Exemplo n.º 1
0
        private List <LogicalEntity> GetPartitions(byte[] contents)
        {
            List <LogicalEntity> entities = new List <LogicalEntity>();
            char partLetter = 'A';
            bool done       = false;

            for (int i = 0x1EE; !done && (i > 0x0D); i -= 0x10)
            {
                int numSect = contents[i + 12] + (contents[i + 13] << 8) + (contents[i + 14] << 16) + (contents[i + 15] << 24);
                if (numSect != 0)
                {
                    PartitionInfo part = new PartitionInfo();
                    part.numSectors       = numSect;
                    part.bootFlag         = ((contents[i] & 0x80) != 0);
                    part.startHead        = contents[i + 1];
                    part.startSector      = contents[i + 2];
                    part.startCylinder    = contents[i + 3];
                    part.partType         = contents[i + 4];
                    part.endHead          = contents[i + 5];
                    part.endTrack         = contents[i + 6];
                    part.endCylinder      = contents[i + 7];
                    part.StartTotalSector = contents[i + 8] + (contents[i + 9] << 8) + (contents[i + 10] << 16) + (contents[i + 11] << 24);
                    LogicalEntity newPartition = new LogicalPartition();
                    newPartition.diskImage   = this;
                    newPartition.name        = "Partition " + partLetter.ToString();
                    newPartition.startOffset = (part.StartTotalSector * 512);
                    newPartition.data        = part;
                    entities.Add(newPartition);
                    partLetter++;
                }
                else
                {
                    done = true;
                }
            }
            return(entities);
        }