Here is the scenario:
<BR>HANDLE hHandle1 = CreateThread(...);<BR>
now, at some point in the program, you want to know if the current thread is the same as the thread pointed to by hHandle1.
So, you do
<BR>HANDLE hHandle2;<BR>DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hHandle2, 0, FALSE, DUPLICATE_SAME_ACCESS);<BR>
The problem is that you end up having two different handles that might refer to the same thread.
Is there a way to determine if they both do refer to the same thread?
I tried getting the thread Ids from both handles and compare them. But they are different, event when I know the two handles refer to the same thread.
Is there a user mode function similar to the kernel mode function ObReferenceObjectByHandle(); This KM function returns the same pointer for both handles.