diff --git a/src/Notification.cpp b/src/Notification.cpp index 6fb1a99..43f08df 100644 --- a/src/Notification.cpp +++ b/src/Notification.cpp @@ -24,7 +24,7 @@ void ShowNotification(std::string_view notification) { auto err2 = NotificationModule_SetDefaultValue(NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO, NOTIFICATION_MODULE_DEFAULT_OPTION_DURATION_BEFORE_FADE_OUT, 15.0f); - + if (err1 != NOTIFICATION_MODULE_RESULT_SUCCESS || err2 != NOTIFICATION_MODULE_RESULT_SUCCESS) return; NotificationModule_AddInfoNotification(notification.data()); diff --git a/src/config.cpp b/src/config.cpp index 56c2a1d..80485e3 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -170,7 +170,7 @@ static WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHa try { auto patching_cat = WUPSConfigCategory::Create(strings.network_category); - + // config id display name default current value changed callback patching_cat.add(WUPSConfigItemBoolean::Create("connect_to_network", strings.connect_to_network_setting, true, Config::connect_to_network, &connect_to_network_changed)); root.add(std::move(patching_cat)); @@ -240,17 +240,17 @@ void Config::Init() { // Try to get value from storage if ((storageRes = WUPSStorageAPI::Get("connect_to_network", Config::connect_to_network)) == WUPS_STORAGE_ERROR_NOT_FOUND) { DEBUG_FUNCTION_LINE("Connect to network value not found, attempting to migrate/create"); - + bool skipPatches = false; if (WUPSStorageAPI::Get("skipPatches", skipPatches) == WUPS_STORAGE_ERROR_SUCCESS) { // Migrate old config value Config::connect_to_network = !skipPatches; WUPSStorageAPI::DeleteItem("skipPatches"); } - + // Add the value to the storage if it's missing. if (WUPSStorageAPI::Store("connect_to_network", connect_to_network) != WUPS_STORAGE_ERROR_SUCCESS) { - DEBUG_FUNCTION_LINE("Failed to store bool"); + DEBUG_FUNCTION_LINE("Failed to store bool"); } } else if (storageRes != WUPS_STORAGE_ERROR_SUCCESS) { @@ -261,4 +261,4 @@ void Config::Init() { if (WUPSStorageAPI::SaveStorage() != WUPS_STORAGE_ERROR_SUCCESS) { DEBUG_FUNCTION_LINE("Failed to save storage"); } -} \ No newline at end of file +} diff --git a/src/config.h b/src/config.h index f9401ad..a83e178 100644 --- a/src/config.h +++ b/src/config.h @@ -14,7 +14,7 @@ public: // private stuff static bool need_relaunch; - + // private stuff static bool is_wiiu_menu; @@ -22,14 +22,14 @@ public: }; struct config_strings { - const char* plugin_name; - const char* network_category; - const char* connect_to_network_setting; - const char* other_category; - const char* reset_wwp_setting; - const char* press_a_action; - const char* restart_to_apply_action; - const char* need_menu_action; + const char *plugin_name; + const char *network_category; + const char *connect_to_network_setting; + const char *other_category; + const char *reset_wwp_setting; + const char *press_a_action; + const char *restart_to_apply_action; + const char *need_menu_action; }; #endif //INKAY_CONFIG_H diff --git a/src/iosu_url_patches.h b/src/iosu_url_patches.h index 2a726a0..b500fc6 100644 --- a/src/iosu_url_patches.h +++ b/src/iosu_url_patches.h @@ -1,8 +1,7 @@ #ifndef _PATCHER_H #define _PATCHER_H -typedef struct URL_Patch -{ +typedef struct URL_Patch { unsigned int address; char url[80]; } URL_Patch; @@ -36,7 +35,7 @@ static const URL_Patch url_patches[] = { {0xE22B3FFC, "https://nus.c.shop.pretendo.cc/nus/services/NetUpdateSOAP"}, {0xE229DE0C, "n.app.pretendo.cc"}, //nim-boss .bss - {0xE24B8A24, "https://nppl.app.pretendo.cc/p01/policylist/1/1/UNK"}, + {0xE24B8A24, "https://nppl.app.pretendo.cc/p01/policylist/1/1/UNK"}, {0xE31930D4, "https://%s%saccount.pretendo.cc/v%u/api/"} }; diff --git a/src/main.cpp b/src/main.cpp index 61582dd..445f095 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -62,6 +62,7 @@ WUPS_PLUGIN_AUTHOR("Pretendo contributors"); WUPS_PLUGIN_LICENSE("ISC"); WUPS_USE_STORAGE("inkay"); + WUPS_USE_WUT_DEVOPTAB(); #include @@ -71,25 +72,24 @@ WUPS_USE_WUT_DEVOPTAB(); #include "utils/sysconfig.h" //thanks @Gary#4139 :p -static void write_string(uint32_t addr, const char* str) -{ +static void write_string(uint32_t addr, const char *str) { int len = strlen(str) + 1; int remaining = len % 4; int num = len - remaining; for (int i = 0; i < (num / 4); i++) { - Mocha_IOSUKernelWrite32(addr + i * 4, *(uint32_t*)(str + i * 4)); + Mocha_IOSUKernelWrite32(addr + i * 4, *(uint32_t * )(str + i * 4)); } if (remaining > 0) { uint8_t buf[4]; - Mocha_IOSUKernelRead32(addr + num, (uint32_t*)&buf); + Mocha_IOSUKernelRead32(addr + num, (uint32_t * ) & buf); for (int i = 0; i < remaining; i++) { buf[i] = *(str + num + i); } - Mocha_IOSUKernelWrite32(addr + num, *(uint32_t*)&buf); + Mocha_IOSUKernelWrite32(addr + num, *(uint32_t * ) & buf); } } @@ -97,7 +97,7 @@ static bool is555(MCPSystemVersion version) { return (version.major == 5) && (version.minor == 5) && (version.patch >= 5); } -static const char * get_nintendo_network_message() { +static const char *get_nintendo_network_message() { // TL note: "Nintendo Network" is a proper noun - "Network" is part of the name // TL note: "Using" instead of "Connected" is deliberate - we don't know if a successful connection exists, we are // only specifying what we'll *attempt* to connect to @@ -109,13 +109,14 @@ static const char * get_nintendo_network_message() { return "Usando Nintendo Network"; case nn::swkbd::LanguageType::French: return "Sur Nintendo Network"; - case nn::swkbd::LanguageType::Italian: + case nn::swkbd::LanguageType::Italian: return "Usando Nintendo Network"; case nn::swkbd::LanguageType::German: return "Nutze Nintendo Network"; } } -static const char * get_pretendo_message() { + +static const char *get_pretendo_message() { // TL note: "Pretendo Network" is also a proper noun - though "Pretendo" alone can refer to us as a project // TL note: "Using" instead of "Connected" is deliberate - we don't know if a successful connection exists, we are // only specifying what we'll *attempt* to connect to @@ -135,7 +136,7 @@ static const char * get_pretendo_message() { } INITIALIZE_PLUGIN() { - WHBLogCafeInit(); + WHBLogCafeInit(); WHBLogUdpInit(); Config::Init(); @@ -162,29 +163,27 @@ INITIALIZE_PLUGIN() { }; } DEBUG_FUNCTION_LINE_VERBOSE("Running on %d.%d.%d%c", - os_version.major, os_version.minor, os_version.patch, os_version.region + os_version.major, os_version.minor, os_version.patch, os_version.region ); - // if using pretendo then (try to) apply the ssl patches + // if using pretendo then (try to) apply the ssl patches if (Config::connect_to_network) { if (is555(os_version)) { Mocha_IOSUKernelWrite32(0xE1019F78, 0xE3A00001); // mov r0, #1 - } - else { + } else { Mocha_IOSUKernelWrite32(0xE1019E84, 0xE3A00001); // mov r0, #1 } - for (const auto& patch : url_patches) { + for (const auto &patch: url_patches) { write_string(patch.address, patch.url); } DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches applied successfully."); - - ShowNotification(get_pretendo_message()); - } - else { + + ShowNotification(get_pretendo_message()); + } else { DEBUG_FUNCTION_LINE_VERBOSE("Pretendo URL and NoSSL patches skipped."); - - ShowNotification(get_nintendo_network_message()); + + ShowNotification(get_nintendo_network_message()); } MCP_Close(mcp); @@ -200,8 +199,8 @@ DEINITIALIZE_PLUGIN() { Mocha_DeInitLibrary(); NotificationModule_DeInitLibrary(); FunctionPatcher_DeInitLibrary(); - - WHBLogCafeDeinit(); + + WHBLogCafeDeinit(); WHBLogUdpDeinit(); } @@ -214,6 +213,5 @@ ON_APPLICATION_START() { } ON_APPLICATION_ENDS() { - // commented because it doesnt really unload inkay - //DEBUG_FUNCTION_LINE_VERBOSE("Unloading Inkay...\n"); + } diff --git a/src/utils/replace_mem.cpp b/src/utils/replace_mem.cpp index d388231..a588417 100644 --- a/src/utils/replace_mem.cpp +++ b/src/utils/replace_mem.cpp @@ -23,13 +23,14 @@ #include #include -bool replace(uint32_t start, uint32_t size, const char* original_val, size_t original_val_sz, const char* new_val, size_t new_val_sz) { +bool replace(uint32_t start, uint32_t size, const char *original_val, size_t original_val_sz, const char *new_val, + size_t new_val_sz) { for (uint32_t addr = start; addr < start + size - original_val_sz; addr++) { - int ret = memcmp(original_val, (void*)addr, original_val_sz); + int ret = memcmp(original_val, (void *) addr, original_val_sz); if (ret == 0) { - DEBUG_FUNCTION_LINE_VERBOSE("found str @%08x: %s", addr, (const char*)addr); - KernelCopyData(OSEffectiveToPhysical(addr), OSEffectiveToPhysical((uint32_t)new_val), new_val_sz); - DEBUG_FUNCTION_LINE_VERBOSE("new str @%08x: %s", addr, (const char*)addr); + DEBUG_FUNCTION_LINE_VERBOSE("found str @%08x: %s", addr, (const char *) addr); + KernelCopyData(OSEffectiveToPhysical(addr), OSEffectiveToPhysical((uint32_t) new_val), new_val_sz); + DEBUG_FUNCTION_LINE_VERBOSE("new str @%08x: %s", addr, (const char *) addr); return true; } } @@ -39,24 +40,24 @@ bool replace(uint32_t start, uint32_t size, const char* original_val, size_t ori void replaceBulk(uint32_t start, uint32_t size, std::span replacements) { // work out the biggest input replacement - auto max_sz = std::max_element(replacements.begin(), replacements.end(), [](auto& a, auto& b) { + auto max_sz = std::max_element(replacements.begin(), replacements.end(), [](auto &a, auto &b) { return a.orig.size_bytes() < b.orig.size_bytes(); })->orig.size_bytes(); int counts[replacements.size()]; - for (auto& c : counts) { + for (auto &c: counts) { c = 0; } for (uint32_t addr = start; addr < start + size - max_sz; addr++) { - for (int i = 0; i < (int)replacements.size(); i++) { - const auto& replacement = replacements[i]; + for (int i = 0; i < (int) replacements.size(); i++) { + const auto &replacement = replacements[i]; - int ret = memcmp((void*)addr, replacement.orig.data(), replacement.orig.size_bytes()); + int ret = memcmp((void *) addr, replacement.orig.data(), replacement.orig.size_bytes()); if (ret == 0) { KernelCopyData( OSEffectiveToPhysical(addr), - OSEffectiveToPhysical((uint32_t)replacement.repl.data()), + OSEffectiveToPhysical((uint32_t) replacement.repl.data()), replacement.repl.size_bytes() ); counts[i]++; @@ -64,7 +65,7 @@ void replaceBulk(uint32_t start, uint32_t size, std::span rep } } } - for (auto c : counts) { + for (auto c: counts) { DEBUG_FUNCTION_LINE("replaced %d times", c); } } diff --git a/src/utils/replace_mem.h b/src/utils/replace_mem.h index 860788a..377f2ac 100644 --- a/src/utils/replace_mem.h +++ b/src/utils/replace_mem.h @@ -18,7 +18,8 @@ #include #include -bool replace(uint32_t start, uint32_t size, const char* original_val, size_t original_val_sz, const char* new_val, size_t new_val_sz); +bool replace(uint32_t start, uint32_t size, const char *original_val, size_t original_val_sz, const char *new_val, + size_t new_val_sz); struct replacement { std::span orig; diff --git a/src/utils/sysconfig.cpp b/src/utils/sysconfig.cpp index aca85bc..cef6d78 100644 --- a/src/utils/sysconfig.cpp +++ b/src/utils/sysconfig.cpp @@ -24,7 +24,7 @@ #include nn::swkbd::LanguageType get_system_language() { - static std::optional cached_language{}; + static std::optional cached_language{}; if (cached_language) return *cached_language; UCHandle handle = UCOpen(); diff --git a/src/wut_extra.h b/src/wut_extra.h index f517d03..b6a65c3 100644 --- a/src/wut_extra.h +++ b/src/wut_extra.h @@ -11,13 +11,13 @@ extern "C" { namespace nn::boss { class Task { - public: - nn::act::PersistentId persistentId; - uint32_t unk1; - char task_name[8]; - uint64_t title_id; - uint32_t unk2; - uint32_t unk3; + public: + nn::act::PersistentId persistentId; + uint32_t unk1; + char task_name[8]; + uint64_t title_id; + uint32_t unk2; + uint32_t unk3; }; static_assert(sizeof(Task) == 32, "nn::boss::Task must be 32 bytes."); @@ -26,15 +26,15 @@ namespace nn::boss { extern "C" uint32_t Initialize__Q2_2nn4bossFv(); extern "C" uint32_t Finalize__Q2_2nn4bossFv(); -extern "C" void __ct__Q3_2nn4boss4TaskFv(nn::boss::Task* task); -extern "C" uint32_t Initialize__Q3_2nn4boss4TaskFPCcUi(nn::boss::Task* task, char const *, unsigned int); -extern "C" uint32_t Unregister__Q3_2nn4boss4TaskFv(nn::boss::Task* task); -extern "C" void __dt__Q3_2nn4boss4TaskFv(nn::boss::Task* task); -extern "C" uint32_t StartScheduling__Q3_2nn4boss4TaskFb(nn::boss::Task* task, bool queueTaskOnCall); -extern "C" uint32_t GetState__Q3_2nn4boss4TaskCFPUi(nn::boss::Task* task, uint32_t *outExecCount); -extern "C" uint32_t Run__Q3_2nn4boss4TaskFb(nn::boss::Task* task, bool unk); -extern "C" uint32_t UpdateIntervalSec__Q3_2nn4boss4TaskFUi(nn::boss::Task* task, uint32_t seconds); -extern "C" bool IsRegistered__Q3_2nn4boss4TaskCFv(nn::boss::Task* task); +extern "C" void __ct__Q3_2nn4boss4TaskFv(nn::boss::Task *task); +extern "C" uint32_t Initialize__Q3_2nn4boss4TaskFPCcUi(nn::boss::Task *task, char const *, unsigned int); +extern "C" uint32_t Unregister__Q3_2nn4boss4TaskFv(nn::boss::Task *task); +extern "C" void __dt__Q3_2nn4boss4TaskFv(nn::boss::Task *task); +extern "C" uint32_t StartScheduling__Q3_2nn4boss4TaskFb(nn::boss::Task *task, bool queueTaskOnCall); +extern "C" uint32_t GetState__Q3_2nn4boss4TaskCFPUi(nn::boss::Task *task, uint32_t *outExecCount); +extern "C" uint32_t Run__Q3_2nn4boss4TaskFb(nn::boss::Task *task, bool unk); +extern "C" uint32_t UpdateIntervalSec__Q3_2nn4boss4TaskFUi(nn::boss::Task *task, uint32_t seconds); +extern "C" bool IsRegistered__Q3_2nn4boss4TaskCFv(nn::boss::Task *task); #ifdef __cplusplus }