From 71e3ee4801a2a52edcc4c7c1f18c2048b25e4941 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Thu, 24 Aug 2023 21:42:27 +0800 Subject: [PATCH] Improved compatibility with pre-SP4 Win2000 Moved the LoadLibrary call out of DllMain entry point. Updated version number and changelog. --- CHANGELOG.md | 3 +++ sfall/main.cpp | 13 +++++++++---- sfall/version.h | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26dc928f1..4930c9d23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 3.8.40.1 +* Improved compatibility with older Windows 2000 (**pre-SP4**) + ## 3.8.40 * Implemented a `mods_order.txt` to improve and simplify mod ordering and add support for mod managers. This replaces previous **.dat** file autoloading. Please refer to `ddraw.ini` for details * Implemented a **custom config file parser**, which greatly improves the performance of sfall initialization and reading files from scripts diff --git a/sfall/main.cpp b/sfall/main.cpp index bc99fb5c0..bbe2bdeec 100644 --- a/sfall/main.cpp +++ b/sfall/main.cpp @@ -87,6 +87,7 @@ #include "WinProc.h" ddrawDll ddraw; +static void LoadOriginalDll(DWORD fdwReason); namespace sfall { @@ -211,6 +212,9 @@ static int CheckEXE() { static HMODULE SfallInit() { char filepath[MAX_PATH]; + + LoadOriginalDll(DLL_PROCESS_ATTACH); + GetModuleFileName(0, filepath, MAX_PATH); SetCursor(LoadCursorA(0, IDC_ARROW)); @@ -311,7 +315,7 @@ static HMODULE SfallInit() { } -static bool LoadOriginalDll(DWORD fdwReason) { +static void LoadOriginalDll(DWORD fdwReason) { switch (fdwReason) { case DLL_PROCESS_ATTACH: char path[MAX_PATH]; @@ -342,20 +346,21 @@ static bool LoadOriginalDll(DWORD fdwReason) { ddraw.ReleaseDDThreadLock = GetProcAddress(ddraw.dll, "ReleaseDDThreadLock"); ddraw.SetAppCompatData = GetProcAddress(ddraw.dll, "SetAppCompatData"); } - return true; + break; case DLL_PROCESS_DETACH: if (ddraw.dll) FreeLibrary(ddraw.dll); break; } - return false; } bool __stdcall DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) { - if (LoadOriginalDll(fdwReason)) { + if (fdwReason == DLL_PROCESS_ATTACH) { if (sfall::CheckEXE()) { ddraw.sfall = hinstDLL; sfall::MakeCall(0x4DE8DE, sfall::SfallInit); // LoadDirectX_ } + } else { + LoadOriginalDll(fdwReason); } return true; } diff --git a/sfall/version.h b/sfall/version.h index d0de4ac4c..ac41bd15a 100644 --- a/sfall/version.h +++ b/sfall/version.h @@ -25,6 +25,6 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 8 #define VERSION_BUILD 40 -#define VERSION_REV 0 +#define VERSION_REV 1 -#define VERSION_STRING "3.8.40" +#define VERSION_STRING "3.8.40.1"