Code:
typedef bool(__fastcall* token2guid)(const char*, unsigned int, ObjectGuid*, bool);
token2guid TokenGUIDFunc = (token2guid)(void*)offsets::GetGUIDFromToken;//(rebase)
bool __fastcall testFunc(const char* token, unsigned int Unknown1, ObjectGuid* guid, bool Unknown2)
{
return TokenGUIDFunc(token, Unknown1, guid, Unknown2);
}
void Hook()
{
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)TokenGUIDFunc, testFunc);
DetourTransactionCommit();
}
I tried detours4.01 but there is No effect
then I want to rewrite some, but can’t write memory Error.
Code:
bool Hook(void* toHook, void* hk_func, int len) {
if (len < 13)
return false;
DWORD curProtection;
VirtualProtect(toHook, len, PAGE_EXECUTE_READWRITE, &curProtection);
memset(toHook, 0x90, len);
unsigned char patch[] = {
0x50, 0x48, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xE0
};
*(DWORD64*)&patch[3] = (DWORD64)hk_func;
memcpy((void*)toHook, patch, sizeof(patch));
DWORD temp;
VirtualProtect(toHook, len, curProtection, &temp);
return true;
}