internal GPT(byte[] GPTBuffer) { this.GPTBuffer = GPTBuffer; UInt32?TempHeaderOffset = ByteOperations.FindAscii(GPTBuffer, "EFI PART"); if (TempHeaderOffset == null) { throw new WPinternalsException("Bad GPT"); } HeaderOffset = (UInt32)TempHeaderOffset; HeaderSize = ByteOperations.ReadUInt32(GPTBuffer, HeaderOffset + 0x0C); TableOffset = HeaderOffset + 0x200; FirstUsableSector = ByteOperations.ReadUInt64(GPTBuffer, HeaderOffset + 0x28); LastUsableSector = ByteOperations.ReadUInt64(GPTBuffer, HeaderOffset + 0x30); MaxPartitions = ByteOperations.ReadUInt32(GPTBuffer, HeaderOffset + 0x50); PartitionEntrySize = ByteOperations.ReadUInt32(GPTBuffer, HeaderOffset + 0x54); TableSize = MaxPartitions * PartitionEntrySize; if ((TableOffset + TableSize) > GPTBuffer.Length) { throw new WPinternalsException("Bad GPT"); } UInt32 PartitionOffset = TableOffset; while (PartitionOffset < (TableOffset + TableSize)) { string Name = ByteOperations.ReadUnicodeString(GPTBuffer, PartitionOffset + 0x38, 0x48).TrimEnd(new char[] { (char)0, ' ' }); if (Name.Length == 0) { break; } Partition CurrentPartition = new Partition(); CurrentPartition.Name = Name; CurrentPartition.FirstSector = ByteOperations.ReadUInt64(GPTBuffer, PartitionOffset + 0x20); CurrentPartition.LastSector = ByteOperations.ReadUInt64(GPTBuffer, PartitionOffset + 0x28); CurrentPartition.PartitionTypeGuid = ByteOperations.ReadGuid(GPTBuffer, PartitionOffset + 0x00); CurrentPartition.PartitionGuid = ByteOperations.ReadGuid(GPTBuffer, PartitionOffset + 0x10); CurrentPartition.Attributes = ByteOperations.ReadUInt64(GPTBuffer, PartitionOffset + 0x30); Partitions.Add(CurrentPartition); PartitionOffset += PartitionEntrySize; } HasChanged = false; }