This topic has not yet been rated - Rate this topic

EvtDeviceSetLock function

A driver's EvtDeviceSetLock event callback function locks the specified device so that it cannot be ejected, or unlocks the device so that it can be ejected.

Syntax


EVT_WDF_DEVICE_SET_LOCK EvtDeviceSetLock;

NTSTATUS EvtDeviceSetLock(
  _In_  WDFDEVICE Device,
  _In_  BOOLEAN IsLocked
)
{ ... }

Parameters

Device [in]

A handle to a framework device object.

IsLocked [in]

A Boolean value that indicates whether the driver must lock or unlock the device. If TRUE, the driver must lock the device so that it cannot be ejected. If FALSE, the driver must unlock the device so that it can be ejected.

Return value

If the driver successfully locks or unlocks the device, it must return STATUS_SUCCESS. Otherwise it must return an NTSTATUS value that NT_SUCCESS evaluates as FALSE.

For more information about this callback function's return values, see Reporting Device Failures.

Remarks

Framework-based bus drivers can provide an EvtDeviceSetLock callback function. To register this callback function, bus drivers call WdfPdoInitSetEventCallbacks.

The framework calls the driver's EvtDeviceSetLock callback function when the PnP manager requests the bus driver to lock or unlock one of its enumerated child devices.

Not implementing an EvtDeviceSetLock callback function for a device is equivalent to returning an NTSTATUS value that evaluates as FALSE.

For more information about return values, see Supporting Ejectable Devices.

Examples

The function type is declared in Wdfpdo.h, as follows.


typedef NTSTATUS
  (EVT_WDF_DEVICE_SET_LOCK)(
    IN WDFDEVICE  Device,
    IN BOOLEAN  IsLocked
    );

To define an EvtDeviceSetLock callback function that is named MyDeviceSetLock, you must first provide a function declaration that SDV and other verification tools require, as follows:


EVT_WDF_DEVICE_SET_LOCK  MyDeviceSetLock;

Then, implement your callback function as follows:


NTSTATUS
 MyDeviceSetLock (
    IN WDFDEVICE  Device,
    IN BOOLEAN  IsLocked
    )
  {...}

Requirements

Version

Supported by version 1.0 and later versions of KMDF (see KMDF Version History).

Header

Wdfpdo.h (include Wdf.h)

IRQL

PASSIVE_LEVEL

See also

EvtDeviceEject

 

 

Send comments about this topic to Microsoft

Build date: 4/23/2013

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.