Support for WUMS 0.3.1

This commit is contained in:
Maschell 2022-01-23 22:07:38 +01:00
parent 7f76c9f8c8
commit 9f7912cb60
8 changed files with 37 additions and 26 deletions

View File

@ -1,5 +1,5 @@
FROM wiiuenv/devkitppc:20211229
COPY --from=wiiuenv/wiiumodulesystem:20211207 /artifacts $DEVKITPRO
COPY --from=wiiuenv/wiiumodulesystem:20220123 /artifacts $DEVKITPRO
WORKDIR project

View File

@ -66,6 +66,14 @@ public:
this->initBeforeRelocationDoneHook = value;
}
[[nodiscard]] bool isSkipInitFini() const {
return this->skipInitFini;
}
void setSkipInitFini(bool value) {
this->skipInitFini = value;
}
bool relocationsDone = false;
private:
std::vector<std::shared_ptr<RelocationData>> relocation_data_list;
@ -73,4 +81,5 @@ private:
std::string export_name;
uint32_t entrypoint = 0;
bool initBeforeRelocationDoneHook = false;
bool skipInitFini = false;
};

View File

@ -26,6 +26,7 @@ std::vector<std::shared_ptr<ModuleDataMinimal>> ModuleDataPersistence::loadModul
moduleData->setEntrypoint(module_data->entrypoint);
moduleData->setInitBeforeRelocationDoneHook(module_data->initBeforeRelocationDoneHook);
moduleData->setSkipInitFini(module_data->skipInitFini);
moduleData->setExportName(module_data->module_export_name);
for (auto &hook_entry: module_data->hook_entries) {

View File

@ -184,14 +184,6 @@ extern "C" void doStart(int argc, char **argv) {
DEBUG_FUNCTION_LINE_VERBOSE("Relocations done\n");
CallHook(loadedModules, WUMS_HOOK_RELOCATIONS_DONE);
for (int i = 0; i < gModuleData->number_used_modules; i++) {
if (!gModuleData->module_data[i].skipEntrypoint) {
DEBUG_FUNCTION_LINE_VERBOSE("About to call %08X\n", gModuleData->module_data[i].entrypoint);
int ret = ((int (*)(int, char **)) (gModuleData->module_data[i].entrypoint))(argc, argv);
DEBUG_FUNCTION_LINE_VERBOSE("return code was %d\n", ret);
}
}
for (auto &curModule: loadedModules) {
if (!curModule->isInitBeforeRelocationDoneHook()) {
CallInitHooksForModule(curModule);
@ -208,8 +200,10 @@ extern "C" void doStart(int argc, char **argv) {
CallHook(loadedModules, WUMS_HOOK_INIT_WUT_STDCPP);
CallHook(loadedModules, WUMS_HOOK_INIT_WUT_DEVOPTAB);
CallHook(loadedModules, WUMS_HOOK_INIT_WUT_SOCKETS);
for (auto &curModule: loadedModules) {
CallHook(curModule, WUMS_HOOK_INIT_WRAPPER, !curModule->isSkipInitFini());
}
CallHook(loadedModules, WUMS_HOOK_APPLICATION_STARTS);
//CallHook(loadedModules, WUMS_HOOK_FINI_WUT);
}
void CallInitHooksForModule(const std::shared_ptr<ModuleDataMinimal> &curModule) {
@ -218,7 +212,9 @@ void CallInitHooksForModule(const std::shared_ptr<ModuleDataMinimal> &curModule)
CallHook(curModule, WUMS_HOOK_INIT_WUT_STDCPP);
CallHook(curModule, WUMS_HOOK_INIT_WUT_DEVOPTAB);
CallHook(curModule, WUMS_HOOK_INIT_WUT_SOCKETS);
CallHook(curModule, WUMS_HOOK_INIT_WRAPPER, !curModule->isSkipInitFini());
CallHook(curModule, WUMS_HOOK_INIT);
CallHook(curModule, WUMS_HOOK_FINI_WRAPPER, !curModule->isSkipInitFini());
CallHook(curModule, WUMS_HOOK_FINI_WUT_SOCKETS);
CallHook(curModule, WUMS_HOOK_FINI_WUT_DEVOPTAB);
CallHook(curModule, WUMS_HOOK_FINI_WUT_STDCPP);

View File

@ -14,6 +14,9 @@ static const char **hook_names = (const char *[]) {
"WUMS_HOOK_INIT_WUT_SOCKETS",
"WUMS_HOOK_FINI_WUT_SOCKETS",
"WUMS_HOOK_INIT_WRAPPER",
"WUMS_HOOK_FINI_WRAPPER",
"WUMS_HOOK_INIT",
"WUMS_HOOK_APPLICATION_STARTS",
"WUMS_HOOK_APPLICATION_ENDS",
@ -65,7 +68,9 @@ void CallHook(const std::shared_ptr<ModuleDataMinimal> &module, wums_hook_type_t
type == WUMS_HOOK_INIT_WUT_DEVOPTAB ||
type == WUMS_HOOK_FINI_WUT_DEVOPTAB ||
type == WUMS_HOOK_INIT_WUT_SOCKETS ||
type == WUMS_HOOK_FINI_WUT_SOCKETS
type == WUMS_HOOK_FINI_WUT_SOCKETS ||
type == WUMS_HOOK_INIT_WRAPPER ||
type == WUMS_HOOK_FINI_WRAPPER
)) {
DEBUG_FUNCTION_LINE_VERBOSE("Calling hook of type %s [%d] %d for %s: %08X\n", hook_names[type], type, curHook->getType(), module->getExportName().c_str(), curHook->getTarget());
((void (*)()) ((uint32_t *) func_ptr))();

View File

@ -148,22 +148,22 @@ public:
return this->export_name;
}
[[nodiscard]] bool isSkipEntrypoint() const {
return this->skipEntrypoint;
}
[[nodiscard]] bool isInitBeforeRelocationDoneHook() const {
return this->initBeforeRelocationDoneHook;
}
void setSkipEntrypoint(bool value) {
this->skipEntrypoint = value;
}
void setInitBeforeRelocationDoneHook(bool value) {
this->initBeforeRelocationDoneHook = value;
}
[[nodiscard]] bool isSkipInitFini() const {
return this->skipInitFini;
}
void setSkipInitFini(bool value) {
this->skipInitFini = value;
}
bool relocationsDone = false;
private:
std::vector<std::shared_ptr<RelocationData>> relocation_data_list;
@ -181,6 +181,6 @@ private:
uint32_t startAddress = 0;
uint32_t endAddress = 0;
uint32_t entrypoint = 0;
bool skipEntrypoint = false;
bool initBeforeRelocationDoneHook = false;
bool skipInitFini = false;
};

View File

@ -186,12 +186,12 @@ ModuleDataFactory::load(const std::string &path, uint32_t *destination_address_p
if (key == "export_name") {
DEBUG_FUNCTION_LINE("export_name = %s", value.c_str());
moduleData->setExportName(value);
} else if (key == "skipEntrypoint") {
} else if (key == "skipInitFini") {
if (value == "true") {
DEBUG_FUNCTION_LINE("skipEntrypoint = %s", value.c_str());
moduleData->setSkipEntrypoint(true);
DEBUG_FUNCTION_LINE("skipInitFini = %s", value.c_str());
moduleData->setSkipInitFini(true);
} else {
moduleData->setSkipEntrypoint(false);
moduleData->setSkipInitFini(false);
}
} else if (key == "initBeforeRelocationDoneHook") {
if (value == "true") {

View File

@ -92,7 +92,7 @@ bool ModuleDataPersistence::saveModuleData(module_information_t *moduleInformati
module_data->startAddress = module->getStartAddress();
module_data->endAddress = module->getEndAddress();
module_data->entrypoint = module->getEntrypoint();
module_data->skipEntrypoint = module->isSkipEntrypoint();
module_data->skipInitFini = module->isSkipInitFini();
module_data->initBeforeRelocationDoneHook = module->isInitBeforeRelocationDoneHook();
moduleInformation->number_used_modules++;
@ -127,7 +127,7 @@ std::vector<std::shared_ptr<ModuleData>> ModuleDataPersistence::loadModuleData(m
moduleData->setStartAddress(module_data->startAddress);
moduleData->setEndAddress(module_data->endAddress);
moduleData->setExportName(module_data->module_export_name);
moduleData->setSkipEntrypoint(module_data->skipEntrypoint);
moduleData->setSkipInitFini(module_data->skipInitFini);
moduleData->setInitBeforeRelocationDoneHook(module_data->initBeforeRelocationDoneHook);
for (auto &export_entrie: module_data->export_entries) {