mirror of
https://github.com/wiiu-env/WUMSLoader.git
synced 2024-11-16 04:59:17 +01:00
68 lines
2.1 KiB
C++
68 lines
2.1 KiB
C++
#include <cstring>
|
|
|
|
#include <elfio/elfio.hpp>
|
|
#include <sysapp/launch.h>
|
|
#include <nn/act/client_cpp.h>
|
|
#include <whb/log_udp.h>
|
|
#include <whb/log_cafe.h>
|
|
#include <whb/log_module.h>
|
|
|
|
#include "fs/DirList.h"
|
|
#include "module/ModuleDataPersistence.h"
|
|
#include "module/ModuleDataFactory.h"
|
|
#include "ElfUtils.h"
|
|
#include "kernel.h"
|
|
#include "globals.h"
|
|
|
|
extern "C" uint32_t textStart();
|
|
|
|
int main(int argc, char **argv) {
|
|
if (!WHBLogModuleInit()) {
|
|
WHBLogCafeInit();
|
|
WHBLogUdpInit();
|
|
}
|
|
|
|
// We subtract 0x100 to be safe.
|
|
uint32_t textSectionStart = textStart() - 0x100;
|
|
|
|
memset((void *) gModuleData, 0, sizeof(module_information_t));
|
|
gModuleData->version = MODULE_INFORMATION_VERSION;
|
|
|
|
std::string basePath = "fs:/vol/external01/wiiu";
|
|
if (argc >= 1) {
|
|
basePath = argv[0];
|
|
}
|
|
|
|
DirList modules(basePath + "/modules", ".wms", DirList::Files, 1);
|
|
modules.SortList();
|
|
|
|
uint32_t destination_address = ((uint32_t) gModuleData + (sizeof(module_information_t) + 0x0000FFFF)) & 0xFFFF0000;
|
|
for (int i = 0; i < modules.GetFilecount(); i++) {
|
|
DEBUG_FUNCTION_LINE("Loading module %s", modules.GetFilepath(i));
|
|
auto moduleData = ModuleDataFactory::load(modules.GetFilepath(i), &destination_address, textSectionStart - destination_address, gModuleData->trampolines,
|
|
DYN_LINK_TRAMPOLIN_LIST_LENGTH);
|
|
if (moduleData) {
|
|
DEBUG_FUNCTION_LINE("Successfully loaded %s", modules.GetFilepath(i));
|
|
ModuleDataPersistence::saveModuleData(gModuleData, moduleData.value());
|
|
} else {
|
|
DEBUG_FUNCTION_LINE("Failed to load %s", modules.GetFilepath(i));
|
|
}
|
|
}
|
|
|
|
SetupRelocator();
|
|
|
|
WHBLogUdpDeinit();
|
|
|
|
nn::act::Initialize();
|
|
nn::act::SlotNo slot = nn::act::GetSlotNo();
|
|
nn::act::SlotNo defaultSlot = nn::act::GetDefaultAccount();
|
|
nn::act::Finalize();
|
|
|
|
if (defaultSlot) { //normal menu boot
|
|
SYSLaunchMenu();
|
|
} else { //show mii select
|
|
_SYSLaunchMenuWithCheckingAccount(slot);
|
|
}
|
|
return 0;
|
|
}
|