// /*************************************************************************** // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // // Filename : Structs.cs // Author(s) : Natalia Portillo // // Component : Disk image plugins. // // --[ Description ] ---------------------------------------------------------- // // Contains structures for Aaru 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-2023 Natalia Portillo // ****************************************************************************/ using System.Runtime.InteropServices; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; namespace Aaru.Images; public sealed partial class AaruFormat { #region Nested type: AaruHeader /// Header, at start of file [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)] struct AaruHeader { /// 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; } #endregion #region Nested type: AaruMetadataJsonBlock /// Aaru Metadata JSON block [StructLayout(LayoutKind.Sequential, Pack = 1)] struct AaruMetadataJsonBlock { /// Identifier, public BlockType identifier; public uint length; } #endregion #region Nested type: BlockHeader /// 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; } #endregion #region Nested type: ChecksumEntry /// 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; } #endregion #region Nested type: ChecksumHeader /// /// 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; } #endregion #region Nested type: CicmMetadataBlock /// CICM Metadata XML block [StructLayout(LayoutKind.Sequential, Pack = 1)] struct CicmMetadataBlock { /// Identifier, public readonly BlockType identifier; public readonly uint length; } #endregion #region Nested type: CompactDiscIndexEntry [StructLayout(LayoutKind.Sequential, Pack = 1)] struct CompactDiscIndexEntry { /// How many entries follow this header public ushort Track; /// Size of the whole block, not including this header, in bytes public ushort Index; /// CRC64-ECMA of the block public int Lba; } #endregion #region Nested type: CompactDiscIndexesHeader /// /// Compact Disc track indexes block, contains a cache of all Compact Disc indexes to not need to interpret /// subchannel /// [StructLayout(LayoutKind.Sequential, Pack = 1)] struct CompactDiscIndexesHeader { /// 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 readonly ulong length; /// CRC64-ECMA of the block public ulong crc64; } #endregion #region Nested type: DdtHeader /// 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 readonly ulong crc64; } #endregion #region Nested type: DumpHardwareEntry /// 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; } #endregion #region Nested type: DumpHardwareHeader /// 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; } #endregion #region Nested type: GeometryBlock /// 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; } #endregion #region Nested type: IndexEntry /// 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; } #endregion #region Nested type: IndexHeader /// 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; } #endregion #region Nested type: IndexHeader2 /// Header for the index, followed by entries [StructLayout(LayoutKind.Sequential, Pack = 1)] struct IndexHeader2 { /// Identifier, public BlockType identifier; /// How many entries follow this header public ulong entries; /// CRC64-ECMA of the index public ulong crc64; } #endregion #region Nested type: MetadataBlock /// 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; } #endregion #region Nested type: TapeFileEntry /// Tape file entry [StructLayout(LayoutKind.Sequential, Pack = 1)] struct TapeFileEntry { /// File number public uint File; /// Partition number public readonly byte Partition; /// First block, inclusive, of the file public ulong FirstBlock; /// Last block, inclusive, of the file public ulong LastBlock; } #endregion #region Nested type: TapeFileHeader /// Tape file block, contains a list of all files in a tape [StructLayout(LayoutKind.Sequential, Pack = 1)] struct TapeFileHeader { /// Identifier, public BlockType identifier; /// How many entries follow this header public uint entries; /// Size of the whole block, not including this header, in bytes public ulong length; /// CRC64-ECMA of the block public ulong crc64; } #endregion #region Nested type: TapePartitionEntry /// Tape partition entry [StructLayout(LayoutKind.Sequential, Pack = 1)] public struct TapePartitionEntry { /// Partition number public byte Number; /// First block, inclusive, of the partition public ulong FirstBlock; /// Last block, inclusive, of the partition public ulong LastBlock; } #endregion #region Nested type: TapePartitionHeader /// Tape partition block, contains a list of all partitions in a tape [StructLayout(LayoutKind.Sequential, Pack = 1)] struct TapePartitionHeader { /// Identifier, public BlockType identifier; /// How many entries follow this header public byte entries; /// Size of the whole block, not including this header, in bytes public ulong length; /// CRC64-ECMA of the block public ulong crc64; } #endregion #region Nested type: TrackEntry /// 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; } #endregion #region Nested type: TracksHeader /// 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; } #endregion }