From 7e86d9ce5f3ed3ec43eb255e0ea3aeb4f914f2fa Mon Sep 17 00:00:00 2001 From: Naim2000 Date: Fri, 3 May 2024 17:18:50 -0500 Subject: [PATCH] disallow uninstalling vWii WADs on Wii --- source/wad.c | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/source/wad.c b/source/wad.c index 5e53fc1..4e8999d 100644 --- a/source/wad.c +++ b/source/wad.c @@ -787,8 +787,8 @@ s32 Wad_Install(FILE *fp) if (tmdIsStubIOS(tmd_data)) { printf("\n Are you sure you wan't to install a stub HBC IOS?\n"); - printf("\n Press A to continue.\n"); - printf(" Press B skip."); + printf("\n Press A to continue."); + printf("\n Press B skip."); u32 buttons = WaitButtons(); @@ -809,8 +809,6 @@ s32 Wad_Install(FILE *fp) goto err; } - - if (tid == TITLE_ID(1, 2)) { if (skipRegionSafetyCheck || gForcedInstall) @@ -1172,8 +1170,9 @@ out: s32 Wad_Uninstall(FILE *fp) { SetPRButtons(false); - wadHeader *header = NULL; - tikview *viewData = NULL; + wadHeader *header = NULL; + tikview *viewData = NULL; + signed_blob *s_tik = NULL; u64 tid; u32 viewCnt; @@ -1192,19 +1191,29 @@ s32 Wad_Uninstall(FILE *fp) if (!__Wad_VerifyHeader(header)) { - puts("Invalid WAD file?"); + puts("\t\tInvalid WAD file?"); ret = ES_EINVAL; goto out; } - /* Get title ID */ - ret = __Wad_GetTitleID(fp, header, &tid); - if (ret < 0) { + /* Get ticket */ + u32 tik_offset = 0; + tik_offset += round_up(header->header_len, 0x40); + tik_offset += round_up(header->certs_len, 0x40); + tik_offset += round_up(header->crl_len, 0x40); + + ret = FSOPReadOpenFileA(fp, (void*)&s_tik, tik_offset, header->tik_len); + if (ret != 1) { printf(" ERROR! (ret = %d)\n", ret); goto out; } + + bool isvWiiTitle = __Wad_FixTicket(s_tik); + tik *ticket = SIGNATURE_PAYLOAD(s_tik); + tid = ticket->titleid; + //Assorted Checks - if (TITLE_UPPER(tid) = 0x1) + if (TITLE_UPPER(tid) == 0x1) { if (!get_title_ios(TITLE_ID(1, 2))) { @@ -1212,6 +1221,17 @@ s32 Wad_Uninstall(FILE *fp) ret = -999; goto out; } + if (isvWiiTitle && !IS_WIIU && !skipRegionSafetyCheck) // Only this way around this time + { + printf("\n" + " Attempting to uninstall a vWii IOS WAD.\n\n" + + " If you're sure about what you're doing, input\n" + " the Konami code on the device screen. Have fun.\n"); + + ret = -990; + goto out; + } if (tid == TITLE_ID(1, 1)) { printf("\n I won't try to uninstall boot2\n");