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+
3+ #include < jitasm.h>
4+ #include < Hooking.h>
5+
6+ static void * SafeGetSrvFromResource (void * resource)
7+ {
8+ __try
9+ {
10+ void ** vtable = *(void ***)resource;
11+ using GetSrvFn = void * (__fastcall*)(void *);
12+ return ((GetSrvFn)vtable[22 ])(resource); // 0xB0 / sizeof(void*)
13+ }
14+ __except (EXCEPTION_EXECUTE_HANDLER )
15+ {
16+ static bool warned = false ;
17+ if (!warned)
18+ {
19+ warned = true ;
20+ trace (" WARNING: SetTextureResourcesUsingVectorDXAPICall: skipped freed grcProgramResource (vtable AV)\n " );
21+ }
22+ return nullptr ;
23+ }
24+ }
25+
26+ static HookFunction hookFunction ([]
27+ {
28+ static struct : jitasm::Frontend
29+ {
30+ void InternalMain () override
31+ {
32+ sub (rsp, 0x28 );
33+ mov (rax, reinterpret_cast <uintptr_t >(&SafeGetSrvFromResource));
34+ call (rax);
35+ add (rsp, 0x28 );
36+ ret ();
37+ }
38+ } safeSrvStub;
39+
40+ auto location = hook::get_pattern<char >(" 48 8B 01 FF 90 ? ? ? ? 4C 8D 05 ? ? ? ? EB" );
41+ hook::nop (location, 9 );
42+ hook::call (location, safeSrvStub.GetCode ());
43+ });
You can’t perform that action at this time.
0 commit comments