MCPcopy Create free account
hub / github.com/diasurgical/devilution / MpqeStream_BlockRead

Function MpqeStream_BlockRead

3rdParty/StormLib/src/FileStream.cpp:2067–2093  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2065}
2066
2067static 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
2095static TFileStream * MpqeStream_Open(const TCHAR * szFileName, DWORD dwStreamFlags)
2096{

Callers

nothing calls this directly

Calls 1

DecryptFileChunkFunction · 0.85

Tested by

no test coverage detected