Worked example · Reverse engineering
Reverse-engineering a file format with WDD
An undocumented file format can be cracked with a round-trip verifier: parse each sample file, write it back out, and compare the bytes. WDD pushes an agent to grow the reader and writer until every sample comes back identical.
The goal
Write a reader and writer for an undocumented save-file format that round-trips 300 sample files byte for byte.
The verifier
A script that reads and rewrites every sample and reports how many come back identical, with a hex diff of the first mismatch.
Why this check: Round-tripping needs no documentation: the files themselves are the specification.
The set-up
- A folder of sample files you have the right to use, with a few kept aside for the final check.
- A notes file for the format: every field found, its offset, type and meaning.
The kickoff prompt
Kickoff
Write a reader and writer for the files in samples/. Done means scripts/roundtrip.sh reports all 300 identical. Record every field you discover in FORMAT.md. Each round: run the round-trip, study the first mismatch in the hex diff, extend the format. Keep going until all match.
How the rounds went
- Rounds 1 to 5
- Header, version and a table of sections. 120 of 300.
- Rounds 6 to 18
- Compressed sections and a checksum. 290 of 300.
- Rounds 19 to 22
- The last 10 are an older version with a different string encoding. 300 of 300, and the 20 held-back files pass too.
What worked
- A self-checking verifier that needs no spec.
- FORMAT.md as a growing, reviewable result in its own right.
- Held-back samples to catch over-fitting.
What to watch for
- Use only files and software you have the right to analyse.
Build a kit for a task like this
A worked example written to show the method, not a report of a specific project.
Questions people ask
What is a round-trip test?
Read a file into your program's structures, write it back out, and compare with the original. If they match, your reader and writer understood everything in the file.