예제 #1
0
        internal static PrivateHeader GetPrivateHeader(VirtualDisk disk)
        {
            if (disk.IsPartitioned)
            {
                long           headerPos = 0;
                PartitionTable pt        = disk.Partitions;
                if (pt is BiosPartitionTable)
                {
                    headerPos = 0xc00;
                }
                else
                {
                    foreach (var part in pt.Partitions)
                    {
                        if (part.GuidType == GuidPartitionTypes.WindowsLdmMetadata)
                        {
                            headerPos = part.LastSector * Sizes.Sector;
                        }
                    }
                }

                if (headerPos != 0)
                {
                    disk.Content.Position = headerPos;
                    byte[] buffer = new byte[Sizes.Sector];
                    disk.Content.Read(buffer, 0, buffer.Length);

                    PrivateHeader hdr = new PrivateHeader();
                    hdr.ReadFrom(buffer, 0);
                    return(hdr);
                }
            }

            return(null);
        }
예제 #2
0
        internal DynamicDisk(VirtualDisk disk)
        {
            _disk = disk;
            _header = GetPrivateHeader(_disk);

            TocBlock toc = GetTableOfContents();

            long dbStart = (_header.ConfigurationStartLba * 512) + (toc.Item1Start * 512);
            _disk.Content.Position = dbStart;
            _database = new Database(_disk.Content);
        }
예제 #3
0
        internal DynamicDisk(VirtualDisk disk)
        {
            _disk   = disk;
            _header = GetPrivateHeader(_disk);

            TocBlock toc = GetTableOfContents();

            long dbStart = (_header.ConfigurationStartLba * 512) + (toc.Item1Start * 512);

            _disk.Content.Position = dbStart;
            _database = new Database(_disk.Content);
        }
예제 #4
0
        /// <summary>
        /// Adds a new disk to be managed.
        /// </summary>
        /// <param name="disk">The disk to manage.</param>
        public void Add(VirtualDisk disk)
        {
            PrivateHeader header = DynamicDisk.GetPrivateHeader(disk);

            DynamicDiskGroup group;

            if (_groups.TryGetValue(header.DiskGroupId, out group))
            {
                group.Add(disk);
            }
            else
            {
                group = new DynamicDiskGroup(disk);
                _groups.Add(header.DiskGroupId, group);
            }
        }
예제 #5
0
        internal static PrivateHeader GetPrivateHeader(VirtualDisk disk)
        {
            if (disk.IsPartitioned)
            {
                long headerPos = 0;
                PartitionTable pt = disk.Partitions;
                if (pt is BiosPartitionTable)
                {
                    headerPos = 0xc00;
                }
                else
                {
                    foreach (var part in pt.Partitions)
                    {
                        if (part.GuidType == GuidPartitionTypes.WindowsLdmMetadata)
                        {
                            headerPos = part.LastSector * Sizes.Sector;
                        }
                    }
                }

                if (headerPos != 0)
                {
                    disk.Content.Position = headerPos;
                    byte[] buffer = new byte[Sizes.Sector];
                    disk.Content.Read(buffer, 0, buffer.Length);

                    PrivateHeader hdr = new PrivateHeader();
                    hdr.ReadFrom(buffer, 0);
                    return hdr;
                }
            }

            return null;
        }