Skip to content

bottomtext228/BTMemory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BTMemory

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();

BTMemory::Patcher

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

BTMemory::VMTHooker::CVMTHook* BTMemory::VMTHooker::Hook(void *pVMT, int iMethodIndex, void *fnHook);
void *BTMemory::VMTHooker::CVMTHook::ApplyHook();
void *BTMemory::VMTHooker::CVMTHook::DestroyHook();

BTMemory::Hooker

CHook* BTMemory::Hooker::Hook(void* fnToHook, void* fnHookCallback, HookType hookType, size_t hookSize = 5);
void* BTMemory::Hooker::CHook::ApplyHook();
void BTMemory::Hooker::CHook::DestroyHook();

Example:

#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

About

x86-x64 Memory library ( patches, NOPs, hooks )

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages