From 579f70de86f931ce7808dc0a36fbabe973ed3f63 Mon Sep 17 00:00:00 2001 From: Maschell Date: Mon, 31 Jul 2023 22:01:32 +0200 Subject: [PATCH] Give the users tips how to fix the 1503030 error when they encounter it in the Wii U Menu --- Dockerfile | 1 + Makefile | 2 +- README.md | 1 + src/SaveRedirection.cpp | 26 ++++++++++++++++++++++++++ src/SaveRedirection.h | 3 ++- src/main.cpp | 11 ++++++++--- 6 files changed, 39 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index e2724d7..d1fc717 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,5 +5,6 @@ COPY --from=ghcr.io/wiiu-env/librpxloader:20230621 /artifacts $DEVKITPRO COPY --from=ghcr.io/wiiu-env/libsdutils:20230621 /artifacts $DEVKITPRO COPY --from=ghcr.io/wiiu-env/libwuhbutils:20230621 /artifacts $DEVKITPRO COPY --from=ghcr.io/wiiu-env/libcontentredirection:20230621 /artifacts $DEVKITPRO +COPY --from=ghcr.io/wiiu-env/libnotifications:20230621 /artifacts $DEVKITPRO WORKDIR project diff --git a/Makefile b/Makefile index c03dd23..625c688 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,7 @@ CXXFLAGS += -DDEBUG -DVERBOSE_DEBUG -g CFLAGS += -DDEBUG -DVERBOSE_DEBUG -g endif -LIBS := -lwups -lwut -lwuhbutils -lcontentredirection -lrpxloader -lsdutils +LIBS := -lwups -lwut -lwuhbutils -lcontentredirection -lrpxloader -lsdutils -lnotifications #------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level diff --git a/README.md b/README.md index 83d0476..70f7daf 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ This plugin allows you to boot homebrew directly from your Wii U Menu. 4. Requires the [WUHBUtilsModule](https://github.com/wiiu-env/WUHBUtilsModule) in `sd:/wiiu/environments/[ENVIRONMENT]/modules`. 5. Requires the [ContentRedirectionModule](https://github.com/wiiu-env/ContentRedirectionModule) in `sd:/wiiu/environments/[ENVIRONMENT]/modules`. 6. Requires the [SDHotSwapModule](https://github.com/wiiu-env/SDHotSwapModule) in `sd:/wiiu/environments/[ENVIRONMENT]/modules`. +7. Requires the [NotificationModule](https://github.com/wiiu-env/NotificationModule) in `sd:/wiiu/environments/[ENVIRONMENT]/modules`. ## Usage diff --git a/src/SaveRedirection.cpp b/src/SaveRedirection.cpp index d2fe1e6..939234d 100644 --- a/src/SaveRedirection.cpp +++ b/src/SaveRedirection.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -186,6 +187,31 @@ DECL_FUNCTION(int32_t, SAVEInit) { return res; } +DECL_FUNCTION(FSError, FSGetLastErrorCodeForViewer, FSClient *client) { + auto res = real_FSGetLastErrorCodeForViewer(client); + if (!gInWiiUMenu) { + return res; + } + if ((uint32_t) res == 1503030) { + // If we encounter error 1503030 when running the Wii U Menu we probably hit a Wii U Menu save related issue + // Either the sd card is write locked or the save on the sd card it corrupted. Let the user now about this.. + + std::string deleteHint = string_format("If not write locked, delete \"sd:" HOMEBREW_ON_MENU_PLUGIN_DATA_PATH_BASE "/%s/save/common/BaristaIconDataBase.dat\".", gSerialId.c_str()); + std::string deleteHint2 = string_format("If deleting this file doesn't fix the error code, delete this directory: \"sd:" HOMEBREW_ON_MENU_PLUGIN_DATA_PATH_BASE "/%s\".", gSerialId.c_str()); + NotificationModuleHandle handle; + + NotificationModule_AddDynamicNotification("Caution: This resets the order of application on the Wii U Menu when using Aroma.", &handle); + NotificationModule_AddDynamicNotification(deleteHint2.c_str(), &handle); + NotificationModule_AddDynamicNotification("", &handle); + NotificationModule_AddDynamicNotification(deleteHint.c_str(), &handle); + NotificationModule_AddDynamicNotification("", &handle); + NotificationModule_AddDynamicNotification("", &handle); + NotificationModule_AddDynamicNotification("The SD card appears to be write-locked or the Wii U Menu save on the SD card is corrupted. Check the SD card write lock.", &handle); + } + return res; +} + WUPS_MUST_REPLACE(SAVEInit, WUPS_LOADER_LIBRARY_NN_SAVE, SAVEInit); WUPS_MUST_REPLACE(LoadConsoleAccount__Q2_2nn3actFUc13ACTLoadOptionPCcb, WUPS_LOADER_LIBRARY_NN_ACT, LoadConsoleAccount__Q2_2nn3actFUc13ACTLoadOptionPCcb); +WUPS_MUST_REPLACE_FOR_PROCESS(FSGetLastErrorCodeForViewer, WUPS_LOADER_LIBRARY_COREINIT, FSGetLastErrorCodeForViewer, WUPS_FP_TARGET_PROCESS_WII_U_MENU); WUPS_MUST_REPLACE(SAVEGetSharedSaveDataPath, WUPS_LOADER_LIBRARY_NN_SAVE, SAVEGetSharedSaveDataPath); \ No newline at end of file diff --git a/src/SaveRedirection.h b/src/SaveRedirection.h index d6dafb0..6a1de30 100644 --- a/src/SaveRedirection.h +++ b/src/SaveRedirection.h @@ -2,6 +2,7 @@ extern bool gInWiiUMenu; -#define HOMEBREW_ON_MENU_PLUGIN_DATA_PATH "/vol/external01/wiiu/homebrew_on_menu_plugin" +#define HOMEBREW_ON_MENU_PLUGIN_DATA_PATH_BASE "/wiiu/homebrew_on_menu_plugin" +#define HOMEBREW_ON_MENU_PLUGIN_DATA_PATH "/vol/external01" HOMEBREW_ON_MENU_PLUGIN_DATA_PATH_BASE void SaveRedirectionCleanUp(); \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 51a053d..4a77628 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,7 +4,6 @@ #include "bootLogoTex_tga.h" #include "bootMovie_h264.h" #include "fs/CFile.hpp" -#include "fs/FSUtils.h" #include "fs/FileReader.h" #include "fs/FileReaderWUHB.h" #include "globals.h" @@ -18,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -27,8 +25,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -124,6 +122,13 @@ INITIALIZE_PLUGIN() { OSFatal("Homebrew on Menu Plugin: Failed to init RPXLoader."); } + // Use libnotifications. + NotificationModuleStatus error4; + if ((error4 = NotificationModule_InitLibrary()) != NOTIFICATION_MODULE_RESULT_SUCCESS) { + DEBUG_FUNCTION_LINE_ERR("Homebrew on Menu Plugin: Failed to init NotificationModule. Error %s [%d]", NotificationModule_GetStatusStr(error4), error4); + OSFatal("Homebrew on Menu Plugin: Failed to init NotificationModule."); + } + // Open storage to read values WUPSStorageError storageRes = WUPS_OpenStorage(); if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) {