aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLadislav Zezula <zezula@volny.cz>2020-03-25 14:19:09 +0100
committerLadislav Zezula <zezula@volny.cz>2020-03-25 14:19:09 +0100
commit468292a0c4f0febef52337ba1f2d9e3f76ccac63 (patch)
treeb5f8443624e075d45deaba9d8b66a554254d0165
parent84b1d23457124dede5856f2d6fa4dcbf682a06fe (diff)
MIX files are now considered Watctaft III maps
-rw-r--r--src/SFileOpenArchive.cpp20
-rw-r--r--test/StormTest.cpp6
2 files changed, 23 insertions, 3 deletions
diff --git a/src/SFileOpenArchive.cpp b/src/SFileOpenArchive.cpp
index 9307cd8..b4facd8 100644
--- a/src/SFileOpenArchive.cpp
+++ b/src/SFileOpenArchive.cpp
@@ -41,12 +41,25 @@ static bool IsWarcraft3Map(DWORD * HeaderData)
return (DwordValue0 == 0x57334D48 && DwordValue1 == 0x00000000);
}
+static bool IsDllFile(LPBYTE pbHeaderBuffer, size_t cbBytesAvailable)
+{
+ // MIX files are DLL files that contain MPQ in overlay.
+ // Only Warcraft III is able to load them, so we consider them MPQs v 1.0
+ if(cbBytesAvailable > 0x200 && pbHeaderBuffer[0] == 'M' && pbHeaderBuffer[1] == 'Z')
+ {
+ DWORD e_lfanew = *(PDWORD)(pbHeaderBuffer + 0x3C);
+ if(0 < e_lfanew && e_lfanew < 0x10000)
+ return true;
+ }
+ return false;
+}
+
static TMPQUserData * IsValidMpqUserData(ULONGLONG ByteOffset, ULONGLONG FileSize, void * pvUserData)
{
TMPQUserData * pUserData;
// BSWAP the source data and copy them to our buffer
- BSWAP_ARRAY32_UNSIGNED(&pvUserData, sizeof(TMPQUserData));
+ BSWAP_ARRAY32_UNSIGNED(pvUserData, sizeof(TMPQUserData));
pUserData = (TMPQUserData *)pvUserData;
// Check the sizes
@@ -260,7 +273,10 @@ bool WINAPI SFileOpenArchive(
break;
}
- bIsWarcraft3Map = IsWarcraft3Map((DWORD *)pbHeaderBuffer);
+ if (IsWarcraft3Map((DWORD *)pbHeaderBuffer))
+ bIsWarcraft3Map = true;
+ if (IsDllFile(pbHeaderBuffer, dwBytesAvailable))
+ bIsWarcraft3Map = true;
}
// Search the header buffer
diff --git a/test/StormTest.cpp b/test/StormTest.cpp
index 6b30629..4ed51cc 100644
--- a/test/StormTest.cpp
+++ b/test/StormTest.cpp
@@ -4421,7 +4421,7 @@ int _tmain(int argc, TCHAR * argv[])
// Not a test, but rather a tool for creating links to duplicated files
// if(nError == ERROR_SUCCESS)
// nError = FindFilePairs(ForEachFile_CreateArchiveLink, "2004 - WoW\\06080", "2004 - WoW\\06299");
-
+/*
// Search all testing archives and verify their SHA1 hash
if(nError == ERROR_SUCCESS)
nError = FindFiles(ForEachFile_VerifyFileChecksum, szMpqSubDir);
@@ -4540,6 +4540,10 @@ int _tmain(int argc, TCHAR * argv[])
// Open an Warcraft III map whose "(attributes)" file has (BlockTableSize-1) entries
if(nError == ERROR_SUCCESS)
nError = TestOpenArchive(_T("MPQ_2014_v1_AttributesOneEntryLess.w3x"));
+*/
+ // Open a MIX file
+ if(nError == ERROR_SUCCESS)
+ nError = TestOpenArchive(_T("MPQ_2020_v1_AHF04patch.mix"));
// Open a MPQ archive v 3.0
if(nError == ERROR_SUCCESS)