diff --git a/source/plugin/FunctionData.cpp b/source/plugin/FunctionData.cpp new file mode 100644 index 0000000..48835af --- /dev/null +++ b/source/plugin/FunctionData.cpp @@ -0,0 +1,85 @@ +#include "FunctionData.h" + +FunctionData::FunctionData(void *paddress, void *vaddress, std::string_view name, function_replacement_library_type_t library, void *replaceAddr, void *replaceCall, FunctionPatcherTargetProcess targetProcess) { + this->paddress = paddress; + this->vaddress = vaddress; + this->name = name; + this->library = library; + this->targetProcess = targetProcess; + this->replaceAddr = replaceAddr; + this->replaceCall = replaceCall; +} + +FunctionData::~FunctionData() { + if (handle != 0) { + DEBUG_FUNCTION_LINE_WARN("Destroying FunctionData while it was still patched. This should never happen."); + RemovePatch(); + } +} + +const std::string &FunctionData::getName() const { + return this->name; +} + +function_replacement_library_type_t FunctionData::getLibrary() const { + return this->library; +} + +const void *FunctionData::getPhysicalAddress() const { + return paddress; +} + +const void *FunctionData::getVirtualAddress() const { + return vaddress; +} + +const void *FunctionData::getReplaceAddress() const { + return replaceAddr; +} + +const void *FunctionData::getReplaceCall() const { + return replaceCall; +} + +FunctionPatcherTargetProcess FunctionData::getTargetProcess() const { + return targetProcess; +} + +bool FunctionData::AddPatch() { + if (handle == 0) { + function_replacement_data_t functionData = { + .version = FUNCTION_REPLACEMENT_DATA_STRUCT_VERSION, + .type = FUNCTION_PATCHER_REPLACE_BY_LIB_OR_ADDRESS, + .physicalAddr = reinterpret_cast(this->paddress), + .virtualAddr = reinterpret_cast(this->vaddress), + .replaceAddr = reinterpret_cast(this->replaceAddr), + .replaceCall = static_cast(this->replaceCall), + .targetProcess = this->targetProcess, + .ReplaceInRPL = { + .function_name = this->name.c_str(), + .library = this->library, + }}; + + if (FunctionPatcher_AddFunctionPatch(&functionData, &handle, nullptr) != FUNCTION_PATCHER_RESULT_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to add patch for function (\"%s\" PA:%08X VA:%08X)", this->name.c_str(), this->paddress, this->vaddress); + return false; + } + } else { + DEBUG_FUNCTION_LINE("Function patch has already been added."); + } + return true; +} + +bool FunctionData::RemovePatch() { + if (handle != 0) { + if (FunctionPatcher_RemoveFunctionPatch(handle) != FUNCTION_PATCHER_RESULT_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Failed to remove patch for function"); + return false; + } + handle = 0; + } else { + DEBUG_FUNCTION_LINE_VERBOSE("Was not patched."); + } + + return true; +} diff --git a/source/plugin/FunctionData.h b/source/plugin/FunctionData.h index 5d496fb..6402255 100644 --- a/source/plugin/FunctionData.h +++ b/source/plugin/FunctionData.h @@ -25,89 +25,27 @@ class FunctionData { public: FunctionData(void *paddress, void *vaddress, std::string_view name, function_replacement_library_type_t library, void *replaceAddr, void *replaceCall, - FunctionPatcherTargetProcess targetProcess) { - this->paddress = paddress; - this->vaddress = vaddress; - this->name = name; - this->library = library; - this->targetProcess = targetProcess; - this->replaceAddr = replaceAddr; - this->replaceCall = replaceCall; - } + FunctionPatcherTargetProcess targetProcess); - ~FunctionData() { - if (handle != 0) { - DEBUG_FUNCTION_LINE_WARN("Destroying FunctionData while it was still patched. This should never happen."); - RemovePatch(); - } - } + ~FunctionData(); - [[nodiscard]] const std::string &getName() const { - return this->name; - } + [[nodiscard]] const std::string &getName() const; - [[nodiscard]] function_replacement_library_type_t getLibrary() const { - return this->library; - } + [[maybe_unused]] [[nodiscard]] function_replacement_library_type_t getLibrary() const; - [[nodiscard]] const void *getPhysicalAddress() const { - return paddress; - } + [[maybe_unused]] [[nodiscard]] const void *getPhysicalAddress() const; - [[nodiscard]] const void *getVirtualAddress() const { - return vaddress; - } + [[maybe_unused]] [[nodiscard]] const void *getVirtualAddress() const; - [[nodiscard]] const void *getReplaceAddress() const { - return replaceAddr; - } + [[maybe_unused]] [[nodiscard]] const void *getReplaceAddress() const; - [[nodiscard]] const void *getReplaceCall() const { - return replaceCall; - } + [[maybe_unused]] [[nodiscard]] const void *getReplaceCall() const; - [[nodiscard]] FunctionPatcherTargetProcess getTargetProcess() const { - return targetProcess; - } + [[maybe_unused]] [[nodiscard]] FunctionPatcherTargetProcess getTargetProcess() const; - bool AddPatch() { - if (handle == 0) { - function_replacement_data_t functionData = { - .version = FUNCTION_REPLACEMENT_DATA_STRUCT_VERSION, - .type = FUNCTION_PATCHER_REPLACE_BY_LIB_OR_ADDRESS, - .physicalAddr = reinterpret_cast(this->paddress), - .virtualAddr = reinterpret_cast(this->vaddress), - .replaceAddr = reinterpret_cast(this->replaceAddr), - .replaceCall = static_cast(this->replaceCall), - .targetProcess = this->targetProcess, - .ReplaceInRPL = { - .function_name = this->name.c_str(), - .library = this->library, - }}; + bool AddPatch(); - if (FunctionPatcher_AddFunctionPatch(&functionData, &handle, nullptr) != FUNCTION_PATCHER_RESULT_SUCCESS) { - DEBUG_FUNCTION_LINE_ERR("Failed to add patch for function (\"%s\" PA:%08X VA:%08X)", this->name.c_str(), this->paddress, this->vaddress); - return false; - } - } else { - DEBUG_FUNCTION_LINE("Function patch has already been added."); - } - return true; - } - - bool RemovePatch() { - if (handle != 0) { - if (FunctionPatcher_RemoveFunctionPatch(handle) != FUNCTION_PATCHER_RESULT_SUCCESS) { - DEBUG_FUNCTION_LINE_ERR("Failed to remove patch for function"); - return false; - } - handle = 0; - } else { - DEBUG_FUNCTION_LINE_VERBOSE("Was not patched."); - } - - return true; - } + bool RemovePatch(); private: void *paddress = nullptr; diff --git a/source/plugin/PluginConfigData.cpp b/source/plugin/PluginConfigData.cpp new file mode 100644 index 0000000..6e4f639 --- /dev/null +++ b/source/plugin/PluginConfigData.cpp @@ -0,0 +1,41 @@ +#include "PluginConfigData.h" + +PluginConfigData::PluginConfigData(std::string_view name, WUPSConfigAPI_MenuOpenedCallback openedCallback, WUPSConfigAPI_MenuClosedCallback closedCallback) : mName(name), + mOpenedCallback(openedCallback), + mClosedCallback(closedCallback) { +} + +std::optional PluginConfigData::createConfig() const { + WUPSConfigHandle handle; + if (WUPSConfigAPIBackend::Intern::CreateConfig(mName.c_str(), &handle) == WUPSCONFIG_API_RESULT_SUCCESS) { + return handle; + } + return std::nullopt; +} + +WUPSConfigAPIStatus PluginConfigData::CallMenuOpenendCallback(WUPSConfigHandle config) const { + if (mOpenedCallback == nullptr) { + return WUPSCONFIG_API_RESULT_MISSING_CALLBACK; + } + if (mOpenedCallback(WUPSConfigCategoryHandle(config.handle)) != WUPSCONFIG_API_CALLBACK_RESULT_SUCCESS) { + return WUPSCONFIG_API_RESULT_UNKNOWN_ERROR; + } + return WUPSCONFIG_API_RESULT_SUCCESS; +} + +WUPSConfigAPIStatus PluginConfigData::CallMenuClosedCallback() const { + if (mClosedCallback == nullptr) { + return WUPSCONFIG_API_RESULT_MISSING_CALLBACK; + } + mClosedCallback(); + return WUPSCONFIG_API_RESULT_SUCCESS; +} + +std::optional PluginConfigData::create(WUPSConfigAPIOptions options, WUPSConfigAPI_MenuOpenedCallback openedCallback, WUPSConfigAPI_MenuClosedCallback closedCallback) { + if (options.version != 1) { + return std::nullopt; + } + PluginConfigData result(options.data.v1.name, openedCallback, closedCallback); + + return result; +} diff --git a/source/plugin/PluginConfigData.h b/source/plugin/PluginConfigData.h index c4df471..c78090c 100644 --- a/source/plugin/PluginConfigData.h +++ b/source/plugin/PluginConfigData.h @@ -9,45 +9,15 @@ class PluginConfigData { public: PluginConfigData(std::string_view name, WUPSConfigAPI_MenuOpenedCallback openedCallback, - WUPSConfigAPI_MenuClosedCallback closedCallback) : mName(name), - mOpenedCallback(openedCallback), - mClosedCallback(closedCallback) { - } + WUPSConfigAPI_MenuClosedCallback closedCallback); - [[nodiscard]] std::optional createConfig() const{ - WUPSConfigHandle handle; - if (WUPSConfigAPIBackend::Intern::CreateConfig(mName.c_str(), &handle) == WUPSCONFIG_API_RESULT_SUCCESS) { - return handle; - } - return std::nullopt; - } + [[nodiscard]] std::optional createConfig() const; - [[nodiscard]] WUPSConfigAPIStatus CallMenuOpenendCallback(WUPSConfigHandle config) const { - if (mOpenedCallback == nullptr) { - return WUPSCONFIG_API_RESULT_MISSING_CALLBACK; - } - if (mOpenedCallback(WUPSConfigCategoryHandle(config.handle)) != WUPSCONFIG_API_CALLBACK_RESULT_SUCCESS) { - return WUPSCONFIG_API_RESULT_UNKNOWN_ERROR; - } - return WUPSCONFIG_API_RESULT_SUCCESS; - } + [[nodiscard]] WUPSConfigAPIStatus CallMenuOpenendCallback(WUPSConfigHandle config) const; - [[nodiscard]] WUPSConfigAPIStatus CallMenuClosedCallback() const { - if (mClosedCallback == nullptr) { - return WUPSCONFIG_API_RESULT_MISSING_CALLBACK; - } - mClosedCallback(); - return WUPSCONFIG_API_RESULT_SUCCESS; - } + [[nodiscard]] WUPSConfigAPIStatus CallMenuClosedCallback() const; - static std::optional create(WUPSConfigAPIOptions options, WUPSConfigAPI_MenuOpenedCallback openedCallback, WUPSConfigAPI_MenuClosedCallback closedCallback) { - if (options.version != 1) { - return std::nullopt; - } - PluginConfigData result(options.data.v1.name, openedCallback, closedCallback); - - return result; - } + static std::optional create(WUPSConfigAPIOptions options, WUPSConfigAPI_MenuOpenedCallback openedCallback, WUPSConfigAPI_MenuClosedCallback closedCallback); private: std::string mName; diff --git a/source/plugin/PluginContainer.cpp b/source/plugin/PluginContainer.cpp new file mode 100644 index 0000000..7b78458 --- /dev/null +++ b/source/plugin/PluginContainer.cpp @@ -0,0 +1,83 @@ +#include "PluginContainer.h" + +PluginContainer::PluginContainer(PluginMetaInformation metaInformation, PluginInformation pluginInformation, std::shared_ptr pluginData) + : mMetaInformation(std::move(metaInformation)), + mPluginInformation(std::move(pluginInformation)), + mPluginData(std::move(pluginData)) { +} + +PluginContainer::PluginContainer(PluginContainer &&src) : mMetaInformation(std::move(src.mMetaInformation)), + mPluginInformation(std::move(src.mPluginInformation)), + mPluginData(std::move(src.mPluginData)), + mPluginConfigData(std::move(src.mPluginConfigData)), + storageRootItem(src.storageRootItem) + +{ + src.storageRootItem = {}; +} + +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; + + storageRootItem = nullptr; + } + return *this; +} + +const PluginMetaInformation &PluginContainer::getMetaInformation() const { + return this->mMetaInformation; +} + +const PluginInformation &PluginContainer::getPluginInformation() const { + return this->mPluginInformation; +} + +PluginInformation &PluginContainer::getPluginInformation() { + return this->mPluginInformation; +} + +std::shared_ptr PluginContainer::getPluginDataCopy() const { + return mPluginData; +} + +uint32_t PluginContainer::getHandle() const { + return (uint32_t) this; +} + +const std::optional &PluginContainer::getConfigData() const { + return mPluginConfigData; +} + +void PluginContainer::setConfigData(const PluginConfigData &pluginConfigData) { + mPluginConfigData = pluginConfigData; +} + +WUPSStorageError PluginContainer::OpenStorage() { + if (getMetaInformation().getWUPSVersion() < WUPSVersion(0, 8, 0)) { + return WUPS_STORAGE_ERROR_SUCCESS; + } + auto &storageId = getMetaInformation().getStorageId(); + if (storageId.empty()) { + return WUPS_STORAGE_ERROR_SUCCESS; + } + auto res = StorageUtils::API::Internal::OpenStorage(storageId, storageRootItem); + if (res != WUPS_STORAGE_ERROR_SUCCESS) { + storageRootItem = nullptr; + } + return res; +} + +WUPSStorageError PluginContainer::CloseStorage() { + if (getMetaInformation().getWUPSVersion() < WUPSVersion(0, 8, 0)) { + return WUPS_STORAGE_ERROR_SUCCESS; + } + if (storageRootItem == nullptr) { + return WUPS_STORAGE_ERROR_SUCCESS; + } + return StorageUtils::API::Internal::CloseStorage(storageRootItem); +} diff --git a/source/plugin/PluginContainer.h b/source/plugin/PluginContainer.h index 4cdee98..8e8619f 100644 --- a/source/plugin/PluginContainer.h +++ b/source/plugin/PluginContainer.h @@ -28,91 +28,33 @@ class PluginContainer { public: - PluginContainer(PluginMetaInformation metaInformation, PluginInformation pluginInformation, std::shared_ptr pluginData) - : mMetaInformation(std::move(metaInformation)), - mPluginInformation(std::move(pluginInformation)), - mPluginData(std::move(pluginData)) { - } + PluginContainer(PluginMetaInformation metaInformation, PluginInformation pluginInformation, std::shared_ptr pluginData); PluginContainer(const PluginContainer &) = delete; - PluginContainer(PluginContainer &&src) : mMetaInformation(std::move(src.mMetaInformation)), - mPluginInformation(std::move(src.mPluginInformation)), - mPluginData(std::move(src.mPluginData)), - mPluginConfigData(std::move(src.mPluginConfigData)), - storageRootItem(src.storageRootItem) + PluginContainer(PluginContainer &&src); - { - src.storageRootItem = {}; - } - - 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; - - storageRootItem = nullptr; - } - return *this; - } + PluginContainer &operator=(PluginContainer &&src); - [[nodiscard]] const PluginMetaInformation &getMetaInformation() const { - return this->mMetaInformation; - } + [[nodiscard]] const PluginMetaInformation &getMetaInformation() const; - [[nodiscard]] const PluginInformation &getPluginInformation() const { - return this->mPluginInformation; - } - [[nodiscard]] PluginInformation &getPluginInformation() { - return this->mPluginInformation; - } + [[nodiscard]] const PluginInformation &getPluginInformation() const; + [[nodiscard]] PluginInformation &getPluginInformation(); - [[nodiscard]] std::shared_ptr getPluginDataCopy() const { - return mPluginData; - } + [[nodiscard]] std::shared_ptr getPluginDataCopy() const; - [[nodiscard]] uint32_t getHandle() const { - return (uint32_t) this; - } + [[nodiscard]] uint32_t getHandle() const; - [[nodiscard]] const std::optional &getConfigData() const { - return mPluginConfigData; - } + [[nodiscard]] const std::optional &getConfigData() const; - void setConfigData(const PluginConfigData &pluginConfigData) { - mPluginConfigData = pluginConfigData; - } + void setConfigData(const PluginConfigData &pluginConfigData); - WUPSStorageError OpenStorage() { - if (getMetaInformation().getWUPSVersion() < WUPSVersion(0, 8, 0)) { - return WUPS_STORAGE_ERROR_SUCCESS; - } - auto &storageId = getMetaInformation().getStorageId(); - if (storageId.empty()) { - return WUPS_STORAGE_ERROR_SUCCESS; - } - auto res = StorageUtils::API::Internal::OpenStorage(storageId, storageRootItem); - if (res != WUPS_STORAGE_ERROR_SUCCESS) { - storageRootItem = nullptr; - } - return res; - } + WUPSStorageError OpenStorage(); - WUPSStorageError CloseStorage() { - if (getMetaInformation().getWUPSVersion() < WUPSVersion(0, 8, 0)) { - return WUPS_STORAGE_ERROR_SUCCESS; - } - if (storageRootItem == nullptr) { - return WUPS_STORAGE_ERROR_SUCCESS; - } - return StorageUtils::API::Internal::CloseStorage(storageRootItem); - } + WUPSStorageError CloseStorage(); [[nodiscard]] wups_storage_root_item getStorageRootItem() const { return storageRootItem; diff --git a/source/plugin/PluginData.cpp b/source/plugin/PluginData.cpp new file mode 100644 index 0000000..98071eb --- /dev/null +++ b/source/plugin/PluginData.cpp @@ -0,0 +1,13 @@ +#include "PluginData.h" + +uint32_t PluginData::getHandle() const { + return (uint32_t) this; +} + +std::span PluginData::getBuffer() const { + return mBuffer; +} + +const std::string &PluginData::getSource() const { + return mSource; +} diff --git a/source/plugin/PluginData.h b/source/plugin/PluginData.h index a181956..8fe6933 100644 --- a/source/plugin/PluginData.h +++ b/source/plugin/PluginData.h @@ -33,17 +33,11 @@ public: explicit PluginData(std::span buffer, std::string_view source) : mBuffer(buffer.begin(), buffer.end()), mSource(source) { } - [[nodiscard]] uint32_t getHandle() const { - return (uint32_t) this; - } + [[nodiscard]] uint32_t getHandle() const; - [[nodiscard]] std::span getBuffer() const { - return mBuffer; - } + [[nodiscard]] std::span getBuffer() const; - [[nodiscard]] const std::string &getSource() const { - return mSource; - } + [[nodiscard]] const std::string &getSource() const; private: std::vector mBuffer; diff --git a/source/plugin/PluginInformation.cpp b/source/plugin/PluginInformation.cpp new file mode 100644 index 0000000..7bccf71 --- /dev/null +++ b/source/plugin/PluginInformation.cpp @@ -0,0 +1,112 @@ +#include "PluginInformation.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)) + +{ + src.mTrampolineId = {}; +} + +PluginInformation &PluginInformation::operator=(PluginInformation &&src) { + if (this != &src) { + this->mHookDataList = std::move(src.mHookDataList); + this->mFunctionDataList = std::move(src.mFunctionDataList); + this->mRelocationDataList = std::move(src.mRelocationDataList); + this->mSymbolDataList = std::move(src.mSymbolDataList); + this->mSectionInfoList = std::move(src.mSectionInfoList); + this->mTrampolineId = src.mTrampolineId; + this->mAllocatedTextMemoryAddress = std::move(src.mAllocatedTextMemoryAddress); + this->mAllocatedDataMemoryAddress = std::move(src.mAllocatedDataMemoryAddress); + src.mTrampolineId = {}; + } + return *this; +} + +void PluginInformation::addHookData(HookData hook_data) { + mHookDataList.push_back(hook_data); +} + +const std::vector &PluginInformation::getHookDataList() const { + return mHookDataList; +} + +void PluginInformation::addFunctionData(FunctionData function_data) { + mFunctionDataList.push_back(std::move(function_data)); +} + +const std::vector &PluginInformation::getFunctionDataList() const { + return mFunctionDataList; +} + +std::vector &PluginInformation::getFunctionDataList() { + return mFunctionDataList; +} + +void PluginInformation::addRelocationData(RelocationData relocation_data) { + mRelocationDataList.push_back(std::move(relocation_data)); +} + +const std::vector &PluginInformation::getRelocationDataList() const { + return mRelocationDataList; +} + +void PluginInformation::addFunctionSymbolData(const FunctionSymbolData &symbol_data) { + mSymbolDataList.insert(symbol_data); +} + +void PluginInformation::addSectionInfo(const SectionInfo §ionInfo) { + mSectionInfoList.insert(std::pair(sectionInfo.getName(), sectionInfo)); +} + +const std::map &PluginInformation::getSectionInfoList() const { + return mSectionInfoList; +} + +std::optional PluginInformation::getSectionInfo(const std::string §ionName) const { + if (getSectionInfoList().contains(sectionName)) { + return mSectionInfoList.at(sectionName); + } + return std::nullopt; +} + +void PluginInformation::setTrampolineId(uint8_t trampolineId) { + this->mTrampolineId = trampolineId; +} + +uint8_t PluginInformation::getTrampolineId() const { + return mTrampolineId; +} + +const FunctionSymbolData *PluginInformation::getNearestFunctionSymbolData(uint32_t address) const { + const FunctionSymbolData *result = nullptr; + + bool foundHit = false; + for (auto &cur : mSymbolDataList) { + if (foundHit && address < (uint32_t) cur.getAddress()) { + break; + } + if (address >= (uint32_t) cur.getAddress()) { + result = &cur; + foundHit = true; + } + } + if (!foundHit) { + return nullptr; + } + + return result; +} + +const HeapMemoryFixedSize &PluginInformation::getTextMemory() const { + return mAllocatedTextMemoryAddress; +} + +const HeapMemoryFixedSize &PluginInformation::getDataMemory() const { + return mAllocatedDataMemoryAddress; +} diff --git a/source/plugin/PluginInformation.h b/source/plugin/PluginInformation.h index eba8567..109e426 100644 --- a/source/plugin/PluginInformation.h +++ b/source/plugin/PluginInformation.h @@ -45,122 +45,45 @@ public: PluginInformation(const PluginInformation &) = delete; - 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)) + PluginInformation(PluginInformation &&src); - { - src.mTrampolineId = {}; - } - - PluginInformation &operator=(PluginInformation &&src) { - if (this != &src) { - this->mHookDataList = std::move(src.mHookDataList); - this->mFunctionDataList = std::move(src.mFunctionDataList); - this->mRelocationDataList = std::move(src.mRelocationDataList); - this->mSymbolDataList = std::move(src.mSymbolDataList); - this->mSectionInfoList = std::move(src.mSectionInfoList); - this->mTrampolineId = src.mTrampolineId; - this->mAllocatedTextMemoryAddress = std::move(src.mAllocatedTextMemoryAddress); - this->mAllocatedDataMemoryAddress = std::move(src.mAllocatedDataMemoryAddress); - src.mTrampolineId = {}; - } - return *this; - } + PluginInformation &operator=(PluginInformation &&src); - void addHookData(HookData hook_data) { - mHookDataList.push_back(hook_data); - } + void addHookData(HookData hook_data); - [[nodiscard]] const std::vector &getHookDataList() const { - return mHookDataList; - } + [[nodiscard]] const std::vector &getHookDataList() const; - void addFunctionData(FunctionData function_data) { - mFunctionDataList.push_back(std::move(function_data)); - } + void addFunctionData(FunctionData function_data); - [[nodiscard]] const std::vector &getFunctionDataList() const { - return mFunctionDataList; - } + [[nodiscard]] const std::vector &getFunctionDataList() const; - [[nodiscard]] std::vector &getFunctionDataList() { - return mFunctionDataList; - } + [[nodiscard]] std::vector &getFunctionDataList(); - void addRelocationData(RelocationData relocation_data) { - mRelocationDataList.push_back(std::move(relocation_data)); - } + void addRelocationData(RelocationData relocation_data); - [[nodiscard]] const std::vector &getRelocationDataList() const { - return mRelocationDataList; - } + [[nodiscard]] const std::vector &getRelocationDataList() const; - void addFunctionSymbolData(const FunctionSymbolData &symbol_data) { - mSymbolDataList.insert(symbol_data); - } + void addFunctionSymbolData(const FunctionSymbolData &symbol_data); - void addSectionInfo(const SectionInfo §ionInfo) { - mSectionInfoList.insert(std::pair(sectionInfo.getName(), sectionInfo)); - } + void addSectionInfo(const SectionInfo §ionInfo); - [[nodiscard]] const std::map &getSectionInfoList() const { - return mSectionInfoList; - } + [[nodiscard]] const std::map &getSectionInfoList() const; - [[nodiscard]] std::optional getSectionInfo(const std::string §ionName) const { - if (getSectionInfoList().contains(sectionName)) { - return mSectionInfoList.at(sectionName); - } - return std::nullopt; - } + [[nodiscard]] std::optional getSectionInfo(const std::string §ionName) const; - void setTrampolineId(uint8_t trampolineId) { - this->mTrampolineId = trampolineId; - } + void setTrampolineId(uint8_t trampolineId); - [[nodiscard]] uint8_t getTrampolineId() const { - return mTrampolineId; - } + [[nodiscard]] uint8_t getTrampolineId() const; - [[nodiscard]] const FunctionSymbolData *getNearestFunctionSymbolData(uint32_t address) const { - const FunctionSymbolData *result = nullptr; + [[nodiscard]] const FunctionSymbolData *getNearestFunctionSymbolData(uint32_t address) const; - bool foundHit = false; - for (auto &cur : mSymbolDataList) { - if (foundHit && address < (uint32_t) cur.getAddress()) { - break; - } - if (address >= (uint32_t) cur.getAddress()) { - result = &cur; - foundHit = true; - } - } - if (!foundHit) { - return nullptr; - } + [[nodiscard]] const HeapMemoryFixedSize &getTextMemory() const; - return result; - } - - [[nodiscard]] const HeapMemoryFixedSize &getTextMemory() const { - return mAllocatedTextMemoryAddress; - } - - [[nodiscard]] const HeapMemoryFixedSize &getDataMemory() const { - return mAllocatedDataMemoryAddress; - } + [[nodiscard]] const HeapMemoryFixedSize &getDataMemory() const; private: - PluginInformation(){ - - } + PluginInformation() = default; std::vector mHookDataList; std::vector mFunctionDataList; std::vector mRelocationDataList;