diff --git a/plugins/apitracing/src/lib/ApiTracing.cpp b/plugins/apitracing/src/lib/ApiTracing.cpp index 5cfa0dcb..85be9b27 100644 --- a/plugins/apitracing/src/lib/ApiTracing.cpp +++ b/plugins/apitracing/src/lib/ApiTracing.cpp @@ -99,10 +99,10 @@ namespace ApiTracing } } -std::unique_ptr -VmiCore::Plugin::init(PluginInterface* pluginInterface, - std::shared_ptr config, // NOLINT(performance-unnecessary-value-param) - std::vector args) +extern "C" std::unique_ptr VmiCore::Plugin::vmicore_plugin_init( + PluginInterface* pluginInterface, + std::shared_ptr config, // NOLINT(performance-unnecessary-value-param) + std::vector args) { return std::make_unique(pluginInterface, *config, args); } diff --git a/plugins/inmemoryscanner/src/lib/InMemory.cpp b/plugins/inmemoryscanner/src/lib/InMemory.cpp index f68c626f..f4b9d20a 100644 --- a/plugins/inmemoryscanner/src/lib/InMemory.cpp +++ b/plugins/inmemoryscanner/src/lib/InMemory.cpp @@ -66,10 +66,10 @@ namespace InMemoryScanner } } -std::unique_ptr -VmiCore::Plugin::init(PluginInterface* pluginInterface, - std::shared_ptr config, // NOLINT(performance-unnecessary-value-param) - std::vector args) +extern "C" std::unique_ptr VmiCore::Plugin::vmicore_plugin_init( + PluginInterface* pluginInterface, + std::shared_ptr config, // NOLINT(performance-unnecessary-value-param) + std::vector args) { return std::make_unique(pluginInterface, *config, args); } diff --git a/plugins/template/src/lib/Template.cpp b/plugins/template/src/lib/Template.cpp old mode 100755 new mode 100644 index c2a10465..c9d22181 --- a/plugins/template/src/lib/Template.cpp +++ b/plugins/template/src/lib/Template.cpp @@ -51,12 +51,13 @@ namespace Template } } -// This is the init function. It is called by VmiCore and is responsible for creating an instance of a plugin. +// This is the init function. It is linked and called dynamically at runtime by +// VmiCore and is responsible for creating an instance of a plugin. // All plugins have to inherit from IPlugin. -std::unique_ptr -VmiCore::Plugin::init(PluginInterface* pluginInterface, - std::shared_ptr config, // NOLINT(performance-unnecessary-value-param) - std::vector args) +extern "C" std::unique_ptr VmiCore::Plugin::vmicore_plugin_init( + PluginInterface* pluginInterface, + std::shared_ptr config, // NOLINT(performance-unnecessary-value-param) + std::vector args) { return std::make_unique(pluginInterface, *config, args); } diff --git a/vmicore/src/include/vmicore/plugins/IPlugin.h b/vmicore/src/include/vmicore/plugins/IPlugin.h index 9b6aef11..1d5f3af3 100644 --- a/vmicore/src/include/vmicore/plugins/IPlugin.h +++ b/vmicore/src/include/vmicore/plugins/IPlugin.h @@ -44,8 +44,9 @@ namespace VmiCore::Plugin * @param args Commandline arguments passed to this specific plugin. Elements are whitespace separated. * @return An instance of the plugin. Has to implement the IPlugin interface. Lifetime will be managed by VMICore. */ - extern std::unique_ptr - init(PluginInterface* pluginInterface, std::shared_ptr config, std::vector args); + extern "C" std::unique_ptr vmicore_plugin_init(PluginInterface* pluginInterface, + std::shared_ptr config, + std::vector args); } #endif // APITRACING_IPLUGIN_H diff --git a/vmicore/src/lib/plugins/PluginSystem.cpp b/vmicore/src/lib/plugins/PluginSystem.cpp index cba1bed3..c0400120 100644 --- a/vmicore/src/lib/plugins/PluginSystem.cpp +++ b/vmicore/src/lib/plugins/PluginSystem.cpp @@ -161,10 +161,8 @@ namespace VmiCore Plugin::PluginInterface::API_VERSION)); } - auto pluginInitFunction = std::bit_cast( - dlsym(libraryHandle, - "_ZN7VmiCore6Plugin4initEPNS0_15PluginInterfaceENSt3__110shared_ptrINS0_13IPluginConfigEEENS3_" - "6vectorINS3_12basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEENSB_ISD_EEEE")); + auto pluginInitFunction = + std::bit_cast(dlsym(libraryHandle, PLUGIN_INIT_FUNCTION.data())); dlErrorMessage = dlerror(); if (dlErrorMessage != nullptr) { diff --git a/vmicore/src/lib/plugins/PluginSystem.h b/vmicore/src/lib/plugins/PluginSystem.h index c8be60c0..113bea51 100644 --- a/vmicore/src/lib/plugins/PluginSystem.h +++ b/vmicore/src/lib/plugins/PluginSystem.h @@ -17,6 +17,8 @@ namespace VmiCore { + constexpr std::string_view PLUGIN_INIT_FUNCTION = "vmicore_plugin_init"; + class IPluginSystem : public Plugin::PluginInterface { public: