KMDF, UMDF and WDM: Choosing a Windows Driver Framework

The Windows Driver Model is the foundation every Windows driver ultimately sits on, but writing to it directly means handling Plug and Play, power management and I/O cancellation yourself, which is where many historic driver bugs came from. The Windows Driver Frameworks wrap that model: KMDF for kernel-mode drivers and UMDF for user-mode drivers. Many device classes add their own models on top.

At a glance

KMDF
Kernel-Mode Driver Framework, which handles Plug and Play and power for the driver.
UMDF 2
User-Mode Driver Framework version 2, sharing most of the KMDF programming model.
WDM
The underlying driver model; direct use is now rare outside specialised cases.
WDK
The Windows Driver Kit, used with Visual Studio to build, test and package drivers.

The problem

Older sample code and legacy drivers are often pure WDM, and copying them carries over the hardest parts of Windows driver writing: IRP handling, cancellation races and power state transitions.

Choosing kernel mode by default is the other common mistake. A KMDF driver that faults causes a system crash; a UMDF driver that faults ends its host process, and the device can often be restarted without a reboot.

Start in user mode, move to kernel mode only for what UMDF cannot do, and leave raw WDM to the cases that truly need it.

Where each fits

UMDF 2 suits many USB, HID, sensor and simple bus devices, and Microsoft recommends it where it meets the requirements. It supports interrupts and access to device registers but not DMA, and it cannot sit below kernel-mode drivers in a device stack. KMDF covers the rest, including PCIe devices that use DMA and filter drivers in kernel-mode stacks.

Many device classes have their own model: NDIS and NetAdapterCx for networking, Storport for storage, WDDM for display and ACX for audio. Where one exists, use it. Because UMDF 2 and KMDF share most of their API, a driver started in UMDF can move to KMDF later with moderate rework.

What good looks like

Check for an inbox Windows driver for the class, such as HID, USB serial, audio or mass storage; matching it may remove the need for a driver.

If a driver is needed, start from UMDF 2 and list anything it cannot do, such as DMA. Only those needs justify KMDF.

Build with the current WDK, follow the driver package isolation and DCH guidance, and test under Driver Verifier from the first build.

KMDF and UMDF 2
KMDFUMDF 2
Effect of a crashSystem bug checkHost process ends
DMASupportedNot supported
Interrupt handlingFull kernel-mode supportSupported, at passive level
DebuggingKernel debuggerUser-mode debugger
Position in device stackAnywhereNot below kernel-mode drivers
The two framework options for most custom devices.
Windows driver options
ModelRuns inUse for
UMDF 2User modeUSB, HID, sensors and other devices without DMA
KMDFKernel modePCIe, DMA, kernel filters and most other devices
Class models (NDIS, Storport, WDDM, ACX)Mostly kernel modeNetwork, storage, display and audio devices
WinUSB with an applicationInbox driver plus user modeVendor-specific USB devices with one client
WDMKernel modeRare cases the frameworks do not cover
Where a class-specific model exists, it usually takes precedence over a general framework driver.

What it changes

Stability

More code in user mode means fewer system crashes.

Less Boilerplate

The framework handles Plug and Play, power and I/O queue details.

Portability

Shared KMDF and UMDF APIs make a later move between modes practical.

Supportability

The driver follows patterns Microsoft documents and supports.

Where to go next

For a vendor-specific USB device, consider WinUSB with a user-space application before writing any driver. For many devices it is enough.

Plan signing at the start: kernel-mode drivers need a Microsoft signature to load on current Windows.

Problems this prevents

  • Cancellation and power bugs copied from old WDM samples
  • Kernel-mode crashes from code that could run in user mode
  • A custom driver for a device Windows already supports
  • Signing requirements found late in the schedule

Discuss your project

Email support@aavico.com or use Get in Touch when the website finishes loading.