Exemplo n.º 1
0
        //Convert primary GPT to backupGPT
        public void ToggleMirror()
        {
            UInt64 backup;

            backup = gptHeader.currentLba;
            gptHeader.currentLba = gptHeader.backupLba;
            gptHeader.backupLba  = backup;
            if (gptHeader.entriesStart == 2)
            {
                gptHeader.entriesStart = gptHeader.currentLba - 32;
            }
            else
            {
                gptHeader.entriesStart = 2;
            }
            gptHeader.UpdateCRC32(CRC.CRC32(gptPartitionTable.ToByteArray()));
        }
Exemplo n.º 2
0
 //Create GPT for BFS
 public GPT(UInt64 totalSectors, UInt32 bytesPerSector)
 {
     pmbr              = new MBR(totalSectors > UInt32.MaxValue ? UInt32.MaxValue : (UInt32)totalSectors, bytesPerSector, true);
     gptHeader         = new GPTHeader((UInt32)totalSectors, bytesPerSector);
     reserved          = new byte[420];
     gptPartitionTable = new GPTPartitionTable();
     reserved2         = new byte[3072];
     //create partition entry
     gptPartitionTable.partitions = new GPTPartition[152];
     gptPartitionTable.partitions[0].BFSParitionType = new Guid("53525542-4354-494F-4E46-494C45535953");
     gptPartitionTable.partitions[0].partitionGuid   = Guid.NewGuid();
     gptPartitionTable.partitions[0].startPos        = 40;
     gptPartitionTable.partitions[0].endPos          = (5 + 2 + ((((UInt64)totalSectors * bytesPerSector / 4096) - 12) / 64 / 64) * 64 * 64) * (4096 / bytesPerSector);
     gptPartitionTable.partitions[0].attributes      = 0;
     //gptEntries[0].partitionName = //Optional Name :-)
     //Update CRCs
     gptHeader.UpdateCRC32(CRC.CRC32(gptPartitionTable.ToByteArray()));
 }
Exemplo n.º 3
0
 public void UpdateCRC32(UInt32 partitionTablecCRC32)
 {
     crc32Array  = partitionTablecCRC32;
     crc32Header = 0;
     crc32Header = CRC.CRC32(ToByteArray());
 }