Windows Driver Samples

repository·main·Indexed 27 days ago

https://github.com/microsoft/windows-driver-samples

Official Microsoft Windows Driver Kit (WDK) code samples for Windows 11. This repository provides foundational resources for developers building Universal Windows drivers using Windows Driver Frameworks (WDF), including detailed samples for WDM audio drivers such as Simple Audio Sample, SysVAD, and Soundwire technology.

Tokens
85.5K
Snippets
137
Records
579
Agent score
90%

What's inside windows-driver-samples

  1. Overview of the WFP Packet Modification Sample (ddproxy)

    main

    The ddproxy sample is a kernel-mode Windows Filtering Platform (WFP) callout driver (Ddproxy.sys) that acts as a transparent redirector for UDP and non-error ICMP traffic.

    Key Features:

    • Redirection: For outbound traffic, it redirects to a new destination address and (for UDP) a new port. For inbound traffic, it redirects back to the original values.
    • Protocol Support: Supports both IPv4 and IPv6.
    • Out-of-band Modification: Uses a system worker thread with a reference-drop-clone-modify-reinject mechanism. This allows modification decisions to be made outside of the initial classifyFn() callout, which is useful if decisions must be made by a user-mode application.
  2. Overview of SimThermalClient Simulated Thermal Client Driver

    main
    The SimThermalClient is a sample driver that simulates a device acting as a Windows thermal management client. It is designed to demonstrate how drivers can participate in global thermal management coordinated by the Windows operating system by publishing the GUID_THERMAL_COOLING_INTERFACE driver interface.
  3. Overview of the PEP ACPI Sample

    main
    The Power Engine Plugin (PEP) ACPI sample demonstrates an interface that allows a PEP to implement ACPI runtime methods natively via a Windows driver instead of using firmware (AML). This interface enables a PEP to act as a Platform Extension. It can be used independently or alongside Device Power Management (DPM) and Processor Power Management (PPM) interfaces.
  4. Overview of the Standard SD Host Controller Miniport

    main

    This sample provides a functional miniport driver implementation for a standard Secure Digital (SD) Host Controller. The driver (sdhc.sys) is designed to work in conjunction with sdport.sys.

    sdport.sys implements the SD/SDIO/eMMC protocols and WDM interfaces, providing the necessary host register interface for the miniport driver to function.

  5. Overview of the WFPSampler Sample

    main

    The WFPSampler is a sample firewall driver for the Windows Filtering Platform (WFP). It provides a command-line interface to add filters at various WFP layers with diverse conditions. It also demonstrates callout functions for injection, basic action, proxying, and stream inspection.

    Key Components:

    • WFPSampler.Exe: Command-line interface for defining policies.
    • WFPSamplerService.Exe: Service that instructs the Base Filtering Engine (BFE) to add or remove policies.
    • WFPSamplerCalloutDriver.Sys: The driver containing callout functions.
    • WFPSamplerProxyService.Exe: Service that listens for connections to proxy.
    • WFPSampler.Lib: User-mode helper library.
    • WFPSamplerSys.Lib: Kernel-mode helper library.
    • WFPSamplerInstall.cmd: Script to install or uninstall components.
  6. Overview of the CDO File System Minifilter Driver

    main
    The CDO (Control Device Object) minifilter sample demonstrates how to implement a CDO alongside a minifilter. While the Filter Manager provides a standard message interface for application-to-minifilter communication, a CDO is useful when your minifilter needs to interface with legacy software that requires explicit device objects.
  7. Overview of KMDF Power Framework (PoFx) Samples

    main

    The KMDF Power Framework (PoFx) sample demonstrates how a Kernel Mode Driver Framework (KMDF) driver can implement F-state-based power management. It is provided in two versions:

    1. SingleComp: For devices with a single component representing the entire device.
    2. MultiComp: For devices with an arbitrary number of components that can be individually power-managed.

    Both samples are Universal Windows Driver Compliant, meaning they use only APIs and DDIs included in OneCoreUAP.

  8. Overview of PCIDRV KMDF Sample

    main

    The PCIDRV sample is a Kernel Mode Driver Framework (KMDF) driver designed for a generic PCI device. It is specifically demonstrated using the Intel 82557/82558 based PCI Ethernet Adapter (10/100) and compatible hardware.

    Key KMDF interfaces demonstrated:

    • Handling PnP & Power Events
    • Registering Device Interfaces
    • Hardware resource mapping (Port, Memory & Interrupt)
    • DMA Interfaces
    • Parallel queues:
      • Default queue for write requests (moves to manual parallel queue if not immediately satisfied).
      • Manual parallel queue for Read requests.
      • Default queue for IOCTL requests (moves to manual parallel queue if not immediately satisfied).
    • Request cancellation
    • Handling Interrupt & DPC
    • Watchdog Timer DPC for device state monitoring
    • Event Tracing & HEXDUMP
    • Registry Read/Write operations

    Note: This is a minimal educational sample and is not intended for production use. For network controllers, use NDIS miniport samples instead.

  9. Overview of the AvsCamera AVStream Sample Driver

    main

    The AvsCamera sample is a pin-centric AVStream capture driver designed to simulate both front and back cameras. It performs simulated captures in several formats: RGB24, RGB32, YUY2, and NV12 at resolutions of 320x240 or 640x480 across various frame rates.

    Key features include:

    • Strong parameter validation and overflow detection.
    • Validation and simulation logic for advanced camera controls implemented in the CCaptureFilter class.
    • A companion DeviceMFT named AvsCameraMft0.dll which parses metadata from the driver via a private channel and reformats it for the capture pipeline.

    To create a real camera driver from this sample, you would need to replace the filter automation table and the CSensor and CSynthesizer class hierarchies.