From 568f189ea5a850a9259c8c89ba5f28a0630a2ce0 Mon Sep 17 00:00:00 2001 From: Ladislav Zezula Date: Fri, 14 Mar 2014 10:17:34 +0100 Subject: + Improved key detection for archives with large sector sizes --- src/StormCommon.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/StormCommon.h') diff --git a/src/StormCommon.h b/src/StormCommon.h index 2b2cf1d..52a5620 100644 --- a/src/StormCommon.h +++ b/src/StormCommon.h @@ -134,6 +134,7 @@ extern unsigned char AsciiToUpperTable[256]; #define MPQ_HASH_NAME_A 0x100 #define MPQ_HASH_NAME_B 0x200 #define MPQ_HASH_FILE_KEY 0x300 +#define MPQ_HASH_KEY2_MIX 0x400 DWORD HashString(const char * szFileName, DWORD dwHashType); DWORD HashStringSlash(const char * szFileName, DWORD dwHashType); @@ -148,11 +149,11 @@ ULONGLONG HashStringJenkins(const char * szFileName); DWORD GetDefaultSpecialFileFlags(DWORD dwFileSize, USHORT wFormatVersion); -void EncryptMpqBlock(void * pvFileBlock, DWORD dwLength, DWORD dwKey); -void DecryptMpqBlock(void * pvFileBlock, DWORD dwLength, DWORD dwKey); +void EncryptMpqBlock(void * pvDataBlock, DWORD dwLength, DWORD dwKey); +void DecryptMpqBlock(void * pvDataBlock, DWORD dwLength, DWORD dwKey); -DWORD DetectFileKeyBySectorSize(LPDWORD SectorOffsets, DWORD decrypted); -DWORD DetectFileKeyByContent(void * pvFileContent, DWORD dwFileSize); +DWORD DetectFileKeyBySectorSize(LPDWORD EncryptedData, DWORD dwSectorSize, DWORD dwSectorOffsLen); +DWORD DetectFileKeyByContent(void * pvEncryptedData, DWORD dwSectorSize, DWORD dwFileSize); DWORD DecryptFileKey(const char * szFileName, ULONGLONG MpqPos, DWORD dwFileSize, DWORD dwFlags); bool IsValidMD5(LPBYTE pbMd5); @@ -235,7 +236,7 @@ int SCompDecompressMpk(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer //----------------------------------------------------------------------------- // Common functions - MPQ File -TMPQFile * CreateMpqFile(TMPQArchive * ha); +TMPQFile * CreateFileHandle(TMPQArchive * ha, TFileEntry * pFileEntry); void * LoadMpqTable(TMPQArchive * ha, ULONGLONG ByteOffset, DWORD dwCompressedSize, DWORD dwRealSize, DWORD dwKey); int AllocateSectorBuffer(TMPQFile * hf); int AllocatePatchInfo(TMPQFile * hf, bool bLoadFromFile); @@ -247,12 +248,12 @@ int WriteSectorOffsets(TMPQFile * hf); int WriteSectorChecksums(TMPQFile * hf); int WriteMemDataMD5(TFileStream * pStream, ULONGLONG RawDataOffs, void * pvRawData, DWORD dwRawDataSize, DWORD dwChunkSize, LPDWORD pcbTotalSize); int WriteMpqDataMD5(TFileStream * pStream, ULONGLONG RawDataOffs, DWORD dwRawDataSize, DWORD dwChunkSize); -void FreeMPQFile(TMPQFile *& hf); +void FreeFileHandle(TMPQFile *& hf); bool IsIncrementalPatchFile(const void * pvData, DWORD cbData, LPDWORD pdwPatchedFileSize); int PatchFileData(TMPQFile * hf); -void FreeMPQArchive(TMPQArchive *& ha); +void FreeArchiveHandle(TMPQArchive *& ha); //----------------------------------------------------------------------------- // Utility functions -- cgit v1.2.3