Skip to content

Commit 637187b

Browse files
committed
fix(gta-core-five): scenario model validation
1 parent 6a79648 commit 637187b

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include <StdInc.h>
2+
#include <Hooking.h>
3+
#include <Hooking.Stubs.h>
4+
#include <jitasm.h>
5+
6+
static HookFunction hookFunction([]
7+
{
8+
auto location = hook::get_pattern<uint8_t>("48 8B 82 ? ? ? ? 8B 48 ? 89 8F");
9+
10+
static struct : jitasm::Frontend
11+
{
12+
intptr_t location;
13+
intptr_t retSuccess;
14+
intptr_t retFail;
15+
16+
uint32_t compositeBoundFlagsArrayOffset;
17+
18+
void Init(intptr_t location)
19+
{
20+
this->location = location;
21+
this->retSuccess = location + 10;
22+
this->retFail = location + 30;
23+
24+
this->compositeBoundFlagsArrayOffset = *(uint32_t*)(location + 3);
25+
}
26+
27+
void InternalMain() override
28+
{
29+
mov(rax, qword_ptr[rdx + this->compositeBoundFlagsArrayOffset]); // [original code]
30+
//
31+
test(rax, rax); // if ( flagArray )
32+
jz("fail"); // {
33+
//
34+
mov(ecx, dword_ptr[rax + 4 /* hardcoded, hasn't changed */]); // [original code]
35+
//
36+
mov(rax, retSuccess); //
37+
jmp(rax); // }
38+
//
39+
L("fail"); //
40+
//
41+
mov(rax, retFail); //
42+
jmp(rax); //
43+
}
44+
} patchStub;
45+
46+
patchStub.Init(reinterpret_cast<intptr_t>(location));
47+
/**
48+
* nop's:
49+
*
50+
* mov rax, [rdx+90h]
51+
* mov [rax+4], ecx
52+
*/
53+
hook::nop(location, 10);
54+
hook::jump(location, patchStub.GetCode());
55+
});

0 commit comments

Comments
 (0)