diff --git a/code_templates/nsp_dumper.c b/code_templates/nsp_dumper.c index 70ce115..b37868a 100644 --- a/code_templates/nsp_dumper.c +++ b/code_templates/nsp_dumper.c @@ -118,6 +118,7 @@ static void consolePrint(const char *text, ...) static void consoleRefresh(void) { mutexLock(&g_conMutex); + fflush(stdout); consoleUpdate(NULL); mutexUnlock(&g_conMutex); } @@ -405,6 +406,8 @@ static void dump_thread_func(void *arg) j++; } + consoleRefresh(); + // generate cnmt xml right away even though we don't yet have all the data we need // This is because we need its size to calculate the full nsp size if (append_authoringtool_data && !cnmtGenerateAuthoringToolXml(&cnmt_ctx, nca_ctx, title_info->content_count)) @@ -545,6 +548,7 @@ static void dump_thread_func(void *arg) nsp_size = (nsp_header_size + pfs_file_ctx.fs_size); consolePrint("nsp header size: 0x%lX | nsp size: 0x%lX\n", nsp_header_size, nsp_size); + consoleRefresh(); if (output_device != 1) { @@ -586,6 +590,7 @@ static void dump_thread_func(void *arg) } consolePrint("dump process started, please wait. hold b to cancel.\n"); + consoleRefresh(); nsp_offset += nsp_header_size; @@ -1010,6 +1015,8 @@ static void nspDump(TitleInfo *title_info) } } + consoleRefresh(); + // create dump thread shared_data.data = title_info; utilsCreateThread(&dump_thread, dump_thread_func, &shared_data, 2); diff --git a/include/core/nxdt_includes.h b/include/core/nxdt_includes.h index 623e6de..088c99c 100644 --- a/include/core/nxdt_includes.h +++ b/include/core/nxdt_includes.h @@ -37,6 +37,7 @@ #include #include #include +#include #include #include diff --git a/include/defines.h b/include/defines.h index e496fa1..3c8c35e 100644 --- a/include/defines.h +++ b/include/defines.h @@ -30,9 +30,6 @@ #define MAX_ELEMENTS(x) ((sizeof((x))) / (sizeof((x)[0]))) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define MAX(a, b) ((a) > (b) ? (a) : (b)) - #define BIT_LONG(n) (1UL << (n)) #define ALIGN_UP(x, y) (((x) + ((y) - 1)) & ~((y) - 1)) diff --git a/source/core/nca.c b/source/core/nca.c index 2dfb4a7..87af7e9 100644 --- a/source/core/nca.c +++ b/source/core/nca.c @@ -852,7 +852,7 @@ static bool ncaInitializeFsSectionContext(NcaContext *nca_ctx, u32 section_idx) if (!raw_storage_size || !sparse_bucket->header.entry_count) { /* Return true but don't set this FS section as enabled, since we can't really use it. */ - LOG_MSG_ERROR("Empty SparseInfo data detected for FS section #%u in \"%s\". Skipping FS section.", section_idx, nca_ctx->content_id_str); + LOG_MSG_WARNING("Empty SparseInfo data detected for FS section #%u in \"%s\". Skipping FS section.", section_idx, nca_ctx->content_id_str); success = true; goto end; } @@ -918,6 +918,15 @@ static bool ncaInitializeFsSectionContext(NcaContext *nca_ctx, u32 section_idx) goto end; } + /* Check if we're dealing with a bogus Patch RomFS (seem to be available in HtmlDocument NCAs). */ + if (fs_ctx->section_type == NcaFsSectionType_PatchRomFs && fs_ctx->section_size <= (fs_ctx->header.patch_info.indirect_bucket.size + fs_ctx->header.patch_info.aes_ctr_ex_bucket.size)) + { + /* Return true but don't set this FS section as enabled, since we can't really use it. */ + LOG_MSG_WARNING("Empty Patch RomFS data detected for FS section #%u in \"%s\". Skipping FS section.", section_idx, nca_ctx->content_id_str); + success = true; + goto end; + } + /* Validate HashData boundaries. */ if (!ncaFsSectionValidateHashDataBoundaries(fs_ctx)) goto end;