Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:NCCH extended header

From ReverseEngineering.wiki
Format
On this wiki Facts · Code · Notes · Topics

The 0x400-byte extended header (ExHeader) of a 3DS executable NCCH (CXI), at offset 0x200 of the NCCH after the header, followed by a 0x400-byte access descriptor: the system control info (process name, compression flag, text/rodata/data segments, stack and bss size, dependency list, save data size) and the access control info (kernel and service permissions).

Location and size

In a CXI, ctrtool's CxiHeader places the 0x200-byte signature plus header at 0x000, the extended header at 0x200-0x5FF and the access control extended (the access descriptor) at 0x600-0x9FF (Fact:NCCH container/struct/Header for the NCCH header). The NCCH header's exhdr_size field (0x180) counts only the extended header; ctrtool's comment says it does not include the access descriptor that follows. So the 0x800 sometimes quoted for "the extended header" is the extended header (0x400) plus the descriptor (0x400).

The extended header itself is two 0x200-byte structures: the system control info and the access control info.

System control info (first 0x200 bytes)

See Fact:NCCH extended header/struct/System control info. It holds the 8-byte process (code set) name, a flags byte whose bit 0 says that the ExeFS .code file is compressed (see Format:ExeFS (3DS) and Format:Nintendo backward LZ (BLZ code compression)), the text, rodata and data segments (address, maximum page count, code size), the stack size and bss size, a list of 0x30 dependency program ids, the save data size and the jump id.

Access control info (second 0x200 bytes)

Unverified here: the full field layout. Azahar's ncch_container.h declares it as the ARM11 system-local capabilities (program id, core version, CPU flags, system mode, priority, resource limit, storage info, service access list), the ARM11 kernel capabilities and the ARM9 access control; I read only that outline. Enumerations that ctrtool declares for it are in Fact:NCCH extended header/enum/System modes.

The extended header is encrypted when the NCCH is; this wiki does not document decryption.

See also Library:Libctru (exheader.h) and Tool:3dstool (extendedheader.h).