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 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); }