[Applies to KMDF only]
The WdfDeviceInitSetRemoveLockOptions method causes the framework to acquire a remove lock before delivering an IRP of any type to the driver.
void WdfDeviceInitSetRemoveLockOptions( PWDFDEVICE_INIT DeviceInit, PWDF_REMOVE_LOCK_OPTIONS Options );
A caller-supplied pointer to a WDFDEVICE_INIT structure.
A pointer to a WDF_REMOVE_LOCK_OPTIONS structure.
This method does not return a value.
By default, the framework acquires a remove lock before it delivers IRPs of the following major types to the driver:
When the IRP completes, the framework releases the remove lock.
Starting in KMDF 1.11, the driver can optionally call WdfDeviceInitSetRemoveLockOptions to cause the framework to acquire a remove lock before delivering all IRP types, not just those listed above.
If your driver has kernel-mode clients that send I/O unsynchronized with the PnP state of your device, you may experience crashes due to I/O IRPs arriving after the framework device object has been removed. In this case, you can call WdfDeviceInitSetRemoveLockOptions to prevent the device object from being removed until I/O has completed.
After a driver calls WdfDeviceInitSetRemoveLockOptions, the setting remains in effect for the lifetime of the framework device object.
For more information about remove locks, see Using Remove Locks.
This code example initializes a WDF_REMOVE_LOCK_OPTIONS structure and calls WdfDeviceInitSetRemoveLockOptions.
|Minimum KMDF version||1.11|
|Header||wdfdevice.h (include Wdf.h)|
|Library||Wdf01000.sys (see Framework Library Versioning.)|
|DDI compliance rules||DriverCreate|