Fix connecting to a 3DS on Mii Maker

This commit is contained in:
Maschell 2023-02-22 16:15:20 +01:00
parent 2d49133dea
commit 729c223091
5 changed files with 64 additions and 28 deletions

View File

@ -1,6 +1,6 @@
FROM wiiuenv/devkitppc:20221228 FROM wiiuenv/devkitppc:20230218
COPY --from=wiiuenv/wiiupluginsystem:20230126 /artifacts $DEVKITPRO COPY --from=wiiuenv/wiiupluginsystem:20230215 /artifacts $DEVKITPRO
COPY --from=wiiuenv/libnotifications:20230126 /artifacts $DEVKITPRO COPY --from=wiiuenv/libnotifications:20230126 /artifacts $DEVKITPRO
COPY --from=wiiuenv/librpxloader:20220903 /artifacts $DEVKITPRO COPY --from=wiiuenv/librpxloader:20220903 /artifacts $DEVKITPRO
COPY --from=wiiuenv/libcurlwrapper:20230121 /artifacts $DEVKITPRO COPY --from=wiiuenv/libcurlwrapper:20230121 /artifacts $DEVKITPRO

View File

@ -15,11 +15,16 @@ Provides some simple patches for Wii U Menu and checks for Aroma updates.
## Usage ## Usage
Via the plugin config menu (press L, DPAD Down and Minus on the GamePad, Pro Controller or Classic Controller) you can configure the plugin. The available options are the following: Via the plugin config menu (press L, DPAD Down and Minus on the GamePad, Pro Controller or Classic Controller) you can configure the plugin. The available options are the following:
- **Wii U Menu patches**: - **Wii U Menu patches**:
- Avoid "Format" dialog on Wii U Menu (UStealth): (Default is false) - Avoid "Format" dialog on Wii U Menu (UStealth): (Default is false)
- Skips the "Format"-nag when launching the Wii U Menu with a non-formatted external drive. - Skips the "Format"-nag when launching the Wii U Menu with a non-formatted external drive.
- Skip "Shutdown warning" on boot: (Default is true) - Skip "Shutdown warning" on boot: (Default is true)
- Hide the "Shutdown warning" after shutting the console down by pressing the power button for 4 seconds. - Hide the "Shutdown warning" after shutting the console down by pressing the power button for 4 seconds.
- **Other patches**:
- Allow error notifications (Default is true)
- Fix connecting to a 3DS in Mii Maker: (Default is true)
- Forces "nn::ndm::SuspendDaemonsAndDisconnectIfWireless" to always return success, this fixes connecting to the 3DS in Mii Maker.
## Building ## Building

View File

@ -43,6 +43,8 @@ INITIALIZE_PLUGIN() {
if (cat_config != nullptr) { if (cat_config != nullptr) {
LOAD_BOOL_FROM_STORAGE(cat_config, USTEALTH_CONFIG_ID, gActivateUStealth); LOAD_BOOL_FROM_STORAGE(cat_config, USTEALTH_CONFIG_ID, gActivateUStealth);
LOAD_BOOL_FROM_STORAGE(cat_config, POWEROFFWARNING_CONFIG_ID, gSkip4SecondOffStatusCheck); LOAD_BOOL_FROM_STORAGE(cat_config, POWEROFFWARNING_CONFIG_ID, gSkip4SecondOffStatusCheck);
LOAD_BOOL_FROM_STORAGE(cat_config, FORCE_NDM_SUSPEND_SUCCESS_CONFIG_ID, gForceNDMSuspendSuccess);
LOAD_BOOL_FROM_STORAGE(cat_config, ALLOW_ERROR_NOTIFICATIONS, gAllowErrorNotifications);
} }
wups_storage_item_t *cat_other = nullptr; wups_storage_item_t *cat_other = nullptr;
@ -92,6 +94,22 @@ DEINITIALIZE_PLUGIN() {
RPXLoader_DeInitLibrary(); RPXLoader_DeInitLibrary();
} }
DECL_FUNCTION(uint32_t, SuspendDaemonsAndDisconnectIfWireless__Q2_2nn3ndmFv) {
auto res = real_SuspendDaemonsAndDisconnectIfWireless__Q2_2nn3ndmFv();
if (res != 0) {
DEBUG_FUNCTION_LINE_ERR("SuspendDaemonsAndDisconnectIfWireless__Q2_2nn3ndmFv returned %08X", res);
if (res == 0xA0B12C80 && gForceNDMSuspendSuccess) {
DEBUG_FUNCTION_LINE_INFO("Patch SuspendDaemonsAndDisconnectIfWireless__Q2_2nn3ndmFv to return 0 instead of %08X", res);
return 0;
} else if (gAllowErrorNotifications) {
NotificationModule_SetDefaultValue(NOTIFICATION_MODULE_NOTIFICATION_TYPE_ERROR, NOTIFICATION_MODULE_DEFAULT_OPTION_DURATION_BEFORE_FADE_OUT, 10.0f);
NotificationModule_AddErrorNotification("\"nn::ndm::SuspendDaemonsAndDisconnectIfWireless\" failed. Connection to 3DS not possible");
}
}
return res;
}
DECL_FUNCTION(int32_t, IsStorageMaybePcFormatted, bool *isPcFormatted, nn::spm::StorageIndex *index) { DECL_FUNCTION(int32_t, IsStorageMaybePcFormatted, bool *isPcFormatted, nn::spm::StorageIndex *index) {
// Make sure the index is valid // Make sure the index is valid
int32_t res = real_IsStorageMaybePcFormatted(isPcFormatted, index); int32_t res = real_IsStorageMaybePcFormatted(isPcFormatted, index);
@ -114,3 +132,4 @@ DECL_FUNCTION(bool, MCP_Get4SecondOffStatus, int32_t handle) {
// Only replace for the Wii U Menu // Only replace for the Wii U Menu
WUPS_MUST_REPLACE_FOR_PROCESS(IsStorageMaybePcFormatted, WUPS_LOADER_LIBRARY_NN_SPM, IsStorageMaybePcFormatted__Q2_2nn3spmFPbQ3_2nn3spm12StorageIndex, WUPS_FP_TARGET_PROCESS_WII_U_MENU); WUPS_MUST_REPLACE_FOR_PROCESS(IsStorageMaybePcFormatted, WUPS_LOADER_LIBRARY_NN_SPM, IsStorageMaybePcFormatted__Q2_2nn3spmFPbQ3_2nn3spm12StorageIndex, WUPS_FP_TARGET_PROCESS_WII_U_MENU);
WUPS_MUST_REPLACE_FOR_PROCESS(MCP_Get4SecondOffStatus, WUPS_LOADER_LIBRARY_COREINIT, MCP_Get4SecondOffStatus, WUPS_FP_TARGET_PROCESS_WII_U_MENU); WUPS_MUST_REPLACE_FOR_PROCESS(MCP_Get4SecondOffStatus, WUPS_LOADER_LIBRARY_COREINIT, MCP_Get4SecondOffStatus, WUPS_FP_TARGET_PROCESS_WII_U_MENU);
WUPS_MUST_REPLACE(SuspendDaemonsAndDisconnectIfWireless__Q2_2nn3ndmFv, WUPS_LOADER_LIBRARY_NN_NDM, SuspendDaemonsAndDisconnectIfWireless__Q2_2nn3ndmFv);

View File

@ -4,6 +4,8 @@ bool gActivateUStealth = false;
bool gSkip4SecondOffStatusCheck = true; bool gSkip4SecondOffStatusCheck = true;
bool gConfigMenuHintShown = false; bool gConfigMenuHintShown = false;
bool gUpdateChecked = false; bool gUpdateChecked = false;
bool gForceNDMSuspendSuccess = true;
bool gAllowErrorNotifications = true;
std::string gLastHash = {}; std::string gLastHash = {};
void boolItemChangedConfig(ConfigItemBoolean *item, bool newValue) { void boolItemChangedConfig(ConfigItemBoolean *item, bool newValue) {
@ -11,6 +13,8 @@ void boolItemChangedConfig(ConfigItemBoolean *item, bool newValue) {
if (WUPS_GetSubItem(nullptr, CAT_CONFIG, &cat_config) == WUPS_STORAGE_ERROR_SUCCESS) { if (WUPS_GetSubItem(nullptr, CAT_CONFIG, &cat_config) == WUPS_STORAGE_ERROR_SUCCESS) {
PROCESS_BOOL_ITEM_CHANGED(cat_config, USTEALTH_CONFIG_ID, gActivateUStealth); PROCESS_BOOL_ITEM_CHANGED(cat_config, USTEALTH_CONFIG_ID, gActivateUStealth);
PROCESS_BOOL_ITEM_CHANGED(cat_config, POWEROFFWARNING_CONFIG_ID, gSkip4SecondOffStatusCheck); PROCESS_BOOL_ITEM_CHANGED(cat_config, POWEROFFWARNING_CONFIG_ID, gSkip4SecondOffStatusCheck);
PROCESS_BOOL_ITEM_CHANGED(cat_config, FORCE_NDM_SUSPEND_SUCCESS_CONFIG_ID, gForceNDMSuspendSuccess);
PROCESS_BOOL_ITEM_CHANGED(cat_config, ALLOW_ERROR_NOTIFICATIONS, gAllowErrorNotifications);
} else { } else {
DEBUG_FUNCTION_LINE_ERR("Failed to get sub item: %s", CAT_CONFIG); DEBUG_FUNCTION_LINE_ERR("Failed to get sub item: %s", CAT_CONFIG);
} }
@ -28,10 +32,15 @@ WUPS_GET_CONFIG() {
WUPSConfigCategoryHandle cat; WUPSConfigCategoryHandle cat;
WUPSConfig_AddCategoryByNameHandled(config, "Wii U Menu patches", &cat); WUPSConfig_AddCategoryByNameHandled(config, "Wii U Menu patches", &cat);
WUPSConfigCategoryHandle catOther;
WUPSConfig_AddCategoryByNameHandled(config, "Other patches", &catOther);
WUPSConfigItemBoolean_AddToCategoryHandled(config, cat, USTEALTH_CONFIG_ID, "Avoid \"Format\" dialog on Wii U Menu", gActivateUStealth, &boolItemChangedConfig); WUPSConfigItemBoolean_AddToCategoryHandled(config, cat, USTEALTH_CONFIG_ID, "Avoid \"Format\" dialog on Wii U Menu", gActivateUStealth, &boolItemChangedConfig);
WUPSConfigItemBoolean_AddToCategoryHandled(config, cat, POWEROFFWARNING_CONFIG_ID, "Skip \"Shutdown warning\" on boot", gSkip4SecondOffStatusCheck, &boolItemChangedConfig); WUPSConfigItemBoolean_AddToCategoryHandled(config, cat, POWEROFFWARNING_CONFIG_ID, "Skip \"Shutdown warning\" on boot", gSkip4SecondOffStatusCheck, &boolItemChangedConfig);
WUPSConfigItemBoolean_AddToCategoryHandled(config, catOther, ALLOW_ERROR_NOTIFICATIONS, "Allow error notifications", gAllowErrorNotifications, &boolItemChangedConfig);
WUPSConfigItemBoolean_AddToCategoryHandled(config, catOther, FORCE_NDM_SUSPEND_SUCCESS_CONFIG_ID, "Fix connecting to a 3DS in Mii Maker", gForceNDMSuspendSuccess, &boolItemChangedConfig);
return config; return config;
} }

View File

@ -4,37 +4,38 @@
#include <wups/config/WUPSConfigItemBoolean.h> #include <wups/config/WUPSConfigItemBoolean.h>
#include <wups/storage.h> #include <wups/storage.h>
#define CAT_CONFIG "config"
#define CAT_OTHER "other"
#define CAT_CONFIG "config" #define USTEALTH_CONFIG_ID "ustealth"
#define CAT_OTHER "other" #define POWEROFFWARNING_CONFIG_ID "SkipPowerOffWarning"
#define FORCE_NDM_SUSPEND_SUCCESS_CONFIG_ID "forceNDMSuspendSuccess"
#define USTEALTH_CONFIG_ID "ustealth" #define ALLOW_ERROR_NOTIFICATIONS "allowErrorNotifications"
#define POWEROFFWARNING_CONFIG_ID "SkipPowerOffWarning"
#define CONFIG_MENU_HINT_SHOWN_ID "configMenuHintShown" #define CONFIG_MENU_HINT_SHOWN_ID "configMenuHintShown"
#define LAST_UPDATE_HASH_ID "lastUpdateHash" #define LAST_UPDATE_HASH_ID "lastUpdateHash"
#define LOAD_BOOL_FROM_STORAGE(__cat, config_name, __variable__) \ #define LOAD_BOOL_FROM_STORAGE(__cat, config_name, __variable__) \
if ((storageRes = WUPS_GetBool(__cat, config_name, &__variable__)) == WUPS_STORAGE_ERROR_NOT_FOUND) { \ if ((storageRes = WUPS_GetBool(__cat, config_name, &__variable__)) == WUPS_STORAGE_ERROR_NOT_FOUND) { \
if (WUPS_StoreBool(__cat, config_name, __variable__) != WUPS_STORAGE_ERROR_SUCCESS) { \ if (WUPS_StoreBool(__cat, config_name, __variable__) != WUPS_STORAGE_ERROR_SUCCESS) { \
DEBUG_FUNCTION_LINE_WARN("Failed to store bool"); \ DEBUG_FUNCTION_LINE_WARN("Failed to store bool %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes); \
} \
} else if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) { \
DEBUG_FUNCTION_LINE_WARN("Failed to get bool %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes); \
} \
while (0)
#define LOAD_STRING_FROM_STORAGE(__cat, config_name, __string, __string_length) \
if ((storageRes = WUPS_GetString(__cat, config_name, __string, __string_length)) == WUPS_STORAGE_ERROR_NOT_FOUND) { \
if (WUPS_StoreString(__cat, config_name, __string) != WUPS_STORAGE_ERROR_SUCCESS) { \
DEBUG_FUNCTION_LINE_WARN("Failed to store string"); \
} \ } \
} else if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) { \ } else if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) { \
DEBUG_FUNCTION_LINE_WARN("Failed to get bool %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes); \ DEBUG_FUNCTION_LINE_WARN("Failed to get bool %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes); \
} \ } \
while (0) while (0)
#define LOAD_STRING_FROM_STORAGE(__cat, config_name, __string, __string_length) \
if ((storageRes = WUPS_GetString(__cat, config_name, __string, __string_length)) == WUPS_STORAGE_ERROR_NOT_FOUND) { \
if (WUPS_StoreString(__cat, config_name, __string) != WUPS_STORAGE_ERROR_SUCCESS) { \
DEBUG_FUNCTION_LINE_WARN("Failed to store string %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes); \
} \
} else if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) { \
DEBUG_FUNCTION_LINE_WARN("Failed to get bool %s (%d)", WUPS_GetStorageStatusStr(storageRes), storageRes); \
} \
while (0)
#define PROCESS_BOOL_ITEM_CHANGED(cat, __config__name, __variable__) \ #define PROCESS_BOOL_ITEM_CHANGED(cat, __config__name, __variable__) \
if (std::string_view(item->configId) == __config__name) { \ if (std::string_view(item->configId) == __config__name) { \
DEBUG_FUNCTION_LINE_ERR("New value in %s: %d", __config__name, newValue); \ DEBUG_FUNCTION_LINE_ERR("New value in %s: %d", __config__name, newValue); \
@ -49,3 +50,5 @@ extern bool gSkip4SecondOffStatusCheck;
extern bool gConfigMenuHintShown; extern bool gConfigMenuHintShown;
extern std::string gLastHash; extern std::string gLastHash;
extern bool gUpdateChecked; extern bool gUpdateChecked;
extern bool gForceNDMSuspendSuccess;
extern bool gAllowErrorNotifications;