|
代码是这样的:
SCSI_PASS_THROUGH_WITH_BUFFERS *sptwb; //send 13bytes the first use this;
sptwb=new SCSI_PASS_THROUGH_WITH_BUFFERS();
ZeroMemory(sptwb,sizeof(SCSI_PASS_THROUGH_WITH_BUFFERS));
sptwb->spt.Length = sizeof(SCSI_PASS_THROUGH);
sptwb->spt.PathId = 0;
sptwb->spt.TargetId = 0;
sptwb->spt.Lun= 0;
sptwb->spt.CdbLength = CDB10GENERIC_LENGTH;//+CDB6GENERIC_LENGTH
sptwb->spt.SenseInfoLength = 0;
sptwb->spt.TimeOutValue = 5;
sptwb->spt.SenseInfoOffset=offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS, ucSenseBuf);
sptwb->spt.DataBufferOffset = offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS, ucDataBuf);
sptwb->spt.DataIn = SCSI_IOCTL_DATA_OUT|SCSI_IOCTL_DATA_IN;
sptwb->spt.DataTransferLength = sizeof(sptwb->spt);
sptwb->spt.Cdb[0] =0xcf;//SCSIOP_WRITE;
sptwb->spt.Cdb[1] =0x01;//Cdb[0]&Cdb[1] is the command which is self defined in the vimicro device cf01:mimayanzhen
for(int i=0,j=0;i<6;i++,j++)
{
psw=strMima.GetAt(j);
sptwb->spt.Cdb[2+i] =psw;
}
bResult =DeviceIoControl(hDevice,
IOCTL_SCSI_PASS_THROUGH,
sptwb,
sizeof(SCSI_PASS_THROUGH_WITH_BUFFERS),
sptwb,
sizeof(SCSI_PASS_THROUGH_WITH_BUFFERS),
(unsigned long *)&nBytes,
NULL);
if(!bResult)
{
int iERR=GetLastError();
TRACE("ERROR CODE:%d\n",iERR);
}
|
|