From 5a4bbc98007be983d27d0818bb7b5c77c64b6d41 Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Sun, 8 May 2022 17:52:17 +0100 Subject: [PATCH] Add Konami code to skip certain wad safety checks, so region changing is possible --- source/menu.c | 22 +++++++++++++++++++++- source/wad.c | 12 ++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/source/menu.c b/source/menu.c index 168c3b2..dd2a44b 100644 --- a/source/menu.c +++ b/source/menu.c @@ -322,6 +322,12 @@ void Menu_FatDevice(void) //Fat_Unmount(fdev); //if (((fdevList[selected].mount[0] == 's') && (ndev->name[0] == 'S'))) //selected++; + static const u16 konamiCode[] = { + WPAD_BUTTON_UP, WPAD_BUTTON_UP, WPAD_BUTTON_DOWN, WPAD_BUTTON_DOWN, WPAD_BUTTON_LEFT, + WPAD_BUTTON_RIGHT, WPAD_BUTTON_LEFT, WPAD_BUTTON_RIGHT, WPAD_BUTTON_B, WPAD_BUTTON_A + }; + + int codePosition = 0; /* Select source device */ if (gConfig.fatDeviceIndex < 0) @@ -342,6 +348,13 @@ void Menu_FatDevice(void) u32 buttons = WaitButtons(); + if (buttons & (WPAD_BUTTON_UP | WPAD_BUTTON_DOWN | WPAD_BUTTON_RIGHT | WPAD_BUTTON_LEFT | WPAD_BUTTON_A | WPAD_BUTTON_B)) { + if (buttons & konamiCode[codePosition]) + ++codePosition; + else + codePosition = 0; + } + /* LEFT/RIGHT buttons */ if (buttons & WPAD_BUTTON_LEFT) { if ((--selected) <= -1) @@ -367,8 +380,15 @@ void Menu_FatDevice(void) Restart(); /* A button */ - if (buttons & WPAD_BUTTON_A) + if (buttons & WPAD_BUTTON_A) { + if (codePosition == sizeof(konamiCode) / sizeof(konamiCode[0])) { + extern bool skipRegionSafetyCheck; + skipRegionSafetyCheck = true; + printf("[+] Disabled SM region checks\n"); + sleep(2); + } break; + } } } else diff --git a/source/wad.c b/source/wad.c index 639bddf..deb5b2a 100644 --- a/source/wad.c +++ b/source/wad.c @@ -257,6 +257,11 @@ void __Wad_FixTicket(signed_blob *p_tik) Title_FakesignTik(p_tik); } +// Some of the safety checks can block region changing +// Entering the Konami code turns this true, so it will +// skip the problematic checks for region changing. +bool skipRegionSafetyCheck = false; + s32 Wad_Install(FILE *fp) { wadHeader *header = NULL; @@ -287,7 +292,7 @@ s32 Wad_Install(FILE *fp) goto out; } - /* WAD certificates */ + /* WAD certificates */ ret = __Wad_ReadAlloc(fp, (void *)&p_certs, offset, header->certs_len); if (ret >= 0) offset += round_up(header->certs_len, 64); @@ -379,6 +384,8 @@ s32 Wad_Install(FILE *fp) if (tid == TITLE_ID(1, 2)) { + if (skipRegionSafetyCheck) goto skipChecks; + if(get_sm_region_basic() == 0) { printf("\n Can't get the SM region\n Please check the site for updates\n"); @@ -400,12 +407,13 @@ s32 Wad_Install(FILE *fp) ret = -999; goto err; } - if( get_sm_region_basic() != regionlist[i].region) + if(get_sm_region_basic() != regionlist[i].region) { printf("\n I won't install the wrong regions SM\n"); ret = -999; goto err; } +skipChecks: if(tmd_data->title_version < 416) { if(boot2version == 4)