Difference between revisions of "WAD files"

From WiiBrew
Jump to: navigation, search
m (ugly table is ugly)
Line 7: Line 7:
 
=== Header ===
 
=== Header ===
  
{| style="border-collapse: collapse; padding: 0.2em 0.2em 0.2em 0.2em;"
+
{| class="wikitable"
|- style="background-color: #ddd;"
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #cdc;" | '''Start'''
+
! '''Start'''
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ccd;" | '''End'''
+
! '''End'''
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ccc;" | '''Length'''
+
! '''Length'''
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dcc;" | '''Description'''
+
! '''Description'''
|- style="background-color: #ddd;"
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x000
+
| 0x000
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x003
+
| 0x003
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 4
+
| 4
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | Header size = 0x0020
+
| Header size = 0x0020
|- style="background-color: #ddd;"
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x004
+
| 0x004
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x007
+
| 0x007
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 4
+
| 4
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | WAD Type ('Is\0\0' or 'ib\0\0' or 'Bk\0\0')
+
| WAD Type ('Is\0\0' or 'ib\0\0' or 'Bk\0\0')
|- style="background-color: #ddd;"
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x008
+
| 0x008
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x00B
+
| 0x00B
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 4
+
| 4
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | [[Certificate chain]] size.
+
| [[Certificate chain]] size.
|- style="background-color: #ddd;"
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x00C
+
| 0x00C
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x00F
+
| 0x00F
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 4
+
| 4
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | Reserved = 0
+
| Reserved = 0
|- style="background-color: #ddd;"
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x010
+
| 0x010
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x013
+
| 0x013
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 4
+
| 4
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | [[Ticket]] size
+
| [[Ticket]] size
|- style="background-color: #ddd;"
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x014
+
| 0x014
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x017
+
| 0x017
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 4
+
| 4
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | [[Tmd file structure|TMD]] size
+
| [[Tmd file structure|TMD]] size
|- style="background-color: #ddd;"
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x018
+
| 0x018
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x01B
+
| 0x01B
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 4
+
| 4
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | Data (APP) size
+
| Data (APP) size
|- style="background-color: #ddd;"
+
|-
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ded;" | 0x01C
+
| 0x01C
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #dde;" | 0x01F
+
| 0x01F
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #ddd;" | 4
+
| 4
| style="border: 1px solid #ccc; padding: 0.2em; background-color: #edd;" | Footer size
+
| Footer size
 
|}
 
|}
  

Revision as of 16:59, 27 September 2008

WAD Format

The data within a WAD file has the following format.

Thanks to Segher for his source.

Header

Start End Length Description
0x000 0x003 4 Header size = 0x0020
0x004 0x007 4 WAD Type ('Is\0\0' or 'ib\0\0' or 'Bk\0\0')
0x008 0x00B 4 Certificate chain size.
0x00C 0x00F 4 Reserved = 0
0x010 0x013 4 Ticket size
0x014 0x017 4 TMD size
0x018 0x01B 4 Data (APP) size
0x01C 0x01F 4 Footer size

The sections are stored in the WAD in the same order that in the header. Each block (header, sections) is aligned to 0x40 bytes.

The contents are stored in the WAD in the same order as in the TMD. Each file is aligned to 0x40 bytes.

The contents (Data section) are encrypted using the title key (decrypt it from the ticket) and the content index (in the TMD, the 2 first bytes of the IV are the index, the last 14 bytes are zeroes) as IV. The SHA1 of the decrypted content must match the hash that is stored in the TMD.

Footer

The "footer" is an optional, unencrypted timestamp / buildstamp.