From 74455db5a976dcf0ab7c05e4e843e6cbfc54037c Mon Sep 17 00:00:00 2001 From: NovaRain Date: Mon, 27 Dec 2021 10:15:41 +0800 Subject: [PATCH] Removed SkipSizeCheck from ddraw.ini * the executable file size check is also removed (mostly). --- artifacts/ddraw.ini | 4 ---- sfall/CRC.cpp | 21 +++++++++------------ 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 4f37f3c4..d730387f 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -851,10 +851,6 @@ AllowUnsafeScripting=0 ;Does not require sfall debugging mode ;ExtraCRC=0x00000000,0x00000000 -;Set to 1 to skip the executable file size check -;Does not require sfall debugging mode -SkipSizeCheck=0 - ;Set to 1 to skip the compatibility mode check SkipCompatModeCheck=0 diff --git a/sfall/CRC.cpp b/sfall/CRC.cpp index 31b17de1..c3839cbb 100644 --- a/sfall/CRC.cpp +++ b/sfall/CRC.cpp @@ -31,7 +31,7 @@ namespace sfall static const DWORD ExpectedSize = 1189888; static const DWORD ExpectedCRC[] = { 0xE1680293, // US 1.02d - 0xEF34F989 // US 1.02d + HRP + 0xEF34F989 // US 1.02d + HRP by Mash }; static void inline ExitMessageFail(const char* a) { @@ -87,22 +87,12 @@ bool CRC(const char* filepath) { HANDLE h = CreateFileA(filepath, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); if (h == INVALID_HANDLE_VALUE) { - sprintf_s(buf, "Cannot open %s for CRC check.", filepath); - ExitMessageFail(buf); + ExitMessageFail("Cannot open the game executable for CRC check."); return false; } DWORD size = GetFileSize(h, 0); - if (size != ExpectedSize && IniReader::GetIntDefaultConfig("Debugging", "SkipSizeCheck", 0) == 0) { - CloseHandle(h); - sprintf_s(buf, "You're trying to use sfall with an incompatible version of Fallout.\n" - "Was expecting '" TARGETVERSION "'.\n\n" - "%s has an unexpected size.\nExpected %d bytes but got %d bytes.", filepath, ExpectedSize, size); - ExitMessageFail(buf); - return false; - } - DWORD crc; BYTE* bytes = new BYTE[size]; ReadFile(h, bytes, size, &crc, 0); @@ -128,6 +118,13 @@ bool CRC(const char* filepath) { sprintf_s(buf, "You're trying to use sfall with an incompatible version of Fallout.\n" "Was expecting '" TARGETVERSION "'.\n\n" "%s has an unexpected CRC.\nExpected 0x%x but got 0x%x.", filepath, ExpectedCRC[0], crc); + + if (size == ExpectedSize) { + if (MessageBoxA(0, buf, "CRC mismatch", MB_TASKMODAL | MB_ICONWARNING | MB_ABORTRETRYIGNORE) != IDIGNORE) { + ExitProcess(1); + } + return true; + } ExitMessageFail(buf); } return matchedCRC;