Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a handle to the process's main thread

I have created an additional thread in some small testing app and want to suspend the main thread from this additional thread. The additional thread is created via CreateRemoteThread from an external process.

Since SuspendThread needs a HANDLE to the thread which should be suspended, I want to know how to get this HANDLE from code running in my additional thread.

like image 604
Etan Avatar asked Dec 28 '09 13:12

Etan


1 Answers

I don't think there is anything that differentiates the main thread from other threads once the process has started. However, you can enumerate all threads in the process, and use GetThreadTimes to find the thread with the earliest creation time. Call OpenThread to get a HANDLE from a thread ID.

like image 58
interjay Avatar answered Oct 13 '22 19:10

interjay