diff --git a/ScriptViewer/Memory/Memory.h b/ScriptViewer/Memory/Memory.h index 72dbcb3..58a73a6 100644 --- a/ScriptViewer/Memory/Memory.h +++ b/ScriptViewer/Memory/Memory.h @@ -21,7 +21,7 @@ namespace Memory template inline void Write(void *pAddr, T value, int count = 1) { - DWORD_t dwOldProtect; + DWORD dwOldProtect; VirtualProtect(static_cast(pAddr), sizeof(T) * count, PAGE_EXECUTE_READWRITE, &dwOldProtect); for (int i = 0; i < count; i++) diff --git a/ScriptViewer/Memory/ScriptRoutineTracer.cpp b/ScriptViewer/Memory/ScriptRoutineTracer.cpp index 4515912..9b30e36 100644 --- a/ScriptViewer/Memory/ScriptRoutineTracer.cpp +++ b/ScriptViewer/Memory/ScriptRoutineTracer.cpp @@ -140,13 +140,23 @@ static void OnHook() LOG("Hooked rage::scrThread::_RunInstr"); - ms_chEnterTrap = handle.At(0x530).Get(); + // Use patterns here also (rather than offsets) as these also tend to change between builds - LOG("Found ENTER instruction byte to trap in rage::scrThread::_RunInstr"); + handle = Memory::FindPattern("49 2B ? 48 C1 F8 03 48 3B C1"); + if (handle.IsValid()) + { + ms_chEnterTrap = handle.Get(); - ms_chLeaveTrap = handle.At(0x5D7).Get(); + LOG("Found ENTER instruction byte to trap in rage::scrThread::_RunInstr"); + } - LOG("Found LEAVE instruction byte to trap in rage::scrThread::_RunInstr"); + handle = Memory::FindPattern("49 2B ? 45 85 C9 74 11"); + if (handle.IsValid()) + { + ms_chLeaveTrap = handle.Get(); + + LOG("Found LEAVE instruction byte to trap in rage::scrThread::_RunInstr"); + } } }