From c8970282b9d5f1d94a5f03839ce3943905de4dd1 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sat, 3 Aug 2024 17:23:27 +0200 Subject: [PATCH] Rename PluginInformation to PluginLinkInformation and make it optional in PluginContainer --- source/PluginManagement.cpp | 25 ++++++--- source/hooks.cpp | 8 ++- source/main.cpp | 6 ++- source/patcher/hooks_patcher_static.cpp | 14 +++-- source/plugin/PluginContainer.cpp | 34 +++++++----- source/plugin/PluginContainer.h | 16 +++--- ...ormation.cpp => PluginLinkInformation.cpp} | 52 +++++++++---------- ...nInformation.h => PluginLinkInformation.h} | 12 ++--- ...y.cpp => PluginLinkInformationFactory.cpp} | 14 ++--- ...ctory.h => PluginLinkInformationFactory.h} | 9 ++-- source/utils/config/ConfigUtils.cpp | 5 +- source/utils/exports.cpp | 10 ++-- 12 files changed, 122 insertions(+), 83 deletions(-) rename source/plugin/{PluginInformation.cpp => PluginLinkInformation.cpp} (54%) rename source/plugin/{PluginInformation.h => PluginLinkInformation.h} (90%) rename source/plugin/{PluginInformationFactory.cpp => PluginLinkInformationFactory.cpp} (96%) rename source/plugin/{PluginInformationFactory.h => PluginLinkInformationFactory.h} (85%) diff --git a/source/PluginManagement.cpp b/source/PluginManagement.cpp index d5ce618..58dcb68 100644 --- a/source/PluginManagement.cpp +++ b/source/PluginManagement.cpp @@ -2,7 +2,7 @@ #include "NotificationsUtils.h" #include "hooks.h" #include "plugin/PluginContainer.h" -#include "plugin/PluginInformationFactory.h" +#include "plugin/PluginLinkInformationFactory.h" #include "plugin/PluginMetaInformationFactory.h" #include "utils/ElfUtils.h" #include "utils/StringTools.h" @@ -22,14 +22,14 @@ PluginManagement::loadPlugins(const std::set> &plugi auto metaInfo = PluginMetaInformationFactory::loadPlugin(*pluginData, error); if (metaInfo && error == PLUGIN_PARSE_ERROR_NONE) { - auto info = PluginInformationFactory::load(*pluginData, trampolineData, trampolineID++); - if (!info) { + auto linkInfo = PluginLinkInformationFactory::load(*pluginData, trampolineData, trampolineID++); + if (!linkInfo) { auto errMsg = string_format("Failed to load plugin: %s", pluginData->getSource().c_str()); DEBUG_FUNCTION_LINE_ERR("%s", errMsg.c_str()); DisplayErrorNotificationMessage(errMsg, 15.0f); continue; } - plugins.emplace_back(std::move(*metaInfo), std::move(*info), pluginData); + plugins.emplace_back(std::move(*metaInfo), std::move(linkInfo), pluginData); } else { auto errMsg = string_format("Failed to load plugin: %s", pluginData->getSource().c_str()); if (error == PLUGIN_PARSE_ERROR_INCOMPATIBLE_VERSION) { @@ -137,10 +137,13 @@ bool PluginManagement::doRelocations(const std::vector &plugins OSDynLoad_SetAllocator(CustomDynLoadAlloc, CustomDynLoadFree); for (const auto &pluginContainer : plugins) { + if (!pluginContainer.isPluginLinkedAndLoaded()) { + continue; + } DEBUG_FUNCTION_LINE_VERBOSE("Doing relocations for plugin: %s", pluginContainer.getMetaInformation().getName().c_str()); - if (!PluginManagement::doRelocation(pluginContainer.getPluginInformation().getRelocationDataList(), + if (!PluginManagement::doRelocation(pluginContainer.getPluginLinkInformation()->getRelocationDataList(), trampData, - pluginContainer.getPluginInformation().getTrampolineId(), + pluginContainer.getPluginLinkInformation()->getTrampolineId(), usedRPls)) { return false; } @@ -153,7 +156,10 @@ bool PluginManagement::doRelocations(const std::vector &plugins bool PluginManagement::RestoreFunctionPatches(std::vector &plugins) { for (auto &cur : std::ranges::reverse_view(plugins)) { - for (auto &curFunction : std::ranges::reverse_view(cur.getPluginInformation().getFunctionDataList())) { + if (!cur.isPluginLinkedAndLoaded()) { + continue; + } + for (auto &curFunction : std::ranges::reverse_view(cur.getPluginLinkInformation()->getFunctionDataList())) { if (!curFunction.RemovePatch()) { return false; } @@ -164,7 +170,10 @@ bool PluginManagement::RestoreFunctionPatches(std::vector &plug bool PluginManagement::DoFunctionPatches(std::vector &plugins) { for (auto &cur : plugins) { - for (auto &curFunction : cur.getPluginInformation().getFunctionDataList()) { + if (!cur.isPluginLinkedAndLoaded()) { + continue; + } + for (auto &curFunction : cur.getPluginLinkInformation()->getFunctionDataList()) { if (!curFunction.AddPatch()) { DEBUG_FUNCTION_LINE_ERR("Failed to add function patch for: plugin %s", cur.getMetaInformation().getName().c_str()); return false; diff --git a/source/hooks.cpp b/source/hooks.cpp index 7a09d9f..0e8cbe8 100644 --- a/source/hooks.cpp +++ b/source/hooks.cpp @@ -38,12 +38,18 @@ static const char **hook_names = (const char *[]){ void CallHook(const std::vector &plugins, wups_loader_hook_type_t hook_type) { DEBUG_FUNCTION_LINE_VERBOSE("Calling hook of type %s [%d]", hook_names[hook_type], hook_type); for (const auto &plugin : plugins) { + if (!plugin.isPluginLinkedAndLoaded()) { + return; + } CallHook(plugin, hook_type); } } void CallHook(const PluginContainer &plugin, wups_loader_hook_type_t hook_type) { - for (const auto &hook : plugin.getPluginInformation().getHookDataList()) { + if (!plugin.isPluginLinkedAndLoaded()) { + return; + } + for (const auto &hook : plugin.getPluginLinkInformation()->getHookDataList()) { if (hook.getType() == hook_type) { DEBUG_FUNCTION_LINE_VERBOSE("Calling hook of type %s for plugin %s [%d]", hook_names[hook.getType()], plugin.getMetaInformation().getName().c_str(), hook_type); void *func_ptr = hook.getFunctionPointer(); diff --git a/source/main.cpp b/source/main.cpp index 4614d3b..fb941f6 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -5,6 +5,7 @@ #include "hooks.h" #include "patcher/hooks_patcher_static.h" #include "plugin/PluginDataFactory.h" +#include "plugin/PluginMetaInformationFactory.h" #include "utils/utils.h" #include #include @@ -190,7 +191,10 @@ WUMS_APPLICATION_STARTS() { void CheckCleanupCallbackUsage(const std::vector &plugins) { auto *curThread = OSGetCurrentThread(); for (const auto &cur : plugins) { - auto textSection = cur.getPluginInformation().getSectionInfo(".text"); + if (!cur.isPluginLinkedAndLoaded()) { + continue; + } + auto textSection = cur.getPluginLinkInformation()->getSectionInfo(".text"); if (!textSection) { continue; } diff --git a/source/patcher/hooks_patcher_static.cpp b/source/patcher/hooks_patcher_static.cpp index 08f2236..e1ec617 100644 --- a/source/patcher/hooks_patcher_static.cpp +++ b/source/patcher/hooks_patcher_static.cpp @@ -146,7 +146,10 @@ DECL_FUNCTION(uint32_t, SC17_FindClosestSymbol, char *moduleNameBuffer, uint32_t moduleNameBufferLength) { for (const auto &plugin : gLoadedPlugins) { - const auto sectionInfo = plugin.getPluginInformation().getSectionInfo(".text"); + if (!plugin.isPluginLinkedAndLoaded()) { + continue; + } + const auto sectionInfo = plugin.getPluginLinkInformation()->getSectionInfo(".text"); if (!sectionInfo) { continue; } @@ -156,7 +159,7 @@ DECL_FUNCTION(uint32_t, SC17_FindClosestSymbol, } strncpy(moduleNameBuffer, plugin.getMetaInformation().getName().c_str(), moduleNameBufferLength - 1); - auto functionSymbolData = plugin.getPluginInformation().getNearestFunctionSymbolData(addr); + auto functionSymbolData = plugin.getPluginLinkInformation()->getNearestFunctionSymbolData(addr); if (functionSymbolData) { strncpy(symbolNameBuffer, functionSymbolData->getName().c_str(), moduleNameBufferLength - 1); if (outDistance) { @@ -179,7 +182,10 @@ DECL_FUNCTION(uint32_t, SC17_FindClosestSymbol, DECL_FUNCTION(uint32_t, KiGetAppSymbolName, uint32_t addr, char *buffer, int32_t bufSize) { for (const auto &plugin : gLoadedPlugins) { - const auto sectionInfo = plugin.getPluginInformation().getSectionInfo(".text"); + if (!plugin.isPluginLinkedAndLoaded()) { + continue; + } + const auto sectionInfo = plugin.getPluginLinkInformation()->getSectionInfo(".text"); if (!sectionInfo) { continue; } @@ -195,7 +201,7 @@ DECL_FUNCTION(uint32_t, KiGetAppSymbolName, uint32_t addr, char *buffer, int32_t } strncpy(buffer, plugin.getMetaInformation().getName().c_str(), bufSize - 1); - const auto functionSymbolData = plugin.getPluginInformation().getNearestFunctionSymbolData(addr); + const auto functionSymbolData = plugin.getPluginLinkInformation()->getNearestFunctionSymbolData(addr); if (functionSymbolData) { buffer[pluginNameLen] = '|'; buffer[pluginNameLen + 1] = '\0'; diff --git a/source/plugin/PluginContainer.cpp b/source/plugin/PluginContainer.cpp index 6f76730..439aafe 100644 --- a/source/plugin/PluginContainer.cpp +++ b/source/plugin/PluginContainer.cpp @@ -1,13 +1,13 @@ #include "PluginContainer.h" -PluginContainer::PluginContainer(PluginMetaInformation metaInformation, PluginInformation pluginInformation, std::shared_ptr pluginData) +PluginContainer::PluginContainer(PluginMetaInformation metaInformation, std::optional pluginLinkInformation, std::shared_ptr pluginData) : mMetaInformation(std::move(metaInformation)), - mPluginInformation(std::move(pluginInformation)), + mPluginLinkInformation(std::move(pluginLinkInformation)), mPluginData(std::move(pluginData)) { } PluginContainer::PluginContainer(PluginContainer &&src) : mMetaInformation(std::move(src.mMetaInformation)), - mPluginInformation(std::move(src.mPluginInformation)), + mPluginLinkInformation(std::move(src.mPluginLinkInformation)), mPluginData(std::move(src.mPluginData)), mPluginConfigData(std::move(src.mPluginConfigData)), storageRootItem(src.storageRootItem) @@ -18,11 +18,11 @@ PluginContainer::PluginContainer(PluginContainer &&src) : mMetaInformation(std:: PluginContainer &PluginContainer::operator=(PluginContainer &&src) { if (this != &src) { - this->mMetaInformation = src.mMetaInformation; - this->mPluginInformation = std::move(src.mPluginInformation); - this->mPluginData = std::move(src.mPluginData); - this->mPluginConfigData = std::move(src.mPluginConfigData); - this->storageRootItem = src.storageRootItem; + this->mMetaInformation = src.mMetaInformation; + this->mPluginLinkInformation = std::move(src.mPluginLinkInformation); + this->mPluginData = std::move(src.mPluginData); + this->mPluginConfigData = std::move(src.mPluginConfigData); + this->storageRootItem = src.storageRootItem; src.storageRootItem = nullptr; } @@ -33,12 +33,22 @@ const PluginMetaInformation &PluginContainer::getMetaInformation() const { return this->mMetaInformation; } -const PluginInformation &PluginContainer::getPluginInformation() const { - return this->mPluginInformation; +bool PluginContainer::isPluginLinkedAndLoaded() const { + return this->mPluginLinkInformation.has_value(); } -PluginInformation &PluginContainer::getPluginInformation() { - return this->mPluginInformation; +const PluginLinkInformation *PluginContainer::getPluginLinkInformation() const { + if (this->mPluginLinkInformation.has_value()) { + return this->mPluginLinkInformation.operator->(); + } + return nullptr; +} + +PluginLinkInformation *PluginContainer::getPluginLinkInformation() { + if (this->mPluginLinkInformation.has_value()) { + return this->mPluginLinkInformation.operator->(); + } + return nullptr; } std::shared_ptr PluginContainer::getPluginDataCopy() const { diff --git a/source/plugin/PluginContainer.h b/source/plugin/PluginContainer.h index 8e8619f..62d670f 100644 --- a/source/plugin/PluginContainer.h +++ b/source/plugin/PluginContainer.h @@ -19,7 +19,7 @@ #include "PluginConfigData.h" #include "PluginData.h" -#include "PluginInformation.h" +#include "PluginLinkInformation.h" #include "PluginMetaInformation.h" #include "utils/storage/StorageUtils.h" #include @@ -28,24 +28,24 @@ class PluginContainer { public: - PluginContainer(PluginMetaInformation metaInformation, PluginInformation pluginInformation, std::shared_ptr pluginData); - + PluginContainer(PluginMetaInformation metaInformation, std::optional pluginLinkInformation, std::shared_ptr pluginData); PluginContainer(const PluginContainer &) = delete; - PluginContainer(PluginContainer &&src); PluginContainer &operator=(PluginContainer &&src); - [[nodiscard]] const PluginMetaInformation &getMetaInformation() const; - [[nodiscard]] const PluginInformation &getPluginInformation() const; - [[nodiscard]] PluginInformation &getPluginInformation(); + [[nodiscard]] const PluginLinkInformation *getPluginLinkInformation() const; + + [[nodiscard]] PluginLinkInformation *getPluginLinkInformation(); [[nodiscard]] std::shared_ptr getPluginDataCopy() const; + [[nodiscard]] bool isPluginLinkedAndLoaded() const; + [[nodiscard]] uint32_t getHandle() const; [[nodiscard]] const std::optional &getConfigData() const; @@ -62,7 +62,7 @@ public: private: PluginMetaInformation mMetaInformation; - PluginInformation mPluginInformation; + std::optional mPluginLinkInformation; std::shared_ptr mPluginData; std::optional mPluginConfigData; diff --git a/source/plugin/PluginInformation.cpp b/source/plugin/PluginLinkInformation.cpp similarity index 54% rename from source/plugin/PluginInformation.cpp rename to source/plugin/PluginLinkInformation.cpp index 7bccf71..e900ade 100644 --- a/source/plugin/PluginInformation.cpp +++ b/source/plugin/PluginLinkInformation.cpp @@ -1,19 +1,19 @@ -#include "PluginInformation.h" +#include "PluginLinkInformation.h" -PluginInformation::PluginInformation(PluginInformation &&src) : mHookDataList(std::move(src.mHookDataList)), - mFunctionDataList(std::move(src.mFunctionDataList)), - mRelocationDataList(std::move(src.mRelocationDataList)), - mSymbolDataList(std::move(src.mSymbolDataList)), - mSectionInfoList(std::move(src.mSectionInfoList)), - mTrampolineId(src.mTrampolineId), - mAllocatedTextMemoryAddress(std::move(src.mAllocatedTextMemoryAddress)), - mAllocatedDataMemoryAddress(std::move(src.mAllocatedDataMemoryAddress)) +PluginLinkInformation::PluginLinkInformation(PluginLinkInformation &&src) : mHookDataList(std::move(src.mHookDataList)), + mFunctionDataList(std::move(src.mFunctionDataList)), + mRelocationDataList(std::move(src.mRelocationDataList)), + mSymbolDataList(std::move(src.mSymbolDataList)), + mSectionInfoList(std::move(src.mSectionInfoList)), + mTrampolineId(src.mTrampolineId), + mAllocatedTextMemoryAddress(std::move(src.mAllocatedTextMemoryAddress)), + mAllocatedDataMemoryAddress(std::move(src.mAllocatedDataMemoryAddress)) { src.mTrampolineId = {}; } -PluginInformation &PluginInformation::operator=(PluginInformation &&src) { +PluginLinkInformation &PluginLinkInformation::operator=(PluginLinkInformation &&src) { if (this != &src) { this->mHookDataList = std::move(src.mHookDataList); this->mFunctionDataList = std::move(src.mFunctionDataList); @@ -28,62 +28,62 @@ PluginInformation &PluginInformation::operator=(PluginInformation &&src) { return *this; } -void PluginInformation::addHookData(HookData hook_data) { +void PluginLinkInformation::addHookData(HookData hook_data) { mHookDataList.push_back(hook_data); } -const std::vector &PluginInformation::getHookDataList() const { +const std::vector &PluginLinkInformation::getHookDataList() const { return mHookDataList; } -void PluginInformation::addFunctionData(FunctionData function_data) { +void PluginLinkInformation::addFunctionData(FunctionData function_data) { mFunctionDataList.push_back(std::move(function_data)); } -const std::vector &PluginInformation::getFunctionDataList() const { +const std::vector &PluginLinkInformation::getFunctionDataList() const { return mFunctionDataList; } -std::vector &PluginInformation::getFunctionDataList() { +std::vector &PluginLinkInformation::getFunctionDataList() { return mFunctionDataList; } -void PluginInformation::addRelocationData(RelocationData relocation_data) { +void PluginLinkInformation::addRelocationData(RelocationData relocation_data) { mRelocationDataList.push_back(std::move(relocation_data)); } -const std::vector &PluginInformation::getRelocationDataList() const { +const std::vector &PluginLinkInformation::getRelocationDataList() const { return mRelocationDataList; } -void PluginInformation::addFunctionSymbolData(const FunctionSymbolData &symbol_data) { +void PluginLinkInformation::addFunctionSymbolData(const FunctionSymbolData &symbol_data) { mSymbolDataList.insert(symbol_data); } -void PluginInformation::addSectionInfo(const SectionInfo §ionInfo) { +void PluginLinkInformation::addSectionInfo(const SectionInfo §ionInfo) { mSectionInfoList.insert(std::pair(sectionInfo.getName(), sectionInfo)); } -const std::map &PluginInformation::getSectionInfoList() const { +const std::map &PluginLinkInformation::getSectionInfoList() const { return mSectionInfoList; } -std::optional PluginInformation::getSectionInfo(const std::string §ionName) const { +std::optional PluginLinkInformation::getSectionInfo(const std::string §ionName) const { if (getSectionInfoList().contains(sectionName)) { return mSectionInfoList.at(sectionName); } return std::nullopt; } -void PluginInformation::setTrampolineId(uint8_t trampolineId) { +void PluginLinkInformation::setTrampolineId(uint8_t trampolineId) { this->mTrampolineId = trampolineId; } -uint8_t PluginInformation::getTrampolineId() const { +uint8_t PluginLinkInformation::getTrampolineId() const { return mTrampolineId; } -const FunctionSymbolData *PluginInformation::getNearestFunctionSymbolData(uint32_t address) const { +const FunctionSymbolData *PluginLinkInformation::getNearestFunctionSymbolData(uint32_t address) const { const FunctionSymbolData *result = nullptr; bool foundHit = false; @@ -103,10 +103,10 @@ const FunctionSymbolData *PluginInformation::getNearestFunctionSymbolData(uint32 return result; } -const HeapMemoryFixedSize &PluginInformation::getTextMemory() const { +const HeapMemoryFixedSize &PluginLinkInformation::getTextMemory() const { return mAllocatedTextMemoryAddress; } -const HeapMemoryFixedSize &PluginInformation::getDataMemory() const { +const HeapMemoryFixedSize &PluginLinkInformation::getDataMemory() const { return mAllocatedDataMemoryAddress; } diff --git a/source/plugin/PluginInformation.h b/source/plugin/PluginLinkInformation.h similarity index 90% rename from source/plugin/PluginInformation.h rename to source/plugin/PluginLinkInformation.h index dab997f..00d6889 100644 --- a/source/plugin/PluginInformation.h +++ b/source/plugin/PluginLinkInformation.h @@ -40,13 +40,13 @@ struct FunctionSymbolDataComparator { } }; -class PluginInformation { +class PluginLinkInformation { public: - PluginInformation(const PluginInformation &) = delete; + PluginLinkInformation(const PluginLinkInformation &) = delete; - PluginInformation(PluginInformation &&src); + PluginLinkInformation(PluginLinkInformation &&src); - PluginInformation &operator=(PluginInformation &&src); + PluginLinkInformation &operator=(PluginLinkInformation &&src); [[nodiscard]] const std::vector &getHookDataList() const; @@ -69,7 +69,7 @@ public: [[nodiscard]] const HeapMemoryFixedSize &getDataMemory() const; private: - PluginInformation() = default; + PluginLinkInformation() = default; void addHookData(HookData hook_data); @@ -94,5 +94,5 @@ private: HeapMemoryFixedSize mAllocatedTextMemoryAddress; HeapMemoryFixedSize mAllocatedDataMemoryAddress; - friend class PluginInformationFactory; + friend class PluginLinkInformationFactory; }; diff --git a/source/plugin/PluginInformationFactory.cpp b/source/plugin/PluginLinkInformationFactory.cpp similarity index 96% rename from source/plugin/PluginInformationFactory.cpp rename to source/plugin/PluginLinkInformationFactory.cpp index 1e8b929..a5ca88d 100644 --- a/source/plugin/PluginInformationFactory.cpp +++ b/source/plugin/PluginLinkInformationFactory.cpp @@ -15,7 +15,7 @@ * along with this program. If not, see . ****************************************************************************/ -#include "PluginInformationFactory.h" +#include "PluginLinkInformationFactory.h" #include "../utils/ElfUtils.h" #include "utils/HeapMemoryFixedSize.h" #include "utils/wiiu_zlib.hpp" @@ -27,8 +27,8 @@ using namespace ELFIO; -std::optional -PluginInformationFactory::load(const PluginData &pluginData, std::vector &trampolineData, uint8_t trampolineId) { +std::optional +PluginLinkInformationFactory::load(const PluginData &pluginData, std::vector &trampolineData, uint8_t trampolineId) { auto buffer = pluginData.getBuffer(); if (buffer.empty()) { DEBUG_FUNCTION_LINE_ERR("Buffer was empty"); @@ -41,7 +41,7 @@ PluginInformationFactory::load(const PluginData &pluginData, std::vector destinations) { +bool PluginLinkInformationFactory::addImportRelocationData(PluginLinkInformation &pluginInfo, const elfio &reader, std::span destinations) { std::map> infoMap; uint32_t sec_num = reader.sections.size(); @@ -336,7 +336,7 @@ bool PluginInformationFactory::addImportRelocationData(PluginInformation &plugin return true; } -bool PluginInformationFactory::linkSection(const elfio &reader, uint32_t section_index, uint32_t destination, uint32_t base_text, uint32_t base_data, +bool PluginLinkInformationFactory::linkSection(const elfio &reader, uint32_t section_index, uint32_t destination, uint32_t base_text, uint32_t base_data, std::vector &trampolineData, uint8_t trampolineId) { uint32_t sec_num = reader.sections.size(); diff --git a/source/plugin/PluginInformationFactory.h b/source/plugin/PluginLinkInformationFactory.h similarity index 85% rename from source/plugin/PluginInformationFactory.h rename to source/plugin/PluginLinkInformationFactory.h index 8b31aab..8fce5ed 100644 --- a/source/plugin/PluginInformationFactory.h +++ b/source/plugin/PluginLinkInformationFactory.h @@ -19,7 +19,7 @@ #include "../elfio/elfio.hpp" #include "PluginContainer.h" -#include "PluginInformation.h" +#include "PluginLinkInformation.h" #include #include #include @@ -27,15 +27,16 @@ #include #include -class PluginInformationFactory { +class PluginLinkInformationFactory { public: - static std::optional + static std::optional load(const PluginData &pluginData, std::vector &trampolineData, uint8_t trampolineId); +private: static bool linkSection(const ELFIO::elfio &reader, uint32_t section_index, uint32_t destination, uint32_t base_text, uint32_t base_data, std::vector &trampolineData, uint8_t trampolineId); static bool - addImportRelocationData(PluginInformation &pluginInfo, const ELFIO::elfio &reader, std::span destinations); + addImportRelocationData(PluginLinkInformation &pluginInfo, const ELFIO::elfio &reader, std::span destinations); }; diff --git a/source/utils/config/ConfigUtils.cpp b/source/utils/config/ConfigUtils.cpp index a8d12bd..f7313a6 100644 --- a/source/utils/config/ConfigUtils.cpp +++ b/source/utils/config/ConfigUtils.cpp @@ -76,6 +76,9 @@ void ConfigUtils::displayMenu() { std::vector configs; for (const auto &plugin : gLoadedPlugins) { + if (!plugin.isPluginLinkedAndLoaded()) { + continue; + } GeneralConfigInformation info; info.name = plugin.getMetaInformation().getName(); info.author = plugin.getMetaInformation().getAuthor(); @@ -100,7 +103,7 @@ void ConfigUtils::displayMenu() { DEBUG_FUNCTION_LINE_ERR("Failed to create config for plugin: \"%s\"", info.name.c_str()); } } else { - for (const auto &hook : plugin.getPluginInformation().getHookDataList()) { + for (const auto &hook : plugin.getPluginLinkInformation()->getHookDataList()) { if (hook.getType() == WUPS_LOADER_HOOK_GET_CONFIG_DEPRECATED) { if (hook.getFunctionPointer() == nullptr) { DEBUG_FUNCTION_LINE_ERR("Hook had invalid ptr"); diff --git a/source/utils/exports.cpp b/source/utils/exports.cpp index e0eafb3..f096a6c 100644 --- a/source/utils/exports.cpp +++ b/source/utils/exports.cpp @@ -272,9 +272,9 @@ extern "C" PluginBackendApiErrorType WUPSGetSectionInformationForPlugin(const wu if (handle != 0 && plugin_section_list != nullptr && buffer_size != 0) { bool found = false; for (const auto &curContainer : gLoadedPlugins) { - if (curContainer.getHandle() == handle) { + if (curContainer.isPluginLinkedAndLoaded() && curContainer.getHandle() == handle) { found = true; - const auto §ionInfoList = curContainer.getPluginInformation().getSectionInfoList(); + const auto §ionInfoList = curContainer.getPluginLinkInformation()->getSectionInfoList(); uint32_t offset = 0; for (auto const &[key, sectionInfo] : sectionInfoList) { @@ -316,9 +316,9 @@ extern "C" PluginBackendApiErrorType WUPSGetSectionMemoryAddresses(wups_backend_ return PLUGIN_BACKEND_API_ERROR_INVALID_ARG; } for (const auto &curContainer : gLoadedPlugins) { - if (curContainer.getHandle() == handle) { - *textAddress = (void *) curContainer.getPluginInformation().getTextMemory().data(); - *dataAddress = (void *) curContainer.getPluginInformation().getDataMemory().data(); + if (curContainer.isPluginLinkedAndLoaded() && curContainer.getHandle() == handle) { + *textAddress = (void *) curContainer.getPluginLinkInformation()->getTextMemory().data(); + *dataAddress = (void *) curContainer.getPluginLinkInformation()->getDataMemory().data(); return PLUGIN_BACKEND_API_ERROR_NONE; } }