Line 82: |
Line 82: |
| The final CMAC key used for this is generated using GenerateAesKek with a kek source and the device key, along with and LoadAesKey and a set key seed. | | The final CMAC key used for this is generated using GenerateAesKek with a kek source and the device key, along with and LoadAesKey and a set key seed. |
| | | |
− | ==== DISF ====
| + | === DISF === |
| | | |
| This section contains information about the structure of the save file. | | This section contains information about the structure of the save file. |
Line 265: |
Line 265: |
| |} | | |} |
| | | |
− | ==== DPFS ==== | + | === Duplex header === |
| | | |
− | * This is located @ 0x300 in the image, following DISF.
| + | * Block sizes are stored as powers of 2 |
− | * Block sizes are log2 | |
| | | |
| {| class="wikitable" | | {| class="wikitable" |
Line 286: |
Line 285: |
| | 0x08 | | | 0x08 |
| | 8 | | | 8 |
− | | Offset 0 | + | | Master bitmap offset |
| |- | | |- |
| | 0x10 | | | 0x10 |
| | 8 | | | 8 |
− | | Size 0 | + | | Master bitmap size |
| |- | | |- |
| | 0x18 | | | 0x18 |
| | 4 | | | 4 |
− | | Block Size 0, in log 2 | + | | Master bitmap block size power |
| |- | | |- |
| | 0x1C | | | 0x1C |
| | 8 | | | 8 |
− | | Offset 1 | + | | Level 1 offset |
| |- | | |- |
| | 0x24 | | | 0x24 |
| | 8 | | | 8 |
− | | Size 1 | + | | Level 1 size |
| |- | | |- |
| | 0x2C | | | 0x2C |
| | 4 | | | 4 |
− | | Block Size 1, in log 2 | + | | Level 1 block size power |
| |- | | |- |
| | 0x30 | | | 0x30 |
| | 8 | | | 8 |
− | | Offset 2 | + | | Level 2 offset |
| |- | | |- |
| | 0x38 | | | 0x38 |
| | 8 | | | 8 |
− | | Size 2 | + | | Level 2 size |
| |- | | |- |
| | 0x40 | | | 0x40 |
| | 4 | | | 4 |
− | | Block Size 2, in log 2 | + | | Level 2 block size power |
| |- | | |- |
| |} | | |} |
| | | |
− | ==== IVFC ==== | + | === Integrity verification header === |
| | | |
− | * Generally follows DPFS, similar to 3DS. | + | * Offsets for levels 1-3 come from the metadata remap storage |
| + | * Offsets for level 4 comes from the main data remap storage |
| + | * This is the same header used in NCA files |
| | | |
| {| class="wikitable" | | {| class="wikitable" |
Line 341: |
Line 342: |
| |- | | |- |
| | 0x08 | | | 0x08 |
− | | 8
| |
− | | Master hash size?
| |
− | |-
| |
− | | 0x10
| |
− | | 8
| |
− | | Level 1 offset
| |
− | |-
| |
− | | 0x18
| |
− | | 8
| |
− | | Level 1 size
| |
− | |-
| |
− | | 0x20
| |
| | 4 | | | 4 |
− | | Level 1 block size, in log2 | + | | Master hash size |
| |- | | |- |
− | | 0x24 | + | | 0xC |
| | 4 | | | 4 |
− | | Reserved | + | | Number of levels (Unused in save files) |
| |- | | |- |
− | | 0x28 | + | | 0x10 |
− | | 8 | + | | 0x18*6 |
− | | Level 2 offset | + | | Level information for up to 6 levels |
| |- | | |- |
− | | 0x30 | + | | 0xA0 |
− | | 8 | + | | 32 |
− | | Level 2 size | + | | Salt seed |
| |- | | |- |
− | | 0x38 | + | |} |
− | | 4
| + | |
− | | Level 2 block size, in log2.
| + | ==== Level information ==== |
| + | |
| + | * 0x18 bytes long |
| + | * Block sizes are stored as powers of 2 |
| + | |
| + | {| class="wikitable" |
| |- | | |- |
− | | 0x3C
| + | ! Start |
− | | 4
| + | ! Length |
− | | Reserved
| + | ! Description |
| |- | | |- |
− | | 0x40 | + | | 0x00 |
| | 8 | | | 8 |
− | | Level 3 offset | + | | Offset |
| |- | | |- |
− | | 0x48 | + | | 0x08 |
| | 8 | | | 8 |
− | | Level 3 size | + | | Size |
| |- | | |- |
− | | 0x50 | + | | 0x10 |
| | 4 | | | 4 |
− | | Level 3 block size, in log2. | + | | Block size power |
| |- | | |- |
− | | 0x54 | + | | 0x14 |
| | 4 | | | 4 |
| | Reserved | | | Reserved |
− | |-
| |
− | | 0x58
| |
− | | 8
| |
− | | Level 4 offset
| |
− | |-
| |
− | | 0x60
| |
− | | 8
| |
− | | Level 4 size
| |
− | |-
| |
− | | 0x68
| |
− | | 4
| |
− | | Level 4 block size, in log2.
| |
− | |-
| |
− | | 0x6C
| |
− | | 4
| |
− | | Reserved
| |
− | |-
| |
− | | 0x70
| |
− | | 48
| |
− | | Unknown, reserved?
| |
− | |-
| |
− | | 0xA0
| |
− | | 32
| |
− | | Hash
| |
| |- | | |- |
| |} | | |} |
| | | |
− | ==== JNGL ==== | + | === Journal header === |
− | | |
− | * Generally follows IVFC
| |
| | | |
| {| class="wikitable" | | {| class="wikitable" |
Line 434: |
Line 402: |
| | 0x04 | | | 0x04 |
| | 4 | | | 4 |
− | | Magic Number (0x10000) | + | | Magic Number (0x10000 or less) |
| |- | | |- |
| | 0x08 | | | 0x08 |
| | 8 | | | 8 |
− | | Savedata Size | + | | Total size (Incl. journal) |
| |- | | |- |
| | 0x10 | | | 0x10 |
| | 8 | | | 8 |
− | | Unknown, Size | + | | Journal size |
| |- | | |- |
| | 0x18 | | | 0x18 |
| | 8 | | | 8 |
− | | Savedata Blocksize? | + | | Block size |
| |- | | |- |
| | 0x20 | | | 0x20 |
| | 4 | | | 4 |
− | | Unknown | + | | Unknown (Must be 0 or 1) |
| |- | | |- |
| | 0x24 | | | 0x24 |
| | 4 | | | 4 |
− | | Unknown | + | | Main data block count |
| |- | | |- |
| | 0x28 | | | 0x28 |
| | 8 | | | 8 |
− | | Unknown | + | | Journal block count |
| |- | | |- |
− | | 0x30 | + | | 0x200 |
− | | 464 | + | | |
− | | Padding? | + | | End |
| |- | | |- |
| |} | | |} |
| | | |
− | ==== SAVE ==== | + | === Save FS header === |
| | | |
− | * Generally follows JNGL, structure is different from 3DS. | + | * Structure is different than 3DS. |
| | | |
| {| class="wikitable" | | {| class="wikitable" |
Line 486: |
Line 454: |
| | 0x08 | | | 0x08 |
| | 8 | | | 8 |
− | | Unknown, number | + | | Number of blocks. Does not change if save file is resized. |
| |- | | |- |
| | 0x10 | | | 0x10 |
| | 8 | | | 8 |
− | | Unknown, block size | + | | Block Size |
| + | |- |
| + | | |
| + | | |
| + | | The below fields are read separately from the above fields |
| |- | | |- |
| | 0x18 | | | 0x18 |
| | 8 | | | 8 |
− | | Unknown, block size | + | | Block size |
| |- | | |- |
| | 0x20 | | | 0x20 |
| | 8 | | | 8 |
− | | Unknown | + | | FAT offset |
| + | |- |
| + | | 0x28 |
| + | | 4 |
| + | | FAT entry count |
| + | |- |
| + | | 0x2C |
| + | | 4 |
| + | | Padding |
| + | |- |
| + | | 0x30 |
| + | | 8 |
| + | | Data offset |
| + | |- |
| + | | 0x38 |
| + | | 4 |
| + | | Data block count |
| + | |- |
| + | | 0x3C |
| + | | 4 |
| + | | Padding |
| + | |- |
| + | | 0x40 |
| + | | 8 |
| + | | Directory table block index |
| + | |- |
| + | | 0x48 |
| + | | 8 |
| + | | File table block index |
| |- | | |- |
| |} | | |} |
| | | |
− | ==== RMAP ====
| + | === RMAP === |
| | | |
| * There are generally two RMAP blocks in sequence. | | * There are generally two RMAP blocks in sequence. |