I want to get a threads context structure (GetThreadContext) on the breakpoint exception debug event. However the event information only gives me the thread ID, and GetThreadContext wants a thread handle.
Is there a way to get the handle from an ID?


Posted on 2002-03-05 12:50:03 by Thomas
have a look at OpenThread
Posted on 2002-03-05 12:54:03 by f0dder
Thanks, I was looking for that function, as OpenProcess exists as well. However it wasn't in my MSDN version (on CD) which isn't surprising as it's one from '98 :rolleyes: .. so I totally missed it.
It's the only version I had available on CD. I've tried downloading the PSDK more than once but each time some .cab files were corrupt.

Posted on 2002-03-05 13:01:48 by Thomas
Hrm, bummer:

Windows NT/2000/XP: Included in Windows 2000 and later.
Windows 95/98/Me: Included in Windows Me
Posted on 2002-03-05 13:06:55 by f0dder
Yeah I noticed that but it isn't really a problem. It's for a little tool for my own use to hook winsock calls and dump the info that is received and sent.. I wasn't planning to support win9x anyway as I already used the NT only PSAPI. But it doesn't matter as I'm using win2k myself.

Posted on 2002-03-05 13:18:53 by Thomas
from win32api.hlp
The Win32 API does not provide a way to get the thread handle from the thread identifier. If the handles were made available this way, the owning process could fail because another process unexpectedly performed an operation on one of its threads, such as suspending it, resuming it, adjusting its priority, or terminating it. Instead, you must request the handle from the thread creator or the thread itself.
Posted on 2002-03-05 16:22:36 by NEMO
NEMO: strange.. OpenProcess works great though.. the win32api help file is a little outdated...

Posted on 2002-03-05 16:36:01 by Thomas
win32api.hlp == old ;)
Posted on 2002-03-05 19:39:27 by f0dder
s**t....... i have to buy MSDN lib:grin:
Posted on 2002-03-06 03:04:12 by NEMO