Skip to content

Commit

Permalink
Improved compatibility with pre-SP4 Win2000
Browse files Browse the repository at this point in the history
Moved the LoadLibrary call out of DllMain entry point.
Updated version number and changelog.
  • Loading branch information
NovaRain committed Aug 24, 2023
1 parent 59eacce commit 71e3ee4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 9 additions & 4 deletions sfall/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
#include "WinProc.h"

ddrawDll ddraw;
static void LoadOriginalDll(DWORD fdwReason);

namespace sfall
{
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
}
4 changes: 2 additions & 2 deletions sfall/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 71e3ee4

Please sign in to comment.