/// <summary>
/// Reads the master boot block.
/// </summary>
/// <returns></returns>
public bool Read()
{
valid = false;
MasterBootBlock mbr = new MasterBootBlock(diskDevice);
if (!mbr.Valid)
return false;
if ((mbr.Partitions[0].PartitionType != PartitionType.GPT) ||
(mbr.Partitions[1].PartitionType != PartitionType.Empty) ||
(mbr.Partitions[2].PartitionType != PartitionType.Empty) ||
(mbr.Partitions[3].PartitionType != PartitionType.Empty) ||
(!mbr.Partitions[0].Bootable) || (mbr.Partitions[0].StartLBA != 1))
return false;
BinaryFormat gpt = new BinaryFormat(diskDevice.ReadBlock(1, 1));
if ((gpt.GetByte(0) != 45) && (gpt.GetByte(1) != 46) && (gpt.GetByte(2) != 49) && (gpt.GetByte(3) != 20) &&
(gpt.GetByte(4) != 50) && (gpt.GetByte(5) != 41) && (gpt.GetByte(6) != 52) && (gpt.GetByte(7) != 54))
return false;
if ((gpt.GetUInt(GPT.Revision) != GPTConstant.SupportedRevision) ||
(gpt.GetUInt(GPT.HeaderSize) != GPTConstant.HeaderSize) ||
(gpt.GetUInt(GPT.Reserved) != 0) ||
(gpt.GetUInt(GPT.PartitionStartingLBA) != 2)
)
return false;
valid = true;
return valid;
}