2026-11-28 Aggressive Kernel Anticheat Strategies for Good
CrowdStrike? Never heard of her

This article is an expanded technical explanation of the NMI stackwalking strategy explained in the talk “Pay 2 Win: What Anti-Cheat Catches That Your EDR Doesn’t” at Nullcon 2026 in Berlin. This talk was made in cooperation with my colleague Ray Goh, an Incident Response Consultant at Mandiant. Unfortunately, I wasn’t able to attend because I had to cram for finals at NTU. This article expands on some of the technical details that might’ve been missed because of the talk’s time limit.
In my previous blog post about ETW-TI, I talked about how PatchGuard made the old SSDT and inline-hook free-for-all a pretty good way to brick your customer devices. After the advent of 64-bit Windows, hooking the System Service Dispatch Table (SSDT) became a no-go once Kernel Patch Protection (PatchGuard) shipped with the x64 editions of Windows XP and Server 2003 SP1 in 2005, since KPP bugchecks the machine when it detects SSDT patching. On 32-bit Windows, which never had KPP, SSDT hooking stayed viable for years afterward. Either way, it discouraged much of the industry from writing questionable code into the kernel.
Most EDR providers began to scan memory for suspicious allocations to catch these types of IOCTL attacks, but a PE header alone is not evidence of execution. But in some anticheat implementations, vendors have resorted to trapping control-flow transitions across a target boundary with EPT. I wanted to build a similar approach by pushing interrupts to the processor, recovering its actual pre-interrupt RIP and call chain, then asking whether those addresses belong to executable sections of inventoried images.
Windows, of course, gives some telemetry to detect these types of attacks via authorized APIs, like the loaded image ranges through AuxKlibQueryModuleInformation. My approach takes an inventory before and after each capture round, as a changed inventory makes the round incomplete. The detection predicate is intentionally boring: check base <= PC < base + image size, then check whether the matching PE section has IMAGE_SCN_MEM_EXECUTE. This gives us additional telemetry that can be used for detection of unsigned code execution, without relying on usual detection signatures like file names, driver signatures, or vulnerable-driver hashes.
Implementation
The driver registers an NMI callback and rotates a sender CPU across rounds. The sender targets the other active processors through the pinned HalSendNMI export. Excluding the sender avoids filling every capture with the detection agent’s own pulse path. The callback’s registers belong to the NMI dispatcher, so the little MASM entry shim first spills them with a generated C/MASM ABI. Then SIDT, SGDT and STR locate vector 2’s IST through the IDT and TSS:
NuReadTables PROC
sidt fword ptr [rcx]
sgdt fword ptr [rcx+16]
str ax
mov word ptr [rcx+32], ax
ret
NuReadTables ENDP
On the Windows 11 26200.9711 build of ntoskrnl, the hardware frame is five qwords at the aligned IST top. The first qword is the interrupted RIP; the fourth is the interrupted RSP. The script tries to validate the gate, TSS descriptor, stack range and alignment:
top = *(volatile UINT64*)(ULONG_PTR)(tss + 36 + (ist - 1) * 8);
top &= ~15ull;
if (!NuKernel(top) || EntryRsp > top - 40 || top - EntryRsp > 0x10000)
return FALSE;
*Top = top;
*Frame = (UINT64*)(ULONG_PTR)(top - 40);
A per-CPU slot moves from WAITING to WRITING with a compare-and-swap. The callback copies the NMI stack, then checks the interrupted thread’s KTHREAD.StackLimit/StackBase before copying up to 64 KiB from its kernel stack (the NMI-side buffer is capped at 8 KiB). So if the bounds or architecture checks fail, the sample carries flags instead of a made-up trace.
previous = InterlockedCompareExchange(&slot->State, NU_WRITING, NU_WAITING);
if (previous != NU_WAITING) goto done;
After NuMachineFrame succeeds, the machine-frame values are copied into the sample:
s->InterruptedRip = frame[0];
s->InterruptedCs = frame[1];
s->InterruptedFlags = frame[2];
s->InterruptedRsp = frame[3];
if (size > d->CaptureBytes) {
size = d->CaptureBytes;
s->Flags |= NU_F_THREAD_TRUNCATED;
}
s->Stack.Size = size;
NuCopyBytes(s->StackBytes, (PVOID)(ULONG_PTR)s->Stack.Base, size);
NuCopyBytes is a REP MOVSB loop, not a call into the memory manager. These are separate excerpts from NuCapture; the actual gate and bounds checks sit around them. Windows’ KiNmiInterrupt and KxNmiInterrupt save the pre-interrupt GPRs, but KeRegisterNmiCallback does not hand those saves to us as a CONTEXT. The script reconstructs them offline from the pinned save layout and checks both handler return slots before trusting an offset:
if (!get(f-0x170, kiReturn) || !get(f-0x2b0, kxReturn) ||
kiReturn != kernel.Base + NU_TARGET_KI_RETURN ||
kxReturn != kernel.Base + NU_TARGET_KX_RETURN)
return reject("HANDLER_RETURN_SLOTS");
RSI is the entertaining one, as KiNmiInterrupt clobbers its live value before the later save, so the original comes from its earlier push at F-0x18. The volatile saves and other nonvolatiles come from different slots. These offsets were derived from the matching kernel and public PDB; the script checks the loaded image identity and selected instruction bytes before arming.
After capture, the collector disarms, drains the slots and calls StackWalk64 in user mode. Its read callback serves bytes from the NMI and thread snapshots; the function-table callback serves .pdata records from matching PE images. If the NMI hits while a function is starting or returning, some of its stack changes have already happened and some haven’t. StackWalk64 uses Windows’ records of those changes to find the caller.
const BOOL advanced=step(IMAGE_FILE_MACHINE_AMD64,GetCurrentProcess(),GetCurrentThread(),
&frame,&c,readMemory,functionTable,moduleBase,nullptr);
if(!advanced)return finish(WalkResult::Incomplete,w.ReadFailed?"read_failure":"unwind_failure");
The first address is where the CPU was when the NMI hit. If a return address sits just past the end of a code section, it checks the byte before it (PC-1) to see which section it came from. If it cannot read the image or stack data it needs, it stops.
if(!m){f.Kind=FrameKind::OutsideModules;return f;}
f.Image=m->Name;
if(!m->Image){f.Kind=FrameKind::MissingImage;return f;}
f.Kind=m->Image->executable(f.LookupPc-m->Base)
?FrameKind::ImageCode:FrameKind::NonExecutableImage;
The four outputs are NMI_UNOWNED_RIP, NMI_UNOWNED_CALLER, NMI_RIP_OUTSIDE_EXECUTABLE_SECTIONS and NMI_CALLER_OUTSIDE_EXECUTABLE_SECTIONS. The RIP findings describe observed execution; the caller findings describe recovered return addresses. Neither says anything about signing. The executable-section test reads archived PE headers, not live PTE permissions or runtime code bytes.
Why?
This started with a very simple thought experiment: what if EDRs worked as aggressively as anticheats? While Western EDRs are typically very skittish about crossing the usermode/kernel boundary, Chinese EDRs have been using aggressive detection strategies for ages. Kingsoft filed a patent describing a system that disassembles NtTerminateProcess, finds its call to ObReferenceObjectByHandle, and hooks the call site. The proposed driver checks which process the handle refers to and denies termination if the path belongs to Kingsoft Antivirus. It also applies the same trick to NtTerminateJobObject and NtAssignProcessToJobObject. The patent even gives FF 75 0C E8 as the bytes to search for in NtTerminateProcess (but I’m pretty sure modern x86 Windows builds don’t use this pattern anymore).
There is PoC on how to bypass NMI callbacks in Windows 10 22H2. But while KiProcessNMI still calls through HalPrivateDispatchTable+0x3e8 twice before it walks the NMI callback list, the PoC’s callback-list signature has zero matches in Windows 11, and its five-byte PoIdle pattern has three. Windows 11’s memory integrity protections also blocks writes to executable kernel pages (but this PoC changes a pointer in the HAL’s data table, so i guessthat protection alone does not stop it).
| Previous · Win10 22H2 · 19041.5678 | Now · Win11 25H2 · 26200.9711 | ||
|---|---|---|---|
| @@ nt!KiProcessNMI: HalPreprocessNmi(0) @@ | |||
| 51336c | mov rax, [HalPrivateDispatchTable+3e8h]48 8B 05 05 D6 6E 00 | 5b896d | mov rax, [HalPrivateDispatchTable+3e8h]48 8B 05 64 82 84 00 |
| 513376 | xor ecx, ecx33 C9 | 5b8977 | xor ecx, ecx33 C9 |
| 51337b | call _guard_dispatch_icallE8 B0 51 EF FF | 5b897c | call _guard_dispatch_icallE8 4F 21 10 00 |
| @@ exits after HAL(0), before the callback walk @@ | |||
| 5133aa | test al, al84 C0 | 5b89a5 | test al, al84 C0 |
| 5133ac | jne 5134bd0F 85 0B 01 00 00 | 5b89a7 | jne 5b8a710F 85 C4 00 00 00 |
| 513404 | test rax, r84C 85 C0 | 5b89c7 | test eax, eax85 C0 |
| 513407 | jne 5134bd0F 85 B0 00 00 00 | 5b89c9 | jne 5b8a710F 85 A2 00 00 00 |
| @@ callback path: HalPreprocessNmi(1) @@ | |||
| 51340d | mov rax, [HalPrivateDispatchTable+3e8h]48 8B 05 64 D5 6E 00 | 5b89cf | mov rax, [HalPrivateDispatchTable+3e8h]48 8B 05 02 82 84 00 |
| 513414 | mov ecx, ebx ; ebx = 18B CB | 5b89da | mov ecx, r12d ; r12d = 141 8B CC |
| 513416 | call _guard_dispatch_icallE8 15 51 EF FF | 5b89dd | call _guard_dispatch_icallE8 EE 20 10 00 |
| @@ callback list: the PoC scans for the two old lines @@ | |||
| 51341b | mov rdi, [KiNmiCallbackListHead]48 8B 3D 4E E0 71 00 | 5b89e2 | mov rbx, [KiNmiCallbackListHead]48 8B 1D BF EB 98 00 |
| 513422 | mov sil, r12b41 8A F4 | 5b89e9 | mov dil, r15b41 8A FF |
| @@ callback loop @@ | |||
| 51342a | mov rax, [rdi+8]48 8B 47 08 | 5b89f1 | mov rax, [rbx+8]48 8B 43 08 |
| 51342e | mov dl, sil40 8A D6 | 5b89f5 | mov dl, dil40 8A D7 |
| 513431 | mov rcx, [rdi+10h]48 8B 4F 10 | 5b89f8 | mov rcx, [rbx+10h]48 8B 4B 10 |
| 513435 | call _guard_dispatch_icallE8 F6 50 EF FF | 5b89fc | call _guard_dispatch_icallE8 CF 20 10 00 |
| 51343a | mov rdi, [rdi]48 8B 3F | 5b8a01 | mov rbx, [rbx]48 8B 1B |
| @@ nt!PoIdle: first five bytes @@ | |||
| 23e4c0 | push rbp; push rbx; push r1440 55 53 41 56 | 2cfb40 | mov [rsp+8], rbx48 89 5C 24 08 |
But the main issue is that the hook can change the saved RIP and RSP and point CurrentThread at the idle thread before NuCapture reads any of them. Bubblewalk’s two copies of the machine frame would then agree because both were taken after the edit, so a fake RSP alone leaves the real RIP exposed, while an RSP outside the thread’s stack bounds gets the sample marked STACK_UNSUPPORTED and discarded.
Runtime stability is also the issue, as this bypass saves the old frame per CPU, but callback_parent and restore_callback are shared. If two CPUs take an NMI at once, they can both edit the same callback list (one restore can remove the other’s link) leaving its machine frame or CurrentThread spoofed when Windows returns from the NMI. The fixed InitialStack-0x38 guess is another gamble on Windows 11, it has to fall inside the idle thread’s stack bounds and give StackWalk64 enough real bytes to unwind.
There is a reason why aggressive kernel hooks are really iffy for vendors, especially after the major CrowdStrike outage left a bad taste in many enterprise customers’ mouths. Solutions such as the Windows Endpoint Security Platform also aim to lessen the dependence on aggressive kernel hooks. I’m not telling EDR firms to ship this; I just wanted to see what it would look like in malware detection.
Plus it’s funny lol.
Afterword, and parting thoughts
As 2026 comes to a close, it has become a personal goal of mine to deepen my involvement in the global security research scene. At the same time, I think several research areas I frequented have become really crowded (especially with the advent of vibe-security-researching), and the last thing I want is to be a one-trick pony.
I hope next year I can branch out to work on more things. I’ve also been in active discussions about doing more varied research pieces that are further outside my comfort zone. I’m still a blue teamer and a low-level programmer at heart, and that’s still gonna be my focus moving forward. But I hope to bring more variety to my work and research. Cheers to what’s to come in 2027 ヘ( ^o^)ノ\(^_^ )!