RC RANDOM CHAOS

Reverse-Engineering a Game Save File with ImHex's Pattern Language

· via Hacker News

Original source

Reverse Engineering Unknown File Formats with ImHex

Hacker News →

The creator of ImHex, a free cross-platform open-source hex editor, walks through how to decode an unknown binary format by reverse-engineering the save file from the 2012 game FEZ. Opening the file reveals it’s uncompressed, unencrypted, and carries no magic bytes, so the raw data is meaningless on its own — the only way to interpret it is to understand the program that produces it. Because FEZ ships as C# assemblies, its logic decompiles cleanly with a tool like JetBrains Rider, and tracing through classes such as PCSaveDevice and SaveFileOperations.Write exposes exactly which fields get written and in what order.

With the layout understood, the field-by-field structure is rebuilt in ImHex’s Pattern Language, a C-like DSL for describing binary formats. The tutorial maps concrete C# behavior onto language features: structs placed with the @ operator, type aliases via using, the standard library’s FILETIME type to render a Windows timestamp as readable time, a [[fixed_size(0xA000)]] attribute mirroring the game’s zero-padding, assertions that reject files whose version field isn’t 6, and template structs to model nullable ‘objects’ that begin with a presence flag.

The piece is essentially a practical primer on the reverse-engineering workflow — pair decompilation of the reader/writer code with a structured hex-parsing definition — using a game save as an approachable stand-in for any proprietary format. The payoff is a reusable, self-documenting pattern that turns opaque bytes into an inspectable, human-readable tree.

Read the full article

Continue reading at Hacker News →

This is an AI-generated summary. Read the original for the full story.