Difference between revisions of "NCA"

From Nintendo Switch Brew
Jump to: navigation, search
(Metadata file)
(Metadata file)
 
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
For the content of the NCA FS which can be [[Filesystem_services|mounted]], see [[NCA_Content_FS|here]].
 +
 
= Metadata file =
 
= Metadata file =
This is the file that ends in <code>".cnmt.nca"</code> or <code>"meta0.ncd"</code>.
+
This is the file that ends in <code>".cnmt{.nca}"</code> or <code>"meta0.ncd"</code>. This seems to replace the TMD format.
  
It starts with an header:
+
There's at least 7 different filenames used for ".cnmt":
 +
* "Application_{lower-case hex titleID}.cnmt"
 +
* "Patch_{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"
 +
 
 +
It starts with a header:
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
Line 11: Line 22:
 
| 0x0
 
| 0x0
 
| 8
 
| 8
| Patch title id
+
| Title ID
 
|-
 
|-
 
| 0x8
 
| 0x8
 
| 4
 
| 4
|
+
| u32 [[Title_list|title-version]]
 
|-
 
|-
 
| 0xC
 
| 0xC
Line 27: Line 38:
 
| 0xE
 
| 0xE
 
| 2
 
| 2
| Offset to table
+
| Offset to table relative to the end of this 0x20-byte header.
 
|-
 
|-
 
| 0x10
 
| 0x10
 
| 2
 
| 2
| Number of entries
+
| Number of content entries
 
|-
 
|-
 
| 0x12
 
| 0x12
| 14
+
| 2
 +
| Number of meta entries
 +
|-
 +
| 0x14
 +
| 12
 
|
 
|
 +
|}
 +
 +
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).
 +
 +
An optional header can follow, depending on the title type.
 +
 +
At the end of the file following the entries is a 0x20-byte block, presumably a hash.
 +
 +
With Patch-format, there's additional data after the end of the entries specified in the header and before the ending hash.
 +
 +
== Application header ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x20
 +
| 8
 +
| Patch title ID
 +
|-
 +
| 0x28
 +
| 8
 +
|
 +
|}
 +
 +
== Patch header ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x20
 +
| 8
 +
| Original title ID
 +
|-
 +
| 0x28
 +
| 8
 +
|
 +
|}
 +
 +
== Add-on content header ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 
|-
 
|-
 
| 0x20
 
| 0x20
| 16
+
| 8
| Original title-id
+
| Application title ID
 +
|-
 +
| 0x28
 +
| 8
 +
|
 
|}
 
|}
 +
 +
== Content records ==
  
 
Each entry is 0x38 bytes:
 
Each entry is 0x38 bytes:
Line 60: Line 129:
 
| 0x30
 
| 0x30
 
| 6
 
| 6
| Size
+
| Size, same as the output from [[Content_Manager_services#GetEntrySize]].
 
|-
 
|-
 
| 0x36
 
| 0x36
 
| 1
 
| 1
| Type (0=meta, 1=program, 2=data, 3=control, 4=html, 5=legal)
+
| Type (0=meta, 1=program, 2=data, 3=control, 4=offline-manual [[Internet_Browser|html]], 5=legal [[Internet_Browser|html]])
 
|-
 
|-
 
| 0x37
 
| 0x37
Line 70: Line 139:
 
|
 
|
 
|}
 
|}
 +
 +
== Meta records ==
 +
 +
Each entry is 0x10 bytes:
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset
 +
! Size
 +
! Description
 +
|-
 +
| 0x0
 +
| 8
 +
| Title ID
 +
|-
 +
| 0x8
 +
| 4
 +
| Title version
 +
|-
 +
| 0xC
 +
| 1
 +
| Type (see [[Content_Manager_services#Title_Types|Title Types]])
 +
|-
 +
| 0xD
 +
| 1
 +
| ? bit0 set = don't install?
 +
|-
 +
| 0xE
 +
| 2
 +
| Unused?
 +
|}
 +
 +
This is used for SystemUpdate, see here: [[Content_Manager_services#GetUpdateTitleList]].

Latest revision as of 11:25, 2 July 2017

For the content of the NCA FS which can be mounted, see here.

Metadata file

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

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

  • "Application_{lower-case hex titleID}.cnmt"
  • "Patch_{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"

It starts with a header:

Offset Size Description
0x0 8 Title ID
0x8 4 u32 title-version
0xC 1 Type (see Title Types)
0xD 1
0xE 2 Offset to table relative to the end of this 0x20-byte header.
0x10 2 Number of content entries
0x12 2 Number of meta entries
0x14 12

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

An optional header can follow, depending on the title type.

At the end of the file following the entries is a 0x20-byte block, presumably a hash.

With Patch-format, there's additional data after the end of the entries specified in the header and before the ending hash.

Application header

Offset Size Description
0x20 8 Patch title ID
0x28 8

Patch header

Offset Size Description
0x20 8 Original title ID
0x28 8

Add-on content header

Offset Size Description
0x20 8 Application title ID
0x28 8

Content records

Each entry is 0x38 bytes:

Offset Size Description
0x0 32 Hash
0x20 16 NcaId [same as first 16-bytes of hash]
0x30 6 Size, same as the output from Content_Manager_services#GetEntrySize.
0x36 1 Type (0=meta, 1=program, 2=data, 3=control, 4=offline-manual html, 5=legal html)
0x37 1

Meta records

Each entry is 0x10 bytes:

Offset Size Description
0x0 8 Title ID
0x8 4 Title version
0xC 1 Type (see Title Types)
0xD 1  ? bit0 set = don't install?
0xE 2 Unused?

This is used for SystemUpdate, see here: Content_Manager_services#GetUpdateTitleList.