From afd304b180607a68edc1613074eeaca5e8805153 Mon Sep 17 00:00:00 2001 From: Ladislav Zezula Date: Tue, 6 Jun 2023 09:50:16 +0200 Subject: Fixed loading of corrupt MPQ version 2 --- test/StormTest.cpp | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'test/StormTest.cpp') diff --git a/test/StormTest.cpp b/test/StormTest.cpp index 2f45e96..82668cf 100644 --- a/test/StormTest.cpp +++ b/test/StormTest.cpp @@ -4183,30 +4183,23 @@ int _tmain(int argc, TCHAR * argv[]) // Initialize storage and mix the random number generator printf("==== Test Suite for StormLib version %s ====\n", STORMLIB_VERSION_STRING); dwErrCode = InitializeMpqDirectory(argv, argc); -/* + // Check creation of the MPQ with LZMA compression - LPCTSTR szArchiveName = _T("E:\\new-mpq.mpq"); + LPCTSTR szArchiveName = _T("e:\\MemoryCorruption.SC2Replay"); HANDLE hFile = NULL; HANDLE hMpq = NULL; - - DeleteFile(szArchiveName); - if(SFileCreateArchive(szArchiveName, MPQ_CREATE_ARCHIVE_V2 | MPQ_CREATE_LISTFILE | MPQ_CREATE_ATTRIBUTES, 0x1000, &hMpq)) +/* + if(SFileOpenArchive(szArchiveName, 0, 0, &hMpq)) { - SFileAddFileEx(hMpq, _T("e:\\DlgSearchFile.cpp"), "DlgSearchFile.cpp", MPQ_FILE_SINGLE_UNIT | MPQ_FILE_COMPRESS, MPQ_COMPRESSION_LZMA, MPQ_COMPRESSION_NEXT_SAME); - SFileCloseArchive(hMpq); - - if(SFileOpenArchive(szArchiveName, 0, 0, &hMpq)) + if(SFileOpenFileEx(hMpq, "DlgSearchFile.cpp", 0, &hFile)) { - if(SFileOpenFileEx(hMpq, "DlgSearchFile.cpp", 0, &hFile)) - { - DWORD dwBytesRead = 0; - BYTE Buffer[0x100]; + DWORD dwBytesRead = 0; + BYTE Buffer[0x100]; - SFileReadFile(hFile, Buffer, sizeof(Buffer), &dwBytesRead, NULL); - SFileCloseFile(hFile); - } - SFileCloseArchive(hMpq); + SFileReadFile(hFile, Buffer, sizeof(Buffer), &dwBytesRead, NULL); + SFileCloseFile(hFile); } + SFileCloseArchive(hMpq); } */ #ifdef TEST_COMMAND_LINE -- cgit v1.2.3