1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-22 18:26:39 +00:00

Fix support for CNMTs with no ContentInfo entries.

This commit is contained in:
Pablo Curiel 2020-10-12 22:46:59 -04:00
parent ebd97d7c82
commit 3ab65d8dca
4 changed files with 13 additions and 7 deletions

View file

@ -135,7 +135,7 @@ bool cnmtInitializeContext(ContentMetaContext *out, NcaContext *nca_ctx)
goto end;
}
if (!out->packaged_header->content_count)
if (!out->packaged_header->content_count && out->packaged_header->content_meta_type != NcmContentMetaType_SystemUpdate)
{
LOGFILE("Invalid content count!");
goto end;
@ -196,8 +196,11 @@ bool cnmtInitializeContext(ContentMetaContext *out, NcaContext *nca_ctx)
}
/* Save pointer to packaged content infos. */
out->packaged_content_info = (NcmPackagedContentInfo*)(out->raw_data + cur_offset);
cur_offset += (out->packaged_header->content_count * sizeof(NcmPackagedContentInfo));
if (out->packaged_header->content_count)
{
out->packaged_content_info = (NcmPackagedContentInfo*)(out->raw_data + cur_offset);
cur_offset += (out->packaged_header->content_count * sizeof(NcmPackagedContentInfo));
}
/* Save pointer to content meta infos. */
if (out->packaged_header->content_meta_count)

View file

@ -226,7 +226,7 @@ typedef struct {
u8 raw_data_hash[SHA256_HASH_SIZE]; ///< SHA-256 checksum calculated over the whole raw CNMT. Used to determine if NcaHierarchicalSha256Patch generation is truly needed.
ContentMetaPackagedContentMetaHeader *packaged_header; ///< Pointer to the ContentMetaPackagedContentMetaHeader within 'raw_data'.
u8 *extended_header; ///< Pointer to the extended header within 'raw_data', if available. May be casted to other types. Its size is stored in 'packaged_header'.
NcmPackagedContentInfo *packaged_content_info; ///< Pointer to the NcmPackagedContentInfo entries within 'raw_data'. The content count is stored in 'packaged_header'.
NcmPackagedContentInfo *packaged_content_info; ///< Pointer to the NcmPackagedContentInfo entries within 'raw_data', if available. The content count is stored in 'packaged_header'.
NcmContentMetaInfo *content_meta_info; ///< Pointer to the NcmContentMetaInfo entries within 'raw_data', if available. The content meta count is stored in 'packaged_header'.
u8 *extended_data; ///< Pointer to the extended data block within 'raw_data', if available.
u32 extended_data_size; ///< Size of the extended data block within 'raw_data', if available. Kept here for convenience - this is part of the header in 'extended_data'.
@ -260,8 +260,9 @@ NX_INLINE bool cnmtIsValidContext(ContentMetaContext *cnmt_ctx)
{
return (cnmt_ctx && cnmt_ctx->nca_ctx && cnmt_ctx->pfs_entry && cnmt_ctx->cnmt_filename && cnmt_ctx->raw_data && cnmt_ctx->raw_data_size && cnmt_ctx->packaged_header && \
((cnmt_ctx->packaged_header->extended_header_size && cnmt_ctx->extended_header) || (!cnmt_ctx->packaged_header->extended_header_size && !cnmt_ctx->extended_header)) && \
cnmt_ctx->packaged_content_info && ((cnmt_ctx->packaged_header->content_meta_count && cnmt_ctx->content_meta_info) || (!cnmt_ctx->packaged_header->content_meta_count && \
!cnmt_ctx->content_meta_info)) && ((cnmt_ctx->extended_data_size && cnmt_ctx->extended_data) || (!cnmt_ctx->extended_data_size && !cnmt_ctx->extended_data)) && cnmt_ctx->digest);
((cnmt_ctx->packaged_header->content_count && cnmt_ctx->packaged_content_info) || (!cnmt_ctx->packaged_header->content_count && !cnmt_ctx->packaged_content_info)) && \
((cnmt_ctx->packaged_header->content_meta_count && cnmt_ctx->content_meta_info) || (!cnmt_ctx->packaged_header->content_meta_count && !cnmt_ctx->content_meta_info)) && \
((cnmt_ctx->extended_data_size && cnmt_ctx->extended_data) || (!cnmt_ctx->extended_data_size && !cnmt_ctx->extended_data)) && cnmt_ctx->digest);
}
NX_INLINE bool cnmtIsNcaPatchRequired(ContentMetaContext *cnmt_ctx)

View file

@ -23,6 +23,8 @@
#ifndef __COMMON_H__
#define __COMMON_H__
#define SYSTEM_UPDATE_TID (u64)0x0100000000000816
/// Used to store version numbers expressed in dot notation: "{major}.{minor}.{micro}-{major_relstep}.{minor_relstep}".
/// Referenced by multiple header files.
typedef struct {

View file

@ -30,7 +30,7 @@
#define GAMECARD_MEDIA_UNIT_SIZE 0x200
#define GAMECARD_MEDIA_UNIT_OFFSET(x) ((u64)(x) * GAMECARD_MEDIA_UNIT_SIZE)
#define GAMECARD_UPDATE_TID (u64)0x0100000000000816
#define GAMECARD_UPDATE_TID SYSTEM_UPDATE_TID
#define GAMECARD_CERTIFICATE_OFFSET 0x7000