mirror of
https://github.com/wiiu-env/WUMSLoader.git
synced 2024-12-25 23:51:50 +01:00
Minor improvements
This commit is contained in:
parent
fe7521b8a6
commit
c68e375567
@ -1,19 +1,16 @@
|
|||||||
#include "DynamicLinkingHelper.h"
|
#include "DynamicLinkingHelper.h"
|
||||||
#include <stdio.h>
|
#include <cstring>
|
||||||
#include <string.h>
|
|
||||||
#include <vector>
|
|
||||||
#include "utils/logger.h"
|
|
||||||
|
|
||||||
dyn_linking_function_t *DynamicLinkingHelper::getOrAddFunctionEntryByName(dyn_linking_relocation_data_t *data, const char *functionName) {
|
dyn_linking_function_t *DynamicLinkingHelper::getOrAddFunctionEntryByName(dyn_linking_relocation_data_t *data, const char *functionName) {
|
||||||
if (data == NULL) {
|
if (data == nullptr) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (functionName == NULL) {
|
if (functionName == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
dyn_linking_function_t *result = NULL;
|
dyn_linking_function_t *result = NULL;
|
||||||
for (int32_t i = 0; i < DYN_LINK_FUNCTION_LIST_LENGTH; i++) {
|
for (auto & function : data->functions) {
|
||||||
dyn_linking_function_t *curEntry = &(data->functions[i]);
|
dyn_linking_function_t *curEntry = &function;
|
||||||
if (strlen(curEntry->functionName) == 0) {
|
if (strlen(curEntry->functionName) == 0) {
|
||||||
if (strlen(functionName) > DYN_LINK_FUNCTION_NAME_LENGTH) {
|
if (strlen(functionName) > DYN_LINK_FUNCTION_NAME_LENGTH) {
|
||||||
DEBUG_FUNCTION_LINE("Failed to add function name, it's too long.\n");
|
DEBUG_FUNCTION_LINE("Failed to add function name, it's too long.\n");
|
||||||
@ -44,8 +41,8 @@ dyn_linking_import_t *DynamicLinkingHelper::getOrAddImport(dyn_linking_relocatio
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
dyn_linking_import_t *result = NULL;
|
dyn_linking_import_t *result = NULL;
|
||||||
for (int32_t i = 0; i < DYN_LINK_IMPORT_LIST_LENGTH; i++) {
|
for (auto & import : data->imports) {
|
||||||
dyn_linking_import_t *curEntry = &(data->imports[i]);
|
dyn_linking_import_t *curEntry = &import;
|
||||||
if (strlen(curEntry->importName) == 0) {
|
if (strlen(curEntry->importName) == 0) {
|
||||||
if (strlen(importName) > DYN_LINK_IMPORT_NAME_LENGTH) {
|
if (strlen(importName) > DYN_LINK_IMPORT_NAME_LENGTH) {
|
||||||
DEBUG_FUNCTION_LINE("Failed to add Import, it's too long.\n");
|
DEBUG_FUNCTION_LINE("Failed to add Import, it's too long.\n");
|
||||||
@ -69,7 +66,7 @@ bool DynamicLinkingHelper::addReloationEntry(dyn_linking_relocation_data_t *link
|
|||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
const std::string& name, const ImportRPLInformation &rplInfo) {
|
||||||
dyn_linking_import_t *importInfoGbl = DynamicLinkingHelper::getOrAddImport(linking_data, rplInfo.getName().c_str(), rplInfo.isData());
|
dyn_linking_import_t *importInfoGbl = DynamicLinkingHelper::getOrAddImport(linking_data, rplInfo.getName().c_str(), rplInfo.isData());
|
||||||
if (importInfoGbl == NULL) {
|
if (importInfoGbl == NULL) {
|
||||||
DEBUG_FUNCTION_LINE("Getting import info failed. Probably maximum of %d rpl files to import reached.\n", DYN_LINK_IMPORT_LIST_LENGTH);
|
DEBUG_FUNCTION_LINE("Getting import info failed. Probably maximum of %d rpl files to import reached.\n", DYN_LINK_IMPORT_LIST_LENGTH);
|
||||||
@ -89,7 +86,7 @@ bool DynamicLinkingHelper::addReloationEntry(dyn_linking_relocation_entry_t *lin
|
|||||||
dyn_linking_import_t *importInfo) {
|
dyn_linking_import_t *importInfo) {
|
||||||
for (uint32_t i = 0; i < linking_entry_length; i++) {
|
for (uint32_t i = 0; i < linking_entry_length; i++) {
|
||||||
dyn_linking_relocation_entry_t *curEntry = &(linking_entries[i]);
|
dyn_linking_relocation_entry_t *curEntry = &(linking_entries[i]);
|
||||||
if (curEntry->functionEntry != NULL) {
|
if (curEntry->functionEntry != nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
curEntry->type = type;
|
curEntry->type = type;
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
|
|
||||||
static bool addReloationEntry(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, 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, const std::string& name,
|
||||||
const ImportRPLInformation &rplInfo);
|
const ImportRPLInformation &rplInfo);
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <coreinit/cache.h>
|
#include <coreinit/cache.h>
|
||||||
|
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include <wums.h>
|
#include <wums.h>
|
||||||
#include "hooks.h"
|
#include "hooks.h"
|
||||||
#include "utils/logger.h"
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
static const char **hook_names = (const char *[]) {
|
static const char **hook_names = (const char *[]) {
|
||||||
@ -21,7 +20,7 @@ void CallHook(const std::vector<ModuleData> &modules, wums_hook_type_t type) {
|
|||||||
|
|
||||||
void CallHook(const ModuleData &module, wums_hook_type_t type) {
|
void CallHook(const ModuleData &module, wums_hook_type_t type) {
|
||||||
for (auto &curHook : module.getHookDataList()) {
|
for (auto &curHook : module.getHookDataList()) {
|
||||||
uint32_t func_ptr = (uint32_t) curHook.getTarget();
|
auto func_ptr = (uint32_t) curHook.getTarget();
|
||||||
if (func_ptr == 0) {
|
if (func_ptr == 0) {
|
||||||
DEBUG_FUNCTION_LINE("Hook ptr was NULL\n");
|
DEBUG_FUNCTION_LINE("Hook ptr was NULL\n");
|
||||||
break;
|
break;
|
||||||
@ -33,7 +32,7 @@ void CallHook(const ModuleData &module, wums_hook_type_t type) {
|
|||||||
type == WUMS_HOOK_INIT_WUT ||
|
type == WUMS_HOOK_INIT_WUT ||
|
||||||
type == WUMS_HOOK_FINI_WUT)) {
|
type == WUMS_HOOK_FINI_WUT)) {
|
||||||
DEBUG_FUNCTION_LINE("Calling hook of type %s [%d] %d for %s \n", hook_names[type], type, curHook.getType(), module.getExportName().c_str());
|
DEBUG_FUNCTION_LINE("Calling hook of type %s [%d] %d for %s \n", hook_names[type], type, curHook.getType(), module.getExportName().c_str());
|
||||||
((void (*)(void)) ((uint32_t *) func_ptr))();
|
((void (*)()) ((uint32_t *) func_ptr))();
|
||||||
break;
|
break;
|
||||||
} else if (type == WUMS_HOOK_INIT ||
|
} else if (type == WUMS_HOOK_INIT ||
|
||||||
type == WUMS_HOOK_RELOCATIONS_DONE) {
|
type == WUMS_HOOK_RELOCATIONS_DONE) {
|
||||||
|
@ -1,21 +1,16 @@
|
|||||||
#include <stdio.h>
|
#include <cstring>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <elfio/elfio.hpp>
|
#include <elfio/elfio.hpp>
|
||||||
#include <proc_ui/procui.h>
|
#include <proc_ui/procui.h>
|
||||||
#include <sysapp/launch.h>
|
#include <sysapp/launch.h>
|
||||||
#include <coreinit/foreground.h>
|
#include <coreinit/foreground.h>
|
||||||
#include <coreinit/cache.h>
|
#include <coreinit/cache.h>
|
||||||
#include <coreinit/cache.h>
|
#include <nn/act/client_cpp.h>
|
||||||
#include <coreinit/memorymap.h>
|
|
||||||
#include <coreinit/dynload.h>
|
#include <coreinit/dynload.h>
|
||||||
#include <whb/log.h>
|
|
||||||
#include <whb/log_udp.h>
|
#include <whb/log_udp.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "fs/DirList.h"
|
#include "fs/DirList.h"
|
||||||
#include "utils/logger.h"
|
|
||||||
#include "utils/utils.h"
|
|
||||||
#include "module/ModuleDataPersistence.h"
|
#include "module/ModuleDataPersistence.h"
|
||||||
#include "module/ModuleDataFactory.h"
|
#include "module/ModuleDataFactory.h"
|
||||||
#include "ElfUtils.h"
|
#include "ElfUtils.h"
|
||||||
@ -49,7 +44,7 @@ bool doRelocation(std::vector<RelocationData> &relocData, relocation_trampolin_e
|
|||||||
std::string functionName = curReloc.getName();
|
std::string functionName = curReloc.getName();
|
||||||
std::string rplName = curReloc.getImportRPLInformation().getName();
|
std::string rplName = curReloc.getImportRPLInformation().getName();
|
||||||
int32_t isData = curReloc.getImportRPLInformation().isData();
|
int32_t isData = curReloc.getImportRPLInformation().isData();
|
||||||
OSDynLoad_Module rplHandle = 0;
|
OSDynLoad_Module rplHandle = nullptr;
|
||||||
OSDynLoad_Acquire(rplName.c_str(), &rplHandle);
|
OSDynLoad_Acquire(rplName.c_str(), &rplHandle);
|
||||||
|
|
||||||
uint32_t functionAddress = 0;
|
uint32_t functionAddress = 0;
|
||||||
@ -79,10 +74,10 @@ int main(int argc, char **argv) {
|
|||||||
setupModules.SortList();
|
setupModules.SortList();
|
||||||
|
|
||||||
for (int i = 0; i < setupModules.GetFilecount(); i++) {
|
for (int i = 0; i < setupModules.GetFilecount(); i++) {
|
||||||
|
uint32_t destination_address = ((uint32_t) gModuleData + (sizeof(module_information_t) + 0x0000FFFF)) & 0xFFFF0000;
|
||||||
memset((void *) gModuleData, 0, sizeof(module_information_t));
|
memset((void *) gModuleData, 0, sizeof(module_information_t));
|
||||||
DEBUG_FUNCTION_LINE("Trying to run %s", setupModules.GetFilepath(i));
|
DEBUG_FUNCTION_LINE("Trying to run %s", setupModules.GetFilepath(i));
|
||||||
uint32_t destination_address = ((uint32_t) gModuleData + (sizeof(module_information_t) + 0x0000FFFF)) & 0xFFFF0000;
|
std::optional<ModuleData> moduleData = ModuleDataFactory::load(setupModules.GetFilepath(i), &destination_address, textSectionStart - destination_address, gModuleData->trampolines, DYN_LINK_TRAMPOLIN_LIST_LENGTH);
|
||||||
std::optional<ModuleData> moduleData = ModuleDataFactory::load(setupModules.GetFilepath(i), &destination_address, MEMORY_REGION_USABLE_END - textSectionStart, gModuleData->trampolines, DYN_LINK_TRAMPOLIN_LIST_LENGTH);
|
|
||||||
if (!moduleData) {
|
if (!moduleData) {
|
||||||
DEBUG_FUNCTION_LINE("Failed to load %s", setupModules.GetFilepath(i));
|
DEBUG_FUNCTION_LINE("Failed to load %s", setupModules.GetFilepath(i));
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user