Table of contents
TOC
Collapse the table of content
Expand the table of content

WDM IRPs and WDF Event Callback Functions

Last Updated: 7/30/2016

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_CLEANUPEvtFileCleanup
IRP_MJ_CLOSEEvtFileClose
IRP_MJ_CREATEEvtDeviceFileCreate or EvtIoDefault
IRP_MJ_CREATE_MAILSLOTNo direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_DEVICE_CHANGENo direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_DEVICE_CONTROLEvtIoDeviceControl or EvtIoDefault
IRP_MJ_DIRECTORY_CONTROLNo direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_FILE_SYSTEM_CONTROLNo direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_FLUSH_BUFFERSNo direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_INTERNAL_DEVICE_CONTROLEvtIoInternalDeviceControl or EvtIoDefault
IRP_MJ_LOCK_CONTROLNo direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_PNPMany; see KMDF Callbacks for IRP_MJ_PNP.
IRP_MJ_POWERMany; see KMDF Callbacks for IRP_MJ_POWER.
IRP_MJ_QUERY_EANo direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_QUERY_INFORMATIONNo direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_QUERY_QUOTANo direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_QUERY_SECURITYNo direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_QUERY_VOLUME_INFORMATIONNo direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_READEvtIoRead or EvtIoDefault
IRP_MJ_SET_EANo direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_SET_INFORMATIONNo direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_SET_QUOTANo direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_SET_SECURITYNo direct support; implement EvtDeviceWdmIrpPreprocess (KMDF only)
IRP_MJ_SET_VOLUME_INFORMATIONNo 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_CONTROLCreate WDFWMIPROVIDER and WDFWMIINSTANCE objects and implement EvtWmiXxx (KMDF only) callbacks.
IRP_MJ_WRITEEvtIoWrite 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 codeKMDF callbacks
IRP_MN_CANCEL_REMOVE_DEVICENone
IRP_MN_CANCEL_STOP_DEVICENone
IRP_MN_DEVICE_USAGE_NOTIFICATIONEvtDeviceUsageNotification
IRP_MN_EJECTEvtDeviceEject (KMDF only)
IRP_MN_FILTER_RESOURCE_REQUIREMENTSEvtDeviceFilterRemoveResourceRequirements (KMDF only)
IRP_MN_FILTER_RESOURCE_REQUIREMENTSEvtDeviceFilterAddResourceRequirements (KMDF only)
IRP_MN_QUERY_BUS_INFORMATIONNone. 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_CAPABILITIESNone. 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_TEXTNone. 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_IDNone. 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_INTERFACEEvtDeviceProcessQueryInterfaceRequest (KMDF only)
IRP_MN_QUERY_PNP_DEVICE_STATENone. 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_DEVICEEvtDeviceQueryRemove
IRP_MN_QUERY_RESOURCE_REQUIREMENTSEvtDeviceResourceRequirementsQuery (KMDF only)
IRP_MN_QUERY_RESOURCESEvtDeviceResourcesQuery (KMDF only)
IRP_MN_QUERY_STOP_DEVICEEvtDeviceQueryStop
IRP_MN_READ_CONFIGNone. 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:

EvtDeviceSelfManagedIoSuspendEvtIoStop (WdfRequestStopActionSuspend flag) EvtDmaEnablerSelfManagedIoStop (KMDF only)EvtDmaEnablerDisable (KMDF only)EvtDmaEnablerFlush (KMDF only)EvtDeviceD0ExitPreInterruptsDisabledEvtInterruptDisableEvtDeviceD0Exit (WdfPowerDeviceD3Final state) EvtDeviceReleaseHardwareEvtIoStop (WdfRequestStopActionPurge flag) for power-managed queues EvtDeviceSelfManagedIoFlushEvtIoStop (WdfRequestStopActionPurge flag) for non-power-managed queues EvtDeviceSelfManagedIoCleanupEvtCleanupCallback for WDFDEVICE EvtDestroyCallback for WDFDEVICE

After IRP_MN_SURPRISE_REMOVAL:

EvtIoStop (WdfRequestStopActionPurge flag) for non-power-managed queues EvtDeviceSelfManagedIoCleanupEvtCleanupCallback for WDFDEVICE EvtDestroyCallback for WDFDEVICE
IRP_MN_SET_LOCKEvtDeviceSetLock (KMDF only)
IRP_MN_START_DEVICE

After enumeration:

EvtDeviceRemoveAddedResources (KMDF only)EvtDevicePrepareHardwareEvtDeviceD0EntryEvtInterruptEnableEvtDeviceD0EntryPostInterruptsEnabledEvtDmaEnablerFill (KMDF only)EvtDmaEnablerEnable (KMDF only)EvtDmaEnablerSelfManagedIoStart (KMDF only)EvtDeviceSelfManagedIoInit

After IRP_MN_STOP_DEVICE:

EvtDeviceRemoveAddedResources (KMDF only)EvtDevicePrepareHardwareEvtDeviceD0EntryEvtInterruptEnableEvtDeviceD0EntryPostInterruptsEnabledEvtDmaEnablerFill (KMDF only)EvtDmaEnablerEnable (KMDF only)EvtDmaEnablerSelfManagedIoStart (KMDF only)EvtIoResumeEvtDeviceSelfManagedIoRestart
IRP_MN_STOP_DEVICEEvtDeviceSelfManagedIoSuspendEvtIoStop (WdfRequestStopActionSuspend flag) EvtDmaEnablerSelfManagedIoStop (KMDF only)EvtDmaEnablerDisable (KMDF only)EvtDmaEnablerFlush (KMDF only)EvtDeviceD0ExitPreInterruptsDisabledEvtInterruptDisableEvtDeviceD0Exit (WdfPowerDeviceD3Final state) EvtDeviceReleaseHardware
IRP_MN_SURPRISE_REMOVALEvtDeviceSurpriseRemovalEvtDeviceSelfManagedIoSuspendEvtIoStop (WdfRequestStopActionSuspend flag) EvtDmaEnablerSelfManagedIoStop (KMDF only)EvtDmaEnablerDisable (KMDF only)EvtDmaEnablerFlush (KMDF only)EvtDeviceD0ExitPreInterruptsDisabledEvtInterruptDisableEvtDeviceD0Exit (WdfPowerDeviceD3Final state) EvtDeviceReleaseHardwareEvtIoStop (WdfRequestStopActionPurge flag) for power-managed queues EvtDeviceSelfManagedIoFlush
IRP_MN_WRITE_CONFIGNone. 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)EvtDeviceSelfManagedIoSuspendEvtIoStop (WdfRequestStopActionSuspend flag) EvtDeviceArmWakeFromS0 or EvtDeviceArmWakeFromSxEvtDmaEnablerSelfManagedIoStop (KMDF only)EvtDmaEnablerDisable (KMDF only)EvtDmaEnablerFlush (KMDF only)EvtDeviceD0ExitPreInterruptsDisabledEvtInterruptDisableEvtDeviceD0Exit
IRP_MN_SET_POWER for D0 (power up)EvtDeviceD0EntryEvtInterruptEnableEvtDeviceD0EntryPostInterruptsEnabledEvtDmaEnablerFill (KMDF only)EvtDmaEnablerEnable (KMDF only)EvtDmaEnablerSelfManagedIoStart (KMDF only)EvtIoResumeEvtDeviceSelfManagedIoRestart
IRP_MN_SET_POWER for SxNone
IRP_MN_SET_POWER for SxNone
IRP_MN_POWER_SEQUENCENone
IRP_MN_WAIT_WAKEEvtDeviceEnableWakeAtBus (KMDF only)
IRP_MN_WAIT_WAKEEvtDeviceDisableWakeAtBus (KMDF only)
© 2017 Microsoft