Difference between revisions of "CIA"

From 3dbrew
Jump to navigation Jump to search
Line 67: Line 67:
  
 
== Banner ==
 
== Banner ==
The banner starts with a 0xF0 large data block, whose purpose is currently unknown. Then at offset 0x400 into the banner section is the actual banner, which contains information about the creator, the first title and the second title (you can see them in the system settings):
+
The banner starts with a 0xF0 large data block, whose purpose is currently unknown.  
 +
 
 +
Then at offset 0x400 into the banner section is the actual banner (or ICN file), which contains information about the creator, the first title and the second title (you can see them in the system settings):
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
Line 82: Line 84:
 
|  Reserved = 0
 
|  Reserved = 0
 
|}
 
|}
This small 'table' is immediately followed by a meta-data described like that:
+
This header is immediately followed by meta-data:
* first title (0x80 bytes)
 
* second title (0x100 bytes)
 
* publisher name (0x80 bytes)
 
All encoded in UTF-16.
 
This order will repeat 11 times (each block for different language supported).
 
  
=== App Titles ===
+
=== Application Titles ===
  
To put it short, the order for each region/language title is the following :
+
{| class="wikitable" border="1"
 +
|-
 +
!  START
 +
!  SIZE
 +
!  DESCRIPTION
 +
|-
 +
|  0x00
 +
|  0x80
 +
|  Short Description
 +
|-
 +
|  0x80
 +
|  0x100
 +
|  Long Description
 +
|-
 +
|  0x180
 +
|  0x80
 +
|  Publisher
 +
|}
  
In Banner Meta-Data (info based on 3DSExplorer v0.89)
+
All encoded in UTF-16.
 
+
This order will repeat 11 times (each block for different language supported).
* 1st = #0 on 3DSExplorer v0.89
 
* 11th = #10 on 3DSExplorer v0.89
 
  
 +
The languages by order of appearance:
  
* 1st 0x200  : Japanese title name
+
* 1st: Japanese title name
* 2nd 0x200  : English title name
+
* 2nd: English title name
* 3rd 0x200  : French title name
+
* 3rd: French title name
* 4th 0x200  : German title name
+
* 4th: German title name
* 5th 0x200  : Italian title name
+
* 5th: Italian title name
* 6th 0x200  : Spanish title name
+
* 6th: Spanish title name
* 7th 0x200  : ???
+
* 7th: ???
* 8th 0x200  : ???
+
* 8th: ???
* 9th 0x200  : (German again?) title name
+
* 9th: (German again?) title name
* 10th 0x200 : Portuguese title name
+
* 10th: Portuguese title name
* 11th 0x200 : Greek title name
+
* 11th: Greek title name
  
 
=== Icons ===
 
=== Icons ===
Line 117: Line 130:
 
* Large - 48x48 icon (the genral icon).
 
* Large - 48x48 icon (the genral icon).
  
Both of the icons are encoded in GBR655 meaning 16bpp.
+
Both of the icons are encoded in RGB565 meaning 16bpp.
  
 
There's a header of 0x40 bytes and then comes the raw data.
 
There's a header of 0x40 bytes and then comes the raw data.
  
The data is encoded in tiles (starting from size 8x8).
+
The data is encoded in tiles (starting from size 8x8, continuing recursively).
  
 
If the buffer is like this:
 
If the buffer is like this:

Revision as of 07:43, 28 November 2011

Overview

CIA stands for CTR Importable Archive. These files contain a compiled application which can be installed on CTR NAND, TWL NAND (part of the NAND used by DSi applications) and on the SD card.

An example .CIA can be downloaded here [1] Credit: Jl12. It includes a .cia file, the .cia file in its extracted form, a screenshot of the application working and some information given by the 3DS.

Format

The CIA format has a similar structure to the WAD format.

The file is represented in little-endian.

The data is aligned in 64 byte blocks (if a content ends at the middle of the block, the next content will begin from a new block).

CIA Header

This is a 32 bytes long header (8 x uint32).

START SIZE DESCRIPTION
0x00 0x04 Archive Header Size (=0x2020 bytes) (Starts with 0x80 @ offset 0x0020)
0x04 0x02 Type
0x06 0x02 Version
0x08 0x04 Certificate chain size
0x0C 0x04 Ticket size
0x10 0x04 TMD file size
0x14 0x04 Banner size (0 if no banner)
0x18 0x04 APP file size
0x1C 0x04 0x80000000

The order of the sections in the header also is the order of them in the CIA file:

  • certificate chain
  • Ticket
  • TMD file data
  • APP file data
  • banner

The APP data can be either encrypted or cleartext, retail Download Play CIAs' APP data is always encrypted.

The banner starts with a 0xF0 large data block, whose purpose is currently unknown.

Then at offset 0x400 into the banner section is the actual banner (or ICN file), which contains information about the creator, the first title and the second title (you can see them in the system settings):

START SIZE DESCRIPTION
0x00 0x04 Magic: 'SMDH'
0x04 0x04 Reserved = 0

This header is immediately followed by meta-data:

Application Titles

START SIZE DESCRIPTION
0x00 0x80 Short Description
0x80 0x100 Long Description
0x180 0x80 Publisher

All encoded in UTF-16. This order will repeat 11 times (each block for different language supported).

The languages by order of appearance:

  • 1st: Japanese title name
  • 2nd: English title name
  • 3rd: French title name
  • 4th: German title name
  • 5th: Italian title name
  • 6th: Spanish title name
  • 7th: ???
  • 8th: ???
  • 9th: (German again?) title name
  • 10th: Portuguese title name
  • 11th: Greek title name

Icons

At offset 0x2400 into the banner (inside the Banner's meta-data) to the end, there are two icons:

  • Small- 24x24 (shown on top screen when pausing the app)
  • Large - 48x48 icon (the genral icon).

Both of the icons are encoded in RGB565 meaning 16bpp.

There's a header of 0x40 bytes and then comes the raw data.

The data is encoded in tiles (starting from size 8x8, continuing recursively).

If the buffer is like this:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Then the image would look like this:

x=0 x=1 x=2 x=3 x=4
0 1 4 5 16
2 3 6 7 ...
8 9 12 13
10 11 14 15