Skip to main content

Overview

Hardware Breakpoint SSN extraction is the most advanced resolution technique in SysWhispers4, using CPU debug registers (DR0-DR3) and a Vectored Exception Handler (VEH) to capture syscall numbers without reading potentially-hooked function bytes. This method extracts SSNs at the exact moment they’re loaded into EAX — after mov eax, <SSN> executes but before the syscall instruction.
Complexity: This technique requires understanding of:
  • x86/x64 debug registers (DR0-DR7)
  • Vectored Exception Handling (VEH)
  • CONTEXT manipulation
  • Single-step exceptions
Use RecycledGate or FreshyCalls unless you specifically need runtime SSN capture.

The Technique: Breakpoint-on-Syscall

Core Concept

Instead of reading the mov eax, <SSN> opcode, we execute it under a hardware breakpoint and capture the result from the CPU register:
Strategy:
  1. Set hardware breakpoint (DR0) at the syscall instruction address
  2. Call into the NT stub
  3. When execution hits the breakpoint, our VEH handler fires
  4. Read EAX from the exception context — it contains the SSN
  5. Clear the breakpoint and skip the syscall to avoid actual kernel entry

CPU Debug Registers

Register Layout (x64)

DR7 Control Register

Setting an Execution Breakpoint

Vectored Exception Handler (VEH)

What is VEH?

VEH allows user-mode applications to register handlers for hardware exceptions before structured exception handling (SEH) runs. Critical for catching debug register breakpoints.

Registration

Handler Structure

Full Implementation

Initialization

Advantages

No Opcode Reading

Never inspects potentially-hooked function bytes — SSN comes from CPU register

Runtime Capture

Extracts actual SSN during execution — guaranteed to match kernel expectations

Hook Proof

Works even if hooks redirect execution — breakpoint fires after SSN is loaded

Educational Value

Demonstrates advanced Windows internals (debug registers, VEH, context manipulation)

Limitations

1. Performance Overhead

Cost: ~20-30ms initialization (vs. ~2ms for FreshyCalls)
  • VEH registration/removal
  • Setting debug registers per function (~64 times)
  • Exception handling overhead
  • Context switching

2. Anti-Debug Detection

Using DR0-DR3 may trigger anti-debug checks by EDRs:
Mitigation: Clear DR7 immediately after each capture.

3. Instrumentation Callbacks

Some EDRs use NtSetInformationProcess(ProcessInstrumentationCallback) to detect debug register manipulation:
Detection: EDR receives notification when SetThreadContext modifies DR0-DR7.

4. Complexity

Highest complexity of all SSN resolution methods:
  • VEH management
  • Debug register programming
  • Exception handling
  • Edge case handling (hooked VEH APIs, thread state issues)

When to Use Hardware Breakpoints

  • Research/PoC demonstrating advanced techniques
  • Maximum paranoia + willingness to accept performance cost
  • Exotic EDR that defeats all other methods (extremely rare)
  • Educational purposes — learning Windows internals
  • Performance matters — use FreshyCalls or RecycledGate
  • Production operations — complexity increases failure risk
  • Anti-debug present — DR register usage is a detection vector
  • Simpler methods work — don’t over-engineer

Comparison with Other Methods

Usage in SysWhispers4

Generate with Hardware Breakpoints

Integration Example

Detection & Evasion

Observable Behaviors

Mitigation Strategies

1

Clear debug registers immediately

Don’t leave DR0-DR3 set after capture:
2

Use indirect syscall invocation

Keep RIP inside ntdll:
3

Combine with anti-instrumentation checks

Detect if ProcessInstrumentationCallback is set:

Technical Deep Dive: Why It Works

Execution Flow

Why Hooks Don’t Matter

Even if an EDR hooks the first bytes with a JMP:
The EDR handler must eventually execute the real syscall, which means:
  1. Loading the SSN into EAX
  2. Executing the syscall instruction
Our hardware breakpoint catches step 2, after step 1 completes — we still capture the SSN.

Further Reading

LayeredSyscall Research

White Knight Labs on VEH abuse

Intel SDM: Debug Registers

Official documentation (Vol. 3, Chapter 17)

RecycledGate

Simpler alternative with excellent hook resistance

FreshyCalls

Fast default method for most use cases