diff --git a/code/components/rage-scripting-five/include/scrThread.h b/code/components/rage-scripting-five/include/scrThread.h index 870907908f..e360b3c1e3 100644 --- a/code/components/rage-scripting-five/include/scrThread.h +++ b/code/components/rage-scripting-five/include/scrThread.h @@ -190,30 +190,38 @@ struct scrThreadContext static_assert(sizeof(scrThreadContext) == 168, "scrThreadContext has wrong size!"); -class +class #ifdef COMPILING_RAGE_SCRIPTING_FIVE - __declspec(dllexport) +__declspec(dllexport) #endif - scrThread +scrThread { protected: - scrThreadContext m_Context; - void* m_pStack; // should be +176 including vtable - void* pad; - void* pad2; + scrThreadContext m_Context; + void* m_pStack; // should be +176 including vtable + void* pad; + void* pad2; // should be +200 - const char* m_pszExitMessage; + const char* m_pszExitMessage; public: - virtual void __dummyMethod1() {} - virtual ~scrThread() {} - virtual eThreadState Reset(uint32_t scriptHash, void* pArgs, uint32_t argCount) = 0; - virtual eThreadState Run(uint32_t opsToExecute) = 0; - virtual eThreadState Tick(uint32_t opsToExecute) = 0; - virtual void Kill() = 0; - - scrThreadContext* GetContext() { return &m_Context; } + virtual uint64_t proxyMethod1(uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4); + virtual uint64_t proxyMethod2(uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4); + virtual uint64_t proxyMethod3(uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4); + virtual uint64_t proxyMethod4(uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4); + virtual uint64_t proxyMethod5(uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4); + virtual uint64_t proxyMethod6(uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4); + + virtual eThreadState Reset(uint32_t scriptHash, void* pArgs, uint32_t argCount) = 0; + virtual eThreadState Run(uint32_t opsToExecute) = 0; + virtual eThreadState Tick(uint32_t opsToExecute) = 0; + virtual void Kill() = 0; + + scrThreadContext* GetContext() + { + return &m_Context; + } }; } @@ -241,30 +249,13 @@ class char pad_b2699[8]; public: - GtaThread() - { - if (!xbr::IsGameBuildOrGreater<3407>()) - { - auto vtable = *(void***)this; - DWORD oldProtect; - VirtualProtect(vtable, 5 * 8, PAGE_EXECUTE_READWRITE, &oldProtect); - - for (int i = 0; i < 5; i++) - { - vtable[i] = vtable[i + 1]; - } - - VirtualProtect(vtable, 5 * 8, oldProtect, &oldProtect); - } - } - - virtual void DoRun() = 0; - virtual rage::eThreadState Reset(uint32_t scriptHash, void* pArgs, uint32_t argCount); virtual rage::eThreadState Run(uint32_t opsToExecute); virtual rage::eThreadState Tick(uint32_t opsToExecute); virtual void Kill(); + virtual void DoRun() = 0; + inline void SetScriptName(const char* name) { if (xbr::IsGameBuildOrGreater<2699>()) diff --git a/code/components/rage-scripting-five/src/scrThread.cpp b/code/components/rage-scripting-five/src/scrThread.cpp index 0d88c65904..12d227b8c4 100644 --- a/code/components/rage-scripting-five/src/scrThread.cpp +++ b/code/components/rage-scripting-five/src/scrThread.cpp @@ -115,3 +115,70 @@ static hook::thiscall_stub setVectorResults([ { return hook::pattern("83 79 18 00 48 8B D1 74 4A FF 4A 18").count(1).get(0).get(); }); + +uint64_t rage::scrThread::proxyMethod1(uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4) +{ + return 0; +} + +uint64_t rage::scrThread::proxyMethod2(uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4) +{ + if (xbr::IsGameBuildOrGreater<3407>()) + { + return 0; + } + else + { + return Reset((uint32_t)a1, (void*)a2, (uint32_t)a3); + } +} // Reset or dtor + +uint64_t rage::scrThread::proxyMethod3(uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4) +{ + if (xbr::IsGameBuildOrGreater<3407>()) + { + return Reset((uint32_t)a1, (void*)a2, (uint32_t)a3); + } + else + { + return Run((uint32_t)a1); + } +} // Run or Reset + +uint64_t rage::scrThread::proxyMethod4(uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4) +{ + if (xbr::IsGameBuildOrGreater<3407>()) + { + return Run((uint32_t)a1); + } + else + { + return Tick((uint32_t)a1); + } +} // Run or Reset + +uint64_t rage::scrThread::proxyMethod5(uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4) +{ + if (xbr::IsGameBuildOrGreater<3407>()) + { + return Tick((uint32_t)a1); + } + else + { + Kill(); + return 0; + } +} // Tick or Run + +uint64_t rage::scrThread::proxyMethod6(uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4) +{ + if (xbr::IsGameBuildOrGreater<3407>()) + { + Kill(); + return 0; + } + else + { + return 0; + } +} // Kill or Tick