A.1.4.2 Handling SCSI Pass-Through Requests

A class driver does not necessarily set up an SRB when it sets up an IRP_MJ_DEVICE_CONTROL request for an I/O control code supported by the port driver, such as IOCTL_SCSI_GET_CAPABILITIES, IOCTL_SCSI_PASS_THROUGH, or IOCTL_SCSI_PASS_THROUGH_DIRECT.

The class driver's DispatchDeviceControl routine is responsible for the following on receipt of a IOCTL_SCSI_PASS_THROUGH or IOCTL_SCSI_PASS_THROUGH_DIRECT request:

·Checking that the length of the user buffer at Parameters.DeviceIoControl.InputBufferLength is at least sizeof(SCSI_PASS_THROUGH) or sizeof(SCSI_PASS_THROUGH_DIRECT), respectively, and for failing the IRP with STATUS_INVALID_PARAMETER if is not

·Ensuring that certain fields in the SCSI_PASS_THROUGH or SCSI_PASS_THROUGH_DIRECT structure contain correct values by setting the pointer to the structure itself to Irp->AssociatedIrp.SystemBuffer, and setting its PathId, TargetId, and Lun members to the corresponding values from the driver's device extension

·Setting up the port driver's I/O stack location as usual and also setting the MinorFunction field to IRP_MN_SCSI_CLASS, which marks the request as having been processed by a SCSI class driver

If the port driver's I/O stack location for an IOCTL_SCSI_PASS_THROUGH or IOCTL_SCSI_PASS_THROUGH_DIRECT request does not have its MinorFunction field set with IRP_MN_SCSI_CLASS, the port driver assumes the request came directly from an application and that no class driver exists for the target device type. It is an application error to send such a request directly to the port driver for a device that has been claimed by a SCSI class driver.