Files
winterknife-EVENSTAR/GetCurrentProcessorNumber

EVENSTAR - GetCurrentProcessorNumber

Version

  • v1.0.0

Brief

  • ISA: x86
  • Mode: Protected, Compatibility, Long
  • Bitness: 32-bit, 64-bit
  • CPL: 0, 3
  • OS: Windows
  • Language: C
  • Sample code that demonstrates the usage of the RDPID, RDTSCP, and the LSL instructions to fetch the current logical processor's ID

Usage

C:\pub\bld>GetCurrentProcessorNumber.exe
[DBG]: [*] GetCurrentProcessorNumber Built Jul  6 2025 16:46:57
Press any key to continue . . .
[DBG]: [+] Logical processor count = 0n2
[DBG]: [+] Pinned all the threads of the current process to logical processor = 0n0
[DBG]: [+] Current logical processor's ID = 0n0
[DBG]: [+] Pinned all the threads of the current process to logical processor = 0n1
[DBG]: [+] Current logical processor's ID = 0n1
Press any key to continue . . .

Tested OS Versions

  • Windows 11 21H2 Build 22000 Revision 675 64-bit

References

  1. Alex Ionescus Blog - Solution to Challenge
  2. Processor Groups
  3. GetCurrentProcessorNumber function (processthreadsapi.h)
  4. Multiple Processors
  5. On pinning and isolating CPU cores
  6. C++11 threads, affinity and hyperthreading
  7. Intel® Intrinsics Guide