// /*************************************************************************** // The Disc Image Chef // ---------------------------------------------------------------------------- // // Filename : Structs.cs // Author(s) : Natalia Portillo // // Component : Disk image plugins. // // --[ Description ] ---------------------------------------------------------- // // Contains structures for DiscImageChef format 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.Runtime.InteropServices; using DiscImageChef.CommonTypes; using DiscImageChef.CommonTypes.Enums; namespace DiscImageChef.DiscImages { public partial class DiscImageChef { /// Header, at start of file [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)] struct DicHeader { /// Header identifier, public ulong identifier; /// UTF-16LE name of the application that created the image [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string application; /// Image format major version. A new major version means a possibly incompatible change of format public byte imageMajorVersion; /// Image format minor version. A new minor version indicates a compatible change of format public byte imageMinorVersion; /// Major version of the application that created the image public byte applicationMajorVersion; /// Minor version of the application that created the image public byte applicationMinorVersion; /// Type of media contained on image public MediaType mediaType; /// Offset to index public ulong indexOffset; /// Windows filetime (100 nanoseconds since 1601/01/01 00:00:00 UTC) of image creation time public long creationTime; /// Windows filetime (100 nanoseconds since 1601/01/01 00:00:00 UTC) of image last written time public long lastWrittenTime; } /// Header for a deduplication table. Table follows it [StructLayout(LayoutKind.Sequential, Pack = 1)] struct DdtHeader { /// Identifier, public BlockType identifier; /// Type of data pointed by this DDT public DataType type; /// Compression algorithm used to compress the DDT public CompressionType compression; /// Each entry is ((byte offset in file) << shift) + (sector offset in block) public byte shift; /// How many entries are in the table public ulong entries; /// Compressed length for the DDT public ulong cmpLength; /// Uncompressed length for the DDT public ulong length; /// CRC64-ECMA of the compressed DDT public ulong cmpCrc64; /// CRC64-ECMA of the uncompressed DDT public ulong crc64; } /// Header for the index, followed by entries [StructLayout(LayoutKind.Sequential, Pack = 1)] struct IndexHeader { /// Identifier, public BlockType identifier; /// How many entries follow this header public ushort entries; /// CRC64-ECMA of the index public ulong crc64; } /// Index entry [StructLayout(LayoutKind.Sequential, Pack = 1)] struct IndexEntry { /// Type of item pointed by this entry public BlockType blockType; /// Type of data contained by the block pointed by this entry public DataType dataType; /// Offset in file where item is stored public ulong offset; } /// Block header, precedes block data [StructLayout(LayoutKind.Sequential, Pack = 1)] struct BlockHeader { /// Identifier, public BlockType identifier; /// Type of data contained by this block public DataType type; /// Compression algorithm used to compress the block public CompressionType compression; /// Size in bytes of each sector contained in this block public uint sectorSize; /// Compressed length for the block public uint cmpLength; /// Uncompressed length for the block public uint length; /// CRC64-ECMA of the compressed block public ulong cmpCrc64; /// CRC64-ECMA of the uncompressed block public ulong crc64; } /// Geometry block, contains physical geometry information [StructLayout(LayoutKind.Sequential, Pack = 1)] struct GeometryBlock { /// Identifier, public BlockType identifier; public uint cylinders; public uint heads; public uint sectorsPerTrack; } /// Metadata block, contains metadata [StructLayout(LayoutKind.Sequential, Pack = 1)] struct MetadataBlock { /// Identifier, public BlockType identifier; /// Size in bytes of this whole metadata block public uint blockSize; /// Sequence of media set this media belongs to public int mediaSequence; /// Total number of media on the media set this media belongs to public int lastMediaSequence; /// Offset to start of creator string from start of this block public uint creatorOffset; /// Length in bytes of the null-terminated UTF-16LE creator string public uint creatorLength; /// Offset to start of creator string from start of this block public uint commentsOffset; /// Length in bytes of the null-terminated UTF-16LE creator string public uint commentsLength; /// Offset to start of creator string from start of this block public uint mediaTitleOffset; /// Length in bytes of the null-terminated UTF-16LE creator string public uint mediaTitleLength; /// Offset to start of creator string from start of this block public uint mediaManufacturerOffset; /// Length in bytes of the null-terminated UTF-16LE creator string public uint mediaManufacturerLength; /// Offset to start of creator string from start of this block public uint mediaModelOffset; /// Length in bytes of the null-terminated UTF-16LE creator string public uint mediaModelLength; /// Offset to start of creator string from start of this block public uint mediaSerialNumberOffset; /// Length in bytes of the null-terminated UTF-16LE creator string public uint mediaSerialNumberLength; /// Offset to start of creator string from start of this block public uint mediaBarcodeOffset; /// Length in bytes of the null-terminated UTF-16LE creator string public uint mediaBarcodeLength; /// Offset to start of creator string from start of this block public uint mediaPartNumberOffset; /// Length in bytes of the null-terminated UTF-16LE creator string public uint mediaPartNumberLength; /// Offset to start of creator string from start of this block public uint driveManufacturerOffset; /// Length in bytes of the null-terminated UTF-16LE creator string public uint driveManufacturerLength; /// Offset to start of creator string from start of this block public uint driveModelOffset; /// Length in bytes of the null-terminated UTF-16LE creator string public uint driveModelLength; /// Offset to start of creator string from start of this block public uint driveSerialNumberOffset; /// Length in bytes of the null-terminated UTF-16LE creator string public uint driveSerialNumberLength; /// Offset to start of creator string from start of this block public uint driveFirmwareRevisionOffset; /// Length in bytes of the null-terminated UTF-16LE creator string public uint driveFirmwareRevisionLength; } /// Contains list of optical disc tracks [StructLayout(LayoutKind.Sequential, Pack = 1)] struct TracksHeader { /// Identifier, public BlockType identifier; /// How many entries follow this header public ushort entries; /// CRC64-ECMA of the block public ulong crc64; } /// Optical disc track [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)] struct TrackEntry { /// Track sequence public byte sequence; /// Track type public TrackType type; /// Track starting LBA public long start; /// Track last LBA public long end; /// Track pregap in sectors public long pregap; /// Track session public byte session; /// Track's ISRC in ASCII [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 13)] public string isrc; /// Track flags public byte flags; } /// Geometry block, contains physical geometry information [StructLayout(LayoutKind.Sequential, Pack = 1)] struct CicmMetadataBlock { /// Identifier, public BlockType identifier; public uint length; } /// Dump hardware block, contains a list of hardware used to dump the media on this image [StructLayout(LayoutKind.Sequential, Pack = 1)] struct DumpHardwareHeader { /// Identifier, public BlockType identifier; /// How many entries follow this header public ushort entries; /// Size of the whole block, not including this header, in bytes public uint length; /// CRC64-ECMA of the block public ulong crc64; } /// Dump hardware entry, contains length of strings that follow, in the same order as the length, this structure [StructLayout(LayoutKind.Sequential, Pack = 1)] struct DumpHardwareEntry { /// Length of UTF-8 manufacturer string public uint manufacturerLength; /// Length of UTF-8 model string public uint modelLength; /// Length of UTF-8 revision string public uint revisionLength; /// Length of UTF-8 firmware version string public uint firmwareLength; /// Length of UTF-8 serial string public uint serialLength; /// Length of UTF-8 software name string public uint softwareNameLength; /// Length of UTF-8 software version string public uint softwareVersionLength; /// Length of UTF-8 software operating system string public uint softwareOperatingSystemLength; /// How many extents are after the strings public uint extents; } /// /// Checksum block, contains a checksum of all user data sectors (except for optical discs that is 2352 bytes raw /// sector if available /// [StructLayout(LayoutKind.Sequential, Pack = 1)] struct ChecksumHeader { /// Identifier, public BlockType identifier; /// Length in bytes of the block public uint length; /// How many checksums follow public byte entries; } /// Checksum entry, followed by checksum data itself [StructLayout(LayoutKind.Sequential, Pack = 1)] struct ChecksumEntry { /// Checksum algorithm public ChecksumAlgorithm type; /// Length in bytes of checksum that follows this structure public uint length; } } }