MSDN Documentation

Microsoft Developer Network

Windows Driver Frameworks (WDF)

The Windows Driver Frameworks (WDF) is a collection of object-oriented frameworks that simplify the development of Windows drivers. WDF helps driver developers create robust, high-quality drivers more efficiently.

Overview

WDF abstracts many of the complexities of kernel-mode driver development and provides a structured, event-driven programming model. It consists of two main frameworks:

WDF simplifies common driver tasks such as device initialization, power management, Plug and Play handling, and communication with user-mode applications.

Getting Started

To begin developing WDF drivers, ensure you have the Windows Driver Kit (WDK) and Visual Studio installed. The WDK includes necessary headers, libraries, and tools for driver development.

Key steps typically involve:

  1. Setting up your development environment.
  2. Creating a new WDF driver project in Visual Studio.
  3. Implementing the driver's entry point and framework object callbacks.
  4. Building and testing your driver.

Kernel-Mode Driver Framework (KMDF)

KMDF provides a layered, object-based driver model. It simplifies interactions with the Windows operating system and hardware. Key components include:

Example snippet:


NTSTATUS
DriverEntry(
    _In_ PDRIVER_OBJECT  DriverObject,
    _In_ PUNICODE_STRING RegistryPath
    )
{
    WDF_DRIVER_CONFIG config;
    NTSTATUS status;

    WDF_DRIVER_CONFIG_INIT(&config, MyEvtDriverDeviceAdd);
    status = WdfDriverCreate(DriverObject, RegistryPath, WDF_NO_OBJECT_ATTRIBUTES, &config, WDF_NO_HANDLE);

    return status;
}
            

User-Mode Driver Framework (UMDF)

UMDF allows drivers to run in user mode, which provides several advantages:

UMDF drivers interact with the system through COM interfaces and a framework similar to KMDF, abstracting hardware access.

Core Concepts

Object Management

WDF uses an object-oriented model where drivers interact with framework objects. These objects represent hardware, I/O queues, power states, and more. The framework manages the lifetime of these objects.

I/O Request Handling

Drivers process I/O requests through queues. WDF provides mechanisms to manage these queues, dispatch requests to the driver, and return results.

Power Management

WDF offers robust support for device power management, including handling power transitions, wake events, and idle states.

Plug and Play

The framework simplifies handling Plug and Play (PnP) events, such as device installation, removal, and enumeration.

API Reference

The WDF API reference provides detailed documentation for all framework functions, structures, and enumerations. You can find detailed information on:

Samples

Explore the provided WDF samples to understand practical implementations of driver features. These samples cover various device types and scenarios.

Tutorials

Beginner-friendly tutorials guide you through creating your first WDF drivers, from basic setup to implementing specific functionalities.