2024-08-03 17:23:27 +02:00
|
|
|
#include "PluginLinkInformation.h"
|
2024-03-24 07:50:30 +01:00
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
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))
|
2024-03-24 07:50:30 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
src.mTrampolineId = {};
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
PluginLinkInformation &PluginLinkInformation::operator=(PluginLinkInformation &&src) {
|
2024-03-24 07:50:30 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
void PluginLinkInformation::addHookData(const HookData &hook_data) {
|
2024-03-24 07:50:30 +01:00
|
|
|
mHookDataList.push_back(hook_data);
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
const std::vector<HookData> &PluginLinkInformation::getHookDataList() const {
|
2024-03-24 07:50:30 +01:00
|
|
|
return mHookDataList;
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
void PluginLinkInformation::addFunctionData(FunctionData function_data) {
|
2024-03-24 07:50:30 +01:00
|
|
|
mFunctionDataList.push_back(std::move(function_data));
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
const std::vector<FunctionData> &PluginLinkInformation::getFunctionDataList() const {
|
2024-03-24 07:50:30 +01:00
|
|
|
return mFunctionDataList;
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
std::vector<FunctionData> &PluginLinkInformation::getFunctionDataList() {
|
2024-03-24 07:50:30 +01:00
|
|
|
return mFunctionDataList;
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
void PluginLinkInformation::addRelocationData(RelocationData relocation_data) {
|
2024-03-24 07:50:30 +01:00
|
|
|
mRelocationDataList.push_back(std::move(relocation_data));
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
const std::vector<RelocationData> &PluginLinkInformation::getRelocationDataList() const {
|
2024-03-24 07:50:30 +01:00
|
|
|
return mRelocationDataList;
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
void PluginLinkInformation::addFunctionSymbolData(const FunctionSymbolData &symbol_data) {
|
2024-03-24 07:50:30 +01:00
|
|
|
mSymbolDataList.insert(symbol_data);
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
void PluginLinkInformation::addSectionInfo(const SectionInfo §ionInfo) {
|
2024-03-24 07:50:30 +01:00
|
|
|
mSectionInfoList.insert(std::pair(sectionInfo.getName(), sectionInfo));
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
const std::map<std::string, SectionInfo> &PluginLinkInformation::getSectionInfoList() const {
|
2024-03-24 07:50:30 +01:00
|
|
|
return mSectionInfoList;
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
std::optional<SectionInfo> PluginLinkInformation::getSectionInfo(const std::string §ionName) const {
|
2024-03-24 07:50:30 +01:00
|
|
|
if (getSectionInfoList().contains(sectionName)) {
|
|
|
|
return mSectionInfoList.at(sectionName);
|
|
|
|
}
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
|
|
|
|
void PluginLinkInformation::setTrampolineId(const uint8_t trampolineId) {
|
2024-03-24 07:50:30 +01:00
|
|
|
this->mTrampolineId = trampolineId;
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
uint8_t PluginLinkInformation::getTrampolineId() const {
|
2024-03-24 07:50:30 +01:00
|
|
|
return mTrampolineId;
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
const FunctionSymbolData *PluginLinkInformation::getNearestFunctionSymbolData(uint32_t address) const {
|
2024-03-24 07:50:30 +01:00
|
|
|
const FunctionSymbolData *result = nullptr;
|
|
|
|
|
|
|
|
bool foundHit = false;
|
|
|
|
for (auto &cur : mSymbolDataList) {
|
2024-11-27 20:44:36 +01:00
|
|
|
if (foundHit && address < reinterpret_cast<uint32_t>(cur.getAddress())) {
|
2024-03-24 07:50:30 +01:00
|
|
|
break;
|
|
|
|
}
|
2024-11-27 20:44:36 +01:00
|
|
|
if (address >= reinterpret_cast<uint32_t>(cur.getAddress())) {
|
2024-03-24 07:50:30 +01:00
|
|
|
result = &cur;
|
|
|
|
foundHit = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!foundHit) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
const HeapMemoryFixedSize &PluginLinkInformation::getTextMemory() const {
|
2024-03-24 07:50:30 +01:00
|
|
|
return mAllocatedTextMemoryAddress;
|
|
|
|
}
|
|
|
|
|
2024-08-03 17:23:27 +02:00
|
|
|
const HeapMemoryFixedSize &PluginLinkInformation::getDataMemory() const {
|
2024-03-24 07:50:30 +01:00
|
|
|
return mAllocatedDataMemoryAddress;
|
|
|
|
}
|
2024-08-04 14:12:52 +02:00
|
|
|
|
|
|
|
PluginLinkInformation PluginLinkInformation::CreateStub() {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PluginLinkInformation::hasValidData() const {
|
|
|
|
return mAllocatedDataMemoryAddress.size() > 0 && mAllocatedTextMemoryAddress.size() > 0;
|
|
|
|
}
|