mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2026-08-13 22:00:53 -05:00
Formatting, fix spelling, clean up
This commit is contained in:
@@ -10,7 +10,7 @@ dyn_linking_function_t *DynamicLinkingHelper::getOrAddFunctionEntryByName(dyn_li
|
||||
return nullptr;
|
||||
}
|
||||
dyn_linking_function_t *result = nullptr;
|
||||
for (auto & curEntry : data->functions) {
|
||||
for (auto &curEntry: data->functions) {
|
||||
if (strlen(curEntry.functionName) == 0) {
|
||||
if (strlen(functionName) > DYN_LINK_FUNCTION_NAME_LENGTH) {
|
||||
DEBUG_FUNCTION_LINE("Failed to add function name, it's too long.");
|
||||
@@ -41,7 +41,7 @@ dyn_linking_import_t *DynamicLinkingHelper::getOrAddImport(dyn_linking_relocatio
|
||||
return nullptr;
|
||||
}
|
||||
dyn_linking_import_t *result = nullptr;
|
||||
for (auto & curEntry : data->imports) {
|
||||
for (auto &curEntry: data->imports) {
|
||||
if (strlen(curEntry.importName) == 0) {
|
||||
if (strlen(importName) > DYN_LINK_IMPORT_NAME_LENGTH) {
|
||||
DEBUG_FUNCTION_LINE("Failed to add Import, it's too long.");
|
||||
|
||||
@@ -47,7 +47,8 @@ public:
|
||||
**/
|
||||
static dyn_linking_import_t *getOrAddImport(dyn_linking_relocation_data_t *data, const char *importName, bool isData);
|
||||
|
||||
static bool addReloationEntry(dyn_linking_relocation_data_t *linking_data, dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length, const std::shared_ptr<RelocationData> &relocationData);
|
||||
static bool addReloationEntry(dyn_linking_relocation_data_t *linking_data, dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length,
|
||||
const std::shared_ptr<RelocationData> &relocationData);
|
||||
|
||||
static bool
|
||||
addReloationEntry(dyn_linking_relocation_data_t *linking_data, dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length, char type, size_t offset, int32_t addend,
|
||||
|
||||
@@ -18,13 +18,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include "../utils/logger.h"
|
||||
|
||||
class ImportRPLInformation {
|
||||
|
||||
public:
|
||||
explicit ImportRPLInformation(std::string name, bool isData = false) {
|
||||
this->name = name;
|
||||
this->name = std::move(name);
|
||||
this->_isData = isData;
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ bool PluginContainerPersistence::savePlugin(plugin_information_t *pluginInformat
|
||||
return false;
|
||||
}
|
||||
}
|
||||
plugin_data->info.trampolinId = pluginInfo->getTrampolinId();
|
||||
plugin_data->info.trampolineId = pluginInfo->getTrampolineId();
|
||||
plugin_data->info.allocatedTextMemoryAddress = pluginInfo->allocatedTextMemoryAddress;
|
||||
plugin_data->info.allocatedDataMemoryAddress = pluginInfo->allocatedDataMemoryAddress;
|
||||
|
||||
@@ -253,7 +253,7 @@ std::vector<std::shared_ptr<PluginContainer>> PluginContainerPersistence::loadPl
|
||||
|
||||
auto curPluginInformation = std::make_shared<PluginInformation>();
|
||||
|
||||
curPluginInformation->setTrampolinId(plugin_data->info.trampolinId);
|
||||
curPluginInformation->setTrampolineId(plugin_data->info.trampolineId);
|
||||
curPluginInformation->allocatedTextMemoryAddress = plugin_data->info.allocatedTextMemoryAddress;
|
||||
curPluginInformation->allocatedDataMemoryAddress = plugin_data->info.allocatedDataMemoryAddress;
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
|
||||
void *buffer = nullptr;
|
||||
MEMHeapHandle heapHandle{};
|
||||
eMemoryTypes memoryType;
|
||||
eMemoryTypes memoryType{};
|
||||
size_t length = 0;
|
||||
|
||||
private:
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
std::vector<std::shared_ptr<PluginData>> PluginDataFactory::loadDir(const std::string &path, MEMHeapHandle heapHandle) {
|
||||
std::vector<std::shared_ptr<PluginData>> result;
|
||||
struct dirent *dp;
|
||||
DIR *dfd = nullptr;
|
||||
DIR *dfd;
|
||||
|
||||
if (path.empty()) {
|
||||
DEBUG_FUNCTION_LINE("Path was empty");
|
||||
|
||||
@@ -13,7 +13,7 @@ bool PluginDataPersistence::save(plugin_data_t *pluginDataStruct, const std::sha
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PluginDataPersistence::save(plugin_data_t *pluginDataStruct, PluginData* plugin) {
|
||||
bool PluginDataPersistence::save(plugin_data_t *pluginDataStruct, PluginData *plugin) {
|
||||
if (pluginDataStruct == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ class PluginDataPersistence {
|
||||
|
||||
public:
|
||||
static bool save(plugin_data_t *pluginDataStruct, const std::shared_ptr<PluginData> &plugin);
|
||||
static bool save(plugin_data_t *pluginDataStruct, PluginData* plugin);
|
||||
|
||||
static bool save(plugin_data_t *pluginDataStruct, PluginData *plugin);
|
||||
|
||||
static std::shared_ptr<PluginData> load(plugin_data_t *pluginDataStruct);
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@ PluginInformation::PluginInformation(const PluginInformation &other) {
|
||||
symbol_data_list.insert(i);
|
||||
}
|
||||
section_info_list = other.section_info_list;
|
||||
trampolinId = other.trampolinId;
|
||||
trampolineId = other.trampolineId;
|
||||
allocatedTextMemoryAddress = other.allocatedTextMemoryAddress;
|
||||
allocatedDataMemoryAddress = other.allocatedDataMemoryAddress;
|
||||
}
|
||||
@@ -31,9 +31,8 @@
|
||||
#include "FunctionSymbolData.h"
|
||||
|
||||
struct FunctionSymbolDataComparator {
|
||||
bool operator()(const std::shared_ptr<FunctionSymbolData>& lhs,
|
||||
const std::shared_ptr<FunctionSymbolData>& rhs) const
|
||||
{
|
||||
bool operator()(const std::shared_ptr<FunctionSymbolData> &lhs,
|
||||
const std::shared_ptr<FunctionSymbolData> &rhs) const {
|
||||
return (uint32_t) lhs->getAddress() < (uint32_t) rhs->getAddress();
|
||||
}
|
||||
};
|
||||
@@ -94,12 +93,12 @@ public:
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
void setTrampolinId(uint8_t _trampolinId) {
|
||||
this->trampolinId = _trampolinId;
|
||||
void setTrampolineId(uint8_t _trampolineId) {
|
||||
this->trampolineId = _trampolineId;
|
||||
}
|
||||
|
||||
[[nodiscard]] uint8_t getTrampolinId() const {
|
||||
return trampolinId;
|
||||
[[nodiscard]] uint8_t getTrampolineId() const {
|
||||
return trampolineId;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -109,7 +108,7 @@ private:
|
||||
std::set<std::shared_ptr<FunctionSymbolData>, FunctionSymbolDataComparator> symbol_data_list;
|
||||
std::map<std::string, std::shared_ptr<SectionInfo>> section_info_list;
|
||||
|
||||
uint8_t trampolinId = 0;
|
||||
uint8_t trampolineId = 0;
|
||||
|
||||
void *allocatedTextMemoryAddress = nullptr;
|
||||
void *allocatedDataMemoryAddress = nullptr;
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
using namespace ELFIO;
|
||||
|
||||
std::optional<std::shared_ptr<PluginInformation>>
|
||||
PluginInformationFactory::load(const std::shared_ptr<PluginData> &pluginData, MEMHeapHandle heapHandle, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length,
|
||||
uint8_t trampolinId) {
|
||||
PluginInformationFactory::load(const std::shared_ptr<PluginData> &pluginData, MEMHeapHandle heapHandle, relocation_trampoline_entry_t *trampoline_data, uint32_t trampoline_data_length,
|
||||
uint8_t trampolineId) {
|
||||
if (pluginData->buffer == nullptr) {
|
||||
DEBUG_FUNCTION_LINE("Buffer was nullptr");
|
||||
return std::nullopt;
|
||||
@@ -145,7 +145,8 @@ PluginInformationFactory::load(const std::shared_ptr<PluginData> &pluginData, ME
|
||||
if ((psec->get_type() == SHT_PROGBITS || psec->get_type() == SHT_NOBITS) && (psec->get_flags() & SHF_ALLOC)) {
|
||||
DEBUG_FUNCTION_LINE_VERBOSE("Linking (%d)... %s at %08X", i, psec->get_name().c_str(), destinations[psec->get_index()]);
|
||||
|
||||
if (!linkSection(reader, psec->get_index(), (uint32_t) destinations[psec->get_index()], (uint32_t) text_data, (uint32_t) data_data, trampolin_data, trampolin_data_length, trampolinId)) {
|
||||
if (!linkSection(reader, psec->get_index(), (uint32_t) destinations[psec->get_index()], (uint32_t) text_data, (uint32_t) data_data, trampoline_data, trampoline_data_length,
|
||||
trampolineId)) {
|
||||
DEBUG_FUNCTION_LINE("elfLink failed");
|
||||
free(destinations);
|
||||
MEMFreeToExpHeap(heapHandle, text_data);
|
||||
@@ -167,7 +168,7 @@ PluginInformationFactory::load(const std::shared_ptr<PluginData> &pluginData, ME
|
||||
|
||||
free(destinations);
|
||||
|
||||
pluginInfo->setTrampolinId(trampolinId);
|
||||
pluginInfo->setTrampolineId(trampolineId);
|
||||
|
||||
auto secInfo = pluginInfo->getSectionInfo(".wups.hooks");
|
||||
if (secInfo && secInfo.value()->getSize() > 0) {
|
||||
@@ -314,9 +315,9 @@ std::vector<std::shared_ptr<RelocationData>> PluginInformationFactory::getImport
|
||||
return result;
|
||||
}
|
||||
|
||||
bool PluginInformationFactory::linkSection(const elfio &reader, uint32_t section_index, uint32_t destination, uint32_t base_text, uint32_t base_data, relocation_trampolin_entry_t *trampolin_data,
|
||||
uint32_t trampolin_data_length,
|
||||
uint8_t trampolinId) {
|
||||
bool PluginInformationFactory::linkSection(const elfio &reader, uint32_t section_index, uint32_t destination, uint32_t base_text, uint32_t base_data, relocation_trampoline_entry_t *trampoline_data,
|
||||
uint32_t trampoline_data_length,
|
||||
uint8_t trampolineId) {
|
||||
uint32_t sec_num = reader.sections.size();
|
||||
|
||||
for (uint32_t i = 0; i < sec_num; ++i) {
|
||||
@@ -372,7 +373,7 @@ bool PluginInformationFactory::linkSection(const elfio &reader, uint32_t section
|
||||
}
|
||||
// DEBUG_FUNCTION_LINE_VERBOSE("sym_value %08X adjusted_sym_value %08X offset %08X adjusted_offset %08X", (uint32_t) sym_value, adjusted_sym_value, (uint32_t) offset, adjusted_offset);
|
||||
|
||||
if (!ElfUtils::elfLinkOne(type, adjusted_offset, addend, destination, adjusted_sym_value, trampolin_data, trampolin_data_length, RELOC_TYPE_FIXED, trampolinId)) {
|
||||
if (!ElfUtils::elfLinkOne(type, adjusted_offset, addend, destination, adjusted_sym_value, trampoline_data, trampoline_data_length, RELOC_TYPE_FIXED, trampolineId)) {
|
||||
DEBUG_FUNCTION_LINE("Link failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -30,11 +30,12 @@
|
||||
class PluginInformationFactory {
|
||||
public:
|
||||
static std::optional<std::shared_ptr<PluginInformation>>
|
||||
load(const std::shared_ptr<PluginData> &pluginData, MEMHeapHandle heaphandle, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length, uint8_t trampolinId);
|
||||
load(const std::shared_ptr<PluginData> &pluginData, MEMHeapHandle heaphandle, relocation_trampoline_entry_t *trampoline_data, uint32_t trampoline_data_length, uint8_t trampolineId);
|
||||
|
||||
static bool
|
||||
linkSection(const elfio &reader, uint32_t section_index, uint32_t destination, uint32_t base_text, uint32_t base_data, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length,
|
||||
uint8_t trampolinId);
|
||||
linkSection(const elfio &reader, uint32_t section_index, uint32_t destination, uint32_t base_text, uint32_t base_data, relocation_trampoline_entry_t *trampoline_data,
|
||||
uint32_t trampoline_data_length,
|
||||
uint8_t trampolineId);
|
||||
|
||||
static std::vector<std::shared_ptr<RelocationData>> getImportRelocationData(const elfio &reader, uint8_t **destinations);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user