Split up declaration and definition for some classes

This commit is contained in:
Maschell 2024-03-24 07:50:30 +01:00
parent 7d07f6525b
commit 8cacf6efe8
10 changed files with 384 additions and 283 deletions

View File

@ -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<uint32_t>(this->paddress),
.virtualAddr = reinterpret_cast<uint32_t>(this->vaddress),
.replaceAddr = reinterpret_cast<uint32_t>(this->replaceAddr),
.replaceCall = static_cast<uint32_t *>(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;
}

View File

@ -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<uint32_t>(this->paddress),
.virtualAddr = reinterpret_cast<uint32_t>(this->vaddress),
.replaceAddr = reinterpret_cast<uint32_t>(this->replaceAddr),
.replaceCall = static_cast<uint32_t *>(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;

View File

@ -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<WUPSConfigHandle> 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> 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;
}

View File

@ -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<WUPSConfigHandle> createConfig() const{
WUPSConfigHandle handle;
if (WUPSConfigAPIBackend::Intern::CreateConfig(mName.c_str(), &handle) == WUPSCONFIG_API_RESULT_SUCCESS) {
return handle;
}
return std::nullopt;
}
[[nodiscard]] std::optional<WUPSConfigHandle> 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<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;
}
static std::optional<PluginConfigData> create(WUPSConfigAPIOptions options, WUPSConfigAPI_MenuOpenedCallback openedCallback, WUPSConfigAPI_MenuClosedCallback closedCallback);
private:
std::string mName;

View File

@ -0,0 +1,83 @@
#include "PluginContainer.h"
PluginContainer::PluginContainer(PluginMetaInformation metaInformation, PluginInformation pluginInformation, std::shared_ptr<PluginData> 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<PluginData> PluginContainer::getPluginDataCopy() const {
return mPluginData;
}
uint32_t PluginContainer::getHandle() const {
return (uint32_t) this;
}
const std::optional<PluginConfigData> &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);
}

View File

@ -28,91 +28,33 @@
class PluginContainer {
public:
PluginContainer(PluginMetaInformation metaInformation, PluginInformation pluginInformation, std::shared_ptr<PluginData> pluginData)
: mMetaInformation(std::move(metaInformation)),
mPluginInformation(std::move(pluginInformation)),
mPluginData(std::move(pluginData)) {
}
PluginContainer(PluginMetaInformation metaInformation, PluginInformation pluginInformation, std::shared_ptr<PluginData> 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<PluginData> getPluginDataCopy() const {
return mPluginData;
}
[[nodiscard]] std::shared_ptr<PluginData> getPluginDataCopy() const;
[[nodiscard]] uint32_t getHandle() const {
return (uint32_t) this;
}
[[nodiscard]] uint32_t getHandle() const;
[[nodiscard]] const std::optional<PluginConfigData> &getConfigData() const {
return mPluginConfigData;
}
[[nodiscard]] const std::optional<PluginConfigData> &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;

View File

@ -0,0 +1,13 @@
#include "PluginData.h"
uint32_t PluginData::getHandle() const {
return (uint32_t) this;
}
std::span<const uint8_t> PluginData::getBuffer() const {
return mBuffer;
}
const std::string &PluginData::getSource() const {
return mSource;
}

View File

@ -33,17 +33,11 @@ public:
explicit PluginData(std::span<uint8_t> 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<uint8_t const> getBuffer() const {
return mBuffer;
}
[[nodiscard]] std::span<uint8_t const> getBuffer() const;
[[nodiscard]] const std::string &getSource() const {
return mSource;
}
[[nodiscard]] const std::string &getSource() const;
private:
std::vector<uint8_t> mBuffer;

View File

@ -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<HookData> &PluginInformation::getHookDataList() const {
return mHookDataList;
}
void PluginInformation::addFunctionData(FunctionData function_data) {
mFunctionDataList.push_back(std::move(function_data));
}
const std::vector<FunctionData> &PluginInformation::getFunctionDataList() const {
return mFunctionDataList;
}
std::vector<FunctionData> &PluginInformation::getFunctionDataList() {
return mFunctionDataList;
}
void PluginInformation::addRelocationData(RelocationData relocation_data) {
mRelocationDataList.push_back(std::move(relocation_data));
}
const std::vector<RelocationData> &PluginInformation::getRelocationDataList() const {
return mRelocationDataList;
}
void PluginInformation::addFunctionSymbolData(const FunctionSymbolData &symbol_data) {
mSymbolDataList.insert(symbol_data);
}
void PluginInformation::addSectionInfo(const SectionInfo &sectionInfo) {
mSectionInfoList.insert(std::pair(sectionInfo.getName(), sectionInfo));
}
const std::map<std::string, SectionInfo> &PluginInformation::getSectionInfoList() const {
return mSectionInfoList;
}
std::optional<SectionInfo> PluginInformation::getSectionInfo(const std::string &sectionName) 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;
}

View File

@ -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<HookData> &getHookDataList() const {
return mHookDataList;
}
[[nodiscard]] const std::vector<HookData> &getHookDataList() const;
void addFunctionData(FunctionData function_data) {
mFunctionDataList.push_back(std::move(function_data));
}
void addFunctionData(FunctionData function_data);
[[nodiscard]] const std::vector<FunctionData> &getFunctionDataList() const {
return mFunctionDataList;
}
[[nodiscard]] const std::vector<FunctionData> &getFunctionDataList() const;
[[nodiscard]] std::vector<FunctionData> &getFunctionDataList() {
return mFunctionDataList;
}
[[nodiscard]] std::vector<FunctionData> &getFunctionDataList();
void addRelocationData(RelocationData relocation_data) {
mRelocationDataList.push_back(std::move(relocation_data));
}
void addRelocationData(RelocationData relocation_data);
[[nodiscard]] const std::vector<RelocationData> &getRelocationDataList() const {
return mRelocationDataList;
}
[[nodiscard]] const std::vector<RelocationData> &getRelocationDataList() const;
void addFunctionSymbolData(const FunctionSymbolData &symbol_data) {
mSymbolDataList.insert(symbol_data);
}
void addFunctionSymbolData(const FunctionSymbolData &symbol_data);
void addSectionInfo(const SectionInfo &sectionInfo) {
mSectionInfoList.insert(std::pair(sectionInfo.getName(), sectionInfo));
}
void addSectionInfo(const SectionInfo &sectionInfo);
[[nodiscard]] const std::map<std::string, SectionInfo> &getSectionInfoList() const {
return mSectionInfoList;
}
[[nodiscard]] const std::map<std::string, SectionInfo> &getSectionInfoList() const;
[[nodiscard]] std::optional<SectionInfo> getSectionInfo(const std::string &sectionName) const {
if (getSectionInfoList().contains(sectionName)) {
return mSectionInfoList.at(sectionName);
}
return std::nullopt;
}
[[nodiscard]] std::optional<SectionInfo> getSectionInfo(const std::string &sectionName) 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<HookData> mHookDataList;
std::vector<FunctionData> mFunctionDataList;
std::vector<RelocationData> mRelocationDataList;