Difference between revisions of "CNMT"

From Nintendo Switch Brew
Jump to: navigation, search
(Meta records: broken link)
(Update header and extended header - next is extended data)
Line 12: Line 12:
 
* "Delta_{lower-case hex titleID}.cnmt"
 
* "Delta_{lower-case hex titleID}.cnmt"
  
It starts with a header:
+
== Header ==
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
Line 20: Line 20:
 
|-
 
|-
 
| 0x0
 
| 0x0
| 8
+
| 0x8
 
| Title ID
 
| Title ID
 
|-
 
|-
 
| 0x8
 
| 0x8
| 4
+
| 0x4
| u32 [[Title_list|title-version]]
+
| [[Title_list|Version]]
 
|-
 
|-
 
| 0xC
 
| 0xC
| 1
+
| 0x1
| Type (see [[NCM_services#Title_Types|Title Types]])
+
| [[NCM_services#Title_Types|Meta Type]]
 
|-
 
|-
 
| 0xD
 
| 0xD
| 1
+
| 0x1
|
+
| Unused
 
|-
 
|-
 
| 0xE
 
| 0xE
| 2
+
| 0x2
| Offset to table relative to the end of this 0x20-byte header.
+
| Extended Header Size
 
|-
 
|-
 
| 0x10
 
| 0x10
| 2
+
| 0x2
| Number of content entries
+
| Content Count
 
|-
 
|-
 
| 0x12
 
| 0x12
| 2
+
| 0x2
| Number of meta entries
+
| Content Meta Count
 
|-
 
|-
 
| 0x14
 
| 0x14
| 12
+
| 0x1
|
+
| Attributes (0=None, 1=IncludesExFatDriver, 2=Rebootless)
 +
|-
 +
| 0x15
 +
| 0x3
 +
| Unused
 +
|-
 +
| 0x18
 +
| 0x4
 +
| Required Download System Version
 +
|-
 +
| 0x1C
 +
| 0x4
 +
| Unused
 
|}
 
|}
  
With SystemUpdate, the 4-bytes at offset 0xE are zero, with the entry-count field located at offset 0x12 instead(header size is the same).
+
== SystemUpdate Extended Header ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0
 +
| 0x4
 +
| Extended Header Size
 +
|}
  
An optional header can follow, depending on the title type.
+
== Application Extended Header ==
 
+
{| class="wikitable" border="1"
At the end of the file following the entries is a 0x20-byte block, presumably a hash.
+
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0
 +
| 0x8
 +
| Patch ID
 +
|-
 +
| 0x8
 +
| 0x4
 +
| Required System Version
 +
|}
  
With Patch-format, there's additional data after the end of the entries specified in the header and before the ending hash.
+
== Patch Extended Header ==
 
 
== Application header ==
 
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
Line 67: Line 99:
 
! Description
 
! Description
 
|-
 
|-
| 0x20
+
| 0x0
| 8
+
| 0x8
| Patch Title ID
+
| Application ID
 +
|-
 +
| 0x8
 +
| 0x4
 +
| Required System Version
 +
|-
 +
| 0xC
 +
| 0x4
 +
| Extended Data Size
 
|-
 
|-
| 0x28
+
| 0x10
| 8
+
| 0x8
| Minimum system version
+
| Unused
 
|}
 
|}
  
== Patch header ==
+
== AddOnContent Extended Header ==
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
Line 83: Line 123:
 
! Description
 
! Description
 
|-
 
|-
| 0x20
+
| 0x0
| 8
+
| 0x8
| Original title ID
+
| Application ID
 +
|-
 +
| 0x8
 +
| 0x4
 +
| Required Application Version
 
|-
 
|-
| 0x28
+
| 0xC
| 8
+
| 0x4
| Minimum system version
+
| Unused
 
|}
 
|}
  
== Add-on content header ==
+
== Delta Extended Header ==
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
Line 99: Line 143:
 
! Description
 
! Description
 
|-
 
|-
| 0x20
+
| 0x0
| 8
+
| 0x8
| Application title ID
+
| Application ID
 +
|-
 +
| 0x8
 +
| 0x4
 +
| Extended Data Size
 
|-
 
|-
| 0x28
+
| 0xC
| 8
+
| 0x4
| Minimum application version
+
| Unused
 
|}
 
|}
  
 
== Content records ==
 
== Content records ==
 
Each entry is 0x38 bytes:
 
  
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
Line 119: Line 165:
 
|-
 
|-
 
| 0x0
 
| 0x0
| 32
+
| 0x20
 
| Hash
 
| Hash
 
|-
 
|-
 
| 0x20
 
| 0x20
| 16
+
| 0x10
| NcaId [same as first 16-bytes of hash]
+
| Content ID
 
|-
 
|-
 
| 0x30
 
| 0x30
| 6
+
| 0x6
| Size, same as the output from [[NCM_services#GetSizeFromContentId]].
+
| Size
 
|-
 
|-
 
| 0x36
 
| 0x36
| 1
+
| 0x1
| Type (0=Meta, 1=Program, 2=Data, 3=Control, 4=[[Internet_Browser|HtmlDocument]], 5=[[Internet_Browser|LegalInformation]], 6=[[NCA_Format|DeltaFragment]])
+
| Title Type (0=Meta, 1=Program, 2=Data, 3=Control, 4=[[Internet_Browser|HtmlDocument]], 5=[[Internet_Browser|LegalInformation]], 6=[[NCA_Format|DeltaFragment]])
 
|-
 
|-
 
| 0x37
 
| 0x37
| 1
+
| 0x1
|
+
| Id Offset
 
|}
 
|}
  
 
== Meta records ==
 
== Meta records ==
 
Each entry is 0x10 bytes:
 
  
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
Line 150: Line 194:
 
|-
 
|-
 
| 0x0
 
| 0x0
| 8
+
| 0x8
 
| Title ID
 
| Title ID
 
|-
 
|-
 
| 0x8
 
| 0x8
| 4
+
| 0x4
| Title version
+
| Version
 
|-
 
|-
 
| 0xC
 
| 0xC
| 1
+
| 0x1
| Type (see [[NCM_services#Title_Types|Title Types]])
+
| [[NCM_services#Title_Types|Meta Type]]
 
|-
 
|-
 
| 0xD
 
| 0xD
| 1
+
| 0x1
| ? bit0 set = don't install?
+
| Attributes (0=None, 1=IncludesExFatDriver, 2=Rebootless)
 
|-
 
|-
 
| 0xE
 
| 0xE
| 2
+
| 0x2
| Unused?
+
| Unused
 
|}
 
|}
  

Revision as of 15:30, 22 May 2019

This is the metadata file that ends in ".cnmt{.nca}" or "meta0.ncd". This seems to replace the TMD format.

There's at least 9 different filenames used for ".cnmt":

  • "Application_{lower-case hex titleID}.cnmt"
  • "Patch_{lower-case hex titleID}.cnmt"
  • "AddOnContent_{lower-case hex titleID}.cnmt"
  • "SystemUpdate_{hex titleID}.cnmt"
  • "SystemData_{lower-case hex titleID}.cnmt"
  • "SystemProgram_{lower-case hex titleID}.cnmt"
  • "BootImagePackage_{lower-case hex titleID}.cnmt"
  • "BootImagePackageSafe_{lower-case hex titleID}.cnmt"
  • "Delta_{lower-case hex titleID}.cnmt"

Header

Offset Size Description
0x0 0x8 Title ID
0x8 0x4 Version
0xC 0x1 Meta Type
0xD 0x1 Unused
0xE 0x2 Extended Header Size
0x10 0x2 Content Count
0x12 0x2 Content Meta Count
0x14 0x1 Attributes (0=None, 1=IncludesExFatDriver, 2=Rebootless)
0x15 0x3 Unused
0x18 0x4 Required Download System Version
0x1C 0x4 Unused

SystemUpdate Extended Header

Offset Size Description
0x0 0x4 Extended Header Size

Application Extended Header

Offset Size Description
0x0 0x8 Patch ID
0x8 0x4 Required System Version

Patch Extended Header

Offset Size Description
0x0 0x8 Application ID
0x8 0x4 Required System Version
0xC 0x4 Extended Data Size
0x10 0x8 Unused

AddOnContent Extended Header

Offset Size Description
0x0 0x8 Application ID
0x8 0x4 Required Application Version
0xC 0x4 Unused

Delta Extended Header

Offset Size Description
0x0 0x8 Application ID
0x8 0x4 Extended Data Size
0xC 0x4 Unused

Content records

Offset Size Description
0x0 0x20 Hash
0x20 0x10 Content ID
0x30 0x6 Size
0x36 0x1 Title Type (0=Meta, 1=Program, 2=Data, 3=Control, 4=HtmlDocument, 5=LegalInformation, 6=DeltaFragment)
0x37 0x1 Id Offset

Meta records

Offset Size Description
0x0 0x8 Title ID
0x8 0x4 Version
0xC 0x1 Meta Type
0xD 0x1 Attributes (0=None, 1=IncludesExFatDriver, 2=Rebootless)
0xE 0x2 Unused

This is used for SystemUpdate, see here: NCM_services#ReadEntryMetaRecords.

Extended data

Patch-type cnmt files include an extended data section.

Offset Size Description
0x0 4 Number of previous cnmt entries.
0x4 4 Number of previous delta entries.
0x8 4 Number of delta info entries.
0xC 4 Number of delta application info entries.
0x10 4 Number of previous content entries.
0x14 4 Number of delta content entries.
0x18 4 Unused?
0x1C 0x38*X Previous cnmt entries
0x28*X Previous delta entries
0x28*X Delta info entries
0x34*X Delta application info entries
0x18*X Previous content entries
0x38*X Delta content entries. (Standard content records)
4 Unknown
4 Unknown
4 Unknown

Previous cnmt records

Each entry is 0x38 bytes:

Offset Size Description
0x0 8 Title ID
0x8 4 Title version
0xC 1 Type (see Title Types)
0xD 3 Unused?
0x10 32 Hash
0x30 2 Unknown
0x32 2 Unused?
0x34 4 Unused?

This contains information on previous metadata files.

Previous delta records

Each entry is 0x28 bytes:

Offset Size Description
0x0 8 Old title ID
0x8 8 New title ID
0x10 4 Old title version
0x14 4 New title version
0x18 8 Size
0x20 8 Unused?

This contains information on previous delta patches.

Delta info records

Each entry is 0x28 bytes:

Offset Size Description
0x0 8 Old title ID
0x8 8 New title ID
0x10 4 Old title version
0x14 4 New title version
0x18 8 Some sort of index?
0x20 8 Some sort of index?

This contains information on the current delta patch.

Delta application info records

Each entry is 0x34 bytes:

Offset Size Description
0x0 16 Old NcaId
0x10 16 New NcaId
0x20 6 Old size
0x26 2 Upper 2 bytes of the new size
0x28 4 Lower 4 bytes of the new size
0x2C 2 Unknown
0x2E 1 Type (see Title Types)
0x2F 1 ? bit0 set = don't install?
0x30 4 Unused?

This contains information on how to apply deltas to the previous patch.

Previous content records

Each entry is 0x18 bytes:

Offset Size Description
0x0 16 NcaId
0x10 6 Size
0x16 1 Type (see Title Types)
0x17 1

This contains information on previous title content from earlier patches.