logo
Kurashizu Blogwhere ideas flow
  • Home
  • News
  • Blog
  • About
  • Home
  • News
  • Blog
  • About

© 2026 Kurashizu. All rights reserved.

Admin·New Post·Service Status
Powered by Cloudflare·03.11.26
← Back to news

WinPE as a stateless harness for Windows driver testing and fuzzing

Original article
bednars.me|64 points|4 comments|by piotrbednarsalt|Jun 28, 2026

Utilizing WinPE as a Stateless Framework for Windows Driver Fuzzing and Testing

Recently, I have been exploring two distinct but related engineering challenges within the realm of low-level automation.

The Core Challenges

  1. CI/CD Orchestration for Windows: Establishing reproducible and deterministic environments for end-to-end (E2E) testing of Windows systems is notoriously inefficient and costly. For those managing a Kernel-Mode Driver Framework (KMDF) repository, deploying automated E2E tests usually involves full Windows runners. This approach is a resource drain; the environments lack idempotency, are non-deterministic, and "cold start" boot times significantly lag the feedback loop.
  2. Dynamic Driver Fuzzing: A similar problem exists during the fuzzing of KMDF drivers, specifically when trying to capture kernel exceptions (such as Bugchecks or BSODs) immediately. The hurdles are the same: massive memory overhead, sluggish state restoration from snapshots, and a general lack of OS predictability.

A standard Windows installation is bloated with telemetry, background services, and graphical shells. For automated kernel testing, this user-mode noise is irrelevant; we only require a lean environment capable of running the NT kernel.

The Solution: Windows PE (WinPE)

The answer lies in Windows Preinstallation Environment (WinPE). This is a lightweight, official version of Windows included in every ISO.

Key Characteristics of WinPE:

  • RAM-Resident: It operates entirely in memory.
  • Low Footprint: Requires as little as 512 MB512\text{ MB}512 MB of RAM.
  • Minimalist: No DirectX, no PowerShell subsystem, and no Explorer.exe.
  • Privileged: Boots by default with NT AUTHORITY\SYSTEM permissions.

Comparison: Full Windows vs. WinPE

FeatureFull Windows InstallationWinPE Harness
Boot SpeedSlow (Cold Start)Ultra-Fast
StatePersistent/StatefulStateless/Idempotent
Memory UsageHigh (GBs)Low (≈512 MB\approx 512\text{ MB}≈512 MB)
NoiseHigh (Services/Telemetry)Minimal (Kernel only)
PrivilegesUser-definedSYSTEM by default

Technical Implementation & Automation

1. Boot Configuration (BCD) Optimization

WinPE loads from a .wim (Windows Image) file, which the bootloader mounts as a RAM disk on the X: drive. To achieve millisecond-level spin-up times in a VM, we must use bcdedit to strip away unnecessary boot delays and recovery prompts.

Essential BCD Optimizations:

:: Ignore boot failures to prevent blocking screens in CI/CD
bcdedit /set {default} bootstatuspolicy ignoreallfailures

:: Disable automatic repair to avoid crash loops in diskless mode
bcdedit /set {default} recoveryenabled no

:: Remove the boot menu timeout
bcdedit /set {bootmgr} timeout 0

2. Bypassing Kernel Protections

To test unsigned KMDF drivers, we must enter "Test Mode." Note that nointegritychecks yes is an obsolete flag ignored by x64 bootloaders since the Vista/7 era. Instead, we must disable Virtualization-Based Security (VBS) and Hypervisor-Protected Code Integrity (HVCI).

The "Unrestricted" Configuration:

  • testsigning yes: Allows the loading of unsigned drivers.
  • hypervisorlaunchtype off: Disables VBS/HVCI at the hypervisor level.
  • isolatedcontext no: Disables Isolated User Mode (IUM) and Credential Guard.
bcdedit /set {default} testsigning yes
bcdedit /set {default} hypervisorlaunchtype off
bcdedit /set {default} isolatedcontext no

Virtualization Architecture via QEMU

To ensure stability during kernel debugging, the choice of emulated hardware is critical.

Hardware Topology

While the modern q35 profile is standard, its complex PCIe Root Complex can cause issues for the simple drivers in WinPE. I recommend the older pc (i440FX) profile, which uses a flat PCI bus (Bus 0), making device addressing trivial and reducing HAL-level allocation errors.

Architecture Diagram

Recommended QEMU Base Configuration

When using WHPX, avoid using cpu host as it often causes instability.

# Stable base for Windows kernel testing
qemu-system-x86_64.exe -M pc -accel whpx -cpu Skylake-Client-IBRS -m 1024 -vga none -nographic ...

Kernel Debugging with KDNET

KDNET allows for kernel debugging over UDP, bypassing the standard NDIS network stack and operating directly at the hardware controller level.

Hardware Mapping

Because WinPE is minimalist, KDNET may not automatically find the network card. You must manually specify the busparams using the Bus.Device.Function format.

The Math of Addressing: If you define your network card in QEMU as: -device e1000,bus=pci.0,addr=0x10

The hexadecimal address 0x100x100x10 converts to decimal: 0x1016=(1×161)+(0×160)=16100x10_{16} = (1 \times 16^1) + (0 \times 16^0) = 16_{10}0x1016​=(1×161)+(0×160)=1610​

Therefore, the BCD command is:

bcdedit /dbgsettings net hostip:10.0.2.2 port:50000 key:1.2.3.4
bcdedit /set {dbgsettings} busparams 0.16.0

Compatibility Warning

KDNET relies on a hardcoded list of supported Vendor/Device IDs.

  • Supported: e1000 (Intel PRO/1000) initializes automatically.
  • Unsupported: e1000e or virtio interfaces often fail to initialize.

Summary Workflow

Setup Checklist

  • Configure bcdedit for zero-timeout and no recovery.
  • Disable VBS/HVCI via hypervisorlaunchtype off.
  • Set QEMU machine type to pc.
  • Map KDNET busparams to match QEMU PCI address.
  • Use e1000 for network emulation.