[Applies to KMDF only]

A driver's EvtDeviceRemoveAddedResources event callback function removes hardware resources that the driver's EvtDeviceFilterAddResourceRequirements callback function added.



NTSTATUS EvtWdfDeviceRemoveAddedResources(
  WDFCMRESLIST ResourcesRaw,
  WDFCMRESLIST ResourcesTranslated



A handle to the framework device object to which resources will be assigned.


A handle to a resource list object that identifies the raw hardware resources that the PnP manager has assigned to the device.


A handle to a resource list object that identifies the translated hardware resources that the PnP manager has assigned to the device.

Return Value

If the driver encountered no errors it must return STATUS_SUCCESS. Otherwise it must return an NTSTATUS value that NT_SUCCESS evaluates as FALSE.

For more information about return values, see Reporting Device Failures.


Framework-based function drivers can provide an EvtDeviceRemoveAddedResources callback function. To register this callback function, drivers call WdfFdoInitSetEventCallbacks.

If a driver provides an EvtDeviceFilterAddResourceRequirements callback function that adds resources to a device's hardware requirements list, the driver must also provide an EvtDeviceRemoveAddedResources callback function. The EvtDeviceRemoveAddedResources callback function examines the resource list that the PnP manager has assigned to the device, and removes the resources from the list that the EvtDeviceFilterAddResourceRequirements callback function added. If the driver removes a resource, it must remove it from both the raw and translated resource lists.

For more information about resource lists and the order in which the resources appear, see raw and translated hardware resources.

The framework calls the driver's EvtDeviceRemoveAddedResources callback function immediately before it passes the device's resource list to the bus driver. This callback function removes added resources so that the bus driver will not attempt to use them.

For more information about the EvtDeviceRemoveAddedResources callback function, see Modifying a Resource List.

For more information about hardware resources, see Hardware Resources for Framework-Based Drivers.


To define an EvtDeviceRemoveAddedResources callback function, you must first provide a function declaration that identifies the type of callback function you’re defining. Windows provides a set of callback function types for drivers. Declaring a function using the callback function types helps Code Analysis for Drivers, Static Driver Verifier (SDV), and other verification tools find errors, and it’s a requirement for writing drivers for the Windows operating system.

For example, to define an EvtDeviceRemoveAddedResources callback function that is named MyDeviceRemoveAddedResources, use the EVT_WDF_DEVICE_REMOVE_ADDED_RESOURCES type as shown in this code example:


Then, implement your callback function as follows:

 MyDeviceRemoveAddedResources (
    WDFDEVICE  Device,
    WDFCMRESLIST  ResourcesRaw,
    WDFCMRESLIST  ResourcesTranslated

The EVT_WDF_DEVICE_REMOVE_ADDED_RESOURCES function type is defined in the Wdffdo.h header file. To more accurately identify errors when you run the code analysis tools, be sure to add the Use_decl_annotations annotation to your function definition. The Use_decl_annotations annotation ensures that the annotations that are applied to the EVT_WDF_DEVICE_REMOVE_ADDED_RESOURCES function type in the header file are used. For more information about the requirements for function declarations, see Declaring Functions by Using Function Role Types for KMDF Drivers. For information about Use_decl_annotations, see Annotating Function Behavior.


Target Platform Universal
Minimum KMDF version 1.0
Header wdffdo.h (include Wdf.h)

See Also



Send comments about this topic to Microsoft