1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-09-18 21:13:25 +01:00

nca: fix ctx init for NCAs with bogus Patch RomFS.

This commit is contained in:
Pablo Curiel 2022-07-14 14:10:03 +02:00
parent f5d418e0d3
commit b70da7e7bf
4 changed files with 18 additions and 4 deletions

View file

@ -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);

View file

@ -37,6 +37,7 @@
#include <math.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <assert.h>
#include <unistd.h>

View file

@ -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))

View file

@ -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;