diff options
author | Ladislav Zezula <ladislav.zezula@avast.com> | 2021-12-17 14:51:35 +0100 |
---|---|---|
committer | Ladislav Zezula <ladislav.zezula@avast.com> | 2021-12-17 22:33:19 +0100 |
commit | 4f4f926c1a3347f7ecd18f549c4be0a1e62413ba (patch) | |
tree | f68df366a3afc64a60f48e679990e5c4504399a2 /src/SFileReadFile.cpp | |
parent | 5ced3835f9d52584bc20fb6a3a0e58069374e9af (diff) |
Support for protected SCX files
Diffstat (limited to 'src/SFileReadFile.cpp')
-rw-r--r-- | src/SFileReadFile.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/SFileReadFile.cpp b/src/SFileReadFile.cpp index 34edc06..1703748 100644 --- a/src/SFileReadFile.cpp +++ b/src/SFileReadFile.cpp @@ -663,7 +663,8 @@ static DWORD ReadMpqFileLocalFile(TMPQFile * hf, void * pvBuffer, DWORD dwFilePo bool WINAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWORD pdwRead, LPOVERLAPPED lpOverlapped) { - TMPQFile * hf = (TMPQFile *)hFile; + TFileEntry * pFileEntry; + TMPQFile * hf; DWORD dwBytesRead = 0; // Number of bytes read DWORD dwErrCode = ERROR_SUCCESS; @@ -673,7 +674,7 @@ bool WINAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWORD lpOverlapped = lpOverlapped; // Check valid parameters - if(!IsValidFileHandle(hFile)) + if((hf = IsValidFileHandle(hFile)) == NULL) { SetLastError(ERROR_INVALID_HANDLE); return false; @@ -697,6 +698,7 @@ bool WINAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWORD } // Clear the last used compression + pFileEntry = hf->pFileEntry; hf->dwCompression0 = 0; // If the file is local file, read the data directly from the stream @@ -706,7 +708,7 @@ bool WINAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWORD } // If the file is a patch file, we have to read it special way - else if(hf->hfPatch != NULL && (hf->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) == 0) + else if(hf->hfPatch != NULL && (pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) == 0) { dwErrCode = ReadMpqFilePatchFile(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead); } @@ -718,7 +720,7 @@ bool WINAPI SFileReadFile(HANDLE hFile, void * pvBuffer, DWORD dwToRead, LPDWORD } // If the file is single unit file, redirect it to read file - else if(hf->pFileEntry->dwFlags & MPQ_FILE_SINGLE_UNIT) + else if(pFileEntry->dwFlags & MPQ_FILE_SINGLE_UNIT) { dwErrCode = ReadMpqFileSingleUnit(hf, pvBuffer, hf->dwFilePos, dwToRead, &dwBytesRead); } |