Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi How can I get Thread Id from its handle in NtCreateThread(&ThreadHandle) system call or NtCreateThreadEx(&ThreadHandle, ...)?

I try to load thread's information by calling NtQueryInformationThread but this system call fails with ambiguous error code. Now I need a solution to get an ID of thread by its handle in kernel driver with suppressed all restriction in accessing to this ID ,e.g. Permission access.

Thanks in advance
Posted
Updated 18-Jul-15 4:07am
v2

1 solution

In Windows, this is how: https://msdn.microsoft.com/en-us/library/windows/desktop/ms683233%28v=vs.85%29.aspx[^].

Note that the handles are only valid inside a single process (it can be inherited as is by child processes); and the same arithmetic value can be something different or meaningful in other processes. IDs provides unique system-wide identification of threads.

See also: https://msdn.microsoft.com/en-us/library/windows/desktop/ms686746%28v=vs.85%29.aspx[^].

—SA
 
Share this answer
 
v3
Comments
hassan_sayfi69 18-Jul-15 10:31am    
Thank you Sergey for your comment. But how can I load ''kernel32.dll" API in Kernel-Mode driver?
Sergey Alexandrovich Kryukov 18-Jul-15 12:39pm    
I did not realize it would present a problem, sorry. But why can't you? Sorry, I know pretty well how kernel mode works at low level but probably not familiar well with Windows kernel-mode API.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900