The Windows kernel creates one Kernel Processor Control Region (KPCR) for every logical processor on the system.
This proof-of-concept driver gets the address of all KPCR
s for a given system and stores them in a linked list. All allocated memory is freeded on DriverUnload
.
- We broadcast a Deferred Procedure Call (DPC) to every processor on the system using
KeGenericCallDpc
- When the DPC executes, a call to
KeGetPcr
will occur and a struct of typeEntryCtx
will be allocated from the non-paged memory pool and added as an entry to the doubly-linked list kept in the global variableg_Ctx
of typeContext
- A call to
KeSignalCallDpcSynchronize
will ensure that all DPCs are synchronized before proceeding toKeSignalCallDpcDone
- The main
DriverEntry
thread will be waiting forg_Ctx->DoneEvent
to be signalled, which will occur afterKeSignalCallDpcDone
. This informsDriverEntry
that all DPCs have finished and the linked list can now be traversed.
A kernel-based container implementation such as jxy::vector could instead be used to store all KPCR pointers.
The APIs KeGenericCallDpc
, KeSignalCallDpcSynchronize
and KeSignalCallDpcDone
are undocumented and their usage has been taken out of gbhv/entry.c.