Add interface to pass dump hardware list and CICM XML metadata to/from images.

This commit is contained in:
2018-01-28 20:29:46 +00:00
parent db766ac76e
commit df5f062500
65 changed files with 3470 additions and 2727 deletions

View File

@@ -39,30 +39,31 @@ using System.Text;
using DiscImageChef.CommonTypes;
using DiscImageChef.Console;
using DiscImageChef.Filters;
using Schemas;
namespace DiscImageChef.DiscImages
{
public class Vhdx : IMediaImage
{
const ulong VHDX_SIGNATURE = 0x656C696678646876;
const uint VHDX_HEADER_SIG = 0x64616568;
const uint VHDX_REGION_SIG = 0x69676572;
const ulong VHDX_SIGNATURE = 0x656C696678646876;
const uint VHDX_HEADER_SIG = 0x64616568;
const uint VHDX_REGION_SIG = 0x69676572;
const ulong VHDX_METADATA_SIG = 0x617461646174656D;
const string PARENT_LINKAGE_KEY = "parent_linkage";
const string PARENT_LINKAGE2_KEY = "parent_linkage2";
const string RELATIVE_PATH_KEY = "relative_path";
const string VOLUME_PATH_KEY = "volume_path";
const string PARENT_LINKAGE_KEY = "parent_linkage";
const string PARENT_LINKAGE2_KEY = "parent_linkage2";
const string RELATIVE_PATH_KEY = "relative_path";
const string VOLUME_PATH_KEY = "volume_path";
const string ABSOLUTE_WIN32_PATH_KEY = "absolute_win32_path";
const uint REGION_FLAGS_REQUIRED = 0x01;
const uint METADATA_FLAGS_USER = 0x01;
const uint METADATA_FLAGS_VIRTUAL = 0x02;
const uint METADATA_FLAGS_USER = 0x01;
const uint METADATA_FLAGS_VIRTUAL = 0x02;
const uint METADATA_FLAGS_REQUIRED = 0x04;
const uint FILE_FLAGS_LEAVE_ALLOCATED = 0x01;
const uint FILE_FLAGS_HAS_PARENT = 0x02;
const uint FILE_FLAGS_HAS_PARENT = 0x02;
/// <summary>Block has never been stored on this image, check parent</summary>
const ulong PAYLOAD_BLOCK_NOT_PRESENT = 0x00;
@@ -78,80 +79,80 @@ namespace DiscImageChef.DiscImages
const ulong PAYLOAD_BLOCK_PARTIALLY_PRESENT = 0x07;
const ulong SECTOR_BITMAP_NOT_PRESENT = 0x00;
const ulong SECTOR_BITMAP_PRESENT = 0x06;
const ulong SECTOR_BITMAP_PRESENT = 0x06;
const ulong BAT_FILE_OFFSET_MASK = 0xFFFFFFFFFFFC0000;
const ulong BAT_FLAGS_MASK = 0x7;
const ulong BAT_RESERVED_MASK = 0x3FFF8;
const ulong BAT_FLAGS_MASK = 0x7;
const ulong BAT_RESERVED_MASK = 0x3FFF8;
const int MAX_CACHE_SIZE = 16777216;
readonly Guid batGuid = new Guid("2DC27766-F623-4200-9D64-115E9BFD4A08");
readonly Guid fileParametersGuid = new Guid("CAA16737-FA36-4D43-B3B6-33F0AA44E76B");
readonly Guid logicalSectorSizeGuid = new Guid("8141BF1D-A96F-4709-BA47-F233A8FAAB5F");
readonly Guid metadataGuid = new Guid("8B7CA206-4790-4B9A-B8FE-575F050F886E");
readonly Guid page83DataGuid = new Guid("BECA12AB-B2E6-4523-93EF-C309E000C746");
readonly Guid parentLocatorGuid = new Guid("A8D35F2D-B30B-454D-ABF7-D3D84834AB0C");
readonly Guid parentTypeVhdxGuid = new Guid("B04AEFB7-D19E-4A81-B789-25B8E9445913");
const int MAX_CACHE_SIZE = 16777216;
readonly Guid batGuid = new Guid("2DC27766-F623-4200-9D64-115E9BFD4A08");
readonly Guid fileParametersGuid = new Guid("CAA16737-FA36-4D43-B3B6-33F0AA44E76B");
readonly Guid logicalSectorSizeGuid = new Guid("8141BF1D-A96F-4709-BA47-F233A8FAAB5F");
readonly Guid metadataGuid = new Guid("8B7CA206-4790-4B9A-B8FE-575F050F886E");
readonly Guid page83DataGuid = new Guid("BECA12AB-B2E6-4523-93EF-C309E000C746");
readonly Guid parentLocatorGuid = new Guid("A8D35F2D-B30B-454D-ABF7-D3D84834AB0C");
readonly Guid parentTypeVhdxGuid = new Guid("B04AEFB7-D19E-4A81-B789-25B8E9445913");
readonly Guid physicalSectorSizeGuid = new Guid("CDA348C7-445D-4471-9CC9-E9885251C556");
readonly Guid virtualDiskSizeGuid = new Guid("2FA54224-CD1B-4876-B211-5DBED83BF4B8");
readonly Guid virtualDiskSizeGuid = new Guid("2FA54224-CD1B-4876-B211-5DBED83BF4B8");
long batOffset;
ulong[] blockAllocationTable;
ulong[] blockAllocationTable;
Dictionary<ulong, byte[]> blockCache;
long chunkRatio;
ulong dataBlocks;
bool hasParent;
ImageInfo imageInfo;
Stream imageStream;
uint logicalSectorSize;
int maxBlockCache;
int maxSectorCache;
long metadataOffset;
Guid page83Data;
long chunkRatio;
ulong dataBlocks;
bool hasParent;
ImageInfo imageInfo;
Stream imageStream;
uint logicalSectorSize;
int maxBlockCache;
int maxSectorCache;
long metadataOffset;
Guid page83Data;
IMediaImage parentImage;
uint physicalSectorSize;
byte[] sectorBitmap;
ulong[] sectorBitmapPointers;
uint physicalSectorSize;
byte[] sectorBitmap;
ulong[] sectorBitmapPointers;
Dictionary<ulong, byte[]> sectorCache;
VhdxFileParameters vFileParms;
VhdxHeader vHdr;
VhdxFileParameters vFileParms;
VhdxHeader vHdr;
VhdxIdentifier vhdxId;
ulong virtualDiskSize;
VhdxMetadataTableHeader vMetHdr;
ulong virtualDiskSize;
VhdxMetadataTableHeader vMetHdr;
VhdxMetadataTableEntry[] vMets;
VhdxParentLocatorHeader vParHdr;
VhdxParentLocatorHeader vParHdr;
VhdxParentLocatorEntry[] vPars;
VhdxRegionTableHeader vRegHdr;
VhdxRegionTableEntry[] vRegs;
VhdxRegionTableHeader vRegHdr;
VhdxRegionTableEntry[] vRegs;
public Vhdx()
{
imageInfo = new ImageInfo
{
ReadableSectorTags = new List<SectorTagType>(),
ReadableMediaTags = new List<MediaTagType>(),
HasPartitions = false,
HasSessions = false,
Version = null,
Application = null,
ApplicationVersion = null,
Creator = null,
Comments = null,
MediaManufacturer = null,
MediaModel = null,
MediaSerialNumber = null,
MediaBarcode = null,
MediaPartNumber = null,
MediaSequence = 0,
LastMediaSequence = 0,
DriveManufacturer = null,
DriveModel = null,
DriveSerialNumber = null,
ReadableSectorTags = new List<SectorTagType>(),
ReadableMediaTags = new List<MediaTagType>(),
HasPartitions = false,
HasSessions = false,
Version = null,
Application = null,
ApplicationVersion = null,
Creator = null,
Comments = null,
MediaManufacturer = null,
MediaModel = null,
MediaSerialNumber = null,
MediaBarcode = null,
MediaPartNumber = null,
MediaSequence = 0,
LastMediaSequence = 0,
DriveManufacturer = null,
DriveModel = null,
DriveSerialNumber = null,
DriveFirmwareRevision = null
};
}
@@ -159,7 +160,7 @@ namespace DiscImageChef.DiscImages
public ImageInfo Info => imageInfo;
public string Name => "Microsoft VHDX";
public Guid Id => new Guid("536B141B-D09C-4799-AB70-34631286EB9D");
public Guid Id => new Guid("536B141B-D09C-4799-AB70-34631286EB9D");
public string Format => "VHDX";
@@ -181,7 +182,7 @@ namespace DiscImageChef.DiscImages
byte[] vhdxIdB = new byte[Marshal.SizeOf(vhdxId)];
stream.Read(vhdxIdB, 0, Marshal.SizeOf(vhdxId));
vhdxId = new VhdxIdentifier();
vhdxId = new VhdxIdentifier();
IntPtr idPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vhdxId));
Marshal.Copy(vhdxIdB, 0, idPtr, Marshal.SizeOf(vhdxId));
vhdxId = (VhdxIdentifier)Marshal.PtrToStructure(idPtr, typeof(VhdxIdentifier));
@@ -199,7 +200,7 @@ namespace DiscImageChef.DiscImages
byte[] vhdxIdB = new byte[Marshal.SizeOf(vhdxId)];
stream.Read(vhdxIdB, 0, Marshal.SizeOf(vhdxId));
vhdxId = new VhdxIdentifier();
vhdxId = new VhdxIdentifier();
IntPtr idPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vhdxId));
Marshal.Copy(vhdxIdB, 0, idPtr, Marshal.SizeOf(vhdxId));
vhdxId = (VhdxIdentifier)Marshal.PtrToStructure(idPtr, typeof(VhdxIdentifier));
@@ -212,7 +213,7 @@ namespace DiscImageChef.DiscImages
stream.Seek(64 * 1024, SeekOrigin.Begin);
byte[] vHdrB = new byte[Marshal.SizeOf(vHdr)];
stream.Read(vHdrB, 0, Marshal.SizeOf(vHdr));
vHdr = new VhdxHeader();
vHdr = new VhdxHeader();
IntPtr headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vHdr));
Marshal.Copy(vHdrB, 0, headerPtr, Marshal.SizeOf(vHdr));
vHdr = (VhdxHeader)Marshal.PtrToStructure(headerPtr, typeof(VhdxHeader));
@@ -223,7 +224,7 @@ namespace DiscImageChef.DiscImages
stream.Seek(128 * 1024, SeekOrigin.Begin);
vHdrB = new byte[Marshal.SizeOf(vHdr)];
stream.Read(vHdrB, 0, Marshal.SizeOf(vHdr));
vHdr = new VhdxHeader();
vHdr = new VhdxHeader();
headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vHdr));
Marshal.Copy(vHdrB, 0, headerPtr, Marshal.SizeOf(vHdr));
vHdr = (VhdxHeader)Marshal.PtrToStructure(headerPtr, typeof(VhdxHeader));
@@ -235,7 +236,7 @@ namespace DiscImageChef.DiscImages
stream.Seek(192 * 1024, SeekOrigin.Begin);
byte[] vRegTableB = new byte[Marshal.SizeOf(vRegHdr)];
stream.Read(vRegTableB, 0, Marshal.SizeOf(vRegHdr));
vRegHdr = new VhdxRegionTableHeader();
vRegHdr = new VhdxRegionTableHeader();
IntPtr vRegTabPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vRegHdr));
Marshal.Copy(vRegTableB, 0, vRegTabPtr, Marshal.SizeOf(vRegHdr));
vRegHdr = (VhdxRegionTableHeader)Marshal.PtrToStructure(vRegTabPtr, typeof(VhdxRegionTableHeader));
@@ -246,7 +247,7 @@ namespace DiscImageChef.DiscImages
stream.Seek(256 * 1024, SeekOrigin.Begin);
vRegTableB = new byte[Marshal.SizeOf(vRegHdr)];
stream.Read(vRegTableB, 0, Marshal.SizeOf(vRegHdr));
vRegHdr = new VhdxRegionTableHeader();
vRegHdr = new VhdxRegionTableHeader();
vRegTabPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vRegHdr));
Marshal.Copy(vRegTableB, 0, vRegTabPtr, Marshal.SizeOf(vRegHdr));
vRegHdr = (VhdxRegionTableHeader)Marshal.PtrToStructure(vRegTabPtr, typeof(VhdxRegionTableHeader));
@@ -261,14 +262,15 @@ namespace DiscImageChef.DiscImages
{
byte[] vRegB = new byte[Marshal.SizeOf(vRegs[i])];
stream.Read(vRegB, 0, Marshal.SizeOf(vRegs[i]));
vRegs[i] = new VhdxRegionTableEntry();
vRegs[i] = new VhdxRegionTableEntry();
IntPtr vRegPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vRegs[i]));
Marshal.Copy(vRegB, 0, vRegPtr, Marshal.SizeOf(vRegs[i]));
vRegs[i] = (VhdxRegionTableEntry)Marshal.PtrToStructure(vRegPtr, typeof(VhdxRegionTableEntry));
Marshal.FreeHGlobal(vRegPtr);
if(vRegs[i].guid == batGuid) batOffset = (long)vRegs[i].offset;
else if(vRegs[i].guid == metadataGuid) metadataOffset = (long)vRegs[i].offset;
if(vRegs[i].guid == batGuid) batOffset = (long)vRegs[i].offset;
else if(vRegs[i].guid == metadataGuid)
metadataOffset = (long)vRegs[i].offset;
else if((vRegs[i].flags & REGION_FLAGS_REQUIRED) == REGION_FLAGS_REQUIRED)
throw new
ImageNotSupportedException($"Found unsupported and required region Guid {vRegs[i].guid}, not proceeding with image.");
@@ -283,7 +285,7 @@ namespace DiscImageChef.DiscImages
stream.Seek(metadataOffset, SeekOrigin.Begin);
byte[] metTableB = new byte[Marshal.SizeOf(vMetHdr)];
stream.Read(metTableB, 0, Marshal.SizeOf(vMetHdr));
vMetHdr = new VhdxMetadataTableHeader();
vMetHdr = new VhdxMetadataTableHeader();
IntPtr metTablePtr = Marshal.AllocHGlobal(Marshal.SizeOf(vMetHdr));
Marshal.Copy(metTableB, 0, metTablePtr, Marshal.SizeOf(vMetHdr));
vMetHdr = (VhdxMetadataTableHeader)Marshal.PtrToStructure(metTablePtr, typeof(VhdxMetadataTableHeader));
@@ -294,18 +296,23 @@ namespace DiscImageChef.DiscImages
{
byte[] vMetB = new byte[Marshal.SizeOf(vMets[i])];
stream.Read(vMetB, 0, Marshal.SizeOf(vMets[i]));
vMets[i] = new VhdxMetadataTableEntry();
vMets[i] = new VhdxMetadataTableEntry();
IntPtr vMetPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vMets[i]));
Marshal.Copy(vMetB, 0, vMetPtr, Marshal.SizeOf(vMets[i]));
vMets[i] = (VhdxMetadataTableEntry)Marshal.PtrToStructure(vMetPtr, typeof(VhdxMetadataTableEntry));
Marshal.FreeHGlobal(vMetPtr);
if(vMets[i].itemId == fileParametersGuid) fileParamsOff = vMets[i].offset;
else if(vMets[i].itemId == virtualDiskSizeGuid) vdSizeOff = vMets[i].offset;
else if(vMets[i].itemId == page83DataGuid) p83Off = vMets[i].offset;
else if(vMets[i].itemId == logicalSectorSizeGuid) logOff = vMets[i].offset;
else if(vMets[i].itemId == physicalSectorSizeGuid) physOff = vMets[i].offset;
else if(vMets[i].itemId == parentLocatorGuid) parentOff = vMets[i].offset;
if(vMets[i].itemId == fileParametersGuid) fileParamsOff = vMets[i].offset;
else if(vMets[i].itemId == virtualDiskSizeGuid)
vdSizeOff = vMets[i].offset;
else if(vMets[i].itemId == page83DataGuid)
p83Off = vMets[i].offset;
else if(vMets[i].itemId == logicalSectorSizeGuid)
logOff = vMets[i].offset;
else if(vMets[i].itemId == physicalSectorSizeGuid)
physOff = vMets[i].offset;
else if(vMets[i].itemId == parentLocatorGuid)
parentOff = vMets[i].offset;
else if((vMets[i].flags & METADATA_FLAGS_REQUIRED) == METADATA_FLAGS_REQUIRED)
throw new
ImageNotSupportedException($"Found unsupported and required metadata Guid {vMets[i].itemId}, not proceeding with image.");
@@ -321,7 +328,7 @@ namespace DiscImageChef.DiscImages
vFileParms = new VhdxFileParameters
{
blockSize = BitConverter.ToUInt32(tmp, 0),
flags = BitConverter.ToUInt32(tmp, 4)
flags = BitConverter.ToUInt32(tmp, 4)
};
}
else throw new Exception("File parameters not found.");
@@ -366,7 +373,7 @@ namespace DiscImageChef.DiscImages
stream.Seek(parentOff + metadataOffset, SeekOrigin.Begin);
byte[] vParHdrB = new byte[Marshal.SizeOf(vMetHdr)];
stream.Read(vParHdrB, 0, Marshal.SizeOf(vMetHdr));
vParHdr = new VhdxParentLocatorHeader();
vParHdr = new VhdxParentLocatorHeader();
IntPtr vParHdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vMetHdr));
Marshal.Copy(vParHdrB, 0, vParHdrPtr, Marshal.SizeOf(vMetHdr));
vParHdr = (VhdxParentLocatorHeader)Marshal.PtrToStructure(vParHdrPtr, typeof(VhdxParentLocatorHeader));
@@ -381,7 +388,7 @@ namespace DiscImageChef.DiscImages
{
byte[] vParB = new byte[Marshal.SizeOf(vPars[i])];
stream.Read(vParB, 0, Marshal.SizeOf(vPars[i]));
vPars[i] = new VhdxParentLocatorEntry();
vPars[i] = new VhdxParentLocatorEntry();
IntPtr vParPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vPars[i]));
Marshal.Copy(vParB, 0, vParPtr, Marshal.SizeOf(vPars[i]));
vPars[i] = (VhdxParentLocatorEntry)Marshal.PtrToStructure(vParPtr, typeof(VhdxParentLocatorEntry));
@@ -392,9 +399,9 @@ namespace DiscImageChef.DiscImages
throw new Exception("Parent locator not found.");
if((vFileParms.flags & FILE_FLAGS_HAS_PARENT) == FILE_FLAGS_HAS_PARENT &&
vParHdr.locatorType == parentTypeVhdxGuid)
vParHdr.locatorType == parentTypeVhdxGuid)
{
parentImage = new Vhdx();
parentImage = new Vhdx();
bool parentWorks = false;
foreach(VhdxParentLocatorEntry parentEntry in vPars)
@@ -440,7 +447,8 @@ namespace DiscImageChef.DiscImages
// ignored
}
}
else if(string.Compare(entryType, VOLUME_PATH_KEY, StringComparison.OrdinalIgnoreCase) == 0 ||
else if(string.Compare(entryType, VOLUME_PATH_KEY, StringComparison.OrdinalIgnoreCase) ==
0 ||
string.Compare(entryType, ABSOLUTE_WIN32_PATH_KEY, StringComparison.OrdinalIgnoreCase) == 0)
{
stream.Seek(parentEntry.valueOffset + metadataOffset, SeekOrigin.Begin);
@@ -470,14 +478,14 @@ namespace DiscImageChef.DiscImages
}
chunkRatio = (long)(Math.Pow(2, 23) * logicalSectorSize / vFileParms.blockSize);
dataBlocks = virtualDiskSize / vFileParms.blockSize;
if(virtualDiskSize % vFileParms.blockSize > 0) dataBlocks++;
dataBlocks = virtualDiskSize / vFileParms.blockSize;
if(virtualDiskSize % vFileParms.blockSize > 0) dataBlocks++;
long batEntries;
if(hasParent)
{
long sectorBitmapBlocks = (long)dataBlocks / chunkRatio;
if(dataBlocks % (ulong)chunkRatio > 0) sectorBitmapBlocks++;
if(dataBlocks % (ulong)chunkRatio > 0) sectorBitmapBlocks++;
sectorBitmapPointers = new ulong[sectorBitmapBlocks];
batEntries = sectorBitmapBlocks * (chunkRatio - 1);
@@ -486,21 +494,21 @@ namespace DiscImageChef.DiscImages
DicConsole.DebugWriteLine("VHDX plugin", "Reading BAT");
long readChunks = 0;
long readChunks = 0;
blockAllocationTable = new ulong[dataBlocks];
byte[] batB = new byte[batEntries * 8];
byte[] batB = new byte[batEntries * 8];
stream.Seek(batOffset, SeekOrigin.Begin);
stream.Read(batB, 0, batB.Length);
ulong skipSize = 0;
for(ulong i = 0; i < dataBlocks; i++)
if(readChunks == chunkRatio)
if(readChunks == chunkRatio)
{
if(hasParent)
sectorBitmapPointers[skipSize / 8] = BitConverter.ToUInt64(batB, (int)(i * 8 + skipSize));
readChunks = 0;
skipSize += 8;
readChunks = 0;
skipSize += 8;
}
else
{
@@ -537,44 +545,33 @@ namespace DiscImageChef.DiscImages
sectorBmpMs.Close();
}
maxBlockCache = (int)(MAX_CACHE_SIZE / vFileParms.blockSize);
maxBlockCache = (int)(MAX_CACHE_SIZE / vFileParms.blockSize);
maxSectorCache = (int)(MAX_CACHE_SIZE / logicalSectorSize);
imageStream = stream;
sectorCache = new Dictionary<ulong, byte[]>();
blockCache = new Dictionary<ulong, byte[]>();
blockCache = new Dictionary<ulong, byte[]>();
imageInfo.CreationTime = imageFilter.GetCreationTime();
imageInfo.CreationTime = imageFilter.GetCreationTime();
imageInfo.LastModificationTime = imageFilter.GetLastWriteTime();
imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename());
imageInfo.SectorSize = logicalSectorSize;
imageInfo.XmlMediaType = XmlMediaType.BlockMedia;
imageInfo.MediaType = MediaType.GENERIC_HDD;
imageInfo.ImageSize = virtualDiskSize;
imageInfo.Sectors = imageInfo.ImageSize / imageInfo.SectorSize;
imageInfo.DriveSerialNumber = page83Data.ToString();
imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename());
imageInfo.SectorSize = logicalSectorSize;
imageInfo.XmlMediaType = XmlMediaType.BlockMedia;
imageInfo.MediaType = MediaType.GENERIC_HDD;
imageInfo.ImageSize = virtualDiskSize;
imageInfo.Sectors = imageInfo.ImageSize / imageInfo.SectorSize;
imageInfo.DriveSerialNumber = page83Data.ToString();
// TODO: Separate image application from version, need several samples.
imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63);
imageInfo.Heads = 16;
imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63);
imageInfo.Heads = 16;
imageInfo.SectorsPerTrack = 63;
return true;
}
bool CheckBitmap(ulong sectorAddress)
{
long index = (long)(sectorAddress / 8);
int shift = (int)(sectorAddress % 8);
byte val = (byte)(1 << shift);
if(index > sectorBitmap.LongLength) return false;
return (sectorBitmap[index] & val) == val;
}
public byte[] ReadSector(ulong sectorAddress)
{
if(sectorAddress > imageInfo.Sectors - 1)
@@ -583,10 +580,10 @@ namespace DiscImageChef.DiscImages
if(sectorCache.TryGetValue(sectorAddress, out byte[] sector)) return sector;
ulong index = sectorAddress * logicalSectorSize / vFileParms.blockSize;
ulong index = sectorAddress * logicalSectorSize / vFileParms.blockSize;
ulong secOff = sectorAddress * logicalSectorSize % vFileParms.blockSize;
ulong blkPtr = blockAllocationTable[index];
ulong blkPtr = blockAllocationTable[index];
ulong blkFlags = blkPtr & BAT_FLAGS_MASK;
if((blkPtr & BAT_RESERVED_MASK) != 0)
@@ -649,13 +646,6 @@ namespace DiscImageChef.DiscImages
return ms.ToArray();
}
static uint VhdxChecksum(IEnumerable<byte> data)
{
uint checksum = data.Aggregate<byte, uint>(0, (current, b) => current + b);
return ~checksum;
}
public byte[] ReadDiskTag(MediaTagType tag)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
@@ -732,7 +722,7 @@ namespace DiscImageChef.DiscImages
}
public bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> failingLbas,
out List<ulong> unknownLbas)
out List<ulong> unknownLbas)
{
failingLbas = new List<ulong>();
unknownLbas = new List<ulong>();
@@ -742,7 +732,7 @@ namespace DiscImageChef.DiscImages
}
public bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> failingLbas,
out List<ulong> unknownLbas)
out List<ulong> unknownLbas)
{
throw new FeatureUnsupportedImageException("Feature not supported by image format");
}
@@ -752,6 +742,27 @@ namespace DiscImageChef.DiscImages
return null;
}
public List<DumpHardwareType> DumpHardware => null;
public CICMMetadataType CicmMetadata => null;
bool CheckBitmap(ulong sectorAddress)
{
long index = (long)(sectorAddress / 8);
int shift = (int)(sectorAddress % 8);
byte val = (byte)(1 << shift);
if(index > sectorBitmap.LongLength) return false;
return (sectorBitmap[index] & val) == val;
}
static uint VhdxChecksum(IEnumerable<byte> data)
{
uint checksum = data.Aggregate<byte, uint>(0, (current, b) => current + b);
return ~checksum;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct VhdxIdentifier
{
@@ -762,11 +773,12 @@ namespace DiscImageChef.DiscImages
/// <summary>
/// UTF-16 string containing creator
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)] public byte[] creator;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)]
public byte[] creator;
}
#pragma warning disable 649
#pragma warning disable 169
#pragma warning disable 649
#pragma warning disable 169
struct VhdxHeader
{
/// <summary>
@@ -809,10 +821,11 @@ namespace DiscImageChef.DiscImages
/// Offset from image start to the log
/// </summary>
public ulong LogOffset;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4016)] public byte[] Reserved;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4016)]
public byte[] Reserved;
}
#pragma warning restore 649
#pragma warning restore 169
#pragma warning restore 649
#pragma warning restore 169
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct VhdxRegionTableHeader
@@ -874,7 +887,8 @@ namespace DiscImageChef.DiscImages
/// <summary>
/// Reserved
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] public uint[] reserved2;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public uint[] reserved2;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
@@ -921,7 +935,7 @@ namespace DiscImageChef.DiscImages
/// <summary>
/// Type of parent virtual disk
/// </summary>
public Guid locatorType;
public Guid locatorType;
public ushort reserved;
/// <summary>
/// How many KVPs are in this parent locator