Skip to content

Commit

Permalink
Fix RunInstr & trap patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
pongo1231 committed Aug 2, 2023
1 parent 0232879 commit a540289
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ScriptViewer/Memory/Memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Memory

template <typename T> inline void Write(void *pAddr, T value, int count = 1)
{
DWORD_t dwOldProtect;
DWORD dwOldProtect;
VirtualProtect(static_cast<T *>(pAddr), sizeof(T) * count, PAGE_EXECUTE_READWRITE, &dwOldProtect);

for (int i = 0; i < count; i++)
Expand Down
18 changes: 14 additions & 4 deletions ScriptViewer/Memory/ScriptRoutineTracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,23 @@ static void OnHook()

LOG("Hooked rage::scrThread::_RunInstr");

ms_chEnterTrap = handle.At(0x530).Get<char>();
// 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<char>();

ms_chLeaveTrap = handle.At(0x5D7).Get<char>();
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<char>();

LOG("Found LEAVE instruction byte to trap in rage::scrThread::_RunInstr");
}
}
}

Expand Down

0 comments on commit a540289

Please sign in to comment.