Windows Driver Samples

Explore and Contribute to Windows Driver Development

Welcome to the official repository of Windows driver samples. Here you'll find a comprehensive collection of code examples demonstrating best practices, advanced features, and core functionalities for developing robust and efficient drivers for the Windows operating system. Whether you're building drivers for peripherals, system components, or specialized hardware, these samples will serve as a valuable resource.

Echo Server (WDF Kernel-Mode)

A simple WDF kernel-mode driver that demonstrates creating a basic echo server. This sample is ideal for understanding fundamental WDF concepts for network drivers.

WDF Kernel-Mode Networking Basic

USB Simple Read/Write (UMDF)

This UMDF sample showcases how to perform basic read and write operations to a connected USB device. It's a great starting point for anyone developing user-mode drivers for USB peripherals.

UMDF User-Mode USB I/O

Virtual Disk Driver (KMDF)

Demonstrates the creation of a virtual disk driver using KMDF. This advanced sample covers storage concepts, I/O verification, and persistence.

KMDF Kernel-Mode Storage Advanced

Basic Display Driver (UMDF)

A foundational user-mode driver sample for display adapters. This illustrates the interaction with the Windows Display Driver Model (WDDM) in a user-mode context.

UMDF User-Mode Graphics WDDM

System Call Filter (WDF Kernel-Mode)

This sample demonstrates how to implement a kernel-mode driver that can intercept and filter system calls, providing a basis for security-focused driver development.

WDF Kernel-Mode Security System Call

Custom Network Protocol Driver (UMDF)

Develop a user-mode driver to implement a custom network protocol. This sample explores the Network Driver Interface Specification (NDIS) in user mode.

UMDF User-Mode Networking NDIS

Featured Snippet

Here's a quick look at a common pattern for initializing a WDF driver:


// DriverEntry function for a WDF Kernel-Mode Driver
NTSTATUS
DriverEntry(
    _In_ PDRIVER_OBJECT  DriverObject,
    _In_ PUNICODE_STRING RegistryPath
    )
{
    NTSTATUS status;
    WDF_DRIVER_CONFIG config;

    WDF_DRIVER_CONFIG_INIT(&config, MyEvtDeviceAdd);

    // Create a framework driver object to represent this driver.
    status = WdfDriverCreate(
        DriverObject,
        RegistryPath,
        WDF_NO_OBJECT_ATTRIBUTES,
        &config,
        WDF_NO_HANDLE);

    return status;
}

// EvtDeviceAdd callback for a WDF Kernel-Mode Driver
VOID
MyEvtDeviceAdd(
    _In_ WDFDRIVER Driver,
    _Inout_ PWDFDEVICE_INIT DeviceInit
    )
{
    NTSTATUS status;
    WDFDEVICE hDevice;

    // ... Device Initialization Logic ...

    status = WdfDeviceCreate(&DeviceInit, &deviceAttributes, &hDevice);

    // ... Error Handling ...
}