Add Support for WUMS_MODULE_SKIP_WUT_INIT macro

This commit is contained in:
Maschell 2021-02-19 17:01:11 +01:00
parent 5f9e2f8725
commit 07adc02d53
6 changed files with 36 additions and 9 deletions

View File

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

View File

@ -32,6 +32,7 @@ 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.setSkipEntrypoint(module_data->skipEntrypoint); moduleData.setSkipEntrypoint(module_data->skipEntrypoint);
moduleData.setSkipWUTInit(module_data->skipWUTInit);
moduleData.setInitBeforeRelocationDoneHook(module_data->initBeforeRelocationDoneHook); moduleData.setInitBeforeRelocationDoneHook(module_data->initBeforeRelocationDoneHook);
moduleData.setExportName(module_data->module_export_name); moduleData.setExportName(module_data->module_export_name);

View File

@ -17,12 +17,17 @@ 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) {
if(!module.relocationsDone){ if(!module.relocationsDone){
DEBUG_FUNCTION_LINE("Hook not called because the relocations failed\n"); DEBUG_FUNCTION_LINE("Hook not called because the relocations failed\n");
return; return;
} }
if ((type == WUMS_HOOK_INIT_WUT || type == WUMS_HOOK_FINI_WUT) && module.isSkipWUTInit()) {
DEBUG_FUNCTION_LINE("Skip WUMS_HOOK_INIT_WUT/WUMS_HOOK_FINI_WUT for %s\n", module.getExportName().c_str());
return;
}
for (auto &curHook : module.getHookDataList()) { for (auto &curHook : module.getHookDataList()) {
auto func_ptr = (uint32_t) curHook.getTarget(); auto func_ptr = (uint32_t) curHook.getTarget();
if (func_ptr == 0) { if (func_ptr == 0) {

View File

@ -140,6 +140,10 @@ public:
return this->initBeforeRelocationDoneHook; return this->initBeforeRelocationDoneHook;
} }
[[nodiscard]] bool isSkipWUTInit() const {
return this->skipWUTInit;
}
void setSkipEntrypoint(bool value) { void setSkipEntrypoint(bool value) {
this->skipEntrypoint = value; this->skipEntrypoint = value;
} }
@ -147,6 +151,10 @@ public:
this->initBeforeRelocationDoneHook = value; this->initBeforeRelocationDoneHook = value;
} }
void setSkipWUTInit(bool value) {
this->skipWUTInit = value;
}
bool relocationsDone = false; bool relocationsDone = false;
private: private:
std::vector<RelocationData> relocation_data_list; std::vector<RelocationData> relocation_data_list;
@ -165,4 +173,5 @@ private:
uint32_t entrypoint = 0; uint32_t entrypoint = 0;
bool skipEntrypoint = false; bool skipEntrypoint = false;
bool initBeforeRelocationDoneHook = false; bool initBeforeRelocationDoneHook = false;
bool skipWUTInit = false;
}; };

View File

@ -186,22 +186,33 @@ std::optional<ModuleData> ModuleDataFactory::load(std::string path, uint32_t *de
std::string key(curEntry); std::string key(curEntry);
std::string value(curEntry + firstFound + 1); std::string value(curEntry + firstFound + 1);
if (key.compare("export_name") == 0) { if (key == "export_name") {
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("skipEntrypoint") == 0) { } else if (key == "skipEntrypoint") {
if (value.compare("true") == 0) { if (value == "true") {
DEBUG_FUNCTION_LINE("skipEntrypoint = %s", value.c_str()); DEBUG_FUNCTION_LINE("skipEntrypoint = %s", value.c_str());
moduleData.setSkipEntrypoint(true); moduleData.setSkipEntrypoint(true);
} else {
moduleData.setSkipEntrypoint(false);
} }
} else if (key.compare("initBeforeRelocationDoneHook") == 0) { } else if (key == "initBeforeRelocationDoneHook") {
if (value.compare("true") == 0) { if (value == "true") {
DEBUG_FUNCTION_LINE("initBeforeRelocationDoneHook = %s", value.c_str()); DEBUG_FUNCTION_LINE("initBeforeRelocationDoneHook = %s", value.c_str());
moduleData.setInitBeforeRelocationDoneHook(true); moduleData.setInitBeforeRelocationDoneHook(true);
} else {
moduleData.setInitBeforeRelocationDoneHook(false);
}
} else if (key == "skipwutInit") {
if (value == "true") {
DEBUG_FUNCTION_LINE("skipwutInit = %s", value.c_str());
moduleData.setSkipWUTInit(true);
} else {
moduleData.setSkipWUTInit(false);
} }
} }
if (key.compare("wums") == 0) { if (key == "wums") {
if (value.compare("0.1") != 0) { if (value != "0.1") {
DEBUG_FUNCTION_LINE("Warning: Ignoring module - Unsupported WUMS version: %s.\n", value.c_str()); DEBUG_FUNCTION_LINE("Warning: Ignoring module - Unsupported WUMS version: %s.\n", value.c_str());
return std::nullopt; return std::nullopt;
} }

View File

@ -73,6 +73,7 @@ bool ModuleDataPersistence::saveModuleData(module_information_t *moduleInformati
module_data->entrypoint = module.getEntrypoint(); module_data->entrypoint = module.getEntrypoint();
module_data->skipEntrypoint = module.isSkipEntrypoint(); module_data->skipEntrypoint = module.isSkipEntrypoint();
module_data->initBeforeRelocationDoneHook = module.isInitBeforeRelocationDoneHook(); module_data->initBeforeRelocationDoneHook = module.isInitBeforeRelocationDoneHook();
module_data->skipWUTInit = module.isSkipWUTInit();
moduleInformation->number_used_modules++; moduleInformation->number_used_modules++;