DT-LS Filesystem
Contents
Overview
Almost all of smash 4's game data is stored in one or more very large "DT" archives. On the 3ds, there is only one of these archives. The WiiU version however contains 2, and a version 2 "LS" file. Version 2 of the LS file allows DT files to be indexed. (e.g DT00, DT01, DT02.) The files within a directory are commonly (but not always) packed into a single file named "PACKED" without any information about the contained files such as size or length.
The PACKED files and any non packed files are stored in the DT archive back to back in chunks, again without information about the files themselves. The info about the data chunks and PACKED files is stored inside the LS file.
LS File
There are two versions of the LS file spec. The first was introduced with the 3ds version, and later the second was introduced in updates and in the wiiu version. The biggest difference between the two versions is the addition of a field to specify what DT file contains the associated data.
Header
Offset | Name | Description |
---|---|---|
0x00 | ASCII tag | "of" |
0x02 | Version | LS file version |
0x04 | Entry count | Number of LSEntries in the file |
LSEntry
Offset | Name | Description |
---|---|---|
0x00 | CRC | CRC32 of the path to this entry's data. |
0x04 | Chunk offset | Offset to the data chunk for this entry |
0x08 | Chunk Length | Length of the data chunk for this entry |
0x0C | DT index | Only seen in LSEntry v2 |
0x0E | unk | Only seen in LSEntry v2 |
Archive Partitions
Since the game has options for multiple languages per region, the game has separate partitions containing the files which are changed per language. In order to view the contents of these partitions, we need the "resource" files which contain the specific information for directories and files (the info that was left out of the DT archive).
For base game dumps, the resource files are placed in the root of the archive. In order to extract it, we need to calculate the CRC32 of the string "resource" (with the first 4 byte's bits inverted) and search for the LS file entry associated with it. Using the LS entry, we can extract the file and begin using it to extract the rest of the files from the partition.
Luckily, there is a default resource file just called "resource" that's defaulted to when files either fail to load, or the file doesn't have a localized variant. The resource files are simply named "resource". If the resource file is for a localized partition, it will have "(xx_xx)" appended to the end where xx_xx is the locale. e.g "(us_en)"
Resource File
The resource files contain file and directory specific information such as flags, data offset, file size, etc. The basic structure of the resource file's is as follows: Header, EntrySection, StringSection.
All data after the header is zlib compressed.
Header
Offset | Name | Description |
---|---|---|
0x00 | ASCII Tag | "RF" |
0x02 | Flags. | 0x4 = Compressed, 0x3 = console type: 1 = 3ds, 2 = wiiu |
0x04 | Content start | |
0x08 | Content size. | 0 if compressed. |
0x0C | EntrySection offset | |
0x10 | EntrySection Length | |
0x14 | Unix Timestamp | |
0x18 | Compressed Len | Compressed size of the Resource File Data. |
0x1C | Decompressed Len | Decompressed size of the Resource File Data. |
0x20 | StringSection offset | |
0x24 | StringSection Len | |
0x28 | ResourceEntry Count | Number of ResourceEntries in the file. |
0x2C - 0x7C | Padding | 0x54 bytes of 0xAA |
Resource Entry
Offset | Name | Description |
---|---|---|
0x00 | Chunk Offset | Offset relative to the start of the data chunk containing this entry's data. |
0x04 | String Offset | Offset into the string section for this entry |
0x08 | Compressed Len | Compressed Length of the data for this entry |
0x0C | Decompressed Len | Decompressed Length of the data for this entry |
0x10 | Unix Timestamp | |
0x14 | Flags | Flags for this entry. See below. |
Resource Flags
Bits | Description |
---|---|
0 - 3 | Folder Depth |
4 - 8 | Unknown. Always 0. |
9 | Is Directory |
10 | Is File |
11 | Has localization data |
12 | Is PACKED |
13 | debug. |
14 | External. True if the file should be loaded from outside it's PACK |