diff --git a/.vscode/settings.json b/.vscode/settings.json index 21142076..776506de 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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" } \ No newline at end of file diff --git a/src/components/Plugins/inc/Plugin.h b/src/components/Plugins/inc/Plugin.h index 8869bdf9..46694a1b 100644 --- a/src/components/Plugins/inc/Plugin.h +++ b/src/components/Plugins/inc/Plugin.h @@ -7,6 +7,10 @@ #include #include +#ifndef _WIN32 +#include +#endif + const std::string funcsToLoad[] = { "RegisterPlayer", "OnProgramLoad", @@ -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]);