using System.Runtime.InteropServices;
namespace BinaryObjectScanner.Models.MoPaQ
{
///
/// Each incremental patch file in a patch MPQ starts with a header. It is supposed
/// to be a structure with variable length.
///
///
[StructLayout(LayoutKind.Sequential)]
public sealed class PatchHeader
{
#region PATCH Header
///
/// 'PTCH'
///
public uint PatchSignature { get; private set; }
///
/// Size of the entire patch (decompressed)
///
public int SizeOfPatchData { get; private set; }
///
/// Size of the file before patch
///
public int SizeBeforePatch { get; private set; }
///
/// Size of file after patch
///
public int SizeAfterPatch { get; private set; }
#endregion
#region MD5 Block
///
/// 'MD5_'
///
public uint Md5Signature { get; private set; }
///
/// Size of the MD5 block, including the signature and size itself
///
public int Md5BlockSize { get; private set; }
///
/// MD5 of the original (unpached) file
///
public byte[] Md5BeforePatch { get; private set; } = new byte[0x10];
///
/// MD5 of the patched file
///
public byte[] Md5AfterPatch { get; private set; } = new byte[0x10];
#endregion
#region XFRM Block
///
/// 'XFRM'
///
public uint XfrmSignature { get; private set; }
///
/// Size of the XFRM block, includes XFRM header and patch data
///
public int XfrmBlockSize { get; private set; }
///
/// Type of patch ('BSD0' or 'COPY')
///
public PatchType PatchType { get; private set; }
#endregion
#region Patch Data - BSD0
///
/// 'BSDIFF40' signature
///
public ulong BsdiffSignature { get; private set; }
///
/// Size of CTRL block (in bytes)
///
public long CtrlBlockSize { get; private set; }
///
/// Size of DATA block (in bytes)
///
public long DataBlockSize { get; private set; }
///
/// Size of file after applying the patch (in bytes)
///
public long NewFileSize { get; private set; }
// TODO: Fill rest of data from http://zezula.net/en/mpq/patchfiles.html
// CTRL block
// DATA block
// EXTRA block
#endregion
#region Patch Data - COPY
///
/// File data are simply replaced by the data in the patch.
///
public byte[] PatchDataCopy { get; private set; }
#endregion
}
}