### Local Storage Parameter Example Source: http://www.zezula.net/en/casc/casclib/cascopenstorage.html Example of szParams for a local storage containing multiple products. Specify the path and the product code name separated by an asterisk. ```text C:\Games\World of Warcraft*wowt ``` -------------------------------- ### Online Storage Parameter Examples Source: http://www.zezula.net/en/casc/casclib/cascopenstorage.html Examples of szParams for online storages. The format includes a local cache folder, an optional CDN server URL, the storage code name, and an optional region. ```text C:\Cache*wow*eu ``` ```text C:\Cache*http://myowncdn.com:8000*wow*eu ``` -------------------------------- ### CascReadFile Function Signature Source: http://www.zezula.net/en/casc/casclib/cascreadfile.html This is the function signature for CascReadFile. Use CascOpenFile to get a handle. The function reads data into a buffer and returns the number of bytes read. It returns true on success, false on failure. ```cpp bool WINAPI CascReadFile( HANDLE _hFile_, // Handle to an open file void * _lpBuffer_, // Buffer where to read the file data DWORD _dwToRead_, // Number of bytes to be read DWORD * _pdwRead_ // Optional pointer to store number of bytes that were actually read ); ``` -------------------------------- ### Opening a file by CKey or EKey Source: http://www.zezula.net/en/casc/casclib/cascopenfile.html Demonstrates how to open a file using its Content Key (CKey) or Encoded Key (EKey). CKey is the MD5 hash of the file's content, while EKey is the MD5 hash of the encoded file frames. This method is useful for files not referenced by name, but be aware that keys may change after file updates. ```APIDOC ## Opening a file by CKey or EKey ### Description This section details how to open files within the CASC system using either their Content Key (CKey) or Encoded Key (EKey). CKey is derived from the MD5 hash of the file's content, and EKey is derived from the MD5 hash of the encoded file frames. This approach is particularly useful for files that do not have a direct name reference. ### Method `CascOpenFile` function is used for opening files. ### Parameters - `hStorage` (handle) - Handle to the CASC storage. - `key` (string or byte array) - The CKey or EKey of the file. - `index` (integer) - Typically 0. - `flags` (integer) - Can be 0, `CASC_OPEN_BY_CKEY`, or `CASC_OPEN_BY_EKEY`. - `&hFile` (pointer) - Pointer to a handle that will receive the opened file. ### Request Example ```c // Example using Content Key (CKey) // Content Key of "dbfilesclient\battlepetspeciesstate.db2" (WoW build 30993) CascOpenFile(hStorage, "2f8acb9da224318cb17ddd98e11f663f", 0, 0, &hFile); BYTE CKey[MD5_HASH_SIZE] = {0x2f, 0x8a, 0xcb, 0x9d, 0xa2, 0x24, 0x31, 0x8c, 0xb1, 0x7d, 0xdd, 0x98, 0xe1, 0x1f, 0x66, 0x3f}; CascOpenFile(hStorage, CKey, 0, CASC_OPEN_BY_CKEY, &hFile); // Example using Encoded Key (EKey) // Encoded Key of "dbfilesclient\battlepetspeciesstate.db2" (WoW build 30993) CascOpenFile(hStorage, "35c1c4b5250c0005ab7a03a693c0f399", 0, 0, &hFile); BYTE EKey[MD5_HASH_SIZE] = {0x35, 0xc1, 0xc4, 0xb5, 0x25, 0x0c, 0x00, 0x05, 0xab, 0x7a, 0x03, 0xa6, 0x93, 0xc0, 0xf3, 0x99}; CascOpenFile(hStorage, EKey, 0, CASC_OPEN_BY_EKEY, &hFile); ``` ### Notes - CKey (and consequently EKey) can change after any update that modifies the file. - This method is recommended only for files that are not referenced by name. ``` -------------------------------- ### Open CASC files using CKey or EKey Source: http://www.zezula.net/en/casc/casclib/cascopenfile.html Demonstrates opening files using string-based MD5 hashes or byte arrays with specific CASC flags. Note that these keys are volatile and change with game updates. ```cpp // Content Key of "dbfilesclient\battlepetspeciesstate.db2" (WoW build 30993) CascOpenFile(hStorage, "2f8acb9da224318cb17ddd98e11f663f", 0, 0, &hFile); BYTE CKey[MD5_HASH_SIZE] = {0x2f, 0x8a, 0xcb, 0x9d, 0xa2, 0x24, 0x31, 0x8c, 0xb1, 0x7d, 0xdd, 0x98, 0xe1, 0x1f, 0x66, 0x3f}; CascOpenFile(hStorage, CKey, 0, CASC_OPEN_BY_CKEY, &hFile); // Encoded Key of "dbfilesclient\battlepetspeciesstate.db2" (WoW build 30993) CascOpenFile(hStorage, "35c1c4b5250c0005ab7a03a693c0f399", 0, 0, &hFile); BYTE EKey[MD5_HASH_SIZE] = {0x35, 0xc1, 0xc4, 0xb5, 0x25, 0x0c, 0x00, 0x05, 0xab, 0x7a, 0x03, 0xa6, 0x93, 0xc0, 0xf3, 0x99}; CascOpenFile(hStorage, EKey, 0, CASC_OPEN_BY_EKEY, &hFile); ``` -------------------------------- ### Open CASC Storage with CascView Source: http://www.zezula.net/en/casc/main.html Use the CascView executable with the path to the game storage directory or a specific storage subdirectory. This can be done directly on the command line. ```bash CascView.exe "c:\Games\Diablo III" ``` ```bash CascView.exe "C:\Games\Heroes of the Storm\HeroesData" ``` ```bash CascView.exe "C:\Games\World of Warcraft\Data" ``` ```bash CascView.exe "C:\Games\Overwatch\data\casc\config\66\77" ``` ```bash CascView.exe "C:\Games\WoW\45745-meta\wow-46902-classic.versions" ``` -------------------------------- ### Open Meta-Storage with CascView Source: http://www.zezula.net/en/casc/main.html To open a meta-storage in CascView (version 2.4 or newer), provide the name of a 'versions' file on the command line. This is useful when multiple game versions share a single storage directory. ```bash CascView.exe "C:\Games\WoW\45745-meta\wow-46902-classic.versions" ``` -------------------------------- ### Opening a file by name Source: http://www.zezula.net/en/casc/casclib/cascopenfile.html Standard method for opening files using path strings. Supports both forward and backslashes. ```cpp CascOpenFile(hStorage, "mods/heromods/murky.stormmod/base.stormdata/gamedata/buttondata.xml", 0, 0, &hFile); ``` -------------------------------- ### Retrieve Variable-Sized File Span Information Source: http://www.zezula.net/en/casc/casclib/cascgetfileinfo.html Demonstrates the two-step pattern for retrieving variable-sized information: first querying the required buffer size, then allocating memory and fetching the data. ```cpp PCASC_FILE_SPAN_INFO GetFileSpanInfo(HANDLE hFile) { PCASC_FILE_SPAN_INFO pSpans = NULL; size_t cbLength = 0; // Retrieve the full file info CascGetFileInfo(hFile, CascFileSpanInfo, pSpans, cbLength, &cbLength); if(cbLength != 0) { if((pSpans = (PCASC_FILE_SPAN_INFO)(new BYTE[cbLength])) != NULL) { if(CascGetFileInfo(hFile, CascFileSpanInfo, pSpans, cbLength, NULL)) return pSpans; CASC_FREE(pSpans); pSpans = NULL; } } return pSpans; } ``` -------------------------------- ### Open CASC Storage Source: http://www.zezula.net/en/casc/casclib/cascopenstorage.html Use CascOpenStorage to open a local CASC storage. Specify the path to the storage and optionally a product code if multiple products exist within the storage. The dwLocaleMask parameter is only relevant for World of Warcraft storages. ```c bool WINAPI CascOpenStorage( LPCTSTR _szParams_, DWORD _dwLocaleMask_, HANDLE * _phStorage_ ); ``` -------------------------------- ### Extract a file from CASC storage Source: http://www.zezula.net/en/casc/casclib.html Demonstrates the process of opening a storage, locating a file, and writing its contents to a local disk file. ```cpp //----------------------------------------------------------------------------- // Extracts a file from the storage and saves it to the disk. // // Parameters : // // char * szStorageName - Name of the storage local path (optionally with product code name) // char * szStorageFile - Name/number of storaged file. // char * szFileName - Name of the target disk file. static int ExtractFile(char * szStorageName, char * szStorageFile, char * szFileName) { HANDLE hStorage = NULL; // Open storage handle HANDLE hFile = NULL; // Storage file handle HANDLE handle = NULL; // Disk file handle DWORD dwErrCode = ERROR_SUCCESS; // Result value // Open a CASC storage, e.g. "c:\Games\StarCraft II". // For a multi-product storage, a product code can be appended // after the storage local path, e.g. "C:\Games\World of Warcraft:wowt". if(dwErrCode == ERROR_SUCCESS) { if(!CascOpenStorage(szStorageName, 0, &hStorage)) dwErrCode = GetLastError(); } // Open a file in the storage, e.g. "mods\core.sc2mod\base.sc2assets\assets\sounds\ui_ac_allyfound.wav" if(dwErrCode == ERROR_SUCCESS) { if(!CascOpenFile(hStorage, szStorageFile, 0, 0, &hFile)) dwErrCode = GetLastError(); } // Create the target file if(dwErrCode == ERROR_SUCCESS) { handle = CreateFile(szFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); if(handle == INVALID_HANDLE_VALUE) dwErrCode = GetLastError(); } // Read the data from the file if(dwErrCode == ERROR_SUCCESS) { char szBuffer[0x10000]; DWORD dwBytes = 1; while(dwBytes != 0) { CascReadFile(hFile, szBuffer, sizeof(szBuffer), &dwBytes); if(dwBytes == 0) break; WriteFile(handle, szBuffer, dwBytes, &dwBytes, NULL); if(dwBytes == 0) break; } } // Cleanup and exit if(handle != NULL) CloseHandle(handle); if(hFile != NULL) CascCloseFile(hFile); if(hStorage != NULL) CascCloseStorage(hStorage); return dwErrCode; } ``` -------------------------------- ### Opening a file by file data ID Source: http://www.zezula.net/en/casc/casclib/cascopenfile.html Methods for opening files using numeric identifiers, primarily for World of Warcraft storages. ```cpp // All these lines open the same file: "dbfilesclient\battlepetspeciesstate.db2" CascOpenFile(hStorage, "File801581.dat", 0, 0, &hFile); // For hexadecimal file data ID, there must be 8 digits in the name CascOpenFile(hStorage, "FILE000C3B2D.dat", 0, 0, &hFile); CascOpenFile(hStorage, CASC_FILE_DATA_ID(801581), 0, CASC_OPEN_BY_FILEID, &hFile); ``` -------------------------------- ### Retrieve storage information with CascGetStorageInfo Source: http://www.zezula.net/en/casc/casclib/cascgetstorageinfo.html Use this function to query specific storage parameters by providing a handle and an information class. The pcbLengthNeeded parameter is optional and can be used to determine required buffer sizes. ```cpp bool WINAPI CascGetStorageInfo( HANDLE hStorage, // Handle to an open storage CASC_STORAGE_INFO_CLASS InfoClass, // Pointer to a structure with extra arguments void * pvStorageInfo, // Specifies whether to open a local or an online storage size_t cbStorageInfo, // Length, in bytes, of the buffer pointed by pvStorageInfo size_t * pcbLengthNeeded, // Pointer to a required length, in bytes ); ``` -------------------------------- ### CascOpenStorageEx Source: http://www.zezula.net/en/casc/casclib/cascopenstorageex.html Opens a CASC storage, supporting both local and online storages. ```APIDOC ## CascOpenStorageEx ### Description Opens a CASC storage. Both local and online storages are supported, depending on the value of the `bOnlineStorage` parameter. ### Method WINAPI ### Endpoint N/A (This is a function call, not an HTTP endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None #### Function Parameters - **szParams** (_LPCTSTR_) - Optional - Parameters of a storage. For local storages, this is the path to the storage. For online storages, it includes the cache folder, CDN server URL, code name, and region. - **pArgs** (_PCASC_OPEN_STORAGE_ARGS_) - Optional - Pointer to a structure with extra arguments. Can be NULL if `szParams` is specified. This structure contains members like `Size`, `szLocalPath`, `szCodeName`, `szRegion`, `PfnProgressCallback`, `PtrProgressParam`, `PfnProductCallback`, `PtrProductParam`, `dwLocaleMask`, `dwFlags`, and `szCdnHostUrl`. - **bOnlineStorage** (_bool_) - Specifies whether to open a local or an online storage. - **phStorage** (_HANDLE ***) - Output - Pointer to a HANDLE variable that receives the storage handle upon success. ### Request Example ```c // Example for opening a local storage HANDLE hStorage = NULL; CascOpenStorageEx(_T("C:\Games\World of Warcraft*wowt"), NULL, false, &hStorage); // Example for opening an online storage HANDLE hStorage = NULL; CascOpenStorageEx(_T("C:\Cache*wow*eu"), NULL, true, &hStorage); ``` ### Response #### Success Response (true) - **Return Value** (bool) - `true` if the storage was opened successfully. #### Failure Response (false) - **Return Value** (bool) - `false` if the storage could not be opened. `GetLastError()` can be used to retrieve the error code. #### Response Example ```c // On success if (CascOpenStorageEx(params, args, online, &hStorage)) { // Storage opened successfully } else { // Handle error, GetLastError() } ``` ``` -------------------------------- ### CascFindFirstFile Source: http://www.zezula.net/en/casc/casclib/cascfindfirstfile.html Begins an iteration over files in a CASC storage and returns information about the first matching file. ```APIDOC ## CascFindFirstFile ### Description Begins an iteration over all files in the storage and returns the information about the first one. ### Parameters #### Path Parameters - **hStorage** (HANDLE) - Required - Handle to an open CASC storage. - **szMask** (LPCSTR) - Optional - Wildcard mask to filter file names. If NULL, all files are searched. - **pFindData** (PCASC_FIND_DATA) - Required - Pointer to a CASC_FIND_DATA structure to be filled with file information. - **szListFile** (LPCTSTR) - Optional - Name of a listfile for storages that do not supply file names. ### Return Value - Returns a search handle on success, or INVALID_HANDLE_VALUE on failure. ### Returned structure (CASC_FIND_DATA) - **szFileName** (string) - Full name of the file. - **CKey** (16-byte) - Content key (MD5 hash of plain data). - **EKey** (16-byte) - Encoded key (MD5 hash of encoded headers). - **TagBitMask** (int) - Bit mask of tags present for the file. - **FileSize** (uint64) - 64-bit content size of the file. - **szPlainName** (string) - Pointer to the plain file name. - **dwFileDataId** (uint32) - File data ID. - **dwLocaleFlags** (uint32) - Locale flags. - **dwContentFlags** (uint32) - Content flags. - **dwSpanCount** (uint32) - Number of file spans. - **bFileAvailable** (bool) - Indicates if the file is locally available. - **NameType** (enum) - Indicates the type of name in szFileName. ``` -------------------------------- ### Declare CascFindFirstFile function Source: http://www.zezula.net/en/casc/casclib/cascfindfirstfile.html Function signature for initiating a file search in a CASC storage. ```cpp **bool WINAPI CascFindFirstFile(** **HANDLE** _hStorage_, // Handle to an open storage **LPCSTR** _szMask_, // Wildcard mask to specify files **PCASC_FIND_DATA** _pFindData_, // Pointer to a CASC_FIND_DATA structure **LPCTSTR** _szListFile_ // Optional name of a listfile **);** ``` -------------------------------- ### CascFindNextFile Source: http://www.zezula.net/en/casc/casclib/cascfindnextfile.html Continues a file iteration initiated by CascFindFirstFile. ```APIDOC ## CascFindNextFile ### Description Function **CascFindNextFile** continues a file iteration (searching) that has been initiated by a previous call to CascFindFirstFile. ### Method WINAPI ### Endpoint N/A (This is a library function, not a web endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (TRUE) - **bool** (TRUE) - Indicates success. The **CASC_FIND_DATA** structure is filled with information about a found file. #### Failure Response (FALSE) - **bool** (FALSE) - Indicates failure. **GetLastError()** can be called to retrieve the error code. #### Response Example None ``` -------------------------------- ### CascOpenStorage / CascOpenOnlineStorage Source: http://www.zezula.net/en/casc/casclib/cascopenstorage.html These functions open a CASC storage, either from a local path or an online source. They are stubs for CascOpenStorageEx. ```APIDOC ## CascOpenStorage / CascOpenOnlineStorage ### Description Functions **CascOpenStorage** and **CascOpenOnlineStorage** open a CASC storage. Both functions are merely stubs for **CascOpenStorageEx**. ### Method `bool WINAPI CascOpenStorage(LPCTSTR _szParams_, DWORD _dwLocaleMask_, HANDLE *** _phStorage_);` `bool WINAPI CascOpenOnlineStorage(LPCTSTR _szParams_, DWORD _dwLocaleMask_, HANDLE *** _phStorage_);` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None #### Parameters - **szParams** (LPCTSTR) - in - Parameters of a local or online storage. - **Local storages**: A parameter string containing the path to a local storage. If the storage contains multiple products (World of Warcraft Retail + World of Warcraft PTR), the product can be specified by the product code name separated by an asterisk: `C:\Games\World of Warcraft*wowt` - **Online storages**: A parameter string containing the storage parameters. The string is in the following format: `local_cache_folder[*cdn_server_url]*code_name[*region]` Example1: `C:\Cache*wow*eu` Example2: `C:\Cache*http://myowncdn.com:8000*wow*eu` - **dwLocaleMask** (DWORD) - in - Locale mask. Only used for World of Warcraft storages. - **phStorage** (HANDLE ***) - out - Pointer to a HANDLE variable that receives storage handle on success. ### Request Example ```json { "szParams": "C:\\Games\\World of Warcraft*wowt", "dwLocaleMask": 0, "phStorage": null } ``` ### Response #### Success Response (true) - **Return Value** (bool) - true on success. #### Failure Response (false) - **Return Value** (bool) - false on failure. **GetLastError()** returns the error code. #### Response Example ```json { "success": true } ``` ### Local storages vs Online Storages Please, refer to **CascOpenStorageEx** documentation for more information. ``` -------------------------------- ### CascGetStorageInfo Source: http://www.zezula.net/en/casc/casclib/cascgetstorageinfo.html Retrieves various parameters of an open storage. The type of information depends on the value of the InfoClass parameter. ```APIDOC ## CascGetStorageInfo ### Description Function **CascGetStorageInfo** retrieves various parameters of an open storage. The type of information depends on the value of the **InfoClass** parameter. ### Method `bool WINAPI CascGetStorageInfo( HANDLE _hStorage_, CASC_STORAGE_INFO_CLASS _InfoClass_, void * _pvStorageInfo_, size_t _cbStorageInfo_, size_t * _pcbLengthNeeded_ ); ` ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Request Example ```json { "example": "No request body for this function." } ``` ### Response #### Success Response (200) * **bool** - Returns `true` on success. #### Response Example ```json { "example": "true" } ``` #### Error Handling * On failure, the function returns `false` and **GetLastError()** returns the error code. #### Return Value Details The following table shows the possible type of information that are obtainable by **CascGetFileInfo** : | Value of _InfoClass_ | pvStorageInfo points to | Returned information | |---|---|---| | CascStorageLocalFileCount | DWORD | Number of local files in the storage. Note that a file can be referenced by different names, so the total number of files in the storage may be higher than physical number of files. | | CascStorageTotalFileCount | DWORD | Total file count in the storage. This includes the files that are offline (not downloaded). | | CascStorageFeatures | DWORD | Bit mask containing various CASC storage features. The mask can be a combination of the following values: * CASC_FEATURE_FILE_NAMES (0x00000001) - File names are supported by the storage * CASC_FEATURE_ROOT_CKEY (0x00000002) - Present if the storage's ROOT returns CKey. If not present, the root contains EKeys. * CASC_FEATURE_TAGS (0x00000004) - Tags are supported by the storage. * CASC_FEATURE_FNAME_HASHES (0x00000008) - The storage contains file name hashes on ALL files. * CASC_FEATURE_FNAME_HASHES_OPTIONAL (0x00000010) - The storage contains file name hashes for SOME files. * CASC_FEATURE_FILE_DATA_IDS (0x00000020) - The storage indexes files by FileDataId. * CASC_FEATURE_LOCALE_FLAGS (0x00000040) - Locale flags are supported by the storage. * CASC_FEATURE_CONTENT_FLAGS (0x00000080) - Content flags are supported by the storage. * CASC_FEATURE_ONLINE (0x00000100) - The storage is an online storage. | | CascStorageProduct | CASC_STORAGE_PRODUCT | Information abot the product - product printable name, build number, and CASC_PRODUCT enum. | | CascStorageTags | CASC_STORAGE_TAGS | Information about tags included in the storage. | | CascStoragePathProduct | TCHAR Buffer | Open parameters of the storage, aka LocalPath:ProductCode. | ``` -------------------------------- ### CascLib Storage Management Source: http://www.zezula.net/en/casc/casclib.html Functions for opening, closing, and retrieving information about CASC storages. ```APIDOC ## CascOpenStorage ### Description Opens a local CASC storage. ## CascOpenStorageEx ### Description Opens a CASC storage. ## CascOpenOnlineStorage ### Description Opens an online CASC storage. ## CascGetStorageInfo ### Description Allows to retrieve information about an open storage. ## CascAddEncryptionKey ### Description Allows to add an external encryption key. ## CascFindEncryptionKey ### Description Allows to find an encryption key. ## CascCloseStorage ### Description Closes a CASC storage. ``` -------------------------------- ### CascSetFilePointer and CascSetFilePointer64 Function Signatures Source: http://www.zezula.net/en/casc/casclib/cascsetfilepointer.html Function definitions for setting the file pointer in CASC archives. CascSetFilePointer64 is recommended for 64-bit file offsets. ```cpp **DWORD WINAPI CascSetFilePointer(** **HANDLE** _hFile_, // Handle to an open file **LONG** _lFilePos_, // Low 32-bits of the bytes to move **LONG *** _PtrFilePosHigh_, // Optional pointer to high 32-bits of the file position **DWORD** _dwMoveMethod_ // Seek method **);** **bool WINAPI CascSetFilePointer64(** **HANDLE** _hFile_, // Handle to an open file **LONGLONG** _DistanceToMove_, // Number of bytes to move **PULONGLONG** _PtrNewPos_, // Pointer to a 64-bit variable that receives the new file pointer **DWORD** _dwMoveMethod_ // Seek method **);** ``` -------------------------------- ### CascOpenFile Source: http://www.zezula.net/en/casc/casclib/cascopenfile.html Opens a file within a CASC storage, allowing access by name, data ID, content key, or encoded key. ```APIDOC ## CascOpenFile ### Description Opens a file within the storage. The file can be open by name, data id, content key or encoded key. ### Method WINAPI bool CascOpenFile( HANDLE _hStorage_, const void * _pvFileName_, DWORD _dwLocaleFlags_, DWORD _dwOpenFlags_, HANDLE * _PtrFileHandle_ ); ### Parameters #### Path Parameters * **_hStorage_** (HANDLE) - Required - Handle to an open storage. Use **CascOpenStorageEx**, **CascOpenStorage** or **CascOpenOnlineStorage** to retrieve such handle. * **_pvFileName_** (const void *) - Required - Identification of the file to open. This can be name, symbolic name, file data id, content key or an encoded key. Type of this parameter is specified in the **dwOpenFlags** parameter. * **_dwLocaleFlags_** (DWORD) - Optional - Specifies the locale flags to open the file. Only used on World of Warcraft storages. * **_dwOpenFlags_** (DWORD) - Optional - Specifies the open flags. Can be a combination of one or more flags. Note that flags **CASC_OPEN_BY_*** are mutually exclusive. * **CASC_OPEN_BY_NAME (0)**: The **pvFileName** parameter is either a file name or a symbolic name. The name is evaluated in the following order: 1. File name as-is. 2. "File######.ext" (case sensitive) - decimal numeric part converted to integer (File Data Id). 3. "FILE######.ext" (case sensitive) - hexadecimal numeric part converted to integer (File Data Id). 4. Hexa string of length 0x20 - converted to 16-byte file key (Content Key or Encoded Key). * **CASC_OPEN_BY_CKEY (1)**: The **pvFileName** parameter is considered pointer to 16-byte file content key. * **CASC_OPEN_BY_EKEY (2)**: The **pvFileName** parameter is considered pointer to 16-byte file encoded key. * **CASC_OPEN_BY_FILEID (3)**: The **pvFileName** parameter is cast to unsigned integer and considered to be a File Data Id. Use the **CASC_FILE_DATA_ID(FileDataId)** macro. * **CASC_STRICT_DATA_CHECK (0x00000010)**: All data read will be verified by MD5. Slows reading operations. * **CASC_OVERCOME_ENCRYPTED (0x00000020)**: Skips encrypted file segments with unknown keys and returns zeroed areas. * **_PtrFileHandle_** (HANDLE *) - Output - Pointer to a HANDLE variable that receives the file handle on success. ### Return Value * **true**: On success. * **false**: On failure. **GetLastError()** returns the error code. ### Request Example Opening a file by name: ```c CascOpenFile(hStorage, "mods/heromods/murky.stormmod/base.stormdata/gamedata/buttondata.xml", 0, 0, &hFile); ``` Opening a file by file data ID: ```c // All these lines open the same file: "dbfilesclient\battlepetspeciesstate.db2" CascOpenFile(hStorage, "File801581.dat", 0, 0, &hFile); CascOpenFile(hStorage, "FILE000C3B2D.dat", 0, 0, &hFile); CascOpenFile(hStorage, CASC_FILE_DATA_ID(801581), 0, CASC_OPEN_BY_FILEID, &hFile); ``` ``` -------------------------------- ### Open Online CASC Storage Source: http://www.zezula.net/en/casc/casclib/cascopenstorage.html Use CascOpenOnlineStorage to open an online CASC storage. The szParams string requires a local cache folder, an optional CDN server URL, the code name of the storage, and an optional region. The dwLocaleMask parameter is only relevant for World of Warcraft storages. ```c bool WINAPI CascOpenOnlineStorage( LPCTSTR _szParams_, DWORD _dwLocaleMask_, HANDLE * _phStorage_ ); ``` -------------------------------- ### CascGetFileSize and CascGetFileSize64 Source: http://www.zezula.net/en/casc/casclib/cascgetfilesize.html Functions to retrieve the size of a file in a CASC storage. CascGetFileSize64 is available since CascLib version 1.60. ```APIDOC ## CascGetFileSize and CascGetFileSize64 ### Description Functions **CascGetFileSize** and **CascGetFileSize64** retrieve size of a file in the storage. The function **CascGetFileSize64** is available since CascLib version **1.60**. ### Parameters #### CascGetFileSize Parameters - **_hFile_** (HANDLE) - Required - Handle to an open file. - **_PtrFileSizeHigh_** (PDWORD) - Optional - Pointer to high 32-bits of the file size. #### CascGetFileSize64 Parameters - **_hFile_** (HANDLE) - Required - Handle to an open file. - **_PtrFileSize_** (PULONGLONG) - Required - Pointer to a 64-bit variable that receives the file size. ### Return Value #### CascGetFileSize Return Value - On success, the function returns lower 32-bits of the file size. - On failure, the function returns **CASC_INVALID_SIZE** and **GetLastError()** returns an error code. #### CascGetFileSize64 Return Value - On success, the function returns **true**. - On failure, the function returns **false** and **GetLastError()** returns an error code. ``` -------------------------------- ### CascLib File Operations Source: http://www.zezula.net/en/casc/casclib.html Functions for opening, reading, and managing files within a CASC storage. ```APIDOC ## CascOpenFile ### Description Opens a file from a storage. ## CascGetFileSize / CascGetFileSize64 ### Description Retrieves the size of the file within storage. ## CascSetFilePointer / CascSetFilePointer64 ### Description Sets a new position within a file. ## CascReadFile ### Description Reads data from the file. ## CascGetFileInfo ### Description Retrieves information about an open file within storage. ## CascCloseFile ### Description Closes an open file. ``` -------------------------------- ### Retrieve CASC file size Source: http://www.zezula.net/en/casc/casclib/cascgetfilesize.html Use these functions to obtain the size of an open file. CascGetFileSize64 is recommended for files larger than 4GB and requires CascLib 1.60 or later. ```cpp **DWORD WINAPI CascGetFileSize(** **HANDLE** _hFile_, // Handle to an open file **PDWORD** _PtrFileSizeHigh_ // Optional pointer to high 32-bits of the file size **);** **bool WINAPI CascGetFileSize64(** **HANDLE** _hFile_, // Handle to an open file **PULONGLONG** _PtrFileSize_ // Pointer to a 64-bit variable that receives the file size **);** ``` -------------------------------- ### CascGetFileInfo Function Signature Source: http://www.zezula.net/en/casc/casclib/cascgetfileinfo.html The function prototype for retrieving file information from an open CASC file handle. ```cpp **bool WINAPI CascGetFileInfo(** **HANDLE** _hFile_ // Handle to an open file **CASC_FILE_INFO_CLASS** _InfoClass_ // Specifies which type of file info to get **void *** _pvFileInfo_, // Pointer to buffer that receives the file info **size_t** _cbFileInfo_, // Length of buffer pointed by pvFileInfo **size_t** * _pcbLengthNeeded_ // Pointer to a variable that receives the length of the file info **);** ``` -------------------------------- ### CascOpenFile Function Signature Source: http://www.zezula.net/en/casc/casclib/cascopenfile.html The function prototype for opening a file within a storage handle. ```cpp **bool WINAPI CascOpenFile(** **HANDLE** _hStorage_, // Handle to an open storage **const void *** _pvFileName_, // Identification of the file to open **DWORD** _dwLocaleFlags_, // Specifies the locale flags to open the file **DWORD** _dwOpenFlags_, // Specifies the open flags **HANDLE *** _PtrFileHandle_ // Pointer to a HANDLE variable that receives file handle **);** ``` -------------------------------- ### CascGetFileInfo Function Source: http://www.zezula.net/en/casc/casclib/cascgetfileinfo.html Retrieves various information about an open CASC file. ```APIDOC ## CascGetFileInfo ### Description Function **CascGetFileInfo** retrieves various information about an open file. The file must have been open by a previous call to CascOpenFile. ### Method `bool WINAPI CascGetFileInfo( HANDLE _hFile_, CASC_FILE_INFO_CLASS _InfoClass_, void * _pvFileInfo_, size_t _cbFileInfo_, size_t * _pcbLengthNeeded_ );` ### Parameters #### Path Parameters * **hFile** (HANDLE) - [in] Handle to an open CASC file. * **InfoClass** (CASC_FILE_INFO_CLASS) - [in] Specifies the type of information to be returned about the file, in the buffer that _pvFileInfo_ points to. * `CascFileContentKey`: 16-byte value of file content key. A content key is a MD5 hash of the plain (decoded) file data. Note: Content key must not be present for all files in the storage. An example is Warcraft III storages, where most of the files are referenced by Encoded key. * `CascFileEncodedKey`: 16-byte value of file encoded key. An encoded key is MD5 hash of the encoded file headers. Note: Encoded key must not have full 16 byte length. In such case, the data returned is padded by zeros. * `CascFileFullInfo`: A **CASC_FILE_FULL_INFO** structure. * `CascFileSpanInfo`: A **CASC_FILE_SPAN_INFO** structure. * **pvFileInfo** (void *) - [out] Pointer to a caller-allocated buffer into which the routine writes the requested information about the file object. The _InfoClass_ parameter specifies the type of information that the caller requests. * **cbFileInfo** (size_t) - [in] The size, in bytes, of the buffer pointed to by _pvFileInfo_. * **pcbLengthNeeded** (size_t *) - [out, optional] If non-NULL, this parameter points to a _size_t_ variable that receives the number of bytes that is needed for storing the entire information. This information can be used to allocate buffer big enough to hold the given file information. ### Return Value On success, the function returns true. On failure, the function returns false and **GetLastError()** returns the error code. ### Request Example ```c++ PCASC_FILE_SPAN_INFO GetFileSpanInfo(HANDLE hFile) { PCASC_FILE_SPAN_INFO pSpans = NULL; size_t cbLength = 0; // Retrieve the full file info CascGetFileInfo(hFile, CascFileSpanInfo, pSpans, cbLength, &cbLength); if(cbLength != 0) { if((pSpans = (PCASC_FILE_SPAN_INFO)(new BYTE[cbLength])) != NULL) { if(CascGetFileInfo(hFile, CascFileSpanInfo, pSpans, cbLength, NULL)) return pSpans; CASC_FREE(pSpans); pSpans = NULL; } } return pSpans; } ``` ``` -------------------------------- ### CascFindNextFile Function Signature Source: http://www.zezula.net/en/casc/casclib/cascfindnextfile.html The function signature for continuing a file search in CascLib. ```cpp **bool WINAPI CascFindNextFile(** **HANDLE** _hFind_, // A valid search handle **PCASC_FIND_DATA** _pFindData_ // Pointer to a CASC_FIND_DATA structure **);** ``` -------------------------------- ### CascFindEncryptionKey Source: http://www.zezula.net/en/casc/casclib/cascfindencryptionkey.html Finds an encryption key in an open CASC storage. ```APIDOC ## CascFindEncryptionKey ### Description Finds an encryption key within an open CASC storage. ### Parameters - **hStorage** (HANDLE) - Required - Handle to an open CASC storage. - **KeyName** (ULONGLONG) - Required - Identifier of the key being searched. ### Return Value - On success, returns a pointer to the stored encryption key. - On failure, returns NULL. ``` -------------------------------- ### CascSetFilePointer and CascSetFilePointer64 Source: http://www.zezula.net/en/casc/casclib/cascsetfilepointer.html These functions allow you to change the current read position within an open CASC file. CascSetFilePointer64 is available since CascLib version 1.60. ```APIDOC ## CascSetFilePointer and CascSetFilePointer64 ### Description Functions **CascSetFilePointer** and **CascSetFilePointer64** change the current read position within an open CASC file. The function **CascSetFilePointer64** is available since CascLib version **1.60**. ### Method `DWORD WINAPI CascSetFilePointer(HANDLE _hFile, LONG _lFilePos, LONG * _PtrFilePosHigh, DWORD _dwMoveMethod);` `bool WINAPI CascSetFilePointer64(HANDLE _hFile, LONGLONG _DistanceToMove, PULONGLONG _PtrNewPos, DWORD _dwMoveMethod);` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters for CascSetFilePointer: #### Path Parameters None #### Query Parameters None #### Request Body None #### Parameters for CascSetFilePointer: - **hFile** (HANDLE) - Required - Handle to an open CASC file. - **lFilePos** (LONG) - Required - Low-order 32 bits of a signed value that specifies the number of bytes to move the file pointer. If PtrFilePosHigh is not NULL, PtrFilePosHigh[0] and lFilePos form a single 64-bit signed value that specifies the distance to move. If PtrFilePosHigh is NULL, lFilePos is a 32-bit signed value. A positive value for lFilePos moves the file pointer forward in the file, and a negative value moves the file pointer back. - **PtrFilePosHigh** (LONG *) - Optional - A pointer to the high order 32-bits of the signed 64-bit distance to move. If you do not need the high order 32-bits, this pointer must be set to NULL. When not NULL, this parameter also receives the high order DWORD of the new value of the file pointer. - **dwMoveMethod** (DWORD) - Required - The starting point for the file pointer move. This parameter can be one of the following values: FILE_BEGIN (0), FILE_CURRENT (1), FILE_END (2). ### Parameters for CascSetFilePointer64: #### Path Parameters None #### Query Parameters None #### Request Body None - **hFile** (HANDLE) - Required - Handle to an open CASC file. - **DistanceToMove** (LONGLONG) - Required - The number of bytes to move the file pointer. A positive value moves the pointer forward in the file and a negative value moves the file pointer backward. - **PtrNewPos** (PULONGLONG) - Optional - A pointer to a variable to receive the new file pointer. If this parameter is NULL, the new file pointer is not returned. - **dwMoveMethod** (DWORD) - Required - The starting point for the file pointer move. This parameter can be one of the following values: FILE_BEGIN (0), FILE_CURRENT (1), FILE_END (2). ### Request Example None ### Response #### Success Response (200) #### Response for CascSetFilePointer: - **Return Value** (DWORD) - On success, returns the lower 32 bits of the new file position. On failure, returns CASC_INVALID_POS and GetLastError() returns an error code. #### Response for CascSetFilePointer64: - **Return Value** (bool) - On success, returns true. On failure, returns false and GetLastError() returns an error code. #### Response Example None ``` -------------------------------- ### CascLib File Searching Source: http://www.zezula.net/en/casc/casclib.html Functions for searching files within a CASC storage. ```APIDOC ## CascFindFirstFile ### Description Finds the first file matching the specification. ## CascFindNextFile ### Description Finds the next file matching the specification. ## CascFindClose ### Description Stops searching in the storage. ``` -------------------------------- ### CascOpenStorageEx Function Signature Source: http://www.zezula.net/en/casc/casclib/cascopenstorageex.html This is the function signature for CascOpenStorageEx. It opens a CASC storage, supporting both local and online types based on the bOnlineStorage parameter. ```cpp bool WINAPI CascOpenStorageEx( LPCTSTR _szParams_, PCASC_OPEN_STORAGE_ARGS _pArgs_, bool _bOnlineStorage_, HANDLE * _phStorage_ ); ``` -------------------------------- ### CascFindEncryptionKey Function Signature Source: http://www.zezula.net/en/casc/casclib/cascfindencryptionkey.html Use this function to retrieve an encryption key by its name from an open storage handle. ```cpp **LPBYTE WINAPI CascFindEncryptionKey(** **HANDLE** _hStorage_, // Handle to an open storage **ULONGLONG** _KeyName_ // "Name" of the key **);** ``` -------------------------------- ### CascFindClose Source: http://www.zezula.net/en/casc/casclib/cascfindclose.html Closes a search handle that has been created by CascFindFirstFile. ```APIDOC ## CascFindClose ### Description Closes a search handle that has been created by CascFindFirstFile. ### Parameters #### Path Parameters - **hFind** (HANDLE) - Required - A valid search handle that was obtained by a successful call to CascFindFirstFile. ### Response #### Success Response (True) - **bool** - Returns true on success. #### Failure Response (False) - **bool** - Returns FALSE on failure, with GetLastError() providing the error code. ``` -------------------------------- ### Add Encryption Key to CASC Storage Source: http://www.zezula.net/en/casc/casclib/cascaddencryptionkey.html Use CascAddEncryptionKey to insert a new encryption key into a CASC storage structure. This is useful for incorporating newly discovered keys without modifying the CascLib library itself. Ensure the key is 16 bytes long. ```c bool WINAPI CascAddEncryptionKey( HANDLE _hStorage_, ULONGLONG _KeyName_, LPBYTE _Key_ ); ``` -------------------------------- ### CascReadFile Function Source: http://www.zezula.net/en/casc/casclib/cascreadfile.html Reads data from a CASC file. It can handle partial reads and returns the number of bytes actually read. ```APIDOC ## CascReadFile ### Description Reads data from a CASC file. ### Method `bool WINAPI CascReadFile(HANDLE _hFile, void *_lpBuffer, DWORD _dwToRead, DWORD *_pdwRead)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c // Example usage (conceptual) HANDLE hFile = CascOpenFile("path/to/your/file.dat"); char buffer[1024]; DWORD bytesRead; if (CascReadFile(hFile, buffer, sizeof(buffer), &bytesRead)) { // Data read successfully } CascCloseFile(hFile); ``` ### Response #### Success Response (true) - **bool** (true) - Indicates that the function executed successfully. #### Failure Response (false) - **bool** (false) - Indicates that the function failed. `GetLastError()` can be called to retrieve the error code. #### Response Example ```json { "success": true } ``` ### Remarks If at least some bytes were read (even if less than requested), the function still returns success. This is useful for reading partially encrypted files. The function reads as much as it can and returns the number of bytes actually read. ```