Created
March 16, 2019 14:01
-
-
Save AmyrAhmady/0d9c332105b684f95aac274079bfa7ab to your computer and use it in GitHub Desktop.
smh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Memory::HookInit() | |
{ | |
// Init MinHook | |
if (MH_Initialize() != MH_OK) | |
{ | |
printf("[Memory::Init] MH_Initialize failed!\n"); | |
return; | |
} | |
} | |
void Memory::HookCleanUp() | |
{ | |
MH_Uninitialize(); | |
} | |
bool Memory::HookFunction(DWORD64 pAddress, void* pDetour, void** ppOriginal) | |
{ | |
// Create Hook | |
int iResult = MH_CreateHook((void*)pAddress, pDetour, ppOriginal); | |
if (iResult != MH_OK) | |
{ | |
printf("[Memory::HookFunction] MH_CreateHook failed: %I64x [Error %i]\n", pAddress, iResult); | |
MessageBoxA(0, "CreateHook fail", "Fail", 0); | |
return false; | |
} | |
// Enable Hook | |
iResult = MH_EnableHook((void*)pAddress); | |
if (iResult != MH_OK) | |
{ | |
printf("[Memory::HookFunction] MH_EnableHook failed: %I64x [Error %i]\n", pAddress, iResult); | |
MessageBoxA(0, "EnableHook fail", "Fail", 0); | |
return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment