Remedy Archive System

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
m (MP1 crypt: ensure last value fits in a byte)
m (Format details: LE)
Line 11: Line 11:
  
 
== Format details ==
 
== Format details ==
 +
 +
Numbers are in little-endian byte order.
  
 
The file's header has the following structure:
 
The file's header has the following structure:

Revision as of 15:31, 21 November 2025

File Format
Name Remedy Archive System
Ontology
Extension(s) .ras
Released 2001

Remedy Archive System is used to store game data for Remedy Entertainment games such as Max Payne and Max Payne 2. The metadata (central directory) following the header is encrypted.

Contents

Identification

Files begin with signature bytes 52 41 53 00.

Format details

Numbers are in little-endian byte order.

The file's header has the following structure:

struct RASHeader {
  uint8_t magic[4]; // "RAS\0"
  uint32_t encryptionKey;
};

The next section of the header must be decrypted first:

// decrypted structure
struct RASMetadata {
  
};

Encryption

Depending on the generation of the RAS file format, different encryption schemes are used.

RAS1 (Max Payne)

function decrypt(data: byte[], key: uint32):
  if key == 0:
    key := 1
 
  for i from 0 to data.length-1:
    a := data[i]
    b := i mod 5         -- such that 0 ≤ b < 5
    c := rotateByteLeft(a by b)
    d := key / 177
    e := d * 30269
    f := key * 171
    key := f - e
    g := i mod 256
    h := g + 3
    k := h * 6
    m := k bitwiseXor data[i]
    p := key mod 256     -- such that 0 ≤ p < 256
    q := m + p
    data[i] := q mod 256

If your programming language doesn't support the rotateLeft operation, it can be emulated using:

function rotateByteLeft(i by n):
  return (i bitShiftLeft n) bitwiseOr (i bitShiftRight (8 - n))
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox