Skip to content

Commit a540289

Browse files
author
pongo1231
committed
Fix RunInstr & trap patterns
1 parent 0232879 commit a540289

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

ScriptViewer/Memory/Memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace Memory
2121

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

2727
for (int i = 0; i < count; i++)

ScriptViewer/Memory/ScriptRoutineTracer.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,23 @@ static void OnHook()
140140

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

143-
ms_chEnterTrap = handle.At(0x530).Get<char>();
143+
// Use patterns here also (rather than offsets) as these also tend to change between builds
144144

145-
LOG("Found ENTER instruction byte to trap in rage::scrThread::_RunInstr");
145+
handle = Memory::FindPattern("49 2B ? 48 C1 F8 03 48 3B C1");
146+
if (handle.IsValid())
147+
{
148+
ms_chEnterTrap = handle.Get<char>();
146149

147-
ms_chLeaveTrap = handle.At(0x5D7).Get<char>();
150+
LOG("Found ENTER instruction byte to trap in rage::scrThread::_RunInstr");
151+
}
148152

149-
LOG("Found LEAVE instruction byte to trap in rage::scrThread::_RunInstr");
153+
handle = Memory::FindPattern("49 2B ? 45 85 C9 74 11");
154+
if (handle.IsValid())
155+
{
156+
ms_chLeaveTrap = handle.Get<char>();
157+
158+
LOG("Found LEAVE instruction byte to trap in rage::scrThread::_RunInstr");
159+
}
150160
}
151161
}
152162

0 commit comments

Comments
 (0)