Windows Hardware Development

User-Mode Drivers

User-mode drivers are a fundamental component in modern Windows operating systems, allowing device interaction from the less privileged user space. This approach enhances stability, security, and ease of development compared to traditional kernel-mode drivers.

Introduction to User-Mode Drivers

User-mode drivers execute within the address space of a user-mode process, typically the "WUDFHost.exe" process for UMDF drivers. This isolation prevents a faulty driver from crashing the entire operating system, a common issue with kernel-mode drivers. The Windows Driver Foundation (WDF) provides two frameworks for developing drivers: the Kernel-Mode Driver Framework (KMDF) and the User-Mode Driver Framework (UMDF).

Advantages of User-Mode Drivers

Key Concepts in UMDF Development

The UMDF Host Process (WUDFHost.exe)

UMDF drivers do not run in their own process. Instead, the system hosts them in a generic process called WUDFHost.exe. Multiple UMDF drivers can be hosted within the same WUDFHost.exe instance, or each driver can be configured to run in its own dedicated host process for maximum isolation.

Driver Objects and Framework Objects

UMDF leverages a rich object model. Your driver interacts with the UMDF framework through a hierarchy of objects. Key objects include:

I/O Request Handling

User-mode drivers receive I/O requests from the operating system. The UMDF framework abstracts the complexities of I/O request packets (IRPs) used in kernel mode. Your driver implements callback functions to handle specific I/O operations like read, write, device control (IOCTL), and power management.

Note

UMDF 2.0 is the recommended version for new driver development, offering significant improvements and a unified programming model with KMDF.

Common User-Mode Driver Scenarios

Getting Started with UMDF Development

To begin developing user-mode drivers, you will need:


// Example of a basic UMDF driver entry point (simplified)
HRESULT
DriverEntry(
    _In_ WDFDRIVER Driver,
    _In_ PDRIVER_SERVICE_REGISTRATION_PROPERTIES ServiceRegProps
    )
{
    WDF_OBJECT_ATTRIBUTES attributes;
    WDF_OBJECT_ATTRIBUTES_INIT(&attributes);

    // Create the device object
    return WdfDeviceCreate(...);
}
            

Tip

Explore the UMDF samples provided in the WDK. They offer practical implementations of various driver functionalities.

Resources