INFO: Read and Write Access Required for SCSI Pass Through Requests (241374)



The information in this article applies to:

  • Microsoft Windows NT Server 4.0
  • Microsoft Windows NT Server 4.0 SP4
  • Microsoft Windows NT Workstation 4.0
  • Microsoft Windows NT Workstation 4.0 SP4

This article was previously published under Q241374

SUMMARY

Starting with Windows NT 4.0 Service Pack 4 and beyond (including Windows 2000), there are new access requirements for SCSI (small computer system interface) pass through requests. For SCSI pass through requests, both GENERIC_READ and GENERIC_WRITE access must be specified in the dwDesiredAccess parameter of the CreateFile call.

If both read and write access are not specified, the DeviceIoControl call will fail with ERROR_ACCESS_DENIED (5L).

Note that only members of the administrator's group have the correct authority to send SCSI pass through requests. Users without administrator authority typically fail either CreateFile or DeviceIoControl with ERROR_ACCESS_DENIED (5L).

MORE INFORMATION

Following is a code snippet showing a proper call to CreateFile.


    // Open the device for SCSI pass through requests.  Make
    // sure to specify both GENERIC_READ and GENERIC_WRITE
    // or the SCSI pass through request will fail.

    hDevice = CreateFile("\\\\.\\F:,
                         GENERIC_READ | GENERIC_WRITE,
                         FILE_SHARE_READ | FILE_SHARE_WRITE,
                         NULL, 
                         OPEN_EXISTING, 
                         FILE_ATTRIBUTE_NORMAL,
                         NULL
                         );

    // Check that CreateFile worked.  If it fails, it returns
    // an invalid handle.

    if (INVALID_HANDLE_VALUE == hDevice) {
    
        dwErrorCode = GetLastError();
        printf("CreateFile failed.  Error %d \n", dwErrorCode);
        return dwErrorCode;
    }

				

Modification Type:MinorLast Reviewed:7/22/2004
Keywords:kbinfo kbStorageDev KB241374