File tree Expand file tree Collapse file tree
code/components/gta-core-five/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #include " StdInc.h"
2+ #include " CrossBuildRuntime.h"
3+ #include < Hooking.h>
4+ #include < jitasm.h>
5+
6+ constexpr int kMaxBlipLegend = 256 ;
7+
8+ static HookFunction hookFunction ([]()
9+ {
10+ if (!xbr::IsGameBuildOrGreater<2372 >()) return ;
11+
12+ static struct : jitasm::Frontend
13+ {
14+ intptr_t toJae, toNext;
15+
16+ void Init (intptr_t jTarget, intptr_t nTarget)
17+ {
18+ toJae = jTarget;
19+ toNext = nTarget;
20+ }
21+
22+ void InternalMain () override
23+ {
24+ cmp (r8w, kMaxBlipLegend );
25+ jae (" maxBlipReached" );
26+ mov (rax, toNext);
27+ jmp (rax);
28+ L (" maxBlipReached" );
29+ mov (rax, toJae);
30+ jmp (rax);
31+ }
32+ } stub;
33+
34+ const char * pattern = xbr::IsGameBuildOrGreater<3407 >()
35+ ? " 66 44 3B C0 73 ? 44 8B 74 24 30 EB"
36+ : " 66 41 83 F8 ? 73 ? 44 8B 74 24 30 EB" ;
37+
38+ const int jaeOffset = xbr::IsGameBuildOrGreater<3407 >() ? 4 : 5 ;
39+
40+ auto location = hook::get_pattern<char >(pattern);
41+ auto jae = location + jaeOffset;
42+ const int8_t disp = *(int8_t *)(jae + 1 );
43+ const intptr_t toJae = (intptr_t )(jae + 2 + disp);
44+ const intptr_t toNext = (intptr_t )(jae + 2 );
45+
46+ stub.Init (toJae, toNext);
47+
48+ hook::nop (location, jaeOffset + 2 );
49+ hook::jump (location, stub.GetCode ());
50+ });
You can’t perform that action at this time.
0 commit comments