Exemple #1
0
        // Token: 0x06000526 RID: 1318 RVA: 0x00052A84 File Offset: 0x00050C84
        public static HardDiskInfo GetHddInfo(byte driveIndex)
        {
            switch (Environment.OSVersion.Platform)
            {
            case PlatformID.Win32S:
                break;

            case PlatformID.Win32Windows:
                return(AtapiDevice.GetHddInfo9x(driveIndex));

            case PlatformID.Win32NT:
                try
                {
                    return(AtapiDevice.GetHddInfoNT(driveIndex));
                }
                catch (ApplicationException ex)
                {
                    throw ex;
                }
                break;

            case PlatformID.WinCE:
                throw new NotSupportedException("WinCE is not supported.");

            default:
                throw new NotSupportedException("Unknown Platform.");
            }
            throw new NotSupportedException("Win32s is not supported.");
        }
Exemple #2
0
        // Token: 0x06000529 RID: 1321 RVA: 0x00052E68 File Offset: 0x00051068
        private static HardDiskInfo GetHardDiskInfo(IdSector phdinfo)
        {
            HardDiskInfo result = default(HardDiskInfo);

            AtapiDevice.ChangeByteOrder(phdinfo.sModelNumber);
            result.ModuleNumber = Encoding.ASCII.GetString(phdinfo.sModelNumber).Trim();
            AtapiDevice.ChangeByteOrder(phdinfo.sFirmwareRev);
            result.Firmware = Encoding.ASCII.GetString(phdinfo.sFirmwareRev).Trim();
            AtapiDevice.ChangeByteOrder(phdinfo.sSerialNumber);
            result.SerialNumber = Encoding.ASCII.GetString(phdinfo.sSerialNumber).Trim();
            result.Capacity     = phdinfo.ulTotalAddressableSectors / 2U / 1024U;
            return(result);
        }
Exemple #3
0
        // 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));
        }