From 77761e819506075b28c1b4eaf3fb295cc544c838 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 3 Apr 2016 10:21:30 +0200 Subject: Dep/CascLib: Update to ladislav-zezula/CascLib@d477d30f7c2b3a306fd07c92929950639335fb3f --- dep/CascLib/src/CascCommon.h | 10 +- dep/CascLib/src/CascDecompress.cpp | 2 +- dep/CascLib/src/CascDumpData.cpp | 10 +- dep/CascLib/src/CascFiles.cpp | 87 +++++++++---- dep/CascLib/src/CascFindFile.cpp | 16 +-- dep/CascLib/src/CascLib.h | 36 +++--- dep/CascLib/src/CascMndx.h | 18 +-- dep/CascLib/src/CascOpenFile.cpp | 2 +- dep/CascLib/src/CascOpenStorage.cpp | 22 ++-- dep/CascLib/src/CascPort.h | 6 +- dep/CascLib/src/CascReadFile.cpp | 12 +- dep/CascLib/src/CascRootFile_Diablo3.cpp | 18 +-- dep/CascLib/src/CascRootFile_Mndx.cpp | 136 ++++++++++----------- dep/CascLib/src/CascRootFile_Ovr.cpp | 25 ++-- dep/CascLib/src/CascRootFile_WoW6.cpp | 6 +- dep/CascLib/src/common/Common.cpp | 66 +++++----- dep/CascLib/src/common/Directory.cpp | 10 +- dep/CascLib/src/common/FileStream.cpp | 48 ++++---- dep/CascLib/src/common/ListFile.cpp | 8 +- dep/CascLib/src/common/Map.h | 2 +- dep/CascLib/src/common/RootHandler.cpp | 6 +- dep/CascLib/src/jenkins/lookup3.c | 42 +++---- dep/CascLib/src/libtomcrypt/src/hashes/md5.c | 30 ++--- .../src/libtomcrypt/src/misc/crypt_argchk.c | 2 +- .../libtomcrypt/src/misc/crypt_hash_descriptor.c | 2 +- .../src/libtomcrypt/src/misc/crypt_hash_is_valid.c | 2 +- 26 files changed, 335 insertions(+), 289 deletions(-) (limited to 'dep/CascLib/src') diff --git a/dep/CascLib/src/CascCommon.h b/dep/CascLib/src/CascCommon.h index 42e158bfcb2..71855726d03 100644 --- a/dep/CascLib/src/CascCommon.h +++ b/dep/CascLib/src/CascCommon.h @@ -117,7 +117,7 @@ typedef struct _CASC_MAPPING_TABLE BYTE KeyBytes; // Size of the file key BYTE SegmentBits; // Number of bits for the file offset (rest is archive index) ULONGLONG MaxFileOffset; - + PCASC_INDEX_ENTRY pIndexEntries; // Sorted array of index entries DWORD nIndexEntries; // Number of index entries @@ -197,7 +197,7 @@ typedef struct _TCascStorage DWORD dwBuildNumber; // Game build number DWORD dwFileBeginDelta; // This is number of bytes to shift back from archive offset (from index entry) to actual begin of file data DWORD dwDefaultLocale; // Default locale, read from ".build.info" - + CBLD_TYPE BuildFileType; // Type of the build file QUERY_KEY CdnConfigKey; @@ -229,7 +229,7 @@ typedef struct _TCascFile TCascStorage * hs; // Pointer to storage structure TFileStream * pStream; // An open data stream const char * szClassName; // "TCascFile" - + DWORD FilePointer; // Current file pointer DWORD ArchiveIndex; // Index of the archive (data.###) @@ -320,7 +320,9 @@ void FreeCascBlob(PQUERY_KEY pQueryKey); int LoadBuildInfo(TCascStorage * hs); int CheckGameDirectory(TCascStorage * hs, TCHAR * szDirectory); -int ParseRootFileLine(const char * szLinePtr, const char * szLineEnd, PQUERY_KEY pEncodingKey, char * szFileName, size_t nMaxChars); + +int GetRootVariableIndex(const char * szLinePtr, const char * szLineEnd, const char * szVariableName, int * PtrIndex); +int ParseRootFileLine(const char * szLinePtr, const char * szLineEnd, int nFileNameIndex, PQUERY_KEY pEncodingKey, char * szFileName, size_t nMaxChars); //----------------------------------------------------------------------------- // Internal file functions diff --git a/dep/CascLib/src/CascDecompress.cpp b/dep/CascLib/src/CascDecompress.cpp index 290b08d64d8..e60adb8f97b 100644 --- a/dep/CascLib/src/CascDecompress.cpp +++ b/dep/CascLib/src/CascDecompress.cpp @@ -40,7 +40,7 @@ int CascDecompress(LPBYTE pbOutBuffer, PDWORD pcbOutBuffer, LPBYTE pbInBuffer, D // Give the size of the uncompressed data *pcbOutBuffer = z.total_out; } - + // Return an error code return (nResult == Z_OK || nResult == Z_STREAM_END) ? ERROR_SUCCESS : ERROR_FILE_CORRUPT; } diff --git a/dep/CascLib/src/CascDumpData.cpp b/dep/CascLib/src/CascDumpData.cpp index 3c0e385ac07..e6b4265d76b 100644 --- a/dep/CascLib/src/CascDumpData.cpp +++ b/dep/CascLib/src/CascDumpData.cpp @@ -59,11 +59,11 @@ void CascDumpSparseArray(const char * szFileName, void * pvSparseArray) // Create the dump file fp = fopen(szFileName, "wt"); - if(fp != NULL) + if(fp != NULL) { // Write header fprintf(fp, "## Value\n-- -----\n"); - + // Write the values for(DWORD i = 0; i < pSparseArray->TotalItemCount; i++) { @@ -91,7 +91,7 @@ void CascDumpNameFragTable(const char * szFileName, void * pMarFile) // Create the dump file fp = fopen(szFileName, "wt"); - if(fp != NULL) + if(fp != NULL) { PNAME_FRAG pNameTable = pDB->NameFragTable.NameFragArray; const char * szNames = pDB->IndexStruct_174.NameFragments.CharArray; @@ -241,7 +241,7 @@ void CascDumpEncodingEntry( { // Dump the index key dump_print(dc, " %s\n", StringFromMD5(pbIndexKey, szMd5)); - + // Dump the index entry as well if(nDumpLevel >= DUMP_LEVEL_INDEX_ENTRIES) { @@ -290,7 +290,7 @@ void CascDumpIndexEntries(const char * szFileName, TCascStorage * hs) FileSize = ConvertBytesToInteger_4_LE(pIndexEntry->FileSizeLE); ArchOffset &= 0x3FFFFFFF; - + fprintf(fp, " %02X %08X %08X %s\n", ArchIndex, (DWORD)ArchOffset, FileSize, StringFromBinary(pIndexEntry->IndexKey, CASC_FILE_KEY_SIZE, szIndexKey)); } diff --git a/dep/CascLib/src/CascFiles.cpp b/dep/CascLib/src/CascFiles.cpp index 8709ea09e36..a32f411462f 100644 --- a/dep/CascLib/src/CascFiles.cpp +++ b/dep/CascLib/src/CascFiles.cpp @@ -41,7 +41,7 @@ static const TBuildFileInfo BuildTypes[] = {NULL, CascBuildNone} }; -static const TCHAR * DataDirs[] = +static const TCHAR * DataDirs[] = { _T("SC2Data"), // Starcraft II (Legacy of the Void) build 38749 _T("Data\\Casc"), // Overwatch @@ -381,7 +381,7 @@ static int LoadMultipleBlobs(PQUERY_KEY pBlob, const char * szLineBegin, const c size_t nLength = (szLineEnd - szLineBegin); // We expect each blob to have length of the encoding key and one space between - if(nLength > (dwBlobCount * MD5_STRING_SIZE) + ((dwBlobCount - 1) * sizeof(char))) + if(nLength > (dwBlobCount * MD5_STRING_SIZE) + ((dwBlobCount - 1) * sizeof(char))) return ERROR_INVALID_PARAMETER; // Allocate the blob buffer @@ -401,7 +401,7 @@ static int LoadMultipleBlobs(PQUERY_KEY pBlob, const char * szLineBegin, const c static int LoadSingleBlob(PQUERY_KEY pBlob, const char * szLineBegin, const char * szLineEnd) { - return LoadMultipleBlobs(pBlob, szLineBegin, szLineEnd, 1); + return LoadMultipleBlobs(pBlob, szLineBegin, szLineEnd, 1); } static int GetGameType(TCascStorage * hs, const char * szVarBegin, const char * szLineEnd) @@ -409,7 +409,7 @@ static int GetGameType(TCascStorage * hs, const char * szVarBegin, const char * // Go through all games that we support for(size_t i = 0; GameIds[i].szGameInfo != NULL; i++) { - // Check the length of the variable + // Check the length of the variable if((size_t)(szLineEnd - szVarBegin) == GameIds[i].cchGameInfo) { // Check the string @@ -475,7 +475,7 @@ static int GetDefaultLocaleMask(TCascStorage * hs, PQUERY_KEY pTagsString) // Get the next part if(szNext == NULL) break; - + // Skip spaces while(szNext < szTagEnd && szNext[0] == ' ') szNext++; @@ -523,7 +523,7 @@ static int ParseFile_BuildInfo(TCascStorage * hs, void * pvListFile) QUERY_KEY CdnHost = {NULL, 0}; QUERY_KEY CdnPath = {NULL, 0}; char szOneLine1[0x200]; - char szOneLine2[0x200]; + char szOneLine2[0x400]; size_t nLength1; size_t nLength2; int nError = ERROR_BAD_FORMAT; @@ -935,7 +935,7 @@ int CheckGameDirectory(TCascStorage * hs, TCHAR * szDirectory) return ERROR_SUCCESS; } } - + CASC_FREE(szBuildFile); } } @@ -943,15 +943,48 @@ int CheckGameDirectory(TCascStorage * hs, TCHAR * szDirectory) return nError; } -// Parses single line from Overwatch. -// The line structure is: "#MD5|CHUNK_ID|FILENAME|INSTALLPATH" +//----------------------------------------------------------------------------- +// Helpers for a config files that have multiple variables separated by "|" +// The line structure is (Overwatch 24919): "#MD5|CHUNK_ID|FILENAME|INSTALLPATH" +// The line structure is (Overwatch 27759): "#MD5|CHUNK_ID|PRIORITY|MPRIORITY|FILENAME|INSTALLPATH" // The line has all preceding spaces removed -int ParseRootFileLine(const char * szLinePtr, const char * szLineEnd, PQUERY_KEY PtrEncodingKey, char * szFileName, size_t nMaxChars) + +// Retrieves the index of a variable from the initial line +int GetRootVariableIndex(const char * szLinePtr, const char * szLineEnd, const char * szVariableName, int * PtrIndex) { - size_t nLength; + size_t nLength = strlen(szVariableName); + int nIndex = 0; + + while(szLinePtr < szLineEnd) + { + // Check the variable there + if(!_strnicmp(szLinePtr, szVariableName, nLength)) + { + // Does the length match? + if(szLinePtr[nLength] == '|' || szLinePtr[nLength] == '0') + { + PtrIndex[0] = nIndex; + return ERROR_SUCCESS; + } + } + + // Get the next variable + szLinePtr = SkipInfoVariable(szLinePtr, szLineEnd); + if(szLinePtr == NULL) + break; + nIndex++; + } + + return ERROR_BAD_FORMAT; +} + +// Parses single line from Overwatch. +int ParseRootFileLine(const char * szLinePtr, const char * szLineEnd, int nFileNameIndex, PQUERY_KEY PtrEncodingKey, char * szFileName, size_t nMaxChars) +{ + int nIndex = 0; int nError; - // Check the MD5 (aka encoding key) + // Extract the MD5 (aka encoding key) if(szLinePtr[MD5_STRING_SIZE] != '|') return ERROR_BAD_FORMAT; @@ -961,21 +994,25 @@ int ParseRootFileLine(const char * szLinePtr, const char * szLineEnd, PQUERY_KEY if(nError != ERROR_SUCCESS) return nError; - // Skip the MD5 - szLinePtr += MD5_STRING_SIZE+1; - - // Skip the chunk ID - szLinePtr = SkipInfoVariable(szLinePtr, szLineEnd); + // Skip the variable + szLinePtr += MD5_STRING_SIZE + 1; + nIndex = 1; - // Get the archived file name - szLineEnd = SkipInfoVariable(szLinePtr, szLineEnd); - nLength = (size_t)(szLineEnd - szLinePtr - 1); + // Skip the variables until we find the file name + while(szLinePtr < szLineEnd && nIndex < nFileNameIndex) + { + if(szLinePtr[0] == '|') + nIndex++; + szLinePtr++; + } - // Get the file name - if(nLength > nMaxChars) - return ERROR_INSUFFICIENT_BUFFER; + // Extract the file name + while(szLinePtr < szLineEnd && szLinePtr[0] != '|' && nMaxChars > 1) + { + *szFileName++ = *szLinePtr++; + nMaxChars--; + } - memcpy(szFileName, szLinePtr, nLength); - szFileName[nLength] = 0; + *szFileName = 0; return ERROR_SUCCESS; } diff --git a/dep/CascLib/src/CascFindFile.cpp b/dep/CascLib/src/CascFindFile.cpp index bea2e308747..1016dffdb45 100644 --- a/dep/CascLib/src/CascFindFile.cpp +++ b/dep/CascLib/src/CascFindFile.cpp @@ -66,7 +66,7 @@ static TCascSearch * AllocateSearchHandle(TCascStorage * hs, const TCHAR * szLis // Initialize the structure memset(pSearch, 0, cbToAllocate); pSearch->szClassName = "TCascSearch"; - + // Save the search handle pSearch->hs = hs; hs->dwRefCount++; @@ -94,7 +94,7 @@ static TCascSearch * AllocateSearchHandle(TCascStorage * hs, const TCHAR * szLis return NULL; } } - + return pSearch; } @@ -132,7 +132,7 @@ static bool DoStorageSearch_RootFile(TCascSearch * pSearch, PCASC_FIND_DATA pFin ByteIndex = (DWORD)(EncodingIndex / 8); BitMask = 1 << (EncodingIndex & 0x07); pSearch->BitArray[ByteIndex] |= BitMask; - + // Locate the index entry IndexKey.pbData = GET_INDEX_KEY(pEncodingEntry); IndexKey.cbData = MD5_HASH_SIZE; @@ -199,7 +199,7 @@ static bool DoStorageSearch_EncodingKey(TCascSearch * pSearch, PCASC_FIND_DATA p // Go to the next encoding entry pSearch->IndexLevel1++; } - + // Nameless search ended return false; } @@ -212,7 +212,7 @@ static bool DoStorageSearch(TCascSearch * pSearch, PCASC_FIND_DATA pFindData) // Does the search specify listfile? if(pSearch->szListFile != NULL) pSearch->pCache = ListFile_OpenExternal(pSearch->szListFile); - + // Move the search phase to the listfile searching pSearch->IndexLevel1 = 0; pSearch->dwState++; @@ -260,7 +260,7 @@ HANDLE WINAPI CascFindFirstFile( nError = ERROR_INVALID_HANDLE; if(szMask == NULL || pFindData == NULL) nError = ERROR_INVALID_PARAMETER; - + // Init the search structure and search handle if(nError == ERROR_SUCCESS) { @@ -286,7 +286,7 @@ HANDLE WINAPI CascFindFirstFile( FreeSearchHandle(pSearch); pSearch = NULL; } - + return (HANDLE)pSearch; } @@ -306,7 +306,7 @@ bool WINAPI CascFindNextFile( // Perform search return DoStorageSearch(pSearch, pFindData); } - + bool WINAPI CascFindClose(HANDLE hFind) { TCascSearch * pSearch; diff --git a/dep/CascLib/src/CascLib.h b/dep/CascLib/src/CascLib.h index bad32eb2dba..cc22738d63a 100644 --- a/dep/CascLib/src/CascLib.h +++ b/dep/CascLib/src/CascLib.h @@ -16,9 +16,9 @@ #define __CASCLIB_H__ #ifdef _MSC_VER -#pragma warning(disable:4668) // 'XXX' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' +#pragma warning(disable:4668) // 'XXX' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' #pragma warning(disable:4820) // 'XXX' : '2' bytes padding added after data member 'XXX::yyy' -#endif +#endif #include "CascPort.h" @@ -65,20 +65,20 @@ extern "C" { #define CASC_LOCALE_NONE 0x00000000 #define CASC_LOCALE_UNKNOWN1 0x00000001 #define CASC_LOCALE_ENUS 0x00000002 -#define CASC_LOCALE_KOKR 0x00000004 -#define CASC_LOCALE_RESERVED 0x00000008 -#define CASC_LOCALE_FRFR 0x00000010 -#define CASC_LOCALE_DEDE 0x00000020 -#define CASC_LOCALE_ZHCN 0x00000040 -#define CASC_LOCALE_ESES 0x00000080 -#define CASC_LOCALE_ZHTW 0x00000100 -#define CASC_LOCALE_ENGB 0x00000200 -#define CASC_LOCALE_ENCN 0x00000400 -#define CASC_LOCALE_ENTW 0x00000800 -#define CASC_LOCALE_ESMX 0x00001000 -#define CASC_LOCALE_RURU 0x00002000 -#define CASC_LOCALE_PTBR 0x00004000 -#define CASC_LOCALE_ITIT 0x00008000 +#define CASC_LOCALE_KOKR 0x00000004 +#define CASC_LOCALE_RESERVED 0x00000008 +#define CASC_LOCALE_FRFR 0x00000010 +#define CASC_LOCALE_DEDE 0x00000020 +#define CASC_LOCALE_ZHCN 0x00000040 +#define CASC_LOCALE_ESES 0x00000080 +#define CASC_LOCALE_ZHTW 0x00000100 +#define CASC_LOCALE_ENGB 0x00000200 +#define CASC_LOCALE_ENCN 0x00000400 +#define CASC_LOCALE_ENTW 0x00000800 +#define CASC_LOCALE_ESMX 0x00001000 +#define CASC_LOCALE_RURU 0x00002000 +#define CASC_LOCALE_PTBR 0x00004000 +#define CASC_LOCALE_ITIT 0x00008000 #define CASC_LOCALE_PTPT 0x00010000 #define CASC_LOCALE_BIT_ENUS 0x01 @@ -88,13 +88,13 @@ extern "C" { #define CASC_LOCALE_BIT_DEDE 0x05 #define CASC_LOCALE_BIT_ZHCN 0x06 #define CASC_LOCALE_BIT_ESES 0x07 -#define CASC_LOCALE_BIT_ZHTW 0x08 +#define CASC_LOCALE_BIT_ZHTW 0x08 #define CASC_LOCALE_BIT_ENGB 0x09 #define CASC_LOCALE_BIT_ENCN 0x0A #define CASC_LOCALE_BIT_ENTW 0x0B #define CASC_LOCALE_BIT_ESMX 0x0C #define CASC_LOCALE_BIT_RURU 0x0D -#define CASC_LOCALE_BIT_PTBR 0x0E +#define CASC_LOCALE_BIT_PTBR 0x0E #define CASC_LOCALE_BIT_ITIT 0x0F #define CASC_LOCALE_BIT_PTPT 0x10 diff --git a/dep/CascLib/src/CascMndx.h b/dep/CascLib/src/CascMndx.h index d1b6653d4fe..0d588855269 100644 --- a/dep/CascLib/src/CascMndx.h +++ b/dep/CascLib/src/CascMndx.h @@ -59,8 +59,8 @@ typedef union _ARRAY_POINTER } ARRAY_POINTER, *PARRAY_POINTER; // Simple access to various tables within TGenericArray -#define ByteArray ArrayPointer.Bytes -#define CharArray ArrayPointer.Chars +#define ByteArray ArrayPointer.Bytes +#define CharArray ArrayPointer.Chars #define Uint32Array ArrayPointer.Uint32s #define TripletArray ArrayPointer.Triplets #define NameFragArray ArrayPointer.NameFrags @@ -90,7 +90,7 @@ class TByteStream HANDLE hMap; }; -class TGenericArray +class TGenericArray { public: @@ -131,7 +131,7 @@ class TGenericArray bool bIsValidArray; }; -class TBitEntryArray : public TGenericArray +class TBitEntryArray : public TGenericArray { public: @@ -247,16 +247,16 @@ class TNameIndexStruct int LoadFromStream(TByteStream & InStream); int LoadFromStream_Exchange(TByteStream & InStream); - TGenericArray NameFragments; - TSparseArray Struct68; + TGenericArray NameFragments; + TSparseArray Struct68; }; class TStruct10 { public: - + TStruct10(); - + void CopyFrom(TStruct10 & Target); int sub_1956FD0(DWORD dwBitMask); int sub_1957050(DWORD dwBitMask); @@ -289,7 +289,7 @@ class TFileNameDatabasePtr class TFileNameDatabase { public: - + TFileNameDatabase(); void ExchangeWith(TFileNameDatabase & Target); diff --git a/dep/CascLib/src/CascOpenFile.cpp b/dep/CascLib/src/CascOpenFile.cpp index c4c27a3f6a6..f590155144d 100644 --- a/dep/CascLib/src/CascOpenFile.cpp +++ b/dep/CascLib/src/CascOpenFile.cpp @@ -57,7 +57,7 @@ static TCascFile * CreateFileHandle(TCascStorage * hs, PCASC_INDEX_ENTRY pIndexE hf->ArchiveIndex = (DWORD)(FileOffset >> hs->KeyMapping[0].SegmentBits); hf->HeaderOffset = (DWORD)(FileOffset & FileOffsMask); hf->szClassName = "TCascFile"; - + // Copy the file size. Note that for all files except ENCODING, // this is the compressed file size hf->CompressedSize = ConvertBytesToInteger_4_LE(pIndexEntry->FileSizeLE); diff --git a/dep/CascLib/src/CascOpenStorage.cpp b/dep/CascLib/src/CascOpenStorage.cpp index c3d623df9f0..d8508da73bf 100644 --- a/dep/CascLib/src/CascOpenStorage.cpp +++ b/dep/CascLib/src/CascOpenStorage.cpp @@ -18,7 +18,7 @@ // Local structures // Size of one segment in the ENCODING table -// The segment is filled by entries of type +// The segment is filled by entries of type #define CASC_ENCODING_SEGMENT_SIZE 0x1000 typedef struct _BLOCK_SIZE_AND_HASH @@ -116,7 +116,7 @@ static bool IsIndexFileName_V1(const TCHAR * szFileName) static bool IsIndexFileName_V2(const TCHAR * szFileName) { // Check if the name looks like a valid index file - return (_tcslen(szFileName) == 14 && + return (_tcslen(szFileName) == 14 && _tcsspn(szFileName, _T("0123456789aAbBcCdDeEfF")) == 0x0A && _tcsicmp(szFileName + 0x0A, _T(".idx")) == 0); } @@ -354,7 +354,7 @@ static int VerifyAndParseKeyMapping_V1(PCASC_MAPPING_TABLE pKeyMapping, DWORD Ke // Verify the format if(pIndexHeader->field_0 != 0x0005) return ERROR_NOT_SUPPORTED; - if(pIndexHeader->KeyIndex != KeyIndex) + if(pIndexHeader->KeyIndex != KeyIndex) return ERROR_NOT_SUPPORTED; if(pIndexHeader->field_8 == 0) return ERROR_NOT_SUPPORTED; @@ -421,7 +421,7 @@ static int VerifyAndParseKeyMapping_V2(PCASC_MAPPING_TABLE pKeyMapping, DWORD Ke FilePosition = (sizeof(BLOCK_SIZE_AND_HASH) + pSizeAndHash->cbBlockSize + 0x0F) & 0xFFFFFFF0; if((FilePosition + 0x08) > pKeyMapping->cbFileData) return ERROR_BAD_FORMAT; - + // Get the pointer to "size+hash" block pSizeAndHash = (PBLOCK_SIZE_AND_HASH)(pKeyMapping->pbFileData + FilePosition); FilePosition += 0x08; @@ -446,11 +446,11 @@ static int VerifyAndParseKeyMapping_V2(PCASC_MAPPING_TABLE pKeyMapping, DWORD Ke FilePosition = ALIGN_TO_SIZE(FilePosition, 0x1000); if(FilePosition > pKeyMapping->cbFileData) return ERROR_BAD_FORMAT; - + LastPartLength = pKeyMapping->cbFileData - FilePosition; if(LastPartLength < 0x7800) return ERROR_BAD_FORMAT; - + pbLastPart = pKeyMapping->pbFileData + FilePosition; pbLastPartEnd = pbLastPart + ((LastPartLength >> 0x09) << 0x09); @@ -768,7 +768,7 @@ static int LoadEncodingFile(TCascStorage * hs) QUERY_KEY EncodingKey; LPBYTE pbStartOfSegment; LPBYTE pbEncodingFile = NULL; - HANDLE hFile = NULL; + HANDLE hFile = NULL; DWORD cbEncodingFile = 0; DWORD dwNumSegments = 0; DWORD dwSegmentsPos = 0; @@ -856,7 +856,7 @@ static int LoadEncodingFile(TCascStorage * hs) static int LoadRootFile(TCascStorage * hs, DWORD dwLocaleMask) { PDWORD FileSignature; - HANDLE hFile = NULL; + HANDLE hFile = NULL; LPBYTE pbRootFile = NULL; DWORD cbRootFile = 0; int nError = ERROR_SUCCESS; @@ -905,7 +905,7 @@ static int LoadRootFile(TCascStorage * hs, DWORD dwLocaleMask) } } - // Insert entry for the + // Insert entry for the if(nError == ERROR_SUCCESS) { InsertExtraFile(hs, "ENCODING", &hs->EncodingKey); @@ -1010,7 +1010,7 @@ static TCascStorage * FreeCascStorage(TCascStorage * hs) bool WINAPI CascOpenStorage(const TCHAR * szDataPath, DWORD dwLocaleMask, HANDLE * phStorage) { - TCascStorage * hs; + TCascStorage * hs; int nError = ERROR_SUCCESS; // Allocate the storage structure @@ -1074,7 +1074,7 @@ bool WINAPI CascOpenStorage(const TCHAR * szDataPath, DWORD dwLocaleMask, HANDLE bool WINAPI CascGetStorageInfo( HANDLE hStorage, - CASC_STORAGE_INFO_CLASS InfoClass, + CASC_STORAGE_INFO_CLASS InfoClass, void * pvStorageInfo, size_t cbStorageInfo, size_t * pcbLengthNeeded) diff --git a/dep/CascLib/src/CascPort.h b/dep/CascLib/src/CascPort.h index 5d0190e07cc..366aedcc89d 100644 --- a/dep/CascLib/src/CascPort.h +++ b/dep/CascLib/src/CascPort.h @@ -72,7 +72,7 @@ #if (__ppc__ == 1) || (__POWERPC__ == 1) || (_ARCH_PPC == 1) #include #include - #endif + #endif #define PKEXPORT #define __SYS_ZLIB @@ -160,7 +160,7 @@ #define MAX_PATH 1024 #endif - #define WINAPI + #define WINAPI #define FILE_BEGIN SEEK_SET #define FILE_CURRENT SEEK_CUR @@ -198,7 +198,7 @@ #define off64_t off_t #define O_LARGEFILE 0 #endif - + // Platform-specific error codes for UNIX-based platforms #if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) #define ERROR_SUCCESS 0 diff --git a/dep/CascLib/src/CascReadFile.cpp b/dep/CascLib/src/CascReadFile.cpp index 72eb2c4b647..76227449461 100644 --- a/dep/CascLib/src/CascReadFile.cpp +++ b/dep/CascLib/src/CascReadFile.cpp @@ -146,7 +146,7 @@ static int EnsureHeaderAreaIsLoaded(TCascFile * hf) hs->dwFileBeginDelta = (FileSignature == BLTE_HEADER_SIGNATURE) ? BLTE_HEADER_DELTA : 0; } - + // If the file size is not loaded yet, do it if(hf->FrameCount == 0) { @@ -225,7 +225,7 @@ static int EnsureFrameHeadersLoaded(TCascFile * hf) { // Offset of the first frame is right after the file frames hf->FramesOffset = hf->HeaderOffset + sizeof(DWORD) + sizeof(DWORD); - + hf->pFrames[0].FrameArchiveOffset = hf->FramesOffset; hf->pFrames[0].FrameFileOffset = 0; hf->pFrames[0].CompressedSize = hf->CompressedSize; @@ -288,12 +288,12 @@ static int ProcessFileFrame( // Perform the loop for(;;) { - // Set the output buffer. + // Set the output buffer. // Even operations: extract to temporary buffer // Odd operations: extract to output buffer pbWorkBuffer = (dwStepCount & 0x01) ? pbOutBuffer : pbTempBuffer; cbWorkBuffer = (dwStepCount & 0x01) ? cbOutBuffer : cbTempBuffer; - + // Perform the operation specific to the operation ID switch(pbInBuffer[0]) { @@ -530,7 +530,7 @@ bool WINAPI CascReadFile(HANDLE hFile, void * pvBuffer, DWORD dwBytesToRead, PDW { if(hf->pbFileCache != NULL) CASC_FREE(hf->pbFileCache); - + hf->pbFileCache = CASC_ALLOC(BYTE, pFrame->FrameSize); hf->cbFileCache = pFrame->FrameSize; } @@ -546,7 +546,7 @@ bool WINAPI CascReadFile(HANDLE hFile, void * pvBuffer, DWORD dwBytesToRead, PDW // Load the raw file data to memory FileOffset = pFrame->FrameArchiveOffset; bReadResult = FileStream_Read(hf->pStream, &FileOffset, pbFrameData, pFrame->CompressedSize); - + // Note: The raw file data size could be less than expected // Happened in WoW build 19342 with the ROOT file. MD5 in the frame header // is zeroed, which means it should not be checked diff --git a/dep/CascLib/src/CascRootFile_Diablo3.cpp b/dep/CascLib/src/CascRootFile_Diablo3.cpp index 98a42cc3226..c515567af5f 100644 --- a/dep/CascLib/src/CascRootFile_Diablo3.cpp +++ b/dep/CascLib/src/CascRootFile_Diablo3.cpp @@ -137,7 +137,7 @@ typedef struct _CASC_FILE_ENTRY DWORD NameOffset; // Offset of the name (in name's dynamic array) USHORT SubIndex; // File\SubFile index BYTE AssetIndex; // Asset index (aka directory index) - BYTE EntryFlags; // Entry flags + BYTE EntryFlags; // Entry flags } CASC_FILE_ENTRY, *PCASC_FILE_ENTRY; //----------------------------------------------------------------------------- @@ -313,9 +313,9 @@ static size_t CreateShortName( // SoundBank\Angel.sbk // SoundBank\Angel\0000.fsb // SoundBank\Angel\0002.fsb - // + // // We use the Base\Data_D3\PC\Misc\Packages.dat for real file extensions, where possible - // + // if(pPackageMap != NULL) { // Retrieve the asset name @@ -459,7 +459,7 @@ static int InsertFileEntry( } static int ParseDirEntries_FileId1( - TRootHandler_Diablo3 * pRootHandler, + TRootHandler_Diablo3 * pRootHandler, LPBYTE pbFileEntries, DWORD dwFileEntries, DWORD dwRootDirIndex) @@ -491,7 +491,7 @@ static int ParseDirEntries_FileId1( } static int ParseDirEntries_FileId2( - TRootHandler_Diablo3 * pRootHandler, + TRootHandler_Diablo3 * pRootHandler, LPBYTE pbFileEntries, DWORD dwFileEntries, DWORD dwRootDirIndex) @@ -523,13 +523,13 @@ static int ParseDirEntries_FileId2( } static int ParseDirEntries_Named( - TRootHandler_Diablo3 * pRootHandler, + TRootHandler_Diablo3 * pRootHandler, LPBYTE pbFileEntries, LPBYTE pbFileEnd, DWORD dwFileEntries, DWORD dwRootDirIndex) { - char szFileName[MAX_PATH+1]; + char szFileName[MAX_PATH+1]; char * szNamePtr = szFileName; DWORD cbFileEntry; int nError = ERROR_SUCCESS; @@ -591,7 +591,7 @@ static int ParseDirEntries_Named( static void ResolveFullFileNames( TRootHandler_Diablo3 * pRootHandler, PDIABLO3_CORE_TOC_ENTRY pCoreTocEntries, - PCASC_MAP pPackageMap, + PCASC_MAP pPackageMap, LPBYTE pbCoreTocFile, DWORD dwFileIndexes) { @@ -703,7 +703,7 @@ static int ParseDirectoryHeader( // Structure of a Diablo3 directory file // 1) Signature (4 bytes) // 2) Number of DIABLO3_FILEID1_ENTRY entries (4 bytes) - // 3) Array of DIABLO3_FILEID1_ENTRY entries + // 3) Array of DIABLO3_FILEID1_ENTRY entries // 4) Number of DIABLO3_FILEID2_ENTRY entries (4 bytes) // 5) Array of DIABLO3_FILEID2_ENTRY entries // 6) Number of DIABLO3_NAMED_ENTRY entries (4 bytes) diff --git a/dep/CascLib/src/CascRootFile_Mndx.cpp b/dep/CascLib/src/CascRootFile_Mndx.cpp index bf17290a0af..0f7e3c42c64 100644 --- a/dep/CascLib/src/CascRootFile_Mndx.cpp +++ b/dep/CascLib/src/CascRootFile_Mndx.cpp @@ -41,7 +41,7 @@ typedef struct _FILE_MAR_INFO typedef struct _CASC_MNDX_INFO { - BYTE RootFileName[MD5_HASH_SIZE]; // Name (aka MD5) of the root file + BYTE RootFileName[MD5_HASH_SIZE]; // Name (aka MD5) of the root file DWORD HeaderVersion; // Must be <= 2 DWORD FormatVersion; DWORD field_1C; @@ -101,7 +101,7 @@ void TestMndxRootFile(PCASC_MNDX_INFO pMndxInfo); //----------------------------------------------------------------------------- // Local variables -unsigned char table_1BA1818[0x800] = +unsigned char table_1BA1818[0x800] = { 0x07, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x04, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, @@ -242,7 +242,7 @@ DWORD GetNumberOfSetBits(DWORD Value32) Value32 = ((Value32 >> 1) & 0x55555555) + (Value32 & 0x55555555); Value32 = ((Value32 >> 2) & 0x33333333) + (Value32 & 0x33333333); Value32 = ((Value32 >> 4) & 0x0F0F0F0F) + (Value32 & 0x0F0F0F0F); - + return (Value32 * 0x01010101); } @@ -313,40 +313,40 @@ int TMndxFindResult::SetSearchPath( if(pStruct40 != NULL) pStruct40->SearchPhase = CASC_SEARCH_INITIALIZING; - + szSearchMask = szNewSearchMask; cchSearchMask = cchNewSearchMask; return ERROR_SUCCESS; } //----------------------------------------------------------------------------- -// TByteStream functions - -// HOTS: 01959990 -TByteStream::TByteStream() -{ - pbByteData = NULL; - pvMappedFile = NULL; - cbByteData = 0; - field_C = 0; - hFile = 0; - hMap = 0; -} - -// HOTS: 19599F0 +// TByteStream functions + +// HOTS: 01959990 +TByteStream::TByteStream() +{ + pbByteData = NULL; + pvMappedFile = NULL; + cbByteData = 0; + field_C = 0; + hFile = 0; + hMap = 0; +} + +// HOTS: 19599F0 void TByteStream::ExchangeWith(TByteStream & Target) -{ - TByteStream WorkBuff; - - WorkBuff = *this; - *this = Target; - Target = WorkBuff; -} - -// HOTS: 19599F0 +{ + TByteStream WorkBuff; + + WorkBuff = *this; + *this = Target; + Target = WorkBuff; +} + +// HOTS: 19599F0 int TByteStream::GetBytes(DWORD cbByteCount, PARRAY_POINTER PtrArray) -{ - if(cbByteData < cbByteCount) +{ + if(cbByteData < cbByteCount) return ERROR_BAD_FORMAT; // Give the buffer to the caller @@ -453,7 +453,7 @@ int TByteStream::GetValue_ItemCount(DWORD & NumberOfBytes, DWORD & ItemCount, DW ByteCount = Pointer.Int64Ptr[0]; if(ByteCount > 0xFFFFFFFF || (ByteCount % ItemSize) != 0) return ERROR_BAD_FORMAT; - + // Give the result to the caller NumberOfBytes = (DWORD)ByteCount; ItemCount = (DWORD)(ByteCount / ItemSize); @@ -619,7 +619,7 @@ void TGenericArray::sub_19583A0(DWORD NewItemCount) if(NewItemCount > MaxItemCount) { DWORD NewMaxItemCount = NewItemCount; - + if(MaxItemCount > (NewItemCount / 2)) { if(MaxItemCount <= (CASC_MAX_ENTRIES(PATH_STOP) / 2)) @@ -702,7 +702,7 @@ int TGenericArray::LoadByteArray(TByteStream & InStream) nError = InStream.GetArray_BYTES(&ArrayPointer, ItemCount); if(nError != ERROR_SUCCESS) return nError; - + nError = InStream.SkipBytes((0 - (DWORD)NumberOfBytes) & 0x07); if(nError != ERROR_SUCCESS) return nError; @@ -746,7 +746,7 @@ int TGenericArray::LoadStrings(TByteStream & InStream) nError = InStream.GetArray_BYTES(&ArrayPointer, ItemCount); if(nError != ERROR_SUCCESS) return nError; - + nError = InStream.SkipBytes((0 - (DWORD)NumberOfBytes) & 0x07); if(nError != ERROR_SUCCESS) return nError; @@ -854,14 +854,14 @@ int TBitEntryArray::LoadFromStream(TByteStream & InStream) ULONGLONG Value = 0; int nError; - nError = LoadDwordsArray_Copy(InStream); + nError = LoadDwordsArray_Copy(InStream); if(nError != ERROR_SUCCESS) return nError; nError = InStream.GetBytes(sizeof(DWORD), &Pointer); if(nError != ERROR_SUCCESS) return nError; - + BitsPerEntry = Pointer.Uint32s[0]; if(BitsPerEntry > 0x20) return ERROR_BAD_FORMAT; @@ -913,13 +913,13 @@ void TStruct40::InitSearchBuffers() DWORD NewMaxItemCount; array_00.ItemCount = 0; - + // HOTS: 19586BD if(array_00.MaxItemCount < 0x40) { // HOTS: 19586C2 NewMaxItemCount = 0x40; - + if(array_00.MaxItemCount > 0x20) { if(array_00.MaxItemCount <= 0x7FFFFFFF) @@ -948,7 +948,7 @@ void TStruct40::InitSearchBuffers() else NewMaxItemCount = CASC_MAX_ENTRIES(PATH_STOP); } - + // HOTS: 195870B PathStops.SetMaxItems_PATH_STOP(NewMaxItemCount); } @@ -997,7 +997,7 @@ int TSparseArray::LoadFromStream(TByteStream & InStream) if(nError != ERROR_SUCCESS) return nError; ValidItemCount = Pointer.Uint32s[0]; - + if(ValidItemCount > TotalItemCount) return ERROR_FILE_CORRUPT; @@ -1025,7 +1025,7 @@ int TSparseArray::LoadFromStream_Exchange(TByteStream & InStream) nError = NewStruct68.LoadFromStream(InStream); if(nError != ERROR_SUCCESS) return nError; - + ExchangeWith(NewStruct68); return ERROR_SUCCESS; } @@ -1038,7 +1038,7 @@ DWORD TSparseArray::GetItemValue(DWORD ItemIndex) DWORD BaseValue; DWORD BitMask; - // + // // Divide the low-8-bits index to four parts: // // |-----------------------|---|------------| @@ -1057,7 +1057,7 @@ DWORD TSparseArray::GetItemValue(DWORD ItemIndex) // // C (32 bits): Number of bits to be checked (up to 0x3F bits). // Number of set bits is then added to the values obtained from A and B - + // Upper 23 bits contain index to the table pTriplet = BaseValues.TripletArray + (ItemIndex >> 0x09); BaseValue = pTriplet->BaseValue; @@ -1169,7 +1169,7 @@ bool TNameIndexStruct::CheckNameFragment(TMndxFindResult * pStruct1C, DWORD dwFr if(dwFragOffs >= pStruct1C->cchSearchMask) return false; } - + return false; } } @@ -1407,7 +1407,7 @@ int TStruct10::sub_19572E0(DWORD dwBitMask) nError = sub_1956FD0(dwBitMask); if(nError != ERROR_SUCCESS) - return nError; + return nError; dwSubMask = dwBitMask & 0xF000; if(dwSubMask == 0 || dwSubMask == 0x1000) @@ -1496,7 +1496,7 @@ DWORD TFileNameDatabase::sub_1959CB0(DWORD dwItemIndex) eax = Struct68_00.ArrayDwords_38.Uint32Array[dwKeyShifted] >> 9; esi = (Struct68_00.ArrayDwords_38.Uint32Array[dwKeyShifted + 1] + 0x1FF) >> 9; dwItemIndex = esi; - + if((eax + 0x0A) >= esi) { // HOTS: 1959CF7 @@ -1638,7 +1638,7 @@ DWORD TFileNameDatabase::sub_1959CB0(DWORD dwItemIndex) eax = GetNumberOfSetBits(ecx); } - // HOTS: 1959eea + // HOTS: 1959eea // ESI gets the number of set bits in the lower 16 bits of ECX esi = (eax >> 0x08) & 0xFF; edi = edi << 0x05; @@ -1699,7 +1699,7 @@ DWORD TFileNameDatabase::sub_1959F50(DWORD arg_0) ItemArray = Struct68_00.ArrayDwords_50.Uint32Array + eax; eax = (ItemArray[0] >> 0x09); edi = (ItemArray[1] + 0x1FF) >> 0x09; - + if((eax + 0x0A) > edi) { // HOTS: 01959F94 @@ -1883,7 +1883,7 @@ bool TFileNameDatabase::CheckNextPathFragment(TMndxFindResult * pStruct1C) // Calculate index of the next name fragment in the name fragment table NameFragIndex = ((pStruct40->ItemIndex << 0x05) ^ pStruct40->ItemIndex ^ pbPathName[pStruct40->CharIndex]) & NameFragIndexMask; - + // Does the hash value match? if(NameFragTable.NameFragArray[NameFragIndex].ItemIndex == pStruct40->ItemIndex) { @@ -1931,7 +1931,7 @@ bool TFileNameDatabase::CheckNextPathFragment(TMndxFindResult * pStruct1C) { // HOTS: 1957A41 // Check if the low 8 bits if the fragment offset contain a single character - // or an offset to a name fragment + // or an offset to a name fragment if(Struct68_D0.IsItemPresent(pStruct40->ItemIndex)) { if(HiBitsIndex == 0xFFFFFFFF) @@ -1947,7 +1947,7 @@ bool TFileNameDatabase::CheckNextPathFragment(TMndxFindResult * pStruct1C) // HOTS: 1957A83 SaveCharIndex = pStruct40->CharIndex; - + // Get the name fragment offset as combined value from lower 8 bits and upper bits FragOffs = GetNameFragmentOffsetEx(pStruct40->ItemIndex, HiBitsIndex); @@ -2031,7 +2031,7 @@ bool TFileNameDatabase::sub_1957B80(TMndxFindResult * pStruct1C, DWORD arg_4) // HOTS: 1957C05 edi = pNameEntry->ItemIndex; - if(edi == 0) + if(edi == 0) return true; if(pStruct40->CharIndex >= pStruct1C->cchSearchMask) @@ -2231,7 +2231,7 @@ bool TFileNameDatabase::sub_1959010(TMndxFindResult * pStruct1C, DWORD arg_4) arg_4 = 0xFFFFFFFF - arg_4 + sub_1959F50(arg_4); } - + // HOTS: 19592D5 if(pStruct40->CharIndex >= pStruct1C->cchSearchMask) break; @@ -2295,7 +2295,7 @@ bool TFileNameDatabase::sub_1959460(TMndxFindResult * pStruct1C) { PPATH_STOP pLastStop; DWORD CollisionIndex; - + pLastStop = pStruct40->PathStops.FirstValid.PathStopPtr + pStruct40->PathStops.ItemCount - 1; CollisionIndex = sub_1959CB0(pLastStop->ItemIndex) + 1; @@ -2384,7 +2384,7 @@ bool TFileNameDatabase::sub_1959460(TMndxFindResult * pStruct1C) pPathStop = pStruct40->PathStops.FirstValid.PathStopPtr + pStruct40->ItemCount - 2; edi = pPathStop->field_8; - + if(edi > pStruct40->array_00.MaxItemCount) { // HOTS: 1959717 @@ -2482,7 +2482,7 @@ bool TFileNameDatabase::sub_1958B00(TMndxFindResult * pStruct1C) // HOTS: 1958C62 SaveCharIndex = pStruct40->CharIndex; - + FragOffs = GetNameFragmentOffsetEx(pStruct40->ItemIndex, var_4); if(NextDB.pDB != NULL) { @@ -2579,7 +2579,7 @@ int TFileNameDatabase::LoadFromStream(TByteStream & InStream) nError = FrgmDist_HiBits.LoadFromStream_Exchange(InStream); if(nError != ERROR_SUCCESS) return nError; - + // HOTS: 019597F5 nError = IndexStruct_174.LoadFromStream_Exchange(InStream); if(nError != ERROR_SUCCESS) @@ -2596,7 +2596,7 @@ int TFileNameDatabase::LoadFromStream(TByteStream & InStream) if(NextDB.pDB == NULL) return ERROR_NOT_ENOUGH_MEMORY; - + nError = NextDB.pDB->LoadFromStream(InStream); if(nError != ERROR_SUCCESS) return nError; @@ -2632,7 +2632,7 @@ int TFileNameDatabase::LoadFromStream_Exchange(TByteStream & InStream) nError = InStream.GetBytes(sizeof(DWORD), &Pointer); if(nError != ERROR_SUCCESS) return nError; - + // Verify the signature dwSignature = Pointer.Uint32s[0]; if(dwSignature != CASC_MAR_SIGNATURE) @@ -2746,7 +2746,7 @@ int TFileNameDatabasePtr::SetDatabase(TFileNameDatabase * pNewDB) if(pDB != NULL) delete pDB; pDB = pNewDB; - return ERROR_SUCCESS; + return ERROR_SUCCESS; } //----------------------------------------------------------------------------- @@ -2824,7 +2824,7 @@ static PCASC_MNDX_PACKAGES InsertToPackageList( nNewNameEntries = nNewNameEntries + CASC_PACKAGES_DELTA; if((pPackages->NameBufferUsed + cchFileName + 1) > nNewNameBufferMax) nNewNameBufferMax = nNewNameBufferMax + 0x1000; - + // If any of the two variables overflowed, we need to reallocate the name list if(nNewNameEntries > pPackages->NameEntries || nNewNameBufferMax > pPackages->NameBufferMax) { @@ -3015,7 +3015,7 @@ static LPBYTE FillFindData(TRootHandler_MNDX * pRootHandler, TCascSearch * pSear // Fill the file name memcpy(pSearch->szFileName, pStruct1C->szFoundPath, pStruct1C->cchFoundPath); pSearch->szFileName[pStruct1C->cchFoundPath] = 0; - + // Fill the file size pPackage = FindMndxPackage(pRootHandler, pSearch->szFileName); if(pPackage == NULL) @@ -3051,7 +3051,7 @@ static LPBYTE MndxHandler_Search(TRootHandler_MNDX * pRootHandler, TCascSearch * PCASC_MNDX_INFO pMndxInfo = &pRootHandler->MndxInfo; PMAR_FILE pMarFile = pMndxInfo->pMarFile3; bool bFindResult = false; - + // If the first time, allocate the structure for the search result if(pSearch->pRootContext == NULL) { @@ -3140,7 +3140,7 @@ int RootHandler_CreateMNDX(TCascStorage * hs, LPBYTE pbRootFile, DWORD cbRootFil { PFILE_MNDX_HEADER pMndxHeader = (PFILE_MNDX_HEADER)pbRootFile; PCASC_MNDX_INFO pMndxInfo; - TRootHandler_MNDX * pRootHandler; + TRootHandler_MNDX * pRootHandler; FILE_MAR_INFO MarInfo; PMAR_FILE pMarFile; LPBYTE pbRootFileEnd = pbRootFile + cbRootFile; @@ -3520,7 +3520,7 @@ static void TestMndxFunctions(PMAR_FILE pMarFile) { DWORD dwResult1 = sub_19573D0_x86(pDB, arg_0, arg_4); DWORD dwResult2 = pDB->GetNameFragmentOffsetEx(arg_0, arg_4); - + assert(dwResult1 == dwResult2); } } @@ -3530,7 +3530,7 @@ static void TestMndxFunctions(PMAR_FILE pMarFile) { DWORD dwResult1 = GetItemValue_x86(&pDB->Struct68_D0, i); DWORD dwResult2 = pDB->Struct68_D0.GetItemValue(i); - + assert(dwResult1 == dwResult2); } @@ -3539,7 +3539,7 @@ static void TestMndxFunctions(PMAR_FILE pMarFile) { DWORD dwResult1 = sub_1959CB0_x86(pDB, i); DWORD dwResult2 = pDB->sub_1959CB0(i); - + assert(dwResult1 == dwResult2); } @@ -3548,7 +3548,7 @@ static void TestMndxFunctions(PMAR_FILE pMarFile) { DWORD dwResult1 = sub_1959F50_x86(pDB, i); DWORD dwResult2 = pDB->sub_1959F50(i); - + assert(dwResult1 == dwResult2); } } @@ -3568,7 +3568,7 @@ void TestMndxRootFile(PCASC_MNDX_INFO pMndxInfo) // Find a "mods" in the package array TestFindPackage(pMndxInfo->pMarFile3, "mods/heroes.stormmod/base.stormassets/assets/textures/glow_green2.dds"); TestMarFile(pMndxInfo->pMarFile3, "mods/heroes.stormmod/base.stormassets/assets/textures/glow_green2.dds", 69); - + // Search the package MAR file aith a path shorter than a fragment TestFileSearch(pMndxInfo->pMarFile1, "mods/heroes.s"); diff --git a/dep/CascLib/src/CascRootFile_Ovr.cpp b/dep/CascLib/src/CascRootFile_Ovr.cpp index 205353c0120..dbb7620b769 100644 --- a/dep/CascLib/src/CascRootFile_Ovr.cpp +++ b/dep/CascLib/src/CascRootFile_Ovr.cpp @@ -140,6 +140,7 @@ int RootHandler_CreateOverwatch(TCascStorage * hs, LPBYTE pbRootFile, DWORD cbRo char szOneLine[0x200]; char szFileName[MAX_PATH+1]; DWORD dwFileCountMax = hs->pEncodingMap->TableSize; + int nFileNameIndex; int nError = ERROR_SUCCESS; // Allocate the root handler object @@ -177,20 +178,26 @@ int RootHandler_CreateOverwatch(TCascStorage * hs, LPBYTE pbRootFile, DWORD cbRo pTextFile = ListFile_FromBuffer(pbRootFile, cbRootFile); if(pTextFile != NULL) { - // Skip the first line, containing "#MD5|CHUNK_ID|FILENAME|INSTALLPATH" - ListFile_GetNextLine(pTextFile, szOneLine, _maxchars(szOneLine)); - - // Parse the next lines - while((nLength = ListFile_GetNextLine(pTextFile, szOneLine, _maxchars(szOneLine))) > 0) + // Get the initial line, containing variable names + nLength = ListFile_GetNextLine(pTextFile, szOneLine, _maxchars(szOneLine)); + + // Determine the index of the "FILENAME" variable + nError = GetRootVariableIndex(szOneLine, szOneLine + nLength, "FILENAME", &nFileNameIndex); + if(nError == ERROR_SUCCESS) { - // Parse the line - nError = ParseRootFileLine(szOneLine, szOneLine + nLength, &EncodingKey, szFileName, _maxchars(szFileName)); - if(nError == ERROR_SUCCESS) + // Parse the next lines + while((nLength = ListFile_GetNextLine(pTextFile, szOneLine, _maxchars(szOneLine))) > 0) { - InsertFileEntry(pRootHandler, szFileName, KeyBuffer.Value); + // Parse the line + nError = ParseRootFileLine(szOneLine, szOneLine + nLength, nFileNameIndex, &EncodingKey, szFileName, _maxchars(szFileName)); + if(nError == ERROR_SUCCESS) + { + InsertFileEntry(pRootHandler, szFileName, KeyBuffer.Value); + } } } + // Free the listfile ListFile_Free(pTextFile); } diff --git a/dep/CascLib/src/CascRootFile_WoW6.cpp b/dep/CascLib/src/CascRootFile_WoW6.cpp index 0c631f82b00..ee915986114 100644 --- a/dep/CascLib/src/CascRootFile_WoW6.cpp +++ b/dep/CascLib/src/CascRootFile_WoW6.cpp @@ -313,7 +313,7 @@ static int ParseWowRootFile( // Implementation of WoW6 root file static int WowHandler_Insert( - TRootHandler_WoW6 * pRootHandler, + TRootHandler_WoW6 * pRootHandler, const char * szFileName, LPBYTE pbEncodingKey) { @@ -448,7 +448,7 @@ static void TRootHandlerWoW6_Dump( // Dump the locale block dump_print(dc, "Flags: %08X Locales: %08X NumberOfFiles: %u\n" "=========================================================\n", - BlockInfo.pLocaleBlockHdr->Flags, + BlockInfo.pLocaleBlockHdr->Flags, BlockInfo.pLocaleBlockHdr->Locales, BlockInfo.pLocaleBlockHdr->NumberOfFiles); @@ -476,7 +476,7 @@ static void TRootHandlerWoW6_Dump( // Put extra newline dump_print(dc, "\n"); } - + ListFile_FreeMap(pListMap); } #endif diff --git a/dep/CascLib/src/common/Common.cpp b/dep/CascLib/src/common/Common.cpp index 9c0f56dc9ba..fe59d800bdc 100644 --- a/dep/CascLib/src/common/Common.cpp +++ b/dep/CascLib/src/common/Common.cpp @@ -17,50 +17,50 @@ // Converts ASCII characters to lowercase // Converts backslash (0x5C) to normal slash (0x2F) -unsigned char AsciiToLowerTable_Slash[256] = +unsigned char AsciiToLowerTable_Slash[256] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x5B, 0x2F, 0x5D, 0x5E, 0x5F, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, + 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x5B, 0x2F, 0x5D, 0x5E, 0x5F, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, + 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, + 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, + 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF }; // Converts ASCII characters to uppercase // Converts slash (0x2F) to backslash (0x5C) -unsigned char AsciiToUpperTable_BkSlash[256] = +unsigned char AsciiToUpperTable_BkSlash[256] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x5C, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, - 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, - 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, - 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, - 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x5C, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, + 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, + 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, + 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, + 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF }; unsigned char IntToHexChar[] = "0123456789abcdef"; - + //----------------------------------------------------------------------------- // GetLastError/SetLastError support for non-Windows platform @@ -171,7 +171,7 @@ TCHAR * CombinePath(const TCHAR * szDirectory, const TCHAR * szSubDir) while(nLength1 > 0 && szDirectory[nLength1 - 1] == _T(PATH_SEPARATOR)) nLength1--; } - + if(szSubDir != NULL) { // Cut all leading backslashes @@ -484,7 +484,7 @@ bool CheckWildCard(const char * szString, const char * szWildCard) bool IsValidMD5(LPBYTE pbMd5) { BYTE BitSummary = 0; - + // The MD5 is considered invalid of it is zeroed BitSummary |= pbMd5[0x00] | pbMd5[0x01] | pbMd5[0x02] | pbMd5[0x03] | pbMd5[0x04] | pbMd5[0x05] | pbMd5[0x06] | pbMd5[0x07]; BitSummary |= pbMd5[0x08] | pbMd5[0x09] | pbMd5[0x0A] | pbMd5[0x0B] | pbMd5[0x0C] | pbMd5[0x0D] | pbMd5[0x0E] | pbMd5[0x0F]; diff --git a/dep/CascLib/src/common/Directory.cpp b/dep/CascLib/src/common/Directory.cpp index cd02db19be3..c4091095859 100644 --- a/dep/CascLib/src/common/Directory.cpp +++ b/dep/CascLib/src/common/Directory.cpp @@ -26,7 +26,7 @@ bool DirectoryExists(const TCHAR * szDirectory) #else // PLATFORM_WINDOWS DIR * dir = opendir(szDirectory); - + if(dir != NULL) { closedir(dir); @@ -70,7 +70,7 @@ int ScanIndexDirectory( pfnOnFileFound(wf.cFileName, MainIndexes, OldIndexArray, pvContext); } } - + // Close the search handle FindClose(hFind); } @@ -81,7 +81,7 @@ int ScanIndexDirectory( struct dirent * dir_entry; DIR * dir; - + dir = opendir(szIndexPath); if(dir != NULL) { @@ -90,9 +90,9 @@ int ScanIndexDirectory( if(dir_entry->d_type != DT_DIR) { pfnOnFileFound(dir_entry->d_name, MainIndexes, OldIndexArray, pvContext); - } + } } - + closedir(dir); } diff --git a/dep/CascLib/src/common/FileStream.cpp b/dep/CascLib/src/common/FileStream.cpp index ef9cc55d7ea..ccd3a65318d 100644 --- a/dep/CascLib/src/common/FileStream.cpp +++ b/dep/CascLib/src/common/FileStream.cpp @@ -70,14 +70,14 @@ static bool BaseFile_Create(TFileStream * pStream) #if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) { intptr_t handle; - + handle = open(pStream->szFileName, O_RDWR | O_CREAT | O_TRUNC | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if(handle == -1) { SetLastError(errno); return false; } - + pStream->Base.File.hFile = (HANDLE)handle; } #endif @@ -205,7 +205,7 @@ static bool BaseFile_Read( SetLastError(errno); return false; } - + dwBytesRead = (DWORD)(size_t)bytes_read; } } @@ -274,7 +274,7 @@ static bool BaseFile_Write(TFileStream * pStream, ULONGLONG * pByteOffset, const SetLastError(errno); return false; } - + dwBytesWritten = (DWORD)(size_t)bytes_written; } #endif @@ -321,7 +321,7 @@ static bool BaseFile_Resize(TFileStream * pStream, ULONGLONG NewFileSize) return bResult; } #endif - + #if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) { if(ftruncate64((intptr_t)pStream->Base.File.hFile, (off64_t)NewFileSize) == -1) @@ -329,7 +329,7 @@ static bool BaseFile_Resize(TFileStream * pStream, ULONGLONG NewFileSize) SetLastError(errno); return false; } - + pStream->Base.File.FileSize = NewFileSize; return true; } @@ -373,7 +373,7 @@ static bool BaseFile_Replace(TFileStream * pStream, TFileStream * pNewStream) SetLastError(errno); return false; } - + return true; #endif } @@ -713,7 +713,7 @@ static bool BaseHttp_Read( // Add range request to the HTTP headers // http://www.clevercomponents.com/articles/article015/resuming.asp _stprintf(szRangeRequest, _T("Range: bytes=%u-%u"), (unsigned int)dwStartOffset, (unsigned int)dwEndOffset); - HttpAddRequestHeaders(hRequest, szRangeRequest, 0xFFFFFFFF, HTTP_ADDREQ_FLAG_ADD_IF_NEW); + HttpAddRequestHeaders(hRequest, szRangeRequest, 0xFFFFFFFF, HTTP_ADDREQ_FLAG_ADD_IF_NEW); // Send the request to the server if(HttpSendRequest(hRequest, NULL, 0, NULL, 0)) @@ -966,7 +966,7 @@ static void BlockStream_Close(TBlockStream * pStream) static STREAM_INIT StreamBaseInit[4] = { BaseFile_Init, - BaseMap_Init, + BaseMap_Init, BaseHttp_Init, BaseNone_Init }; @@ -1005,7 +1005,7 @@ static TFileStream * AllocateFileStream( SetLastError(ERROR_INVALID_PARAMETER); return NULL; } - + // Open the master file pMaster = FileStream_OpenFile(szNextFile + 1, STREAM_FLAG_READ_ONLY); } @@ -1063,7 +1063,7 @@ static DWORD FlatStream_CheckFile(TBlockStream * pStream) static bool FlatStream_LoadBitmap(TBlockStream * pStream) { FILE_BITMAP_FOOTER Footer; - ULONGLONG ByteOffset; + ULONGLONG ByteOffset; LPBYTE FileBitmap; DWORD BlockCount; DWORD BitmapSize; @@ -1171,7 +1171,7 @@ static bool FlatStream_BlockCheck( // Sanity checks assert((BlockOffset & (pStream->BlockSize - 1)) == 0); assert(FileBitmap != NULL); - + // Calculate the index of the block BlockIndex = (DWORD)(BlockOffset / pStream->BlockSize); BitMask = (BYTE)(1 << (BlockIndex & 0x07)); @@ -1232,7 +1232,7 @@ static void FlatStream_Close(TBlockStream * pStream) { // Write the file bitmap pStream->BaseWrite(pStream, &pStream->StreamSize, pStream->FileBitmap, pStream->BitmapSize); - + // Prepare and write the file footer Footer.Signature = ID_FILE_BITMAP_FOOTER; Footer.Version = 3; @@ -1327,7 +1327,7 @@ static bool FlatStream_CreateMirror(TBlockStream * pStream) static TFileStream * FlatStream_Open(const TCHAR * szFileName, DWORD dwStreamFlags) { - TBlockStream * pStream; + TBlockStream * pStream; ULONGLONG ByteOffset = 0; // Create new empty stream @@ -1551,7 +1551,7 @@ static bool PartStream_BlockCheck( // Sanity checks assert((BlockOffset & (pStream->BlockSize - 1)) == 0); assert(pStream->FileBitmap != NULL); - + // Calculate the block map entry FileBitmap = (PPART_FILE_MAP_ENTRY)pStream->FileBitmap + (BlockOffset / pStream->BlockSize); @@ -1647,7 +1647,7 @@ static void PartStream_Close(TBlockStream * pStream) PartHeader.FileSizeHi = (DWORD)(pStream->StreamSize >> 0x20); PartHeader.FileSizeLo = (DWORD)(pStream->StreamSize & 0xFFFFFFFF); PartHeader.BlockSize = pStream->BlockSize; - + // Make sure that the header is properly BSWAPed BSWAP_ARRAY32_UNSIGNED(&PartHeader, sizeof(PART_FILE_HEADER)); sprintf(PartHeader.GameBuildNumber, "%u", (unsigned int)pStream->BuildNumber); @@ -1812,7 +1812,7 @@ static const char * AuthCodeArray[] = "S48B6CDTN5XEQAKQDJNDLJBJ73FDFM3U", // SC2 Heart of the Swarm-all : "expand 32-byte kQAKQ0000FM3UN5XE000073FD6CDT0000LJBJS48B0000DJND" // Diablo III: Agent.exe (1.0.0.954) - // Address of decryption routine: 00502b00 + // Address of decryption routine: 00502b00 // Pointer to decryptor object: ECX // Pointer to key: ECX+0x5C // Authentication code URL: http://dist.blizzard.com/mediakey/d3-authenticationcode-enGB.txt @@ -1918,7 +1918,7 @@ static void DecryptFileChunk( KeyShuffled[0x04] = KeyMirror[0x0D]; KeyShuffled[0x01] = KeyMirror[0x0E]; KeyShuffled[0x00] = KeyMirror[0x0F]; - + // Shuffle the key - part 2 for(DWORD i = 0; i < RoundCount; i += 2) { @@ -2009,7 +2009,7 @@ static bool EncrStream_DetectFileKey(TEncryptedStream * pStream) // Prepare they decryption key from game serial number CreateKeyFromAuthCode(pStream->Key, AuthCodeArray[i]); - // Try to decrypt with the given key + // Try to decrypt with the given key memcpy(FileHeader, EncryptedHeader, ENCRYPTED_CHUNK_SIZE); DecryptFileChunk((PDWORD)FileHeader, pStream->Key, ByteOffset, ENCRYPTED_CHUNK_SIZE); @@ -2264,8 +2264,8 @@ static TFileStream * Block4Stream_Open(const TCHAR * szFileName, DWORD dwStreamF assert(FileSize <= BLOCK4_MAX_FSIZE); RemainderBlock = FileSize % (BLOCK4_BLOCK_SIZE + BLOCK4_HASH_SIZE); BlockCount = FileSize / (BLOCK4_BLOCK_SIZE + BLOCK4_HASH_SIZE); - - // Increment the stream size and number of blocks + + // Increment the stream size and number of blocks pStream->StreamSize += (BlockCount * BLOCK4_BLOCK_SIZE); pStream->BlockCount += (DWORD)BlockCount; @@ -2482,7 +2482,7 @@ size_t FileStream_Prefix(const TCHAR * szFileName, DWORD * pdwProvider) dwProvider |= BASE_PROVIDER_MAP; nPrefixLength2 = 4; } - + else if(!_tcsnicmp(szFileName+nPrefixLength1, _T("http:"), 5)) { dwProvider |= BASE_PROVIDER_HTTP; @@ -2605,7 +2605,7 @@ bool FileStream_GetSize(TFileStream * pStream, ULONGLONG * pFileSize) * \a NewFileSize File size to set */ bool FileStream_SetSize(TFileStream * pStream, ULONGLONG NewFileSize) -{ +{ if(pStream->dwFlags & STREAM_FLAG_READ_ONLY) { SetLastError(ERROR_ACCESS_DENIED); @@ -2717,7 +2717,7 @@ void FileStream_Close(TFileStream * pStream) // Close the stream provider. if(pStream->StreamClose != NULL) pStream->StreamClose(pStream); - + // Also close base stream, if any else if(pStream->BaseClose != NULL) pStream->BaseClose(pStream); diff --git a/dep/CascLib/src/common/ListFile.cpp b/dep/CascLib/src/common/ListFile.cpp index b9915f0f31c..19d11b874b1 100644 --- a/dep/CascLib/src/common/ListFile.cpp +++ b/dep/CascLib/src/common/ListFile.cpp @@ -37,7 +37,7 @@ static PLISTFILE_CACHE CreateListFileCache(DWORD dwFileSize) if(pCache != NULL) { // Set the initial pointers - pCache->pBegin = + pCache->pBegin = pCache->pPos = (char *)(pCache + 1); pCache->pEnd = pCache->pBegin + dwFileSize; } @@ -114,7 +114,7 @@ size_t ListFile_GetNextLine(void * pvListFile, const char ** pszLineBegin, const char * szExtraString = NULL; char * szLineBegin; char * szLineEnd; - + // Skip newlines, spaces, tabs and another non-printable stuff while(pCache->pPos < pCache->pEnd && pCache->pPos[0] <= 0x20) pCache->pPos++; @@ -215,7 +215,7 @@ static PLISTFILE_MAP ListMap_Create() { PLISTFILE_MAP pListMap; size_t cbToAllocate; - + // Create buffer for the listfile // Note that because the listfile is quite big and CASC_REALLOC // is a costly operation, we want to have as few reallocs as possible. @@ -273,7 +273,7 @@ static PLISTFILE_MAP ListMap_Finish(PLISTFILE_MAP pListMap) // Sanity check assert(pListMap->pNameMap == NULL); - + // Create the map pListMap->pNameMap = pMap = Map_Create((DWORD)pListMap->nEntries, sizeof(ULONGLONG), 0); if(pListMap->pNameMap == NULL) diff --git a/dep/CascLib/src/common/Map.h b/dep/CascLib/src/common/Map.h index 7b0c1321e6c..2b590578105 100644 --- a/dep/CascLib/src/common/Map.h +++ b/dep/CascLib/src/common/Map.h @@ -32,7 +32,7 @@ typedef bool (*MAP_COMPARE)(PCASC_MAP pMap, void * pvObject, void * pvKey); // Functions PCASC_MAP Map_Create(DWORD dwMaxItems, DWORD dwKeyLength, DWORD dwKeyOffset); -size_t Map_EnumObjects(PCASC_MAP pMap, void **ppvArray); +size_t Map_EnumObjects(PCASC_MAP pMap, void **ppvArray); void * Map_FindObject(PCASC_MAP pMap, void * pvKey, PDWORD PtrIndex); bool Map_InsertObject(PCASC_MAP pMap, void * pvNewObject, void * pvKey); const char * Map_FindString(PCASC_MAP pMap, const char * szString, const char * szStringEnd); diff --git a/dep/CascLib/src/common/RootHandler.cpp b/dep/CascLib/src/common/RootHandler.cpp index df9953f3ea6..0ecbee981fb 100644 --- a/dep/CascLib/src/common/RootHandler.cpp +++ b/dep/CascLib/src/common/RootHandler.cpp @@ -28,7 +28,7 @@ LPBYTE RootHandler_Search(TRootHandler * pRootHandler, struct _TCascSearch * pSe // Check if the root structure is valid at all if(pRootHandler == NULL) return NULL; - + return pRootHandler->Search(pRootHandler, pSearch, PtrFileSize, PtrLocaleFlags); } @@ -46,7 +46,7 @@ LPBYTE RootHandler_GetKey(TRootHandler * pRootHandler, const char * szFileName) // Check if the root structure is valid at all if(pRootHandler == NULL) return NULL; - + return pRootHandler->GetKey(pRootHandler, szFileName); } @@ -59,7 +59,7 @@ void RootHandler_Dump(TCascStorage * hs, LPBYTE pbRootHandler, DWORD cbRootHandl { // Create the dump file dc = CreateDumpContext(hs, szNameFormat); - if(dc != NULL) + if(dc != NULL) { // Dump the content and close the file hs->pRootHandler->Dump(hs, dc, pbRootHandler, cbRootHandler, szListFile, nDumpLevel); diff --git a/dep/CascLib/src/jenkins/lookup3.c b/dep/CascLib/src/jenkins/lookup3.c index 6af56b481ad..8035dc4655a 100644 --- a/dep/CascLib/src/jenkins/lookup3.c +++ b/dep/CascLib/src/jenkins/lookup3.c @@ -3,8 +3,8 @@ lookup3.c, by Bob Jenkins, May 2006, Public Domain. These are functions for producing 32-bit hashes for hash table lookup. -hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final() -are externally useful functions. Routines to test the hash are included +hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final() +are externally useful functions. Routines to test the hash are included if SELF_TEST is defined. You can use this free for any purpose. It's in the public domain. It has no warranty. @@ -12,7 +12,7 @@ You probably want to use hashlittle(). hashlittle() and hashbig() hash byte arrays. hashlittle() is is faster than hashbig() on little-endian machines. Intel and AMD are little-endian machines. On second thought, you probably want hashlittle2(), which is identical to -hashlittle() except it returns two 32-bit hashes for the price of one. +hashlittle() except it returns two 32-bit hashes for the price of one. You could implement hashbig2() if you wanted but I haven't bothered here. If you want to find a hash of, say, exactly 7 integers, do @@ -25,9 +25,9 @@ If you want to find a hash of, say, exactly 7 integers, do then use c as the hash value. If you have a variable length array of 4-byte integers to hash, use hashword(). If you have a byte array (like a character string), use hashlittle(). If you have several byte arrays, or -a mix of things, see the comments above hashlittle(). +a mix of things, see the comments above hashlittle(). -Why is this so big? I read 12 bytes at a time into 3 4-byte integers, +Why is this so big? I read 12 bytes at a time into 3 4-byte integers, then mix those integers. This is fast (you can do a lot more thorough mixing with 12*3 instructions on 3 integers than you can with 3 instructions on 1 byte), but shoehorning those bytes into integers efficiently is messy. @@ -87,7 +87,7 @@ This was tested for: the output delta to a Gray code (a^(a>>1)) so a string of 1's (as is commonly produced by subtraction) look like a single 1-bit difference. -* the base values were pseudorandom, all zero but one bit set, or +* the base values were pseudorandom, all zero but one bit set, or all zero plus a counter that starts at zero. Some k values for my "a-=c; a^=rot(c,k); c+=b;" arrangement that @@ -97,7 +97,7 @@ satisfy this are 14 9 3 7 17 3 Well, "9 15 3 18 27 15" didn't quite get 32 bits diffing for "differ" defined as + with a one-bit base and a two-bit delta. I -used http://burtleburtle.net/bob/hash/avalanche.html to choose +used http://burtleburtle.net/bob/hash/avalanche.html to choose the operations, constants, and arrangements of the variables. This does not achieve avalanche. There are input bits of (a,b,c) @@ -136,7 +136,7 @@ produce values of c that look totally different. This was tested for the output delta to a Gray code (a^(a>>1)) so a string of 1's (as is commonly produced by subtraction) look like a single 1-bit difference. -* the base values were pseudorandom, all zero but one bit set, or +* the base values were pseudorandom, all zero but one bit set, or all zero plus a counter that starts at zero. These constants passed: @@ -195,7 +195,7 @@ uint32_t initval) /* the previous hash, or an arbitrary value */ /*------------------------------------------- handle the last 3 uint32_t's */ switch(length) /* all the case statements fall through */ - { + { case 3 : c+=k[2]; case 2 : b+=k[1]; case 1 : a+=k[0]; @@ -212,7 +212,7 @@ uint32_t initval) /* the previous hash, or an arbitrary value */ -------------------------------------------------------------------- hashword2() -- same as hashword(), but take two seeds and return two 32-bit values. pc and pb must both be nonnull, and *pc and *pb must -both be initialized with seeds. If you pass in (*pb)==0, the output +both be initialized with seeds. If you pass in (*pb)==0, the output (*pc) will be the same as the return value from hashword(). -------------------------------------------------------------------- */ @@ -241,7 +241,7 @@ uint32_t *pb) /* IN: more seed OUT: secondary hash value */ /*------------------------------------------- handle the last 3 uint32_t's */ switch(length) /* all the case statements fall through */ - { + { case 3 : c+=k[2]; case 2 : b+=k[1]; case 1 : a+=k[0]; @@ -306,7 +306,7 @@ uint32_t hashlittle( const void *key, size_t length, uint32_t initval) } /*----------------------------- handle the last (probably partial) block */ - /* + /* * "k[2]&0xffffff" actually reads beyond the end of the string, but * then masks off the part it's not allowed to read. Because the * string is aligned, the masked-off tail is in the same word as the @@ -461,7 +461,7 @@ uint32_t hashlittle( const void *key, size_t length, uint32_t initval) * the key. *pc is better mixed than *pb, so use *pc first. If you want * a 64-bit value do something like "*pc + (((uint64_t)*pb)<<32)". */ -void hashlittle2( +void hashlittle2( const void *key, /* the key to hash */ size_t length, /* length of the key */ uint32_t *pc, /* IN: primary initval, OUT: primary hash */ @@ -491,7 +491,7 @@ void hashlittle2( } /*----------------------------- handle the last (probably partial) block */ - /* + /* * "k[2]&0xffffff" actually reads beyond the end of the string, but * then masks off the part it's not allowed to read. Because the * string is aligned, the masked-off tail is in the same word as the @@ -641,7 +641,7 @@ void hashlittle2( * hashbig(): * This is the same as hashword() on big-endian machines. It is different * from hashlittle() on all machines. hashbig() takes advantage of - * big-endian byte ordering. + * big-endian byte ordering. */ uint32_t hashbig( const void *key, size_t length, uint32_t initval) { @@ -668,7 +668,7 @@ uint32_t hashbig( const void *key, size_t length, uint32_t initval) } /*----------------------------- handle the last (probably partial) block */ - /* + /* * "k[2]<<8" actually reads beyond the end of the string, but * then shifts out the part it's not allowed to read. Because the * string is aligned, the illegal read is in the same word as the @@ -778,7 +778,7 @@ void driver1() time(&a); for (i=0; i<256; ++i) buf[i] = 'x'; - for (i=0; i<1; ++i) + for (i=0; i<1; ++i) { h = hashlittle(&buf[0],1,h); } @@ -814,7 +814,7 @@ void driver2() /*---- check that every output bit is affected by that input bit */ for (k=0; kz) z=k; - if (k==MAXPAIR) + if (k==MAXPAIR) { printf("Some bit didn't change: "); printf("%.8x %.8x %.8x %.8x %.8x %.8x ", @@ -925,7 +925,7 @@ void driver3() i=47, j=0; hashword2(&len, 1, &i, &j); if (hashword(&len, 1, 47) != i) - printf("hashword2 and hashword mismatch %x %x\n", + printf("hashword2 and hashword mismatch %x %x\n", i, hashword(&len, 1, 47)); /* check hashlittle doesn't read before or after the ends of the string */ @@ -942,7 +942,7 @@ void driver3() *(b-1)=(uint8_t)~0; x = hashlittle(b, len, (uint32_t)1); y = hashlittle(b, len, (uint32_t)1); - if ((ref != x) || (ref != y)) + if ((ref != x) || (ref != y)) { printf("alignment error: %.8x %.8x %.8x %d %d\n",ref,x,y, h, i); diff --git a/dep/CascLib/src/libtomcrypt/src/hashes/md5.c b/dep/CascLib/src/libtomcrypt/src/hashes/md5.c index 4cbd000c0d4..e92da256d56 100644 --- a/dep/CascLib/src/libtomcrypt/src/hashes/md5.c +++ b/dep/CascLib/src/libtomcrypt/src/hashes/md5.c @@ -13,7 +13,7 @@ /** @file md5.c - LTC_MD5 hash function by Tom St Denis + LTC_MD5 hash function by Tom St Denis */ #ifdef LTC_MD5 @@ -95,7 +95,7 @@ static const ulong32 Korder[64] = { a = (a + I(b,c,d) + M + t); a = ROLc(a, s) + b; -#endif +#endif #ifdef LTC_CLEAN_STACK static int _md5_compress(hash_state *md, unsigned char *buf) @@ -112,7 +112,7 @@ static int md5_compress(hash_state *md, unsigned char *buf) for (i = 0; i < 16; i++) { LOAD32L(W[i], buf + (4*i)); } - + /* copy state */ a = md->md5.state[0]; b = md->md5.state[1]; @@ -309,37 +309,37 @@ int md5_done(hash_state * md, unsigned char *out) /** Self-test the hash @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled -*/ +*/ int md5_test(void) { #ifndef LTC_TEST return CRYPT_NOP; - #else + #else static const struct { char *msg; unsigned char hash[16]; } tests[] = { { "", - { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, + { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e } }, { "a", - {0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8, + {0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8, 0x31, 0xc3, 0x99, 0xe2, 0x69, 0x77, 0x26, 0x61 } }, { "abc", - { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, + { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72 } }, - { "message digest", - { 0xf9, 0x6b, 0x69, 0x7d, 0x7c, 0xb7, 0x93, 0x8d, - 0x52, 0x5a, 0x2f, 0x31, 0xaa, 0xf1, 0x61, 0xd0 } }, + { "message digest", + { 0xf9, 0x6b, 0x69, 0x7d, 0x7c, 0xb7, 0x93, 0x8d, + 0x52, 0x5a, 0x2f, 0x31, 0xaa, 0xf1, 0x61, 0xd0 } }, { "abcdefghijklmnopqrstuvwxyz", - { 0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00, + { 0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00, 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b } }, { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", - { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5, + { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5, 0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f } }, { "12345678901234567890123456789012345678901234567890123456789012345678901234567890", - { 0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55, - 0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a } }, + { 0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55, + 0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a } }, { NULL, { 0 } } }; diff --git a/dep/CascLib/src/libtomcrypt/src/misc/crypt_argchk.c b/dep/CascLib/src/libtomcrypt/src/misc/crypt_argchk.c index 1cd875f5260..39c686a5d46 100644 --- a/dep/CascLib/src/libtomcrypt/src/misc/crypt_argchk.c +++ b/dep/CascLib/src/libtomcrypt/src/misc/crypt_argchk.c @@ -14,7 +14,7 @@ /** @file crypt_argchk.c Perform argument checking, Tom St Denis -*/ +*/ #if (ARGTYPE == 0) void crypt_argchk(char *v, char *s, int d) diff --git a/dep/CascLib/src/libtomcrypt/src/misc/crypt_hash_descriptor.c b/dep/CascLib/src/libtomcrypt/src/misc/crypt_hash_descriptor.c index 5925fd27302..9953551a8b7 100644 --- a/dep/CascLib/src/libtomcrypt/src/misc/crypt_hash_descriptor.c +++ b/dep/CascLib/src/libtomcrypt/src/misc/crypt_hash_descriptor.c @@ -12,7 +12,7 @@ /** @file crypt_hash_descriptor.c - Stores the hash descriptor table, Tom St Denis + Stores the hash descriptor table, Tom St Denis */ struct ltc_hash_descriptor hash_descriptor[TAB_SIZE] = { diff --git a/dep/CascLib/src/libtomcrypt/src/misc/crypt_hash_is_valid.c b/dep/CascLib/src/libtomcrypt/src/misc/crypt_hash_is_valid.c index 8ed5105b56c..20cc30cb0e1 100644 --- a/dep/CascLib/src/libtomcrypt/src/misc/crypt_hash_is_valid.c +++ b/dep/CascLib/src/libtomcrypt/src/misc/crypt_hash_is_valid.c @@ -13,7 +13,7 @@ /** @file crypt_hash_is_valid.c Determine if hash is valid, Tom St Denis -*/ +*/ /* Test if a hash index is valid -- cgit v1.2.3