UMDF Object Model Implementation

In UMDF, the framework maintains a set of framework objects, and the driver creates a callback object that corresponds to each framework object for which the driver requires an event callback. The callback objects expose callback interfaces that are defined by the framework.

UMDF drivers use the following types of objects:

Driver-created file

I/O completion parameters

Base object

I/O target




USB device


USB I/O target

I/O request

USB interface

I/O queue


UMDF objects and interfaces are based on the COM programming pattern. UMDF uses only the query-interface and reference-counting features of COM; it does not depend on the entire COM infrastructure and runtime library.

Chapter 18, "An Introduction to COM," provides information about COM.

UMDF Naming Conventions

UMDF follows naming conventions for the interfaces that it implements and the callback interfaces that it defines.

 UMDF interface names  The UMDF-implemented interfaces are named:

  • IWDFObject[Description]


  • Object specifies the UMDF object that exposes the interface.

  • Description is additional information that indicates which aspect of the object it acts on.

For example, framework device objects expose the IWDFDevice interface, which supports methods that manipulate a framework device object. Framework I/O target objects expose the IWDFIoTarget and IWDFIoTargetStateManagement interfaces.

 UMDF method names  Methods in UMDF interfaces are named:

  • ActionQualifier


  • Action is a verb that indicates the action that the function performs.

  • Qualifier specifies the object or data that is the target of the action.

For example, the IWDFDevice interface includes the CreateIoQueue and ConfigureRequestDispatching methods.

 UMDF property names  UMDF properties are named:

  • {Set|Get}Data

  • {Assign|Retrieve}Data


  • Data specifies the field that the function reads or writes.

Some properties can be read and written without failure, but other properties can sometimes fail. Functions with Set and Get in their names read and write properties without failure. Functions with Assign and Retrieve in their names can fail and return an HRESULT that contains a status value.

For example, IWDFDevice::GetPnpState and IWDFDevice::SetPnpState set and return the value of individual Plug and Play characteristics for a device object.

 UMDF event callback interface names  Event callback interfaces for UMDF objects are generally named:

  • IObjectCallbackDescription


  • Object identifies the object type.

  • Description indicates what the interface does.

For example, the IQueueCallbackWrite interface is implemented on a queue callback object. It supports a method that the framework calls in response to a write request.

The IPnpCallbackXxx interfaces are an exception. Although these interfaces have Pnp in their names, they are implemented on device objects. They support methods that respond to Plug and Play events.

UMDF methods within the callback interfaces are named:

  • OnEvent


  • Event indicates the event for which the framework invokes the callback method.

For example, the framework calls the IQueueCallbackWrite::OnWrite method when a write request arrives for the device object. The IPnpCallback::OnD0Entry method is called when the device enters the working power state.

UMDF Framework Objects and Interfaces

Table 5-1 lists the interfaces that the framework implements on each type of object.

Table 5-1: UMDF Framework Objects and Interfaces
Open table as spreadsheet

Type of object

Object description


Interface description

Base object

Represents a generic base object for the driver to use as required.


Supports actions common to all objects, such as locking, deletion, and managing the context area.


Represents a device object. A driver typically has one device object for each device that it controls. Inherits from IWDFObject.


Provides device-specific information and creates device-specific objects.



Creates an I/O target object based on a file handle.



Creates a USB I/O target device object.


Represents the driver object itself. Every driver has one driver object. Inherits from IWDFObject.


Creates driver child objects and provides version information.


Represents a framework file object that was opened by the CreateFile function, through which applications can access the device. Inherits from IWDFObject.


Returns information about the file and device that are associated with a file handle.

Driver-created file

Represents a framework file object that the driver created. Inherits from IWDFFile.


Closes a driver-created file.

I/O queue

Represents an I/O queue, which controls the flow of I/O in the driver. A driver can have any number of I/O queues. Inherits from IWDFObject.


Configures, manages, and retrieves requests and information from a queue.

I/O request

Represents a request for device I/O. Inherits from IWDFObject.


Formats, sends, cancels, and returns information about an I/O request.

I/O request completion information

Represents the completion information for an I/O request.


Returns status, number of bytes, and request type for a completed I/O request.

I/O request completion parameters

Exposes the parameters returned in a completed I/O request. Inherits from IWDF-RequestCompletionParams.


Returns buffers for read, write, and device I/O control requests.

I/O target

Represents the next-lower driver in the device stack, to which the driver sends I/O requests. Inherits from IWDFObject.


Formats and cancels I/O requests and returns information about the target file.



Monitors and controls the state of an I/O target.


Represents memory that the driver uses, typically an input or output buffer that is associated with an I/O request. Inherits from IWDFObject.


Copies data to and from a memory buffer and returns information about the buffer.

Property store

Represents an object through which a driver can maintain persistent data in the registry between driver loads and unloads.


Enables a driver to query and set information in the registry.

USB interface

Represents an interface on a USB device. Inherits from IWDFObject.


Returns information about and selects a setting for a USB interface.

USB target device

Represents a USB device object that is an I/O target. Inherits from IWDFIoTarget.


Formats requests for and returns information about a USB target device.

USB target pipe

Represents a USB pipe that is an I/O target. Inherits from IWDFIoTarget.


Manages and returns information about a USB pipe.

USB I/O request completion parameters

Exposes the parameters returned in a completed I/O request to a USB target. Inherits from IWDFRequestCompletionParams.


Returns request type and buffers for USB read, write, and device I/O control requests.

UMDF Driver Callback Objects and Interfaces

A UMDF driver assigns a callback object to each framework object whose events the driver is interested in and implements callback interfaces for those events on the callback object. Every UMDF driver must implement one driver callback object for the driver itself and one device callback object for each device that it supports. Most drivers also implement a queue callback object for each queue.

The driver must implement the IUnknown interface for each callback object. The driver can do this in any of several ways. The UMDF Echo, Skeleton, and USB samples include the Comsup.h header file, which implements IUnknown in the CUnknown base class. In your own driver, you can include Comsup.h and list CUnknown as a base class when you declare the driver's classes.

Chapter 13, "UMDF Driver Template," provides details about how to use the Skeleton sample as a template for your own driver development.

Table 5-2 lists the possible callback interfaces that a driver can implement.

Table 5-2: UMDF Driver Callback Objects and Interfaces
Open table as spreadsheet

Type of object

Callback interfaces

Description of interface

All objects


Provides processing that is required before an object is disposed, typically releasing any circular references.



Provides the main entry point from the framework into the driver and methods to initialize the driver and add its devices. This object is required for all drivers.

Unlike other callback interfaces, the driver does not register IDriverEntry with any particular object. Instead, the framework requests this interface from the driver's CoClass object when it loads the driver.



Handles device stop, removal, and power state changes.



Provides hardware-related operations before device power-up and after device power-down.



Enables the driver to perform actions when the framework starts and stops I/O processing at specific Plug and Play and power management state transitions.



Handles cleanup requests for file objects on a specific device, typically so that the driver can cancel any outstanding I/O requests for the file before it is closed.



Receives close notifications for file objects on a specific device so that the driver can release file-specific resources.

I/O queue


Handles file create requests.



Handles create, device I/O control, read, and write requests for which no other interface has been implemented.



Handles device I/O control requests.



Resumes processing an I/O request after its queue has been stopped.



Stops processing an I/O request because its queue is stopping.



Notifies the driver when the state of a queue changes.



Handles read requests.



Handles write requests.

I/O request


Performs tasks while the driver impersonates the client that issued the I/O request.



Performs tasks after an I/O request is canceled.



Performs tasks when an I/O request is completed.

When an event occurs, the framework calls methods on the appropriate callback interfaces so that the driver can respond to the events that are associated with the request. For example, if the driver has configured a queue for read requests, the framework calls methods in the queue callback object's IQueueCallbackRead interface when it receives such a request.


Framework objects and callback objects are not required to correspond on a one-to-one basis. The driver can do whatever makes the most sense for the callback and the driver.

For example, consider I/O cancellation and completion callbacks. You can implement these interfaces on whichever callback object seems most appropriate. If your driver has a queue that also manages continuous reads on an interrupt pipe, then it might make sense to implement the cancellation and completion callback interfaces on the queue. Likewise, if your driver allocates a context area for each request to track the state of the request, then you could create a callback object instead and implement the I/O cancellation and completion callback interfaces on the callback object.

UMDF Example: Objects and Callback Interfaces

Figure 5-1 shows the primary callback interfaces that the Fx2_Driver sample implements for the driver and device objects. IUnknown-which all COM objects must support-is not shown, nor are the objects and callback interfaces that support the driver's I/O queues.

image from book
Figure 5-1: Driver and device callback objects in the Fx2_Driver sample

As the figure shows, the framework implements a driver object and a device object, and the Fx2_Driver sample creates a driver callback object and a device callback object. The framework driver object uses the driver callback object's IDriverEntry interface, and the driver callback object, in turn, uses the IWDFDriver interface on the framework driver object.

The framework device object exposes the IWDFDevice and IWDFDeviceInitialize interfaces, which the device callback object uses. The device callback object also implements the IPnpCallbackHardware and IPnpCallback interfaces, which the framework device object uses.

Developing Drivers with the Microsoft Windows Driver Foundation
Developing Drivers with the Windows Driver Foundation (Pro Developer)
ISBN: 0735623740
EAN: 2147483647
Year: 2007
Pages: 224

Similar book on Amazon
Windows Internals, Part 1: Covering Windows Server 2008 R2 and Windows 7
Windows Internals, Part 1: Covering Windows Server 2008 R2 and Windows 7
Windowsu00ae Internals: Including Windows Server 2008 and Windows Vista, Fifth Edition (Pro Developer)
Windowsu00ae Internals: Including Windows Server 2008 and Windows Vista, Fifth Edition (Pro Developer)
Advanced Windows Debugging
Advanced Windows Debugging
The Windows 2000 Device Driver Book: A Guide for Programmers (2nd Edition)
The Windows 2000 Device Driver Book: A Guide for Programmers (2nd Edition) © 2008-2017.
If you may any questions please contact us: