PCK File

PCK are the primary container format for Rusty Hearts, containing almost all of the asset files for the game.

Examples:

  • 000.pck through 009.pck in the Rusty Hearts installation directory.

General Format Overview

The file directory of the PCK files is stored in a file named f00X.dat. The file system metadata within f00X.dat is encrypted using a static stream cipher.

stream cipher

30 22 41 A8 5B A6 6A 49 BF 53 35 E5 9E 0E EC B8
5E 15 1F C1 4F EC 77 E8 B7 4E 87 E6 F5 3C B3 43
CC 53 36 AC 5A 77 B8 DD 30 74 8C 4A 9A 9B BC 0A
A4 AD BB 13 4B 8C D4 80 CE 65 1D 08 5A 6A 6F 25
F9 3F EF 1B A4 72 14 ED 97 22 4A 2E B8 96 4B 8E
96 93 F1 28 B2 0B 3C F8 5D AA A9 82 13 6E C1 A9
20 57 B2 5B 16 CF 9E 5F D4 CC 2E F5 C9 4C 1C EE
E3 3F 29 B3 06 70 43 3D F5 90 A2 42 02 98 50 FD
5D 4E 92 AD AD 7F AB 60 2C B8 43 76 8F 5F E6 A7
19 E0 B9 B5 62 6B D4 47 69 34 0E 6D A4 52 E3 64
4A 65 47 F5 3F 53 5E 8B 1B FD 21 F7 BA 68 F9 DF
68 A8 96 0F 8B 01 97 58 8C 1E EF B3 41 44 21 DA
E0 F4 E0 2D CD 0B F0 5C 59 D6 99 E7 01 15 67 32
E0 12 2F CD A2 DE 52 CE EC EF 77 0E BC 38 64 8D
B4 DB 67 FF C8 66 0C 8A 60 E1 2E 00 43 A9 37 9C
11 AA B9 98 ED 21 35 D4 C3 DE 65 54 9D 1C B0 A9

Decryption Process

  1. Decrypt f00X.dat: Use the stream cipher to XOR-decrypt the f00X.dat file.

  2. Decompress using zlib: After decryption, decompress the resulting file using zlib to retrieve the directory tree.

Directory Tree Structure

The directory tree extracted from f00X.dat provides metadata about the files stored in the corresponding PCK files. Each entry in the directory tree contains the following fields:

directoryTreeFile
{
   fileName (Widechar string)      # Name of the file within the game.
   packFileNumber (byte)           # The corresponding PCK file number (e.g., '000.pck', '001.pck', etc.).
   fileLength (int32)              # Length of the file in bytes.
   fileChecksum (uint32)           # Checksum of the file for integrity verification.
   fileOffset (int32)              # The offset in the PCK file where the file begins.
   nulls (int32)                   # Reserved or unused field (typically zeroed out).
}

Extraction Process

Once the directory tree is available, the files can be extracted from the PCK.

Example Workflow

Assume we want to extract a file from 000.pck:

  1. Decrypt and decompress the f00X.dat file to obtain the directory tree.

  2. Locate the file in the directory tree, which provides:

    • fileName: "sound/rusthearts_alonewolf.ogg"

    • packFileNumber: 0 (meaning the file is in 000.pck)

    • fileLength: 1693853 bytes

    • fileOffset: 876672131 (the file starts 876672131 bytes into the 000.pck file)

  3. Open 000.pck, seek to byte 876672131, and read the next 1693853 bytes.

  4. Save the extracted data to the file path sound/rusthearts_alonewolf.ogg.

By following this process, you can successfully extract and handle the assets from the Rusty Hearts .pck files.

Last updated