Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:Ruby Marshal

From ReverseEngineering.wiki
Format
Vendor Ruby
Magic 04 08
Extensions .rxdata, .rvdata, .rvdata2
On this wiki Facts · Code · Notes · Topics

Ruby's Marshal.dump format, used by RPG Maker XP/VX/VX Ace data and save files (.rxdata, .rvdata, .rvdata2): a two-byte version 4.8 followed by one value made of single-character type bytes, with Symbols and objects back-referenced by index.

Overview

A Marshal stream starts with major version 4 and minor version 8 (bytes 04 08; MARSHAL_MAJOR 4, MARSHAL_MINOR 8 in marshal.c). The loader rejects another major version or a newer minor. RPG Maker XP (.rxdata), VX (.rvdata) and VX Ace (.rvdata2) store their database files and saves as Marshal streams of the editor's Ruby classes (see Library:RPG Maker); anything written by Marshal.dump has the same form.

Type bytes

From the TYPE_* defines in marshal.c: 0 nil, T true, F false, i fixnum, f float (text), l bignum, " string (bytes), : symbol, ; symbol link (index), @ object link (index), [ array, { hash, } hash with default value, o object (class name symbol, then instance variables), S struct, u user-defined _dump data, U marshal_dump data, I wrapper that adds instance variables (typically the string encoding: ivar E true means UTF-8, false US-ASCII, or encoding with a name), e extended by a module, C subclass of a core class, c class, m module, M old module, / regexp, d data (C extension).

Integers

A length or small integer is one packed value (w_long): 0 is byte 00; 1..122 is n+5; -123..-1 is (n-5) & 0xFF; larger magnitudes are a byte 1..4 (negative: 0xFF..0xFC) followed by that many little-endian bytes. Fixnum i uses the same packing. Bignums (l) are a sign byte + or -, a length in 16-bit words, then little-endian digits.

Reading a stream

Symbols are numbered in order of first appearance and later referenced with ; plus the packed index; objects (not symbols or immediates) are numbered for @. A parser must keep both tables. Example built by hand from the rules above: 04 08 5B 07 69 06 69 07 is the array [1, 2] ([, length 2 packed as 07, i 1 packed as 06, i 2 packed as 07).

Code & repositories

  • https://github.com/ruby/ruby @ af502c75307230d0ba5d9c99d4e24de9e7775df6 · license: Ruby OR BSD-2-Clause (declared by the contributor; GitHub's detector did not recognize COPYING)
    Reference implementation of Marshal in marshal.c (TYPE_* type bytes, w_long integer packing, version 4.8).
    Tested on: source read, not run: source read, not run · checked 2026-10-18; last activity 2026-10-18

Pitfalls

  • Unverified: RPG Maker's Table, Color and Tone classes use _dump, so they appear as u records with raw binary bytes rather than nested objects.
  • Compare Format:Python pickle, also a typed object stream but a stack-machine bytecode.

See also Technique:Reverse engineering game save files.