-2

Hello i'm trying to pause a thread, but for some reason it keeps crashing the game. here is what i got

void Test(){
    SuspendThread((PVOID)0x83593C24);//0x83593C24 The offset from the game
    Scr_AddInt(1);
    ResumeThread((PVOID)0x83593C24);
}

Basically i'm trying to pause than call Add Int than resume it

user207421
  • 305,947
  • 44
  • 307
  • 483
HorseFrog
  • 11
  • 1
  • 2
    A thread **is not** some memory address. Look for thread id and process id. – Deduplicator Jul 20 '14 at 00:22
  • i fount the threadid which is 0x8354F7A8 but i don't see the processid http://gyazo.com/13a976b7993ce574ff9489d82110f1cc – HorseFrog Jul 20 '14 at 00:24
  • That looks much too big for a thread-id... – Deduplicator Jul 20 '14 at 00:46
  • I think you'll need to provide more information, like what your platform is (PowerPC?); what library provides `SuspendThread` and `ResumeThread`; and what compiler/threading libraries you're using; and what that crazy assembler is. – NicholasM Jul 20 '14 at 00:55
  • im using VS2012 to compile my code. the pic i provided is IDA Pro displaying PowerPC code. and the libraries SuspendThread and ResumeThread are in winbase.h – HorseFrog Jul 20 '14 at 01:06
  • 'In memory' has nothing to do with this question. All threads are in memory. – user207421 Jul 20 '14 at 02:35

1 Answers1

0

You need to use the thread handle that was returned when you created the thread. See documentation for CreateThread; SuspendThread; and ResumeThread.

In particular, from the documentation for CreateThread:

If the function succeeds, the return value is a handle to the new thread. If the function fails, the return value is NULL.

Example:

HANDLE thread_handle = CreateThread(/*args*/);  // hold on to this value (and check for failure)
if (thread_handle == NULL)
{
    // handle creation error
} 

DWORD suspend_retval = SuspendThread(thread_handle); 
if (suspend_retval == static_cast<DWORD>(-1))
{ 
    // handle suspend error
}

Scr_AddInt(1);  // original work  

DWORD resume_retval = ResumeThread(thread_handle);
if (resume_retval == static_cast<DWORD>(-1))
{ 
    // handle resume error
}

It may be worthwhile to create a wrapper class that encapsulates thread creation, suspension, resumption, and termination. This class can perform all error checking internally, and throw an exception when appropriate.

NicholasM
  • 4,557
  • 1
  • 20
  • 47