// /*************************************************************************** // The Disc Image Chef // ---------------------------------------------------------------------------- // // Filename : Structs.cs // Author(s) : Natalia Portillo // // Component : Disk image plugins. // // --[ Description ] ---------------------------------------------------------- // // Contains structures for Microsoft Hyper-V disk images. // // --[ 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 . // // ---------------------------------------------------------------------------- // Copyright © 2011-2019 Natalia Portillo // ****************************************************************************/ using System; using System.Runtime.InteropServices; namespace DiscImageChef.DiscImages { public partial class Vhdx { [StructLayout(LayoutKind.Sequential, Pack = 1)] struct VhdxIdentifier { /// /// Signature, /// public ulong signature; /// /// UTF-16 string containing creator /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)] public byte[] creator; } #pragma warning disable 649 #pragma warning disable 169 struct VhdxHeader { /// /// Signature, /// public uint Signature; /// /// CRC-32C of whole 4096 bytes header with this field set to 0 /// public uint Checksum; /// /// Sequence number /// public ulong Sequence; /// /// Unique identifier for file contents, must be changed on first write to metadata /// public Guid FileWriteGuid; /// /// Unique identifier for disk contents, must be changed on first write to metadata or data /// public Guid DataWriteGuid; /// /// Unique identifier for log entries /// public Guid LogGuid; /// /// Version of log format /// public ushort LogVersion; /// /// Version of VHDX format /// public ushort Version; /// /// Length in bytes of the log /// public uint LogLength; /// /// Offset from image start to the log /// public ulong LogOffset; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4016)] public byte[] Reserved; } #pragma warning restore 649 #pragma warning restore 169 [StructLayout(LayoutKind.Sequential, Pack = 1)] struct VhdxRegionTableHeader { /// /// Signature, /// public uint signature; /// /// CRC-32C of whole 64Kb table with this field set to 0 /// public uint checksum; /// /// How many entries follow this table /// public uint entries; /// /// Reserved /// public uint reserved; } [StructLayout(LayoutKind.Sequential, Pack = 1)] struct VhdxRegionTableEntry { /// /// Object identifier /// public Guid guid; /// /// Offset in image of the object /// public ulong offset; /// /// Length in bytes of the object /// public uint length; /// /// Flags /// public uint flags; } [StructLayout(LayoutKind.Sequential, Pack = 1)] struct VhdxMetadataTableHeader { /// /// Signature /// public ulong signature; /// /// Reserved /// public ushort reserved; /// /// How many entries are in the table /// public ushort entries; /// /// Reserved /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] public uint[] reserved2; } [StructLayout(LayoutKind.Sequential, Pack = 1)] struct VhdxMetadataTableEntry { /// /// Metadata ID /// public Guid itemId; /// /// Offset relative to start of metadata region /// public uint offset; /// /// Length in bytes /// public uint length; /// /// Flags /// public uint flags; /// /// Reserved /// public uint reserved; } [StructLayout(LayoutKind.Sequential, Pack = 1)] struct VhdxFileParameters { /// /// Block size in bytes /// public uint blockSize; /// /// Flags /// public uint flags; } [StructLayout(LayoutKind.Sequential, Pack = 1)] struct VhdxParentLocatorHeader { /// /// Type of parent virtual disk /// public Guid locatorType; public ushort reserved; /// /// How many KVPs are in this parent locator /// public ushort keyValueCount; } [StructLayout(LayoutKind.Sequential, Pack = 1)] struct VhdxParentLocatorEntry { /// /// Offset from metadata to key /// public uint keyOffset; /// /// Offset from metadata to value /// public uint valueOffset; /// /// Size of key /// public ushort keyLength; /// /// Size of value /// public ushort valueLength; } } }