From 3a2ebae8694f4df166c862d8a0a308454e342fdd Mon Sep 17 00:00:00 2001 From: icex2 Date: Sun, 25 Feb 2024 09:36:53 +0100 Subject: [PATCH] feat(launcher): Improve error output when missing vcredist deps Apply a simple heuristic to provide the user with more specific information regarding which vcredist package might not have been found on their system. This is a common problem as different games require different versions and different versions of windows and installations might already come with some versions already pre-installed. Also improve the readme regarding that and provide links to all versions that are required by one game or another today. --- README.md | 39 ++++++++++++++++++++++++++------------ dist/dwarfstack/readme.md | 2 +- src/main/launcher/module.c | 38 ++++++++++++++++++++++++++++++++++++- 3 files changed, 65 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 6827f95..4c581a7 100644 --- a/README.md +++ b/README.md @@ -148,21 +148,36 @@ helpful or important to know and should be added. ### Setup and dependencies -Most (older generation) games were developed for Windows XP Embedded but should run fine on any -consumer version of Windows XP. Newer versions of Windows, e.g. Windows 7, 8 and 10, should be fine -as well. Some hooks also include fixes required to run the games on a more recent version. +The games bemanitools support span several generations of (embedded) Windows versions: XP, 7 and 10 +(IoT). With these come different generations of dependencies as requirements. -Depending on the game, you also need the following dependencies installed: +Simplified, this boils down to the following list of C++ Redistributable (vcredist) packages that +are recommended to be installed without going into detail which game needs exactly which version. +Keep in mind the "bitness" (32-bit vs. 64-bit) of each specific game and download the right ones +accordingly. -- The 32-bit (x86) version of - [Microsoft Visual C++ 2010 Service Pack 1 Redistributable Package MFC Security Update](https://www.microsoft.com/en-sg/download/details.aspx?id=26999) -- The 32-bit (x86) and 64-bit (x64) versions of - [Microsoft Visual C++ Redistributable Packages for Visual Studio 2013](https://www.microsoft.com/en-sg/download/details.aspx?id=40784) -- The - [DirectX 9 End-User Runtimes (June 2010)](https://www.microsoft.com/en-us/download/details.aspx?id=8109) +You can use a tool like [dependencywalker](https://www.dependencywalker.com/) to figure that out if +it is relevant to you. -See also [bemanitools-supplement](https://www.github.com/djhackersdev/bemanitools-supplement/) for -files. +Links/files are also provided by +[bemanitools-supplement](https://github.com/djhackersdev/bemanitools-supplement/tree/master/misc/win-runtime#windows-runtimes-and-libraries) + +#### Visual C++ Redistributable Packages + +- 2010 + - [32-bit (x86)](http://download.microsoft.com/download/5/B/C/5BC5DBB3-652D-4DCE-B14A-475AB85EEF6E/vcredist_x86.exe) + - [64-bit (x64)](http://download.microsoft.com/download/d/2/4/d242c3fb-da5a-4542-ad66-f9661d0a8d19/vcredist_x64.exe) +- 2013 + - [32-bit (x86)](http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x86.exe) + - [64-bit (x64)](http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe) +- 2015 + - [32-bit (x86)](https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x86.exe) + - [64-bit (x64)](https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x64.exe) + +#### DirectX 9 + +Most/nearly all games support to this day use the DirectX 9(ex) API. Make sure to install the +[DirectX 9 End-User Runtimes (June 2010)](https://www.microsoft.com/en-us/download/details.aspx?id=8109) ## Development diff --git a/dist/dwarfstack/readme.md b/dist/dwarfstack/readme.md index c8ce1e3..03c8320 100644 --- a/dist/dwarfstack/readme.md +++ b/dist/dwarfstack/readme.md @@ -1 +1 @@ -Version/release: https://github.com/ssbssa/dwarfstack/releases/tag/2.2 \ No newline at end of file +Version/release: https://github.com/ssbssa/dwarfstack/releases/tag/2.2 diff --git a/src/main/launcher/module.c b/src/main/launcher/module.c index c0b9ef4..ff291ff 100644 --- a/src/main/launcher/module.c +++ b/src/main/launcher/module.c @@ -16,6 +16,20 @@ #define MM_ALLOCATION_GRANULARITY 0x10000 +static bool _module_dependency_available(const char *lib) +{ + HMODULE module; + + module = LoadLibraryA(lib); + + if (module == NULL) { + return false; + } else { + FreeLibrary(module); + return true; + } +} + static bool module_replace_dll_iat(HMODULE hModule, const struct array *iat_hook_dlls) { @@ -141,7 +155,7 @@ void module_init(struct module_context *module, const char *path) log_info("init: %s", path); - module->dll = LoadLibrary(path); + module->dll = LoadLibraryA(path); if (module->dll == NULL) { LPSTR buffer; @@ -160,6 +174,28 @@ void module_init(struct module_context *module, const char *path) if (err == ERROR_MOD_NOT_FOUND) { log_warning("%s is likely missing dependencies", path); log_warning("Do you have vcredist/directx runtimes installed?"); + log_warning( + "Ensure the installed dependencies match the architecture, " + "32-bit/64-bit, of the game"); + log_warning( + "Running heuristic for commonly used libraries (actual " + "requirements depend on game)..."); + + if (_module_dependency_available("d3d9.dll")) { + log_warning("Could not find directx9 runtime"); + } + + if (_module_dependency_available("msvcr100.dll")) { + log_warning("Could not find vcredist 2010 runtime"); + } + + if (_module_dependency_available("msvcr120.dll")) { + log_warning("Could not find vcredist 2013 runtime"); + } + + if (_module_dependency_available("msvcp140.dll")) { + log_warning("Could not find vcredist 2015 runtime"); + } } log_fatal("%s: Failed to load game DLL: %s", path, buffer);