/**************************************************************************** * Copyright (C) 2018 Maschell * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ #pragma once #include "FunctionData.h" #include "FunctionSymbolData.h" #include "HookData.h" #include "PluginMetaInformation.h" #include "RelocationData.h" #include "SectionInfo.h" #include "utils/HeapMemoryFixedSize.h" #include "utils/utils.h" #include #include #include #include #include #include #include struct FunctionSymbolDataComparator { bool operator()(const FunctionSymbolData &lhs, const FunctionSymbolData &rhs) const { return lhs < rhs; } }; class PluginLinkInformation { public: static PluginLinkInformation CreateStub(); PluginLinkInformation(const PluginLinkInformation &) = delete; PluginLinkInformation(PluginLinkInformation &&src); PluginLinkInformation &operator=(PluginLinkInformation &&src); [[nodiscard]] const std::vector &getHookDataList() const; [[nodiscard]] const std::vector &getFunctionDataList() const; [[nodiscard]] std::vector &getFunctionDataList(); [[nodiscard]] const std::vector &getRelocationDataList() const; [[nodiscard]] const std::map &getSectionInfoList() const; [[nodiscard]] std::optional getSectionInfo(const std::string §ionName) const; [[nodiscard]] uint8_t getTrampolineId() const; [[nodiscard]] const FunctionSymbolData *getNearestFunctionSymbolData(uint32_t address) const; [[nodiscard]] const HeapMemoryFixedSize &getTextMemory() const; [[nodiscard]] const HeapMemoryFixedSize &getDataMemory() const; [[nodiscard]] bool hasValidData() const; private: PluginLinkInformation() = default; void addHookData(HookData hook_data); void addFunctionData(FunctionData function_data); void addRelocationData(RelocationData relocation_data); void addFunctionSymbolData(const FunctionSymbolData &symbol_data); void addSectionInfo(const SectionInfo §ionInfo); void setTrampolineId(uint8_t trampolineId); std::vector mHookDataList; std::vector mFunctionDataList; std::vector mRelocationDataList; std::set mSymbolDataList; std::map mSectionInfoList; uint8_t mTrampolineId = 0; HeapMemoryFixedSize mAllocatedTextMemoryAddress; HeapMemoryFixedSize mAllocatedDataMemoryAddress; friend class PluginLinkInformationFactory; };