2020-04-29 18:02:36 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-02-04 16:25:44 +01:00
|
|
|
#include "FunctionData.h"
|
|
|
|
#include "FunctionSymbolData.h"
|
|
|
|
#include "HookData.h"
|
|
|
|
#include "RelocationData.h"
|
|
|
|
#include "SectionInfo.h"
|
2023-11-04 15:32:45 +01:00
|
|
|
#include "utils/HeapMemoryFixedSize.h"
|
2024-11-27 20:44:36 +01:00
|
|
|
#include <cstdint>
|
2020-04-29 18:02:36 +02:00
|
|
|
#include <map>
|
|
|
|
#include <optional>
|
2022-02-04 16:25:44 +01:00
|
|
|
#include <set>
|
2020-04-29 18:02:36 +02:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2021-12-15 17:09:30 +01:00
|
|
|
struct FunctionSymbolDataComparator {
|
2024-03-24 07:40:58 +01:00
|
|
|
bool operator()(const FunctionSymbolData &lhs,
|
|
|
|
const FunctionSymbolData &rhs) const {
|
|
|
|
return lhs < rhs;
|
2021-12-15 17:09:30 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
class PluginLinkInformation {
|
2020-04-29 18:02:36 +02:00
|
|
|
public:
|
2024-08-03 17:23:27 +02:00
|
|
|
PluginLinkInformation(const PluginLinkInformation &) = delete;
|
2024-03-24 07:40:58 +01:00
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
PluginLinkInformation(PluginLinkInformation &&src) noexcept;
|
2024-03-24 07:40:58 +01:00
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
PluginLinkInformation &operator=(PluginLinkInformation &&src);
|
2020-04-29 18:02:36 +02:00
|
|
|
|
2024-03-24 07:50:30 +01:00
|
|
|
[[nodiscard]] const std::vector<HookData> &getHookDataList() const;
|
2020-04-29 18:02:36 +02:00
|
|
|
|
2024-03-24 07:50:30 +01:00
|
|
|
[[nodiscard]] const std::vector<FunctionData> &getFunctionDataList() const;
|
2020-04-29 18:02:36 +02:00
|
|
|
|
2024-03-24 07:50:30 +01:00
|
|
|
[[nodiscard]] std::vector<FunctionData> &getFunctionDataList();
|
2024-03-24 07:40:58 +01:00
|
|
|
|
2024-03-24 07:50:30 +01:00
|
|
|
[[nodiscard]] const std::vector<RelocationData> &getRelocationDataList() const;
|
2020-04-29 18:02:36 +02:00
|
|
|
|
2024-03-24 07:50:30 +01:00
|
|
|
[[nodiscard]] const std::map<std::string, SectionInfo> &getSectionInfoList() const;
|
2020-04-29 18:02:36 +02:00
|
|
|
|
2024-03-24 07:50:30 +01:00
|
|
|
[[nodiscard]] std::optional<SectionInfo> getSectionInfo(const std::string §ionName) const;
|
2020-04-29 18:02:36 +02:00
|
|
|
|
2024-03-24 07:50:30 +01:00
|
|
|
[[nodiscard]] uint8_t getTrampolineId() const;
|
2020-05-03 12:23:50 +02:00
|
|
|
|
2024-03-24 07:50:30 +01:00
|
|
|
[[nodiscard]] const FunctionSymbolData *getNearestFunctionSymbolData(uint32_t address) const;
|
2022-05-14 14:00:20 +02:00
|
|
|
|
2024-03-24 07:50:30 +01:00
|
|
|
[[nodiscard]] const HeapMemoryFixedSize &getTextMemory() const;
|
2023-02-17 17:30:28 +01:00
|
|
|
|
2024-03-24 07:50:30 +01:00
|
|
|
[[nodiscard]] const HeapMemoryFixedSize &getDataMemory() const;
|
2023-02-17 17:30:28 +01:00
|
|
|
|
2020-04-29 18:02:36 +02:00
|
|
|
private:
|
2024-08-03 17:23:27 +02:00
|
|
|
PluginLinkInformation() = default;
|
2024-03-24 09:30:43 +01:00
|
|
|
|
2024-11-27 20:44:36 +01:00
|
|
|
void addHookData(const HookData &hook_data);
|
2024-03-24 09:30:43 +01:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2024-03-24 07:40:58 +01:00
|
|
|
std::vector<HookData> mHookDataList;
|
|
|
|
std::vector<FunctionData> mFunctionDataList;
|
|
|
|
std::vector<RelocationData> mRelocationDataList;
|
|
|
|
std::set<FunctionSymbolData, FunctionSymbolDataComparator> mSymbolDataList;
|
|
|
|
std::map<std::string, SectionInfo> mSectionInfoList;
|
2020-04-29 18:02:36 +02:00
|
|
|
|
2023-11-04 15:32:45 +01:00
|
|
|
uint8_t mTrampolineId = 0;
|
2020-04-29 18:02:36 +02:00
|
|
|
|
2023-11-04 15:32:45 +01:00
|
|
|
HeapMemoryFixedSize mAllocatedTextMemoryAddress;
|
|
|
|
HeapMemoryFixedSize mAllocatedDataMemoryAddress;
|
2020-05-03 12:23:50 +02:00
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
friend class PluginLinkInformationFactory;
|
2020-04-29 18:02:36 +02:00
|
|
|
};
|