aboutsummaryrefslogtreecommitdiff
path: root/dep/CascLib/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2019-06-09 21:14:42 +0200
committerShauren <shauren.trinity@gmail.com>2019-06-09 21:14:42 +0200
commit138e822d859fd9ff9d79e1ce16823992ad43aec4 (patch)
treef1e22a1afbaa3457e6169146f350c91b9493f926 /dep/CascLib/src
parentc4f11447546836844ade509991b4219c88ebaaa3 (diff)
Dep/CascLib: Update to ladislav-zezula/CascLib@03a3bcaed285ab0d8ff0845a65ffe7d1fa653960
Diffstat (limited to 'dep/CascLib/src')
-rw-r--r--dep/CascLib/src/CascCommon.h1
-rw-r--r--dep/CascLib/src/CascDecrypt.cpp3
-rw-r--r--dep/CascLib/src/CascLib.h44
-rw-r--r--dep/CascLib/src/CascOpenFile.cpp5
-rw-r--r--dep/CascLib/src/CascReadFile.cpp10
-rw-r--r--dep/CascLib/src/CascRootFile_MNDX.cpp (renamed from dep/CascLib/src/CascRootFile_Mndx.cpp)0
-rw-r--r--dep/CascLib/src/common/Common.cpp29
-rw-r--r--dep/CascLib/src/common/Common.h9
-rw-r--r--dep/CascLib/src/common/Csv.h2
9 files changed, 62 insertions, 41 deletions
diff --git a/dep/CascLib/src/CascCommon.h b/dep/CascLib/src/CascCommon.h
index 3ce527061c2..f32be935352 100644
--- a/dep/CascLib/src/CascCommon.h
+++ b/dep/CascLib/src/CascCommon.h
@@ -342,6 +342,7 @@ struct TCascFile
DWORD bVerifyIntegrity:1; // If true, then the data are validated more strictly when read
DWORD bDownloadFileIf:1; // If true, then the data will be downloaded from the online storage if missing
DWORD bLocalFileStream:1; // If true, then the file stream is a local file
+ DWORD bOvercomeEncrypted:1; // If true, then CascReadFile will fill the part that is encrypted (and key was not found) with zeros
LPBYTE pbFileCache; // Pointer to file cache
DWORD cbFileCache; // Size of the file cache
diff --git a/dep/CascLib/src/CascDecrypt.cpp b/dep/CascLib/src/CascDecrypt.cpp
index 043d8effa66..42bf3084801 100644
--- a/dep/CascLib/src/CascDecrypt.cpp
+++ b/dep/CascLib/src/CascDecrypt.cpp
@@ -480,6 +480,9 @@ int CascDirectCopy(LPBYTE pbOutBuffer, PDWORD pcbOutBuffer, LPBYTE pbInBuffer, D
return ERROR_SUCCESS;
}
+//-----------------------------------------------------------------------------
+// Public functions
+
bool WINAPI CascAddEncryptionKey(HANDLE hStorage, ULONGLONG KeyName, LPBYTE Key)
{
PCASC_ENCRYPTION_KEY pEncKey;
diff --git a/dep/CascLib/src/CascLib.h b/dep/CascLib/src/CascLib.h
index 9695ad7429a..52451ac8f20 100644
--- a/dep/CascLib/src/CascLib.h
+++ b/dep/CascLib/src/CascLib.h
@@ -27,6 +27,49 @@ extern "C" {
#endif
//-----------------------------------------------------------------------------
+// Use the apropriate library
+//
+// The library type is encoded in the library name as the following
+// CascLibXYZ.lib
+//
+// X - D for Debug version, R for Release version
+// Y - A for ANSI version, U for Unicode version
+// Z - S for static-linked CRT library, D for multithreaded DLL CRT library
+//
+#if defined(_MSC_VER) && !defined(__CASCLIB_SELF__) && !defined(CASCLIB_NO_AUTO_LINK_LIBRARY)
+
+ #ifdef _DEBUG // DEBUG VERSIONS
+ #ifndef _UNICODE
+ #ifdef _DLL
+ #pragma comment(lib, "CascLibDAD.lib") // Debug Ansi CRT-DLL version
+ #else
+ #pragma comment(lib, "CascLibDAS.lib") // Debug Ansi CRT-LIB version
+ #endif
+ #else
+ #ifdef _DLL
+ #pragma comment(lib, "CascLibDUD.lib") // Debug Unicode CRT-DLL version
+ #else
+ #pragma comment(lib, "CascLibDUS.lib") // Debug Unicode CRT-LIB version
+ #endif
+ #endif
+ #else // RELEASE VERSIONS
+ #ifndef _UNICODE
+ #ifdef _DLL
+ #pragma comment(lib, "CascLibRAD.lib") // Release Ansi CRT-DLL version
+ #else
+ #pragma comment(lib, "CascLibRAS.lib") // Release Ansi CRT-LIB version
+ #endif
+ #else
+ #ifdef _DLL
+ #pragma comment(lib, "CascLibRUD.lib") // Release Unicode CRT-DLL version
+ #else
+ #pragma comment(lib, "CascLibRUS.lib") // Release Unicode CRT-LIB version
+ #endif
+ #endif
+ #endif
+
+#endif
+//-----------------------------------------------------------------------------
// Defines
#define CASCLIB_VERSION 0x0132 // Current version of CascLib (1.50)
@@ -40,6 +83,7 @@ extern "C" {
#define CASC_OPEN_TYPE_MASK 0x0000000F // The mask which gets open type from the dwFlags
#define CASC_OPEN_FLAGS_MASK 0xFFFFFFF0 // The mask which gets open type from the dwFlags
#define CASC_STRICT_DATA_CHECK 0x00000010 // Verify all data read from a file
+#define CASC_OVERCOME_ENCRYPTED 0x00000020 // When CascReadFile encounters a block encrypted with a key that is missing, the block is filled with zeros and returned as success
#define CASC_LOCALE_ALL 0xFFFFFFFF
#define CASC_LOCALE_NONE 0x00000000
diff --git a/dep/CascLib/src/CascOpenFile.cpp b/dep/CascLib/src/CascOpenFile.cpp
index 741ab1e1005..45d10bc18f1 100644
--- a/dep/CascLib/src/CascOpenFile.cpp
+++ b/dep/CascLib/src/CascOpenFile.cpp
@@ -36,8 +36,9 @@ bool OpenFileByCKeyEntry(TCascStorage * hs, PCASC_CKEY_ENTRY pCKeyEntry, DWORD d
// Create the file handle structure
if((hf = new TCascFile(hs, pCKeyEntry)) != NULL)
{
- hf->bVerifyIntegrity = (dwOpenFlags & CASC_STRICT_DATA_CHECK) ? true : false;
- hf->bDownloadFileIf = (hs->dwFeatures & CASC_FEATURE_ONLINE) ? true : false;
+ hf->bVerifyIntegrity = (dwOpenFlags & CASC_STRICT_DATA_CHECK) ? true : false;
+ hf->bDownloadFileIf = (hs->dwFeatures & CASC_FEATURE_ONLINE) ? true : false;
+ hf->bOvercomeEncrypted = (dwOpenFlags & CASC_OVERCOME_ENCRYPTED) ? true : false;
nError = ERROR_SUCCESS;
}
else
diff --git a/dep/CascLib/src/CascReadFile.cpp b/dep/CascLib/src/CascReadFile.cpp
index 2720d6d5adb..2f444d0d80f 100644
--- a/dep/CascLib/src/CascReadFile.cpp
+++ b/dep/CascLib/src/CascReadFile.cpp
@@ -791,6 +791,16 @@ bool WINAPI CascReadFile(HANDLE hFile, void * pvBuffer, DWORD dwBytesToRead, PDW
pbEncodedFrame,
pFrame->EncodedSize,
(DWORD)(pFrame - hf->pFrames));
+
+ // Some people find it handy to extract data from partially encrypted file,
+ // even at the cost producing files that are corrupt.
+ // We overcome missing decryption key by zeroing the encrypted portions
+ if(nError == ERROR_FILE_ENCRYPTED && hf->bOvercomeEncrypted)
+ {
+ memset(pbDecodedFrame, 0, pFrame->ContentSize);
+ nError = ERROR_SUCCESS;
+ }
+
if (nError == ERROR_SUCCESS)
{
// Mark the frame as loaded
diff --git a/dep/CascLib/src/CascRootFile_Mndx.cpp b/dep/CascLib/src/CascRootFile_MNDX.cpp
index 9dca8d30eb4..9dca8d30eb4 100644
--- a/dep/CascLib/src/CascRootFile_Mndx.cpp
+++ b/dep/CascLib/src/CascRootFile_MNDX.cpp
diff --git a/dep/CascLib/src/common/Common.cpp b/dep/CascLib/src/common/Common.cpp
index d545f52f84a..fafa00e7739 100644
--- a/dep/CascLib/src/common/Common.cpp
+++ b/dep/CascLib/src/common/Common.cpp
@@ -79,35 +79,6 @@ void SetLastError(DWORD dwErrCode)
#endif
//-----------------------------------------------------------------------------
-// Overloaded "new" and "delete" operators
-
-void * operator new(size_t size)
-{
- return CASC_ALLOC(BYTE, size);
-}
-
-void * operator new[](size_t size)
-{
- return CASC_ALLOC(BYTE, size);
-}
-
-void operator delete(void * ptr)
-{
- CASC_FREE(ptr);
-}
-
-void operator delete[](void * ptr)
-{
- CASC_FREE(ptr);
-}
-
-// For some reason, VS2015 needs this
-void operator delete(void * ptr, size_t)
-{
- CASC_FREE(ptr);
-}
-
-//-----------------------------------------------------------------------------
// Linear data stream manipulation
LPBYTE CaptureInteger32(LPBYTE pbDataPtr, LPBYTE pbDataEnd, PDWORD PtrValue)
diff --git a/dep/CascLib/src/common/Common.h b/dep/CascLib/src/common/Common.h
index c7f189b91ac..705777b7b0b 100644
--- a/dep/CascLib/src/common/Common.h
+++ b/dep/CascLib/src/common/Common.h
@@ -123,15 +123,6 @@ void CASC_FREE(T *& ptr)
}
//-----------------------------------------------------------------------------
-// Overloaded "new" and "delete" operators
-
-void * operator new(size_t size);
-void * operator new[](size_t size);
-void operator delete(void * ptr);
-void operator delete[](void * ptr);
-void operator delete(void * ptr, size_t); // For some reason, VS2015 needs this
-
-//-----------------------------------------------------------------------------
// Big endian number manipulation
inline DWORD ConvertBytesToInteger_2(LPBYTE ValueAsBytes)
diff --git a/dep/CascLib/src/common/Csv.h b/dep/CascLib/src/common/Csv.h
index 2138255e74e..bf1a7413e13 100644
--- a/dep/CascLib/src/common/Csv.h
+++ b/dep/CascLib/src/common/Csv.h
@@ -16,7 +16,7 @@
#define CSV_INVALID_INDEX ((size_t)(-1))
#define CSV_ZERO ((size_t)(0)) // Use Csv[0][CSV_ZERO] instead of ambiguous Csv[0][0]
-#define CSV_MAX_COLUMNS 0x10
+#define CSV_MAX_COLUMNS 0x20
#define CSV_HASH_TABLE_SIZE 0x80
//-----------------------------------------------------------------------------