diff --git a/SilentPatch/MemoryMgr.h b/SilentPatch/MemoryMgr.h index b42be77..b637f29 100644 --- a/SilentPatch/MemoryMgr.h +++ b/SilentPatch/MemoryMgr.h @@ -20,6 +20,7 @@ #include #include +#include #ifndef _MEMORY_NO_CRT #include @@ -523,6 +524,14 @@ namespace Memory func = Func(*(ptrdiff_t*)((intptr_t)address+1) + (intptr_t)address + 5); } + template + inline void* ReadCallFrom(AT address, ptrdiff_t offset = 0) + { + uintptr_t addr; + ReadCall( address, addr ); + return reinterpret_cast( addr + offset ); + } + #ifndef _MEMORY_NO_CRT inline bool MemEquals(uintptr_t address, std::initializer_list val) { @@ -531,6 +540,13 @@ namespace Memory } #endif + template + inline AT Verify(AT address, uintptr_t expected) + { + assert( uintptr_t(address) == expected ); + return address; + } + namespace DynBase { template @@ -571,11 +587,23 @@ namespace Memory Memory::ReadCall(DynBaseAddress(address), func); } + template + inline void* ReadCallFrom(AT address, ptrdiff_t offset = 0) + { + return Memory::ReadCallFrom(DynBaseAddress(address), offset); + } + #ifndef _MEMORY_NO_CRT inline bool MemEquals(uintptr_t address, std::initializer_list val) { return Memory::MemEquals(DynBaseAddress(address), std::move(val)); } + + template + inline AT Verify(AT address, uintptr_t expected) + { + return Memory::Verify(address, DynBaseAddress(expected)); + } #endif }; @@ -636,6 +664,12 @@ namespace Memory Memory::ReadCall(address, func); } + template + inline void* ReadCallFrom(AT address, ptrdiff_t offset = 0) + { + return Memory::ReadCallFrom(address, offset); + } + #ifndef _MEMORY_NO_CRT inline bool MemEquals(uintptr_t address, std::initializer_list val) { @@ -643,6 +677,12 @@ namespace Memory } #endif + template + inline AT Verify(AT address, uintptr_t expected) + { + return Memory::Verify(address, expected); + } + namespace DynBase { template @@ -683,12 +723,25 @@ namespace Memory Memory::ReadCall(DynBaseAddress(address), func); } + template + inline void* ReadCallFrom(AT address, ptrdiff_t offset = 0) + { + Memory::ReadCallFrom(DynBaseAddress(address), offset); + } + #ifndef _MEMORY_NO_CRT inline bool MemEquals(uintptr_t address, std::initializer_list val) { return Memory::MemEquals(DynBaseAddress(address), std::move(val)); } #endif + + template + inline AT Verify(AT address, uintptr_t expected) + { + return Memory::Verify(address, DynBaseAddress(expected)); + } + }; }; };