Kuribo64 Wiki
Home | ForumsLogin

WIKI BACKUP

Back to listing

RARC

Contents
1. File header
2. Directory nodes section
3. File entries section
4. String table section
5. File data section
6. How file/directory name hashes are calculated

RARC is an archive format commonly used in Gamecube games. It is also used in some Wii games like SMG 1 and 2, but on the Wii the U8 format is more commonly used.
In SMG games, the RARC archives have .arc extensions. Original archives are compressed using Yaz0, but compression is optional.

Like pretty much any GC/Wii file format, RARC is a big-endian file format.

Typically, all offsets found within a RARC's header, and file data offsets, are aligned to a 32-byte boundary.

1. File header


Offset Size Description
0x00 4 Magic (RARC)
0x04 4 Size of the whole file
0x08 4 Unknown (always 0x00000020)
0x0C 4 Offset to the file data section minus 0x20
0x10 4 Length of the file data section
0x14 4 Length of the file data section (again?)
0x18 4 Unknown (always 0x00000000)
0x1C 4 Unknown (always 0x00000000)
0x20 4 Number of directory nodes
0x24 4 Offset to the directory nodes section minus 0x20 (always 0x20)
0x28 4 Number of file entries
0x2C 4 Offset to the file entries block minus 0x20
0x30 4 Size of the string table section
0x34 4 Offset to the string table section minus 0x20
0x38 4 Unknown
0x3C 4 Padding (always 0x00000000)

2. Directory nodes section


Offset Size Description
0x00 4 ROOT for the root directory, the name's 4 first letters in uppercase for others (if the name is less than 4 letters, it is padded with spaces)
0x04 4 Offset to the directory name in the string table section
0x08 2 Hash of the directory name
0x0A 2 Number of file entries in this directory
0x0C 4 Offset to the first file entry in the file entries section

3. File entries section


Offset Size Description
0x00 2 File ID (0xFFFF for a subdirectory)
0x02 2 Hash of the file name
0x04 2 Type? 0x0200 for subdirectories, 0x1100 for files
0x06 2 Offset to entry name in the string table section
0x08 4 For files: offset to file data in file data section, for subdirectories: index of the corresponding directory node
0x0C 4 For files: size of the file, for subdirectories: always 0x10 (size of the node entry?)
0x10 4 Unknown (always 0x00000000)

For whatever reason, among file entries are subdirectory entries named . and .. . They don't seem to have a purpose, aside from perhaps being shown in whatever RARC editing software Nintendo used?

The . entry points to the current directory, and the .. entry points to the parent directory.

The .. entries have their directory node index set to 0xFFFFFFFF when they are already in the root directory.

4. String table section


This section contains NULL-terminated ASCII strings representing the file and directory names.

If two or more files/directories have the same name, their name strings will be duplicated.

5. File data section


This section is just a huge blob of data. Use the previous sections to exploit it.

6. How file/directory name hashes are calculated


Start out with a 16-bit value of zero. For each character in the name to hash, multiply your value by 3 and add the character's value to your value.

Here's some C code to calculate hashes:
unsigned short calculateHash(char* name)
{
int i = 0;
unsigned short hashval = 0;

while (name[i] != '\0')
{
hashval *= 3;
hashval += name[i];
i++;
}

return hashval;
}

Page rendered in 0.012 seconds. (2048KB of memory used)
MySQL - queries: 17, rows: 66/66, time: 0.010 seconds.