http://www.osronline.com/showThread.cfm?link=26006 if ((CpuNumber != KeGetCurrentProcessorNumber()) && (CpuNumber != 0xffffffff))
{
DbgPrint("OSRx (T): On wrong processor -- changing affinity mask\n");
DbgPrint("OSRx (T): Current CPU number: %d\n",KeGetCurrentProcessorNumber());
AffinityMask = 1 << CpuNumber;
//
// Call ZwSetInformationThread to set the affinity mask which causes the
// correct CPU to be selected when it gets scheduled to execute.
//
ZwSetInformationThread(ThreadHandle, ThreadAffinityMask, &AffinityMask, sizeof(KAFFINITY));
DbgPrint("OSRx (T): Current CPU number: %d\n",KeGetCurrentProcessorNumber());
}
else
{
DbgPrint("OSRx (T): Already executing on requested CPU\n");
}