Skip to content

Commit 52b6513

Browse files
authored
Updates in load_dynamic_library opcode. (#110)
1 parent 61d8d12 commit 52b6513

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

cleo_plugins/MemoryOperations/MemoryOperations.cpp

+10-7
Original file line numberDiff line numberDiff line change
@@ -363,18 +363,21 @@ class MemoryOperations
363363
static OpcodeResult __stdcall opcode_0AA2(CLEO::CRunningScript* thread)
364364
{
365365
OPCODE_READ_PARAM_STRING(path);
366+
367+
HMODULE ptr = nullptr;
366368

367-
// get absolute path
368-
// in case of just filename let LoadLibrary resolve it itself
369+
// resolve absolute path and try load
369370
char buff[MAX_PATH];
370-
if (std::filesystem::path(path).has_parent_path())
371+
strncpy(buff, path, sizeof(buff));
372+
CLEO_ResolvePath(thread, buff, sizeof(buff));
373+
ptr = LoadLibrary(buff);
374+
375+
// in case of just filename let LoadLibrary resolve it itself
376+
if (ptr == nullptr && !std::filesystem::path(path).has_parent_path())
371377
{
372-
strncpy(buff, path, sizeof(buff));
373-
CLEO_ResolvePath(thread, buff, sizeof(buff));
374-
path = buff;
378+
ptr = LoadLibrary(path);
375379
}
376380

377-
auto ptr = LoadLibrary(path);
378381
if (ptr != nullptr)
379382
{
380383
m_libraries.insert(ptr);

0 commit comments

Comments
 (0)