From: ted.lin on 23 May 2005 03:00 Dear all, I use the SCSI command to read the CD-ROM. The below is my code. DiskDevice= CreateFile("\\\\.\\E", // file name GENERIC_READ | GENERIC_WRITE , // access mode FILE_SHARE_READ |FILE_SHARE_WRITE, // share mode NULL, // SD OPEN_EXISTING, // how to create 0, // file attrib NULL ); // handle to template file SRB_EXECSCSICMD srbExec; memset ( &srbExec, 0, sizeof ( SRB_EXECSCSICMD ) ); srbExec.SRB_Cmd = SC_EXEC_SCSI_CMD; srbExec.SRB_HaId = SCSI_HaId; srbExec.SRB_Target = SCSI_TargetId; srbExec.SRB_Lun = SCSI_Lun; srbExec.SRB_Flags = SRB_DIR_IN; srbExec.SRB_BufLen = len; srbExec.SRB_BufPointer = pbtBuffer; srbExec.SRB_SenseLen = SENSE_LEN; srbExec.SRB_CDBLen = 12; srbExec.CDBByte [ 0 ] = 0x28; srbExec.CDBByte [ 2 ] = (addr>>24)&0xff; srbExec.CDBByte [ 3 ] = (addr>>16)&0xff; srbExec.CDBByte [ 4 ] = (addr>>8)&0xff; srbExec.CDBByte [ 5 ] = addr&0xff; srbExec.CDBByte [ 7 ] = (len>>8)&0xff; srbExec.CDBByte [ 8 ] = len&0xff; BOOL status; SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER swb; ULONG length, returned; ZeroMemory( &swb, sizeof(swb) ); swb.spt.Length = sizeof(SCSI_PASS_THROUGH); swb.spt.CdbLength = lpsrb->SRB_CDBLen; if ( lpsrb->SRB_Flags & SRB_DIR_IN ) swb.spt.DataIn = SCSI_IOCTL_DATA_IN; else if ( lpsrb->SRB_Flags & SRB_DIR_OUT ) swb.spt.DataIn = SCSI_IOCTL_DATA_OUT; else swb.spt.DataIn = SCSI_IOCTL_DATA_UNSPECIFIED; swb.spt.DataTransferLength = lpsrb->SRB_BufLen; swb.spt.TimeOutValue = 1000; swb.spt.DataBuffer = lpsrb->SRB_BufPointer; swb.spt.SenseInfoOffset = offsetof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER,ucSenseBuf ); memcpy( swb.spt.Cdb, lpsrb->CDBByte, lpsrb->SRB_CDBLen ); length = sizeof(swb); status = DeviceIoControl( DiskDevice, IOCTL_SCSI_PASS_THROUGH_DIRECT, &swb, length, &swb, length, &returned, NULL ); if ( status ) { lpsrb->SRB_Status = SS_COMP; } When I set the len = 1, the status is always ok. other value the IOCTL will time out and cannot work well. Would you lead me what happened in my code? I see the READ(10) command. It show me the len is the trasfer length. But I cannot write the right command. Could you tell me where can I get the right method to call the READ(10) command? Thanks.
|
Pages: 1 Prev: performance counter value using PDH Next: bluetooth problem with irprops.dll |