Export (0) Print
Expand All

IOCTL_STORAGE_MCN_CONTROL control code

Temporarily enables or disables delivery of the custom PnP events GUID_IO_MEDIA_ARRIVAL and GUID_IO_MEDIA_REMOVAL on a removable-media device. This, in turn, enables or disables media change detection (AutoPlay) for the device if the caller has opened the device with FILE_READ_ATTRIBUTES access and if the device has AutoPlay enabled in the registry. The caller must not open the device for read or write access or the IOCTL operation will fail. This IOCTL has no effect on the AutoPlay setting in the registry.

A driver for such a removable-media device must do the following:

  1. Keep a count of disable requests, per physical device, in the device object extension.

  2. When called with this IOCTL, if the flag to disable media change detection is set, increment the count; if the flag is clear, decrement the count.

  3. Set the media change event for the device when the media state is changed only if the disable request count is zero.

When the IRP_MJ_DEVICE_CONTROL IRP that contains this IOCTL is passed to the SCSI class driver, the FileObject member of the current IO_STACK_LOCATION must point to a valid file object. The SCSI class driver requires a file object for cases where a user-mode application that is disabling or enabling AutoPlay terminates unexpectedly. In such cases, the SCSI class driver uses the file object to reenable media change detection. Because the file object is necessary for proper clean-up, the SCSI class driver will cause the IRP to fail with an error message of STATUS_INVALID_PARAMETER if the FileObject member of IO_STACK_LOCATION does not point to a valid file object. If a user-mode application opens the device, then the I/O manager initializes this member, but kernel-mode driver writers should not assume that FileObject will be properly initialized when the IRP is generated by a user-mode application. If, for instance, a user-mode application mistakenly opens the device for either read or write access before sending the IOCTL, then the device control IRP will be routed through the file system, preventing the SCSI class driver and the device driver from directly accessing the device's file object.

Input Parameters

The buffer at Irp->AssociatedIrp.SystemBuffer contains a Boolean value, with TRUE indicating that the driver should disable media change detection.

Output Parameters

None

I/O Status Block

The Information field is set to zero. The Status field is set to STATUS_SUCCESS, or possibly to STATUS_BUFFER_TOO_SMALL, STATUS_INVALID_PARAMETER, or STATUS_INVALID_DEVICE_STATE.

Requirements

Header

Ntddstor.h (include Ntddstor.h)

See also

IO_STACK_LOCATION

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft