Share via


Creating KMDF HID Minidrivers

You can use KMDF to write a HID minidriver for a USB-compatible device. The HID minidriver resides below the Microsoft-supplied HID class driver in the HID device's driver stack. Windows 8 provides enhanced support for HID over USB.

The HID class driver and the framework provide conflicting WDM dispatch routines to handle some I/O requests (such as Plug and Play and power management requests) for minidrivers. As a result, a HID minidriver cannot link to both the class driver and the framework.

Therefore, Microsoft provides an additional driver, called MsHidKmdf.sys, that resides between the class driver and the minidriver, as the following diagram shows.

Location of MsHidKmdf.sys in driver stack

The MsHidKmdf.sys driver calls the HID Class driver's HidRegisterMinidriver routine to register as the actual minidriver. Although MsHidKmdf.sys acts as the device's function driver, it just passes I/O requests from the class driver to your driver (and is thus sometimes called a pass-through driver).

The framework-based driver that you supply is actually a filter driver that resides under MsHidKmdf.sys. The driver's EvtDriverDeviceAdd callback function must call WdfFdoInitSetFilter. Your driver creates I/O queues to receive I/O requests that the pass-through driver passes from the class driver to your driver.

The WDK provides several sample framework-based HID minidrivers, including the drivers in the \src\hid\hidusbfx2 and \src\hid\vhidmini subdirectories.

Starting in Windows 7, the MsHidKmdf.sys driver is included as part of the operating system. If you want to provide a framework-based HID minidriver for earlier versions of Windows, you can provide a customized version of the MsHidKmdf.sys driver. The WDK contains the source code for this driver, in the src\hid\hidusbfx2\hidkmdf subdirectory.

The sample framework-based HID minidrivers include INF files that show how to use the MsHidKmdf.sys driver to install the drivers on Windows 7 and later, as well as how to modify MsHidKmdf.sys for use on earlier versions of Windows.

HidClass support routines are not available to framework-based HID minidrivers.

 

 

Send comments about this topic to Microsoft