SCSI Pass-Through Interface

Hi!

I hope someone can help me with a problem accessing SCSI drives via the
Windows NT Pass-Through Interface under Windows 2000.

After calling DeviceIoControl, I get a sense key telling me that I have an
invalid field in my CDB. This happens with almost all commands that require
some data to be returned.

typedef struct _NT_SCSI_REQUEST_DIRECT
{
SCSI_PASS_THROUGH_DIRECT sPass;
SENSE_DATA sSense;
} NT_SCSI_REQUEST_DIRECT;

hDrive = ::CreateFile (
strDeviceName,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);

CDVD_CAPABILITIES_PAGE sCapabilities;

// Set up CDB
memset (&sCDB.MODE_SENSE10, 0, sizeof (sCDB.MODE_SENSE10));
sCDB.MODE_SENSE10.Pc = 0;
sCDB.MODE_SENSE10.PageCode = 0x2A;
sCDB.MODE_SENSE10.AllocationLength [1] = sizeof (sCapabilities);

// Clear Mode Page
memset (&sCapabilities, 0, sizeof (sCapabilities));

// Set up structure for DeviceIoControl
memset (&sScsiRequest, 0, sizeof (sScsiRequest));
sScsiRequest.sPass.Length = sizeof (sScsiRequest.sPass);
// SCSI Address
sScsiRequest.sPass.PathId = psDeviceInfo->sScsiAddress.PathId;
sScsiRequest.sPass.TargetId = psDeviceInfo->sScsiAddress.TargetId;
sScsiRequest.sPass.Lun = psDeviceInfo->sScsiAddress.Lun;
// CDB Information
memcpy (sScsiRequest.sPass.Cdb, &sCDB.MODE_SENSE10, sizeof
(sCDB.MODE_SENSE10));
sScsiRequest.sPass.CdbLength = sizeof (sCDB.MODE_SENSE10);
// Data
sScsiRequest.sPass.DataBuffer = &sCapabilities;
sScsiRequest.sPass.DataTransferLength = sizeof (sCapabilities);
sScsiRequest.sPass.DataIn = SCSI_IOCTL_DATA_IN;
// Sense Information
sScsiRequest.sPass.SenseInfoOffset = offsetof (NT_SCSI_REQUEST_DIRECT,
sSense);
sScsiRequest.sPass.SenseInfoLength = sizeof (sScsiRequest.sSense);
// Timeout
sScsiRequest.sPass.TimeOutValue = 30; // 15s

// Sending command
bResult = ::DeviceIoControl (
hDrive,
IOCTL_SCSI_PASS_THROUGH_DIRECT,
&sScsiRequest,
sizeof (sScsiRequest),
&sScsiRequest,
sizeof (sScsiRequest),
&dwBytesReturned,
NULL);

Regards,

Ren?


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

You’re gonna smack your head on this one.
You’ve forgotten to set the operation code in the CDB, so you’ve probably been
issuing TEST_UNIT_READYs.
Try adding:
sScsiRequest.sPass.OperationCode = SCSIOP_MODE_SENSE10;

Regards,

Paul Bunn, UltraBac.com, 425-644-6000
Microsoft MVP - WindowsNT/2000
http://www.ultrabac.com

-----Original Message-----
From: JUNG, Rene [mailto:xxxxx@rrmess.at]
Sent: Friday, June 01, 2001 12:34 AM
To: NT Developers Interest List
Subject: [ntdev] SCSI Pass-Through Interface

Hi!

I hope someone can help me with a problem accessing SCSI drives via the
Windows NT Pass-Through Interface under Windows 2000.

After calling DeviceIoControl, I get a sense key telling me that I have an
invalid field in my CDB. This happens with almost all commands that require
some data to be returned.

// CDB Information
memcpy (sScsiRequest.sPass.Cdb, &sCDB.MODE_SENSE10, sizeof
(sCDB.MODE_SENSE10));
sScsiRequest.sPass.CdbLength = sizeof (sCDB.MODE_SENSE10);
// Data
sScsiRequest.sPass.DataBuffer = &sCapabilities;
sScsiRequest.sPass.DataTransferLength = sizeof (sCapabilities);
sScsiRequest.sPass.DataIn = SCSI_IOCTL_DATA_IN;
// Sense Information
sScsiRequest.sPass.SenseInfoOffset = offsetof (NT_SCSI_REQUEST_DIRECT,
sSense);
sScsiRequest.sPass.SenseInfoLength = sizeof (sScsiRequest.sSense);
// Timeout
sScsiRequest.sPass.TimeOutValue = 30; // 15s

// Sending command
bResult = ::DeviceIoControl (
hDrive,
IOCTL_SCSI_PASS_THROUGH_DIRECT,
&sScsiRequest,
sizeof (sScsiRequest),
&sScsiRequest,
sizeof (sScsiRequest),
&dwBytesReturned,
NULL);


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com