I am new to SCSI command to DeviceIoControl API.
Will the SCSI Command support USB Memory Stick Device to READ10 WRITE10 operation?
or only bulk read and bulk write only possible?
I am new to SCSI command to DeviceIoControl API.
Will the SCSI Command support USB Memory Stick Device to READ10 WRITE10 operation?
or only bulk read and bulk write only possible?
From what level? From the disk class driver, a USBSTORAGE device is a
standard scsi disk device, That is the perspective above usbstor. From
below usbstor it is all bulk usb operations, as defined in the usb
specs.
Mark Roddy
On Mon, Sep 28, 2009 at 11:58 PM, wrote:
>
> ? I am new to SCSI command to DeviceIoControl API.
>
> Will the SCSI Command support USB Memory Stick Device to READ10 WRITE10 operation?
>
> or only bulk read and bulk write only possible?
>
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>
Mark is right. If you have a disk class lower filter you’ll get all the SCSI
commands.
On Tue, Sep 29, 2009 at 8:08 AM, Mark Roddy wrote:
> From what level? From the disk class driver, a USBSTORAGE device is a
> standard scsi disk device, That is the perspective above usbstor. From
> below usbstor it is all bulk usb operations, as defined in the usb
> specs.
>
> Mark Roddy
>
>
>
> On Mon, Sep 28, 2009 at 11:58 PM, wrote:
> >
> > I am new to SCSI command to DeviceIoControl API.
> >
> > Will the SCSI Command support USB Memory Stick Device to READ10 WRITE10
> operation?
> >
> > or only bulk read and bulk write only possible?
> >
> >
> >
> > —
> > NTDEV is sponsored by OSR
> >
> > For our schedule of WDF, WDM, debugging and other seminars visit:
> > http://www.osr.com/seminars
> >
> > To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
> >
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
I am using device path to create handle for the device as below…
\?\storage#removablemedia#7&7274f86&0&rm#{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}
So i feel it will work from USBSTORAGE driver.
CreateFile(DevicePhysicalPath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
NULL,
NULL);
I am able to send INQUIRY and READ10 command.
INQUIRY is working fine.
READ10 working if i pass LBA value 69 (0x45) then it read from MBR of USB stick.
WRITE10 is try to write into CDROM the handle is same as READ10 and INQUIRY.
I suppose you are using spti. How you prepare the parameter for READ10 and
WRITE10? Show more code or details.
On Wed, Sep 30, 2009 at 12:01 AM, wrote:
> I am using device path to create handle for the device as below…
>
>
> \?\storage#removablemedia#7&7274f86&0&rm#{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}
>
> So i feel it will work from USBSTORAGE driver.
>
> CreateFile(DevicePhysicalPath,
> GENERIC_READ | GENERIC_WRITE,
> FILE_SHARE_READ | FILE_SHARE_WRITE,
> NULL,
> OPEN_EXISTING,
> NULL,
> NULL);
>
> I am able to send INQUIRY and READ10 command.
> INQUIRY is working fine.
> READ10 working if i pass LBA value 69 (0x45) then it read from MBR of USB
> stick.
> WRITE10 is try to write into CDROM the handle is same as READ10 and
> INQUIRY.
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
READ10 SCSI example.
SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER sptdwb;
PUCHAR dataBuffer = NULL;
ULONG length = 0,
errorCode = 0,
returned = 0,
sectorSize = 512;
BOOL status = 0;
ULONG alignmentMask = 0;
ULONG c_lba =1;
dataBuffer = (PUCHAR)malloc(512);
ZeroMemory(&sptdwb, sizeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER));
//ZeroMemory(dataBuffer,sectorSize);
sptdwb.sptd.Length = sizeof(SCSI_PASS_THROUGH_DIRECT);
sptdwb.sptd.PathId = 0;
sptdwb.sptd.TargetId = 0;
sptdwb.sptd.Lun = 0;
sptdwb.sptd.CdbLength = CDB10_LENGTH;
sptdwb.sptd.DataIn = SCSI_IOCTL_DATA_IN;
sptdwb.sptd.SenseInfoLength = 32;
sptdwb.sptd.DataTransferLength = SECTORSIZE;
sptdwb.sptd.TimeOutValue = 60; //interval in seconds
sptdwb.sptd.DataBuffer = dataBuffer;
sptdwb.sptd.SenseInfoOffset = offsetof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER,ucSenseBuf);
sptdwb.sptd.Cdb[0] = 0x28;
sptdwb.sptd.Cdb[1] = 0; // Data mode
sptdwb.sptd.Cdb[2] = (UCHAR)(c_lba >> 24) & 0xFF; // MSB of lba
sptdwb.sptd.Cdb[3] = (UCHAR)(c_lba >> 16) & 0xFF;
sptdwb.sptd.Cdb[4] = (UCHAR)(c_lba >> 8) & 0xFF;
sptdwb.sptd.Cdb[5] = (UCHAR)(c_lba) & 0xFF; // LSB of lba // Zero means MBR. Very careful when write operation.
sptdwb.sptd.Cdb[6] = 0x00;
sptdwb.sptd.Cdb[7] = (UCHAR)(SECTORSIZE >> 8)& 0xFF;
sptdwb.sptd.Cdb[8] = (UCHAR)(SECTORSIZE) & 0xFF; // Parameter List length
sptdwb.sptd.Cdb[9] = 0x00;
length = sizeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER);
status = DeviceIoControl(g_hUsbDriver,
IOCTL_SCSI_PASS_THROUGH_DIRECT,
&sptdwb,
length,
&sptdwb,
length,
&returned,
NULL);