Re-examining SetThreadContext

Mike Hearn mh at codeweavers.com
Mon Feb 7 08:12:58 CST 2005


Alexandre Julliard wrote:
> What makes you think that?  There is no such restriction in the API,
> you can get/set the context without suspending the thread.  The
> obvious use case is a thread setting its own context.

Hmm, you must know something I don't :)

MSDN (I know, I know ...) says:

"You cannot get a valid context for a running thread. Use the 
SuspendThread function to suspend the thread before calling 
GetThreadContext."

and

"If you call GetThreadContext for the current thread, the function 
returns successfully; however, the context returned is not valid."

also

"Do not try to set the context for a running thread; the results are 
unpredictable. Use the SuspendThread function to suspend the thread 
before calling SetThreadContext."

So I'd be surprised if any app actually relies on being able to do those 
things, as it's either not allowed or the results are likely to be garbage.

As for a thread setting its own context, I think it'd be OK to check for 
that and do a FIXME for now. That way if an app really tries to do it, 
we can use some custom assembly to achieve the right effect without 
getting the wineserver involved.

thanks -mike



More information about the wine-devel mailing list