Hi,
I am sending SCSI_INQUIRY from an application to
the port driver. This application works fine for the Non-Disk
devices but returns ERROR_INVALID_FUNCTION for the Disk
devices.
Does anyone has any idea about it?
I am sending the inquiry as follows:
int iRetVal , i;
unsigned int align = 8 ;
UCHAR ucDataBuf[MAX_RECV_DATA_SIZE] ;
SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER scsiCmd ;
ULONG length = 0, inLength = 0, errorCode = 0, returned = 0 ;
ZeroMemory(&scsiCmd,sizeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER));
memcpy(ucDataBuf ,m_scsiCmdBuffer.SRB_BufPointer,
m_scsiCmdBuffer.SRB_BufLen) ;
memcpy(scsiCmd.sptd.Cdb,m_scsiCmdBuffer.SRB_CDBByte,
TR_SCSI_CDB_SIZE );
scsiCmd.sptd.Length = sizeof(SCSI_PASS_THROUGH);
scsiCmd.sptd.PathId = gBus;
scsiCmd.sptd.TargetId = gTarget;
scsiCmd.sptd.CdbLength = m_scsiCmdBuffer.SRB_CDBLen;
scsiCmd.sptd.SenseInfoLength = m_scsiCmdBuffer.SRB_SenseLen ;
scsiCmd.sptd.DataIn = m_scsiCmdBuffer.SRB_Flags;
scsiCmd.sptd.DataTransferLength = m_scsiCmdBuffer.SRB_BufLen ;
scsiCmd.sptd.TimeOutValue = USCSI_TIMEOUT ;
scsiCmd.sptd.DataBuffer = ucDataBuf ;
scsiCmd.sptd.SenseInfoOffset =
offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS,ucSenseBuf) ;
scsiCmd.sptd.Lun = gLun;
if (m_scsiCmdBuffer.SRB_BufLen <
sizeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER))
length = sizeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER) ;
else
length = m_scsiCmdBuffer.SRB_BufLen ;
if (length < 512 )
length= 512 ;
iRetVal = DeviceIoControl(m_Handle.Handle,
IOCTL_SCSI_PASS_THROUGH_DIRECT,
&scsiCmd,
length ,
&scsiCmd,
length,
&returned,
FALSE);
memcpy(m_scsiCmdBuffer.SRB_BufPointer,ucDataBuf,
m_scsiCmdBuffer.SRB_BufLen) ;
if(iRetVal == 0) {
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default
language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
printf(“\nERROR : %s\n”, lpMsgBuf) ;
// Free the buffer.
LocalFree( lpMsgBuf );
fprintf(stderr,“\n SENSE ERROR:IOCTL Fail with iRetVal = %d
\n”, iRetVal) ;
sprintf(m_scsiCmdBuffer.SRB_SenseArea,“ERROR:IOCTL Fail with
iRetVal = %d”, iRetVal) ;
m_Status = iRetVal ;
m_errorCode = MY_IOCTL_FAIL ;
/*
Here m_retVal is undfined
*/
return MY_ERROR ;
}
return (MY_SUCCESS) ;