Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "stdafx.h"
- enum scrThreadState : unsigned int {
- scrThreadStateIdle,
- scrThreadStateRunning,
- scrThreadStateKilled,
- scrThreadState3, // dont know but it wont execute if this is the case (scrThread::Run)
- };
- struct scrThreadContext {
- unsigned int ThreadID; // 0x04
- unsigned int ProgramID; // 0x08 (*.xsc + 0x38)
- scrThreadState ThreadState; // 0x0C
- char _0x10[0x0C];
- unsigned int TimerA; // 0x1C
- unsigned int TimerB; // 0x20
- float WaitTime; // 0x24
- char _0x28[0x1C];
- unsigned int AllocatedStackSize; // 0x40
- char _0x44[0x0C];
- }; // size 0x50
- class scrThread {
- public:
- virtual void scrThread_ctr() {};
- virtual void Reset(int ProgramID, void *Args, int ArgCount) = 0;
- virtual scrThreadState Run(int OpsToExecute) = 0;
- virtual scrThreadState Tick(int OpsToExecute) = 0;
- virtual void Kill() = 0;
- scrThreadContext Context; // 0x04
- void *Stack; // 0x54
- char _0x58[0x0C];
- char *KillMessage; // 0x64
- }; // size 0x68
- class GtaThread : public scrThread {
- public:
- char ThreadName[24]; // 0x68
- char _0x80[0x0C];
- int NumberOfEvents; // 0x8C - not sure
- char _0x90[0x47];
- // char MissionFlag; // 0xD0
- char CanBePaused; // 0xD7
- char CanRemoveBlipsCreatedByAnyScript; // 0xD8
- }; // size unknown
- class ScriptHookThread : public GtaThread {
- protected:
- void Reset(int ProgramID, void *Args, int ArgCount);
- scrThreadState Run(int OpsToExecute);
- scrThreadState Tick(int OpsToExecute);
- void Kill();
- private:
- WORD ThreadIndex;
- PVOID StartAddress;
- public:
- BOOL ScriptInitializedCalled;
- ScriptHookThread(PVOID lpStartAddress, PBOOL Result);
- ~ScriptHookThread();
- };
- // GtaThread scrThread
- // TickThreads() -> GtaThread::Tick() -> scrThread::Tick() -> scrThread::Run()
- // 0x83B435C4 opsToExecute
- // 0x83DCD1E8 currentScriptName
- // 0x83DCD600 globals
- /*
- bool TickThreads(unsigned int opsToExecute)
- {
- if(opsToExecute == 0) {
- opsToExecute = 1000000;
- }
- bool r = false;
- // just enumerates the thread pool then executes the GtaThread::Tick for each thread.
- for(int i = 0; i < ThreadPool->Count; i++) {
- GtaThread *Thread = ThreadPool->Threads[i];
- if(Thread->Context.ThreadID != NULL) {
- Thread::Tick();
- }
- }
- return r;
- }
- If we look at the native TIMERA
- lwz r11, 0(r13) # Load Word and Zero
- li r10, 0x134 # Load Immediate
- lwz r9, 0(r3) # Load Word and Zero
- lwzx r8, r10, r11 # Load Word and Zero Indexed
- lwz r7, 0x1C(r8) # Load Word and Zero
- stw r7, 0(r9) # Store Word
- blr
- makes sense now
- in scrThread::Run the r13 is packed with the GtaThread parameter
- TlsValue(0); // ??
- tls_index_0 + 0x134 = GtaThread
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement