diff --git a/SilentPatch/MemoryMgr.h b/SilentPatch/MemoryMgr.h index d35301e..fece197 100644 --- a/SilentPatch/MemoryMgr.h +++ b/SilentPatch/MemoryMgr.h @@ -21,6 +21,11 @@ #include +#ifndef _MEMORY_NO_CRT +#include +#include +#endif + enum { PATCH_CALL, @@ -422,6 +427,15 @@ namespace Memory inline void Patch(AT address, T value) {*(T*)address = value; } +#ifndef _MEMORY_NO_CRT + template + inline void Patch(AT address, std::initializer_list list ) + { + uint8_t* const addr = (uint8_t*)address; + std::copy( list.begin(), list.end(), stdext::checked_array_iterator(addr, list.size()) ); + } +#endif + template inline void Nop(AT address, size_t count) #ifndef _MEMORY_NO_CRT @@ -474,6 +488,14 @@ namespace Memory Memory::Patch(DynBaseAddress(address), value); } +#ifndef _MEMORY_NO_CRT + template + inline void Patch(AT address, std::initializer_list list ) + { + Memory::Patch(DynBaseAddress(address), std::move(list)); + } +#endif + template inline void Nop(AT address, size_t count) { @@ -510,6 +532,17 @@ namespace Memory VirtualProtect((void*)address, sizeof(T), dwProtect[0], &dwProtect[1]); } +#ifndef _MEMORY_NO_CRT + template + inline void Patch(AT address, std::initializer_list list ) + { + DWORD dwProtect[2]; + VirtualProtect((void*)address, list.size(), PAGE_EXECUTE_READWRITE, &dwProtect[0]); + Memory::Patch(address, std::move(list)); + VirtualProtect((void*)address, list.size(), dwProtect[0], &dwProtect[1]); + } +#endif + template inline void Nop(AT address, size_t count) { @@ -553,6 +586,14 @@ namespace Memory VP::Patch(DynBaseAddress(address), value); } +#ifndef _MEMORY_NO_CRT + template + inline void Patch(AT address, std::initializer_list list ) + { + VP::Patch(DynBaseAddress(address), std::move(list)); + } +#endif + template inline void Nop(AT address, size_t count) {