// Token: 0x06000527 RID: 1319 RVA: 0x00052AFC File Offset: 0x00050CFC private static HardDiskInfo GetHddInfo9x(byte driveIndex) { GetVersionOutParams getVersionOutParams = default(GetVersionOutParams); SendCmdInParams sendCmdInParams = default(SendCmdInParams); SendCmdOutParams sendCmdOutParams = default(SendCmdOutParams); uint num = 0U; IntPtr intPtr = AtapiDevice.CreateFile("\\\\.\\Smartvsd", 0U, 0U, IntPtr.Zero, 1U, 0U, IntPtr.Zero); if (intPtr == IntPtr.Zero) { throw new Exception("Open smartvsd.vxd failed."); } if (AtapiDevice.DeviceIoControl(intPtr, 475264U, IntPtr.Zero, 0U, ref getVersionOutParams, (uint)Marshal.SizeOf(getVersionOutParams), ref num, IntPtr.Zero) == 0) { AtapiDevice.CloseHandle(intPtr); throw new Exception("DeviceIoControl failed:DFP_GET_VERSION"); } if ((getVersionOutParams.fCapabilities & 1U) == 0U) { AtapiDevice.CloseHandle(intPtr); throw new Exception("Error: IDE identify command not supported."); } if ((driveIndex & 1) != 0) { sendCmdInParams.irDriveRegs.bDriveHeadReg = 176; } else { sendCmdInParams.irDriveRegs.bDriveHeadReg = 160; } if (0UL != ((ulong)getVersionOutParams.fCapabilities & (ulong)((long)(16 >> (int)driveIndex)))) { AtapiDevice.CloseHandle(intPtr); throw new Exception(string.Format("Drive {0} is a ATAPI device, we don't detect it", (int)(driveIndex + 1))); } sendCmdInParams.irDriveRegs.bCommandReg = 236; sendCmdInParams.bDriveNumber = driveIndex; sendCmdInParams.irDriveRegs.bSectorCountReg = 1; sendCmdInParams.irDriveRegs.bSectorNumberReg = 1; sendCmdInParams.cBufferSize = 512U; if (AtapiDevice.DeviceIoControl(intPtr, 508040U, ref sendCmdInParams, (uint)Marshal.SizeOf(sendCmdInParams), ref sendCmdOutParams, (uint)Marshal.SizeOf(sendCmdOutParams), ref num, IntPtr.Zero) == 0) { AtapiDevice.CloseHandle(intPtr); throw new Exception("DeviceIoControl failed: DFP_RECEIVE_DRIVE_DATA"); } AtapiDevice.CloseHandle(intPtr); return(AtapiDevice.GetHardDiskInfo(sendCmdOutParams.bBuffer)); }
private static extern int DeviceIoControl(IntPtr hDevice, uint dwIoControlCode, IntPtr lpInBuffer, uint nInBufferSize, ref GetVersionOutParams lpOutBuffer, uint nOutBufferSize, ref uint lpBytesReturned, [Out] IntPtr lpOverlapped);