Format:CRO
| On this wiki | Facts · Code · Notes · Topics |
|---|
CRO and CRS are the 3DS relocatable dynamic modules loaded by the RO service: a 0x138-byte header whose magic CRO0 sits at offset 0x80 (after four 0x20-byte hash slots), followed by 17 (offset, size-or-count) section entries for code, data, segment, export, import and relocation tables.
Header
See Fact:CRO/struct/Header and Fact:CRO/magic/CRO0 at 0x80. All fields are little endian. The first 0x80 bytes are four 0x20-byte hash slots (ctrtool names the array hash_table); the magic CRO0 is at 0x80, followed by name offset, two list-pointer words that the RO service fills while loading, file size, bss size, two words ctrtool leaves unnamed, four core-function segment offsets, and 17 section entries (u32 offset, u32 size or count). The whole header is 0x138 bytes.
The sections are listed in Fact:CRO/enum/Section index; relocation and import patches use the 12-byte entries of Fact:CRO/enum/Patch types.
Loaded state
Azahar's CROHelper addresses header fields as 32-bit words starting at module address + 0x80, and after it "fixes" a module (drops the import/relocation tables to save memory) it rewrites the magic to FIXD (Fact:CRO/magic/CRO0 at 0x80). A dumped module from a running process may therefore carry FIXD instead of CRO0.
Not covered
Unverified: how a CRS (the static module) differs from a CRO beyond the comment in ctrtool's cro.h that core-function index 0 is 0xFFFFFFFF in a CRS; the retail signature file for modules (CRR) and the file extensions .cro/.crs were not read in a source.
Unverified: the meaning of the two unnamed header words (unk0, unk1 in ctrtool); azahar names them FixedSize and UnknownZero in its word list, which suggests the first holds the size after fixing, but I did not check that they are the same fields.
See also Platform:Nintendo 3DS, Format:NCCH container.