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: public:
FunctionData(void *paddress, void *vaddress, std::string_view name, function_replacement_library_type_t library, void *replaceAddr, void *replaceCall, FunctionData(void *paddress, void *vaddress, std::string_view name, function_replacement_library_type_t library, void *replaceAddr, void *replaceCall,
FunctionPatcherTargetProcess targetProcess) { 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();
}
}
[[nodiscard]] const std::string &getName() const { [[nodiscard]] const std::string &getName() const;
return this->name;
}
[[nodiscard]] function_replacement_library_type_t getLibrary() const { [[maybe_unused]] [[nodiscard]] function_replacement_library_type_t getLibrary() const;
return this->library;
}
[[nodiscard]] const void *getPhysicalAddress() const { [[maybe_unused]] [[nodiscard]] const void *getPhysicalAddress() const;
return paddress;
}
[[nodiscard]] const void *getVirtualAddress() const { [[maybe_unused]] [[nodiscard]] const void *getVirtualAddress() const;
return vaddress;
}
[[nodiscard]] const void *getReplaceAddress() const { [[maybe_unused]] [[nodiscard]] const void *getReplaceAddress() const;
return replaceAddr;
}
[[nodiscard]] const void *getReplaceCall() const { [[maybe_unused]] [[nodiscard]] const void *getReplaceCall() const;
return replaceCall;
}
[[nodiscard]] FunctionPatcherTargetProcess getTargetProcess() const { [[maybe_unused]] [[nodiscard]] FunctionPatcherTargetProcess getTargetProcess() const;
return targetProcess;
}
bool AddPatch() { 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,
}};
if (FunctionPatcher_AddFunctionPatch(&functionData, &handle, nullptr) != FUNCTION_PATCHER_RESULT_SUCCESS) { bool RemovePatch();
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;
}
private: private:
void *paddress = nullptr; 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: public:
PluginConfigData(std::string_view name, PluginConfigData(std::string_view name,
WUPSConfigAPI_MenuOpenedCallback openedCallback, WUPSConfigAPI_MenuOpenedCallback openedCallback,
WUPSConfigAPI_MenuClosedCallback closedCallback) : mName(name), WUPSConfigAPI_MenuClosedCallback closedCallback);
mOpenedCallback(openedCallback),
mClosedCallback(closedCallback) {
}
[[nodiscard]] std::optional<WUPSConfigHandle> createConfig() const{ [[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]] WUPSConfigAPIStatus CallMenuOpenendCallback(WUPSConfigHandle config) 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 CallMenuClosedCallback() const { [[nodiscard]] WUPSConfigAPIStatus CallMenuClosedCallback() const;
if (mClosedCallback == nullptr) {
return WUPSCONFIG_API_RESULT_MISSING_CALLBACK;
}
mClosedCallback();
return WUPSCONFIG_API_RESULT_SUCCESS;
}
static std::optional<PluginConfigData> create(WUPSConfigAPIOptions options, WUPSConfigAPI_MenuOpenedCallback openedCallback, WUPSConfigAPI_MenuClosedCallback closedCallback) { 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;
}
private: private:
std::string mName; 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 { class PluginContainer {
public: public:
PluginContainer(PluginMetaInformation metaInformation, PluginInformation pluginInformation, std::shared_ptr<PluginData> pluginData) PluginContainer(PluginMetaInformation metaInformation, PluginInformation pluginInformation, std::shared_ptr<PluginData> pluginData);
: mMetaInformation(std::move(metaInformation)),
mPluginInformation(std::move(pluginInformation)),
mPluginData(std::move(pluginData)) {
}
PluginContainer(const PluginContainer &) = delete; PluginContainer(const PluginContainer &) = delete;
PluginContainer(PluginContainer &&src) : mMetaInformation(std::move(src.mMetaInformation)), PluginContainer(PluginContainer &&src);
mPluginInformation(std::move(src.mPluginInformation)),
mPluginData(std::move(src.mPluginData)),
mPluginConfigData(std::move(src.mPluginConfigData)),
storageRootItem(src.storageRootItem)
{ PluginContainer &operator=(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;
}
[[nodiscard]] const PluginMetaInformation &getMetaInformation() const { [[nodiscard]] const PluginMetaInformation &getMetaInformation() const;
return this->mMetaInformation;
}
[[nodiscard]] const PluginInformation &getPluginInformation() const { [[nodiscard]] const PluginInformation &getPluginInformation() const;
return this->mPluginInformation; [[nodiscard]] PluginInformation &getPluginInformation();
}
[[nodiscard]] PluginInformation &getPluginInformation() {
return this->mPluginInformation;
}
[[nodiscard]] std::shared_ptr<PluginData> getPluginDataCopy() const { [[nodiscard]] std::shared_ptr<PluginData> getPluginDataCopy() const;
return mPluginData;
}
[[nodiscard]] uint32_t getHandle() const { [[nodiscard]] uint32_t getHandle() const;
return (uint32_t) this;
}
[[nodiscard]] const std::optional<PluginConfigData> &getConfigData() const { [[nodiscard]] const std::optional<PluginConfigData> &getConfigData() const;
return mPluginConfigData;
}
void setConfigData(const PluginConfigData &pluginConfigData) { void setConfigData(const PluginConfigData &pluginConfigData);
mPluginConfigData = pluginConfigData;
}
WUPSStorageError OpenStorage() { 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 CloseStorage() { 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);
}
[[nodiscard]] wups_storage_root_item getStorageRootItem() const { [[nodiscard]] wups_storage_root_item getStorageRootItem() const {
return storageRootItem; 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) { explicit PluginData(std::span<uint8_t> buffer, std::string_view source) : mBuffer(buffer.begin(), buffer.end()), mSource(source) {
} }
[[nodiscard]] uint32_t getHandle() const { [[nodiscard]] uint32_t getHandle() const;
return (uint32_t) this;
}
[[nodiscard]] std::span<uint8_t const> getBuffer() const { [[nodiscard]] std::span<uint8_t const> getBuffer() const;
return mBuffer;
}
[[nodiscard]] const std::string &getSource() const { [[nodiscard]] const std::string &getSource() const;
return mSource;
}
private: private:
std::vector<uint8_t> mBuffer; 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(const PluginInformation &) = delete;
PluginInformation(PluginInformation &&src) : mHookDataList(std::move(src.mHookDataList)), PluginInformation(PluginInformation &&src);
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 &operator=(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;
}
void addHookData(HookData hook_data) { void addHookData(HookData hook_data);
mHookDataList.push_back(hook_data);
}
[[nodiscard]] const std::vector<HookData> &getHookDataList() const { [[nodiscard]] const std::vector<HookData> &getHookDataList() const;
return mHookDataList;
}
void addFunctionData(FunctionData function_data) { void addFunctionData(FunctionData function_data);
mFunctionDataList.push_back(std::move(function_data));
}
[[nodiscard]] const std::vector<FunctionData> &getFunctionDataList() const { [[nodiscard]] const std::vector<FunctionData> &getFunctionDataList() const;
return mFunctionDataList;
}
[[nodiscard]] std::vector<FunctionData> &getFunctionDataList() { [[nodiscard]] std::vector<FunctionData> &getFunctionDataList();
return mFunctionDataList;
}
void addRelocationData(RelocationData relocation_data) { void addRelocationData(RelocationData relocation_data);
mRelocationDataList.push_back(std::move(relocation_data));
}
[[nodiscard]] const std::vector<RelocationData> &getRelocationDataList() const { [[nodiscard]] const std::vector<RelocationData> &getRelocationDataList() const;
return mRelocationDataList;
}
void addFunctionSymbolData(const FunctionSymbolData &symbol_data) { void addFunctionSymbolData(const FunctionSymbolData &symbol_data);
mSymbolDataList.insert(symbol_data);
}
void addSectionInfo(const SectionInfo &sectionInfo) { void addSectionInfo(const SectionInfo &sectionInfo);
mSectionInfoList.insert(std::pair(sectionInfo.getName(), sectionInfo));
}
[[nodiscard]] const std::map<std::string, SectionInfo> &getSectionInfoList() const { [[nodiscard]] const std::map<std::string, SectionInfo> &getSectionInfoList() const;
return mSectionInfoList;
}
[[nodiscard]] std::optional<SectionInfo> getSectionInfo(const std::string &sectionName) const { [[nodiscard]] std::optional<SectionInfo> getSectionInfo(const std::string &sectionName) const;
if (getSectionInfoList().contains(sectionName)) {
return mSectionInfoList.at(sectionName);
}
return std::nullopt;
}
void setTrampolineId(uint8_t trampolineId) { void setTrampolineId(uint8_t trampolineId);
this->mTrampolineId = trampolineId;
}
[[nodiscard]] uint8_t getTrampolineId() const { [[nodiscard]] uint8_t getTrampolineId() const;
return mTrampolineId;
}
[[nodiscard]] const FunctionSymbolData *getNearestFunctionSymbolData(uint32_t address) const { [[nodiscard]] const FunctionSymbolData *getNearestFunctionSymbolData(uint32_t address) const;
const FunctionSymbolData *result = nullptr;
bool foundHit = false; [[nodiscard]] const HeapMemoryFixedSize &getTextMemory() const;
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; [[nodiscard]] const HeapMemoryFixedSize &getDataMemory() const;
}
[[nodiscard]] const HeapMemoryFixedSize &getTextMemory() const {
return mAllocatedTextMemoryAddress;
}
[[nodiscard]] const HeapMemoryFixedSize &getDataMemory() const {
return mAllocatedDataMemoryAddress;
}
private: private:
PluginInformation(){ PluginInformation() = default;
}
std::vector<HookData> mHookDataList; std::vector<HookData> mHookDataList;
std::vector<FunctionData> mFunctionDataList; std::vector<FunctionData> mFunctionDataList;
std::vector<RelocationData> mRelocationDataList; std::vector<RelocationData> mRelocationDataList;