示例#1
0
 /*
  * CTOR - Creates FATBootSector and Calculates Partition Cluster Start LBA
  *
  */
 public Partition(byte[] bootSectorBytes, HardDrive hdd, PartitionTableEntry entry)
 {
     if (entry.TypeCode == 0x0B || entry.TypeCode == 0x0C)
     {
         bootSector = new FATBootSector(bootSectorBytes);
         //Partition cluster starts immediately following both FAT's
         clusterBeginLBA = entry.LBA_Begin1 + bootSector.BPB.ReservedSectors + (bootSector.BPB.NumOfFATs * bootSector.BPB.SectorsPerFAT32);
         fatBeginLBA = entry.LBA_Begin1 + bootSector.BPB.ReservedSectors;
     }
     this.hdd = hdd;
     this.entry = entry;
 }
示例#2
0
 /*
  * CTOR - Creates FATBootSector and Calculates Partition Cluster Start LBA
  *
  */
 public Partition(byte[] bootSectorBytes, HardDrive hdd, PartitionTableEntry entry)
 {
     if (entry.TypeCode == 0x0B || entry.TypeCode == 0x0C)
     {
         bootSector = new FATBootSector(bootSectorBytes);
         //Partition cluster starts immediately following both FAT's
         clusterBeginLBA = entry.LBA_Begin1 + bootSector.BPB.ReservedSectors + (bootSector.BPB.NumOfFATs * bootSector.BPB.SectorsPerFAT32);
         fatBeginLBA     = entry.LBA_Begin1 + bootSector.BPB.ReservedSectors;
     }
     this.hdd   = hdd;
     this.entry = entry;
 }
示例#3
0
        /*
         * CTOR - Deserializes partition table bytes and creates partition table entries
         */
        public PartitionTable(byte[] data)
        {
            //Four partitions per partition table (64 bytes)
            partitions = new PartitionTableEntry[4];

            //Iterate over each entry
            for (int i = 0; i < 4; i++)
            {
                byte[] entry = new byte[16];
                Array.Copy(data, i * 16, entry, 0, entry.Length);

                //Deserialize
                partitions[i] = new PartitionTableEntry(entry);
            }
        }
示例#4
0
        /*
         * CTOR - Deserializes partition table bytes and creates partition table entries
         */
        public PartitionTable(byte[] data)
        {
            //Four partitions per partition table (64 bytes)
            partitions = new PartitionTableEntry[4];

            //Iterate over each entry
            for (int i = 0; i < 4; i++)
            {
                byte[] entry = new byte[16];
                Array.Copy(data, i * 16, entry, 0, entry.Length);

                //Deserialize
                partitions[i] = new PartitionTableEntry(entry);
            }
        }
示例#5
0
        /*
         * ParseDirectoryEntries - Seeks disk to Directory Table start then begins recursive creation         *
         */
        public void ParseDirectoryEntries(BufferedDiskReader disk)
        {
            disk.SeekAbsolute((ulong)this.clusterBeginLBA * BootSector.BPB.BytesPerSector);

            int error = Marshal.GetLastWin32Error();

            byte[] data = new byte[32];
            disk.Read(data, 0, data.Length);

            rootDirectory = new DirectoryEntry(data, disk, this);
            if (!rootDirectory.IsVolumeID)
            {
                DirectoryEntry entry = rootDirectory;
                rootDirectory = new DirectoryEntry();
                rootDirectory.Children.Add(entry);
                disk.Read(data, 0, data.Length);
                entry = new DirectoryEntry(data, disk, this);
                while (entry.Type != DirectoryEntryType.EndOfDirectory)
                {
                    if (entry.Type != DirectoryEntryType.Unused)
                    {
                        rootDirectory.Children.Add(entry);
                    }
                    disk.Read(data, 0, data.Length);
                    entry = new DirectoryEntry(data, disk, this);
                }
            }
        }