Title Database: Difference between revisions

Wwylele (talk | contribs)
Redirect extdata to DIFF format; Remove dead link
TimmSkiller (talk | contribs)
Restructure a bit to have a proper ToC
 
(8 intermediate revisions by 3 users not shown)
Line 69: Line 69:
|-
|-
| 0x08
| 0x08
| 0x78
| 0x4
| Version (always 0)
|-
| 0xC
| 0x74
| Reserved
| Reserved
|}
|}


For ticket.db different pre header is used:
For ticket.db, a different pre-header is used:


{| class="wikitable"
{| class="wikitable"
Line 87: Line 91:
| 0x04
| 0x04
| 0x04
| 0x04
| Unknown (always 0x00000001 ?)
| Version (always 1)
|-
|-
| 0x08
| 0x08
| 0x04
| 0x08
| Unknown
| Reserved
|-
| 0x0C
| 0x04
| Unknown (0x30 smaller than previous one)
|}
|}


Line 125: Line 125:
| SD Card title.db
| SD Card title.db
| TEMPTDB
| TEMPTDB
|-
| (unused, likely supposed to be SD card import.db)
| SDMCIDB
|}
|}


== BDRI ==
== BDRI ==


Information stored about titles in these Title Database files are stored in two parts in a BDRI partition. Firstly in a Title Entry Table, and secondly in a Title Info Table.
This is a variant of [[Inner FAT|FAT filesystem]]. It consists one "root" directory and multiple "files". Each "file" is one title info entry described below.
 
=== Title Info Entry ===
 
An entry contains information taken from both the application NCCH file(s) and TMD.


{| class="wikitable"
{| class="wikitable"
|-
|-
! Start
! Start !! Length !! Description
! Length
! Description
|-
| 0x0
| 4
| Database Magic ("BDRI")
|-
| 0x4
| 4
| File Format Version (0x30000)
|-
| 0x8
| 8
| Unknown
|-
| 0x10
| 8
| File Size (including pre header), in blocks (see next field)
|-
|-
| 0x18
| 0x0 || 0x8 || u64, Title Size
| 4
| Block Size (Usually 0x80; 0x200 for ticket.db)
|-
|-
| 0x1C
| 0x8 || 0x4 || u32, Title Type from TMD (usually 0x40)
| 4
| Reserved
|-
|-
| 0x20
| 0xC || 0x2 || u16, Title Version
| 0x20
| Unknown/Constant
|-
|-
| 0x40
| 0xE || 0x2 || u16, Content index for Download Play Child content
| 0x18
| Unknown
|-
|-
| 0x58
| 0x10 || 0x2 || u16, Content index for Instruction Manual content
| 8
| Relative Title Entry Table Offset
|-
|-
| 0x60
| 0x12 || 0x2 || u16, Content index for Old3DS update partition (even though this is unused because digital titles don't have update partitions)
| 0x20
| Unknown
|}
 
== Title Entry Table ==
 
This contains 'Entries' for all the titles stored in the database. However this just appears to be an indexing table, the majority of title information is kept in a Title Info Table, which these index entries point to. Title Entries start immediately after the Title Entry Table Header. And there is no padding between entries.
 
=== Header ===
 
{| class="wikitable"
|-
|-
! Start
| 0x14 || 0x4 || TMD file ID (the ID part in <code>{ID}.tmd</code> inside the title folder)
! Length
! Description
|-
|-
| 0x0
| 0x18 || 0x4 || CMD file ID (the ID part in <code>{ID}.cmd</code> inside the title folder)
| 4
| Unknown/Magic? (usually = 0x2)
|-
|-
| 0x4
| 0x1C || 0x4 || save file ID (the ID part in <code>{ID}.sav</code> inside the title/data folder)
| 4
| Unknown/Magic? (usually = 0x3)
|-
|-
| 0x8
| 0x20 || 0x8 || u64, extdata ID (zero if title does not use extdata)
| 0x24
| Reserved
|-
|-
| 0x2C
| 0x28 || 0x1 || bool, has public.sav (DSiWare only)
| 4
| Number of used Title Entries
|-
|-
| 0x30
| 0x29 || 0x1 || bool, has private.sav (DSiWare only)
| X - 0x30
| Alignment padding for X = BDRI Block Size
|-
|-
| X
| 0x2A || 0x1 || bool, has banner.sav (DSiWare only)
| 4
| MAX Number of Title Entries
|-
|-
| X + 0x04
| 0x2B || 0x1 || bool, requires moving public/private/banner.new to public/private/banner.sav (DSiWare only) (see [[AMPXI:WriteTWLSavedata]])
| 4
| Unknown
|-
|-
| X + 0x08
| 0x2C || 0x1 || u8, CMD format version (see [[Titles#Data_Structure|Title Data Structure]])
| 0x20
| Reserved
|}
 
=== Title Entry Format ===
 
The entries are 0x2C bytes long.
 
{| class="wikitable"
|-
|-
! Start
| 0x2D || 0x1 || bool, is user DSiWare title (as in, does not have system title bit set, see [[Title_list#TWL_(DSi)_Titles|TWL (DSi) Titles]] for more information)
! Length
! Description
! ticket.db only
|-
|-
| 0x0
| 0x2E || 0x2 || u16, New3DS update partition content index (even though this is unused because digital titles don't have update partitions)
| 4
| Unknown
| Unknown (0)
|-
|-
| 0x4
| 0x30 || 0x10 || Product code (first 12 bytes of raw .nds for DSiWare, which is the game title)
| 4
| Active Flag. If this isn't = 0x1, then this entry slot is unused
| same
|-
|-
| 0x8
| 0x40 || 0x8 || u64, ordering number. Used in some code paths to find the "latest" added entry, but this value is never written and always 0.
| 0x8
| Title ID
| same
|-
|-
| 0x10
| 0x48 || 0x1 || bool, is temporary (true for DLP child titles added into tmp_i/tmp_t.db)
| 4
| Title Entry Index
| same
|-
|-
| 0x14
| 0x49 || 0x1 || u8, [[Application_Manager_Services#ImportTitleContextState|ImportTitleContextState]]
| 4
| Relative Title Info Offset, in blocks (see next field)
| Unknown
|-
|-
| 0x18
| 0x4A || 0x1 || bool, overwrite (set when reinstalling an existing title)
| 0x4
| Block Size (Usually 0x80; 0x200 for ticket.db)
| Relative Title Info Offset, in BDRI blocks
|-
|-
| 0x1c
| 0x4B || 0x1 || Reserved
| 4
| Reserved
| Title Info size, in bytes
|-
|-
| 0x20
| 0x4C || 0x4 || Content ID for content index 0, 0xFFFFFFFF if not applicable
| 4
| Unknown, occasionally this value is the title's "Title ID lower"
| Unknown (0)
|-
|-
| 0x24
| 0x50 || 0x4 || u32, random value generated during title installation (See [[CTXT]])
| 0x4
| Unknown
| same
|-
|-
| 0x28
| 0x54 || 0x2C || Reserved
| 0x4
| Unknown
| same
|}
|}


* The actual Title Info offset is calculated by the following: Offset of BDRI Header + Relative Offset of Title Entry Table + Relative Title Info Offset
=== Ticket Info Entry ===
 
For ticket.db entries, there is a header indicates ticket count (as a Title ID can have more than one ticket installed). Then each entry contains the size, followed by the actual ticket data.
== Title Info Table ==
 
These consist of 0x80 byte long entries, pointed to by the title index entries. They contain information taken from both the application NCCH file(s) and TMD.


{| class="wikitable"
{| class="wikitable"
|+ Header
|-
|-
! Start
! Start
Line 298: Line 206:
|-
|-
| 0x0
| 0x0
| 8
| Title Size
|-
| 0x8
| 4
| Title Type(usually 0x40)
|-
| 0xC
| 4
| Title Version
|-
| 0x10
| 4
| Flags_0
|-
| 0x14
| 4
| TMD Content ID
|-
| 0x18
| 4
| CMD Content ID
|-
| 0x1c
| 4
| Flags_1
|-
| 0x20
| 4
| ExtdataID low (zero if title doesn't use Extdata)
|-
| 0x24
| 4
| 4
| Reserved
| Amount of tickets X
|-
| 0x28
| 8
| Flags_2
|-
| 0x30
| 0x10
| Product Code
|-
| 0x40
| 0x10
| Reserved
|-
|-
| 0x50
| 0x4
| 0x4
| Unknown
| X * (size of tickets + 4)
|-
| Ticket entries
| 0x54
| 0x2c
| Reserved
|}
|}
For ticket.db title info contains a small header and actual ticket data:
{| class="wikitable"
{| class="wikitable"
|+ Ticket entry
|-
|-
! Start
! Start
Line 363: Line 222:
| 0x0
| 0x0
| 4
| 4
| Unknown (always 0x00000001?)
| Ticket data size X (often 0x350 but some DLC tickets may be larger)
|-
|-
| 0x4
| 0x4
| 4
| Ticket data size X (=0x530)
|-
| 0x8
| X
| X
| [[Ticket|Ticket]] data
| [[Ticket|Ticket]] data
|}
==== Flags_0 ====
{| class="wikitable"
|-
! Index
! Description
|-
| 0
| Electronic Manual
|-
| 1
| ?
|-
| 2
| ?
|-
| 3
| ?
|}
==== Flags_1 ====
{| class="wikitable"
|-
! Index
! Description
|-
| 0
| SD Save Data
|-
| 1
| ?
|-
| 2
| ?
|-
| 3
| ?
|}
==== Flags_2 ====
{| class="wikitable"
|-
! Index
! Description
|-
| 0
| DSiWare Related (Visibility on Home Menu/Export Flag?)
|-
| 1
| ?
|-
| 2
| ?
|-
| 3
| ?
|-
| 4
| Found with DSiWare Titles and titles with an 'Application' Title ID
|-
| 5
| DSiWare Related (Visibility on Home Menu/Export Flag?)
|-
| 6
| ?
|-
| 7
| ?
|}
|}