File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed
code/components/gta-core-five/src Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change
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
+ });
You can’t perform that action at this time.
0 commit comments