summaryrefslogtreecommitdiff
path: root/src/StormLib.h
diff options
context:
space:
mode:
authorLadislav Zezula <ladislav.zezula@avg.com>2014-10-07 11:23:52 +0200
committerLadislav Zezula <ladislav.zezula@avg.com>2014-10-07 11:23:52 +0200
commit2d3b3e11c032728a74dbc65a4a3941714b870a0f (patch)
treecdeed734ed6b3882e37df2ea87e34ec776607e75 /src/StormLib.h
parent1aa906cf21accf9d82b39340c1a7b5b54a9440e1 (diff)
+ Improved patching process so that it works for Starcraft II patches
+ Removed memory leaks in file search
Diffstat (limited to 'src/StormLib.h')
-rw-r--r--src/StormLib.h21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/StormLib.h b/src/StormLib.h
index ce1c02f..3ea3e19 100644
--- a/src/StormLib.h
+++ b/src/StormLib.h
@@ -162,8 +162,6 @@ extern "C" {
#define HASH_STATE_SIZE 0x60 // Size of LibTomCrypt's hash_state structure
-#define MPQ_PATCH_PREFIX_LEN 0x20 // Maximum length of the patch prefix
-
// Values for SFileOpenArchive
#define SFILE_OPEN_HARD_DISK_FILE 2 // Open the archive on HDD
#define SFILE_OPEN_CDROM_FILE 3 // Open the archive only if it is on CDROM
@@ -183,6 +181,7 @@ extern "C" {
#define MPQ_FLAG_ATTRIBUTES_INVALID 0x00000040 // If set, it means that the (attributes) has been invalidated
#define MPQ_FLAG_SIGNATURE_INVALID 0x00000080 // If set, it means that the (signature) has been invalidated
#define MPQ_FLAG_SAVING_TABLES 0x00000100 // If set, we are saving MPQ internal files and MPQ tables
+#define MPQ_FLAG_PATCH 0x00000200 // If set, this MPQ is a patch archive
// Values for TMPQArchive::dwSubType
#define MPQ_SUBTYPE_MPQ 0x00000000 // The file is a MPQ file (Blizzard games)
@@ -287,6 +286,7 @@ extern "C" {
#define MPQ_OPEN_NO_HEADER_SEARCH 0x00040000 // Don't search for the MPQ header past the begin of the file
#define MPQ_OPEN_FORCE_MPQ_V1 0x00080000 // Always open the archive as MPQ v 1.00, ignore the "wFormatVersion" variable in the header
#define MPQ_OPEN_CHECK_SECTOR_CRC 0x00100000 // On files with MPQ_FILE_SECTOR_CRC, the CRC will be checked when reading file
+#define MPQ_OPEN_PATCH 0x00200000 // This archive is a patch MPQ. Used internally.
#define MPQ_OPEN_READ_ONLY STREAM_FLAG_READ_ONLY
// Flags for SFileCreateArchive
@@ -821,9 +821,16 @@ typedef struct _TMPQBetTable
DWORD dwBitExtra_NameHash2; // Extra bits in the NameHash2
DWORD dwBitCount_NameHash2; // Effective size of the NameHash2
DWORD dwEntryCount; // Number of entries
- DWORD dwFlagCount; // Number of fil flags in pFileFlags
+ DWORD dwFlagCount; // Number of file flags in pFileFlags
} TMPQBetTable;
+// Structure for patch prefix
+typedef struct _TMPQNamePrefix
+{
+ size_t nLength; // Length of this patch prefix. Can be 0
+ char szPatchPrefix[1]; // Patch name prefix (variable length). If not empty, it always starts with backslash.
+} TMPQNamePrefix;
+
// Archive handle structure
typedef struct _TMPQArchive
{
@@ -834,8 +841,7 @@ typedef struct _TMPQArchive
struct _TMPQArchive * haPatch; // Pointer to patch archive, if any
struct _TMPQArchive * haBase; // Pointer to base ("previous version") archive, if any
- char szPatchPrefix[MPQ_PATCH_PREFIX_LEN]; // Prefix for file names in patch MPQs
- size_t cchPatchPrefix; // Length of the patch prefix, in characters
+ TMPQNamePrefix * pPatchPrefix; // Patch prefix to precede names of patch files
TMPQUserData * pUserData; // MPQ user data (NULL if not present in the file)
TMPQHeader * pHeader; // MPQ file header
@@ -883,8 +889,9 @@ typedef struct _TMPQFile
struct _TMPQFile * hfPatch; // Pointer to opened patch file
TPatchHeader * pPatchHeader; // Patch header. Only used if the file is a patch file
- LPBYTE pbFileData; // Loaded and patched file data. Only used if the file is a patch file
- DWORD cbFileData; // Size of loaded patched data
+ LPBYTE pbFileData; // Data of the file (single unit files, patched files)
+ DWORD cbFileData; // Size of file data
+ BYTE FileDataMD5[MD5_DIGEST_SIZE];// MD5 hash of the loaded file data. Used during patch process
TPatchInfo * pPatchInfo; // Patch info block, preceding the sector table
DWORD * SectorOffsets; // Position of each file sector, relative to the begin of the file. Only for compressed files.