static void frontend_wiiu_exec(const char *path, bool should_load_game) { struct { u32 magic; u32 argc; char * argv[3]; char args[]; }*param = getApplicationEndAddr(); int len = 0; param->argc = 0; if(!path || !*path) { RARCH_LOG("No executable path provided, cannot Restart\n"); } DEBUG_STR(path); strcpy(param->args + len, elf_path_cst); param->argv[param->argc] = param->args + len; len += strlen(param->args + len) + 1; param->argc++; RARCH_LOG("Attempt to load core: [%s].\n", path); #ifndef IS_SALAMANDER if (should_load_game && !path_is_empty(RARCH_PATH_CONTENT)) { strcpy(param->args + len, path_get(RARCH_PATH_CONTENT)); param->argv[param->argc] = param->args + len; len += strlen(param->args + len) + 1; param->argc++; RARCH_LOG("content path: [%s].\n", path_get(RARCH_PATH_CONTENT)); } #endif param->argv[param->argc] = NULL; { if (HBL_loadToMemory(path, (u32)param->args - (u32)param + len) < 0) RARCH_LOG("Failed to load core\n"); else { param->magic = ARGV_MAGIC; ARGV_PTR = param; DEBUG_VAR(param->argc); DEBUG_VAR(param->argv); } } }
extern "C" int32_t Menu_Main(int32_t argc, char **argv) { if(gAppStatus == 2) { //"No, we don't want to patch stuff again."); return EXIT_RELAUNCH_ON_LOAD; } InitOSFunctionPointers(); InitSocketFunctionPointers(); //For logging InitSysFunctionPointers(); InitFSFunctionPointers(); InitGX2FunctionPointers(); InitSysFunctionPointers(); InitVPadFunctionPointers(); InitPadScoreFunctionPointers(); InitAXFunctionPointers(); InitProcUIFunctionPointers(); log_init(); DEBUG_FUNCTION_LINE("We have %d kb for plugins.\n",(PLUGIN_LOCATION_END_ADDRESS-getApplicationEndAddr())/1024); //setup_os_exceptions(); DEBUG_FUNCTION_LINE("Wii U Plugin System Loader %s\n",APP_VERSION); DEBUG_FUNCTION_LINE("Sizeof dyn_linking_relocation_data_t %d\n",sizeof(dyn_linking_relocation_data_t)); Init(); init_kernel_syscalls(); wups_init_kernel_syscalls(); gGameTitleID = OSGetTitleID(); int32_t result = 0; //Reset everything when were going back to the Mii Maker if(isInMiiMakerHBL()) { CallHook(WUPS_LOADER_HOOK_DEINIT_PLUGIN); // Restore patches as the patched functions could change. RestorePatches(); DynamicLinkingHelper::getInstance()->clearAll(); //PluginLoader * pluginLoader = PluginLoader::getInstance(); //std::vector<PluginInformation *> pluginList = pluginLoader->getPluginInformation("sd:/wiiu/plugins/"); //pluginLoader->loadAndLinkPlugins(pluginList); //pluginLoader->clearPluginInformation(pluginList); //!******************************************************************* //! Initialize heap memory * //!******************************************************************* DEBUG_FUNCTION_LINE("Initialize memory management\n"); memoryInitialize(); DEBUG_FUNCTION_LINE("Start main application\n"); result = Application::instance()->exec(); DEBUG_FUNCTION_LINE("Main application stopped result: %d\n",result); DEBUG_FUNCTION_LINE("Application::destroyInstance\n"); Application::destroyInstance(); DEBUG_FUNCTION_LINE("Release memory\n"); memoryRelease(); CSettings::destroyInstance(); PluginLoader::destroyInstance(); } if(result == APPLICATION_CLOSE_APPLY_MEMORY) { if(!MemoryMapping::isMemoryMapped()) { MemoryMapping::setupMemoryMapping(); } } DEBUG_FUNCTION_LINE("Do relocations\n"); std::vector<dyn_linking_relocation_entry_t *> relocations = DynamicLinkingHelper::getInstance()->getAllValidDynamicLinkingRelocations(); DEBUG_FUNCTION_LINE("Found relocation information for %d functions\n",relocations.size()); if(!DynamicLinkingHelper::getInstance()->fillRelocations(relocations)) { OSFatal("fillRelocations failed."); } if(!isInMiiMakerHBL()) { DEBUG_FUNCTION_LINE("Apply patches.\n"); ApplyPatchesAndCallHookStartingApp(); ConfigUtils::loadConfigFromSD(); if(MemoryMapping::isMemoryMapped()) { DEBUG_FUNCTION_LINE("Mapping was already done. Running %016llX\n",gGameTitleID); readAndPrintSegmentRegister(NULL,NULL); MemoryMapping::readTestValuesFromMemory(); } else { DEBUG_FUNCTION_LINE("<-----------------------------------------------------> \n"); DEBUG_FUNCTION_LINE("<---------------- COPY PASTE ME START-----------------> \n"); DEBUG_FUNCTION_LINE("<-----------------------------------------------------> \n"); DEBUG_FUNCTION_LINE("Mapping was't done. Running %016llX\n",gGameTitleID); readAndPrintSegmentRegister(NULL,NULL); DEBUG_FUNCTION_LINE("<-----------------------------------------------------> \n"); DEBUG_FUNCTION_LINE("<----------------- COPY PASTE ME END -----------------> \n"); DEBUG_FUNCTION_LINE("<-----------------------------------------------------> \n"); } return EXIT_RELAUNCH_ON_LOAD; } if(result == APPLICATION_CLOSE_APPLY || result == APPLICATION_CLOSE_APPLY_MEMORY) { CallHook(WUPS_LOADER_HOOK_INIT_KERNEL); CallHook(WUPS_LOADER_HOOK_INIT_FS); CallHook(WUPS_LOADER_HOOK_INIT_OVERLAY); CallHook(WUPS_LOADER_HOOK_INIT_PLUGIN); DEBUG_FUNCTION_LINE("Loading the system menu.\n"); DeInit(); SYSLaunchMenu(); return EXIT_RELAUNCH_ON_LOAD; } DEBUG_FUNCTION_LINE("Let's go to back to the Homebrew Launcher\n"); DEBUG_FUNCTION_LINE("Restoring the patched functions\n"); RestorePatches(); DEBUG_FUNCTION_LINE("Calling the plugin deinit hook\n"); CallHook(WUPS_LOADER_HOOK_DEINIT_PLUGIN); DEBUG_FUNCTION_LINE("Unmounting SD/USB devices\n"); DeInit(); DEBUG_FUNCTION_LINE("Bye bye!\n"); return EXIT_SUCCESS; }