// /*************************************************************************** // The Disc Image Chef // ---------------------------------------------------------------------------- // // Filename : Structs.cs // Author(s) : Natalia Portillo // // Component : Disk image plugins. // // --[ Description ] ---------------------------------------------------------- // // Contains structures for Connectix and Microsoft Virtual PC 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-2018 Natalia Portillo // ****************************************************************************/ using System; using System.Runtime.InteropServices; namespace DiscImageChef.DiscImages { public partial class Vhd { struct HardDiskFooter { /// /// Offset 0x00, File magic number, /// public ulong Cookie; /// /// Offset 0x08, Specific feature support /// public uint Features; /// /// Offset 0x0C, File format version /// public uint Version; /// /// Offset 0x10, Offset from beginning of file to next structure /// public ulong Offset; /// /// Offset 0x18, Creation date seconds since 2000/01/01 00:00:00 UTC /// public uint Timestamp; /// /// Offset 0x1C, Application that created this disk image /// public uint CreatorApplication; /// /// Offset 0x20, Version of the application that created this disk image /// public uint CreatorVersion; /// /// Offset 0x24, Host operating system of the application that created this disk image /// public uint CreatorHostOs; /// /// Offset 0x28, Original hard disk size, in bytes /// public ulong OriginalSize; /// /// Offset 0x30, Current hard disk size, in bytes /// public ulong CurrentSize; /// /// Offset 0x38, CHS geometry /// Cylinder mask = 0xFFFF0000 /// Heads mask = 0x0000FF00 /// Sectors mask = 0x000000FF /// public uint DiskGeometry; /// /// Offset 0x3C, Disk image type /// public uint DiskType; /// /// Offset 0x40, Checksum for this structure /// public uint Checksum; /// /// Offset 0x44, UUID, used to associate parent with differencing disk images /// public Guid UniqueId; /// /// Offset 0x54, If set, system is saved, so compaction and expansion cannot be performed /// public byte SavedState; /// /// Offset 0x55, 427 bytes reserved, should contain zeros. /// public byte[] Reserved; } struct ParentLocatorEntry { /// /// Offset 0x00, Describes the platform specific type this entry belongs to /// public uint PlatformCode; /// /// Offset 0x04, Describes the number of 512 bytes sectors used by this entry /// public uint PlatformDataSpace; /// /// Offset 0x08, Describes this entry's size in bytes /// public uint PlatformDataLength; /// /// Offset 0x0c, Reserved /// public uint Reserved; /// /// Offset 0x10, Offset on disk image this entry resides on /// public ulong PlatformDataOffset; } struct DynamicDiskHeader { /// /// Offset 0x00, Header magic, /// public ulong Cookie; /// /// Offset 0x08, Offset to next structure on disk image. /// Currently unused, 0xFFFFFFFF /// public ulong DataOffset; /// /// Offset 0x10, Offset of the Block Allocation Table (BAT) /// public ulong TableOffset; /// /// Offset 0x18, Version of this header /// public uint HeaderVersion; /// /// Offset 0x1C, Maximum entries present in the BAT /// public uint MaxTableEntries; /// /// Offset 0x20, Size of a block in bytes /// Should always be a power of two of 512 /// public uint BlockSize; /// /// Offset 0x24, Checksum of this header /// public uint Checksum; /// /// Offset 0x28, UUID of parent disk image for differencing type /// public Guid ParentId; /// /// Offset 0x38, Timestamp of parent disk image /// public uint ParentTimestamp; /// /// Offset 0x3C, Reserved /// public uint Reserved; /// /// Offset 0x40, 512 bytes UTF-16 of parent disk image filename /// public string ParentName; /// /// Offset 0x240, Parent disk image locator entry, /// public ParentLocatorEntry[] LocatorEntries; /// /// Offset 0x300, 256 reserved bytes /// public byte[] Reserved2; } [StructLayout(LayoutKind.Sequential, Pack = 1)] struct BatSector { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)] public uint[] blockPointer; } } }