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 | UMDF 2 | |
|---|---|---|
| Effect of a crash | System bug check | Host process ends |
| DMA | Supported | Not supported |
| Interrupt handling | Full kernel-mode support | Supported, at passive level |
| Debugging | Kernel debugger | User-mode debugger |
| Position in device stack | Anywhere | Not below kernel-mode drivers |
| Model | Runs in | Use for |
|---|---|---|
| UMDF 2 | User mode | USB, HID, sensors and other devices without DMA |
| KMDF | Kernel mode | PCIe, DMA, kernel filters and most other devices |
| Class models (NDIS, Storport, WDDM, ACX) | Mostly kernel mode | Network, storage, display and audio devices |
| WinUSB with an application | Inbox driver plus user mode | Vendor-specific USB devices with one client |
| WDM | Kernel mode | Rare cases the frameworks do not cover |
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.