UMDF 2 is the latest version of UMDF and supersedes UMDF 1. All new UMDF drivers should be written using UMDF 2. No new features are being added to UMDF 1 and there is limited support for UMDF 1 on newer versions of Windows 10. Universal Windows drivers must use UMDF 2.
For more info, see Getting Started with UMDF.
The framework represents each USB device as a framework USB device object. A UMDF driver must create a framework USB device object before the driver can access the framework's support for USB I/O targets. UMDF provides USB device object methods that enable a UMDF driver to:
Creating a UMDF-USB Device Object
To use the framework's USB I/O target capabilities, a UMDF driver must first obtain a pointer to the IWDFUsbTargetFactory interface. To obtain the pointer, the driver must call the QueryInterface method of the device's IWDFDevice interface. The following code example shows how to call QueryInterface to obtain the pointer:
hr = pdevice->QueryInterface(IID_IWDFUsbTargetFactory, (LPVOID*)&ppUsbTargetFactory);
The driver must next call the IWDFUsbTargetFactory::CreateUsbTargetDevice method to create a USB I/O target object for the device. After the driver creates the USB I/O target, the driver can send requests to the I/O target. Typically, drivers call IWDFUsbTargetFactory::CreateUsbTargetDevice from within an IPnpCallbackHardware::OnPrepareHardware callback function.
After the driver calls IWDFUsbTargetFactory::CreateUsbTargetDevice, the driver can obtain USB device information (for example, USB descriptors for the device, USB interfaces, and interface endpoints). The USB descriptors are described in the USB specification.
Obtaining UMDF-USB Device Information
After a UMDF driver calls the IWDFUsbTargetFactory::CreateUsbTargetDevice method to create a UMDF-USB target device object, the driver can call the following methods that the USB target device object defines for obtaining information about a USB device:
Obtains a device's USB device descriptor.
Obtains the number of USB interfaces that the device supports.
Retrieves capability information that is associated with a USB device.
Retrieves a WinUsb power policy.
Obtains the WinUsb interface handle that is associated with the I/O target device object.
A UMDF driver can call the IWDFUsbTargetDevice::FormatRequestForControlTransfer method to format an I/O request that describes a standard, device-class-specific, or vendor-specific USB control transfer. The driver can then call the IWDFIoRequest::Send method to send the request synchronously or asynchronously.
A UMDF driver can call the IWDFUsbTargetDevice::SetPowerPolicy method to set the power policy that is used by WinUsb for a USB device. The power policy for a USB device effects changes to power management states for the device.