|
系统中有一SCSI controller 卡,驱动为miniport driver,在用户态,我使用CreateFile("\\\\.\\Scsi2:"........)打开设备,没出现问题,但在DeviceIoControl中,程序出现55号错误,即:“The specified network resource or device is no longer available.”不知为什么?
代码如下:
UCHAR string[NAME_COUNT + 1];
char buffer[sizeof(SRB_IO_CONTROL)+1];
PSRB_IO_CONTROL psrbio = (PSRB_IO_CONTROL) buffer;
psrbio->HeaderLength = sizeof (SRB_IO_CONTROL);
psrbio->Timeout = 10000;
psrbio->Length = 1;
strncpy((char *)psrbio->Signature,"SCSIDISK",8);
_snprintf(string, NAME_COUNT, "\\\\.\\Scsi2:");
string[NAME_COUNT] = 0;
shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; // default
accessMode = GENERIC_WRITE | GENERIC_READ; // default
fileHandle = CreateFile(string,
accessMode,
shareMode,
NULL,
OPEN_EXISTING,
0,
NULL);
if (fileHandle == INVALID_HANDLE_VALUE) {
errorCode = GetLastError();
printf("Error opening %s. Error: %d\n",
string, errorCode);
return;
}
sr = DeviceIoControl(fileHandle,
IOCTL_SCSI_MINIPORT,
buffer,
sizeof(SRB_IO_CONTROL)+1,
buffer,
sizeof(SRB_IO_CONTROL)+1,
&result,
NULL);
if(!sr){
printf("Failure in ioctl!\n");
errorCode = GetLastError();
printf("Error: %d\n",
errorCode);
PrintError(errorCode);
}
CloseHandle(fileHandle);
|
|