| 2065 | } |
| 2066 | |
| 2067 | static bool MpqeStream_BlockRead( |
| 2068 | TEncryptedStream * pStream, |
| 2069 | ULONGLONG StartOffset, |
| 2070 | ULONGLONG EndOffset, |
| 2071 | LPBYTE BlockBuffer, |
| 2072 | DWORD BytesNeeded, |
| 2073 | bool bAvailable) |
| 2074 | { |
| 2075 | DWORD dwBytesToRead; |
| 2076 | |
| 2077 | assert((StartOffset & (pStream->BlockSize - 1)) == 0); |
| 2078 | assert(StartOffset < EndOffset); |
| 2079 | assert(bAvailable != false); |
| 2080 | BytesNeeded = BytesNeeded; |
| 2081 | bAvailable = bAvailable; |
| 2082 | |
| 2083 | // Read the file from the stream as-is |
| 2084 | // Limit the reading to number of blocks really needed |
| 2085 | dwBytesToRead = (DWORD)(EndOffset - StartOffset); |
| 2086 | if(!pStream->BaseRead(pStream, &StartOffset, BlockBuffer, dwBytesToRead)) |
| 2087 | return false; |
| 2088 | |
| 2089 | // Decrypt the data |
| 2090 | dwBytesToRead = (dwBytesToRead + MPQE_CHUNK_SIZE - 1) & ~(MPQE_CHUNK_SIZE - 1); |
| 2091 | DecryptFileChunk((LPDWORD)BlockBuffer, pStream->Key, StartOffset, dwBytesToRead); |
| 2092 | return true; |
| 2093 | } |
| 2094 | |
| 2095 | static TFileStream * MpqeStream_Open(const TCHAR * szFileName, DWORD dwStreamFlags) |
| 2096 | { |
nothing calls this directly
no test coverage detected