Filesystem services: Difference between revisions

TimmSkiller (talk | contribs)
Rework system savedata + (shared) extdata path formats
TimmSkiller (talk | contribs)
 
(26 intermediate revisions by the same user not shown)
Line 946: Line 946:
|-
|-
| 0x12345680
| 0x12345680
| Used for transferring [[Extdata#NAND_Shared_Extdata|NAND Shared Extdata]] during [[System_Transfer#System_Save_Data_Transfer|system tranfers]].
| Extdata transfer. Used for transferring [[Extdata#NAND_Shared_Extdata|NAND Shared Extdata]] during [[System_Transfer#System_Save_Data_/_Shared_Extdata_Transfer|system tranfers]].
| Yes
| Yes
| Yes
| Yes
Line 954: Line 954:
|-
|-
| 0x12345681
| 0x12345681
| Used for transferring [[System_SaveData|System Save Data]] during [[System_Transfer#System_Save_Data_Transfer|system tranfers]].
| System Savedata transfer. Used for transferring [[System_SaveData|System Save Data]] during [[System_Transfer#System_Save_Data_/_Shared_Extdata_Transfer|system tranfers]].
| Yes
| Yes
| Yes
| Yes
Line 964: Line 964:
| Unknown. There's code for this in spider v9.9, but that code isn't actually used.
| Unknown. There's code for this in spider v9.9, but that code isn't actually used.
| Yes
| Yes
| ?
| No
| No
| No
| Yes
| Yes
Line 1,002: Line 1,002:
|-
|-
| 0x2345678E
| 0x2345678E
| FSPXI: Similar to archive 0x2345678A. For fs:LDR(used by the "loader" FIRM ARM11-process), only ExeFS. Not accessible with fs:USER.
| FSPXI: Program Access (limited subset of merged main title + update/patch title access). For fs:LDR(used by the "loader" FIRM ARM11-process), only <code>exefs:/.code</code>. Not accessible with fs:USER.
| Yes
| Yes
| Yes
| Yes
Line 1,050: Line 1,050:
|-
|-
| 0x567890B0
| 0x567890B0
| ?
| Internally creates the same "ID Storage" wrapper over the NAND that is used for SystemSaveData and Shared ExtData, but all operations are stubbed and return 0xE0C046F8.
| No
| No
| Yes
| Yes
Line 1,072: Line 1,072:
| Yes
| Yes
| 0x6
| 0x6
|-
| 0x567890B3
| [[3DS_Virtual_Console#NAND_Savegame|AGB Save Data]]
| No
| No
| Yes
| No
| -
|-
|-
| 0x567890B4
| 0x567890B4
Line 1,120: Line 1,128:
== Binary LowPath ==
== Binary LowPath ==
The format of the data that a binary LowPath points to is custom per archive.
The format of the data that a binary LowPath points to is custom per archive.
=== SelfNCCH File Path Data Format ===
{| class="wikitable" border="1"
|-
!  Index word
!  Description
|-
| 0
| Type:
* 0x0: RomFS
* 0x1: error 0xD9004676
* 0x2: ExeFS
* 0x3: Error 0xE0E046BE.
* 0x4: FS-module crashes on this
* 0x5: Update RomFS?
|-
| 1-2
| File name for ExeFS ("icon"/"banner"/"logo"). ".code" is not allowed
|}
Note that ExeFS files only support reading from offset=0 and with size=file_size.


=== SystemSaveData / Extdata / Shared Extdata Archive Path Data Format ===
=== SystemSaveData / Extdata / Shared Extdata Archive Path Data Format ===
Line 1,161: Line 1,148:
| 1 || Accesses from/to <code>nand:/fixdata</code>
| 1 || Accesses from/to <code>nand:/fixdata</code>
|-
|-
| 2 || Accesses from/to <code>nand:/data/<ID0 from source console's [[Filesystem_services#DeviceMoveContext|Device Move Context]]></code>
| 2 || Accesses from/to <code>nand:/data/<ID0 from [[Filesystem_services#DeviceMoveContext|Device Move Context]]></code>
|}
|}
|-
|-
Line 1,181: Line 1,168:
|-
|-
| 1
| 1
| save ID low (save ID high is usually 0)
| save ID low (save ID high is 0)
|}
|}


Line 1,277: Line 1,264:
|}
|}


=== 0x2345678A Archive Path Data Format ===
=== Title Access Archive Path Data Format ===
==== Title Access Type ====
{| class="wikitable" border="1"
|-
! Value !! Description
|-
| 0 || High-level NCCH content access
|-
| 1 || Save data access (high-level, decrypted)
|-
| 2 || Raw content (low-level NCCH/SRL) access
|-
| 3 || Banner save data access (for DSiWare titles)
|-
| 4 || FS only: Save data transfer (internally uses generated data from [[FS:BeginSaveDataMove]] as the IV for "Save data access (low-level, encrypted)")
|-
| 5 || Save data access (low-level, encrypted)
|}
 
==== NCCH Access Type ====
{| class="wikitable" border="1"
|-
! Value !! Description
|-
| 0 || RomFS
|-
| 1 || <code>exefs:/.code</code>
|-
| 2 || System Menu Data (<code>exefs:/icon</code>, <code>exefs:/banner</code>, <code>exefs:/logo</code>)
|-
| 3 || NCCH Header(s)
|-
| 4 || "is seeded" check
|-
| 5 || Seed verify/validate
|}
 
==== NCCH Header Access Type ====
{| class="wikitable" border="1"
|-
! Value !! Description
|-
| 0 || [[NCCH/Extended_Header|Extheader]] (0x0-0x400)
|-
| 1 || [[NCCH/Extended_Header|Extheader]] AccessDesc (0x400-0x800)
|-
| 2 || Raw [[NCCH#NCCH_Header|NCCH Header]]
|}
 
==== Archive Path ====
 
{| class="wikitable" border="1"
|-
! Offset !! Size !! Description
|-
| 0x0 || 0x8 || Program ID (Title ID)
|-
| 0xB || 0x1 || [[Mediatypes|Media Type]]
|-
| 0xC || 0x4 || padding
|}
 
==== File Path ====
 
{| class="wikitable" border="1"
|-
! Offset !! Size !! Description
|-
| 0x0 || 0x4 || [[Filesystem_services#Title_Access_Type|Title Access Type]]
|-
| 0x4 || 0x10 || Dynamic data depending on [[Filesystem_services#Title_Access_Type|Title Access Type]]:
 
{| class="wikitable" border="1"
|-
! High Level NCCH Access !! Save Data Access (high level) !! Raw Content !! FS only: Save Data Transfer
|-
|
{| class="wikitable" border="1"
|-
! Offset !! Size !! Description
|-
| 0x0 || 0x4 || Content index from TMD for NAND/SD titles
NCSD partition index for gamecards
|-
| 0x4 || 0x4 || [[Filesystem_services#NCCH_Access_Type|NCCH Access Type]]
|-
| 0x8 || 0x8 || Dynamic data depending on [[Filesystem_services#NCCH_Access_Type|NCCH Access Type]]:
For ExeFS, (System Menu Data / <code>exefs:/.code</code>),
 
{| class="wikitable" border="1"
| 8-byte ExeFS file name
|}
 
For Header Access,
 
{| class="wikitable" border="1"
| [[Filesystem_services#NCCH_Header_Access_Type|u64, NCCH Header Access Type]]
|}
 
For RomFS,
 
{| class="wikitable" border="1"
| [[NCCH#Content_Types|u64, Allowed content types flag]]
(<code>(1 << allowed_type_a) |
 
(1 << allowed_type_b)...</code>)
|}
 
|}
|
{| class="wikitable" border="1"
|-
! Offset !! Size !! Description
|-
| 0x0 || 0x10 || 16-byte IV for save data crypto
|}
|
{| class="wikitable" border="1"
|-
! Offset !! Size !! Description
|-
| 0x0 || 0x4 || Content index from TMD for NAND/SD titles
NCSD partition index for gamecards
|-
| 0x4 || 0xC || padding
|}
|
{| class="wikitable" border="1"
|-
! Offset !! Size !! Description
|-
| 0x0 || 0x4 || Save data transfer key from [[FS:BeginSaveDataMove]]
|-
| 0x4 || 0xC || padding
|}
|}
|-
| 0x14 || 0x10 || 16-byte seed for titles that require one, or for validating a seed against the check value in the [[NCCH#NCCH_Header|NCCH Header]]'s check value.
If the title does not use a seed, this should not be included and size 0x14 should be used instead of 0x24.
|}
 
For encrypted save data access and banner save data access, the entire 0x10 portion of the dynamic data is left blank.
 
The "is seeded check" NCCH access type opens a virtual 1-byte file that reads either 0 or 1; this value is generated on-the-fly and will be 1 if ncchflags[7] has bit5 set (content uses seed), and 0 otherwise.
 
For NCCH sections that require a seed (e.g. <code>.code</code>, RomFS, etc.), the additional seed portion of the low path must be populated with the correct seed.
 
The "Seed Verify/Validate" NCCH access type also requires the seed portion of the lowpath. The target NCCH content is opened (with the opened file interface being stubbed, meaning no real reads/writes can be performed on it), and the given seed is used to calculate the seed check hash, and part of it is compared to the check value in the NCCH header. If it matches, opening the "file" succeeds, otherwise 0xD900458C is returned. If attempt is made to use the seed validation type on a content that does not use a seed, error 0xC92044E6 is returned.
 
==== FS Limitations ====
 
For FS, this archive functions the same, except for the following limitations:
 
- Only the title access types "High Level NCCH Access" and "High Level Save Data Access", and "Save Data Transfer" are allowed.
 
- For high level NCCH access, the types "RomFS", "System Menu Data", "Seeded check", and "Seed Check/Verify" are allowed.
 
- For "Seed Check/Verify", rather than providing the title seed in the file path (as is the case for FSPXI), the seed is retrieved from the seed database (meaning the file lowpath size is always 0x14 for FS).
 
=== Program Access / SelfNCCH access ===
 
Provides access to a "merged" archive of a base title and, optionally, a separate update (patch) title.
 
If no patch title exists, the base title is considered to be the patch title, i.e. turning all "patch" accesses into accesses to the base title.
 
==== Program Access Type ====
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
! Index word
! Value !! Description !! Accesses
! Description
|-
| 0 || RomFS ("unspecified" [[NCCH#Content_Type|content type]], the default) || Base title
|-
| 1 || <code>exefs:/.code</code> || Patch title
|-
| 2 || System Menu Data (<code>exefs:/icon</code>, <code>exefs:/banner</code>, <code>exefs:/logo</code>) || Base title
|-
| 3 || Save Data (high level, decrypted) || -
|-
|-
| 0
| 4 || RomFS (all [[NCCH#Content_Type|content types]]) || Base title
| Lower word programID
|-
|-
| 1
| 5 || RomFS ("unspecified" [[NCCH#Content_Type|content type]], the default) || Patch title
| Upper word programID
|}
 
==== Archive Path ====
{| class="wikitable" border="1"
|-
|-
| 2
! Offset !! Size !! Description
| ([[Mediatypes|Mediatype]] & 0xFF) | (uninitialized_data? & 0xFFFFFF00)
|-
|-
| 3
| 0x0 || 0x8 || u64, Program Handle from [[PXIPM:RegisterProgram]]
| Number of something? Hardcoded per-archive, 0 for ExeFS, 200 for area:, 100 for rate:, 40 for eula:, etc.
|}
|}


File lowpath:
==== File Path ====
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
! Index word
! Offset !! Size !! Description
! Description
|-
| 0x0 || 0x4 || [[Filesystem_services#Program_Access_Type|Program Access Type]]
|-
| 0x4 || 0x8 || Dynamic data depending on [[Filesystem_services#Program_Access_Type|Program Access Type]]:
{| class="wikitable" border="1"
|-
! ExeFS files (System Menu Data, etc.) !! RomFS of base title (all [[NCCH#Content_Type|content types]])
|-
|-
| 0
|
| 0 for NCCH data, 1 for savedata. The latter is only valid for FSPXI. Value 2 is allowed via archive 0x3, it's unknown what this is.
{| class="wikitable" border="1"
| 8-character ExeFS filename
|}
|
{| class="wikitable" border="1"
|-
|-
| 1
! Offset !! Size !! Description
| TMD content index / NCSD partition index.
|-
|-
| 2
| 0x0 || 0x4 || u32, content index of target content
| Type: 0=romfs(0 for non-NCCH as well), 1=exefs ".code"(?), 2=exefs "icon"/"banner"/"logo", 3=unknown, 4=unknown, 5=unknown.
|-
|-
| 3-4
| 0x4 || 0x4 || padding
| Filename for ExeFS.
|}
|}
|}
|}


The 0x14-byte lowpath is all-zero for accessing the title's main RomFS.
==== FS Limitations ====
 
- FSPXI allows all access types.
 
- When used through fs:LDR by loader, FS only provides access to <code>exefs:/.code</code>.
 
- For SelfNCCH access, the only allowed access types are "RomFS ("unspecified" [[NCCH#Content_Type|content type]], the default)" of the Base or Patch title, and "System Menu Data". Attempting to access "Save Data" results in error 0xE0E046BE, "RomFS (all [[NCCH#Content_Type|content types]])" in 0xF9604784, and "<code>exefs:/.code</code>" in 0xD9004676.


=== [[RomFS]] ===
=== [[RomFS]] ===
Line 1,568: Line 1,742:
|-
|-
| 0x0
| 0x0
| 0x1
| 0x4
| [[Filesystem_services#MediaType|Media Type]]
| [[Filesystem_services#DataAccessPath|DataAccessPath]]
|-
| 0x1
| 0x1
| Unknown
|-
| 0x2
| 0x2
| Reserved
|-
|-
| 0x4
| 0x4
Line 1,596: Line 1,762:
|-
|-
| 0x0
| 0x0
| 0x1
| 0x4
| [[Filesystem_services#MediaType|Media Type]]
| [[Filesystem_services#DataAccessPath|DataAccessPath]]
|-
| 0x1
| 0x1
| Unknown
|-
| 0x2
| 0x2
| Reserved
|-
|-
| 0x4
| 0x4
Line 1,749: Line 1,907:
|  0x0
|  0x0
|  0x10
|  0x10
|  IVs
|  IVs (ID0 of source console)
|-
|-
|  0x10
|  0x10
|  0x10
|  0x10
|  Encrypt Parameter
|  Encrypt Parameter (used to calculate the IV for encryption)
|}
|}