Skip to content

Instantly share code, notes, and snippets.

@ergot86
Created March 22, 2024 17:57
Show Gist options
  • Save ergot86/967e8b4aa969cfaa89ff967393a9a012 to your computer and use it in GitHub Desktop.
Save ergot86/967e8b4aa969cfaa89ff967393a9a012 to your computer and use it in GitHub Desktop.

What to debug?

Hyper-v worker process

  • User mode debugging (easy).
  • Symbols available.
  • Attack surface: mostly Gen-1 VMs, device emulation, x86 emulation (for MMIO accesses).

Debugging options:

  1. Attach to running process with WinDbg.
  2. JIT debugger (not recommended):
    • Will be launched as the same user as the (crashing) worker process.
    • Each worker process (one per VM) is launched in an isolated user.
  3. Crash dumps for postmortem.

Root partition / VSPs

Debugging options:

  1. Serial port (slow, not recommended).
  2. USB.
  3. KDNET:
    • What I usually do.
    • Needs a supported NIC but not usually a problem.
  4. Run under nested virtualization:
    • Powerful.
    • But too slow for my taste.
    • I rarely use it.

VMM (hvix64/hvax64)

Debugging options:

  1. Serial port.
  2. KDNET (recommended).
  3. Nested virtualization.
  4. DCI (https://up-shop.org/default/up-xtreme-i11-boards-0000-series.html).

Getting NIC(s) information

Get-NetAdapterHardwareInfo | Format-Table Name,Description,Bus,Device,Function
Get-NetIPAddress -AddressFamily IPv4 | Where-Object { $_.IPAddress -NotLike '169.254.*' -and $_.InterfaceAlias -like "Ethernet*" } | Format-Table InterfaceAlias, IPAddress -AutoSize

Debugging Hyper-V (hvix64) with KDNET

bcdedit /hypervisorsettings NET HOSTIP:192.168.1.13 PORT:50000 BUSPARAMS:2.0.0
bcdedit /set hypervisordebug on
bcdedit /set hypervisorlaunchtype auto

Debugging the Root partition (Windows Kernel) with KDNET

bcdedit /debug on
bcdedit /dbgsettings net hostip:192.168.1.13 PORT:50001
bcdedit /set "{dbgsettings}" busparams 1.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment