Skip to content

Commit

Permalink
feat: Move all URL defines into a central location
Browse files Browse the repository at this point in the history
  • Loading branch information
ashquarky committed Dec 17, 2024
1 parent 38f1b18 commit 9e376f7
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 41 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
*.wps
certs/
*.lst
inkay_config.local.h
21 changes: 21 additions & 0 deletions common/inkay_config.h
Original file line number Diff line number Diff line change
@@ -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
35 changes: 22 additions & 13 deletions src/patches/account_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "olv_urls.h"
#include "utils/logger.h"
#include "utils/replace_mem.h"
#include "inkay_config.h"

#include <function_patcher/function_patching.h>
#include <vector>
Expand All @@ -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 && (
Expand Down Expand Up @@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions src/patches/dns_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@

#include <netdb.h>


#include "config.h"
#include "utils/logger.h"
#include "inkay_config.h"
#include <array>
#include <vector>
#include <function_patcher/function_patching.h>

std::vector<PatchedFunctionHandle> dns_patches;

const std::pair<const char *, const char *> dns_replacements[] = {
constexpr std::pair<const char *, const char *> 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) {
Expand Down
34 changes: 21 additions & 13 deletions src/patches/eshop_applet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "olv_urls.h"
#include "utils/logger.h"
#include "utils/replace_mem.h"
#include "inkay_config.h"

#include <vector>
#include <function_patcher/function_patching.h>
Expand All @@ -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<FSFileHandle> rootca_pem_handle{};
Expand All @@ -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
Expand Down
29 changes: 20 additions & 9 deletions src/patches/olv_applet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/patches/olv_urls.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
#pragma once

#include <cstdlib>
#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.");
Expand Down

0 comments on commit 9e376f7

Please sign in to comment.