diff --git a/.gitignore b/.gitignore index 3f9ac48..c753597 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ *.wps certs/ *.lst +inkay_config.local.h diff --git a/common/inkay_config.h b/common/inkay_config.h new file mode 100644 index 0000000..0293c20 --- /dev/null +++ b/common/inkay_config.h @@ -0,0 +1,21 @@ +// +// Created by ash on 17/12/24. +// + +#ifndef INKAY_INKAY_CONFIG_H +#define INKAY_INKAY_CONFIG_H + +#ifdef __has_include +#if __has_include("inkay_config.local.h") + +#include "inkay_config.local.h" +#define INKAY_CUSTOM 1 + +#endif +#endif + +#ifndef NETWORK_BASEURL +#define NETWORK_BASEURL "pretendo.cc" +#endif + +#endif //INKAY_INKAY_CONFIG_H diff --git a/src/patches/account_settings.cpp b/src/patches/account_settings.cpp index 232782f..3a0e7bb 100644 --- a/src/patches/account_settings.cpp +++ b/src/patches/account_settings.cpp @@ -21,6 +21,7 @@ #include "olv_urls.h" #include "utils/logger.h" #include "utils/replace_mem.h" +#include "inkay_config.h" #include #include @@ -36,21 +37,29 @@ #define ACCOUNT_SETTINGS_TID_U 0x000500101004B100 #define ACCOUNT_SETTINGS_TID_E 0x000500101004B200 -const char whitelist_original[] = { - 0x68, 0x74, 0x74, 0x70, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x61, 0x63, 0x63, 0x6F, 0x75, 0x6E, 0x74, 0x2E, - 0x6E, 0x69, 0x6E, 0x74, 0x65, 0x6E, 0x64, 0x6F, 0x2E, 0x6E, 0x65, 0x74 +struct account_settings_allowlist { + char scheme[16]; + char domain[128]; + char path[128]; // unverified + uint32_t flags; }; -const char whitelist_new[] = { - 0x68, 0x74, 0x74, 0x70, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x61, 0x63, 0x63, 0x6F, 0x75, 0x6E, 0x74, 0x2E, - 0x70, 0x72, 0x65, 0x74, 0x65, 0x6E, 0x64, 0x6F, 0x2E, 0x63, 0x63, 0x00 +constexpr struct account_settings_allowlist original_entry = { + .scheme = "https", + .domain = "account.nintendo.net", + .path = "", + .flags = 0x01010101, }; -const char wave_original[] = "saccount.nintendo.net"; +constexpr struct account_settings_allowlist new_entry = { + .scheme = "https", + .domain = "account." NETWORK_BASEURL, + .path = "", + .flags = 0x01010101, +}; +constexpr char wave_original[] = "saccount.nintendo.net"; -const char wave_new[] = "saccount.pretendo.cc"; +constexpr char wave_new[] = "saccount." NETWORK_BASEURL; static bool isAccountSettingsTitle() { return (OSGetTitleID() != 0 && ( @@ -141,12 +150,12 @@ bool hotpatchAccountSettings() { DEBUG_FUNCTION_LINE_VERBOSE("Inkay: hewwo account settings!\n"); if (!replace(0x10000000, 0x10000000, wave_original, sizeof(wave_original), wave_new, sizeof(wave_new))) { - DEBUG_FUNCTION_LINE_VERBOSE("Inkay: We didn't find the url /)>~<(\\"); + DEBUG_FUNCTION_LINE("Inkay: We didn't find the url /)>~<(\\"); return false; } - if (!replace(0x10000000, 0x10000000, whitelist_original, sizeof(whitelist_original), whitelist_new, sizeof(whitelist_new))) { - DEBUG_FUNCTION_LINE_VERBOSE("Inkay: We didn't find the whitelist /)>~<(\\"); + if (!replace(0x10000000, 0x10000000, (const char *)&original_entry, sizeof(original_entry), (const char *)&new_entry, sizeof(new_entry))) { + DEBUG_FUNCTION_LINE("Inkay: We didn't find the whitelist /)>~<(\\"); return false; } diff --git a/src/patches/dns_hooks.cpp b/src/patches/dns_hooks.cpp index d51520b..a4f0840 100644 --- a/src/patches/dns_hooks.cpp +++ b/src/patches/dns_hooks.cpp @@ -17,19 +17,19 @@ #include - #include "config.h" #include "utils/logger.h" +#include "inkay_config.h" #include #include #include std::vector dns_patches; -const std::pair dns_replacements[] = { +constexpr std::pair dns_replacements[] = { // NNCS servers - { "nncs1.app.nintendowifi.net", "nncs1.app.pretendo.cc" }, - { "nncs2.app.nintendowifi.net", "nncs2.app.pretendo.cc" }, + { "nncs1.app.nintendowifi.net", "nncs1.app." NETWORK_BASEURL }, + { "nncs2.app.nintendowifi.net", "nncs2.app." NETWORK_BASEURL }, }; static const char * replace_dns_name(const char *dns_name) { diff --git a/src/patches/eshop_applet.cpp b/src/patches/eshop_applet.cpp index 33467ac..9ae5e2e 100644 --- a/src/patches/eshop_applet.cpp +++ b/src/patches/eshop_applet.cpp @@ -20,6 +20,7 @@ #include "olv_urls.h" #include "utils/logger.h" #include "utils/replace_mem.h" +#include "inkay_config.h" #include #include @@ -30,21 +31,28 @@ #include "ca_pem.h" // generated at buildtime -const char wave_original[] = "https://ninja.wup.shop.nintendo.net/ninja/wood_index.html?"; -const char wave_new[] = "http://samurai.wup.shop.pretendo.cc/ninja/wood_index.html?"; +constexpr char wave_original[] = "https://ninja.wup.shop.nintendo.net/ninja/wood_index.html?"; +constexpr char wave_new[] = "http://samurai.wup.shop." NETWORK_BASEURL "/ninja/wood_index.html?"; -const char whitelist_original[] = { - 0x68, 0x74, 0x74, 0x70, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x73, 0x61, 0x6D, 0x75, 0x72, 0x61, 0x69, 0x2E, - 0x77, 0x75, 0x70, 0x2E, 0x73, 0x68, 0x6F, 0x70, 0x2E, 0x6E, 0x69, 0x6E, - 0x74, 0x65, 0x6E, 0x64, 0x6F, 0x2E, 0x6E, 0x65, 0x74 +struct eshop_allowlist { + char scheme[16]; + char domain[128]; + char path[128]; // unverified + unsigned char flags[5]; }; -const char whitelist_new[] = { - 0x68, 0x74, 0x74, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x73, 0x61, 0x6D, 0x75, 0x72, 0x61, 0x69, 0x2E, - 0x77, 0x75, 0x70, 0x2E, 0x73, 0x68, 0x6F, 0x70, 0x2E, 0x70, 0x72, 0x65, - 0x74, 0x65, 0x6E, 0x64, 0x6F, 0x2E, 0x63, 0x63, 0x00 +constexpr struct eshop_allowlist original_entry = { + .scheme = "https", + .domain = "samurai.wup.shop.nintendo.net", + .path = "", + .flags = {1, 1, 1, 1, 0}, +}; + +constexpr struct eshop_allowlist new_entry = { + .scheme = "http", + .domain = "samurai.wup.shop." NETWORK_BASEURL, + .path = "", + .flags = {1, 1, 1, 1, 0}, }; static std::optional rootca_pem_handle{}; @@ -68,7 +76,7 @@ DECL_FUNCTION(int, FSOpenFile_eShop, FSClient *client, FSCmdBlock *block, char * if (!replace(0x10000000, 0x10000000, wave_original, sizeof(wave_original), wave_new, sizeof(wave_new))) DEBUG_FUNCTION_LINE_VERBOSE("Inkay: We didn't find the url /)>~<(\\"); - if (!replace(0x10000000, 0x10000000, whitelist_original, sizeof(whitelist_original), whitelist_new, sizeof(whitelist_new))) + if (!replace(0x10000000, 0x10000000, (const char *)&original_entry, sizeof(original_entry), (const char *)&new_entry, sizeof(new_entry))) DEBUG_FUNCTION_LINE_VERBOSE("Inkay: We didn't find the whitelist /)>~<(\\"); // Check for root CA file and take note of its handle diff --git a/src/patches/olv_applet.cpp b/src/patches/olv_applet.cpp index 256b3fd..8f97a79 100644 --- a/src/patches/olv_applet.cpp +++ b/src/patches/olv_applet.cpp @@ -30,16 +30,27 @@ #include "ca_pem.h" // generated at buildtime -const char wave_original[] = { - 0x68, 0x74, 0x74, 0x70, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x2E, 0x6E, 0x69, 0x6E, 0x74, 0x65, 0x6E, 0x64, - 0x6F, 0x2E, 0x6E, 0x65, 0x74 +struct olv_allowlist { + char scheme[16]; + char domain[128]; + char path[128]; // unverified + unsigned char flags[5]; }; -const char wave_new[] = { - 0x68, 0x74, 0x74, 0x70, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x2E, 0x70, 0x72, 0x65, 0x74, 0x65, 0x6E, 0x64, - 0x6F, 0x2E, 0x63, 0x63, 0x00 + +constexpr struct olv_allowlist original_entry = { + .scheme = "https", + .domain = ".nintendo.net", + .path = "", + .flags = {1, 1, 1, 1, 1}, +}; + +constexpr struct olv_allowlist new_entry = { + .scheme = "https", + .domain = "." NETWORK_BASEURL, + .path = "", + .flags = {1, 1, 1, 1, 1}, }; + const unsigned char miiverse_green_highlight[] = { 0x82, 0xff, 0x05, 0xff, 0x82, 0xff, 0x05, 0xff, 0x1d, 0xff, 0x04, 0xff, 0x1d, 0xff, 0x04, 0xff }; @@ -87,7 +98,7 @@ DECL_FUNCTION(int, FSOpenFile, FSClient *client, FSCmdBlock *block, char *path, auto olv_ok = setup_olv_libs(); // Patch applet binary too if (olv_ok) - replace(0x10000000, 0x10000000, wave_original, sizeof(wave_original), wave_new, sizeof(wave_new)); + replace(0x10000000, 0x10000000, (const char *)&original_entry, sizeof(original_entry), (const char *)&new_entry, sizeof(new_entry)); // Check for root CA file and take note of its handle } else if (strcmp("vol/content/browser/rootca.pem", path) == 0) { int ret = real_FSOpenFile(client, block, path, mode, handle, error); diff --git a/src/patches/olv_urls.h b/src/patches/olv_urls.h index 3224b0e..323498f 100644 --- a/src/patches/olv_urls.h +++ b/src/patches/olv_urls.h @@ -15,9 +15,10 @@ #pragma once #include +#include "inkay_config.h" -const char original_url[] = "discovery.olv.nintendo.net/v1/endpoint"; -const char new_url[] = "discovery.olv.pretendo.cc/v1/endpoint"; +constexpr char original_url[] = "discovery.olv.nintendo.net/v1/endpoint"; +constexpr char new_url[] = "discovery.olv." NETWORK_BASEURL "/v1/endpoint"; _Static_assert(sizeof(original_url) > sizeof(new_url), "new_url too long! Must be less than 38chars.");