WDM IRPs and WDF Event Callback Functions

Kernel-Mode Driver Framework (KMDF) and User-Mode Driver Framework (UMDF) support a subset of Windows IRPs. The following table lists the major WDM IRP types and the corresponding framework event callback functions. Unless otherwise specified, the callbacks apply to both KMDF and UMDF.

Major IRP codeWDF event callback function
IRP_MJ_CLEANUP EvtFileCleanup
IRP_MJ_CLOSE EvtFileClose
IRP_MJ_CREATE EvtDeviceFileCreate or EvtIoDefault
IRP_MJ_CREATE_MAILSLOT No direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_DEVICE_CHANGE No direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_DEVICE_CONTROL EvtIoDeviceControl or EvtIoDefault
IRP_MJ_DIRECTORY_CONTROL No direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_FILE_SYSTEM_CONTROL No direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_FLUSH_BUFFERS No direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_INTERNAL_DEVICE_CONTROL EvtIoInternalDeviceControl or EvtIoDefault
IRP_MJ_LOCK_CONTROL No direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_PNP Many; see KMDF Callbacks for IRP_MJ_PNP.
IRP_MJ_POWER Many; see KMDF Callbacks for IRP_MJ_POWER.
IRP_MJ_QUERY_EA No direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_QUERY_INFORMATION No direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_QUERY_QUOTA No direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_QUERY_SECURITY No direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_QUERY_VOLUME_INFORMATION No direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_READ EvtIoRead or EvtIoDefault
IRP_MJ_SET_EA No direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_SET_INFORMATION No direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_SET_QUOTA No direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_SET_SECURITY No direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_SET_VOLUME_INFORMATION No direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_SHUTDOWN

For control device objects, implement EvtDeviceShutdownNotification (KMDF only)

For all Plug and Play device objects: Not supported; implement EvtDeviceWdmIrpPreprocess (KMDF only).

IRP_MJ_SYSTEM_CONTROL Create WDFWMIPROVIDER and WDFWMIINSTANCE objects and implement EvtWmiXxx (KMDF only) callbacks.
IRP_MJ_WRITE EvtIoWrite or EvtIoDefault

 

KMDF Callbacks for IRP_MJ_PNP

The following table lists, in order of execution, the KMDF callbacks that correspond to the minor IRP codes for IRP_MJ_PNP. The arrows indicate whether a WDM FDO handles the IRP as it travels up or down the stack.

Note   In a KMDF driver, Plug and Play and power management are integrated operations and the driver does not receive the individual minor IRP_MJ_PNP or IRP_MJ_POWER requests. Instead, the framework calls a core set of callbacks at power up and a corresponding set at power down, and calls additional callbacks before and after this core set as appropriate for each individual Plug and Play request. For comprehensive diagrams that show the power-up and power-down sequences, see Porting PnP and Power Management Functionality.

IRP_MJ_PNP minor code KMDF callbacks
IRP_MN_CANCEL_REMOVE_DEVICE None
IRP_MN_CANCEL_STOP_DEVICE None
IRP_MN_DEVICE_USAGE_NOTIFICATION EvtDeviceUsageNotification
IRP_MN_EJECT EvtDeviceEject (KMDF only)
IRP_MN_FILTER_RESOURCE_REQUIREMENTS EvtDeviceFilterRemoveResourceRequirements (KMDF only)
IRP_MN_FILTER_RESOURCE_REQUIREMENTS EvtDeviceFilterAddResourceRequirements (KMDF only)
IRP_MN_QUERY_BUS_INFORMATION None. The KMDF driver calls WdfDeviceInitXxx methods to set device properties during initialization so that the framework can respond to this query on its own without notifying the driver.
IRP_MN_QUERY_CAPABILITIES None. The KMDF driver calls WdfDeviceInitXxx methods to set device properties during initialization so that the framework can respond to this query on its own without notifying the driver.
IRP_MN_QUERY_DEVICE_RELATIONS (bus, removal, and ejection relations) EvtDeviceRelationsQuery
IRP_MN_QUERY_DEVICE_TEXT None. The KMDF driver calls WdfDeviceInitXxx methods to set device properties during initialization so that the framework can respond to this query on its own without notifying the driver.
IRP_MN_QUERY_ID None. The KMDF driver calls WdfDeviceInitXxx methods to set device properties during initialization so that the framework can respond to this query on its own without notifying the driver.
IRP_MN_QUERY_INTERFACE EvtDeviceProcessQueryInterfaceRequest (KMDF only)
IRP_MN_QUERY_PNP_DEVICE_STATE None. The KMDF driver calls WdfDeviceInitXxx methods to set device properties during initialization so that the framework can respond to this query on its own without notifying the driver.
IRP_MN_QUERY_REMOVE_DEVICE EvtDeviceQueryRemove
IRP_MN_QUERY_RESOURCE_REQUIREMENTS EvtDeviceResourceRequirementsQuery (KMDF only)
IRP_MN_QUERY_RESOURCES EvtDeviceResourcesQuery (KMDF only)
IRP_MN_QUERY_STOP_DEVICE EvtDeviceQueryStop
IRP_MN_READ_CONFIG None. The KMDF driver calls WdfDeviceInitXxx methods to set device properties during initialization so that the framework can respond to this query on its own without notifying the driver.
IRP_MN_REMOVE_DEVICE

After IRP_MN_QUERY_REMOVE_DEVICE:

EvtDeviceSelfManagedIoSuspend
EvtIoStop (WdfRequestStopActionSuspend flag)
EvtDmaEnablerSelfManagedIoStop (KMDF only)
EvtDmaEnablerDisable (KMDF only)
EvtDmaEnablerFlush (KMDF only)
EvtDeviceD0ExitPreInterruptsDisabled
EvtInterruptDisable
EvtDeviceD0Exit (WdfPowerDeviceD3Final state)
EvtDeviceReleaseHardware
EvtIoStop (WdfRequestStopActionPurge flag) for power-managed queues
EvtDeviceSelfManagedIoFlush
EvtIoStop (WdfRequestStopActionPurge flag) for non-power-managed queues
EvtDeviceSelfManagedIoCleanup
EvtCleanupCallback for WDFDEVICE
EvtDestroyCallback for WDFDEVICE

After IRP_MN_SURPRISE_REMOVAL:

EvtIoStop (WdfRequestStopActionPurge flag) for non-power-managed queues
EvtDeviceSelfManagedIoCleanup
EvtCleanupCallback for WDFDEVICE
EvtDestroyCallback for WDFDEVICE
IRP_MN_SET_LOCK EvtDeviceSetLock (KMDF only)
IRP_MN_START_DEVICE

After enumeration:

EvtDeviceRemoveAddedResources (KMDF only)
EvtDevicePrepareHardware
EvtDeviceD0Entry
EvtInterruptEnable
EvtDeviceD0EntryPostInterruptsEnabled
EvtDmaEnablerFill (KMDF only)
EvtDmaEnablerEnable (KMDF only)
EvtDmaEnablerSelfManagedIoStart (KMDF only)
EvtDeviceSelfManagedIoInit

After IRP_MN_STOP_DEVICE:

EvtDeviceRemoveAddedResources (KMDF only)
EvtDevicePrepareHardware
EvtDeviceD0Entry
EvtInterruptEnable
EvtDeviceD0EntryPostInterruptsEnabled
EvtDmaEnablerFill (KMDF only)
EvtDmaEnablerEnable (KMDF only)
EvtDmaEnablerSelfManagedIoStart (KMDF only)
EvtIoResume
EvtDeviceSelfManagedIoRestart
IRP_MN_STOP_DEVICE
EvtDeviceSelfManagedIoSuspend
EvtIoStop (WdfRequestStopActionSuspend flag)
EvtDmaEnablerSelfManagedIoStop (KMDF only)
EvtDmaEnablerDisable (KMDF only)
EvtDmaEnablerFlush (KMDF only)
EvtDeviceD0ExitPreInterruptsDisabled
EvtInterruptDisable
EvtDeviceD0Exit (WdfPowerDeviceD3Final state)
EvtDeviceReleaseHardware
IRP_MN_SURPRISE_REMOVAL
EvtDeviceSurpriseRemoval
EvtDeviceSelfManagedIoSuspend
EvtIoStop (WdfRequestStopActionSuspend flag)
EvtDmaEnablerSelfManagedIoStop (KMDF only)
EvtDmaEnablerDisable (KMDF only)
EvtDmaEnablerFlush (KMDF only)
EvtDeviceD0ExitPreInterruptsDisabled
EvtInterruptDisable
EvtDeviceD0Exit (WdfPowerDeviceD3Final state)
EvtDeviceReleaseHardware
EvtIoStop (WdfRequestStopActionPurge flag) for power-managed queues
EvtDeviceSelfManagedIoFlush
IRP_MN_WRITE_CONFIG None. The KMDF driver calls WdfDeviceInitXxx methods to set device properties during initialization so that the framework can respond to this query on its own without notifying the driver.

 

KMDF Callbacks for IRP_MJ_POWER

The following table lists, in order of execution, the KMDF callbacks that correspond to the minor IRP codes for IRP_MJ_POWER. The arrows indicate whether a WDM FDO handles the IRP as it travels up or down the stack.

Note   Note: In a KMDF driver, Plug and Play and power management are integrated operations and the driver does not receive the individual minor IRP_MJ_PNP or IRP_MJ_POWER requests. Instead, the framework calls a core set of callbacks at power up and a corresponding set at power down, and calls additional callbacks before and after this core set as appropriate for each individual Plug and Play request. For comprehensive diagrams that show the power-up and power-down sequences, see Porting PnP and Power Management Functionality.

IRP_MJ_POWER minor codeFramework callbacks
IRP_MN_SET_POWER for D1, D2, or D3 (power down)
EvtDeviceSelfManagedIoSuspend
EvtIoStop (WdfRequestStopActionSuspend flag)
EvtDeviceArmWakeFromS0 or EvtDeviceArmWakeFromSx
EvtDmaEnablerSelfManagedIoStop (KMDF only)
EvtDmaEnablerDisable (KMDF only)
EvtDmaEnablerFlush (KMDF only)
EvtDeviceD0ExitPreInterruptsDisabled
EvtInterruptDisable
EvtDeviceD0Exit
IRP_MN_SET_POWER for D0 (power up)
EvtDeviceD0Entry
EvtInterruptEnable
EvtDeviceD0EntryPostInterruptsEnabled
EvtDmaEnablerFill (KMDF only)
EvtDmaEnablerEnable (KMDF only)
EvtDmaEnablerSelfManagedIoStart (KMDF only)
EvtIoResume
EvtDeviceSelfManagedIoRestart
IRP_MN_SET_POWER for Sx None
IRP_MN_SET_POWER for Sx None
IRP_MN_POWER_SEQUENCE None
IRP_MN_WAIT_WAKE EvtDeviceEnableWakeAtBus (KMDF only)
IRP_MN_WAIT_WAKE EvtDeviceDisableWakeAtBus (KMDF only)

 

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft