The following summarizes the public I/O control codes that disk-type drivers support. However, each device driver is required to handle only those I/O control codes that its particular device(s) support.
For example, only a floppy driver would handle IOCTL_STORAGE_GET_MEDIA_TYPES requests; it would not handle IOCTL_DISK_GET/SET_PARTITION_INFO or IOCTL_GET/SET_DRIVE_LAYOUT requests. As another example, a filter driver like the system-supplied diskperf driver that monitors disk performance statistics would handle IOCTL_DISK_PERFORMANCE requests from a corresponding (user-mode) application; it would simply pass down other IOCTL_DISK_XXX requests to the underlying disk device driver.
All public I/O control codes for drivers of disk-type devices use buffered I/O. Consequently, the input or output data buffer for these requests is at Irp->AssociatedIrp.SystemBuffer.
Class drivers for SCSI disk devices handle additional public I/O control codes, along with those described in this section. See also Chapter 9 for more information about requirements for SCSI class drivers of mass-storage devices.
The IOCTL_INTERNAL_DISK_Xxx codes can be used for communication between two kernel-mode drivers.
Formats the specified set of contiguous tracks on the disk.
The buffer at Irp->AssociatedIrp.SystemBuffer contains the FORMAT_PARAMETERS data. Parameters.DeviceIoControl.InputBufferLength in the I/O stack location of the IRP indicates the size in bytes of the buffer.
The device driver returns an array of BAD_TRACK_NUMBER values to the buffer at Irp->AssociatedIrp.SystemBuffer.
The Information field is set to the size of the returned bad-track array when the Status field is set to STATUS_SUCCESS. Otherwise, the Information field is zero, and the Status field possibly can be set to STATUS_INVALID_PARAMETER or STATUS_MEDIA_WRITE_PROTECTED if the media is removable.
This IOCTL is similar to IOCTL_DISK_FORMAT_TRACKS except that it allows the caller to specify several more parameters. The additional extended parameters are the format gap length, the number of sectors per track, and an array whose element size is equal to the number of sectors per track. This array represents the track layout.
The buffer at Irp->AssociatedIrp.SystemBuffer contains the FORMAT_EX_PARAMETERS data. Parameters.DeviceIoControl.InputBufferLength in the I/O stack location of the IRP indicates the size in bytes of the buffer.
The device driver returns an array of BAD_TRACK_NUMBER values to the buffer at Irp->AssociatedIrp.SystemBuffer.
The driver sets the Status field to STATUS_SUCCESS. Otherwise, the driver sets the Status field to INVALID_PARAMETER if the input buffer length is < sizeof(FORMAT_EX_PARAMETERS), or if the format parameters supplied by the caller won’t work on the drive to be formatted.
Verifys the specified extent on the fixed disk.
The buffer at Irp->AssociatedIrp.SystemBuffer contains the VERIFY_INFORMATION data specifying the starting offset and length to be verified. Parameters.DeviceIoControl.InputBufferLength indicates the size in bytes of the buffer, which must be >= sizeof(VERIFY_INFORMATION).
None
The Information field is set to the number of bytes verified when the Status field is set to STATUS_SUCCESS. Otherwise, the Status field can be set to STATUS_BUFFER_TOO_SMALL, STATUS_INFO_LENGTH_MISMATCH, STATUS_INVALID_PARAMETER, STATUS_INSUFFICIENT_RESOURCES, STATUS_NONEXISTANT_SECTOR, STATUS_DEVICE_DATA_ERROR, STATUS_INVALID_DEVICE_REQUEST, STATUS_IO_TIMEOUT, or STATUS_DEVICE_NOT_CONNECTED.
Returns information about the physical disk’s geometry (media type, number of cylinders, tracks per cylinder, sectors per track, and bytes per sector).
Parameters.DeviceIoControl.OutputBufferLength in the I/O stack location of the IRP indicates the size in bytes of the buffer, which must be >= sizeof(DISK_GEOMETRY).
The driver returns the DISK_GEOMETRY data in the buffer at Irp->AssociatedIrp.SystemBuffer.
The Information field is set to the size in bytes of the returned data. The Status field can be set to STATUS_SUCCESS, or possibly to STATUS_UNRECOGNIZED_MEDIA, STATUS_INVALID_PARAMETER, STATUS_INVALID_DEVICE_REQUEST, STATUS_INFO_LENGTH_MISMATCH, STATUS_INSUFFICIENT_RESOURCES, or STATUS_BUFFER_TOO_SMALL.
This IOCTL is replaced by IOCTL_STORAGE_GET_MEDIA_TYPES. The only difference between the two IOCTLs is the base code.
Returns information about the geometry of the floppy drives.
Parameters.DeviceIoControl.OutputBufferLength in the I/O stack location of the IRP indicates the size in bytes of the buffer, which must be at least (NumberOfSupportedMediaTypes * sizeof(DISK_GEOMETRY)).
The driver returns an array of DISK_GEOMETRY records for the types of media it supports in the buffer at Irp->AssociatedIrp.SystemBuffer.
The Information field is set to the size in bytes of the returned data. The Status field can be set to STATUS_SUCCESS, or possibly to STATUS_INVALID_DEVICE_REQUEST, STATUS_BUFFER_TOO_SMALL, or STATUS_BUFFER_OVERFLOW.
This IOCTL is replaced by IOCTL_STORAGE_CHECK_VERIFY. The only difference between the two IOCTLs is the base code.
Determines whether the media has changed on a removable-media device. (For more information about handling removable media, see the Kernel-Mode Driver Design Guide.)
Optionally, Parameters.DeviceIoControl.OutputBufferLength in the I/O stack location of the IRP indicates the size in bytes of a buffer, which must be >= sizeof(ULONG). This field is zero if the optional buffer is not specified.
Optionally, Irp->AssociatedIrp.SystemBuffer points to a buffer to receive the media change count. The driver fills this buffer only if Parameters.DeviceIoControl.OutputBufferLength was nonzero and the return value is STATUS_SUCCESS. The media change count is a ULONG indicating how many times the media has changed since the driver started.
If the driver has no indication that the media has changed, the driver sets the Status field to STATUS_SUCCESS. In addition, if the optional media change buffer was specified, the driver returns the media change count in the buffer at Irp->AssociatedIrp.SystemBuffer and sets the Information field to sizeof(ULONG). If the optional media change buffer was not specified, the driver sets Information to zero.
If the driver detects that the media has changed and the volume is mounted (VPD_MOUNTED is set in the VPB), it must: set Information to zero, set Status to STATUS_VERIFY_REQUIRED, set the DO_VERIFY_VOLUME flag in the DeviceObject, and call IoCompleteRequest with the input IRP.
If the driver detects that the media has changed, but the volume is not mounted, the driver must not set the DO_VERIFY_VOLUME bit, The driver should set Status to STATUS_IO_DEVICE_ERROR, set Information to zero, and call IoCompleteRequest with the IRP.
If the driver detects an error such as STATUS_BUFFER_TOO_SMALL, STATUS_INSUFFICIENT_RESOURCES, or a device error, it sets Information to zero and sets the appropriate error value in the Status field.
Returns information about the type, size, and nature of a disk partition. (Floppy drivers need not handle this request.)
Parameters.DeviceIoControl.OutputBufferLength in the I/O stack location of the IRP indicates the size in bytes of the buffer, which must be >= sizeof(PARTITION_INFORMATION).
The driver returns the PARTITION_INFORMATION data in the buffer at Irp->AssociatedIrp.SystemBuffer.
The Information field is set to the size in bytes of the returned data. The Status field can be set to STATUS_SUCCESS, or possibly to STATUS_INVALID_PARAMETER, STATUS_INFO_LENGTH_MISMATCH, STATUS_INSUFFICIENT_RESOURCES, STATUS_INVALID_DEVICE_REQUEST, or STATUS_BUFFER_TOO_SMALL.
Changes the partition type of the specified disk partition. (Floppy drivers need not handle this request.)
The buffer at Irp->AssociatedIrp.SystemBuffer contains the SET_PARTITION_INFORMATION to be set. Parameters.DeviceIoControl.InputBufferLength in the I/O stack location of the IRP indicates the size of the buffer, which must be >= sizeof(SET_PARTITION_INFORMATION).
None
The Information field is set to zero. The Status field can be set to STATUS_SUCCESS, or possibly to STATUS_INVALID_PARAMETER, STATUS_INVALID_DEVICE_REQUEST, STATUS_UNSUCCESSFUL, STATUS_INFO_LENGTH_MISMATCH, STATUS_INSUFFICIENT_RESOURCES, or STATUS_BUFFER_TOO_SMALL.
Returns information about the number of partitions, disk signature, and features of each partition on a disk. (Floppy drivers need not handle this request.)
Parameters.DeviceIoControl.OutputBufferLength in the I/O stack location of the IRP indicates the size in bytes of the buffer, which must be >= sizeof(DRIVE_LAYOUT_INFORMATION). Note that this structure contains a variable-sized array of PARTITION_INFORMATION elements.
The driver returns the DRIVE_LAYOUT_INFORMATION data in the buffer at Irp->AssociatedIrp.SystemBuffer.
The Information field is set to the size in bytes of the returned data. The Status field can be set to STATUS_SUCCESS, or possibly to STATUS_INFO_LENGTH_MISMATCH, STATUS_INSUFFICIENT_RESOURCES, or STATUS_BUFFER_TOO_SMALL.
Repartitions a disk as specified. (Floppy drivers need not handle this request.)
The buffer at Irp->AssociatedIrp.SystemBuffer contains the DRIVE_LAYOUT_INFORMATION values to be set. Parameters.DeviceIoControl.InputBufferLength in the I/O stack location of the IRP indicates the size in bytes of the buffer, which must be >= sizeof(DRIVE_LAYOUT_INFORMATION).
Returns updated DRIVE_LAYOUT_INFORMATION, possibly with modified partition numbers, to the buffer at Irp->AssociatedIrp.SystemBuffer.
The Information field is set to the size in bytes of the returned information. The Status field can be set to STATUS_SUCCESS, or possibly to STATUS_INVALID_PARAMETER, STATUS_INFO_LENGTH_MISMATCH, STATUS_INSUFFICIENT_RESOURCES, or STATUS_BUFFER_TOO_SMALL.
Determines whether a disk is writable.
None
None
The Information field is set to zero. The Status field can be set to STATUS_SUCCESS, or possibly to STATUS_INSUFFICIENT_RESOURCES, STATUS_IO_DEVICE_ERROR, or STATUS_MEDIA_WRITE_PROTECTED.
Directs the device to map a block to one from its spare-block pool.
The buffer at Irp->AssociatedIrp.SystemBuffer contains the REASSIGN_BLOCKS values to be set. Parameters.DeviceIoControl.InputBufferLength in the I/O stack location of the IRP indicates the size in bytes of the buffer, which must be >= sizeof(REASSIGN_BLOCKS). Note that this structure contains a variable-sized array of block numbers.
None
The Information field is set to zero. The Status field can be set to STATUS_SUCCESS, or possibly to STATUS_INFO_LENGTH_MISMATCH, STATUS_INSUFFICIENT_RESOURCES, or STATUS_BUFFER_TOO_SMALL.
This IOCTL is replaced by IOCTL_STORAGE_FIND_NEW_DEVICES. The only difference between the two IOCTLs is the base code.
Determines whether another device that the driver supports has been connected to the I/O bus, either since the system was booted or since the driver last processed this request. If such a device is found, the driver sets up any necessary system objects and resources to handle I/O requests for its new device. It also initializes the device on receipt of this request dynamically: that is, without requiring the machine to be rebooted. Such a driver is assumed to support devices connected on a dynamically configurable I/O bus.
None
None
The Information field is set to zero. The Status field can be set to STATUS_SUCCESS or to any other value returned by the driver’s (re)initialization code.
Collects disk performance statistics, such as the numbers of bytes read and written since the driver last processed this request, for a corresponding disk monitoring application.
Parameters.DeviceIoControl.OutputBufferLength in the I/O stack location of the IRP indicates the size in bytes of the buffer, which must be at least sizeof(DISK_PERFORMANCE).
The driver returns the DISK_PERFORMANCE data in the buffer at Irp->AssociatedIrp.SystemBuffer.
The Information field is set to sizeof(DISK_PERFORMANCE) when the Status field is set to STATUS_SUCCESS. Otherwise, the Status field can be set to STATUS_INVALID_PARAMETER or STATUS_BUFFER_TOO_SMALL.
The system supplied SCSI port driver and atdisk driver support this request. Any replacement driver that controls a disk used for the paging file, must support this request.
This request is issued during system initialization. The driver must return configuration parameters that are used if a system crash occurs to dump memory to the paging file. The DUMP_POINTERS structure describes these configuration parameters, and the driver must set all parameters appropriately to its disk. Each pointer must be a valid pointer or NULL; each size must be a valid size or zero.
None.
The driver returns the DUMP_POINTERS parameters in the buffer at Irp->AssociatedIrp.SystemBuffer.
The driver sets Irp->IoStatus.Information to sizeof(DUMP_POINTERS). The driver sets the Status field to STATUS_SUCCESS or possibly to STATUS_BUFFER_TOO_SMALL, STATUS_INVALID_PARAMETER, or STATUS_NOT_SUPPORTED. An error return indicates that the crash dump functionality is disabled and no memory dump is produced if a system failure occurs.
None. This IOCTL is obsolete.
Returns version information, a capabilities mask, and a bitmask for the device. This IOCTL must be handled by drivers that support Self-Monitoring Analysis and Reporting Technology (SMART).
Parameters.DeviceIoControl.OutputBufferLength indicates the size in bytes of the buffer, which must be >= sizeof(GETVERSIONINPARAMS).
The driver returns the information to the buffer at
Irp->AssociatedIrp.SystemBuffer.
The driver sets the Information field to sizeof(GETVERSIONINPARAMS) when it sets the Status field to STATUS_SUCCESS. Otherwise, the driver sets the Information field to zero and sets the Status field to possibly STATUS_INVALID_PARAMETER.
Returns the ATA-2 identify data, the SMART thresholds, or the SMART attributes for the device. This IOCTL must be handled by drivers that support SMART.
The buffer at Irp->AssociatedIrp.SystemBuffer contains a SENDCMDINPARAMS structure that describes the request being sent to the device. The irDriveRegs.bCommandReg member specifies ID_CMD when identify data is requested and SMART_CMD when SMART data is requested. If SMART data is requested, the irDriveRegs.bFeaturesReg member specifies either READ_ATTRIBUTES or READ_THRESHOLDS.
Parameters.DeviceIoControl.InputBufferLength specifies the size in bytes of the input buffer, which must be >= (sizeof(SENDCMDINPARAMS) - 1).
Parameters.DeviceIoControl.OutputBufferLength specifies the size in bytes of the output buffer, which must be >= (sizeof(SENDCMDOUTPARAMS) - 1 + 512).
The driver returns the SENDCMDOUTPARAMS structure and a 512-byte buffer of drive data to the buffer at Irp->AssociatedIrp.SystemBuffer.
The driver sets the Information field to (sizeof(SENDCMDOUTPARAMS) - 1 + 512) when it sets the Status field to STATUS_SUCCESS. Otherwise, the driver sets the Information field to zero and the Status field to possibly STATUS_INVALID_PARAMETER or STATUS_INSUFFICIENT_RESOURCES.
Sends one of the following SMART commands to the device:
This IOCTL must be handled by drivers that support SMART.
The buffer at Irp->AssociatedIrp.SystemBuffer contains a SENDCMDINPARAMS structure that describes the command being sent to the device. The irDriveRegs.bCommandReg member must specify SMART_CMD. The irDriveRegs.bFeaturesReg member must specify one of ENABLE_SMART, DISABLE_SMART, ENABLE_DISABLE_AUTOSAVE, SAVE_ATTRIBUTE_VALUES, EXECUTE_OFFLINE_DIAG, or RETURN_SMART_STATUS.
Parameters.DeviceIoControl.InputBufferLength specifies the size in bytes of the input buffer, which must be >= (sizeof(SENDCMDINPARAMS) - 1).
Parameters.DeviceIoControl.OutputBufferLength specifies the size in bytes of the output buffer, which must be >= (sizeof(SENDCMDOUTPARAMS) - 1). If SMART status is being requested, the output buffer must be >= (sizeof(SENDCMDOUTPARAMS) - 1 + sizeof(IDEREGS)).
The driver returns the SENDCMDOUTPARAMS structure to the buffer at
Irp->AssociatedIrp.SystemBuffer. If SMART status was requested, and
successfully received from the device, the driver includes the IDEREGS
structure in the output buffer.
When the driver sets the Status field to STATUS_SUCCESS, it sets the Information field is set to ((sizeof(SENDCMDOUTPARAMS) - 1) + sizeof(IDEREGS)) for returning SMART status and to (sizeof(SENDCMDOUTPARAMS) - 1) for all other commands. The driver should set the Status field to STATUS_INVALID_PARAMETER if an input parameter is incorrect or to STATUS_IO_DEVICE_ERROR if the device aborts a command it does not support. If Status is not STATUS_SUCCESS, the driver sets the Information field to zero.
Allows a driver to set the verify bit on a disk device object if the mode of the caller is kernel mode.
None
None
The Status field is set to STATUS_SUCCESS. If the mode of the requestor is not kernel mode, the requested operation is not performed, but STATUS_SUCCESS is still returned.
Allows a driver to clear the verify bit on a disk device object, if the mode of the caller is kernel mode.
None
None
The Status field is set to STATUS_SUCCESS. If the mode of the requestor is not kernel mode, the requested operation is not performed, but STATUS_SUCCESS is still returned.