diff --git a/source/plugin/PluginMetaInformationFactory.cpp b/source/plugin/PluginMetaInformationFactory.cpp index 16cb060..205ed57 100644 --- a/source/plugin/PluginMetaInformationFactory.cpp +++ b/source/plugin/PluginMetaInformationFactory.cpp @@ -34,13 +34,36 @@ std::optional PluginMetaInformationFactory::loadPlugin(co DEBUG_FUNCTION_LINE("Can't find or process ELF file"); return std::nullopt; } - auto reader = readerOpt.value(); + return loadPlugin(readerOpt.value()); +} +std::optional PluginMetaInformationFactory::loadPlugin(const std::string filePath) { + auto reader = new elfio; + if (reader == NULL || !reader->load(filePath)) { + DEBUG_FUNCTION_LINE("Can't find or process ELF file\n"); + delete reader; + return std::nullopt; + } + return loadPlugin(reader); +} +std::optional PluginMetaInformationFactory::loadPlugin(char *buffer, size_t size) { + auto reader = new elfio; + if (reader == NULL || !reader->load(buffer, size)) { + DEBUG_FUNCTION_LINE("Can't find or process ELF file\n"); + delete reader; + return std::nullopt; + } + + return loadPlugin(reader); +} + +std::optional PluginMetaInformationFactory::loadPlugin(elfio *reader) { DEBUG_FUNCTION_LINE("Found elfio reader"); size_t pluginSize = 0; PluginMetaInformation pluginInfo; + uint32_t sec_num = reader->sections.size(); DEBUG_FUNCTION_LINE("%d number of sections", sec_num); diff --git a/source/plugin/PluginMetaInformationFactory.h b/source/plugin/PluginMetaInformationFactory.h index 2f0edf8..86a0431 100644 --- a/source/plugin/PluginMetaInformationFactory.h +++ b/source/plugin/PluginMetaInformationFactory.h @@ -26,4 +26,10 @@ class PluginMetaInformationFactory { public: static std::optional loadPlugin(const PluginData &pluginData); + + static std::optional loadPlugin(const std::string filePath); + + static std::optional loadPlugin(char *buffer, size_t size); + + static std::optional loadPlugin(elfio *reader); };