ImageTally.sys / Windows kernel
Counting image loads in seven instructions
The ImageTally.sys callback receives a process ID, an optional image name and mapping details. Only the process ID affects the result. Each notification adds one to either the driver-image total or the process-image total.
- Specimen
- ImageTally.sys
- Format
- Windows x64 driver
- Binary size
- 4,096 bytes
The deciding argument
The entry routine passes a function address to PsSetLoadImageNotifyRoutine. At that address, the callback tests its second argument in RDX.
A zero process ID selects the driver-image counter. Any nonzero ID selects the process-image counter. Both paths use the same atomic increment.
- 0x1044
test rdx,rdx - 0x1047
setne dl - 0x104A
movzx edx,dl - 0x104D
lea rax,[rip+0xfec] - 0x1054
mov rax,QWORD PTR [rax+rdx*8] - 0x1058
lock add QWORD PTR [rax],0x1 - 0x105D
ret
The only memory write is the increment at 0x1058.
Reading the totals
The unload routine passes the same callback address to PsRemoveLoadImageNotifyRoutine. If removal succeeds, it reports both totals to the kernel debugger. By then, individual events are indistinguishable. Ten process-image notifications could all have come from the same process.
For an anti-cheat investigator, these counts measure load activity. Attributing an event to a particular image or player would require a separate record linking that event to an identity.
Scope of the analysis
The walkthrough follows the compiled callback from its first comparison through its return. The two process IDs illustrate how the same instructions update different counters.
Driver loading, callback delivery, and debugger output on Windows remain unverified.