ThievingSix
asked on
DeviceIOControl, vendor-specific SCSI command blocks
Well, I've come to poke Ex-Ex again over this question. I need to use windows to send a SCSI command to a usb device. I have a source for linux but have been told that without rewriting a driver I won't be able to do this. I don't think that's the case(although it very well may be).
I've also been told that I need to use IOCTL_SCSI_PASS_THROUGH_DI RECT although I've gotten a ERROR_REVISION_MISMATCH error from DeviceIOControl.
Any ideas(I can provide the source for the linux version if need be)?
I've also been told that I need to use IOCTL_SCSI_PASS_THROUGH_DI
Any ideas(I can provide the source for the linux version if need be)?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
After meddling and testing, to my surprise, it has worked. Code below.
Thanks for answering though, I've posted this question 2x before with no one knowing what to do.
Thanks for answering though, I've posted this question 2x before with no one knowing what to do.
var
PD : DWORD;
Buffer : PChar;
BytesReturned : DWORD;
srb : SCSI_PASS_THROUGH_DIRECT;
begin
PD := GetPD(GetPhysicalDiskNumber('H'));
If PD = INVALID_HANDLE_VALUE Then
begin
ShowMessage(Format('%d - 1',[GetLastError]));
Exit;
end;
ZeroMemory(@srb,SizeOf(srb));
Buffer := AllocMem(512);
BytesReturned := 0;
srb.Length := sizeof(srb);
srb.Lun := 2;
srb.Cdb[0] := Byte(Commands[5].Cmd[1]);
srb.Cdb[1] := Byte(Commands[5].Cmd[2]);
srb.Cdb[2] := Byte(Commands[5].Cmd[3]);
srb.Cdb[3] := Byte(Commands[5].Cmd[4]);
srb.Cdb[4] := Byte(Commands[5].Cmd[5]);
srb.Cdb[5] := Byte(Commands[5].Cmd[6]);
srb.Cdb[6] := Byte(Commands[5].Cmd[7]);
srb.Cdb[7] := Byte(Commands[5].Cmd[8]);
srb.Cdb[8] := Byte(Commands[5].Cmd[9]);
srb.Cdb[9] := Byte(Commands[5].Cmd[10]);
srb.CdbLength := Commands[5].Len;
srb.DataIn := 1;
srb.TimeOutValue := 10;
srb.DataBuffer := Buffer;
srb.DataTransferLength := 512;
If Not(DeviceIOControl(PD,IOCTL_SCSI_PASS_THROUGH_DIRECT,@srb,SizeOf(srb),@srb,SizeOf(srb),BytesReturned,nil)) Then
begin
ShowMessage(Format('%d - 2',[GetLastError]));
end;
CloseHandle(PD);
Memo1.Text := HexDump(Buffer,512);
FreeMem(Buffer,512);
ASKER
Here is a bit more detail.
When acting as a USB mass storage controller ("USB Connection" mode),
the PSP accepts a few vendor-specific SCSI command blocks. This
program sends these commands via the Linux generic SCSI interface and
displays the results. To run, pass it the device node of your connected PSP.
I'm supposed to send a sg_io_hdr struct using the generic SCSI interface. I know of those constants for DeviceIOControl() but I don't know how to tie them into the sg_io_hdr_t struct.
Open in new window