2018-07-23 23:25:43 +01:00
|
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
|
// Aaru Data Preservation Suite
|
2018-07-23 23:25:43 +01:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : Structs.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : Disk image plugins.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Contains structures for partimage 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2020-01-03 17:51:30 +00:00
|
|
|
|
// Copyright © 2011-2020 Natalia Portillo
|
2018-07-23 23:25:43 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
2020-07-20 07:47:12 +01:00
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
2020-02-27 00:33:26 +00:00
|
|
|
|
namespace Aaru.DiscImages
|
2018-07-23 23:25:43 +01:00
|
|
|
|
{
|
2020-07-20 07:47:12 +01:00
|
|
|
|
[SuppressMessage("ReSharper", "UnusedType.Local")]
|
2018-07-23 23:25:43 +01:00
|
|
|
|
public partial class Partimage
|
|
|
|
|
|
{
|
2020-02-29 18:03:35 +00:00
|
|
|
|
/// <summary>Partimage disk image header, little-endian</summary>
|
2018-07-23 23:25:43 +01:00
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
|
struct PartimageHeader
|
|
|
|
|
|
{
|
2020-02-29 18:03:35 +00:00
|
|
|
|
/// <summary>Magic, <see cref="Partimage.partimageMagic" /></summary>
|
2018-07-23 23:25:43 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] magic;
|
|
|
|
|
|
/// <summary>Source filesystem</summary>
|
2018-07-23 23:25:43 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] version;
|
|
|
|
|
|
/// <summary>Volume number</summary>
|
|
|
|
|
|
public readonly uint volumeNumber;
|
|
|
|
|
|
/// <summary>Image identifier</summary>
|
|
|
|
|
|
public readonly ulong identificator;
|
|
|
|
|
|
/// <summary>Empty space</summary>
|
2018-07-23 23:25:43 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 404)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] reserved;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct PortableTm
|
|
|
|
|
|
{
|
|
|
|
|
|
public uint Second;
|
|
|
|
|
|
public uint Minute;
|
|
|
|
|
|
public uint Hour;
|
|
|
|
|
|
public uint DayOfMonth;
|
|
|
|
|
|
public uint Month;
|
|
|
|
|
|
public uint Year;
|
|
|
|
|
|
public uint DayOfWeek;
|
|
|
|
|
|
public uint DayOfYear;
|
|
|
|
|
|
public uint IsDst;
|
|
|
|
|
|
|
|
|
|
|
|
public uint GmtOff;
|
|
|
|
|
|
public uint Timezone;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
/// <summary>Partimage CMainHeader</summary>
|
2018-07-23 23:25:43 +01:00
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
|
struct PartimageMainHeader
|
|
|
|
|
|
{
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] szFileSystem; // ext2fs, ntfs, reiserfs, ...
|
2018-07-23 23:25:43 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_DESCRIPTION)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] szPartDescription; // user description of the partition
|
2018-07-23 23:25:43 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_DEVICENAMELEN)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] szOriginalDevice; // original partition name
|
2018-07-23 23:25:43 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4095)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] szFirstImageFilepath; //MAXPATHLEN]; // for splitted image files
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
|
// system and hardware infos
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_UNAMEINFOLEN)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] szUnameSysname;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_UNAMEINFOLEN)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] szUnameNodename;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_UNAMEINFOLEN)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] szUnameRelease;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_UNAMEINFOLEN)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] szUnameVersion;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_UNAMEINFOLEN)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] szUnameMachine;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly PCompression dwCompression; // COMPRESS_XXXXXX
|
|
|
|
|
|
public readonly uint dwMainFlags;
|
|
|
|
|
|
public readonly PortableTm dateCreate; // date of image creation
|
|
|
|
|
|
public readonly ulong qwPartSize; // size of the partition in bytes
|
2018-07-23 23:25:43 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_HOSTNAMESIZE)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] szHostname;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] szVersion; // version of the image file
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
|
// MBR backup
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly uint dwMbrCount; // how many MBR are saved in the image file
|
|
|
|
|
|
public readonly uint dwMbrSize; // size of a MBR record (allow to change the size in the next versions)
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
|
// future encryption support
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly PEncryption dwEncryptAlgo; // algo used to encrypt data
|
2018-07-23 23:25:43 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] cHashTestKey; // used to test the password without giving it
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
|
// reserved for future use (save DiskLabel, Extended partitions, ...)
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly uint dwReservedFuture000;
|
|
|
|
|
|
public readonly uint dwReservedFuture001;
|
|
|
|
|
|
public readonly uint dwReservedFuture002;
|
|
|
|
|
|
public readonly uint dwReservedFuture003;
|
|
|
|
|
|
public readonly uint dwReservedFuture004;
|
|
|
|
|
|
public readonly uint dwReservedFuture005;
|
|
|
|
|
|
public readonly uint dwReservedFuture006;
|
|
|
|
|
|
public readonly uint dwReservedFuture007;
|
|
|
|
|
|
public readonly uint dwReservedFuture008;
|
|
|
|
|
|
public readonly uint dwReservedFuture009;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6524)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] cReserved; // Adjust to fit with total header size
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly uint crc;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
|
struct CMbr // must be 1024
|
|
|
|
|
|
{
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MBR_SIZE_WHOLE)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] cData;
|
|
|
|
|
|
public readonly uint dwDataCRC;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_DEVICENAMELEN)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] szDevice; // ex: "hda"
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
|
// disk identificators
|
2020-02-29 18:03:35 +00:00
|
|
|
|
readonly ulong qwBlocksCount;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_DESC_MODEL)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] szDescModel;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 884)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] cReserved; // for future use
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
|
//public byte[] szDescGeometry[MAX_DESC_GEOMETRY];
|
|
|
|
|
|
//public byte[] szDescIdentify[MAX_DESC_IDENTIFY];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
|
struct CCheck
|
|
|
|
|
|
{
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
readonly byte[] cMagic; // must be 'C','H','K'
|
|
|
|
|
|
public readonly uint dwCRC; // CRC of the CHECK_FREQUENCY blocks
|
|
|
|
|
|
public readonly ulong qwPos; // number of the last block written
|
2018-07-23 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
|
struct CLocalHeader // size must be 16384 (adjust the reserved data)
|
|
|
|
|
|
{
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly ulong qwBlockSize;
|
|
|
|
|
|
public readonly ulong qwUsedBlocks;
|
|
|
|
|
|
public readonly ulong qwBlocksCount;
|
|
|
|
|
|
public readonly ulong qwBitmapSize; // bytes in the bitmap
|
|
|
|
|
|
public readonly ulong qwBadBlocksCount;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] szLabel;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16280)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] cReserved; // Adjust to fit with total header size
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly uint crc;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
|
struct CMainTail // size must be 16384 (adjust the reserved data)
|
|
|
|
|
|
{
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly ulong qwCRC;
|
|
|
|
|
|
public readonly uint dwVolumeNumber;
|
2018-07-23 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16372)]
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte[] cReserved; // Adjust to fit with total header size
|
2018-07-23 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|