Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Driver Kit
Storage
Reference
 IOCTL_STORAGE_EJECTION_CONTROL

  Switch on low bandwidth view
Windows Driver Kit: Storage Devices
IOCTL_STORAGE_EJECTION_CONTROL

Operation

Locks the device to prevent removal of the media. If the driver can prevent the media from being removed while the drive is in use, the driver disables or enables the mechanism that ejects media, thereby locking the drive. A caller must open the device with FILE_READ_ATTRIBUTES to send this request.

Unlike IOCTL_STORAGE_MEDIA_REMOVAL, the driver tracks IOCTL_STORAGE_EJECTION_CONTROL requests by caller and ignores unlock requests for which it has not received a lock request from the same caller, thereby preventing other callers from unlocking the drive.

A driver for a removable-media device - can support this IOCTL must do the following:

  1. Keep a lock count, tagged by caller, in the device object extension.
  2. Keep the lock count per physical device.
  3. When called with this IOCTL, if the flag to prevent removing the media is set, increment the count; if the flag is clear and the driver has previously received a lock request from the same caller, decrement the count.
  4. Prevent removal of the media unless all lock counts are zero.

Under normal circumstances, the caller who locked the device using IOCTL_STORAGE_EJECTION_CONTROL, unlocks the device by sending IOCTL_STORAGE_EJECTION_CONTROL again with Irp->AssociatedIrp.SystemBuffer set to a boolean value of FALSE. However, sometimes the caller fails to unlock the device properly.

To ensure that media removal locks are released properly, the class driver keeps track of callers who lock the media with IOCTL_STORAGE_EJECTION_CONTROL. If the caller terminates without unlocking the device, the class driver unlocks the device.

Input

The buffer at Irp->AssociatedIrp.SystemBuffer contains a Boolean value, with TRUE indicating that the driver should lock the media in the drive.

Output

None

I/O Status Block

The Information field is set to zero. The Status field is set to STATUS_SUCCESS, or possibly to STATUS_INVALID_DEVICE_REQUEST, STATUS_NO_MEDIA_IN_DEVICE, or STATUS_DEVICE_NOT_CONNECTED.

Requirements

Headers: Defined in Ntddstor.h. Include Ntddstor.h.

See Also

IOCTL_STORAGE_EJECT_MEDIA


Send feedback on this topic
Built on May 20, 2009
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker