public DeviceElementValue(Guid parentObject, PhysicalVolumeInfo pvi)
        {
            _parentObject = parentObject;

            PartitionRecord record = new PartitionRecord();
            record.Type = 6;
            if (pvi.VolumeType == PhysicalVolumeType.BiosPartition)
            {
                record.PartitionType = 1;
                record.DiskIdentity = new byte[4];
                Utilities.WriteBytesLittleEndian(pvi.DiskSignature, record.DiskIdentity, 0);
                record.PartitionIdentity = new byte[8];
                Utilities.WriteBytesLittleEndian(pvi.PhysicalStartSector * 512, record.PartitionIdentity, 0);
            }
            else if (pvi.VolumeType == PhysicalVolumeType.GptPartition)
            {
                record.PartitionType = 0;
                record.DiskIdentity = new byte[16];
                Utilities.WriteBytesLittleEndian(pvi.DiskIdentity, record.DiskIdentity, 0);
                record.PartitionIdentity = new byte[16];
                Utilities.WriteBytesLittleEndian(pvi.PartitionIdentity, record.PartitionIdentity, 0);
            }
            else
            {
                throw new NotImplementedException(string.Format(CultureInfo.InvariantCulture, "Unknown how to convert volume type {0} to a Device element", pvi.VolumeType));
            }

            _record = record;
        }
Example #2
0
        public DeviceElementValue(Guid parentObject, PhysicalVolumeInfo pvi)
        {
            _parentObject = parentObject;

            PartitionRecord record = new PartitionRecord();

            record.Type = 6;
            if (pvi.VolumeType == PhysicalVolumeType.BiosPartition)
            {
                record.PartitionType = 1;
                record.DiskIdentity  = new byte[4];
                Utilities.WriteBytesLittleEndian(pvi.DiskSignature, record.DiskIdentity, 0);
                record.PartitionIdentity = new byte[8];
                Utilities.WriteBytesLittleEndian(pvi.PhysicalStartSector * 512, record.PartitionIdentity, 0);
            }
            else if (pvi.VolumeType == PhysicalVolumeType.GptPartition)
            {
                record.PartitionType = 0;
                record.DiskIdentity  = new byte[16];
                Utilities.WriteBytesLittleEndian(pvi.DiskIdentity, record.DiskIdentity, 0);
                record.PartitionIdentity = new byte[16];
                Utilities.WriteBytesLittleEndian(pvi.PartitionIdentity, record.PartitionIdentity, 0);
            }
            else
            {
                throw new NotImplementedException(string.Format(CultureInfo.InvariantCulture, "Unknown how to convert volume type {0} to a Device element", pvi.VolumeType));
            }

            _record = record;
        }
        public DeviceElementValue()
        {
            _parentObject = Guid.Empty;

            PartitionRecord record = new PartitionRecord();
            record.Type = 5;
            _record = record;
        }
        protected override void DoParse(byte[] data, int offset)
        {
            base.DoParse(data, offset);

            _container = DeviceRecord.Parse(data, offset + 0x34);

            int pathStart = 0x34 + _container.Size;
            _path = Encoding.Unicode.GetString(data, offset + pathStart, Length - pathStart);
        }
Example #5
0
        public DeviceElementValue()
        {
            _parentObject = Guid.Empty;

            PartitionRecord record = new PartitionRecord();

            record.Type = 5;
            _record     = record;
        }
Example #6
0
        protected override void DoParse(byte[] data, int offset)
        {
            base.DoParse(data, offset);

            _container = DeviceRecord.Parse(data, offset + 0x34);

            int pathStart = 0x34 + _container.Size;

            _path = Encoding.Unicode.GetString(data, offset + pathStart, Length - pathStart);
        }
Example #7
0
        public static DeviceRecord Parse(byte[] data, int offset)
        {
            int type   = Utilities.ToInt32LittleEndian(data, offset);
            int length = Utilities.ToInt32LittleEndian(data, offset + 0x8);

            if (offset + length > data.Length)
            {
                throw new InvalidDataException("Device record is truncated");
            }

            DeviceRecord newRecord = null;

            switch (type)
            {
            case 0:
                newRecord = new DeviceAndPathRecord();
                break;

            case 5:     // Logical 'boot' device
            case 6:     // Disk partition
                newRecord = new PartitionRecord();
                break;

            case 8:     // custom:nnnnnn
                break;

            default:
                throw new NotImplementedException("Unknown device type: " + type);
            }

            if (newRecord != null)
            {
                newRecord.DoParse(data, offset);
            }

            return(newRecord);
        }
 public DeviceElementValue(byte[] value)
 {
     _parentObject = Utilities.ToGuidLittleEndian(value, 0x00);
     _record = DeviceRecord.Parse(value, 0x10);
 }
Example #9
0
 public DeviceElementValue(byte[] value)
 {
     _parentObject = Utilities.ToGuidLittleEndian(value, 0x00);
     _record       = DeviceRecord.Parse(value, 0x10);
 }