From c0f6e1744a68f47f31c225490715900b83c57db0 Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 25 Aug 2022 19:49:00 +0200 Subject: [PATCH] Use libmocha instead of libiosuhax --- Dockerfile | 2 +- Makefile | 2 +- source/BootUtils.cpp | 44 +++++++++++++++++++++----------------------- source/BootUtils.h | 4 +++- source/main.cpp | 7 +++++++ 5 files changed, 33 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2f2a6be..42b8749 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM wiiuenv/devkitppc:20220806 -COPY --from=wiiuenv/libiosuhax:20220523 /artifacts $DEVKITPRO +COPY --from=wiiuenv/libmocha:20220728 /artifacts $DEVKITPRO WORKDIR project \ No newline at end of file diff --git a/Makefile b/Makefile index 332ca2a..dff9caa 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ CXXFLAGS := $(CFLAGS) -std=c++20 -fno-rtti ASFLAGS := -g $(ARCH) LDFLAGS = -g $(ARCH) $(RPXSPECS) --entry=_start -Wl,-Map,$(notdir $*.map) -LIBS := -lfreetype -lpng -lbz2 -liosuhax -lwut -lz +LIBS := -lfreetype -lpng -lbz2 -lmocha -lwut -lz ifeq ($(DEBUG),1) CXXFLAGS += -DDEBUG -g diff --git a/source/BootUtils.cpp b/source/BootUtils.cpp index 4b614b5..0e31c2e 100644 --- a/source/BootUtils.cpp +++ b/source/BootUtils.cpp @@ -4,14 +4,11 @@ #include "MenuUtils.h" #include "logger.h" #include -#include -#include -#include -#include +#include #include #include -#include #include +#include #include #include #include @@ -19,7 +16,6 @@ #include #include #include -#include void handleAccountSelection(); @@ -118,41 +114,43 @@ void bootvWiiMenu() { launchvWiiTitle(0); } -void bootHomebrewChannel() { +uint64_t getVWiiHBLTitleId() { // fall back to booting the vWii system menu if anything fails uint64_t titleId = 0; - if (IOSUHAX_Open(nullptr) >= 0) { - int fsaFd = IOSUHAX_FSA_Open(); - if (fsaFd >= 0) { + FSAInit(); + auto client = FSAAddClient(nullptr); + if (client > 0) { + if (Mocha_UnlockFSClientEx(client) == MOCHA_RESULT_SUCCESS) { // mount the slccmpt - if (IOSUHAX_FSA_Mount(fsaFd, "/dev/slccmpt01", "/vol/storage_slccmpt01", 2, nullptr, 0) >= 0) { + if (FSAMount(client, "/dev/slccmpt01", "/vol/storage_slccmpt01", FSA_MOUNT_FLAG_GLOBAL_MOUNT, nullptr, 0) >= 0) { FSStat stat; // test if the OHBC or HBC is installed - if (IOSUHAX_FSA_GetStat(fsaFd, "/vol/storage_slccmpt01/title/00010001/4f484243/content/00000000.app", &stat) >= 0) { + if (FSAGetStat(client, "/vol/storage_slccmpt01/title/00010001/4f484243/content/00000000.app", &stat) >= 0) { titleId = 0x000100014F484243L; // 'OHBC' - } else if (IOSUHAX_FSA_GetStat(fsaFd, "/vol/storage_slccmpt01/title/00010001/4c554c5a/content/00000000.app", &stat) >= 0) { + } else if (FSAGetStat(client, "/vol/storage_slccmpt01/title/00010001/4c554c5a/content/00000000.app", &stat) >= 0) { titleId = 0x000100014C554C5AL; // 'LULZ' } else { - DEBUG_FUNCTION_LINE("Cannot find HBC, booting vWii System Menu"); + DEBUG_FUNCTION_LINE("Cannot find HBC"); } - - IOSUHAX_FSA_Unmount(fsaFd, "/vol/storage_slccmpt01", 2); + FSAUnmount(client, "/vol/storage_slccmpt01", static_cast(2)); } else { - DEBUG_FUNCTION_LINE("Failed to mount SLCCMPT"); + DEBUG_FUNCTION_LINE_ERR("Failed to mount slccmpt01"); } - - IOSUHAX_FSA_Close(fsaFd); } else { - DEBUG_FUNCTION_LINE("Failed to open FSA"); + DEBUG_FUNCTION_LINE_ERR("Failed to unlock FSClient"); } - - IOSUHAX_Close(); + FSADelClient(client); } else { - DEBUG_FUNCTION_LINE("Failed to open IOSUHAX"); + DEBUG_FUNCTION_LINE_ERR("Failed to add FSAClient"); } + DEBUG_FUNCTION_LINE_ERR("%016llX", titleId); + return titleId; +} +void bootHomebrewChannel() { + uint64_t titleId = getVWiiHBLTitleId(); DEBUG_FUNCTION_LINE("Launching vWii title %016llx", titleId); launchvWiiTitle(titleId); } diff --git a/source/BootUtils.h b/source/BootUtils.h index 4eeb473..6ac2121 100644 --- a/source/BootUtils.h +++ b/source/BootUtils.h @@ -8,4 +8,6 @@ void bootHomebrewLauncher(); void bootvWiiMenu(); -void bootHomebrewChannel(); \ No newline at end of file +void bootHomebrewChannel(); + +uint64_t getVWiiHBLTitleId(); \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp index 28689f6..bde7ef9 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -38,6 +39,11 @@ int32_t main(int32_t argc, char **argv) { deinitLogging(); return 0; } + + if (Mocha_InitLibrary() != MOCHA_RESULT_SUCCESS) { + OSFatal("AutobootModule: Mocha_InitLibrary failed"); + } + bool showHBL = false; std::string configPath = "fs:/vol/external01/wiiu/autoboot.cfg"; if (argc >= 1) { @@ -86,5 +92,6 @@ int32_t main(int32_t argc, char **argv) { } deinitLogging(); + Mocha_DeinitLibrary(); return 0; }