11 #ifndef __CASCCOMMON_H__
12 #define __CASCCOMMON_H__
25 #include "common/Common.h"
43 #define CASC_GAME_HOTS 0x00010000 // Heroes of the Storm
44 #define CASC_GAME_WOW6 0x00020000 // World of Warcraft - Warlords of Draenor
45 #define CASC_GAME_DIABLO3 0x00030000 // Diablo 3 since PTR 2.2.0
46 #define CASC_GAME_OVERWATCH 0x00040000 // Overwatch since PTR 24919
47 #define CASC_GAME_STARCRAFT2 0x00050000 // Starcraft II - Legacy of the Void, since build 38996
48 #define CASC_GAME_MASK 0xFFFF0000 // Mask for getting game ID
50 #define CASC_INDEX_COUNT 0x10
51 #define CASC_FILE_KEY_SIZE 0x09 // Size of the file key
52 #define CASC_MAX_DATA_FILES 0x100
53 #define CASC_EXTRA_FILES 0x20 // Number of extra entries to be reserved for additionally inserted files
55 #define CASC_SEARCH_HAVE_NAME 0x0001 // Indicated that previous search found a name
57 #define BLTE_HEADER_SIGNATURE 0x45544C42 // 'BLTE' header in the data files
58 #define BLTE_HEADER_DELTA 0x1E // Distance of BLTE header from begin of the header area
59 #define MAX_HEADER_AREA_SIZE 0x2A // Length of the file header area
73 #define CASCLIB_MIN(a, b) ((a < b) ? a : b)
74 #define CASCLIB_MAX(a, b) ((a > b) ? a : b)
75 #define CASCLIB_UNUSED(p) ((void)(p))
77 #define CASC_PACKAGE_BUFFER 0x1000
80 #define _maxchars(buff) ((sizeof(buff) / sizeof(buff[0])) - 1)
180 #define GET_INDEX_KEY(pEncodingEntry) (pEncodingEntry->EncodingKey + MD5_HASH_SIZE)
181 #define FAKE_ENCODING_ENTRY_SIZE (sizeof(CASC_ENCODING_ENTRY) + MD5_HASH_SIZE)
251 #ifdef CASCLIB_TEST // Extra fields for analyzing the file size problem
252 DWORD FileSize_RootEntry;
253 DWORD FileSize_EncEntry;
254 DWORD FileSize_IdxEntry;
255 DWORD FileSize_HdrArea;
256 DWORD FileSize_FrameSum;
293 #if defined(_MSC_VER) && defined(_DEBUG)
295 #define CASC_REALLOC(type, ptr, count) (type *)HeapReAlloc(GetProcessHeap(), 0, ptr, ((count) * sizeof(type)))
296 #define CASC_ALLOC(type, count) (type *)HeapAlloc(GetProcessHeap(), 0, ((count) * sizeof(type)))
297 #define CASC_FREE(ptr) HeapFree(GetProcessHeap(), 0, ptr)
301 #define CASC_REALLOC(type, ptr, count) (type *)realloc(ptr, (count) * sizeof(type))
302 #define CASC_ALLOC(type, count) (type *)malloc((count) * sizeof(type))
303 #define CASC_FREE(ptr) free(ptr)
324 int GetRootVariableIndex(
const char * szLinePtr,
const char * szLineEnd,
const char * szVariableName,
int * PtrIndex);
325 int ParseRootFileLine(
const char * szLinePtr,
const char * szLineEnd,
int nFileNameIndex,
PQUERY_KEY pEncodingKey,
char * szFileName,
size_t nMaxChars);
352 void CascDumpSparseArray(
const char * szFileName,
void * pvSparseArray);
353 void CascDumpNameFragTable(
const char * szFileName,
void * pvMarFile);
354 void CascDumpFileNames(
const char * szFileName,
void * pvMarFile);
355 void CascDumpIndexEntries(
const char * szFileName,
TCascStorage * hs);
356 void CascDumpEncodingEntry(
TCascStorage * hs,
TDumpContext * dc, PCASC_ENCODING_ENTRY pEncodingEntry,
int nDumpLevel);
357 void CascDumpFile(
const char * szFileName,
HANDLE hFile);
360 #endif // __CASCCOMMON_H__
int CascDirectCopy(LPBYTE pbOutBuffer, PDWORD pcbOutBuffer, LPBYTE pbInBuffer, DWORD cbInBuffer)
Definition: CascDecrypt.cpp:289
TRootHandler * pRootHandler
Definition: CascCommon.h:223
DWORD CacheEnd
Definition: CascCommon.h:249
Definition: CascCommon.h:96
DWORD FrameSize
Definition: CascCommon.h:131
QUERY_KEY RootKey
Definition: CascCommon.h:208
BYTE SpanSizeBytes
Definition: CascCommon.h:115
struct _TCascFile TCascFile
const char * szClassName
Definition: CascCommon.h:231
DWORD HeaderOffset
Definition: CascCommon.h:236
struct _TCascStorage TCascStorage
DWORD dwDefaultLocale
Definition: CascCommon.h:199
struct _CASC_ENCODING_ENTRY_1 * PCASC_ENCODING_ENTRY_1
void * HANDLE
Definition: CascPort.h:146
unsigned long long ULONGLONG
Definition: CascPort.h:144
DWORD dwState
Definition: CascCommon.h:274
DWORD * PDWORD
Definition: CascPort.h:151
_CBLD_TYPE
Definition: CascCommon.h:89
BYTE SegmentBits
Definition: CascCommon.h:118
struct _CASC_MAPPING_TABLE CASC_MAPPING_TABLE
CASC_MAPPING_TABLE KeyMapping[CASC_INDEX_COUNT]
Definition: CascCommon.h:216
int CascDecrypt(LPBYTE pbOutBuffer, PDWORD pcbOutBuffer, LPBYTE pbInBuffer, DWORD cbInBuffer, DWORD dwFrameIndex)
Definition: CascDecrypt.cpp:205
BYTE KeyBytes
Definition: CascCommon.h:117
int RootHandler_CreateMNDX(TCascStorage *hs, LPBYTE pbRootFile, DWORD cbRootFile)
Definition: CascRootFile_Mndx.cpp:3139
DWORD ConvertBytesToInteger_4_LE(LPBYTE ValueAsBytes)
Definition: CascCommon.cpp:43
struct _TCascSearch TCascSearch
#define CASC_MAX_DATA_FILES
Definition: CascCommon.h:52
Definition: RootHandler.h:66
QUERY_KEY ArchivesKey
Definition: CascCommon.h:206
Definition: CascCommon.h:109
BYTE FileSizeBE[4]
Definition: CascCommon.h:162
TCascStorage * hs
Definition: CascCommon.h:263
QUERY_KEY DownloadKey
Definition: CascCommon.h:210
DWORD ConvertBytesToInteger_4(LPBYTE ValueAsBytes)
Definition: CascCommon.cpp:31
CBLD_TYPE BuildFileType
Definition: CascCommon.h:201
ULONGLONG MaxFileOffset
Definition: CascCommon.h:119
Definition: CascLib.h:138
#define MAX_PATH
Definition: CascPort.h:160
struct _CASC_MAPPING_TABLE * PCASC_MAPPING_TABLE
ULONGLONG ConvertBytesToInteger_5(LPBYTE ValueAsBytes)
Definition: CascCommon.cpp:56
PCASC_MAP pIndexEntryMap
Definition: CascCommon.h:217
int LoadBuildInfo(TCascStorage *hs)
Definition: CascFiles.cpp:826
BYTE IndexKey[MD5_HASH_SIZE]
Definition: CascCommon.h:176
char TCHAR
Definition: CascPort.h:148
DWORD FileSize
Definition: CascCommon.h:240
struct _ENCODING_KEY ENCODING_KEY
LPBYTE pbFileData
Definition: CascCommon.h:112
struct _CASC_ENCODING_ENTRY CASC_ENCODING_ENTRY
void * pCache
Definition: CascCommon.h:266
struct _CASC_INDEX_ENTRY * PCASC_INDEX_ENTRY
int ParseRootFileLine(const char *szLinePtr, const char *szLineEnd, int nFileNameIndex, PQUERY_KEY pEncodingKey, char *szFileName, size_t nMaxChars)
Definition: CascFiles.cpp:982
Definition: CascCommon.h:92
QUERY_KEY CdnBuildKey
Definition: CascCommon.h:204
int RootHandler_CreateWoW6(TCascStorage *hs, LPBYTE pbRootFile, DWORD cbRootFile, DWORD dwLocaleMask)
Definition: CascRootFile_WoW6.cpp:487
PCASC_INDEX_ENTRY pIndexEntries
Definition: CascCommon.h:121
TCascFile * IsValidFileHandle(HANDLE hFile)
Definition: CascOpenFile.cpp:18
QUERY_KEY ArchivesGroup
Definition: CascCommon.h:205
BYTE * LPBYTE
Definition: CascPort.h:152
DWORD dwFileBeginDelta
Definition: CascCommon.h:198
LPBYTE pbFileCache
Definition: CascCommon.h:246
DYNAMIC_ARRAY ExtraEntries
Definition: CascCommon.h:221
BYTE SpanOffsBytes
Definition: CascCommon.h:116
TCHAR * szUrlPath
Definition: CascCommon.h:194
unsigned short USHORT
Definition: CascPort.h:137
DWORD FrameCount
Definition: CascCommon.h:244
const TCHAR * szIndexFormat
Definition: CascCommon.h:189
DWORD nIndexEntries
Definition: CascCommon.h:122
#define CASC_INDEX_COUNT
Definition: CascCommon.h:50
struct _CASC_FILE_FRAME CASC_FILE_FRAME
void FreeCascBlob(PQUERY_KEY pQueryKey)
Definition: CascCommon.cpp:80
DWORD ArchiveIndex
Definition: CascCommon.h:235
DWORD FramesOffset
Definition: CascCommon.h:238
void * pRootContext
Definition: CascCommon.h:271
#define MD5_HASH_SIZE
Definition: CascLib.h:105
Definition: DumpContext.h:21
Definition: DynamicArray.h:17
struct _CASC_ENCODING_ENTRY * PCASC_ENCODING_ENTRY
TCHAR * szRootPath
Definition: CascCommon.h:190
PCASC_FILE_FRAME pFrames
Definition: CascCommon.h:243
DWORD cbFileCache
Definition: CascCommon.h:247
DWORD HeaderSize
Definition: CascCommon.h:237
BYTE FrameArrayHash[MD5_HASH_SIZE]
Definition: CascCommon.h:241
USHORT KeyCount
Definition: CascCommon.h:173
int RootHandler_CreateDiablo3(TCascStorage *hs, LPBYTE pbRootFile, DWORD cbRootFile)
Definition: CascRootFile_Diablo3.cpp:1079
Definition: CascCommon.h:186
int RootHandler_CreateOverwatch(TCascStorage *hs, LPBYTE pbRootFile, DWORD cbRootFile)
Definition: CascRootFile_Ovr.cpp:133
int CheckGameDirectory(TCascStorage *hs, TCHAR *szDirectory)
Definition: CascFiles.cpp:909
TCHAR * szFileName
Definition: CascCommon.h:111
Definition: CascCommon.h:93
QUERY_KEY PatchArchivesKey
Definition: CascCommon.h:207
struct _CASC_ENCODING_HEADER * PCASC_ENCODING_HEADER
QUERY_KEY EncodingFile
Definition: CascCommon.h:219
BYTE md5[MD5_HASH_SIZE]
Definition: CascCommon.h:132
struct _CASC_INDEX_ENTRY CASC_INDEX_ENTRY
const char * szClassName
Definition: CascCommon.h:264
char * szMask
Definition: CascCommon.h:267
PCASC_MAP pEncodingMap
Definition: CascCommon.h:220
Definition: CascCommon.h:261
QUERY_KEY EncodingKey
Definition: CascCommon.h:212
QUERY_KEY CdnConfigKey
Definition: CascCommon.h:203
TCascStorage * hs
Definition: CascCommon.h:229
DWORD cbFileData
Definition: CascCommon.h:113
TCHAR * szIndexPath
Definition: CascCommon.h:193
char szFileName[MAX_PATH]
Definition: CascCommon.h:268
TCHAR * szBuildFile
Definition: CascCommon.h:192
struct _ENCODING_KEY * PENCODING_KEY
DWORD dwGameInfo
Definition: CascCommon.h:196
unsigned int DWORD
Definition: CascPort.h:139
int CascDecompress(LPBYTE pvOutBuffer, PDWORD pcbOutBuffer, LPBYTE pvInBuffer, DWORD cbInBuffer)
Definition: CascDecompress.cpp:18
BYTE BitArray[1]
Definition: CascCommon.h:276
Definition: CascCommon.h:102
BYTE EncodingKey[MD5_HASH_SIZE]
Definition: CascCommon.h:163
DWORD dwRefCount
Definition: CascCommon.h:195
Definition: CascCommon.h:91
DWORD CacheStart
Definition: CascCommon.h:248
Definition: CascCommon.h:171
BYTE FileOffsetBE[5]
Definition: CascCommon.h:105
DWORD ConvertBytesToInteger_3(LPBYTE ValueAsBytes)
Definition: CascCommon.cpp:19
enum _CBLD_TYPE CBLD_TYPE
struct _CASC_ENCODING_ENTRY_1 CASC_ENCODING_ENTRY_1
DWORD FrameArchiveOffset
Definition: CascCommon.h:128
Definition: CascCommon.h:126
DWORD FrameFileOffset
Definition: CascCommon.h:129
#define CASC_FILE_KEY_SIZE
Definition: CascCommon.h:51
Definition: FileStream.h:153
enum _CBLD_TYPE * PCBLD_TYPE
TCHAR * szDataPath
Definition: CascCommon.h:191
USHORT KeyCount
Definition: CascCommon.h:161
BYTE EncodingKey[MD5_HASH_SIZE]
Definition: CascCommon.h:175
DWORD CompressedSize
Definition: CascCommon.h:239
Definition: CascCommon.h:159
const char * szClassName
Definition: CascCommon.h:188
BYTE FileSizeBE[4]
Definition: CascCommon.h:174
PCASC_ENCODING_ENTRY FindEncodingEntry(TCascStorage *hs, PQUERY_KEY pEncodingKey, PDWORD PtrIndex)
Definition: CascOpenFile.cpp:35
unsigned char BYTE
Definition: CascPort.h:136
Definition: CascCommon.h:227
DWORD FilePointer
Definition: CascCommon.h:233
TFileStream * DataFileArray[CASC_MAX_DATA_FILES]
Definition: CascCommon.h:214
TCascStorage * IsValidStorageHandle(HANDLE hStorage)
Definition: CascOpenStorage.cpp:100
int GetRootVariableIndex(const char *szLinePtr, const char *szLineEnd, const char *szVariableName, int *PtrIndex)
Definition: CascFiles.cpp:953
size_t IndexLevel1
Definition: CascCommon.h:272
void ConvertIntegerToBytes_4(DWORD Value, LPBYTE ValueAsBytes)
Definition: CascCommon.cpp:69
QUERY_KEY PatchKey
Definition: CascCommon.h:209
struct _CASC_ENCODING_HEADER CASC_ENCODING_HEADER
size_t IndexLevel2
Definition: CascCommon.h:273
PCASC_INDEX_ENTRY FindIndexEntry(TCascStorage *hs, PQUERY_KEY pIndexKey)
Definition: CascOpenFile.cpp:25
TFileStream * pStream
Definition: CascCommon.h:230
BYTE IndexKey[CASC_FILE_KEY_SIZE]
Definition: CascCommon.h:104
BYTE FileSizeLE[4]
Definition: CascCommon.h:106
QUERY_KEY InstallKey
Definition: CascCommon.h:211
DWORD dwBuildNumber
Definition: CascCommon.h:197
struct _CASC_FILE_FRAME * PCASC_FILE_FRAME
BYTE ExtraBytes
Definition: CascCommon.h:114
DWORD CompressedSize
Definition: CascCommon.h:130
TCHAR * szListFile
Definition: CascCommon.h:265