From e81bffa69c7a30365891135044a1dbced8008b8b Mon Sep 17 00:00:00 2001 From: Miran Date: Sun, 6 Oct 2024 00:52:32 +0200 Subject: [PATCH] load_dynamic_library performance improvement. --- cleo_plugins/MemoryOperations/MemoryOperations.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cleo_plugins/MemoryOperations/MemoryOperations.cpp b/cleo_plugins/MemoryOperations/MemoryOperations.cpp index 43a6508a..edc5559d 100644 --- a/cleo_plugins/MemoryOperations/MemoryOperations.cpp +++ b/cleo_plugins/MemoryOperations/MemoryOperations.cpp @@ -405,10 +405,13 @@ class MemoryOperations CLEO_ResolvePath(thread, buff.data(), buff.size()); buff.resize(strlen(buff.data())); - // ModLoader's hooks require relative paths in LoadLibrary to work - FilepathRemoveParent(buff, CLEO_GetGameDirectory()); + if (std::filesystem::is_regular_file(buff)) + { + // ModLoader's hooks require relative paths in LoadLibrary to work + FilepathRemoveParent(buff, CLEO_GetGameDirectory()); - ptr = LoadLibrary(buff.c_str()); + ptr = LoadLibrary(buff.c_str()); + } // in case of just filename let LoadLibrary resolve it itself if (ptr == nullptr && !std::filesystem::path(path).has_parent_path())