DeviceIoControl调用失败,窗口错误代码为183

时间:2012-11-14 03:19:34

标签: c# windows ioctl iscsi

我正在尝试将缓冲区数据写入SCSI设备,但是当我触发deviceIoControl调用时,我得到了Windows错误代码183.错误代码表示文件已经退出,但我无法理解有关的错误IOCTL致电。

传递的CreateFile函数,因为我能够获得适当的设备句柄,如下所示。

int devHandle = DeviceIoControlHelper.CreateFile(                        设备名称,                        DeviceIoControlHelper.GENERIC_READ | DeviceIoControlHelper.GENERIC_WRITE,                        DeviceIoControlHelper.FILE_SHARE_READ | DeviceIoControlHelper.FILE_SHARE_WRITE,                        IntPtr.Zero,                        DeviceIoControlHelper.OPEN_EXISTING,                        0,                        IntPtr.Zero);

但是,当我尝试编写缓冲区时,我收到错误:

 dwReturned = 0;
        int b = DeviceIoControlHelper.DeviceIoControl(
                devHandle,
                DeviceIoControlHelper.IOCTL_SCSI_PASS_THROUGH,
                inpBuffer,
                (uint)Marshal.SizeOf(info),
                inpBuffer, //out pDriveLayout,
                (uint)Marshal.SizeOf(info), //(uint)Marshal.SizeOf(typeof(DRIVE_LAYOUT_INFORMATION_EX)),
                out dwReturned,
                IntPtr.Zero);

        Log.Write(Log.TraceLevel_5,"ExecuteDeviceIoControl return pass_through scsistatus = " + info.spt.ScsiStatus);
        if (b == 0)
        {
            int win_err = this.GetWindowsErrorCode();
            Log.Write(Log.TraceLevel_5, "ExecuteDeviceIoControl failed, error =  " + win_err);
            LogMyTrace.Write(LogMyTrace.TraceLevel_5, "ExecuteDeviceIoControl failed, error =  " + win_err);

            this.CloseOpenHandle(devHandle);
            Marshal.FreeHGlobal(inpBuffer);
            throw new Exception("DeviceIoControl  failed " + deviceName +
                    " is '" + deviceName + "'. Windows Err is " + win_err);
        }
The error code is 183.

请提供一些输入,说明造成此错误的原因和灵魂。

我使用的是Windows 2008 R2(x64),它是iSCSI路径。

0 个答案:

没有答案