mirror of
https://github.com/wiiu-env/WUMSLoader.git
synced 2024-12-25 15:41:50 +01:00
Implementation of InitBeforeRelocationDoneHook and SkipEntrypoint module options
This commit is contained in:
parent
6e352b0085
commit
98c8de7479
@ -31,7 +31,8 @@ std::vector<ModuleData> ModuleDataPersistence::loadModuleData(module_information
|
|||||||
moduleData.setEntrypoint(module_data->entrypoint);
|
moduleData.setEntrypoint(module_data->entrypoint);
|
||||||
moduleData.setStartAddress(module_data->startAddress);
|
moduleData.setStartAddress(module_data->startAddress);
|
||||||
moduleData.setEndAddress(module_data->endAddress);
|
moduleData.setEndAddress(module_data->endAddress);
|
||||||
moduleData.setInitBeforeEntrypoint(module_data->initBeforeEntrypoint);
|
moduleData.setSkipEntrypoint(module_data->skipEntrypoint);
|
||||||
|
moduleData.setInitBeforeRelocationDoneHook(module_data->initBeforeRelocationDoneHook);
|
||||||
|
|
||||||
moduleData.setExportName(module_data->module_export_name);
|
moduleData.setExportName(module_data->module_export_name);
|
||||||
|
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
#include <coreinit/dynload.h>
|
#include <coreinit/dynload.h>
|
||||||
#include <coreinit/cache.h>
|
#include <coreinit/cache.h>
|
||||||
#include <nsysnet/socket.h>
|
#include <nsysnet/socket.h>
|
||||||
#include <coreinit/memorymap.h>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "../../source/module/RelocationData.h"
|
#include "../../source/module/RelocationData.h"
|
||||||
#include "../../source/module/ModuleData.h"
|
#include "../../source/module/ModuleData.h"
|
||||||
#include "ModuleDataPersistence.h"
|
#include "ModuleDataPersistence.h"
|
||||||
#include "ElfUtils.h"
|
#include "ElfUtils.h"
|
||||||
|
|
||||||
#include "utils/logger.h"
|
|
||||||
#include "utils/dynamic.h"
|
#include "utils/dynamic.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "hooks.h"
|
#include "hooks.h"
|
||||||
@ -125,24 +122,25 @@ extern "C" void doStart(int argc, char **argv) {
|
|||||||
DEBUG_FUNCTION_LINE("Resolve relocations without replacing alloc functions\n");
|
DEBUG_FUNCTION_LINE("Resolve relocations without replacing alloc functions\n");
|
||||||
ResolveRelocations(loadedModules);
|
ResolveRelocations(loadedModules);
|
||||||
|
|
||||||
DEBUG_FUNCTION_LINE("Try to call kernel init\n");
|
|
||||||
// Call init hook of kernel
|
|
||||||
for (auto &curModule : loadedModules) {
|
for (auto &curModule : loadedModules) {
|
||||||
if (curModule.isInitBeforeEntrypoint()) {
|
if (curModule.isInitBeforeRelocationDoneHook()) {
|
||||||
CallHook(curModule, WUMS_HOOK_INIT);
|
CallHook(curModule, WUMS_HOOK_INIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEBUG_FUNCTION_LINE("Relocations done\n");
|
||||||
CallHook(loadedModules, WUMS_HOOK_RELOCATIONS_DONE);
|
CallHook(loadedModules, WUMS_HOOK_RELOCATIONS_DONE);
|
||||||
|
|
||||||
for (int i = 0; i < gModuleData->number_used_modules; i++) {
|
for (int i = 0; i < gModuleData->number_used_modules; i++) {
|
||||||
DEBUG_FUNCTION_LINE("About to call %08X\n", gModuleData->module_data[i].entrypoint);
|
if (!gModuleData->module_data[i].skipEntrypoint) {
|
||||||
int ret = ((int (*)(int, char **)) (gModuleData->module_data[i].entrypoint))(argc, argv);
|
DEBUG_FUNCTION_LINE("About to call %08X\n", gModuleData->module_data[i].entrypoint);
|
||||||
DEBUG_FUNCTION_LINE("return code was %d\n", ret);
|
int ret = ((int (*)(int, char **)) (gModuleData->module_data[i].entrypoint))(argc, argv);
|
||||||
|
DEBUG_FUNCTION_LINE("return code was %d\n", ret);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &curModule : loadedModules) {
|
for (auto &curModule : loadedModules) {
|
||||||
if (!curModule.isInitBeforeEntrypoint()) {
|
if (!curModule.isInitBeforeRelocationDoneHook()) {
|
||||||
CallHook(curModule, WUMS_HOOK_INIT);
|
CallHook(curModule, WUMS_HOOK_INIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,6 +150,7 @@ extern "C" void doStart(int argc, char **argv) {
|
|||||||
CallHook(loadedModules, WUMS_HOOK_RELOCATIONS_DONE);
|
CallHook(loadedModules, WUMS_HOOK_RELOCATIONS_DONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Implement Application ends hook
|
||||||
// CallHook(loadedModules, WUMS_HOOK_FINI_WUT);
|
// CallHook(loadedModules, WUMS_HOOK_FINI_WUT);
|
||||||
// CallHook(loadedModules, WUMS_HOOK_INIT_WUT);
|
// CallHook(loadedModules, WUMS_HOOK_INIT_WUT);
|
||||||
|
|
||||||
|
@ -132,12 +132,19 @@ public:
|
|||||||
return this->export_name;
|
return this->export_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isInitBeforeEntrypoint() const {
|
bool isSkipEntrypoint() const {
|
||||||
return this->initBeforeEntrypoint;
|
return this->skipEntrypoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setInitBeforeEntrypoint(bool value) {
|
bool isInitBeforeRelocationDoneHook() const {
|
||||||
this->initBeforeEntrypoint = value;
|
return this->initBeforeRelocationDoneHook;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setSkipEntrypoint(bool value) {
|
||||||
|
this->skipEntrypoint = value;
|
||||||
|
}
|
||||||
|
void setInitBeforeRelocationDoneHook(bool value) {
|
||||||
|
this->initBeforeRelocationDoneHook = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -155,5 +162,6 @@ private:
|
|||||||
uint32_t startAddress = 0;
|
uint32_t startAddress = 0;
|
||||||
uint32_t endAddress = 0;
|
uint32_t endAddress = 0;
|
||||||
uint32_t entrypoint = 0;
|
uint32_t entrypoint = 0;
|
||||||
bool initBeforeEntrypoint = false;
|
bool skipEntrypoint = false;
|
||||||
|
bool initBeforeRelocationDoneHook = false;
|
||||||
};
|
};
|
||||||
|
@ -189,10 +189,15 @@ std::optional<ModuleData> ModuleDataFactory::load(std::string path, uint32_t *de
|
|||||||
if (key.compare("export_name") == 0) {
|
if (key.compare("export_name") == 0) {
|
||||||
DEBUG_FUNCTION_LINE("export_name = %s", value.c_str());
|
DEBUG_FUNCTION_LINE("export_name = %s", value.c_str());
|
||||||
moduleData.setExportName(value);
|
moduleData.setExportName(value);
|
||||||
} else if (key.compare("initBeforeEntrypoint") == 0) {
|
} else if (key.compare("skipEntrypoint") == 0) {
|
||||||
if (value.compare("true") == 0) {
|
if (value.compare("true") == 0) {
|
||||||
DEBUG_FUNCTION_LINE("initBeforeEntrypoint = %s", value.c_str());
|
DEBUG_FUNCTION_LINE("skipEntrypoint = %s", value.c_str());
|
||||||
moduleData.setInitBeforeEntrypoint(true);
|
moduleData.setSkipEntrypoint(true);
|
||||||
|
}
|
||||||
|
} else if (key.compare("initBeforeRelocationDoneHook") == 0) {
|
||||||
|
if (value.compare("true") == 0) {
|
||||||
|
DEBUG_FUNCTION_LINE("initBeforeRelocationDoneHook = %s", value.c_str());
|
||||||
|
moduleData.setInitBeforeRelocationDoneHook(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (key.compare("wums") == 0) {
|
if (key.compare("wums") == 0) {
|
||||||
|
@ -71,7 +71,8 @@ bool ModuleDataPersistence::saveModuleData(module_information_t *moduleInformati
|
|||||||
module_data->startAddress = module.getStartAddress();
|
module_data->startAddress = module.getStartAddress();
|
||||||
module_data->endAddress = module.getEndAddress();
|
module_data->endAddress = module.getEndAddress();
|
||||||
module_data->entrypoint = module.getEntrypoint();
|
module_data->entrypoint = module.getEntrypoint();
|
||||||
module_data->initBeforeEntrypoint = module.isInitBeforeEntrypoint();
|
module_data->skipEntrypoint = module.isSkipEntrypoint();
|
||||||
|
module_data->initBeforeRelocationDoneHook = module.isInitBeforeRelocationDoneHook();
|
||||||
|
|
||||||
moduleInformation->number_used_modules++;
|
moduleInformation->number_used_modules++;
|
||||||
|
|
||||||
@ -105,7 +106,8 @@ std::vector<ModuleData> ModuleDataPersistence::loadModuleData(module_information
|
|||||||
moduleData.setStartAddress(module_data->startAddress);
|
moduleData.setStartAddress(module_data->startAddress);
|
||||||
moduleData.setEndAddress(module_data->endAddress);
|
moduleData.setEndAddress(module_data->endAddress);
|
||||||
moduleData.setExportName(module_data->module_export_name);
|
moduleData.setExportName(module_data->module_export_name);
|
||||||
moduleData.setInitBeforeEntrypoint(module_data->initBeforeEntrypoint);
|
moduleData.setSkipEntrypoint(module_data->skipEntrypoint);
|
||||||
|
moduleData.setInitBeforeRelocationDoneHook(module_data->initBeforeRelocationDoneHook);
|
||||||
|
|
||||||
for (uint32_t j = 0; j < EXPORT_ENTRY_LIST_LENGTH; j++) {
|
for (uint32_t j = 0; j < EXPORT_ENTRY_LIST_LENGTH; j++) {
|
||||||
export_data_t *export_entry = &(module_data->export_entries[j]);
|
export_data_t *export_entry = &(module_data->export_entries[j]);
|
||||||
|
Loading…
Reference in New Issue
Block a user