using System.Runtime.InteropServices;
namespace BinaryObjectScanner.Models.MoPaQ
{
///
/// MoPaQ archive header
///
///
[StructLayout(LayoutKind.Sequential)]
public sealed class ArchiveHeader
{
#region V1 Properties
///
/// The MPQ archive signature
///
public string Signature;
///
/// Size of the archive header
///
public uint HeaderSize;
///
/// Size of MPQ archive
///
///
/// This field is deprecated in the Burning Crusade MoPaQ format, and the size of the archive
/// is calculated as the size from the beginning of the archive to the end of the hash table,
/// block table, or extended block table (whichever is largest).
///
public uint ArchiveSize;
///
/// 0 = Format 1 (up to The Burning Crusade)
/// 1 = Format 2 (The Burning Crusade and newer)
/// 2 = Format 3 (WoW - Cataclysm beta or newer)
/// 3 = Format 4 (WoW - Cataclysm beta or newer)
///
public FormatVersion FormatVersion;
///
/// Power of two exponent specifying the number of 512-byte disk sectors in each logical sector
/// in the archive. The size of each logical sector in the archive is 512 * 2 ^ BlockSize.
///
public ushort BlockSize;
///
/// Offset to the beginning of the hash table, relative to the beginning of the archive.
///
public uint HashTablePosition;
///
/// Offset to the beginning of the block table, relative to the beginning of the archive.
///
public uint BlockTablePosition;
///
/// Number of entries in the hash table. Must be a power of two, and must be less than 2^16 for
/// the original MoPaQ format, or less than 2^20 for the Burning Crusade format.
///
public uint HashTableSize;
///
/// Number of entries in the block table
///
public uint BlockTableSize;
#endregion
#region V2 Properties
///
/// Offset to the beginning of array of 16-bit high parts of file offsets.
///
public ulong HiBlockTablePosition;
///
/// High 16 bits of the hash table offset for large archives.
///
public ushort HashTablePositionHi;
///
/// High 16 bits of the block table offset for large archives.
///
public ushort BlockTablePositionHi;
#endregion
#region V3 Properties
///
/// 64-bit version of the archive size
///
public ulong ArchiveSizeLong;
///
/// 64-bit position of the BET table
///
public ulong BetTablePosition;
///
/// 64-bit position of the HET table
///
public ulong HetTablePosition;
#endregion
#region V4 Properties
///
/// Compressed size of the hash table
///
public ulong HashTableSizeLong;
///
/// Compressed size of the block table
///
public ulong BlockTableSizeLong;
///
/// Compressed size of the hi-block table
///
public ulong HiBlockTableSize;
///
/// Compressed size of the HET block
///
public ulong HetTableSize;
///
/// Compressed size of the BET block
///
public ulong BetTablesize;
///
/// Size of raw data chunk to calculate MD5.
///
/// MD5 of each data chunk follows the raw file data.
public uint RawChunkSize;
///
/// MD5 of the block table before decryption
///
/// 0x10 bytes
public byte[] BlockTableMD5;
///
/// MD5 of the hash table before decryption
///
/// 0x10 bytes
public byte[] HashTableMD5;
///
/// MD5 of the hi-block table
///
/// 0x10 bytes
public byte[] HiBlockTableMD5;
///
/// MD5 of the BET table before decryption
///
/// 0x10 bytes
public byte[] BetTableMD5;
///
/// MD5 of the HET table before decryption
///
/// 0x10 bytes
public byte[] HetTableMD5;
///
/// MD5 of the MPQ header from signature to (including) HetTableMD5
///
/// 0x10 bytes
public byte[] MpqHeaderMD5;
#endregion
}
}