From a48ea69ece86291ec77963f4153140c245f51f8e Mon Sep 17 00:00:00 2001 From: FakeMichau <49685661+FakeMichau@users.noreply.github.com> Date: Sun, 3 May 2026 00:40:43 +0200 Subject: [PATCH] Always resolve MainDllPath into an absolute path Should fix FindFilePath sometimes not picking up DLSS when manually setting OptiDllPath --- OptiScaler/dllmain.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/OptiScaler/dllmain.cpp b/OptiScaler/dllmain.cpp index 1727e389..ef7647c5 100644 --- a/OptiScaler/dllmain.cpp +++ b/OptiScaler/dllmain.cpp @@ -1751,22 +1751,25 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv // Main Opti DLL path if (!Config::Instance()->MainDllPath.has_value()) { - Config::Instance()->MainDllPath.set_volatile_value(Util::ExePath().parent_path() / L"."); - - Config::Instance()->MainDllPath.set_volatile_value( - std::filesystem::absolute(Config::Instance()->MainDllPath.value())); + Config::Instance()->MainDllPath.set_volatile_value(L"OptiScaler"); } - // If path is not correct + if (std::filesystem::path mainDllPath(Config::Instance()->MainDllPath.value()); mainDllPath.is_relative()) + { + Config::Instance()->MainDllPath.set_volatile_value(Util::ExePath().parent_path() / mainDllPath); + } + + // If path is invalid or doesn't exist, use the exe folder as main if (!std::filesystem::exists(Config::Instance()->MainDllPath.value()) || !std::filesystem::is_directory(Config::Instance()->MainDllPath.value())) { - LOG_ERROR("MainDllPath does not exist or wrong: {}", - wstring_to_string(Config::Instance()->MainDllPath.value())); - - Config::Instance()->MainDllPath.set_volatile_value(Util::ExePath().parent_path() / L"."); + Config::Instance()->MainDllPath.set_volatile_value(Util::ExePath().parent_path()); } + // Clean up path + Config::Instance()->MainDllPath.set_volatile_value( + std::filesystem::absolute(Config::Instance()->MainDllPath.value())); + // If path is not set or incorrect if (!Config::Instance()->PluginPath.has_value() || (!std::filesystem::exists(Config::Instance()->PluginPath.value()) || @@ -1774,8 +1777,6 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv { Config::Instance()->PluginPath.set_volatile_value( std::filesystem::path(Config::Instance()->MainDllPath.value()) / L"plugins"); - - LOG_WARN("PluginPath updated: {}", wstring_to_string(Config::Instance()->PluginPath.value())); } CheckForExcludedProcess();