Jump to content
Tuts 4 You
Sign in to follow this  
Readme

thread starting

Recommended Posts

Readme

i created a thread using CreateThread succesfully. the problem is that the thread is not directly after creating is executed.


the thread will be executed after calling Sleep().


the thread is not created in suspended mode, but with the creation flag 0 (0 = The thread runs immediately after creation.).


 


but still the thread is not executed direclty.


 


any suggestions?



 invoke CreateThread, 0, 0, addr ThreadProc, NULL, 0, addr dwThreadID
 
invoke Sleep, 200 ; when reaching this code the thread created above should be executed first

Edited by Readme (see edit history)

Share this post


Link to post
Lostin

Alternatively you can use a Boolean global variable and check on a loop from your main thread if its true then execute your code. You set this value to true from your newly created thread. Just a suggestion though.


  • Like 1

Share this post


Link to post
Aguila

You can try the flag THREAD_PRIORITY_HIGHEST


  • Like 1

Share this post


Link to post
Readme

seems to work deepzero and aguila. thanks people 


 


and lostin, thanks for the suggestion


Share this post


Link to post
Peter Ferrie

The whole point of the thread scheduler is that *the scheduler* gets to decide when the thread will execute. Given enough critical-priority threads elsewhere in the system, you can end up with your thread essentially never running at all.

  • Like 1

Share this post


Link to post
JMC31337

The whole point of the thread scheduler is that *the scheduler* gets to decide when the thread will execute. Given enough critical-priority threads elsewhere in the system, you can end up with your thread essentially never running at all.

 

is that helpful for the system or can it be exploited? creating a thread and it never running, doesnt a thread die with the program that creates it?

Edited by JMC31337 (see edit history)

Share this post


Link to post
atom0s

is that helpful for the system or can it be exploited? creating a thread and it never running, doesnt a thread die with the program that creates it?

 

Depending on how the application is exited, it is not guaranteed to hault the threads which will leave the application in a 'hung' state while the threads continue to run.

As Microsoft explains:

 

The thread object remains in the system until the thread has terminated and all handles to it have been closed through a call to CloseHandle.
  • Like 1

Share this post


Link to post
JMC31337

Thread TSR (under a hung app state)

Interesting...

Guess that goes for all OS' vista win7 and sp3?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×
×
  • Create New...