2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2016-08-29 03:38:18 +01:00
|
|
|
// The Disc Image Chef
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : VHDX.cs
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
// Component : Disk image plugins.
|
2016-08-29 03:38:18 +01:00
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
// Manages Microsoft Hyper-V disk images.
|
2016-08-29 03:38:18 +01:00
|
|
|
//
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// This library is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
// published by the Free Software Foundation; either version 2.1 of the
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This library is distributed in the hope that it will be useful, but
|
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2016-08-29 03:38:18 +01:00
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
2017-12-21 07:08:26 +00:00
|
|
|
using System.Linq;
|
2016-08-29 03:38:18 +01:00
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using DiscImageChef.CommonTypes;
|
2018-06-25 19:08:16 +01:00
|
|
|
using DiscImageChef.CommonTypes.Enums;
|
|
|
|
|
using DiscImageChef.CommonTypes.Exceptions;
|
|
|
|
|
using DiscImageChef.CommonTypes.Interfaces;
|
|
|
|
|
using DiscImageChef.CommonTypes.Structs;
|
2016-08-29 03:38:18 +01:00
|
|
|
using DiscImageChef.Console;
|
2016-09-05 17:37:31 +01:00
|
|
|
using DiscImageChef.Filters;
|
2018-01-28 20:29:46 +00:00
|
|
|
using Schemas;
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
namespace DiscImageChef.DiscImages
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
public class Vhdx : IMediaImage
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
2018-01-28 20:29:46 +00:00
|
|
|
const ulong VHDX_SIGNATURE = 0x656C696678646876;
|
|
|
|
|
const uint VHDX_HEADER_SIG = 0x64616568;
|
|
|
|
|
const uint VHDX_REGION_SIG = 0x69676572;
|
2017-12-20 17:15:26 +00:00
|
|
|
const ulong VHDX_METADATA_SIG = 0x617461646174656D;
|
|
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
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";
|
2017-12-20 17:15:26 +00:00
|
|
|
const string ABSOLUTE_WIN32_PATH_KEY = "absolute_win32_path";
|
|
|
|
|
|
|
|
|
|
const uint REGION_FLAGS_REQUIRED = 0x01;
|
|
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
const uint METADATA_FLAGS_USER = 0x01;
|
|
|
|
|
const uint METADATA_FLAGS_VIRTUAL = 0x02;
|
2017-12-20 17:15:26 +00:00
|
|
|
const uint METADATA_FLAGS_REQUIRED = 0x04;
|
|
|
|
|
|
|
|
|
|
const uint FILE_FLAGS_LEAVE_ALLOCATED = 0x01;
|
2018-01-28 20:29:46 +00:00
|
|
|
const uint FILE_FLAGS_HAS_PARENT = 0x02;
|
2016-08-29 03:38:18 +01:00
|
|
|
|
|
|
|
|
/// <summary>Block has never been stored on this image, check parent</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const ulong PAYLOAD_BLOCK_NOT_PRESENT = 0x00;
|
2016-08-29 03:38:18 +01:00
|
|
|
/// <summary>Block was stored on this image and is removed, return whatever data you wish</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const ulong PAYLOAD_BLOCK_UNDEFINED = 0x01;
|
2016-08-29 03:38:18 +01:00
|
|
|
/// <summary>Block is filled with zeroes</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const ulong PAYLOAD_BLOCK_ZERO = 0x02;
|
2016-08-29 03:38:18 +01:00
|
|
|
/// <summary>All sectors in this block were UNMAPed/TRIMed, return zeroes</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const ulong PAYLOAD_BLOCK_UNMAPPER = 0x03;
|
2016-08-29 03:38:18 +01:00
|
|
|
/// <summary>Block is present on this image</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const ulong PAYLOAD_BLOCK_FULLY_PRESENT = 0x06;
|
2016-08-29 03:38:18 +01:00
|
|
|
/// <summary>Block is present on image but there may be sectors present on parent image</summary>
|
2017-12-20 17:15:26 +00:00
|
|
|
const ulong PAYLOAD_BLOCK_PARTIALLY_PRESENT = 0x07;
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
const ulong SECTOR_BITMAP_NOT_PRESENT = 0x00;
|
2018-01-28 20:29:46 +00:00
|
|
|
const ulong SECTOR_BITMAP_PRESENT = 0x06;
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
const ulong BAT_FILE_OFFSET_MASK = 0xFFFFFFFFFFFC0000;
|
2018-01-28 20:29:46 +00:00
|
|
|
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");
|
2017-12-24 00:12:31 +00:00
|
|
|
readonly Guid physicalSectorSizeGuid = new Guid("CDA348C7-445D-4471-9CC9-E9885251C556");
|
2018-01-28 20:29:46 +00:00
|
|
|
readonly Guid virtualDiskSizeGuid = new Guid("2FA54224-CD1B-4876-B211-5DBED83BF4B8");
|
2016-08-29 03:38:18 +01:00
|
|
|
|
|
|
|
|
long batOffset;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
ulong[] blockAllocationTable;
|
2017-12-24 00:12:31 +00:00
|
|
|
Dictionary<ulong, byte[]> blockCache;
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
long chunkRatio;
|
|
|
|
|
ulong dataBlocks;
|
|
|
|
|
bool hasParent;
|
|
|
|
|
ImageInfo imageInfo;
|
|
|
|
|
Stream imageStream;
|
|
|
|
|
uint logicalSectorSize;
|
|
|
|
|
int maxBlockCache;
|
|
|
|
|
int maxSectorCache;
|
|
|
|
|
long metadataOffset;
|
|
|
|
|
Guid page83Data;
|
2017-12-26 06:05:12 +00:00
|
|
|
IMediaImage parentImage;
|
2018-01-28 20:29:46 +00:00
|
|
|
uint physicalSectorSize;
|
|
|
|
|
byte[] sectorBitmap;
|
|
|
|
|
ulong[] sectorBitmapPointers;
|
2016-08-29 03:38:18 +01:00
|
|
|
|
|
|
|
|
Dictionary<ulong, byte[]> sectorCache;
|
2018-01-28 20:29:46 +00:00
|
|
|
VhdxFileParameters vFileParms;
|
|
|
|
|
VhdxHeader vHdr;
|
2017-12-24 00:12:31 +00:00
|
|
|
|
|
|
|
|
VhdxIdentifier vhdxId;
|
|
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
ulong virtualDiskSize;
|
|
|
|
|
VhdxMetadataTableHeader vMetHdr;
|
2017-12-24 00:12:31 +00:00
|
|
|
VhdxMetadataTableEntry[] vMets;
|
2018-01-28 20:29:46 +00:00
|
|
|
VhdxParentLocatorHeader vParHdr;
|
2017-12-24 00:12:31 +00:00
|
|
|
VhdxParentLocatorEntry[] vPars;
|
2018-01-28 20:29:46 +00:00
|
|
|
VhdxRegionTableHeader vRegHdr;
|
|
|
|
|
VhdxRegionTableEntry[] vRegs;
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
public Vhdx()
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo = new ImageInfo
|
2017-12-22 06:55:04 +00:00
|
|
|
{
|
2018-01-28 20:29:46 +00:00
|
|
|
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,
|
2017-12-22 06:55:04 +00:00
|
|
|
DriveFirmwareRevision = null
|
|
|
|
|
};
|
2016-08-29 03:38:18 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public ImageInfo Info => imageInfo;
|
2017-12-26 02:51:10 +00:00
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public string Name => "Microsoft VHDX";
|
2018-01-28 20:29:46 +00:00
|
|
|
public Guid Id => new Guid("536B141B-D09C-4799-AB70-34631286EB9D");
|
2017-12-26 06:05:12 +00:00
|
|
|
|
2017-12-28 19:56:36 +00:00
|
|
|
public string Format => "VHDX";
|
2017-12-26 06:05:12 +00:00
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public List<Partition> Partitions =>
|
2017-12-26 02:51:10 +00:00
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public List<Track> Tracks =>
|
2017-12-26 02:51:10 +00:00
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public List<Session> Sessions =>
|
2017-12-26 02:51:10 +00:00
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
|
2017-12-28 19:56:36 +00:00
|
|
|
public bool Identify(IFilter imageFilter)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
2016-09-05 17:37:31 +01:00
|
|
|
Stream stream = imageFilter.GetDataForkStream();
|
2016-08-29 03:38:18 +01:00
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
if(stream.Length < 512) return false;
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] vhdxIdB = new byte[Marshal.SizeOf(vhdxId)];
|
|
|
|
|
stream.Read(vhdxIdB, 0, Marshal.SizeOf(vhdxId));
|
2018-06-22 08:08:38 +01:00
|
|
|
vhdxId = new VhdxIdentifier();
|
2016-08-29 03:38:18 +01:00
|
|
|
IntPtr idPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vhdxId));
|
2017-12-20 17:15:26 +00:00
|
|
|
Marshal.Copy(vhdxIdB, 0, idPtr, Marshal.SizeOf(vhdxId));
|
|
|
|
|
vhdxId = (VhdxIdentifier)Marshal.PtrToStructure(idPtr, typeof(VhdxIdentifier));
|
2016-08-29 03:38:18 +01:00
|
|
|
Marshal.FreeHGlobal(idPtr);
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
return vhdxId.signature == VHDX_SIGNATURE;
|
2016-08-29 03:38:18 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-28 19:56:36 +00:00
|
|
|
public bool Open(IFilter imageFilter)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
2016-09-05 17:37:31 +01:00
|
|
|
Stream stream = imageFilter.GetDataForkStream();
|
2016-08-29 03:38:18 +01:00
|
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
if(stream.Length < 512) return false;
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] vhdxIdB = new byte[Marshal.SizeOf(vhdxId)];
|
|
|
|
|
stream.Read(vhdxIdB, 0, Marshal.SizeOf(vhdxId));
|
2018-06-22 08:08:38 +01:00
|
|
|
vhdxId = new VhdxIdentifier();
|
2016-08-29 03:38:18 +01:00
|
|
|
IntPtr idPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vhdxId));
|
2017-12-20 17:15:26 +00:00
|
|
|
Marshal.Copy(vhdxIdB, 0, idPtr, Marshal.SizeOf(vhdxId));
|
|
|
|
|
vhdxId = (VhdxIdentifier)Marshal.PtrToStructure(idPtr, typeof(VhdxIdentifier));
|
2016-08-29 03:38:18 +01:00
|
|
|
Marshal.FreeHGlobal(idPtr);
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(vhdxId.signature != VHDX_SIGNATURE) return false;
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo.Application = Encoding.Unicode.GetString(vhdxId.creator);
|
2016-08-29 03:38:18 +01:00
|
|
|
|
|
|
|
|
stream.Seek(64 * 1024, SeekOrigin.Begin);
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] vHdrB = new byte[Marshal.SizeOf(vHdr)];
|
|
|
|
|
stream.Read(vHdrB, 0, Marshal.SizeOf(vHdr));
|
2018-06-22 08:08:38 +01:00
|
|
|
vHdr = new VhdxHeader();
|
2016-08-29 03:38:18 +01:00
|
|
|
IntPtr headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vHdr));
|
2017-12-20 17:15:26 +00:00
|
|
|
Marshal.Copy(vHdrB, 0, headerPtr, Marshal.SizeOf(vHdr));
|
|
|
|
|
vHdr = (VhdxHeader)Marshal.PtrToStructure(headerPtr, typeof(VhdxHeader));
|
2016-08-29 03:38:18 +01:00
|
|
|
Marshal.FreeHGlobal(headerPtr);
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(vHdr.Signature != VHDX_HEADER_SIG)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
stream.Seek(128 * 1024, SeekOrigin.Begin);
|
2017-12-20 17:15:26 +00:00
|
|
|
vHdrB = new byte[Marshal.SizeOf(vHdr)];
|
|
|
|
|
stream.Read(vHdrB, 0, Marshal.SizeOf(vHdr));
|
2018-01-28 20:29:46 +00:00
|
|
|
vHdr = new VhdxHeader();
|
2016-08-29 03:38:18 +01:00
|
|
|
headerPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vHdr));
|
2017-12-20 17:15:26 +00:00
|
|
|
Marshal.Copy(vHdrB, 0, headerPtr, Marshal.SizeOf(vHdr));
|
|
|
|
|
vHdr = (VhdxHeader)Marshal.PtrToStructure(headerPtr, typeof(VhdxHeader));
|
2016-08-29 03:38:18 +01:00
|
|
|
Marshal.FreeHGlobal(headerPtr);
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(vHdr.Signature != VHDX_HEADER_SIG) throw new ImageNotSupportedException("VHDX header not found");
|
2016-08-29 03:38:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stream.Seek(192 * 1024, SeekOrigin.Begin);
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] vRegTableB = new byte[Marshal.SizeOf(vRegHdr)];
|
|
|
|
|
stream.Read(vRegTableB, 0, Marshal.SizeOf(vRegHdr));
|
2018-06-22 08:08:38 +01:00
|
|
|
vRegHdr = new VhdxRegionTableHeader();
|
2016-08-29 03:38:18 +01:00
|
|
|
IntPtr vRegTabPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vRegHdr));
|
2017-12-20 17:15:26 +00:00
|
|
|
Marshal.Copy(vRegTableB, 0, vRegTabPtr, Marshal.SizeOf(vRegHdr));
|
|
|
|
|
vRegHdr = (VhdxRegionTableHeader)Marshal.PtrToStructure(vRegTabPtr, typeof(VhdxRegionTableHeader));
|
2016-08-29 03:38:18 +01:00
|
|
|
Marshal.FreeHGlobal(vRegTabPtr);
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(vRegHdr.signature != VHDX_REGION_SIG)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
stream.Seek(256 * 1024, SeekOrigin.Begin);
|
2017-12-20 17:15:26 +00:00
|
|
|
vRegTableB = new byte[Marshal.SizeOf(vRegHdr)];
|
|
|
|
|
stream.Read(vRegTableB, 0, Marshal.SizeOf(vRegHdr));
|
2018-01-28 20:29:46 +00:00
|
|
|
vRegHdr = new VhdxRegionTableHeader();
|
2016-08-29 03:38:18 +01:00
|
|
|
vRegTabPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vRegHdr));
|
2017-12-20 17:15:26 +00:00
|
|
|
Marshal.Copy(vRegTableB, 0, vRegTabPtr, Marshal.SizeOf(vRegHdr));
|
|
|
|
|
vRegHdr = (VhdxRegionTableHeader)Marshal.PtrToStructure(vRegTabPtr, typeof(VhdxRegionTableHeader));
|
2016-08-29 03:38:18 +01:00
|
|
|
Marshal.FreeHGlobal(vRegTabPtr);
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(vRegHdr.signature != VHDX_REGION_SIG)
|
2016-08-29 03:38:18 +01:00
|
|
|
throw new ImageNotSupportedException("VHDX region table not found");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
vRegs = new VhdxRegionTableEntry[vRegHdr.entries];
|
2016-08-29 03:38:18 +01:00
|
|
|
for(int i = 0; i < vRegs.Length; i++)
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] vRegB = new byte[Marshal.SizeOf(vRegs[i])];
|
|
|
|
|
stream.Read(vRegB, 0, Marshal.SizeOf(vRegs[i]));
|
2018-06-22 08:08:38 +01:00
|
|
|
vRegs[i] = new VhdxRegionTableEntry();
|
2016-08-29 03:38:18 +01:00
|
|
|
IntPtr vRegPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vRegs[i]));
|
2017-12-20 17:15:26 +00:00
|
|
|
Marshal.Copy(vRegB, 0, vRegPtr, Marshal.SizeOf(vRegs[i]));
|
|
|
|
|
vRegs[i] = (VhdxRegionTableEntry)Marshal.PtrToStructure(vRegPtr, typeof(VhdxRegionTableEntry));
|
2016-08-29 03:38:18 +01:00
|
|
|
Marshal.FreeHGlobal(vRegPtr);
|
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
if(vRegs[i].guid == batGuid)
|
|
|
|
|
batOffset = (long)vRegs[i].offset;
|
2018-01-28 20:29:46 +00:00
|
|
|
else if(vRegs[i].guid == metadataGuid)
|
|
|
|
|
metadataOffset = (long)vRegs[i].offset;
|
2017-12-20 17:15:26 +00:00
|
|
|
else if((vRegs[i].flags & REGION_FLAGS_REQUIRED) == REGION_FLAGS_REQUIRED)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new
|
2017-12-21 17:58:51 +00:00
|
|
|
ImageNotSupportedException($"Found unsupported and required region Guid {vRegs[i].guid}, not proceeding with image.");
|
2016-08-29 03:38:18 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
if(batOffset == 0) throw new Exception("BAT not found, cannot continue.");
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
if(metadataOffset == 0) throw new Exception("Metadata not found, cannot continue.");
|
2016-08-29 03:38:18 +01:00
|
|
|
|
|
|
|
|
uint fileParamsOff = 0, vdSizeOff = 0, p83Off = 0, logOff = 0, physOff = 0, parentOff = 0;
|
|
|
|
|
|
|
|
|
|
stream.Seek(metadataOffset, SeekOrigin.Begin);
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] metTableB = new byte[Marshal.SizeOf(vMetHdr)];
|
|
|
|
|
stream.Read(metTableB, 0, Marshal.SizeOf(vMetHdr));
|
2018-06-22 08:08:38 +01:00
|
|
|
vMetHdr = new VhdxMetadataTableHeader();
|
2016-08-29 03:38:18 +01:00
|
|
|
IntPtr metTablePtr = Marshal.AllocHGlobal(Marshal.SizeOf(vMetHdr));
|
2017-12-20 17:15:26 +00:00
|
|
|
Marshal.Copy(metTableB, 0, metTablePtr, Marshal.SizeOf(vMetHdr));
|
|
|
|
|
vMetHdr = (VhdxMetadataTableHeader)Marshal.PtrToStructure(metTablePtr, typeof(VhdxMetadataTableHeader));
|
2016-08-29 03:38:18 +01:00
|
|
|
Marshal.FreeHGlobal(metTablePtr);
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
vMets = new VhdxMetadataTableEntry[vMetHdr.entries];
|
2016-08-29 03:38:18 +01:00
|
|
|
for(int i = 0; i < vMets.Length; i++)
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] vMetB = new byte[Marshal.SizeOf(vMets[i])];
|
|
|
|
|
stream.Read(vMetB, 0, Marshal.SizeOf(vMets[i]));
|
2018-06-22 08:08:38 +01:00
|
|
|
vMets[i] = new VhdxMetadataTableEntry();
|
2016-08-29 03:38:18 +01:00
|
|
|
IntPtr vMetPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vMets[i]));
|
2017-12-20 17:15:26 +00:00
|
|
|
Marshal.Copy(vMetB, 0, vMetPtr, Marshal.SizeOf(vMets[i]));
|
|
|
|
|
vMets[i] = (VhdxMetadataTableEntry)Marshal.PtrToStructure(vMetPtr, typeof(VhdxMetadataTableEntry));
|
2016-08-29 03:38:18 +01:00
|
|
|
Marshal.FreeHGlobal(vMetPtr);
|
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
if(vMets[i].itemId == fileParametersGuid)
|
|
|
|
|
fileParamsOff = vMets[i].offset;
|
2018-01-28 20:29:46 +00:00
|
|
|
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;
|
2017-12-20 17:15:26 +00:00
|
|
|
else if((vMets[i].flags & METADATA_FLAGS_REQUIRED) == METADATA_FLAGS_REQUIRED)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new
|
2017-12-21 17:58:51 +00:00
|
|
|
ImageNotSupportedException($"Found unsupported and required metadata Guid {vMets[i].itemId}, not proceeding with image.");
|
2016-08-29 03:38:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
byte[] tmp;
|
|
|
|
|
|
|
|
|
|
if(fileParamsOff != 0)
|
|
|
|
|
{
|
|
|
|
|
stream.Seek(fileParamsOff + metadataOffset, SeekOrigin.Begin);
|
|
|
|
|
tmp = new byte[8];
|
|
|
|
|
stream.Read(tmp, 0, 8);
|
2017-12-22 06:55:04 +00:00
|
|
|
vFileParms = new VhdxFileParameters
|
|
|
|
|
{
|
|
|
|
|
blockSize = BitConverter.ToUInt32(tmp, 0),
|
2018-01-28 20:29:46 +00:00
|
|
|
flags = BitConverter.ToUInt32(tmp, 4)
|
2017-12-22 06:55:04 +00:00
|
|
|
};
|
2016-08-29 03:38:18 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
else throw new Exception("File parameters not found.");
|
2016-08-29 03:38:18 +01:00
|
|
|
|
|
|
|
|
if(vdSizeOff != 0)
|
|
|
|
|
{
|
|
|
|
|
stream.Seek(vdSizeOff + metadataOffset, SeekOrigin.Begin);
|
|
|
|
|
tmp = new byte[8];
|
|
|
|
|
stream.Read(tmp, 0, 8);
|
2017-12-20 17:15:26 +00:00
|
|
|
virtualDiskSize = BitConverter.ToUInt64(tmp, 0);
|
2016-08-29 03:38:18 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
else throw new Exception("Virtual disk size not found.");
|
2016-08-29 03:38:18 +01:00
|
|
|
|
|
|
|
|
if(p83Off != 0)
|
|
|
|
|
{
|
|
|
|
|
stream.Seek(p83Off + metadataOffset, SeekOrigin.Begin);
|
|
|
|
|
tmp = new byte[16];
|
|
|
|
|
stream.Read(tmp, 0, 16);
|
2017-12-20 17:15:26 +00:00
|
|
|
page83Data = new Guid(tmp);
|
2016-08-29 03:38:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(logOff != 0)
|
|
|
|
|
{
|
|
|
|
|
stream.Seek(logOff + metadataOffset, SeekOrigin.Begin);
|
|
|
|
|
tmp = new byte[4];
|
|
|
|
|
stream.Read(tmp, 0, 4);
|
2017-12-20 17:15:26 +00:00
|
|
|
logicalSectorSize = BitConverter.ToUInt32(tmp, 0);
|
2016-08-29 03:38:18 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
else throw new Exception("Logical sector size not found.");
|
|
|
|
|
|
2016-08-29 03:38:18 +01:00
|
|
|
if(physOff != 0)
|
|
|
|
|
{
|
|
|
|
|
stream.Seek(physOff + metadataOffset, SeekOrigin.Begin);
|
|
|
|
|
tmp = new byte[4];
|
|
|
|
|
stream.Read(tmp, 0, 4);
|
2017-12-20 17:15:26 +00:00
|
|
|
physicalSectorSize = BitConverter.ToUInt32(tmp, 0);
|
2016-08-29 03:38:18 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
else throw new Exception("Physical sector size not found.");
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(parentOff != 0 && (vFileParms.flags & FILE_FLAGS_HAS_PARENT) == FILE_FLAGS_HAS_PARENT)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
stream.Seek(parentOff + metadataOffset, SeekOrigin.Begin);
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] vParHdrB = new byte[Marshal.SizeOf(vMetHdr)];
|
|
|
|
|
stream.Read(vParHdrB, 0, Marshal.SizeOf(vMetHdr));
|
2018-06-22 08:08:38 +01:00
|
|
|
vParHdr = new VhdxParentLocatorHeader();
|
2016-08-29 03:38:18 +01:00
|
|
|
IntPtr vParHdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vMetHdr));
|
2017-12-20 17:15:26 +00:00
|
|
|
Marshal.Copy(vParHdrB, 0, vParHdrPtr, Marshal.SizeOf(vMetHdr));
|
|
|
|
|
vParHdr = (VhdxParentLocatorHeader)Marshal.PtrToStructure(vParHdrPtr, typeof(VhdxParentLocatorHeader));
|
2016-08-29 03:38:18 +01:00
|
|
|
Marshal.FreeHGlobal(vParHdrPtr);
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if(vParHdr.locatorType != parentTypeVhdxGuid)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new
|
2017-12-21 17:58:51 +00:00
|
|
|
ImageNotSupportedException($"Found unsupported and required parent locator type {vParHdr.locatorType}, not proceeding with image.");
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
vPars = new VhdxParentLocatorEntry[vParHdr.keyValueCount];
|
2016-08-29 03:38:18 +01:00
|
|
|
for(int i = 0; i < vPars.Length; i++)
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
byte[] vParB = new byte[Marshal.SizeOf(vPars[i])];
|
|
|
|
|
stream.Read(vParB, 0, Marshal.SizeOf(vPars[i]));
|
2018-06-22 08:08:38 +01:00
|
|
|
vPars[i] = new VhdxParentLocatorEntry();
|
2016-08-29 03:38:18 +01:00
|
|
|
IntPtr vParPtr = Marshal.AllocHGlobal(Marshal.SizeOf(vPars[i]));
|
2017-12-20 17:15:26 +00:00
|
|
|
Marshal.Copy(vParB, 0, vParPtr, Marshal.SizeOf(vPars[i]));
|
|
|
|
|
vPars[i] = (VhdxParentLocatorEntry)Marshal.PtrToStructure(vParPtr, typeof(VhdxParentLocatorEntry));
|
2016-08-29 03:38:18 +01:00
|
|
|
Marshal.FreeHGlobal(vParPtr);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-12-20 17:15:26 +00:00
|
|
|
else if((vFileParms.flags & FILE_FLAGS_HAS_PARENT) == FILE_FLAGS_HAS_PARENT)
|
2016-08-29 03:38:18 +01:00
|
|
|
throw new Exception("Parent locator not found.");
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if((vFileParms.flags & FILE_FLAGS_HAS_PARENT) == FILE_FLAGS_HAS_PARENT &&
|
2018-01-28 20:29:46 +00:00
|
|
|
vParHdr.locatorType == parentTypeVhdxGuid)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
2018-06-22 08:08:38 +01:00
|
|
|
parentImage = new Vhdx();
|
2016-08-29 03:38:18 +01:00
|
|
|
bool parentWorks = false;
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
foreach(VhdxParentLocatorEntry parentEntry in vPars)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
stream.Seek(parentEntry.keyOffset + metadataOffset, SeekOrigin.Begin);
|
|
|
|
|
byte[] tmpKey = new byte[parentEntry.keyLength];
|
|
|
|
|
stream.Read(tmpKey, 0, tmpKey.Length);
|
|
|
|
|
string entryType = Encoding.Unicode.GetString(tmpKey);
|
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
IFilter parentFilter;
|
2017-12-20 17:15:26 +00:00
|
|
|
if(string.Compare(entryType, RELATIVE_PATH_KEY, StringComparison.OrdinalIgnoreCase) == 0)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
stream.Seek(parentEntry.valueOffset + metadataOffset, SeekOrigin.Begin);
|
|
|
|
|
byte[] tmpVal = new byte[parentEntry.valueLength];
|
|
|
|
|
stream.Read(tmpVal, 0, tmpVal.Length);
|
|
|
|
|
string entryValue = Encoding.Unicode.GetString(tmpVal);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
parentFilter =
|
|
|
|
|
new FiltersList().GetFilter(Path.Combine(imageFilter.GetParentFolder(), entryValue));
|
2017-12-28 19:56:36 +00:00
|
|
|
if(parentFilter != null && parentImage.Open(parentFilter))
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
parentWorks = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch { parentWorks = false; }
|
|
|
|
|
|
2016-09-05 17:37:31 +01:00
|
|
|
string relEntry = Path.Combine(Path.GetDirectoryName(imageFilter.GetPath()), entryValue);
|
2016-08-29 03:38:18 +01:00
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
parentFilter =
|
|
|
|
|
new FiltersList().GetFilter(Path.Combine(imageFilter.GetParentFolder(), relEntry));
|
2017-12-28 19:56:36 +00:00
|
|
|
if(parentFilter == null || !parentImage.Open(parentFilter)) continue;
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
|
|
|
parentWorks = true;
|
|
|
|
|
break;
|
2016-08-29 03:38:18 +01:00
|
|
|
}
|
2017-12-24 00:12:31 +00:00
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
// ignored
|
|
|
|
|
}
|
2016-08-29 03:38:18 +01:00
|
|
|
}
|
2018-01-28 20:29:46 +00:00
|
|
|
else if(string.Compare(entryType, VOLUME_PATH_KEY, StringComparison.OrdinalIgnoreCase) ==
|
|
|
|
|
0 ||
|
2017-12-20 17:15:26 +00:00
|
|
|
string.Compare(entryType, ABSOLUTE_WIN32_PATH_KEY, StringComparison.OrdinalIgnoreCase) == 0)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
stream.Seek(parentEntry.valueOffset + metadataOffset, SeekOrigin.Begin);
|
|
|
|
|
byte[] tmpVal = new byte[parentEntry.valueLength];
|
|
|
|
|
stream.Read(tmpVal, 0, tmpVal.Length);
|
|
|
|
|
string entryValue = Encoding.Unicode.GetString(tmpVal);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
parentFilter =
|
|
|
|
|
new FiltersList().GetFilter(Path.Combine(imageFilter.GetParentFolder(), entryValue));
|
2017-12-28 19:56:36 +00:00
|
|
|
if(parentFilter == null || !parentImage.Open(parentFilter)) continue;
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
|
|
|
parentWorks = true;
|
|
|
|
|
break;
|
2016-08-29 03:38:18 +01:00
|
|
|
}
|
2017-12-24 00:12:31 +00:00
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
// ignored
|
|
|
|
|
}
|
2016-08-29 03:38:18 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
if(!parentWorks) throw new Exception("Image is differential but parent cannot be opened.");
|
2016-08-29 03:38:18 +01:00
|
|
|
|
|
|
|
|
hasParent = true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:26:28 +00:00
|
|
|
chunkRatio = (long)(Math.Pow(2, 23) * logicalSectorSize / vFileParms.blockSize);
|
2018-06-22 08:08:38 +01:00
|
|
|
dataBlocks = virtualDiskSize / vFileParms.blockSize;
|
|
|
|
|
if(virtualDiskSize % vFileParms.blockSize > 0) dataBlocks++;
|
2016-08-29 03:38:18 +01:00
|
|
|
|
|
|
|
|
long batEntries;
|
|
|
|
|
if(hasParent)
|
|
|
|
|
{
|
|
|
|
|
long sectorBitmapBlocks = (long)dataBlocks / chunkRatio;
|
2018-06-22 08:08:38 +01:00
|
|
|
if(dataBlocks % (ulong)chunkRatio > 0) sectorBitmapBlocks++;
|
2016-08-29 03:38:18 +01:00
|
|
|
sectorBitmapPointers = new ulong[sectorBitmapBlocks];
|
|
|
|
|
|
|
|
|
|
batEntries = sectorBitmapBlocks * (chunkRatio - 1);
|
|
|
|
|
}
|
2017-12-20 17:26:28 +00:00
|
|
|
else batEntries = (long)(dataBlocks + (dataBlocks - 1) / (ulong)chunkRatio);
|
2016-08-29 03:38:18 +01:00
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("VHDX plugin", "Reading BAT");
|
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
long readChunks = 0;
|
2016-08-29 03:38:18 +01:00
|
|
|
blockAllocationTable = new ulong[dataBlocks];
|
2018-06-22 08:08:38 +01:00
|
|
|
byte[] batB = new byte[batEntries * 8];
|
2016-08-29 03:38:18 +01:00
|
|
|
stream.Seek(batOffset, SeekOrigin.Begin);
|
2017-12-20 17:15:26 +00:00
|
|
|
stream.Read(batB, 0, batB.Length);
|
2016-08-29 03:38:18 +01:00
|
|
|
|
|
|
|
|
ulong skipSize = 0;
|
|
|
|
|
for(ulong i = 0; i < dataBlocks; i++)
|
2018-06-22 08:08:38 +01:00
|
|
|
if(readChunks == chunkRatio)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
if(hasParent)
|
2017-12-20 17:15:26 +00:00
|
|
|
sectorBitmapPointers[skipSize / 8] = BitConverter.ToUInt64(batB, (int)(i * 8 + skipSize));
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
readChunks = 0;
|
|
|
|
|
skipSize += 8;
|
2016-08-29 03:38:18 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
blockAllocationTable[i] = BitConverter.ToUInt64(batB, (int)(i * 8 + skipSize));
|
2016-08-29 03:38:18 +01:00
|
|
|
readChunks++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(hasParent)
|
|
|
|
|
{
|
|
|
|
|
DicConsole.DebugWriteLine("VHDX plugin", "Reading Sector Bitmap");
|
|
|
|
|
|
|
|
|
|
MemoryStream sectorBmpMs = new MemoryStream();
|
|
|
|
|
foreach(ulong pt in sectorBitmapPointers)
|
2017-12-24 00:12:31 +00:00
|
|
|
switch(pt & BAT_FLAGS_MASK)
|
|
|
|
|
{
|
|
|
|
|
case SECTOR_BITMAP_NOT_PRESENT:
|
|
|
|
|
sectorBmpMs.Write(new byte[1048576], 0, 1048576);
|
2017-12-21 04:43:29 +00:00
|
|
|
break;
|
|
|
|
|
case SECTOR_BITMAP_PRESENT:
|
|
|
|
|
stream.Seek((long)((pt & BAT_FILE_OFFSET_MASK) * 1048576), SeekOrigin.Begin);
|
|
|
|
|
byte[] bmp = new byte[1048576];
|
|
|
|
|
stream.Read(bmp, 0, bmp.Length);
|
|
|
|
|
sectorBmpMs.Write(bmp, 0, bmp.Length);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if((pt & BAT_FLAGS_MASK) != 0)
|
|
|
|
|
throw new
|
2017-12-21 17:58:51 +00:00
|
|
|
ImageNotSupportedException($"Unsupported sector bitmap block flags (0x{pt & BAT_FLAGS_MASK:X16}) found, not proceeding.");
|
2017-12-21 04:43:29 +00:00
|
|
|
|
|
|
|
|
break;
|
2016-08-29 03:38:18 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2016-08-29 03:38:18 +01:00
|
|
|
sectorBitmap = sectorBmpMs.ToArray();
|
|
|
|
|
sectorBmpMs.Close();
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
maxBlockCache = (int)(MAX_CACHE_SIZE / vFileParms.blockSize);
|
2017-12-20 17:15:26 +00:00
|
|
|
maxSectorCache = (int)(MAX_CACHE_SIZE / logicalSectorSize);
|
2016-08-29 03:38:18 +01:00
|
|
|
|
|
|
|
|
imageStream = stream;
|
|
|
|
|
|
|
|
|
|
sectorCache = new Dictionary<ulong, byte[]>();
|
2018-01-28 20:29:46 +00:00
|
|
|
blockCache = new Dictionary<ulong, byte[]>();
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
imageInfo.CreationTime = imageFilter.GetCreationTime();
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo.LastModificationTime = imageFilter.GetLastWriteTime();
|
2018-01-28 20:29:46 +00:00
|
|
|
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();
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
// TODO: Separate image application from version, need several samples.
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
imageInfo.Cylinders = (uint)(imageInfo.Sectors / 16 / 63);
|
|
|
|
|
imageInfo.Heads = 16;
|
2017-12-26 06:05:12 +00:00
|
|
|
imageInfo.SectorsPerTrack = 63;
|
2017-08-02 23:01:11 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
return true;
|
2016-08-29 03:38:18 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSector(ulong sectorAddress)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
if(sectorAddress > imageInfo.Sectors - 1)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress),
|
2017-12-21 17:58:51 +00:00
|
|
|
$"Sector address {sectorAddress} not found");
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(sectorCache.TryGetValue(sectorAddress, out byte[] sector)) return sector;
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
ulong index = sectorAddress * logicalSectorSize / vFileParms.blockSize;
|
2017-12-20 17:26:28 +00:00
|
|
|
ulong secOff = sectorAddress * logicalSectorSize % vFileParms.blockSize;
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
ulong blkPtr = blockAllocationTable[index];
|
2017-12-20 17:15:26 +00:00
|
|
|
ulong blkFlags = blkPtr & BAT_FLAGS_MASK;
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
if((blkPtr & BAT_RESERVED_MASK) != 0)
|
2017-12-24 00:12:31 +00:00
|
|
|
throw new
|
|
|
|
|
ImageNotSupportedException($"Unknown flags (0x{blkPtr & BAT_RESERVED_MASK:X16}) set in block pointer");
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
switch(blkFlags & BAT_FLAGS_MASK)
|
|
|
|
|
{
|
|
|
|
|
case PAYLOAD_BLOCK_NOT_PRESENT:
|
|
|
|
|
return hasParent ? parentImage.ReadSector(sectorAddress) : new byte[logicalSectorSize];
|
2017-12-21 04:43:29 +00:00
|
|
|
case PAYLOAD_BLOCK_UNDEFINED:
|
|
|
|
|
case PAYLOAD_BLOCK_ZERO:
|
|
|
|
|
case PAYLOAD_BLOCK_UNMAPPER: return new byte[logicalSectorSize];
|
|
|
|
|
}
|
2016-08-29 03:38:18 +01:00
|
|
|
|
|
|
|
|
bool partialBlock;
|
2017-12-20 17:15:26 +00:00
|
|
|
partialBlock = (blkFlags & BAT_FLAGS_MASK) == PAYLOAD_BLOCK_PARTIALLY_PRESENT;
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
if(partialBlock && hasParent && !CheckBitmap(sectorAddress)) return parentImage.ReadSector(sectorAddress);
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2017-12-22 06:55:04 +00:00
|
|
|
if(!blockCache.TryGetValue(blkPtr & BAT_FILE_OFFSET_MASK, out byte[] block))
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
block = new byte[vFileParms.blockSize];
|
2017-12-20 17:26:28 +00:00
|
|
|
imageStream.Seek((long)(blkPtr & BAT_FILE_OFFSET_MASK), SeekOrigin.Begin);
|
2016-08-29 03:38:18 +01:00
|
|
|
imageStream.Read(block, 0, block.Length);
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
if(blockCache.Count >= maxBlockCache) blockCache.Clear();
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
blockCache.Add(blkPtr & BAT_FILE_OFFSET_MASK, block);
|
2016-08-29 03:38:18 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 17:15:26 +00:00
|
|
|
sector = new byte[logicalSectorSize];
|
2016-08-29 03:38:18 +01:00
|
|
|
Array.Copy(block, (int)secOff, sector, 0, sector.Length);
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
if(sectorCache.Count >= maxSectorCache) sectorCache.Clear();
|
2016-08-29 03:38:18 +01:00
|
|
|
|
|
|
|
|
sectorCache.Add(sectorAddress, sector);
|
|
|
|
|
|
|
|
|
|
return sector;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectors(ulong sectorAddress, uint length)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
if(sectorAddress > imageInfo.Sectors - 1)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(sectorAddress),
|
2017-12-21 17:58:51 +00:00
|
|
|
$"Sector address {sectorAddress} not found");
|
2016-08-29 03:38:18 +01:00
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
if(sectorAddress + length > imageInfo.Sectors)
|
2017-12-19 20:33:03 +00:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(length),
|
2017-12-26 06:05:12 +00:00
|
|
|
$"Requested more sectors ({sectorAddress + length}) than available ({imageInfo.Sectors})");
|
2016-08-29 03:38:18 +01:00
|
|
|
|
|
|
|
|
MemoryStream ms = new MemoryStream();
|
|
|
|
|
|
|
|
|
|
for(uint i = 0; i < length; i++)
|
|
|
|
|
{
|
|
|
|
|
byte[] sector = ReadSector(sectorAddress + i);
|
|
|
|
|
ms.Write(sector, 0, sector.Length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ms.ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadDiskTag(MediaTagType tag)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectorTag(ulong sectorAddress, SectorTagType tag)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSector(ulong sectorAddress, uint track)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectorTag(ulong sectorAddress, uint track, SectorTagType tag)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, SectorTagType tag)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectors(ulong sectorAddress, uint length, uint track)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectorsTag(ulong sectorAddress, uint length, uint track, SectorTagType tag)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectorLong(ulong sectorAddress)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectorLong(ulong sectorAddress, uint track)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectorsLong(ulong sectorAddress, uint length)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public byte[] ReadSectorsLong(ulong sectorAddress, uint length, uint track)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public List<Track> GetSessionTracks(Session session)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public List<Track> GetSessionTracks(ushort session)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public bool? VerifySector(ulong sectorAddress)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public bool? VerifySector(ulong sectorAddress, uint track)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> failingLbas,
|
|
|
|
|
out List<ulong> unknownLbas)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
2017-12-20 17:15:26 +00:00
|
|
|
failingLbas = new List<ulong>();
|
|
|
|
|
unknownLbas = new List<ulong>();
|
2017-12-26 06:05:12 +00:00
|
|
|
for(ulong i = 0; i < imageInfo.Sectors; i++) unknownLbas.Add(i);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2016-08-29 03:38:18 +01:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
public bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> failingLbas,
|
|
|
|
|
out List<ulong> unknownLbas)
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
public bool? VerifyMediaImage()
|
2016-08-29 03:38:18 +01:00
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2017-12-24 00:12:31 +00:00
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-24 00:12:31 +00:00
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
struct VhdxIdentifier
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Signature, <see cref="Vhdx.VHDX_SIGNATURE" />
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ulong signature;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// UTF-16 string containing creator
|
|
|
|
|
/// </summary>
|
2018-01-28 20:29:46 +00:00
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)]
|
|
|
|
|
public byte[] creator;
|
2017-12-24 00:12:31 +00:00
|
|
|
}
|
|
|
|
|
|
2018-01-28 20:29:46 +00:00
|
|
|
#pragma warning disable 649
|
|
|
|
|
#pragma warning disable 169
|
2017-12-24 00:12:31 +00:00
|
|
|
struct VhdxHeader
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Signature, <see cref="Vhdx.VHDX_HEADER_SIG" />
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint Signature;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CRC-32C of whole 4096 bytes header with this field set to 0
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint Checksum;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sequence number
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ulong Sequence;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Unique identifier for file contents, must be changed on first write to metadata
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Guid FileWriteGuid;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Unique identifier for disk contents, must be changed on first write to metadata or data
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Guid DataWriteGuid;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Unique identifier for log entries
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Guid LogGuid;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Version of log format
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ushort LogVersion;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Version of VHDX format
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ushort Version;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Length in bytes of the log
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint LogLength;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Offset from image start to the log
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ulong LogOffset;
|
2018-01-28 20:29:46 +00:00
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4016)]
|
|
|
|
|
public byte[] Reserved;
|
2017-12-24 00:12:31 +00:00
|
|
|
}
|
2018-01-28 20:29:46 +00:00
|
|
|
#pragma warning restore 649
|
|
|
|
|
#pragma warning restore 169
|
2017-12-24 00:12:31 +00:00
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
struct VhdxRegionTableHeader
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Signature, <see cref="Vhdx.VHDX_REGION_SIG" />
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint signature;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CRC-32C of whole 64Kb table with this field set to 0
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint checksum;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// How many entries follow this table
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint entries;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reserved
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint reserved;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
struct VhdxRegionTableEntry
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Object identifier
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Guid guid;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Offset in image of the object
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ulong offset;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Length in bytes of the object
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint length;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Flags
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint flags;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
struct VhdxMetadataTableHeader
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Signature
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ulong signature;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reserved
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ushort reserved;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// How many entries are in the table
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ushort entries;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reserved
|
|
|
|
|
/// </summary>
|
2018-01-28 20:29:46 +00:00
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
|
|
|
|
|
public uint[] reserved2;
|
2017-12-24 00:12:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
struct VhdxMetadataTableEntry
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Metadata ID
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Guid itemId;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Offset relative to start of metadata region
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint offset;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Length in bytes
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint length;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Flags
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint flags;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reserved
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint reserved;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
struct VhdxFileParameters
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Block size in bytes
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint blockSize;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Flags
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint flags;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
struct VhdxParentLocatorHeader
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Type of parent virtual disk
|
|
|
|
|
/// </summary>
|
2018-06-22 08:08:38 +01:00
|
|
|
public Guid locatorType;
|
2017-12-24 00:12:31 +00:00
|
|
|
public ushort reserved;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// How many KVPs are in this parent locator
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ushort keyValueCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
struct VhdxParentLocatorEntry
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Offset from metadata to key
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint keyOffset;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Offset from metadata to value
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint valueOffset;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Size of key
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ushort keyLength;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Size of value
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ushort valueLength;
|
|
|
|
|
}
|
2016-08-29 03:38:18 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|