Changes

7,246 bytes added ,  00:50, 25 August 2013
add page eng.ver http://3dbrew.org/w/index.php?title=Extdata&oldid=7869
页面介绍了extdata的文件格式和加密方式。"extra data"记录在[[SD_Filesystem|SD card]]和[[Flash_Filesystem|NAND]]中的:
* nand/data/<ID>/extdata/<ExtdataID-High>
* sdmc/Nintendo 3DS/<ID0>/<ID1>/extdata/<ExtdataID-High>

(ExtdataID-High is always 00000000 for SD, and always 00048000 for NAND) Some titles can have Quota.dat stored in these directories. The directory-name for these directories is the ExtdataID-Low. Then there's a sub-directory 00000000, which contains the actual extdata. Size and number of files in this dir varies per title.
NAND stores the shared extdata and is structured exactly the same way, see [[Flash Filesystem]].

Extdata image 00000001 contains a VSXE partition for the FST, the actual file data is stored in the subsequent extdata images.

Regular apps can only mount SD extdata using the same extdataID which is stored in the [[NCCH#CXI|CXI]] exheader. Therefore, regular apps which have the exheader extdataID set to zero can't use extdata. This restriction doesn't apply for shared extdata with extdataID high bitmask 0x48000 stored on NAND. System apps with a certain access right can mount arbitrary extdata.
All NAND extdata is shared extdata, while all SD extdata is normal extdata. Thus, normal extdata doesn't exist on NAND, and shared extdata doesn't exist on SD. The extdataID high excluding that bitmask is always zero for shared extdata.

=== Encryption ===

These files are [[AES|encrypted]] with AES-CTR, the keyslot is initialized by [[nand/private/movable.sed|movable.sed]]. The same keyslot is used for the NAND/SD extdata MAC. The NAND extdata images are stored in cleartext. The WCHAR LowPath "/extdata/<ExtdataIDHigh>/<ExtdataIDLow>/<PathToImage>" text path is hashed with SHA-256, including the WCHAR null-terminator. A separate hash is used for Quota.dat. The base CTR seems to be then generated by XORing the calculated hash: CTRword[i] = Hashword[i] ^ Hashword[4+i].

The base CTR is fixed therefore the CTR never changes after each write. Thus it is possible to obtain some cleartext by XORing one file(like newly created extdata) with a newer file, where the newer file overwrote zeros in the original file with non-zero data.

=== Filesystem ===

Title extdata contains a series of extdata images which comprise an independent file system. The first image (00000001) contains the VSXE (FST) partition, and subsequent images each containing a single file. Non-title extdata, usually contain single files, or a [[Title Database|database]].
Quota.dat is an extdata image, however it's unknown what this is used for.

'''QUOT'''

* This is contained in the Quota.dat extdata image.

{| class="wikitable"
|-
! Start
! Length
! Description
|-
| 0x0
| 4
| Magic ("QUOT")
|-
| 0x4
| 4
| Magic Number (0x30000)
|-
| 0x8
| 8
| Unknown
|-
| 0x10
| 0x38
| Unknown
|}

==== Filesystem structure ====

When extdata is created, these are *always* created regardless of whether the title actually uses them.
User extdata and SpotPass extdata use separate [[FS:OpenArchive|mount]] points at /user and /boss. Therefore one mount can't access the other directory, and also can't access /icon.(The title's SpotPass extdata can be mounted by the title itself, if it uses SpotPass)

* /icon This file contains the extdata [[SMDH|icon]] displayed in data management. This icon can only be written to by titles when creating extdata, titles would have to recreate extdata to change the icon. This file can't be read directly, instead it is read via [[FS:ReadExtSaveDataIcon]].
* /user/ Contains the title's actual extdata files.
* /boss/ Can contain [[SpotPass]] content. SpotPass content can only be downloaded to this /boss directory.

* /user/ExBanner This directory can optionally store [[Extended_Banner| extended banners]]. When this is available, this banner is displayed instead of the [[CXI]] ExeFS banner. COMMON.bin stores the common exbanner, while <regionlang_code>.bin stores an optional separate region/language specific banner.(regionlang_code can be "JPN_JP", "USA_EN", etc)

=== SD Extdata ===
Usually the ExtdataID low is in the format '00<Unique ID>'

{| class="wikitable" border="1"
|-
! JPN ExtdataID
! USA ExtdataID
! EUR ExtdataID
! Description
! Extdata images
|-
| 00000082
| 0000008f
| 00000098
| Homemenu extdata, this contains home-menu savedata and cached icons for applications.
|
|-
| 00000200
| 00000210
| 00000220
| [[System_Settings|System Settings]] extdata added with [[2.0.0-2]].
|
|-
| 00000207
| 00000217
| 00000227
| Mii Maker, contains an ExBanner
| [https://dl.dropbox.com/u/20520664/extdata00000217.zip cleartext]
|-
| 00000208
| 00000217
| 00000228
| Streetpass Mii Plaza
| 11 mb big!
|-
| 00000209
| 00000219
| 00000229
| eShop
|
|-
| 0000020d
| 0000021d
| 0000022d
| Face Raiders, likely contains an ExBanner
|
|-
| 0000020b
| 0000021b
| 0000022b
| Nintendo Zone
|
|-
| ?
| 000004aa
| 000004ab
| Nintendo Video Extra Data
This is where the video files are stored, and [[Nintendo_Video|includes]] the thumbnail, the description, and possibly some checksum info in each video file stored in the extdata images. There are always 9 files within the subdirectory "00000000" of this folder, even without any videos downloaded. The files are "00000001" - "00000009", and "00000003" - "00000008" have the same filesize of 50.7 MB. It is possible to restore the older videos by overwriting all the files within this directory. Provided of course you have made a backup of the files before hand, by copying all the files within this directory to your computer. As far I'm aware its not possible to mix and match the files in order to get certain videos in one grouping, ie. having all 3 Zelda orchestral recordings in one group of 4 Nintendo videos.
|
|-
|?
|00000308
|00000307
|Mario Kart 7
|
|-
| 0000030b
| 0000030d
| 0000030c
| Nintendogs + Cats
|
|-
| ?
| 00000326
| 00000326
| Pokédex 3D
|
|-
| 00000305
| 0000032d
| 0000033c
| Super Street Fighter IV 3D
|
|-
| 00000328
| 00000358
| 0000033b
| Ridge Racer 3D
|
|-
| ?
| 0000034d
| 00000402
| Samurai Warriors Chronicles
|
|-
| ?
| 0000034f
| 0000038a
| Dead or Alive Dimensions
|
|-
| 00000481
| N/A
| N/A
| Monster Hunter Tri G (Download-Quests)
|
|-
| ?
| ?
| 00000a86
| Professor Layton and the Miracle Mask
|
|-
| ?
| ?
| 00000c24
| Denpa men
|
|-
| ?
| 00000c73
| 00000c73
| Save Data Transfer Tool
|
|-
| ?
| ?
| 00000d9a
| Donkey Kong Country Returns 3d Trailer
|
|}

=== NAND Shared Extdata ===
{| class="wikitable" border="1"
|-
! ExtdataID
! Description
|-
| 0xf0000001
| NAND JPEG/MPO files and phtcache.bin from the camera application are stored here. This also contains UploadData.dat.
|-
| 0xf0000002
| NAND M4A files from the sound application are stored here
|-
| 0xf0000009
| ?
|-
| 0xf000000b
| Contains idb.dat, idbt.dat, gamecoin.dat, ubll.lst, CFL_DB.dat, and CFL_OldDB.dat. These files contain cleartext [[Mii_Maker|Miis]] and some data relating (including cached ICN data) to Play/Usage Records.
|-
| 0xf000000c
| Contains bashotorya.dat and bashotorya2.dat.
|-
| 0xf000000d
| ?
|}

=== Tools ===

* [https://github.com/ps3hen/ctr_toolkit/tree/master/extdata_tool extdata_tool] - Extract standalone extdata images, aswell as title extdata FS.
155

edits