//---------------------------------------------------------------------------
BOOL __fastcall TUsbDrive::read_2kbuff(HANDLE hDevice, int address, BYTE* pbuf)
{
SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER sptdwb;
ZeroMemory(&sptdwb, sizeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER));
ZeroMemory(pbuf,2048);
sptdwb.sptd.Length = sizeof(SCSI_PASS_THROUGH_DIRECT);
sptdwb.sptd.PathId = 0;
sptdwb.sptd.TargetId = 1;
sptdwb.sptd.Lun = 0;
sptdwb.sptd.CdbLength = CDB10GENERIC_LENGTH;
sptdwb.sptd.DataIn = SCSI_IOCTL_DATA_IN;
sptdwb.sptd.SenseInfoLength = 0;
sptdwb.sptd.DataTransferLength = 1024;
sptdwb.sptd.TimeOutValue = 0x20;
sptdwb.sptd.DataBuffer = pbuf;
sptdwb.sptd.SenseInfoOffset =
offsetof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER,ucSenseBuf);
sptdwb.sptd.Cdb[0] = 0xC9;
sptdwb.sptd.Cdb[1] = 0;
sptdwb.sptd.Cdb[2]= 2;
sptdwb.sptd.Cdb[3]= 0;
sptdwb.sptd.Cdb[4]= (address>>8)&0xff;
sptdwb.sptd.Cdb[5]= (address&0xff);
sptdwb.sptd.Cdb[6] = 0;
sptdwb.sptd.Cdb[7] = 4;
sptdwb.sptd.Cdb[8] = 0;
sptdwb.sptd.Cdb[9] = 0;
ULONG length = sizeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER);
ULONG returned;
BOOL status;
for (int i=0;i<5;i++)
{
status= DeviceIoControl(hDevice,
IOCTL_SCSI_PASS_THROUGH_DIRECT,
&sptdwb,
length,
&sptdwb,
length,
&returned,
FALSE);
if (status) break;
}
return status;
}
这段代码 是win32上的,里面的DeviceIoControl这个函数是不是就是libusb里面的 libusb_control_transfer