PAK (File Format)/RetroStudios: Difference between revisions

From Wexos's Wiki
Jump to navigationJump to search
(Created page with "'''PAK''' is an archive file format used in games such as Donkey Kong Country Returns created by RetroStudios. = File Format = == Header == The file starts with the following header: {|class="wikitable" ! Offset !! Type !! Description |- | 0x00 || UInt32 || {{Unknown-left|'''Unknown'''. Always 2, possibly a version number.}} |- | 0x04 || UInt32 || '''Header size'''. Always 0x40. |- | 0x08 || Byte[0x10] || '''MD5 hash''' of the file data following the header. |- |...")
(No difference)

Revision as of 17:34, 11 July 2025

PAK is an archive file format used in games such as Donkey Kong Country Returns created by RetroStudios.

File Format

Header

The file starts with the following header:

Offset Type Description
0x00 UInt32 Unknown. Always 2, possibly a version number.
0x04 UInt32 Header size. Always 0x40.
0x08 Byte[0x10] MD5 hash of the file data following the header.
0x18 Byte[0x18] Padding.

Table Of Content

After the header, a table of content structure specify what sections are stored in the file. It has the following structure:

Offset Type Description
0x00 UInt32 Section count (N). In practice this will always be 3 with order STRG, RSHD, DATA.

N entries of the following structure follows.

Offset Type Description
0x00 Char[4] Section magic.
0x04 UInt32 Section size in bytes.

Afterwards the section data is layout in the same order as they are specified above.

STRG

The STRG data starts with the following structure:

Offset Type Description
0x00 UInt32 Number of named resources (N).

Immediately afterwards N named resources follows.

Named Resource

Each resource has the following structure:

Offset Type Description
0x00 Char[N + 1] Resource name stored as a null-terminated string of length N.
N + 1 Char[4] Resource magic. File magic of the resource specifying file type.
N + 5 UInt64 Resource ID.

RSHD

The RSHD data starts with the following structure:

Offset Type Description
0x00 UInt32 Number of resources (N).

Immediately afterwards N resources follows.

Resource

Each resource has the following structure:

Offset Type Description
0x00 UInt32 Compression flag. Either 0 (uncompressed) or 1 (compressed).
0x04 Char[4] Resource magic. File magic of the resource specifying file type.
0x08 UInt64 Resource ID.
0x10 UInt32 File data size in bytes.
0x14 UInt32 File data offset, relative to the start of the DATA section.

DATA

All file data is stored in the DATA section and references by each resource.

Tools

The following tools can handle PAK files: