I have a driver which can be invoked from a thread to monitor the performance of that thread, using AMD hardware performance monitors. The hardware will generate an interrupt from time to time and the ISR can then read some information about what the processor was doing at the time of the interrupt.
I want the ISR to be able to verify that the thread just interrupted is the same thread that called the driver initially.
On Windows XP and 7, I can call KeGetCurrentThread() during the initial driver call, save it, and then match this with KeGetCurrentThread() called in the ISR.
On Windows 8, however, I get two different values.
I've also tried PsGetCurrentThreadId(), and again, I get a different value initially from the value I get in the ISR.

Can anyone tell me how to identify the thread that is making the driver call and later being interrupted, so that I get the same number in both cases?