Difference between revisions of "SARC (File Format)"

From MK8
Jump to: navigation, search
m
(Tidied page up and added some information based on a bit of guesswork. Props to Celcodioc for the article.)
Line 1: Line 1:
'''SARC Files''' are uncompressed archive files used in [[Wii U]] software, including [[Mario Kart 8]]. They are similar to the [[mkw:U8 (File Format)|U8]] files found in GameCube and Wii games. Common extensions are .arc, .sarc, .pack, and .bars.
+
'''SARC Files''' are uncompressed archive files used in [[Wii U]] software, including [[Mario Kart 8]]. They are similar to the [[mkw:U8 (File Format)|U8]] files found in GameCube and Wii games. Common extensions are .arc, .sarc, .pack, and .bars. The '''.bars''' extension is commonly used when the archive contains audio data.
  
 
= File Format =
 
= File Format =
The file begins with a 16 bytes long header, and is followed by a file system and a list of filenames that are included in the archive. All values are big endian.
+
The basic structure of the archive is a '''SARC Header''' followed by a '''File Table''' and a '''File Name Table'''. Finally, the content of all files in the archive is stored directly. The '''File Table''' references the data.
 +
 
 +
== Header (SARC) ==
 +
Every SARC archive beings with a 0x14 byte '''SARC Header''' structure.
  
== Header ==
 
 
{| class="wikitable"
 
{| class="wikitable"
 
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x00 || 4 || '''Magic''': 0x53415243 ("SARC").
+
| 0x00 || 4 || '''Magic''': 0x53415243 ("SARC" in ASCII).
 
|-
 
|-
| 0x04 || 2 || {{Unknown|'''Unknown.''' Always 0x0014?}}
+
| 0x04 || 2 || '''Header Length''': the length of this header in bytes. Always '''0x14'''.
 
|-
 
|-
| 0x06 || 2 || '''Byte order mark''' (0xFEFF)
+
| 0x06 || 2 || '''Byte order mark''' (BOM): 0xFE,0xFF for big endian and 0xFF,0xFE for little endian.
 
|-
 
|-
| 0x08 || 4 || '''File size''' of the entire archive.
+
| 0x08 || 4 || '''File size''' of the entire archive in bytes.
 
|-
 
|-
 
| 0x0c || 4 || '''Beginning of data''' offset.
 
| 0x0c || 4 || '''Beginning of data''' offset.
 
|-
 
|-
| 0x10 || colspan=2 {{Unknown|End of '''SARC''' header}}
+
| 0x10 || 4 || {{Unknown|'''Unknown'''. Always '''0x01000000'''?}}
 +
|-
 +
| 0x14 || colspan=2 {{Unknown|End of '''SARC''' header}}
 
|-
 
|-
 
|}
 
|}
Line 25: Line 29:
 
Unlike the U8 format, SARC does generally not contain directory nodes (though files may reside inside subfolders). It is currently unknown if it is able to.
 
Unlike the U8 format, SARC does generally not contain directory nodes (though files may reside inside subfolders). It is currently unknown if it is able to.
  
=== Header ===
+
=== Header (SFAT) ===
 +
The '''SARC Header''' is immediately followed by 0xc byte '''SFAT Header''' structure.
 +
 
 
{| class="wikitable"
 
{| class="wikitable"
 
! Offset !! Type !! Description
 
! Offset !! Type !! Description
Line 31: Line 37:
 
| 0x00 || 4 || '''Magic''': 0x53464154 ("SFAT").
 
| 0x00 || 4 || '''Magic''': 0x53464154 ("SFAT").
 
|-
 
|-
| 0x04 || 2 || {{Unknown|'''Unknown.''' Always 0x000C?}}
+
| 0x04 || 2 || '''Header Length''': the length of this header in bytes. Always '''0xc'''.
 
|-
 
|-
 
| 0x06 || 2 || '''Node count'''.
 
| 0x06 || 2 || '''Node count'''.
 
|-
 
|-
| 0x08 || 4 || {{Unknown|'''Unknown.''' Always 0x00000065?}}
+
| 0x08 || 4 || {{Unknown|'''Unknown.''' Always '''0x00000065'''?}}
 
|-
 
|-
 
| 0x0c || colspan=2 {{Unknown|End of '''SFAT''' header}}
 
| 0x0c || colspan=2 {{Unknown|End of '''SFAT''' header}}
Line 42: Line 48:
  
 
=== Node ===
 
=== Node ===
 +
The '''SFAT Header''' is followed by an array of 0x10 byte '''SFAT Node''' structures.
 +
 
{| class="wikitable"
 
{| class="wikitable"
 
! Offset !! Size !! Description
 
! Offset !! Size !! Description
 
|-
 
|-
| 0x00 || 4 || {{Unknown|'''Unknown.'''}}
+
| 0x00 || 4 || {{Unknown|'''Unknown.''' Could plausibly be an ID of some sort, the files are encoded sorted by this value, so perhaps even a hash of the name.}}
 
|-
 
|-
| 0x04 || 1 || {{Unknown|'''Unknown.''' Always 0x01? Comparable to the file/folder flag from U8?}}
+
| 0x04 || 1 || {{Unknown|'''Unknown.''' Always '''0x01'''? Comparable to the file/folder flag from U8?}}
 
|-
 
|-
 
| 0x05 || 3 || '''File name table entry''' offset, relative to the end of the file name table header, divided by 4.
 
| 0x05 || 3 || '''File name table entry''' offset, relative to the end of the file name table header, divided by 4.
 
|-
 
|-
| 0x08 || 4 || '''Beginning of node file data''', relative to the starting offset specified in the SARC header.
+
| 0x08 || 4 || '''Beginning of node file data''', relative to the '''Beginning of data''' offset specified in the '''SARC header'''.
 
|-
 
|-
| 0x0c || 4 || '''End of node file data''', relative to the starting offset specified in the SARC header.
+
| 0x0c || 4 || '''End of node file data''', relative to the '''Beginning of data''' offset specified in the '''SARC header'''.
 
|-
 
|-
 
| 0x10 || colspan=2 {{Unknown|End of node}}
 
| 0x10 || colspan=2 {{Unknown|End of node}}
Line 60: Line 68:
  
 
== File Name Table ==
 
== File Name Table ==
The header is immediately followed by 4-byte aligned null-terminated strings that represent the filenames of the packed files.
+
The '''File Name Table''' is a list of null-terminated strings which represent the filenames of the packed files. It is referenced by '''SFAT Node'''s.
 +
 
 +
=== Header (SFAT) ===
 +
The '''SFAT Node''' array is immediately followed by an 0x8 byte '''SFNT Header''' structure.
  
=== Header ===
 
 
{| class="wikitable"
 
{| class="wikitable"
! Offset !! Type !! Description
+
! Offset !! Size !! Description
 
|-
 
|-
 
| 0x00 || 4 || '''Magic''': 0x53464E54 ("SFNT").
 
| 0x00 || 4 || '''Magic''': 0x53464E54 ("SFNT").
 
|-
 
|-
| 0x04 || 4 || {{Unknown|'''Unknown.''' Always 0x00080000?}}
+
| 0x04 || 2 || '''Header Length''': the length of this header in bytes. Always '''0x8'''.
 +
|-
 +
| 0x06 || 2 || {{Unknown|'''Unknown.''' Always '''0'''?}}
 
|-
 
|-
 
| 0x08 || colspan=2 {{Unknown|End of '''SFNT''' header}}
 
| 0x08 || colspan=2 {{Unknown|End of '''SFNT''' header}}
 
|-
 
|-
 
|}
 
|}
 +
 +
=== Strings ===
 +
The '''SFAT Header''' is immediately followed by 4-byte aligned null-terminated strings that represent the filenames of the packed files.
  
 
== File Data ==
 
== File Data ==
The data begins at the variable value specified in the SARC header. There is padding between the files for 256-byte (0x100) alignment.
+
The data begins at the '''Beginning of data''' offset specified in the '''SARC Header'''. There is padding between the files for 256-byte (0x100) alignment.
  
 
= Tools =
 
= Tools =

Revision as of 05:28, 10 August 2014

SARC Files are uncompressed archive files used in Wii U software, including Mario Kart 8. They are similar to the U8 files found in GameCube and Wii games. Common extensions are .arc, .sarc, .pack, and .bars. The .bars extension is commonly used when the archive contains audio data.

File Format

The basic structure of the archive is a SARC Header followed by a File Table and a File Name Table. Finally, the content of all files in the archive is stored directly. The File Table references the data.

Header (SARC)

Every SARC archive beings with a 0x14 byte SARC Header structure.

Offset Size Description
0x00 4 Magic: 0x53415243 ("SARC" in ASCII).
0x04 2 Header Length: the length of this header in bytes. Always 0x14.
0x06 2 Byte order mark (BOM): 0xFE,0xFF for big endian and 0xFF,0xFE for little endian.
0x08 4 File size of the entire archive in bytes.
0x0c 4 Beginning of data offset.
0x10 4 Unknown. Always 0x01000000?
0x14 End of SARC header

File Table

Unlike the U8 format, SARC does generally not contain directory nodes (though files may reside inside subfolders). It is currently unknown if it is able to.

Header (SFAT)

The SARC Header is immediately followed by 0xc byte SFAT Header structure.

Offset Type Description
0x00 4 Magic: 0x53464154 ("SFAT").
0x04 2 Header Length: the length of this header in bytes. Always 0xc.
0x06 2 Node count.
0x08 4 Unknown. Always 0x00000065?
0x0c End of SFAT header

Node

The SFAT Header is followed by an array of 0x10 byte SFAT Node structures.

Offset Size Description
0x00 4 Unknown. Could plausibly be an ID of some sort, the files are encoded sorted by this value, so perhaps even a hash of the name.
0x04 1 Unknown. Always 0x01? Comparable to the file/folder flag from U8?
0x05 3 File name table entry offset, relative to the end of the file name table header, divided by 4.
0x08 4 Beginning of node file data, relative to the Beginning of data offset specified in the SARC header.
0x0c 4 End of node file data, relative to the Beginning of data offset specified in the SARC header.
0x10 End of node

File Name Table

The File Name Table is a list of null-terminated strings which represent the filenames of the packed files. It is referenced by SFAT Nodes.

Header (SFAT)

The SFAT Node array is immediately followed by an 0x8 byte SFNT Header structure.

Offset Size Description
0x00 4 Magic: 0x53464E54 ("SFNT").
0x04 2 Header Length: the length of this header in bytes. Always 0x8.
0x06 2 Unknown. Always 0?
0x08 End of SFNT header

Strings

The SFAT Header is immediately followed by 4-byte aligned null-terminated strings that represent the filenames of the packed files.

File Data

The data begins at the Beginning of data offset specified in the SARC Header. There is padding between the files for 256-byte (0x100) alignment.

Tools

The following tool can extract SARC files: