From 2b735ffd5577d2dfd01b81ee6fd8182248f69007 Mon Sep 17 00:00:00 2001 From: bicarus-dev <202771338+bicarus-dev@users.noreply.github.com> Date: Fri, 2 May 2025 01:51:23 -0700 Subject: [PATCH] launcher: check for custom d3d9.dll in user's game directory (#309) ## Link to GitHub Issue, if one exists n/a ## Description of change Log a message if d3d9.dll (and friends) are found in the game root or the modules directory. This is to help with troubleshooting in cases where the user is unaware that d3d9 is being used to inject other DLLs (e.g., ifs_layeredfs), or when DX9 reimplementation is causing issues / crashes (e.g., dxvk). ## Testing Observed the new messages being logged in both modules / root directory. --- src/spice2x/launcher/launcher.cpp | 10 ++++++++++ src/spice2x/util/libutils.cpp | 12 ++++++++++++ src/spice2x/util/libutils.h | 1 + 3 files changed, 23 insertions(+) diff --git a/src/spice2x/launcher/launcher.cpp b/src/spice2x/launcher/launcher.cpp index 5652d75..82215f9 100644 --- a/src/spice2x/launcher/launcher.cpp +++ b/src/spice2x/launcher/launcher.cpp @@ -1820,6 +1820,16 @@ int main_implementation(int argc, char *argv[]) { exit(spicecfg_run(sextet_devices)); } + // log some DLLs found in path (purely for troubleshooting purposes to detect + // dxvk, ForceD3D9On12, ifs_layeredfs, etc) + libutils::warn_if_dll_exists("d3d8.dll"); + libutils::warn_if_dll_exists("d3d9.dll"); + libutils::warn_if_dll_exists("d3d10core.dll"); + libutils::warn_if_dll_exists("d3d11.dll"); + libutils::warn_if_dll_exists("d3d12.dll"); + libutils::warn_if_dll_exists("dxgi.dll"); + libutils::warn_if_dll_exists("opengl32.dll"); + // complain loudly & early about dll load ordering issue libutils::check_duplicate_dlls(); diff --git a/src/spice2x/util/libutils.cpp b/src/spice2x/util/libutils.cpp index 11509b5..52c027d 100644 --- a/src/spice2x/util/libutils.cpp +++ b/src/spice2x/util/libutils.cpp @@ -355,4 +355,16 @@ void libutils::check_duplicate_dlls() { (MODULE_PATH / filename).string()); } } +} + +void libutils::warn_if_dll_exists(const std::string &file_name) { + if (fileutils::file_exists(MODULE_PATH / file_name)) { + log_info("libutils", "found user-supplied {} in modules directory", file_name); + return; + } + const auto &spice_bin_path = libutils::module_file_name(nullptr).parent_path(); + if (fileutils::file_exists(spice_bin_path / file_name)) { + log_info("libutils", "found user-supplied {} next to spice executable path", file_name); + return; + } } \ No newline at end of file diff --git a/src/spice2x/util/libutils.h b/src/spice2x/util/libutils.h index d5123ca..305a603 100644 --- a/src/spice2x/util/libutils.h +++ b/src/spice2x/util/libutils.h @@ -25,6 +25,7 @@ namespace libutils { } void check_duplicate_dlls(); + void warn_if_dll_exists(const std::string &file_name); // get module handle helpers HMODULE get_module(const char *module_name);