Gevork Sarkisyan

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.

Callback walkthrough RVA / x64 assembly
  1. 0x1044test rdx,rdx
  2. 0x1047setne dl
  3. 0x104Amovzx edx,dl
  4. 0x104Dlea rax,[rip+0xfec]
  5. 0x1054mov rax,QWORD PTR [rax+rdx*8]
  6. 0x1058lock add QWORD PTR [rax],0x1
  7. 0x105Dret

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.