Windows driver developers should now have an easier way to create simple and structured drivers, as well as to share code amongst drivers, using the new Microsoft Driver Module Framework (DMF), which has been recently open sourced.
Born from the work done by the Surface team, Microsoft DMF is an extension of the traditional Windows Driver Framework (WDF) that aims to make it easier for developers to create any type of WDF drivers:
About three years ago, the [Surface] team decided to take a holistic look at drivers written for various Surface products […]. We started by breaking down individual functionalities in drivers into a shareable code base. This iterative effort led to the creation of DMF: an extension to WDF that provides you with a library of new WDF Objects called DMF Modules. Modules allow interaction with one another, WDF, and hardware in a structured manner.
While WDF encourages the creation of a driver as a single object, with a single context and event callback, DMF prefers breaking it down into a number of separate WDF objects to make their behaviour and interaction cleaner and more understandable.
An DMF-based driver is made of a number of modules that interact with the general WDF framework through a thin arbitration layer which uses WDF callbacks to dispatch them events. Each module owns its own context to maintain its state and generally communicates with other modules using the same WDF callbacks. Modules can only communicate directly with their child modules, i.e., with modules they instantiated as opposed to DMF-instantiated modules.
(Image from Microsoft announcement post)
Microsoft has also open-sourced many common modules that driver developers can readily reuse in their own drivers, such as:
- ACPI notification module, which allows a driver to request and receive asynchronous notifications from ACPI.
- HID target module, which provides a driver access to HID devices.
- Thermal Cooling Interface module, which implements the Thermal Cooling Interface and provides Passive and Active cooling callbacks for clients to act upon.
- Thread, which makes it easier for a driver to easily do work in a separate thread.
According to Microsoft, today all WDF drivers are based on DMF modules.
Microsoft has included three sample drivers that show how to use DMF to create a driver, and more samples will be provided in future. It is important to note that while DMF includes a library of different modules that Microsoft developed for their own Surface drivers, the actual Surface drivers' code is not included with DMF.