Loading mods

Signed-off-by: Faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2025-10-20 22:04:25 +03:00
1 parent de940dab27
commit 6ea34bf00b
10 files changed
+169 -10

No files matched your search

+5 -3
View File
@@ -1,4 +1,6 @@
#include <Mods/LoadLibrary.hpp>
#include <Mods/Loader.hpp>
#include <Mods/LoadLibrary.hpp>
#include <Agent.hpp>
#include <dlfcn.h>
#include <iostream>
@@ -6,8 +8,8 @@
namespace vl::mod {
std::size_t ModLoader::loadModule(const std::string& path, const Context& ctx) {
void* handle = dlopen(path.c_str(), RTLD_NOW | RTLD_GLOBAL);
std::size_t ModLoader::loadModule(const std::string& path, const Context& ctx, bool isGlobal) {
void* handle = LoadLibrary(path, isGlobal);
if (!handle) throw std::runtime_error(std::string("dlopen failed: ") + dlerror());
handles_.push_back(handle);
@@ -48,7 +50,7 @@ void ModLoader::stopAll() {
void ModLoader::unloadAll() {
stopAll();
instances_.clear();
for (auto* h : handles_) if (h) dlclose(h);
for (auto* h : handles_) if (h) CloseLibrary(h);
handles_.clear();
}