<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://switchbrew.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Myster-Tee</id>
	<title>Nintendo Switch Brew - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://switchbrew.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Myster-Tee"/>
	<link rel="alternate" type="text/html" href="https://switchbrew.org/wiki/Special:Contributions/Myster-Tee"/>
	<updated>2026-05-17T08:56:30Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://switchbrew.org/w/index.php?title=NCA&amp;diff=11412</id>
		<title>NCA</title>
		<link rel="alternate" type="text/html" href="https://switchbrew.org/w/index.php?title=NCA&amp;diff=11412"/>
		<updated>2022-01-18T20:04:29Z</updated>

		<summary type="html">&lt;p&gt;Myster-Tee: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;NCA means «Nintendo Content Archive».&lt;br /&gt;
&lt;br /&gt;
The entire raw NCAs are encrypted.&lt;br /&gt;
&lt;br /&gt;
The only known area which is not encrypted in the raw NCA is the logo section, when the NCA includes that section. Everything else documented on this page is for the plaintext version of that data.&lt;br /&gt;
&lt;br /&gt;
= Encryption =&lt;br /&gt;
The first 0xC00 bytes are encrypted with AES-XTS with sector size 0x200 with a non-standard &amp;quot;tweak&amp;quot; (endianness is reversed, see [https://gist.github.com/SciresM/fe8a631d13c069bd66e9c656ab5b3f7f here]), this encrypted data is an 0x400 NCA header + an 0x200 header for each section in the section table.&lt;br /&gt;
&lt;br /&gt;
For pre-1.0.0 &amp;quot;NCA2&amp;quot; NCAs, the first 0x400 byte are encrypted the same way as in NCA3. However, each section header is individually encrypted as though it were sector 0, instead of the appropriate sector as in NCA3.&lt;br /&gt;
&lt;br /&gt;
= Header =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x100&lt;br /&gt;
| RSA-2048 signature over the header (data from 0x200 to 0x400) using a fixed key&lt;br /&gt;
|-&lt;br /&gt;
| 0x100&lt;br /&gt;
| 0x100&lt;br /&gt;
| RSA-2048 signature over the header (data from 0x200 to 0x400) using a key from [[NPDM]] (or zeroes if not a program)&lt;br /&gt;
|-&lt;br /&gt;
| 0x200&lt;br /&gt;
| 0x4&lt;br /&gt;
| Magicnum &amp;quot;NCA3&amp;quot; (&amp;quot;NCA2&amp;quot;, &amp;quot;NCA1&amp;quot; or &amp;quot;NCA0&amp;quot; for pre-1.0.0 NCAs)&lt;br /&gt;
|-&lt;br /&gt;
| 0x204&lt;br /&gt;
| 0x1&lt;br /&gt;
| DistributionType (0x00 = System NCA, 0x01 = Gamecard NCA)&lt;br /&gt;
|-&lt;br /&gt;
| 0x205&lt;br /&gt;
| 0x1&lt;br /&gt;
| ContentType (0x00 = Program, 0x01 = Meta, 0x02 = Control, 0x03 = Manual, 0x04 = Data, 0x05 = PublicData)&lt;br /&gt;
|-&lt;br /&gt;
| 0x206&lt;br /&gt;
| 0x1&lt;br /&gt;
| KeyGenerationOld (0x00 = [[1.0.0]], 0x01 = Unused, 0x02 = [[3.0.0]])&lt;br /&gt;
|-&lt;br /&gt;
| 0x207&lt;br /&gt;
| 0x1&lt;br /&gt;
| KeyAreaEncryptionKeyIndex (0x00 = Application, 0x01 = Ocean, 0x02 = System)&lt;br /&gt;
|-&lt;br /&gt;
| 0x208&lt;br /&gt;
| 0x8&lt;br /&gt;
| ContentSize&lt;br /&gt;
|-&lt;br /&gt;
| 0x210&lt;br /&gt;
| 0x8&lt;br /&gt;
| ProgramId&lt;br /&gt;
|-&lt;br /&gt;
| 0x218&lt;br /&gt;
| 0x4&lt;br /&gt;
| ContentIndex&lt;br /&gt;
|-&lt;br /&gt;
| 0x21C&lt;br /&gt;
| 0x4&lt;br /&gt;
| SdkAddonVersion (used in &amp;quot;FS_ACCESS: { sdk_version: {byte3}.{byte2}.{byte1}, ...&amp;quot; with byte0 set to 0 and compared with a required minimum value: 0x000B0000)&lt;br /&gt;
|-&lt;br /&gt;
| 0x220&lt;br /&gt;
| 0x1&lt;br /&gt;
| KeyGeneration (0x03 = [[3.0.1]], 0x04 = [[4.0.0]], 0x05 = [[5.0.0]], 0x06 = [[6.0.0]], 0x07 = [[6.2.0]], 0x08 = [[7.0.0]], 0x09 = [[8.1.0]], 0x0A = [[9.0.0]], 0x0B = [[9.1.0]], 0x0C = [[12.1.0]], 0x0D = [[13.0.0]], 0xFF = Invalid)&lt;br /&gt;
|-&lt;br /&gt;
| 0x221&lt;br /&gt;
| 0x1&lt;br /&gt;
| [9.0.0+] Header1SignatureKeyGeneration (0 or 1)&lt;br /&gt;
|-&lt;br /&gt;
| 0x222&lt;br /&gt;
| 0xE&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x230&lt;br /&gt;
| 0x10&lt;br /&gt;
| RightsId&lt;br /&gt;
|-&lt;br /&gt;
| 0x240&lt;br /&gt;
| 0x10 * 4&lt;br /&gt;
| Array of [[#FsEntry|FsEntry]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x280&lt;br /&gt;
| 0x20 * 4&lt;br /&gt;
| Array of SHA256 hashes (over each [[#FsHeader|FsHeader]])&lt;br /&gt;
|-&lt;br /&gt;
| 0x300&lt;br /&gt;
| 0x10 * 4&lt;br /&gt;
| EncryptedKeyArea&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
When the above &#039;&#039;&#039;KeyGenerationOld&#039;&#039;&#039; field is 0x2 on &amp;gt;= v3.0, different {crypto/keydata} is used for the sections&#039; data. With system content, this is used with every ncatype except ncatype0. The only other exception is {data-content} for the firm titles: this is required in order for older-system-versions to install it.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KeyGeneration&#039;&#039;&#039; 0x3 (with &#039;&#039;&#039;KeyGenerationOld&#039;&#039;&#039; set to 0x2) is used for all [[3.0.1]] sysmodules and the [[System_Version_Title]]. With [[3.0.2]], all updated titles use the crypto from [[3.0.1]] for non-ncatype0, except for firm {data-content}. In some cases various game content uses the above newer crypto as well.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KeyGeneration&#039;&#039;&#039; is always &#039;&#039;&#039;MasterKeyVersion&#039;&#039;&#039; + 1, except for generations 0 and 1 which are both version 0.&lt;br /&gt;
&lt;br /&gt;
The keyindex passed to &amp;lt;key-generation-related code&amp;gt; is determined as follows:&lt;br /&gt;
* Pre-[[3.0.0]]: The &#039;&#039;&#039;KeyAreaEncryptionKeyIndex&#039;&#039;&#039; field (0x207) is passed directly.&lt;br /&gt;
* [[3.0.0]]+: It&#039;s determined using the &#039;&#039;&#039;KeyAreaEncryptionKeyIndex&#039;&#039;&#039; field (0x207) and the &#039;&#039;&#039;KeyGenerationOld&#039;&#039;&#039; field (0x206). The latter field must be 0, 1 or 2. In each ncahdr_keyindex block, it executes &amp;quot;if(ncahdr_x206&amp;gt;=3)&amp;lt;panic&amp;gt;&amp;quot;, but that won&#039;t trigger due to the earlier check. The end result is basically the same as pre-[[3.0.0]], except when ncahdr_x206 == 0x2, final_index is new_base_index+ncahdr_keyindex. Actual implementation loads index from u32_array[ncahdr_crypto_type], where the address of u32_array is different for each ncahdr_keyindex.&lt;br /&gt;
* [[3.0.1]]+: The dedicated range check for the &#039;&#039;&#039;KeyGenerationOld&#039;&#039;&#039; field (0x206) was removed, since the updated code no longer needs it. The output from a function masked with 0xFF is now used instead of ncahdr_x206. The range check for that field was changed from {ncahdr_x206 check with panic described above}, to &amp;quot;if(index&amp;gt;=4)final_index=10;&amp;quot;(skips accessing the array and uses 10 directly). The arrays were updated with an additional entry: final_index=v301_base_index+ncahdr_keyindex.&lt;br /&gt;
** The keydata for the above index10 is not(?) known to be initialized.&lt;br /&gt;
** The new function called by the code described above does:&lt;br /&gt;
** &amp;lt;code&amp;gt;if(ncahdr_x206 &amp;lt; ncahdr_x220){ret = ncahdr_x220; } else { ret = ncahdr_x206; } return ret;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FsEntry ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x4&lt;br /&gt;
| StartOffset (in Media Units which are 0x200 bytes) &lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x4&lt;br /&gt;
| EndOffset (in Media Units which are 0x200 bytes) &lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x4&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0xC&lt;br /&gt;
| 0x4&lt;br /&gt;
| Reserved&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= FsHeader =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x2&lt;br /&gt;
| Version (always 2)&lt;br /&gt;
|-&lt;br /&gt;
| 0x2&lt;br /&gt;
| 0x1&lt;br /&gt;
| FsType (0 = RomFs, 1 = PartitionFs)&lt;br /&gt;
|-&lt;br /&gt;
| 0x3&lt;br /&gt;
| 0x1&lt;br /&gt;
| HashType (0 = Auto, 2 = HierarchicalSha256, 3 = HierarchicalIntegrity)&lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x1&lt;br /&gt;
| EncryptionType (0 = Auto, 1 = None, 2 = AesCtrOld, 3 = AesCtr, 4 = AesCtrEx)&lt;br /&gt;
|-&lt;br /&gt;
| 0x5&lt;br /&gt;
| 0x3&lt;br /&gt;
| Padding&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0xF8&lt;br /&gt;
| [[#HashInfo|HashInfo]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x100&lt;br /&gt;
| 0x40&lt;br /&gt;
| [[#PatchInfo|PatchInfo]] (only used with game updates RomFs)&lt;br /&gt;
|-&lt;br /&gt;
| 0x140&lt;br /&gt;
| 0x4&lt;br /&gt;
| Generation&lt;br /&gt;
|-&lt;br /&gt;
| 0x144&lt;br /&gt;
| 0x4&lt;br /&gt;
| SecureValue&lt;br /&gt;
|-&lt;br /&gt;
| 0x148&lt;br /&gt;
| 0x30&lt;br /&gt;
| SparseInfo (only used in sections with sparse storage)&lt;br /&gt;
|-&lt;br /&gt;
| 0x178&lt;br /&gt;
| 0x88&lt;br /&gt;
| Reserved&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The FsHeader for each section is at absoluteoffset+0x400+(sectionid*0x200), where sectionid corresponds to the index used with the entry/hash tables.&lt;br /&gt;
&lt;br /&gt;
== HashInfo ==&lt;br /&gt;
This contains information specific to the hash type in use.&lt;br /&gt;
&lt;br /&gt;
=== HierarchicalSha256 ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x20&lt;br /&gt;
| SHA256 hash over the hash-table at section-start+0 with the below hash-table size&lt;br /&gt;
|-&lt;br /&gt;
| 0x20&lt;br /&gt;
| 0x4&lt;br /&gt;
| Block size in bytes&lt;br /&gt;
|-&lt;br /&gt;
| 0x24&lt;br /&gt;
| 0x4&lt;br /&gt;
| Must be 0x2&lt;br /&gt;
|-&lt;br /&gt;
| 0x28&lt;br /&gt;
| 0x8&lt;br /&gt;
| Offset of hash-table (normally zero)&lt;br /&gt;
|-&lt;br /&gt;
| 0x30&lt;br /&gt;
| 0x8&lt;br /&gt;
| Size of hash-table&lt;br /&gt;
|-&lt;br /&gt;
| 0x38&lt;br /&gt;
| 0x8&lt;br /&gt;
| Offset relative to section-start where the PFS0 header is located&lt;br /&gt;
|-&lt;br /&gt;
| 0x40&lt;br /&gt;
| 0x8&lt;br /&gt;
| Actual byte-size of the PFS0 filesystem relative to the PFS0 header&lt;br /&gt;
|-&lt;br /&gt;
| 0x48&lt;br /&gt;
| 0xB0&lt;br /&gt;
| Reserved&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== HierarchicalIntegrity ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x4&lt;br /&gt;
| Magicnum &amp;quot;IVFC&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x4&lt;br /&gt;
| Magic Number (0x20000)&lt;br /&gt;
|-&lt;br /&gt;
| 0xC&lt;br /&gt;
| 0x4&lt;br /&gt;
| Master hash size?&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x4&lt;br /&gt;
| Usually 7? Unknown, could be related to total number of levels maybe?&lt;br /&gt;
|-&lt;br /&gt;
| 0x14&lt;br /&gt;
| 0x8&lt;br /&gt;
| Level 1 offset&lt;br /&gt;
|-&lt;br /&gt;
| 0x1C&lt;br /&gt;
| 0x8&lt;br /&gt;
| Level 1 size&lt;br /&gt;
|-&lt;br /&gt;
| 0x20&lt;br /&gt;
| 0x4&lt;br /&gt;
| Level 1 block size (in log2)&lt;br /&gt;
|-&lt;br /&gt;
| 0x24&lt;br /&gt;
| 0x4&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x28&lt;br /&gt;
| 0x8&lt;br /&gt;
| Level 2 offset&lt;br /&gt;
|-&lt;br /&gt;
| 0x30&lt;br /&gt;
| 0x8&lt;br /&gt;
| Level 2 size&lt;br /&gt;
|-&lt;br /&gt;
| 0x38&lt;br /&gt;
| 0x4&lt;br /&gt;
| Level 2 block size (in log2)&lt;br /&gt;
|-&lt;br /&gt;
| 0x3C&lt;br /&gt;
| 0x4&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x40&lt;br /&gt;
| 0x8&lt;br /&gt;
| Level 3 offset&lt;br /&gt;
|-&lt;br /&gt;
| 0x48&lt;br /&gt;
| 0x8&lt;br /&gt;
| Level 3 size&lt;br /&gt;
|-&lt;br /&gt;
| 0x50&lt;br /&gt;
| 0x4&lt;br /&gt;
| Level 3 block size (in log2)&lt;br /&gt;
|-&lt;br /&gt;
| 0x54&lt;br /&gt;
| 0x4&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x58&lt;br /&gt;
| 0x8&lt;br /&gt;
| Level 4 offset&lt;br /&gt;
|-&lt;br /&gt;
| 0x60&lt;br /&gt;
| 0x8&lt;br /&gt;
| Level 4 size&lt;br /&gt;
|-&lt;br /&gt;
| 0x68&lt;br /&gt;
| 0x4&lt;br /&gt;
| Level 4 block size (in log2)&lt;br /&gt;
|-&lt;br /&gt;
| 0x6C&lt;br /&gt;
| 0x4&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x70&lt;br /&gt;
| 0x8&lt;br /&gt;
| Level 5 offset&lt;br /&gt;
|-&lt;br /&gt;
| 0x78&lt;br /&gt;
| 0x8&lt;br /&gt;
| Level 5 size&lt;br /&gt;
|-&lt;br /&gt;
| 0x80&lt;br /&gt;
| 0x4&lt;br /&gt;
| Level 5 block size (in log2)&lt;br /&gt;
|-&lt;br /&gt;
| 0x84&lt;br /&gt;
| 0x4&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x88&lt;br /&gt;
| 0x8&lt;br /&gt;
| Level 6 offset&lt;br /&gt;
|-&lt;br /&gt;
| 0x90&lt;br /&gt;
| 0x8&lt;br /&gt;
| Level 6 size&lt;br /&gt;
|-&lt;br /&gt;
| 0x98&lt;br /&gt;
| 0x4&lt;br /&gt;
| Level 6 block size (in log2)&lt;br /&gt;
|-&lt;br /&gt;
| 0x9C&lt;br /&gt;
| 0x4&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0xA0&lt;br /&gt;
| 0x20&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0xC0&lt;br /&gt;
| 0x20&lt;br /&gt;
| Hash&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== PatchInfo ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| Offset&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x8&lt;br /&gt;
| Size&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x4&lt;br /&gt;
| Magicnum &amp;quot;BKTR&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 0x14&lt;br /&gt;
| 0x4&lt;br /&gt;
| u32, must be &amp;lt;=1.&lt;br /&gt;
|-&lt;br /&gt;
| 0x18&lt;br /&gt;
| 0x4&lt;br /&gt;
| s32, must be &amp;gt;=1.&lt;br /&gt;
|-&lt;br /&gt;
| 0x1C&lt;br /&gt;
| 0x4&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| 0x20&lt;br /&gt;
| 0x20&lt;br /&gt;
| Same as the above 0x20-bytes except with different data.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The above byte-offsets are relative to the start of the section-data.&lt;br /&gt;
&lt;br /&gt;
The two sections specified by the two BKTR entries are usually(?) at the very end of the section data(section_endoffset-{size of BKTR sections}).&lt;br /&gt;
&lt;br /&gt;
=== RomFs Patching ===&lt;br /&gt;
The [[#PatchInfo|PatchInfo]] section enables combining data from an update NCA with the RomFs from a base NCA to create a single patched RomFS image. &lt;br /&gt;
&lt;br /&gt;
The first BKTR entry describes how to map regions of the two RomFs images to create the patched RomFs. It has the following format:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x4&lt;br /&gt;
| Padding/Unused?&lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x4&lt;br /&gt;
| Number of Buckets&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x8&lt;br /&gt;
| Total Size of the Virtual RomFS Image&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x3FF0&lt;br /&gt;
| Base Virtual Offset for each Bucket (u64s, padded with 0s until end)&lt;br /&gt;
|-&lt;br /&gt;
| 0x4000&lt;br /&gt;
| 0x4000*X&lt;br /&gt;
| Relocation Buckets&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Where relocation buckets are as follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x4&lt;br /&gt;
| Padding/Unused?&lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x4&lt;br /&gt;
| Number of Entries&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x8&lt;br /&gt;
| End offset for this Bucket&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x3FF0&lt;br /&gt;
| Relocation Entries&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Where relocation entries are as follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| Address in Patched RomFs&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x8&lt;br /&gt;
| Address in Source RomFs&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x4&lt;br /&gt;
| 1=Is from Patch RomFS, 0=Is from Base RomFS&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The second BKTR entry describes the subsections within the Patch RomFs. It has the following format:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x4&lt;br /&gt;
| Padding/Unused?&lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x4&lt;br /&gt;
| Number of Buckets&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x8&lt;br /&gt;
| Total Size of the Physical Patch Image&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x3FF0&lt;br /&gt;
| Base Physical Offset for each Bucket (u64s, padded with 0s until end)&lt;br /&gt;
|-&lt;br /&gt;
| 0x4000&lt;br /&gt;
| 0x4000*X&lt;br /&gt;
| Subsection Buckets&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Where subsection buckets are as follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x4&lt;br /&gt;
| Padding/Unused?&lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x4&lt;br /&gt;
| Number of Entries&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x8&lt;br /&gt;
| End offset for this Bucket&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x3FF0&lt;br /&gt;
| Subsection Entries&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Where subsection entries are as follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| Address in Patch RomFs&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x4&lt;br /&gt;
| Padding/Unused?&lt;br /&gt;
|-&lt;br /&gt;
| 0xC&lt;br /&gt;
| 0x4&lt;br /&gt;
| Value for subsection AES-CTR&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Official code assumes the relocation entries are sorted, and performs a binary search when determining where to read from. Each subsection in the Patch RomFs has its CTR calculated separately from the others based on the value in its entry (the BKTR entries use normal crypto). Thus decrypting a Patch RomFS requires decrypting and parsing the BKTR entries before anything else.&lt;br /&gt;
&lt;br /&gt;
= Logo Section =&lt;br /&gt;
This is a PFS0.&lt;br /&gt;
&lt;br /&gt;
See [[NCA_Content_FS|here]] for the mounted-FS logo contents.&lt;br /&gt;
&lt;br /&gt;
= ExeFS Section =&lt;br /&gt;
This is a PFS0.&lt;br /&gt;
&lt;br /&gt;
See [[ExeFS|here]] for mounted-FS ExeFS contents.&lt;br /&gt;
&lt;br /&gt;
= Game Updates =&lt;br /&gt;
The section-data for ncatype1 RomFS section(section1) uses section-crypto-type 0x4.&lt;br /&gt;
&lt;br /&gt;
Game updates also contain multiple ncatype6 content, which contain &amp;quot;section0_pfs0/fragment&amp;quot;. Some of these are just NCAs, unknown for the rest(presumably NCAs with additional crypto?). The first ncatype6 content fragment file has a NDV0 header, with the NCA starting at offset 0x44.&lt;br /&gt;
&lt;br /&gt;
= PFS0 =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| {Hash-table offset from superblock}&lt;br /&gt;
| {Hash-table size from superblock}&lt;br /&gt;
| Table of SHA256 hashes.&lt;br /&gt;
|-&lt;br /&gt;
| {Hash-table &amp;lt;offset+size&amp;gt; from superblock}&lt;br /&gt;
| &lt;br /&gt;
| Zeros for alignment to {alignment size}.&lt;br /&gt;
|-&lt;br /&gt;
| {PFS0 offset from superblock}&lt;br /&gt;
| {PFS0 size from superblock}&lt;br /&gt;
| The actual PFS0.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is the FS which has magicnum &amp;quot;PFS0&amp;quot; at header+0. This is very similar to [[Gamecard_Format|HFS0]]. A tool for extracting this FS is available [https://gist.github.com/yellows8/1a96c2b846f4ebc4bb45d7f7fa1eb7db here].&lt;br /&gt;
&lt;br /&gt;
The hash table is hashes for every {Block size from superblock} starting at the PFS0 header. The size used for the last hash is {PFS0 filesystem size from superblock} - offset_relativeto_header.&lt;br /&gt;
&lt;br /&gt;
See also the PFS0 superblock above.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x4&lt;br /&gt;
| Magicnum &amp;quot;PFS0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x4&lt;br /&gt;
| Number of files&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x4&lt;br /&gt;
| Size of the string table&lt;br /&gt;
|-&lt;br /&gt;
| 0xC&lt;br /&gt;
| 0x4&lt;br /&gt;
| Zero/Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| X&lt;br /&gt;
| File Entry Table&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 + X&lt;br /&gt;
| Y&lt;br /&gt;
| String Table&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 + X + Y&lt;br /&gt;
| Z&lt;br /&gt;
| Raw File Data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Where File Entry Table consists of Number of Files FileEntries:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| Offset of file in Data&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x8&lt;br /&gt;
| Size of file in Data&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x4&lt;br /&gt;
| Offset of filename in String Table&lt;br /&gt;
|-&lt;br /&gt;
| 0x14&lt;br /&gt;
| 0x4&lt;br /&gt;
| Normally zero?&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Myster-Tee</name></author>
	</entry>
	<entry>
		<id>https://switchbrew.org/w/index.php?title=CNMT&amp;diff=11411</id>
		<title>CNMT</title>
		<link rel="alternate" type="text/html" href="https://switchbrew.org/w/index.php?title=CNMT&amp;diff=11411"/>
		<updated>2022-01-11T21:37:08Z</updated>

		<summary type="html">&lt;p&gt;Myster-Tee: /* Packaged Content Info */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the metadata file that ends in &amp;lt;code&amp;gt;&amp;quot;.cnmt{.nca}&amp;quot;&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;&amp;quot;meta0.ncd&amp;quot;&amp;lt;/code&amp;gt;. This seems to replace the TMD format.&lt;br /&gt;
&lt;br /&gt;
The official name for CNMT is &amp;quot;PackagedContentMeta&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Header ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| ID&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x4&lt;br /&gt;
| Version&lt;br /&gt;
|-&lt;br /&gt;
| 0xC&lt;br /&gt;
| 0x1&lt;br /&gt;
| [[NCM_services#ContentMetaType|Content Meta Type]]&lt;br /&gt;
|-&lt;br /&gt;
| 0xD&lt;br /&gt;
| 0x1&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0xE&lt;br /&gt;
| 0x2&lt;br /&gt;
| Extended Header Size&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x2&lt;br /&gt;
| Content Count&lt;br /&gt;
|-&lt;br /&gt;
| 0x12&lt;br /&gt;
| 0x2&lt;br /&gt;
| Content Meta Count&lt;br /&gt;
|-&lt;br /&gt;
| 0x14&lt;br /&gt;
| 0x1&lt;br /&gt;
| Content Meta Attributes (0=None, 1=IncludesExFatDriver, 2=Rebootless)&lt;br /&gt;
|-&lt;br /&gt;
| 0x15&lt;br /&gt;
| 0x3&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x18&lt;br /&gt;
| 0x4&lt;br /&gt;
| Required Download System Version&lt;br /&gt;
|-&lt;br /&gt;
| 0x1C&lt;br /&gt;
| 0x4&lt;br /&gt;
| Reserved&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== SystemUpdate Extended Header ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x4&lt;br /&gt;
| Extended Data Size&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Application Extended Header ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| Patch ID&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x4&lt;br /&gt;
| Required System Version&lt;br /&gt;
|-&lt;br /&gt;
| 0xC&lt;br /&gt;
| 0x4&lt;br /&gt;
| Required Application Version&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Patch Extended Header ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| Application ID&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x4&lt;br /&gt;
| Required System Version&lt;br /&gt;
|-&lt;br /&gt;
| 0xC&lt;br /&gt;
| 0x4&lt;br /&gt;
| Extended Data Size&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x8&lt;br /&gt;
| Reserved&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== AddOnContent Extended Header ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| Application ID&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x4&lt;br /&gt;
| Required Application Version&lt;br /&gt;
|-&lt;br /&gt;
| 0xC&lt;br /&gt;
| 0x4&lt;br /&gt;
| Reserved&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Delta Extended Header ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| Application ID&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x4&lt;br /&gt;
| Extended Data Size&lt;br /&gt;
|-&lt;br /&gt;
| 0xC&lt;br /&gt;
| 0x4&lt;br /&gt;
| Reserved&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Packaged Content Info ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x20&lt;br /&gt;
| Hash (SHA256 of the referenced content)&lt;br /&gt;
|-&lt;br /&gt;
| 0x20&lt;br /&gt;
| 0x10&lt;br /&gt;
| Content ID&lt;br /&gt;
|-&lt;br /&gt;
| 0x30&lt;br /&gt;
| 0x6&lt;br /&gt;
| Size&lt;br /&gt;
|-&lt;br /&gt;
| 0x36&lt;br /&gt;
| 0x1&lt;br /&gt;
| Content Type (0=Meta, 1=Program, 2=Data, 3=Control, 4=[[Internet_Browser|HtmlDocument]], 5=[[Internet_Browser|LegalInformation]], 6=[[NCA_Format|DeltaFragment]])&lt;br /&gt;
|-&lt;br /&gt;
| 0x37&lt;br /&gt;
| 0x1&lt;br /&gt;
| ID Offset&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Content Meta Info ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| ID&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x4&lt;br /&gt;
| Version&lt;br /&gt;
|-&lt;br /&gt;
| 0xC&lt;br /&gt;
| 0x1&lt;br /&gt;
| [[NCM_services#Title_Types|Content Meta Type]]&lt;br /&gt;
|-&lt;br /&gt;
| 0xD&lt;br /&gt;
| 0x1&lt;br /&gt;
| Content Meta Attributes (0=None, 1=IncludesExFatDriver, 2=Rebootless)&lt;br /&gt;
|-&lt;br /&gt;
| 0xE&lt;br /&gt;
| 0x2&lt;br /&gt;
| Reserved&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is used for SystemUpdate, see here: [[NCM_services#ReadEntryMetaRecords]].&lt;br /&gt;
&lt;br /&gt;
== SystemUpdate Extended Data ==&lt;br /&gt;
&lt;br /&gt;
If the Version field is 1, the format is:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x4&lt;br /&gt;
| Version&lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x4&lt;br /&gt;
| Variation Count&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x20 * Variation Count&lt;br /&gt;
| [[CNMT#Firmware_Variation_Info_(Version_1)|Firmware Variation Info (Version 1)]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If the Version field is 2, the format is:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x4&lt;br /&gt;
| Version&lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x4&lt;br /&gt;
| Variation Count&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x4 * Variation Count&lt;br /&gt;
| Firmware Variation ID&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| 0x20 * Variation Count&lt;br /&gt;
| [[CNMT#Firmware_Variation_Info_(Version_2)|Firmware Variation Info (Version 2)]]&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| 0x10 * Meta Count (From [[CNMT#Firmware_Variation_Info_(Version_2)|Firmware Variation Info (Version 2)]])&lt;br /&gt;
| [[CNMT#Content_Meta_Info|Content Meta Info]] (If Refer To Base is False)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Firmware Variation Info (Version 1) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x4&lt;br /&gt;
| Firmware Variation ID&lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x1C&lt;br /&gt;
| Reserved&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Firmware Variation Info (Version 2) ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x1&lt;br /&gt;
| Refer To Base (0=False, 1=True)&lt;br /&gt;
|-&lt;br /&gt;
| 0x1&lt;br /&gt;
| 0x3&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x4&lt;br /&gt;
| Meta Count&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x18&lt;br /&gt;
| Reserved&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Patch Extended Data ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x4&lt;br /&gt;
| History Count&lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x4&lt;br /&gt;
| Delta History Count&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x4&lt;br /&gt;
| Delta Count&lt;br /&gt;
|-&lt;br /&gt;
| 0xC&lt;br /&gt;
| 0x4&lt;br /&gt;
| Fragment Set Count&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x4&lt;br /&gt;
| History Content Count&lt;br /&gt;
|-&lt;br /&gt;
| 0x14&lt;br /&gt;
| 0x4&lt;br /&gt;
| Delta Content Count&lt;br /&gt;
|-&lt;br /&gt;
| 0x18&lt;br /&gt;
| 0x4&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x1C&lt;br /&gt;
| 0x38 * History Count&lt;br /&gt;
| [[CNMT#History_Header|History Headers]]&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| 0x28 * Delta History Count&lt;br /&gt;
| [[CNMT#Delta_History|Delta Histories]]&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| 0x28 * Delta Count&lt;br /&gt;
| [[CNMT#Delta_Header|Delta Headers]]&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| 0x34 * Fragment Set Count&lt;br /&gt;
| [[CNMT#Fragment_Set|Fragment Sets]]&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| 0x18 * History Content Count&lt;br /&gt;
| [[CNMT#Packaged_Content_Info|History Content Info]] (Packaged Content Info without the Hash entry)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| 0x38 * Delta Content Count&lt;br /&gt;
| [[CNMT#Packaged_Content_Info|Delta Packaged Content Info]]&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 0x4 * Fragment Indicator Count (From [[CNMT#Fragment_Set|Fragment Sets]])&lt;br /&gt;
| [[CNMT#Fragment_Indicator|Fragment Indicators]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== History Header ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x10&lt;br /&gt;
| Content Meta Key (Slightly different Content Meta Info)&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x20&lt;br /&gt;
| Digest&lt;br /&gt;
|-&lt;br /&gt;
| 0x30&lt;br /&gt;
| 0x2&lt;br /&gt;
| Content Info Count&lt;br /&gt;
|-&lt;br /&gt;
| 0x32&lt;br /&gt;
| 0x6&lt;br /&gt;
| Reserved&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Delta History ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| Source Patch ID&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x8&lt;br /&gt;
| Destination Patch ID&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x4&lt;br /&gt;
| Source Version&lt;br /&gt;
|-&lt;br /&gt;
| 0x14&lt;br /&gt;
| 0x4&lt;br /&gt;
| Destination Version&lt;br /&gt;
|-&lt;br /&gt;
| 0x18&lt;br /&gt;
| 0x8&lt;br /&gt;
| Download Size&lt;br /&gt;
|-&lt;br /&gt;
| 0x20&lt;br /&gt;
| 0x8&lt;br /&gt;
| Reserved&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Delta Header ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| Source Patch ID&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 8&lt;br /&gt;
| Destination Patch ID&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x4&lt;br /&gt;
| Source Version&lt;br /&gt;
|-&lt;br /&gt;
| 0x14&lt;br /&gt;
| 0x4&lt;br /&gt;
| Destination Version&lt;br /&gt;
|-&lt;br /&gt;
| 0x18&lt;br /&gt;
| 0x2&lt;br /&gt;
| Fragment Set Count&lt;br /&gt;
|-&lt;br /&gt;
| 0x1A&lt;br /&gt;
| 0x6&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x20&lt;br /&gt;
| 0x2&lt;br /&gt;
| Content Info Count&lt;br /&gt;
|-&lt;br /&gt;
| 0x22&lt;br /&gt;
| 0x6&lt;br /&gt;
| Reserved&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Fragment Set ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x10&lt;br /&gt;
| Source Content ID&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x10&lt;br /&gt;
| Destination Content ID&lt;br /&gt;
|-&lt;br /&gt;
| 0x20&lt;br /&gt;
| 0x6&lt;br /&gt;
| Source Size&lt;br /&gt;
|-&lt;br /&gt;
| 0x26&lt;br /&gt;
| 0x6&lt;br /&gt;
| Destination Size&lt;br /&gt;
|-&lt;br /&gt;
| 0x2C&lt;br /&gt;
| 0x2&lt;br /&gt;
| Fragment Indicator Count&lt;br /&gt;
|-&lt;br /&gt;
| 0x2E&lt;br /&gt;
| 0x1&lt;br /&gt;
| Fragment Target Content Type (0=Meta, 1=Program, 2=Data, 3=Control, 4=[[Internet_Browser|HtmlDocument]], 5=[[Internet_Browser|LegalInformation]], 6=[[NCA_Format|DeltaFragment]])&lt;br /&gt;
|-&lt;br /&gt;
| 0x2F&lt;br /&gt;
| 0x1&lt;br /&gt;
| Update Type (0=ApplyAsDelta, 1=Overwrite, 2=Create)&lt;br /&gt;
|-&lt;br /&gt;
| 0x30&lt;br /&gt;
| 0x4&lt;br /&gt;
| Reserved&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Fragment Indicator ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x2&lt;br /&gt;
| Content Info Index&lt;br /&gt;
|-&lt;br /&gt;
| 0x2&lt;br /&gt;
| 0x2&lt;br /&gt;
| Fragment Index&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Delta Extended Data ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| Source Patch ID&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x8&lt;br /&gt;
| Destination Patch ID&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x4&lt;br /&gt;
| Source Version&lt;br /&gt;
|-&lt;br /&gt;
| 0x14&lt;br /&gt;
| 0x4&lt;br /&gt;
| Destination Version&lt;br /&gt;
|-&lt;br /&gt;
| 0x18&lt;br /&gt;
| 0x2&lt;br /&gt;
| Fragment Set Count&lt;br /&gt;
|-&lt;br /&gt;
| 0x1A&lt;br /&gt;
| 0x6&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x20&lt;br /&gt;
| 0x34 * Fragment Set Count&lt;br /&gt;
| [[CNMT#Fragment_Set|Fragment Sets]]&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
| 0x4 * Fragment Indicator Count (From [[CNMT#Fragment_Set|Fragment Sets]])&lt;br /&gt;
| [[CNMT#Fragment_Indicator|Fragment Indicators]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Digest ==&lt;br /&gt;
&lt;br /&gt;
Always found at the end of the file.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x20&lt;br /&gt;
| Digest&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Myster-Tee</name></author>
	</entry>
	<entry>
		<id>https://switchbrew.org/w/index.php?title=NACP&amp;diff=6929</id>
		<title>NACP</title>
		<link rel="alternate" type="text/html" href="https://switchbrew.org/w/index.php?title=NACP&amp;diff=6929"/>
		<updated>2019-05-20T19:31:55Z</updated>

		<summary type="html">&lt;p&gt;Myster-Tee: /* Title Entry */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is &#039;&#039;&#039;control.nacp&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Roughly equivalent to non-gfx areas of 3DS SMDH. All strings for language-entries are UTF-8, unlike SMDH which uses UTF-16.&lt;br /&gt;
&lt;br /&gt;
Total size is 0x4000-bytes.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x3000 (0x300*0x10)&lt;br /&gt;
| [[#Title Entry|Title entries]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x3000&lt;br /&gt;
| 0x25&lt;br /&gt;
| Isbn&lt;br /&gt;
|-&lt;br /&gt;
| 0x3025&lt;br /&gt;
| 0x1&lt;br /&gt;
| StartupUserAccount&lt;br /&gt;
|-&lt;br /&gt;
| 0x3026&lt;br /&gt;
| 0x1&lt;br /&gt;
| UserAccountSwitchLock&lt;br /&gt;
|-&lt;br /&gt;
| 0x3027&lt;br /&gt;
| 0x1&lt;br /&gt;
| AddOnContentRegistrationType&lt;br /&gt;
|-&lt;br /&gt;
| 0x3028&lt;br /&gt;
| 0x4&lt;br /&gt;
| ApplicationAttribute&lt;br /&gt;
|-&lt;br /&gt;
| 0x302C&lt;br /&gt;
| 0x4&lt;br /&gt;
| SupportedLanguages&lt;br /&gt;
|-&lt;br /&gt;
| 0x3030&lt;br /&gt;
| 0x4&lt;br /&gt;
| ParentalControl&lt;br /&gt;
|-&lt;br /&gt;
| 0x3034&lt;br /&gt;
| 0x1&lt;br /&gt;
| Screenshot&lt;br /&gt;
|-&lt;br /&gt;
| 0x3035&lt;br /&gt;
| 0x1&lt;br /&gt;
| [[#VideoCaptureMode]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x3036&lt;br /&gt;
| 0x1&lt;br /&gt;
| DataLossConfirmation&lt;br /&gt;
|-&lt;br /&gt;
| 0x3037&lt;br /&gt;
| 0x1&lt;br /&gt;
| PlayLogPolicy&lt;br /&gt;
|-&lt;br /&gt;
| 0x3038&lt;br /&gt;
| 0x8&lt;br /&gt;
| PresenceGroupId&lt;br /&gt;
|-&lt;br /&gt;
| 0x3040&lt;br /&gt;
| 0x20&lt;br /&gt;
| RatingAge&lt;br /&gt;
|-&lt;br /&gt;
| 0x3060&lt;br /&gt;
| 0x10&lt;br /&gt;
| DisplayVersion&lt;br /&gt;
|-&lt;br /&gt;
| 0x3070&lt;br /&gt;
| 0x8&lt;br /&gt;
| AddOnContentBaseId&lt;br /&gt;
|-&lt;br /&gt;
| 0x3078&lt;br /&gt;
| 0x8&lt;br /&gt;
| SaveDataOwnerId&lt;br /&gt;
|-&lt;br /&gt;
| 0x3080&lt;br /&gt;
| 0x8&lt;br /&gt;
| UserAccountSaveDataSize&lt;br /&gt;
|-&lt;br /&gt;
| 0x3088&lt;br /&gt;
| 0x8&lt;br /&gt;
| UserAccountSaveDataJournalSize&lt;br /&gt;
|-&lt;br /&gt;
| 0x3090&lt;br /&gt;
| 0x8&lt;br /&gt;
| DeviceSaveDataSize&lt;br /&gt;
|-&lt;br /&gt;
| 0x3098&lt;br /&gt;
| 0x8&lt;br /&gt;
| DeviceSaveDataJournalSize&lt;br /&gt;
|-&lt;br /&gt;
| 0x30A0&lt;br /&gt;
| 0x8&lt;br /&gt;
| BcatDeliveryCacheStorageSize&lt;br /&gt;
|-&lt;br /&gt;
| 0x30A8&lt;br /&gt;
| 0x8&lt;br /&gt;
| ApplicationErrorCodeCategory&lt;br /&gt;
|-&lt;br /&gt;
| 0x30B0&lt;br /&gt;
| 0x40 (0x8*0x8)&lt;br /&gt;
| LocalCommunicationIds&lt;br /&gt;
|-&lt;br /&gt;
| 0x30F0&lt;br /&gt;
| 0x1&lt;br /&gt;
| LogoType&lt;br /&gt;
|-&lt;br /&gt;
| 0x30F1&lt;br /&gt;
| 0x1&lt;br /&gt;
| LogoHandling&lt;br /&gt;
|-&lt;br /&gt;
| 0x30F2&lt;br /&gt;
| 0x1&lt;br /&gt;
| RuntimeAddOnContentInstall&lt;br /&gt;
|-&lt;br /&gt;
| 0x30F3&lt;br /&gt;
| 0x3&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x30F6&lt;br /&gt;
| 0x1&lt;br /&gt;
| CrashReport&lt;br /&gt;
|-&lt;br /&gt;
| 0x30F7&lt;br /&gt;
| 0x1&lt;br /&gt;
| Hdcp&lt;br /&gt;
|-&lt;br /&gt;
| 0x30F8&lt;br /&gt;
| 0x8&lt;br /&gt;
| SeedForPseudoDeviceId&lt;br /&gt;
|-&lt;br /&gt;
| 0x3100&lt;br /&gt;
| 0x41&lt;br /&gt;
| [[BCAT_Content_Container|BcatPassphrase]] (all-zero when unused)&lt;br /&gt;
|-&lt;br /&gt;
| 0x3141&lt;br /&gt;
| 0x1&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x3142&lt;br /&gt;
| 0x6&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x3148&lt;br /&gt;
| 0x8&lt;br /&gt;
| UserAccountSaveDataMaxSize&lt;br /&gt;
|-&lt;br /&gt;
| 0x3150&lt;br /&gt;
| 0x8&lt;br /&gt;
| UserAccountSaveDataMaxJournalSize&lt;br /&gt;
|-&lt;br /&gt;
| 0x3158&lt;br /&gt;
| 0x8&lt;br /&gt;
| DeviceSaveDataMaxSize&lt;br /&gt;
|-&lt;br /&gt;
| 0x3160&lt;br /&gt;
| 0x8&lt;br /&gt;
| DeviceSaveDataMaxJournalSize&lt;br /&gt;
|-&lt;br /&gt;
| 0x3168&lt;br /&gt;
| 0x8&lt;br /&gt;
| TemporaryStorageSize&lt;br /&gt;
|-&lt;br /&gt;
| 0x3170&lt;br /&gt;
| 0x8&lt;br /&gt;
| CacheStorageSize&lt;br /&gt;
|-&lt;br /&gt;
| 0x3178&lt;br /&gt;
| 0x8&lt;br /&gt;
| CacheStorageJournalSize&lt;br /&gt;
|-&lt;br /&gt;
| 0x3180&lt;br /&gt;
| 0x8&lt;br /&gt;
| CacheStorageMaxSizeAndMaxJournalSize&lt;br /&gt;
|-&lt;br /&gt;
| 0x3188&lt;br /&gt;
| 0x8&lt;br /&gt;
| CacheStorageMaxIndex&lt;br /&gt;
|-&lt;br /&gt;
| 0x3190&lt;br /&gt;
| 0x80 (0x10*0x8)&lt;br /&gt;
| PlayLogQueryableApplicationId&lt;br /&gt;
|-&lt;br /&gt;
| 0x3210&lt;br /&gt;
| 0x1&lt;br /&gt;
| PlayLogQueryCapability&lt;br /&gt;
|-&lt;br /&gt;
| 0x3211&lt;br /&gt;
| 0x1&lt;br /&gt;
| RepairFlag&lt;br /&gt;
|-&lt;br /&gt;
| 0x3212&lt;br /&gt;
| 0x1&lt;br /&gt;
| ProgramIndex&lt;br /&gt;
|-&lt;br /&gt;
| 0x3213&lt;br /&gt;
| 0x1&lt;br /&gt;
| RequiredNetworkServiceLicenseOnLaunchFlag&lt;br /&gt;
|-&lt;br /&gt;
| 0x3214&lt;br /&gt;
| 0xDEC&lt;br /&gt;
| Reserved&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Title Entry ==&lt;br /&gt;
Total size is 0x300-bytes.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x200&lt;br /&gt;
| Application name strings&lt;br /&gt;
|-&lt;br /&gt;
| 0x200&lt;br /&gt;
| 0x100&lt;br /&gt;
| Application publisher strings&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Entry index for each [[Settings_services#LanguageCode|language]]:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Entry-index || Icon [[NCA_Content_FS#FS-type3|language]] filename&lt;br /&gt;
|-&lt;br /&gt;
| 0 || &amp;quot;AmericanEnglish&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 1 || &amp;quot;BritishEnglish&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 2 || &amp;quot;Japanese&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 3 || &amp;quot;French&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 4 || &amp;quot;German&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 5 || &amp;quot;LatinAmericanSpanish&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 6 || &amp;quot;Spanish&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 7 || &amp;quot;Italian&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 8 || &amp;quot;Dutch&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 9 || &amp;quot;CanadianFrench&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 10 || &amp;quot;Portuguese&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 11 || &amp;quot;Russian&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 12 || &amp;quot;Korean&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 13 || &amp;quot;TraditionalChinese&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 14 || &amp;quot;SimplifiedChinese&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Official apps tend to have the title entries&#039; strings set only to English. Some apps don&#039;t have certain title entries set at all. In addition, official apps usually (?) don&#039;t have the following title entries set: Korean, Taiwanese, and Chinese.&lt;br /&gt;
&lt;br /&gt;
== VideoCaptureMode ==&lt;br /&gt;
This is the enum used to determine how gameplay recording can occur, if at all.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Disabled&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Enabled&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Automatic&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
When this value is 0, gameplay cannot be recorded. When this value is 1, the game must manually sacrifice some of its heap as transfer memory for AM&#039;s IApplicationProxy-&amp;gt;InitializeGamePlayRecording(). When this value is 2, AM will call NS-&amp;gt;BoostSystemMemoryResourceSize(), and allocate the required memory for recording automatically without the usermode process having to do anything.&lt;/div&gt;</summary>
		<author><name>Myster-Tee</name></author>
	</entry>
	<entry>
		<id>https://switchbrew.org/w/index.php?title=NCA&amp;diff=6917</id>
		<title>NCA</title>
		<link rel="alternate" type="text/html" href="https://switchbrew.org/w/index.php?title=NCA&amp;diff=6917"/>
		<updated>2019-05-19T08:12:36Z</updated>

		<summary type="html">&lt;p&gt;Myster-Tee: /* Header */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The entire raw NCAs are encrypted.&lt;br /&gt;
&lt;br /&gt;
The only known area which is not encrypted in the raw NCA is the logo section, when the NCA includes that section. Everything else documented on this page is for the plaintext version of that data.&lt;br /&gt;
&lt;br /&gt;
=Encryption=&lt;br /&gt;
The first 0xC00 bytes are encrypted with AES-XTS with sector size 0x200 with a non-standard &amp;quot;tweak&amp;quot; (endianness is reversed, see [https://gist.github.com/SciresM/fe8a631d13c069bd66e9c656ab5b3f7f here]), this encrypted data is an 0x400 NCA header + an 0x200 header for each section in the section table.&lt;br /&gt;
&lt;br /&gt;
For pre-1.0.0 &amp;quot;NCA2&amp;quot; NCAs, the first 0x400 byte are encrypted the same way as in NCA3. However, each section header is individually encrypted as though it were sector 0, instead of the appropriate sector as in NCA3.&lt;br /&gt;
&lt;br /&gt;
=Header=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x100&lt;br /&gt;
| RSA-2048 signature over the 0x200-bytes starting at offset 0x200 using fixed key.&lt;br /&gt;
|-&lt;br /&gt;
| 0x100&lt;br /&gt;
| 0x100&lt;br /&gt;
| RSA-2048 signature over the 0x200-bytes starting at offset 0x200 using key from [[NPDM]], or zeroes if not a program.&lt;br /&gt;
|-&lt;br /&gt;
| 0x200&lt;br /&gt;
| 0x4&lt;br /&gt;
| Magicnum (Normally &amp;quot;NCA3&amp;quot;, &amp;quot;NCA2&amp;quot; for some pre-1.0.0 NCAs)&lt;br /&gt;
|-&lt;br /&gt;
| 0x204&lt;br /&gt;
| 0x1&lt;br /&gt;
| 0 for system NCAs. 1 for a NCA from gamecard.&lt;br /&gt;
|-&lt;br /&gt;
| 0x205&lt;br /&gt;
| 0x1&lt;br /&gt;
| Content Type (0=Program, 1=Meta, 2=Control, 3=Manual, 4=Data, 5=PublicData)&lt;br /&gt;
|-&lt;br /&gt;
| 0x206&lt;br /&gt;
| 0x1&lt;br /&gt;
| Crypto Type. Only used stating with [[3.0.0]]. Normally 0. 2 = Crypto supported starting with [[3.0.0]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x207&lt;br /&gt;
| 0x1&lt;br /&gt;
| Key index, must be 0-2.&lt;br /&gt;
|-&lt;br /&gt;
| 0x208&lt;br /&gt;
| 0x8&lt;br /&gt;
| Size of the entire NCA.&lt;br /&gt;
|-&lt;br /&gt;
| 0x210&lt;br /&gt;
| 0x8&lt;br /&gt;
| titleID&lt;br /&gt;
|-&lt;br /&gt;
| 0x218&lt;br /&gt;
| 0x4&lt;br /&gt;
| contentIndex&lt;br /&gt;
|-&lt;br /&gt;
| 0x21C&lt;br /&gt;
| 0x4&lt;br /&gt;
| sdk_version. byte0 is normally 0? Compared with a required minimum-value(0x000B0000). Matches this string from codebin: &amp;quot;FS_ACCESS: { sdk_version: {byte3}.{byte2}.{byte1}, ...&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| 0x220&lt;br /&gt;
| 0x1&lt;br /&gt;
| Crypto-Type2. Selects which crypto-sysver to use. 0x3 = [[3.0.1]], 0x4 = [[4.0.0]], 0x5 = [[5.0.0]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x230&lt;br /&gt;
| 0x10&lt;br /&gt;
| Rights ID ([[Ticket]])&lt;br /&gt;
|-&lt;br /&gt;
| 0x240&lt;br /&gt;
| 0x10*0x4(0x40)&lt;br /&gt;
| Table for each section, see below.&lt;br /&gt;
|-&lt;br /&gt;
| 0x280&lt;br /&gt;
| 0x20*0x4(0x80)&lt;br /&gt;
| Table of SHA256 hashes, over each 0x200-byte Section Header Block.&lt;br /&gt;
|-&lt;br /&gt;
| 0x300&lt;br /&gt;
| 0x10*0x4(0x40)&lt;br /&gt;
| Key area&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The header is 0x400-bytes, at NCA+0.&lt;br /&gt;
&lt;br /&gt;
When the above &amp;quot;Crypto Type&amp;quot; field is 0x2 on &amp;gt;=v3.0, different {crypto/keydata} is used for the sections&#039; data. With system content, this is used with every ncatype except ncatype0. The only other exception is {data-content} for the firm titles: this is required in order for older-system-versions to install it.&lt;br /&gt;
&lt;br /&gt;
Crypto-Type2 0x3(with the above crypto-type value) is used for all [[3.0.1]] sysmodules and the [[System_Version_Title]].&lt;br /&gt;
&lt;br /&gt;
With [[3.0.2]], all updated titles use the crypto from [[3.0.1]] for non-ncatype0, except for firm {data-content}.&lt;br /&gt;
&lt;br /&gt;
Note: in some cases various game content uses the above newer crypto as well.&lt;br /&gt;
&lt;br /&gt;
The keyindex passed to &amp;lt;key-generation-related code&amp;gt; is determined as follows:&lt;br /&gt;
* Pre-[[3.0.0]]: The ncahdr keyindex field(0x207) is passed directly.&lt;br /&gt;
* [[3.0.0]]+: It&#039;s determined using ncahdr keyindex(0x207) and &amp;quot;Crypto Type&amp;quot;(0x206). The latter field must be 0-2. In each ncahdr_keyindex block, it executes &amp;quot;if(ncahdr_x206&amp;gt;=3)&amp;lt;panic&amp;gt;&amp;quot;, but that won&#039;t trigger due to the earlier check. The end result is basically the same as pre-[[3.0.0]], except when ncahdr_x206 == 0x2, final_index is new_base_index+ncahdr_keyindex. Actual implementation loads index from u32_array[ncahdr_crypto_type], where the address of u32_array is different for each ncahdr_keyindex.&lt;br /&gt;
* [[3.0.1]]+: The dedicated range check for ncahdr_x206(&amp;quot;Crypto Type&amp;quot;) was removed, since the updated code no longer needs it. The output from a function masked with 0xFF is now used instead of ncahdr_x206(ncahdr_crypto_type). The range check for that field was changed from {ncahdr_x206 check with panic described above}, to &amp;quot;if(index&amp;gt;=4)final_index=10;&amp;quot;(skips accessing the array and uses 10 directly). The arrays were updated with an additional entry: final_index=v301_base_index+ncahdr_keyindex.&lt;br /&gt;
** The keydata for the above index10 is not(?) known to be initialized.&lt;br /&gt;
** The new function called by the code described above does:&lt;br /&gt;
** &amp;lt;code&amp;gt;if(ncahdr_x206 &amp;lt; ncahdr_x220){ret = ncahdr_x220; } else { ret = ncahdr_x206; } return ret;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Section Table Entry==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x4&lt;br /&gt;
| Media offset&lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x4&lt;br /&gt;
| Media end-offset&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x4&lt;br /&gt;
| Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 0xC&lt;br /&gt;
| 0x4&lt;br /&gt;
| Unknown&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Entry size is 0x10-bytes.&lt;br /&gt;
&lt;br /&gt;
Media offset is absoluteoffset/{mediasize}, where mediasize is hard-coded to 0x200.&lt;br /&gt;
&lt;br /&gt;
=Section Header Block=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x2&lt;br /&gt;
| Version. Always 0x2&lt;br /&gt;
|-&lt;br /&gt;
| 0x2&lt;br /&gt;
| 0x1&lt;br /&gt;
| Filesystem Type. 0x0 = RomFS. 0x1 = PFS0&lt;br /&gt;
|-&lt;br /&gt;
| 0x3&lt;br /&gt;
| 0x1&lt;br /&gt;
| Hash Type. 0x2 = PFS0. 0x3 = RomFS&lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x1&lt;br /&gt;
| Crypto type. 0 and &amp;gt;4 are invalid. 1 = none(plaintext from raw NCA). 2 = other crypto. 3 = regular crypto. 4 = unknown.&lt;br /&gt;
|-&lt;br /&gt;
| 0x5&lt;br /&gt;
| 0x1&lt;br /&gt;
| Padding?&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0xF8&lt;br /&gt;
| FS-specific superblock.&lt;br /&gt;
|-&lt;br /&gt;
| 0x100&lt;br /&gt;
| ?&lt;br /&gt;
| Optional BKTR header. Can be used with any section, but only known to be used with game-updates RomFS.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The Section Header Block for each section is at absoluteoffset+0x400+(sectionid*0x200), where sectionid corresponds to the index used with the entry/hash tables.&lt;br /&gt;
&lt;br /&gt;
The total size is 0x200-bytes.&lt;br /&gt;
&lt;br /&gt;
==PFS0 superblock==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x20&lt;br /&gt;
| SHA256 hash over the hash-table at section-start+0 with the below hash-table size.&lt;br /&gt;
|-&lt;br /&gt;
| 0x20&lt;br /&gt;
| 0x4&lt;br /&gt;
| Block size in bytes.&lt;br /&gt;
|-&lt;br /&gt;
| 0x24&lt;br /&gt;
| 0x4&lt;br /&gt;
| Must be 0x2.&lt;br /&gt;
|-&lt;br /&gt;
| 0x28&lt;br /&gt;
| 0x8&lt;br /&gt;
| Offset of hash-table. Normally zero?&lt;br /&gt;
|-&lt;br /&gt;
| 0x30&lt;br /&gt;
| 0x8&lt;br /&gt;
| Size of hash-table.&lt;br /&gt;
|-&lt;br /&gt;
| 0x38&lt;br /&gt;
| 0x8&lt;br /&gt;
| Offset relative to section-start where the PFS0 header is located.&lt;br /&gt;
|-&lt;br /&gt;
| 0x40&lt;br /&gt;
| 0x8&lt;br /&gt;
| Actual byte-size of the PFS0 filesystem relative to the PFS0 header.&lt;br /&gt;
|-&lt;br /&gt;
| 0x48&lt;br /&gt;
| 0xB0&lt;br /&gt;
| Normally zeros.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==RomFS superblock==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0xE0&lt;br /&gt;
| IVFC header. Basically the same as [[Savegames]] IVFC except with 2 more levels and +0x0C is non-zero, see below.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This documents the structure of Section Header Block +0 for RomFS.&lt;br /&gt;
&lt;br /&gt;
=== IVFC ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Start&lt;br /&gt;
! Length&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x00&lt;br /&gt;
| 4&lt;br /&gt;
| Magic (&amp;quot;IVFC&amp;quot;)&lt;br /&gt;
|-&lt;br /&gt;
| 0x04&lt;br /&gt;
| 4&lt;br /&gt;
| Magic Number (0x20000)&lt;br /&gt;
|-&lt;br /&gt;
| 0x08&lt;br /&gt;
| 4&lt;br /&gt;
| Master hash size?&lt;br /&gt;
|-&lt;br /&gt;
| 0x0C&lt;br /&gt;
| 4&lt;br /&gt;
| Usually 7? Unknown, could be related to total number of levels maybe?&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 8&lt;br /&gt;
| Level 1 offset&lt;br /&gt;
|-&lt;br /&gt;
| 0x18&lt;br /&gt;
| 8&lt;br /&gt;
| Level 1 size&lt;br /&gt;
|-&lt;br /&gt;
| 0x20&lt;br /&gt;
| 4&lt;br /&gt;
| Level 1 block size, in log2&lt;br /&gt;
|-&lt;br /&gt;
| 0x24&lt;br /&gt;
| 4&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x28&lt;br /&gt;
| 8&lt;br /&gt;
| Level 2 offset&lt;br /&gt;
|-&lt;br /&gt;
| 0x30&lt;br /&gt;
| 8&lt;br /&gt;
| Level 2 size&lt;br /&gt;
|-&lt;br /&gt;
| 0x38&lt;br /&gt;
| 4&lt;br /&gt;
| Level 2 block size, in log2.&lt;br /&gt;
|-&lt;br /&gt;
| 0x3C&lt;br /&gt;
| 4&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x40&lt;br /&gt;
| 8&lt;br /&gt;
| Level 3 offset&lt;br /&gt;
|-&lt;br /&gt;
| 0x48&lt;br /&gt;
| 8&lt;br /&gt;
| Level 3 size&lt;br /&gt;
|-&lt;br /&gt;
| 0x50&lt;br /&gt;
| 4&lt;br /&gt;
| Level 3 block size, in log2.&lt;br /&gt;
|-&lt;br /&gt;
| 0x54&lt;br /&gt;
| 4&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x58&lt;br /&gt;
| 8&lt;br /&gt;
| Level 4 offset&lt;br /&gt;
|-&lt;br /&gt;
| 0x60&lt;br /&gt;
| 8&lt;br /&gt;
| Level 4 size&lt;br /&gt;
|-&lt;br /&gt;
| 0x68&lt;br /&gt;
| 4&lt;br /&gt;
| Level 4 block size, in log2.&lt;br /&gt;
|-&lt;br /&gt;
| 0x6C&lt;br /&gt;
| 4&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x70&lt;br /&gt;
| 8&lt;br /&gt;
| Level 5 offset&lt;br /&gt;
|-&lt;br /&gt;
| 0x78&lt;br /&gt;
| 8&lt;br /&gt;
| Level 5 size&lt;br /&gt;
|-&lt;br /&gt;
| 0x80&lt;br /&gt;
| 4&lt;br /&gt;
| Level 5 block size, in log2.&lt;br /&gt;
|-&lt;br /&gt;
| 0x84&lt;br /&gt;
| 4&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x88&lt;br /&gt;
| 8&lt;br /&gt;
| Level 6 offset&lt;br /&gt;
|-&lt;br /&gt;
| 0x90&lt;br /&gt;
| 8&lt;br /&gt;
| Level 6 size&lt;br /&gt;
|-&lt;br /&gt;
| 0x98&lt;br /&gt;
| 4&lt;br /&gt;
| Level 6 block size, in log2.&lt;br /&gt;
|-&lt;br /&gt;
| 0x9C&lt;br /&gt;
| 4&lt;br /&gt;
| Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0xA0&lt;br /&gt;
| 32&lt;br /&gt;
| Unknown, reserved?&lt;br /&gt;
|-&lt;br /&gt;
| 0xC0&lt;br /&gt;
| 32&lt;br /&gt;
| Hash&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== BKTR ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Start&lt;br /&gt;
! Length&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| Offset&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x8&lt;br /&gt;
| Size&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x4&lt;br /&gt;
| &amp;quot;BKTR&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| 0x14&lt;br /&gt;
| 0x4&lt;br /&gt;
| u32, must be &amp;lt;=1.&lt;br /&gt;
|-&lt;br /&gt;
| 0x18&lt;br /&gt;
| 0x4&lt;br /&gt;
| s32, must be &amp;gt;=1.&lt;br /&gt;
|-&lt;br /&gt;
| 0x1C&lt;br /&gt;
| 0x4&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x20&lt;br /&gt;
| 0x20&lt;br /&gt;
| Same as the above 0x20-bytes except with different data.&lt;br /&gt;
|-&lt;br /&gt;
| 0x40&lt;br /&gt;
| 0x4?&lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| 0x44&lt;br /&gt;
| 0x4?&lt;br /&gt;
| ?&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Using this header is enabled when offset 0x8 in this header is non-zero.&lt;br /&gt;
&lt;br /&gt;
The above byte-offsets are relative to the start of the section-data.&lt;br /&gt;
&lt;br /&gt;
The two sections specified by the two BKTR entries are usually(?) at the very end of the section data(section_endoffset-{size of BKTR sections}).&lt;br /&gt;
&lt;br /&gt;
===RomFS Patching===&lt;br /&gt;
&lt;br /&gt;
The BKTR section enables combining data from an update NCA with the RomFS from a base NCA to create a single patched RomFS image. &lt;br /&gt;
&lt;br /&gt;
The first BKTR entry describes how to map regions of the two RomFS images to create the patched RomFS. It has the following format:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Start&lt;br /&gt;
! Length&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || 0x4 || Padding/Unused?&lt;br /&gt;
|-&lt;br /&gt;
| 0x4 || 0x4 || Number of Buckets&lt;br /&gt;
|-&lt;br /&gt;
| 0x8 || 0x8 || Total Size of the Virtual RomFS Image&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || 0x3FF0 || Base Virtual Offset for each Bucket (u64s, padded with 0s until end)&lt;br /&gt;
|-&lt;br /&gt;
| 0x4000 || 0x4000*X || Relocation Buckets&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Where relocation buckets are as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Start&lt;br /&gt;
! Length&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || 0x4 || Padding/Unused?&lt;br /&gt;
|-&lt;br /&gt;
| 0x4 || 0x4 || Number of Entries&lt;br /&gt;
|-&lt;br /&gt;
| 0x8 || 0x8 || End offset for this Bucket&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || 0x3FF0 || Relocation Entries&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Where relocation entries are as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Start&lt;br /&gt;
! Length&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || 0x8 || Address in Patched RomFS&lt;br /&gt;
|-&lt;br /&gt;
| 0x8 || 0x8 || Address in Source RomFS&lt;br /&gt;
|-&lt;br /&gt;
| 0x10  || 0x4 || 1=Is from Patch RomFS, 0=Is from Base RomFS&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The second BKTR entry describes the subsections within the Patch RomFS. It has the following format:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Start&lt;br /&gt;
! Length&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || 0x4 || Padding/Unused?&lt;br /&gt;
|-&lt;br /&gt;
| 0x4 || 0x4 || Number of Buckets&lt;br /&gt;
|-&lt;br /&gt;
| 0x8 || 0x8 || Total Size of the Physical Patch Image&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || 0x3FF0 || Base Physical Offset for each Bucket (u64s, padded with 0s until end)&lt;br /&gt;
|-&lt;br /&gt;
| 0x4000 || 0x4000*X || Subsection Buckets&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Where subsection buckets are as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Start&lt;br /&gt;
! Length&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || 0x4 || Padding/Unused?&lt;br /&gt;
|-&lt;br /&gt;
| 0x4 || 0x4 || Number of Entries&lt;br /&gt;
|-&lt;br /&gt;
| 0x8 || 0x8 || End offset for this Bucket&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || 0x3FF0 || Subsection Entries&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Where subsection entries are as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Start&lt;br /&gt;
! Length&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || 0x8 || Address in Patch RomFS&lt;br /&gt;
|-&lt;br /&gt;
| 0x8 || 0x4 || Padding/Unused?&lt;br /&gt;
|-&lt;br /&gt;
| 0xC  || 0x4 || Value for subsection AES-CTR&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Official code assumes the relocation entries are sorted, and performs a binary search when determining where to read from. Each subsection in the Patch RomFS has its CTR calculated separately from the others based on the value in its entry (the BKTR entries use normal crypto). Thus decrypting a Patch RomFS requires decrypting and parsing the BKTR entries before anything else.&lt;br /&gt;
&lt;br /&gt;
=Logo section=&lt;br /&gt;
This is a PFS0. See [[NCA_Content_FS|here]] for the mounted-FS logo contents.&lt;br /&gt;
&lt;br /&gt;
=ExeFS section =&lt;br /&gt;
This is a PFS0.&lt;br /&gt;
&lt;br /&gt;
See [[ExeFS|here]] for mounted-FS ExeFS contents.&lt;br /&gt;
&lt;br /&gt;
=Game-updates=&lt;br /&gt;
The section-data for ncatype1 RomFS section(section1) uses section-crypto-type 0x4.&lt;br /&gt;
&lt;br /&gt;
Game-updates also contain multiple ncatype6 content, which contain &amp;quot;section0_pfs0/fragment&amp;quot;. Some of these are just NCAs, unknown for the rest(presumably NCAs with additional crypto?). The first ncatype6 content fragment file has a NDV0 header, with the NCA starting at offset 0x44.&lt;br /&gt;
&lt;br /&gt;
=PFS0=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| {Hash-table offset from superblock}&lt;br /&gt;
| {Hash-table size from superblock}&lt;br /&gt;
| Table of SHA256 hashes.&lt;br /&gt;
|-&lt;br /&gt;
| {Hash-table &amp;lt;offset+size&amp;gt; from superblock}&lt;br /&gt;
| &lt;br /&gt;
| Zeros for alignment to {alignment size}.&lt;br /&gt;
|-&lt;br /&gt;
| {PFS0 offset from superblock}&lt;br /&gt;
| {PFS0 size from superblock}&lt;br /&gt;
| The actual PFS0.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is the FS which has magicnum &amp;quot;PFS0&amp;quot; at header+0. This is very similar to [[Gamecard_Format|HFS0]]. A tool for extracting this FS is available [https://gist.github.com/yellows8/1a96c2b846f4ebc4bb45d7f7fa1eb7db here].&lt;br /&gt;
&lt;br /&gt;
The hash table is hashes for every {Block size from superblock} starting at the PFS0 header. The size used for the last hash is {PFS0 filesystem size from superblock} - offset_relativeto_header.&lt;br /&gt;
&lt;br /&gt;
See also the PFS0 superblock above.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x4&lt;br /&gt;
| &amp;quot;PFS0&amp;quot; Magic&lt;br /&gt;
|-&lt;br /&gt;
| 0x4&lt;br /&gt;
| 0x4&lt;br /&gt;
| Number of files&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x4&lt;br /&gt;
| Size of the string table&lt;br /&gt;
|-&lt;br /&gt;
| 0xC&lt;br /&gt;
| 0x4&lt;br /&gt;
| Zero/Reserved&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| X&lt;br /&gt;
| File Entry Table&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 + X&lt;br /&gt;
| Y&lt;br /&gt;
| String Table&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 + X + Y&lt;br /&gt;
| Z&lt;br /&gt;
| Raw File Data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Where File Entry Table consists of Number of Files FileEntries:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Offset&lt;br /&gt;
! Size&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0&lt;br /&gt;
| 0x8&lt;br /&gt;
| Offset of file in Data&lt;br /&gt;
|-&lt;br /&gt;
| 0x8&lt;br /&gt;
| 0x8&lt;br /&gt;
| Size of file in Data&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| 0x4&lt;br /&gt;
| Offset of filename in String Table&lt;br /&gt;
|-&lt;br /&gt;
| 0x14&lt;br /&gt;
| 0x4&lt;br /&gt;
| Normally zero?&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Myster-Tee</name></author>
	</entry>
</feed>