disallow uninstalling vWii WADs on Wii

This commit is contained in:
Naim2000 2024-05-03 17:18:50 -05:00
parent 4875edf350
commit 7e86d9ce5f

View File

@ -787,8 +787,8 @@ s32 Wad_Install(FILE *fp)
if (tmdIsStubIOS(tmd_data)) if (tmdIsStubIOS(tmd_data))
{ {
printf("\n Are you sure you wan't to install a stub HBC IOS?\n"); printf("\n Are you sure you wan't to install a stub HBC IOS?\n");
printf("\n Press A to continue.\n"); printf("\n Press A to continue.");
printf(" Press B skip."); printf("\n Press B skip.");
u32 buttons = WaitButtons(); u32 buttons = WaitButtons();
@ -809,8 +809,6 @@ s32 Wad_Install(FILE *fp)
goto err; goto err;
} }
if (tid == TITLE_ID(1, 2)) if (tid == TITLE_ID(1, 2))
{ {
if (skipRegionSafetyCheck || gForcedInstall) if (skipRegionSafetyCheck || gForcedInstall)
@ -1172,8 +1170,9 @@ out:
s32 Wad_Uninstall(FILE *fp) s32 Wad_Uninstall(FILE *fp)
{ {
SetPRButtons(false); SetPRButtons(false);
wadHeader *header = NULL; wadHeader *header = NULL;
tikview *viewData = NULL; tikview *viewData = NULL;
signed_blob *s_tik = NULL;
u64 tid; u64 tid;
u32 viewCnt; u32 viewCnt;
@ -1192,19 +1191,29 @@ s32 Wad_Uninstall(FILE *fp)
if (!__Wad_VerifyHeader(header)) if (!__Wad_VerifyHeader(header))
{ {
puts("Invalid WAD file?"); puts("\t\tInvalid WAD file?");
ret = ES_EINVAL; ret = ES_EINVAL;
goto out; goto out;
} }
/* Get title ID */ /* Get ticket */
ret = __Wad_GetTitleID(fp, header, &tid); u32 tik_offset = 0;
if (ret < 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); printf(" ERROR! (ret = %d)\n", ret);
goto out; goto out;
} }
bool isvWiiTitle = __Wad_FixTicket(s_tik);
tik *ticket = SIGNATURE_PAYLOAD(s_tik);
tid = ticket->titleid;
//Assorted Checks //Assorted Checks
if (TITLE_UPPER(tid) = 0x1) if (TITLE_UPPER(tid) == 0x1)
{ {
if (!get_title_ios(TITLE_ID(1, 2))) if (!get_title_ios(TITLE_ID(1, 2)))
{ {
@ -1212,6 +1221,17 @@ s32 Wad_Uninstall(FILE *fp)
ret = -999; ret = -999;
goto out; 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)) if (tid == TITLE_ID(1, 1))
{ {
printf("\n I won't try to uninstall boot2\n"); printf("\n I won't try to uninstall boot2\n");