From b14ccf2037814e98e6bf4c6e809449ec079e1bf1 Mon Sep 17 00:00:00 2001 From: Pablo Curiel Date: Fri, 3 Nov 2023 19:03:50 +0100 Subject: [PATCH] poc: display a warning if a titlekey can't be located after starting a NSP dump. Also, what the heck was I thinking last night with that NcmContentMetaType_Patch...? I'm degenerating. --- .github/workflows/rewrite.yml | 3 +-- code_templates/nxdt_rw_poc.c | 41 +++++++++++++++++++++++------------ 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/.github/workflows/rewrite.yml b/.github/workflows/rewrite.yml index 12d0db8..d2656e0 100644 --- a/.github/workflows/rewrite.yml +++ b/.github/workflows/rewrite.yml @@ -94,10 +94,9 @@ jobs: - name: Upload artifact to prerelease uses: ncipollo/release-action@v1 with: - # Only update attachments on "rewrite-prerelease" tag. Make sure to update the commit referenced by the tag as well by using the branch name. + # Only update attachments on "rewrite-prerelease" tag. prerelease: True tag: "rewrite-prerelease" - commit: "rewrite" updateOnlyUnreleased: True # Remove old artifacts and replace with new ones. removeArtifacts: True diff --git a/code_templates/nxdt_rw_poc.c b/code_templates/nxdt_rw_poc.c index 7f0ff52..2959f85 100644 --- a/code_templates/nxdt_rw_poc.c +++ b/code_templates/nxdt_rw_poc.c @@ -140,7 +140,7 @@ typedef struct { static void utilsScanPads(void); static u64 utilsGetButtonsDown(void); static u64 utilsGetButtonsHeld(void); -static void utilsWaitForButtonPress(u64 flag); +static u64 utilsWaitForButtonPress(u64 flag); static void consolePrint(const char *text, ...); static void consolePrintReversedColors(const char *text, ...); @@ -1420,7 +1420,7 @@ static u64 utilsGetButtonsHeld(void) return padGetButtons(&g_padState); } -static void utilsWaitForButtonPress(u64 flag) +static u64 utilsWaitForButtonPress(u64 flag) { /* Don't consider stick movement as button inputs. */ if (!flag) flag = ~(HidNpadButton_StickLLeft | HidNpadButton_StickLRight | HidNpadButton_StickLUp | HidNpadButton_StickLDown | HidNpadButton_StickRLeft | HidNpadButton_StickRRight | \ @@ -1428,12 +1428,16 @@ static void utilsWaitForButtonPress(u64 flag) consoleRefresh(); + u64 btn_down = 0; + while(appletMainLoop()) { utilsScanPads(); - if (utilsGetButtonsDown() & flag) break; + if ((btn_down = utilsGetButtonsDown()) & flag) break; utilsAppletLoopDelay(); } + + return btn_down; } static void consolePrint(const char *text, ...) @@ -3214,12 +3218,6 @@ static bool saveNintendoContentArchiveFsSection(void *userdata) /* Use a matching NCA FS section entry. */ base_patch_nca_fs_ctx = &(base_patch_nca_ctx->fs_ctx[nca_fs_ctx->section_idx]); - } else - if (title_type != NcmContentMetaType_Patch) - { - /* Handles edge cases where a specific NCA from an update has no matching equivalent by type/ID offset in its base title (e.g. Fall Guys' HtmlDocument NCA). */ - consolePrint("unable to find content with type %s and id offset %u in selected base/patch title!\n", titleGetNcmContentTypeName(content_type), nca_ctx->id_offset); - goto end; } if (section_type == NcaFsSectionType_PartitionFs) @@ -4785,7 +4783,7 @@ static void nspThreadFunc(void *arg) bool patch_video_capture = (bool)getNspEnableVideoCaptureOption(); bool patch_hdcp = (bool)getNspDisableHdcpOption(); bool generate_authoringtool_data = (bool)getNspGenerateAuthoringToolDataOption(); - bool success = false; + bool success = false, no_titlekey_confirmation = false; u64 free_space = 0; u32 dev_idx = g_storageMenuElementOption.selected; @@ -4924,11 +4922,26 @@ static void nspThreadFunc(void *arg) consolePrint("%s #%u initialize nca ctx succeeded\n", titleGetNcmContentTypeName(content_info->content_type), content_info->id_offset); // don't go any further with this nca if we can't access its fs data because it's pointless - // TODO: add preload warning - if (cur_nca_ctx->rights_id_available && !cur_nca_ctx->titlekey_retrieved) + if (cur_nca_ctx->rights_id_available && !cur_nca_ctx->titlekey_retrieved && !no_titlekey_confirmation) { - j++; - continue; + consolePrintReversedColors("\nunable to retrieve titlekey for the selected title"); + consolePrintReversedColors("\nif you proceed, nca modifications will be disabled, and content decryption"); + consolePrintReversedColors("\nwill not be possible for external tools (e.g. emulators, etc.)\n"); + + consolePrintReversedColors("\nif this is a shared game and you wish to fix this, exit the application and"); + consolePrintReversedColors("\ntry running it at least once, then come back and try again\n"); + + consolePrintReversedColors("\npress a to proceed anyway, or b to cancel\n\n"); + + u64 btn_down = utilsWaitForButtonPress(HidNpadButton_A | HidNpadButton_B); + if (btn_down & HidNpadButton_A) + { + j++; + no_titlekey_confirmation = true; + continue; + } + + goto end; } // set download distribution type