From e5df0172d09e15df6e8b98e9688df30dc1d5dc91 Mon Sep 17 00:00:00 2001 From: Knightly Date: Tue, 5 May 2026 13:18:49 +1200 Subject: [PATCH] Load openssl libs from working directory / fix log - OpenSSL is being copied to the exe directory on build but nothing was loading the local dlls - Add OpenSSL path loading from the working directory - Add step to copy legacy.dll for openssl since it is a runtime dll - This removes the requirement to install OpenSSL on the system - The working directory can be separate from the exe directory if the user still requires this functionality - Change logging to always be active when the system starts --- loginserver/CMakeLists.txt | 10 ++++++++++ loginserver/encryption.cpp | 7 +++++++ loginserver/main.cpp | 7 +------ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/loginserver/CMakeLists.txt b/loginserver/CMakeLists.txt index 71466df1b..67d0658c2 100644 --- a/loginserver/CMakeLists.txt +++ b/loginserver/CMakeLists.txt @@ -37,3 +37,13 @@ target_include_directories(loginserver PRIVATE ..) set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) set_property(TARGET loginserver PROPERTY FOLDER executables/servers) + +# vcpkg doesn't copy legacy.dll automatically because it is loaded at runtime, not via the import table. +if(WIN32 AND DEFINED VCPKG_INSTALLED_DIR AND DEFINED VCPKG_TARGET_TRIPLET) + add_custom_command(TARGET loginserver POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "$,${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/bin/legacy.dll,${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/legacy.dll>" + "$/legacy.dll" + VERBATIM + ) +endif() diff --git a/loginserver/encryption.cpp b/loginserver/encryption.cpp index 3fa140768..1b08a5651 100644 --- a/loginserver/encryption.cpp +++ b/loginserver/encryption.cpp @@ -31,6 +31,7 @@ #endif #include +#include #include #include @@ -182,6 +183,12 @@ static OSSL_PROVIDER *s_default_provider = nullptr; bool eqcrypt_init() { #ifdef EQEMU_USE_OPENSSL +#ifdef _WIN32 + // Set OpenSSL default provider search path to the working directory. Okay to throw. + std::string search_path = std::filesystem::current_path().string(); + OSSL_PROVIDER_set_default_search_path(nullptr, search_path.c_str()); +#endif + if (!s_default_provider) { s_default_provider = OSSL_PROVIDER_load(nullptr, "default"); } diff --git a/loginserver/main.cpp b/loginserver/main.cpp index 9b9766223..106fdc7df 100644 --- a/loginserver/main.cpp +++ b/loginserver/main.cpp @@ -159,6 +159,7 @@ void start_web_server() int main(int argc, char **argv) { RegisterExecutablePlatform(ExePlatformLogin); + EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); set_exception_handler(); if (!eqcrypt_init()) { @@ -166,12 +167,6 @@ int main(int argc, char **argv) return 1; } - LogInfo("Logging System Init"); - - if (argc == 1) { - EQEmuLogSys::Instance()->LoadLogSettingsDefaults(); - } - PathManager::Instance()->Init(); // command handler