x86-x64 Memory library ( patches, NOPs, hooks )
uintptr_t FindSignature(const char* moduleName, const void* signatureString, const char* mask);
uintptr_t FindDMAAddy(uintptr_t baseAddress, std::vector<unsigned int> offsets);
void UnpatchAll();
CPatch* BTMemory::Patcher::Patch(uintptr_t destination, const void* patchBytes, size_t patchSize, bool isSimple = false);
CPatch* BTMemory::Patcher::Nop(uintptr_t destination, size_t patchSize, bool isSimple = false);
void BTMemory::Patcher::CPatch::ApplyPatch();
void BTMemory::Patcher::CPatch::RestorePatch();
void BTMemory::Patcher::CPatch::DestroyPatch();
BTMemory::VMTHooker::CVMTHook* BTMemory::VMTHooker::Hook(void *pVMT, int iMethodIndex, void *fnHook);
void *BTMemory::VMTHooker::CVMTHook::ApplyHook();
void *BTMemory::VMTHooker::CVMTHook::DestroyHook();
CHook* BTMemory::Hooker::Hook(void* fnToHook, void* fnHookCallback, HookType hookType, size_t hookSize = 5);
void* BTMemory::Hooker::CHook::ApplyHook();
void BTMemory::Hooker::CHook::DestroyHook();
#include "BTMemory.h"
// Assault Cube no recoil
DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) {
switch (dwReason) {
case DLL_PROCESS_ATTACH:
static auto* noRecoilNop = BTMemory::Patcher::Nop((DWORD)GetModuleHandle(NULL) + 0x63786, 10); // nop the function call
// or
//static BTMemory::CPatch* noRecoilPatch = BTMemory::Patch((DWORD)GetModuleHandle(NULL) + 0x62020, "\xC2\x80\x00", 3); // "ret 08" to prevent execution of function
noRecoilNop->ApplyPatch();
break;
case DLL_PROCESS_DETACH:
BTMemory::UnpatchAll(); // restore original bytes and deletes allocated memory for them
break;
}
return TRUE;
}
Other examples at main.cpp