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 — aftermov eax, <SSN> executes but before the syscall instruction.
The Technique: Breakpoint-on-Syscall
Core Concept
Instead of reading themov eax, <SSN> opcode, we execute it under a hardware breakpoint and capture the result from the CPU register:
- Set hardware breakpoint (DR0) at the
syscallinstruction address - Call into the NT stub
- When execution hits the breakpoint, our VEH handler fires
- Read EAX from the exception context — it contains the SSN
- Clear the breakpoint and skip the syscall to avoid actual kernel entry
CPU Debug Registers
Register Layout (x64)
| Register | Purpose | Size | Usage |
|---|---|---|---|
| DR0-DR3 | Breakpoint addresses | 64-bit | Hold linear addresses to break on |
| DR4-DR5 | Reserved | — | Aliased to DR6/DR7 on old CPUs |
| DR6 | Debug status | 64-bit | Flags indicating which breakpoint fired |
| DR7 | Debug control | 64-bit | Enable/disable DR0-DR3, set conditions |
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:3. Instrumentation Callbacks
Some EDRs useNtSetInformationProcess(ProcessInstrumentationCallback) to detect debug register manipulation:
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
Use When
Use When
- 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
Avoid When
Avoid When
- 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
| Feature | FreshyCalls | RecycledGate | SyscallsFromDisk | HW Breakpoint |
|---|---|---|---|---|
| Hook resistance | Very High | Maximum | Maximum | Maximum |
| Speed | Fast (~2ms) | Fast (~5ms) | Slow (~15ms) | Slowest (~25ms) |
| Complexity | Low | Medium | Medium | Very High |
| Anti-debug risk | ❌ | ❌ | ❌ | ⚠️ High |
| Opcode dependency | ❌ | Partial | ✅ | ❌ |
| Runtime capture | ❌ | ❌ | ❌ | ✅ |
Usage in SysWhispers4
Generate with Hardware Breakpoints
Integration Example
Detection & Evasion
Observable Behaviors
| Action | EDR Visibility | Kernel Visibility |
|---|---|---|
AddVectoredExceptionHandler | ✅ (user32.dll hook) | ❌ |
SetThreadContext (DR writes) | ✅ (ntdll hook) | ✅ (instrumentation) |
| Debug register usage | ⚠️ (polling) | ✅ (via callbacks) |
| VEH handler execution | ❌ (in-process) | ❌ |
Mitigation Strategies
Technical Deep Dive: Why It Works
Execution Flow
Why Hooks Don’t Matter
Even if an EDR hooks the first bytes with a JMP:- Loading the SSN into EAX
- Executing the
syscallinstruction
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
