Esempio n. 1
0
 /// <summary>
 /// Creates an empty MBR partition table entry
 /// </summary>
 public PartitionTableEntry()
 {
     Status         = PartitionStatus.Inactive;
     FirstSector    = new CHS();
     LastSector     = new CHS();
     Type           = PartitionType.Empty;
     LBAFirstSector = LBASectorCount = 0;
 }
Esempio n. 2
0
 /// <summary>
 /// Creates a partition table entry from the given bytes
 /// </summary>
 /// <param name="RawData">Partition table bytes</param>
 public PartitionTableEntry(byte[] RawData)
 {
     if (RawData == null)
     {
         throw new ArgumentNullException(nameof(RawData));
     }
     if (RawData.Length != ENTRY_SIZE)
     {
         throw new ArgumentOutOfRangeException(nameof(RawData), $"Partition table entry must be {ENTRY_SIZE} bytes long");
     }
     using (var MS = new MemoryStream(RawData, false))
     {
         using (var BR = new BinaryReader(MS))
         {
             Status         = (PartitionStatus)BR.ReadByte();
             FirstSector    = new CHS(BR.ReadBytes(3));
             Type           = (PartitionType)BR.ReadByte();
             LastSector     = new CHS(BR.ReadBytes(3));
             LBAFirstSector = BR.ReadUInt32();
             LBASectorCount = BR.ReadUInt32();
         }
     }
 }