Files
libaaruformat/include/aaruformat/structs.h

326 lines
11 KiB
C
Raw Normal View History

2019-03-16 19:15:07 +00:00
// /***************************************************************************
2020-03-01 19:50:12 +00:00
// Aaru Data Preservation Suite
2019-03-16 19:15:07 +00:00
// ----------------------------------------------------------------------------
//
// Filename : structs.h
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// 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 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 License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License aint64_t with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
2020-01-03 17:47:47 +00:00
// Copyright © 2011-2020 Natalia Portillo
2019-03-16 19:15:07 +00:00
// ****************************************************************************/
#pragma clang diagnostic push
2020-03-01 19:53:05 +00:00
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
#ifndef LIBAARUFORMAT_STRUCTS_H
#define LIBAARUFORMAT_STRUCTS_H
2019-03-16 19:15:07 +00:00
#pragma pack(push, 1)
#include "enums.h"
2020-03-01 19:51:43 +00:00
#include <aaru.h>
2019-03-31 20:52:06 +01:00
#include <stdbool.h>
#include <stdint.h>
2019-03-16 19:15:07 +00:00
/**Header, at start of file */
2020-03-01 19:55:22 +00:00
typedef struct AaruHeader
2019-03-16 19:15:07 +00:00
{
2020-03-01 19:53:05 +00:00
/**Header identifier, <see cref="AARU_MAGIC" /> */
2019-03-20 22:34:21 +00:00
uint64_t identifier;
2019-03-16 19:15:07 +00:00
/**UTF-16LE name of the application that created the image */
2019-03-31 20:52:06 +01:00
uint8_t application[64];
2019-03-16 19:15:07 +00:00
/**Image format major version. A new major version means a possibly incompatible change of format */
2019-03-31 20:52:06 +01:00
uint8_t imageMajorVersion;
2019-03-16 19:15:07 +00:00
/**Image format minor version. A new minor version indicates a compatible change of format */
2019-03-31 20:52:06 +01:00
uint8_t imageMinorVersion;
2019-03-16 19:15:07 +00:00
/**Major version of the application that created the image */
2019-03-31 20:52:06 +01:00
uint8_t applicationMajorVersion;
2019-03-16 19:15:07 +00:00
/**Minor version of the application that created the image */
2019-03-31 20:52:06 +01:00
uint8_t applicationMinorVersion;
2019-03-16 19:15:07 +00:00
/**Type of media contained on image */
2019-03-20 22:34:21 +00:00
uint32_t mediaType;
2019-03-16 19:15:07 +00:00
/**Offset to index */
2019-03-20 22:34:21 +00:00
uint64_t indexOffset;
2019-03-16 19:15:07 +00:00
/**Windows filetime (100 nanoseconds since 1601/01/01 00:00:00 UTC) of image creation time */
2019-03-31 20:52:06 +01:00
int64_t creationTime;
2019-03-16 19:15:07 +00:00
/**Windows filetime (100 nanoseconds since 1601/01/01 00:00:00 UTC) of image last written time */
2019-03-31 20:52:06 +01:00
int64_t lastWrittenTime;
2020-03-01 19:55:22 +00:00
} AaruHeader;
2019-03-16 19:15:07 +00:00
/**Header for a deduplication table. Table follows it */
typedef struct DdtHeader
{
/**Identifier, <see cref="BlockType.DeDuplicationTable" /> */
uint32_t identifier;
/**Type of data pointed by this DDT */
uint16_t type;
/**Compression algorithm used to compress the DDT */
uint16_t compression;
/**Each entry is ((uint8_t offset in file) &lt;&lt; shift) + (sector offset in block) */
2019-03-31 20:52:06 +01:00
uint8_t shift;
2019-03-16 19:15:07 +00:00
/**How many entries are in the table */
uint64_t entries;
/**Compressed length for the DDT */
uint64_t cmpLength;
/**Uncompressed length for the DDT */
uint64_t length;
/**CRC64-ECMA of the compressed DDT */
uint64_t cmpCrc64;
/**CRC64-ECMA of the uncompressed DDT */
uint64_t crc64;
} DdtHeader;
/**Header for the index, followed by entries */
typedef struct IndexHeader
{
/**Identifier, <see cref="BlockType.Index" /> */
uint32_t identifier;
/**How many entries follow this header */
uint16_t entries;
/**CRC64-ECMA of the index */
uint64_t crc64;
} IndexHeader;
/**Index entry */
typedef struct IndexEntry
{
/**Type of item pointed by this entry */
2019-03-17 21:14:40 +00:00
uint32_t blockType;
2019-03-16 19:15:07 +00:00
/**Type of data contained by the block pointed by this entry */
uint16_t dataType;
/**Offset in file where item is stored */
uint64_t offset;
} IndexEntry;
/**Block header, precedes block data */
typedef struct BlockHeader
{
/**Identifier, <see cref="BlockType.DataBlock" /> */
uint32_t identifier;
/**Type of data contained by this block */
uint16_t type;
/**Compression algorithm used to compress the block */
uint16_t compression;
/**Size in uint8_ts of each sector contained in this block */
uint32_t sectorSize;
/**Compressed length for the block */
uint32_t cmpLength;
/**Uncompressed length for the block */
uint32_t length;
/**CRC64-ECMA of the compressed block */
uint64_t cmpCrc64;
/**CRC64-ECMA of the uncompressed block */
uint64_t crc64;
} BlockHeader;
/**Geometry block, contains physical geometry information */
typedef struct GeometryBlockHeader
{
/**Identifier, <see cref="BlockType.GeometryBlock" /> */
uint32_t identifier;
uint32_t cylinders;
uint32_t heads;
uint32_t sectorsPerTrack;
} GeometryBlockHeader;
/**Metadata block, contains metadata */
typedef struct MetadataBlockHeader
{
/**Identifier, <see cref="BlockType.MetadataBlock" /> */
uint32_t identifier;
/**Size in uint8_ts of this whole metadata block */
uint32_t blockSize;
/**Sequence of media set this media beint64_ts to */
2019-03-31 20:52:06 +01:00
int32_t mediaSequence;
2019-03-16 19:15:07 +00:00
/**Total number of media on the media set this media beint64_ts to */
2019-03-31 20:52:06 +01:00
int32_t lastMediaSequence;
2019-03-16 19:15:07 +00:00
/**Offset to start of creator string from start of this block */
uint32_t creatorOffset;
/**Length in uint8_ts of the null-terminated UTF-16LE creator string */
uint32_t creatorLength;
/**Offset to start of creator string from start of this block */
uint32_t commentsOffset;
/**Length in uint8_ts of the null-terminated UTF-16LE creator string */
uint32_t commentsLength;
/**Offset to start of creator string from start of this block */
uint32_t mediaTitleOffset;
/**Length in uint8_ts of the null-terminated UTF-16LE creator string */
uint32_t mediaTitleLength;
/**Offset to start of creator string from start of this block */
uint32_t mediaManufacturerOffset;
/**Length in uint8_ts of the null-terminated UTF-16LE creator string */
uint32_t mediaManufacturerLength;
/**Offset to start of creator string from start of this block */
uint32_t mediaModelOffset;
/**Length in uint8_ts of the null-terminated UTF-16LE creator string */
uint32_t mediaModelLength;
/**Offset to start of creator string from start of this block */
uint32_t mediaSerialNumberOffset;
/**Length in uint8_ts of the null-terminated UTF-16LE creator string */
uint32_t mediaSerialNumberLength;
/**Offset to start of creator string from start of this block */
uint32_t mediaBarcodeOffset;
/**Length in uint8_ts of the null-terminated UTF-16LE creator string */
uint32_t mediaBarcodeLength;
/**Offset to start of creator string from start of this block */
uint32_t mediaPartNumberOffset;
/**Length in uint8_ts of the null-terminated UTF-16LE creator string */
uint32_t mediaPartNumberLength;
/**Offset to start of creator string from start of this block */
uint32_t driveManufacturerOffset;
/**Length in uint8_ts of the null-terminated UTF-16LE creator string */
uint32_t driveManufacturerLength;
/**Offset to start of creator string from start of this block */
uint32_t driveModelOffset;
/**Length in uint8_ts of the null-terminated UTF-16LE creator string */
uint32_t driveModelLength;
/**Offset to start of creator string from start of this block */
uint32_t driveSerialNumberOffset;
/**Length in uint8_ts of the null-terminated UTF-16LE creator string */
uint32_t driveSerialNumberLength;
/**Offset to start of creator string from start of this block */
uint32_t driveFirmwareRevisionOffset;
/**Length in uint8_ts of the null-terminated UTF-16LE creator string */
uint32_t driveFirmwareRevisionLength;
} MetadataBlockHeader;
/**Contains list of optical disc tracks */
typedef struct TracksHeader
{
/**Identifier, <see cref="BlockType.TracksBlock" /> */
uint32_t identifier;
/**How many entries follow this header */
uint16_t entries;
/**CRC64-ECMA of the block */
uint64_t crc64;
} TracksHeader;
/**Optical disc track */
typedef struct TrackEntry
{
/**Track sequence */
2019-03-20 22:34:21 +00:00
uint8_t sequence;
2019-03-16 19:15:07 +00:00
/**Track type */
2019-03-20 22:34:21 +00:00
uint8_t type;
2019-03-16 19:15:07 +00:00
/**Track starting LBA */
2019-03-20 22:34:21 +00:00
int64_t start;
2019-03-16 19:15:07 +00:00
/**Track last LBA */
2019-03-20 22:34:21 +00:00
int64_t end;
2019-03-16 19:15:07 +00:00
/**Track pregap in sectors */
2019-03-20 22:34:21 +00:00
int64_t pregap;
2019-03-16 19:15:07 +00:00
/**Track session */
2019-03-20 22:34:21 +00:00
uint8_t session;
2019-03-16 19:15:07 +00:00
/**Track's ISRC in ASCII */
2019-03-20 22:34:21 +00:00
uint8_t isrc[13];
2019-03-16 19:15:07 +00:00
/**Track flags */
2019-03-20 22:34:21 +00:00
uint8_t flags;
2019-03-16 19:15:07 +00:00
} TrackEntry;
/**Geometry block, contains physical geometry information */
typedef struct CicmMetadataBlock
{
/**Identifier, <see cref="BlockType.CicmBlock" /> */
uint32_t identifier;
uint32_t length;
} CicmMetadataBlock;
/**Dump hardware block, contains a list of hardware used to dump the media on this image */
typedef struct DumpHardwareHeader
{
/**Identifier, <see cref="BlockType.DumpHardwareBlock" /> */
uint32_t identifier;
/**How many entries follow this header */
uint16_t entries;
/**Size of the whole block, not including this header, in uint8_ts */
uint32_t length;
/**CRC64-ECMA of the block */
uint64_t crc64;
} DumpHardwareHeader;
/**Dump hardware entry, contains length of strings that follow, in the same order as the length, this structure */
typedef struct DumpHardwareEntry
{
/**Length of UTF-8 manufacturer string */
uint32_t manufacturerLength;
/**Length of UTF-8 model string */
uint32_t modelLength;
/**Length of UTF-8 revision string */
uint32_t revisionLength;
/**Length of UTF-8 firmware version string */
uint32_t firmwareLength;
/**Length of UTF-8 serial string */
uint32_t serialLength;
/**Length of UTF-8 software name string */
uint32_t softwareNameLength;
/**Length of UTF-8 software version string */
uint32_t softwareVersionLength;
/**Length of UTF-8 software operating system string */
uint32_t softwareOperatingSystemLength;
/**How many extents are after the strings */
uint32_t extents;
} DumpHardwareEntry;
/**
* Checksum block, contains a checksum of all user data sectors (except for optical discs that is 2352 uint8_ts raw
* sector if available
* */
typedef struct ChecksumHeader
{
/**Identifier, <see cref="BlockType.ChecksumBlock" /> */
uint32_t identifier;
/**Length in uint8_ts of the block */
uint32_t length;
/**How many checksums follow */
2019-03-31 20:52:06 +01:00
uint8_t entries;
2019-03-16 19:15:07 +00:00
} ChecksumHeader;
/**Checksum entry, followed by checksum data itself */
typedef struct ChecksumEntry
{
/**Checksum algorithm */
2019-03-31 20:52:06 +01:00
uint8_t type;
2019-03-16 19:15:07 +00:00
/**Length in uint8_ts of checksum that follows this structure */
uint32_t length;
} ChecksumEntry;
2019-03-20 23:41:16 +00:00
typedef struct Crc64Context
{
uint64_t finalSeed;
uint64_t table[256];
uint64_t hashInt;
} Crc64Context;
2019-03-16 19:15:07 +00:00
2019-03-23 22:59:36 +00:00
typedef struct CdEccContext
{
2019-03-31 20:52:06 +01:00
bool initedEdc;
2019-08-03 01:58:19 +01:00
uint8_t* eccBTable;
uint8_t* eccFTable;
uint32_t* edcTable;
2019-03-23 22:59:36 +00:00
} CdEccContext;
2019-03-16 19:15:07 +00:00
#pragma pack(pop)
2020-03-01 19:53:05 +00:00
#endif // LIBAARUFORMAT_STRUCTS_H
2019-03-16 19:15:07 +00:00
#pragma clang diagnostic pop