Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let LoadLibrary API resolve library paths itself. #101

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion cleo_plugins/MemoryOperations/MemoryOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "CLEO_Utils.h"
#include "plugin.h"
#include "CTheScripts.h"
#include <filesystem>
#include <set>

using namespace CLEO;
Expand Down Expand Up @@ -361,7 +362,17 @@ class MemoryOperations
//0AA2=2, load_dynamic_library %1s% store_to %2d% // IF and SET
static OpcodeResult __stdcall opcode_0AA2(CLEO::CRunningScript* thread)
{
OPCODE_READ_PARAM_FILEPATH(path);
OPCODE_READ_PARAM_STRING(path);

// get absolute path
// in case of just filename let LoadLibrary resolve it itself
char buff[MAX_PATH];
if (std::filesystem::path(path).has_parent_path())
{
strncpy(buff, path, sizeof(buff));
CLEO_ResolvePath(thread, buff, sizeof(buff));
path = buff;
}

auto ptr = LoadLibrary(path);
if (ptr != nullptr)
Expand Down