mirror of
https://github.com/wiiu-env/WUMSLoader.git
synced 2026-09-27 04:17:03 -05:00
Formatting
This commit is contained in:
@@ -64,12 +64,15 @@ dyn_linking_import_t *DynamicLinkingHelper::getOrAddImport(dyn_linking_relocatio
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DynamicLinkingHelper::addRelocationEntry(dyn_linking_relocation_data_t *linking_data, dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length, const RelocationData &relocationData) {
|
||||
return addReloationEntry(linking_data, linking_entries, linking_entry_length, relocationData.getType(), relocationData.getOffset(), relocationData.getAddend(), relocationData.getDestination(), relocationData.getName(),
|
||||
bool DynamicLinkingHelper::addRelocationEntry(dyn_linking_relocation_data_t *linking_data, dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length,
|
||||
const RelocationData &relocationData) {
|
||||
return addReloationEntry(linking_data, linking_entries, linking_entry_length, relocationData.getType(), relocationData.getOffset(), relocationData.getAddend(), relocationData.getDestination(),
|
||||
relocationData.getName(),
|
||||
relocationData.getImportRPLInformation());
|
||||
}
|
||||
|
||||
bool DynamicLinkingHelper::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, void *destination,
|
||||
bool DynamicLinkingHelper::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, void *destination,
|
||||
std::string name, const ImportRPLInformation &rplInfo) {
|
||||
dyn_linking_import_t *importInfoGbl = DynamicLinkingHelper::getOrAddImport(linking_data, rplInfo.getName().c_str(), rplInfo.isData());
|
||||
if (importInfoGbl == NULL) {
|
||||
@@ -87,7 +90,8 @@ bool DynamicLinkingHelper::addReloationEntry(dyn_linking_relocation_data_t *link
|
||||
importInfoGbl);
|
||||
}
|
||||
|
||||
bool DynamicLinkingHelper::addRelocationEntry(dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length, char type, size_t offset, int32_t addend, void *destination, dyn_linking_function_t *functionName,
|
||||
bool DynamicLinkingHelper::addRelocationEntry(dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length, char type, size_t offset, int32_t addend, void *destination,
|
||||
dyn_linking_function_t *functionName,
|
||||
dyn_linking_import_t *importInfo) {
|
||||
for (uint32_t i = 0; i < linking_entry_length; i++) {
|
||||
dyn_linking_relocation_entry_t *curEntry = &(linking_entries[i]);
|
||||
|
||||
@@ -49,11 +49,13 @@ public:
|
||||
|
||||
static bool addRelocationEntry(dyn_linking_relocation_data_t *linking_data, dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length, const 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, void *destination, std::string name,
|
||||
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,
|
||||
void *destination, std::string name,
|
||||
const ImportRPLInformation &rplInfo);
|
||||
|
||||
static bool
|
||||
addRelocationEntry(dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length, char type, size_t offset, int32_t addend, void *destination, dyn_linking_function_t *functionName, dyn_linking_import_t *importInfo);
|
||||
addRelocationEntry(dyn_linking_relocation_entry_t *linking_entries, uint32_t linking_entry_length, char type, size_t offset, int32_t addend, void *destination,
|
||||
dyn_linking_function_t *functionName, dyn_linking_import_t *importInfo);
|
||||
|
||||
private:
|
||||
DynamicLinkingHelper() = default;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
std::string ModuleData::toString() const {
|
||||
std::string res = StringTools::strfmt("Entrypoint %08X, bss: %08X (%d), bss: %08X (%d)\n", getEntrypoint(), getBSSAddr(), getBSSSize(), getSBSSAddr(), getSBSSSize());
|
||||
for (auto const &reloc : relocation_data_list) {
|
||||
for (auto const &reloc: relocation_data_list) {
|
||||
res += reloc.toString();
|
||||
}
|
||||
return res;
|
||||
|
||||
@@ -141,6 +141,7 @@ public:
|
||||
void setSkipEntrypoint(bool value) {
|
||||
this->skipEntrypoint = value;
|
||||
}
|
||||
|
||||
void setInitBeforeRelocationDoneHook(bool value) {
|
||||
this->initBeforeRelocationDoneHook = value;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
|
||||
using namespace ELFIO;
|
||||
|
||||
std::optional<ModuleData> ModuleDataFactory::load(const std::string& path, uint32_t *destination_address_ptr, uint32_t maximum_size, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length) {
|
||||
std::optional<ModuleData>
|
||||
ModuleDataFactory::load(const std::string &path, uint32_t *destination_address_ptr, uint32_t maximum_size, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length) {
|
||||
elfio reader;
|
||||
ModuleData moduleData;
|
||||
|
||||
@@ -60,7 +61,7 @@ std::optional<ModuleData> ModuleDataFactory::load(const std::string& path, uint3
|
||||
uint32_t sectionSize = psec->get_size();
|
||||
|
||||
totalSize += sectionSize;
|
||||
if(totalSize > maximum_size){
|
||||
if (totalSize > maximum_size) {
|
||||
DEBUG_FUNCTION_LINE("Couldn't load setup module because it's too big.");
|
||||
return {};
|
||||
}
|
||||
@@ -131,7 +132,7 @@ std::optional<ModuleData> ModuleDataFactory::load(const std::string& path, uint3
|
||||
}
|
||||
std::vector<RelocationData> relocationData = getImportRelocationData(reader, destinations);
|
||||
|
||||
for (auto const &reloc : relocationData) {
|
||||
for (auto const &reloc: relocationData) {
|
||||
moduleData.addRelocationData(reloc);
|
||||
}
|
||||
|
||||
@@ -280,7 +281,8 @@ std::vector<RelocationData> ModuleDataFactory::getImportRelocationData(elfio &re
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ModuleDataFactory::linkSection(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) {
|
||||
bool ModuleDataFactory::linkSection(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) {
|
||||
uint32_t sec_num = reader.sections.size();
|
||||
|
||||
for (uint32_t i = 0; i < sec_num; ++i) {
|
||||
|
||||
@@ -26,9 +26,11 @@
|
||||
|
||||
class ModuleDataFactory {
|
||||
public:
|
||||
static std::optional<ModuleData> load(const std::string& path, uint32_t *destination_address_ptr, uint32_t maximum_size, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length);
|
||||
static std::optional<ModuleData>
|
||||
load(const std::string &path, uint32_t *destination_address_ptr, uint32_t maximum_size, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length);
|
||||
|
||||
static bool linkSection(ELFIO::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);
|
||||
static bool linkSection(ELFIO::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);
|
||||
|
||||
static std::vector<RelocationData> getImportRelocationData(ELFIO::elfio &reader, uint8_t **destinations);
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ bool ModuleDataPersistence::saveModuleData(module_information_t *moduleInformati
|
||||
DEBUG_FUNCTION_LINE("Saving reloation data for module at %08X", module.getEntrypoint());
|
||||
// Relocation
|
||||
std::vector<RelocationData> relocationData = module.getRelocationDataList();
|
||||
for (auto const &reloc : relocationData) {
|
||||
for (auto const &reloc: relocationData) {
|
||||
if (!DynamicLinkingHelper::addRelocationEntry(&(moduleInformation->linking_data), module_data->linking_entries,
|
||||
DYN_LINK_RELOCATION_LIST_LENGTH, reloc)) {
|
||||
DEBUG_FUNCTION_LINE("Failed to add relocation entry\n");
|
||||
@@ -27,9 +27,9 @@ bool ModuleDataPersistence::saveModuleData(module_information_t *moduleInformati
|
||||
}
|
||||
|
||||
std::vector<ExportData> exportData = module.getExportDataList();
|
||||
for (auto const &curExport : exportData) {
|
||||
for (auto const &curExport: exportData) {
|
||||
bool found = false;
|
||||
for (auto &export_entry : module_data->export_entries) {
|
||||
for (auto &export_entry: module_data->export_entries) {
|
||||
if (export_entry.address == 0) {
|
||||
export_entry.type = curExport.getType();
|
||||
export_entry.name[0] = '\0';
|
||||
@@ -46,9 +46,9 @@ bool ModuleDataPersistence::saveModuleData(module_information_t *moduleInformati
|
||||
}
|
||||
|
||||
std::vector<HookData> hookData = module.getHookDataList();
|
||||
for (auto const &curHook : hookData) {
|
||||
for (auto const &curHook: hookData) {
|
||||
bool found = false;
|
||||
for (auto &hook_entry : module_data->hook_entries) {
|
||||
for (auto &hook_entry: module_data->hook_entries) {
|
||||
if (hook_entry.target == 0) {
|
||||
hook_entry.type = curHook.getType();
|
||||
hook_entry.target = (uint32_t) curHook.getTarget();
|
||||
@@ -109,7 +109,7 @@ std::vector<ModuleData> ModuleDataPersistence::loadModuleData(module_information
|
||||
moduleData.setSkipEntrypoint(module_data->skipEntrypoint);
|
||||
moduleData.setInitBeforeRelocationDoneHook(module_data->initBeforeRelocationDoneHook);
|
||||
|
||||
for (auto &export_entrie : module_data->export_entries) {
|
||||
for (auto &export_entrie: module_data->export_entries) {
|
||||
export_data_t *export_entry = &export_entrie;
|
||||
if (export_entry->address == 0) {
|
||||
continue;
|
||||
@@ -117,14 +117,14 @@ std::vector<ModuleData> ModuleDataPersistence::loadModuleData(module_information
|
||||
moduleData.addExportData(ExportData(static_cast<wums_entry_type_t>(export_entry->type), export_entry->name, reinterpret_cast<const void *>(export_entry->address)));
|
||||
}
|
||||
|
||||
for (auto &hook_entry : module_data->hook_entries) {
|
||||
for (auto &hook_entry: module_data->hook_entries) {
|
||||
if (hook_entry.target == 0) {
|
||||
continue;
|
||||
}
|
||||
moduleData.addHookData(HookData(static_cast<wums_hook_type_t>(hook_entry.type), reinterpret_cast<const void *>(hook_entry.target)));
|
||||
}
|
||||
|
||||
for (auto &linking_entry : module_data->linking_entries) {
|
||||
for (auto &linking_entry: module_data->linking_entries) {
|
||||
if (linking_entry.destination == nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
#include "utils/StringTools.h"
|
||||
|
||||
std::string RelocationData::toString() const {
|
||||
return StringTools::strfmt("%s destination: %08X offset: %08X type: %02X addend: %d rplName: %s isData: %d \n", name.c_str(), destination, offset, type, addend, rplInfo.getName().c_str(), rplInfo.isData());
|
||||
return StringTools::strfmt("%s destination: %08X offset: %08X type: %02X addend: %d rplName: %s isData: %d \n", name.c_str(), destination, offset, type, addend, rplInfo.getName().c_str(),
|
||||
rplInfo.isData());
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
sectionSize(o2.sectionSize) {
|
||||
}
|
||||
|
||||
SectionInfo& operator=(const SectionInfo& other) = default;
|
||||
SectionInfo &operator=(const SectionInfo &other) = default;
|
||||
|
||||
|
||||
virtual ~SectionInfo() = default;
|
||||
|
||||
Reference in New Issue
Block a user