- Programming Drivers for the Kernel Mode Driver Framework
- Sample Drivers by Model
- Sample Drivers by Features
- KMDF Driver Structure and Concepts
- A Minimal KMDF Driver: The Simple Toaster
- Creating a WDF Driver Object: <em>DriverEntry</em>
- Creating the Device Object, Device Interface, and I/O Queue: EvtDriverDeviceAdd
KMDF Driver Structure and Concepts
KMDF drivers are object-oriented, event-driven drivers that link dynamically with the Kernel Mode Driver Framework at runtime. In this section, we will provide a brief overview of the KMDF concepts.
The KMDF object model defines object types to represent common driver constructs. Each object exports methods (functions) and properties (data) that drivers can access and is associated with object-specific events, which drivers can support by providing event callbacks. The objects themselves are opaque to the driver. KMDF and the driver instantiate the objects that are required to service the device. The driver provides callbacks for the events for which the KMDF defaults do not suit its device and calls methods on the object to get and set properties and perform any additional actions. Thus, a KMDF driver consists of a DriverEntry function, callback routines for events that affect the driver or its devices, and whatever utility functions the driver requires.
All KMDF drivers create a WDFDRIVER object to represent the driver and a WDFDEVICE object to represent each device that the driver supports. Most drivers also create one or more WDFQUEUE object to represent the driver’s I/O queues. KMDF place I/O request into the queue until the driver is ready to handle them.
Drivers can create additional objects as their device hardware and driver features require. KMDF objects are organized hierarchically, with the WDFDRIVER object as the root. The object hierarchy defines the object’s lifetime; each object is deleted when its parent is deleted.
All KMDF objects are created in the same way, by using KMDF defined initialization functions and an object creation method. Any KMDF object has one or more driver-defined object context areas, in which the driver can store data is specific to that particular instance of the object.