The master boot record of a physical disk.
Inheritance: PhysicalDiskSection
コード例 #1
0
        private void GetDiskSections()
        {
            _sections = new List <PhysicalDiskSection>();
            try {
                _masterBootRecord = new MasterBootRecord(this);
                _sections.Add(_masterBootRecord);
                ulong offset = MasterBootRecord.MBR_SIZE;
                foreach (MasterBootRecord.PartitionEntry pEntry in _masterBootRecord.PartitionEntries)
                {
                    if (pEntry.PartitionOffset > offset)
                    {
                        _sections.Add(new UnallocatedDiskArea(this, offset, pEntry.PartitionOffset - offset));
                    }
                    if (offset > pEntry.PartitionOffset)
                    {
                        throw new Exception("Something went wrong!");
                    }

                    _sections.Add(new PhysicalDiskPartition(this, pEntry));

                    offset = pEntry.PartitionOffset + pEntry.PartitionLength;
                }
                if (StreamLength > offset)
                {
                    _sections.Add(new UnallocatedDiskArea(this, offset, StreamLength - offset));
                }
            } catch (Exception) { }
        }
コード例 #2
0
		public PhysicalDiskPartition(WinPhysicalDisk disk, MasterBootRecord.PartitionEntry pEntry) {
			PhysicalDisk = disk;
			Offset = pEntry.PartitionOffset;
			Length = pEntry.PartitionLength;

			ManagementScope ms = new ManagementScope();
			ObjectQuery oq = new ObjectQuery(
					string.Format("SELECT * FROM Win32_DiskPartition WHERE DiskIndex = {0} AND Index = {1}",
					disk.Attributes.Index, pEntry.Index));
			ManagementObjectSearcher mos = new ManagementObjectSearcher(ms, oq);
			ManagementObjectCollection moc = mos.Get();
			if (moc.Count != 1) {
				throw new Exception("Unable to get partition data from WMI");
			}
			foreach (ManagementObject mo in moc) {
				Attributes = new PhysicalDiskPartitionAttributes(mo, disk);
				break;
			}
			Attributes.PartitionType = pEntry.PartitionType;

			_fileSystem = FileSystem.TryLoad(this as IFileSystemStore);
		}
コード例 #3
0
		private void GetDiskSections() {
			_sections = new List<PhysicalDiskSection>();
			try {
				_masterBootRecord = new MasterBootRecord(this);
				_sections.Add(_masterBootRecord);
				ulong offset = MasterBootRecord.MBR_SIZE;
				foreach (MasterBootRecord.PartitionEntry pEntry in _masterBootRecord.PartitionEntries) {
					if (pEntry.PartitionOffset > offset) {
						_sections.Add(new UnallocatedDiskArea(this, offset, pEntry.PartitionOffset - offset));
					}
					if (offset > pEntry.PartitionOffset) {
						throw new Exception("Something went wrong!");
					}

					_sections.Add(new PhysicalDiskPartition(this, pEntry));

					offset = pEntry.PartitionOffset + pEntry.PartitionLength;
				}
				if (StreamLength > offset) {
					_sections.Add(new UnallocatedDiskArea(this, offset, StreamLength - offset));
				}
			} catch (Exception) { }
		}