Valhalla Legends Forums Archive | Advanced Programming | Modifying the context of a suspended thread: Not always safe!

AuthorMessageTime
Skywing
I ran into this problem at work today; it took a fair amount of time to debug due to the fact that the thread context I was changing appeared to be modified into something else out of nowhere.

Even though MSDN documents SetThreadContext as safe when used with suspended threads, this is actually not true, as this program demonstrates.

It turns out that you can never safely modify the context of a thread if that thread may have been executing a system service, even if you suspend the thread first. This can be particularly annoying if you are trying to "borrow" a thread in a different program for a task (such as to load a dll of yours).
May 18, 2004, 4:44 AM

Search