Skip to content

Commit

Permalink
update(plugin-loader): Adding again debug
Browse files Browse the repository at this point in the history
  • Loading branch information
skuzzis committed Nov 16, 2023
1 parent 48c06c6 commit 0fc217e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
"regex": "cpp",
"time.h": "c",
"cfenv": "cpp",
"any": "cpp"
"any": "cpp",
"filesystem": "cpp"
},
"cmake.sourceDirectory": "C:/Users/SkuZZis/Desktop/CS2 Server/plugins/swiftly/vendor/rapidjson/test/unittest",
"C_Cpp.default.compilerPath": "C:\\msys64\\mingw64\\bin\\g++.exe"
}
11 changes: 10 additions & 1 deletion src/components/Plugins/inc/Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include <metamod_oslink.h>
#include <filesystem>

#ifndef _WIN32
#include <dlfcn.h>
#endif

const std::string funcsToLoad[] = {
"RegisterPlayer",
"OnProgramLoad",
Expand Down Expand Up @@ -54,7 +58,12 @@ class Plugin

void LoadPlugin()
{
this->m_hModule = dlmount(WIN_LINUX(this->m_path.c_str(), string_format("%s/%s", std::filesystem::current_path().string().c_str(), this->m_path.c_str()).c_str()));
#ifdef _WIN32
this->m_hModule = dlmount(this->m_path.c_str());
#else
this->m_hModule = dlopen(string_format("%s/%s", std::filesystem::current_path().string().c_str(), this->m_path.c_str()).c_str(), RTLD_LAZY);
#endif
PRINT("LoadPlugin", string_format("%s/%s\nhModule addr: %p\n", std::filesystem::current_path().string().c_str(), this->m_path.c_str(), this->m_hModule).c_str());

for (uint16 i = 0; i < ARR_SIZE(funcsToLoad); i++)
this->RegisterFunction("Internal_" + funcsToLoad[i]);
Expand Down

0 comments on commit 0fc217e

Please sign in to comment.