private GuidPartitionTable(string devicePath)
        {
            byte[] bytes = GuidPartitionTable.GetBytes(devicePath);

            // Test GPT Signature
            Signature = Encoding.ASCII.GetString(bytes, 0x00, 0x08);

            if (Signature == SIGNATURE_STRING)
            {
                Revision   = new Version(BitConverter.ToUInt16(bytes, 0x08), BitConverter.ToUInt16(bytes, 0x0A));
                HeaderSize = BitConverter.ToUInt32(bytes, 0x0C);
                // Get HeaderCRC32 Value
                #region MyLBA

                MyLBA = BitConverter.ToUInt64(bytes, 0x18);
                if (MyLBA != 1)
                {
                    throw new Exception("Invalid MyLBA property value");
                }

                #endregion MyLBA
                AlternateLBA             = BitConverter.ToUInt64(bytes, 0x20);
                FirstUsableLBA           = BitConverter.ToUInt64(bytes, 0x28);
                LastUsableLBA            = BitConverter.ToUInt64(bytes, 0x30);
                DiskGuid                 = new Guid(Helper.GetSubArray(bytes, 0x38, 0x10));
                PartitionEntryLBA        = BitConverter.ToUInt64(bytes, 0x48);
                NumberOfPartitionEntries = BitConverter.ToUInt32(bytes, 0x50);
                SizeOfPartitionEntry     = BitConverter.ToUInt32(bytes, 0x54);
                // Get PartitionEntryArrayCRC32 Value
            }
            else
            {
                throw new Exception("Invalid GPT Signature");
            }

            PartitionTable = GuidPartitionTableEntry.GetInstances(bytes, NumberOfPartitionEntries, SizeOfPartitionEntry);
        }
Esempio n. 2
0
 public static GuidPartitionTable Get(string devicePath)
 {
     return(new GuidPartitionTable(GuidPartitionTable.GetBytes(devicePath)));
 }