Exemple #1
0
        private static HardDiskInfo smethod_2(byte byte_0)
        {
            Struct10 struct2 = new Struct10();
            Struct12 struct3 = new Struct12();
            Struct14 struct4 = new Struct14();
            uint     num     = 0;
            IntPtr   ptr     = CreateFile(string.Format(@"\\.\PhysicalDrive{0}", byte_0), 0xc0000000, 3, IntPtr.Zero, 3, 0, IntPtr.Zero);

            if (ptr == IntPtr.Zero)
            {
                throw new Exception("CreateFile faild.");
            }
            if (0 == DeviceIoControl(ptr, 0x74080, IntPtr.Zero, 0, ref struct2, (uint)Marshal.SizeOf(struct2), ref num, IntPtr.Zero))
            {
                CloseHandle(ptr);
                throw new Exception(string.Format("Drive {0} may not exists.", byte_0 + 1));
            }
            if (0 == (struct2.uint_0 & 1))
            {
                CloseHandle(ptr);
                throw new Exception("Error: IDE identify command not supported.");
            }
            if (0 != (byte_0 & 1))
            {
                struct3.struct11_0.byte_5 = 0xb0;
            }
            else
            {
                struct3.struct11_0.byte_5 = 160;
            }
            if (0 != (struct2.uint_0 & (((int)0x10) >> byte_0)))
            {
                CloseHandle(ptr);
                throw new Exception(string.Format("Drive {0} is a ATAPI device, we don''t detect it.", byte_0 + 1));
            }
            struct3.struct11_0.byte_6 = 0xec;
            struct3.byte_0            = byte_0;
            struct3.struct11_0.byte_1 = 1;
            struct3.struct11_0.byte_2 = 1;
            struct3.uint_0            = 0x200;
            if (0 == DeviceIoControl_1(ptr, 0x7c088, ref struct3, (uint)Marshal.SizeOf(struct3), ref struct4, (uint)Marshal.SizeOf(struct4), ref num, IntPtr.Zero))
            {
                CloseHandle(ptr);
                throw new Exception("DeviceIoControl failed: DFP_RECEIVE_DRIVE_DATA");
            }
            CloseHandle(ptr);
            return(smethod_3(struct4.struct15_0));
        }
Exemple #2
0
 internal static extern bool GetCharABCWidths(IntPtr A_0, int A_1, int A_2, ref Struct12 A_3);
Exemple #3
0
 private static extern int DeviceIoControl_1(IntPtr intptr_0, uint uint_9, ref Struct12 struct12_0, uint uint_10, ref Struct14 struct14_0, uint uint_11, ref uint uint_12, [Out] IntPtr intptr_1);