/// Used to display version numbers in dot notation: "{Major}.{Minor}.{Micro}-{MajorRelstep}.{MinorRelstep}".
typedefstruct{
u32ContentMetaVersion_MinorRelstep:8;
u32ContentMetaVersion_MajorRelstep:8;
u32ContentMetaVersion_Micro:4;
u32ContentMetaVersion_Minor:6;
u32ContentMetaVersion_Major:6;
}ContentMetaVersion;
/// Equivalent to NcmContentMetaAttribute.
typedefenum{
ContentMetaAttribute_IncludesExFatDriver=BIT(0),
ContentMetaAttribute_Rebootless=BIT(1),
ContentMetaAttribute_Compacted=BIT(2)
}ContentMetaAttribute;
typedefstruct{
u8ContentMetaInstallState_Committed:1;
u8ContentMetaInstallState_Reserved:7;
}ContentMetaInstallState;
/// Extended variation of NcmContentMetaHeader. This is essentially the start of every CNMT file.
/// Depending on the content meta type value, this header may be followed by an additional extended header for that specific content meta type.
/// NcmPackagedContentInfo and/or NcmContentMetaInfo entries may follow afterwards.
/// If the extended data size field from the extended header (if available) is non-zero, this data is saved after the content info entries.
/// Finally, a 0x20 byte long digest is appended to the EOF.
typedefstruct{
u64title_id;
ContentMetaVersionversion;
u8content_meta_type;///< NcmContentMetaType.
u8reserved_1;
u16extended_header_size;///< Must match the size from the extended header struct for this content meta type (SystemUpdate, Application, Patch, AddOnContent, Delta).
u16content_count;///< Determines how many NcmPackagedContentInfo entries are available after the extended header.
u16content_meta_count;///< Determines how many NcmContentMetaInfo entries are available after the NcmPackagedContentInfo entries. Only used for SystemUpdate.
/// * (Optionally) A variable number of NcmContentMetaInfo entries, which is the sum of all 'meta_count' values from ContentMetaFirmwareVariationInfoV2 entries where 'refer_to_base' is set to false.
NcaContext*nca_ctx;///< Pointer to the NCA context for the Meta NCA from which CNMT data is retrieved.
PartitionFileSystemContextpfs_ctx;///< PartitionFileSystemContext for the Meta NCA FS section #0, which is where the CNMT is stored.
PartitionFileSystemEntry*pfs_entry;///< PartitionFileSystemEntry for the CNMT in the Meta NCA FS section #0. Used to generate a NcaHierarchicalSha256Patch if needed.
NcaHierarchicalSha256Patchnca_patch;///< NcaHierarchicalSha256Patch generated if CNMT modifications are needed. Used to seamlessly replace Meta NCA data while writing it.
///< Bear in mind that generating a patch modifies the NCA context.
char*cnmt_filename;///< Pointer to the CNMT filename in the Meta NCA FS section #0.
u8*raw_data;///< Pointer to a dynamically allocated buffer that holds the raw CNMT.
u64raw_data_size;///< Raw CNMT size. Kept here for convenience - this is part of 'pfs_entry'.
u8raw_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'.
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.
u32extended_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'.
u8*digest;///< Pointer to the digest within 'raw_data'.
char*authoring_tool_xml;///< Pointer to a dynamically allocated, NULL-terminated buffer that holds AuthoringTool-like XML data.
///< This is always NULL unless cnmtGenerateAuthoringToolXml() is used on this ContentMetaContext.
u64authoring_tool_xml_size;///< Size for the AuthoringTool-like XML. This is essentially the same as using strlen() on 'authoring_tool_xml'.
///< This is always 0 unless cnmtGenerateAuthoringToolXml() is used on this ContentMetaContext.
/// Generates an AuthoringTool-like XML using information from a previously initialized ContentMetaContext, as well as a pointer to 'nca_ctx_count' NcaContext with content information.
/// If the function succeeds, XML data and size will get saved to the 'authoring_tool_xml' and 'authoring_tool_xml_size' members from the ContentMetaContext.