Expand Minimize

EvtDeviceRemoveAddedResources function

[Applies to KMDF only]

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

Syntax


EVT_WDF_DEVICE_REMOVE_ADDED_RESOURCES EvtDeviceRemoveAddedResources;

NTSTATUS EvtDeviceRemoveAddedResources(
  _In_  WDFDEVICE Device,
  _In_  WDFCMRESLIST ResourcesRaw,
  _In_  WDFCMRESLIST ResourcesTranslated
)
{ ... }

Parameters

Device [in]

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

ResourcesRaw [in]

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

ResourcesTranslated [in]

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.

Remarks

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.

Examples

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:


EVT_WDF_DEVICE_REMOVE_ADDED_RESOURCES  MyDeviceRemoveAddedResources;

Then, implement your callback function as follows:


_Use_decl_annotations_
NTSTATUS
 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.

Requirements

Minimum KMDF version

1.0

Header

Wdffdo.h (include Wdf.h)

IRQL

PASSIVE_LEVEL

See also

EvtDeviceFilterAddResourceRequirements
EvtDeviceFilterRemoveResourceRequirements

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft. All rights reserved.