Released · Windows · Open source (MIT)

Reverse Engineering · Binary Patching

Wizardry Gold High-Roll Patch

A legacy x86 Windows game binary, read instruction by instruction. Found a developer-only code path the shipped game keeps switched off, turned it back on with a six-byte patch, and fixed a timing bug that has been in the original release since the 1990s.

Problem

In Wizardry 7: Crusaders of the Dark Savant (the “Wizardry Gold” Windows re-release), character creation rolls a pool of bonus points. A Faery Ninja needs a roll around 21 to 23, against a normal range of roughly 5 to 11. Players re-roll for hours to get one.

The obvious approach, editing the value in memory, does nothing. Profession eligibility is computed from the roll at the instant you pick a gender and never re-read afterward. Pinning the value, and even injecting it with a hardware breakpoint, failed for the same reason (the breakpoint version crashed the game). The only fix that works is changing what the generator produces.

Before and after

Approach

The fix came out of four investigations in the disassembly.

  1. Where do rolls come from?

    The roll generator has a dormant developer branch: when a flag word equals 1 it rolls random(10)+21, 21 to 30. The shipped game hard-codes that flag to 0. Replacing the guarding jump with NOPs, six bytes, makes it fire every time while the game still rolls with its own code.

  2. Why is pacing erratic?

    About 30 throttles stamp a shared timestamp in 55 ms units (the DOS 18.2 Hz tick) while the main step timer reads it in 128 ms units. One timestamp, two time bases. The fix moves both stamps to the 55 ms idiom inside the original instruction bytes.

  3. Why do patches vanish?

    Unpacking the UPX-packed launcher showed it runs a different executable per resolution setting. Patches had been landing on an exe the launcher wasn’t running, so now both copies get patched.

  4. How do I find code that runs constantly?

    A read-only call-stack sampler suspends the game, reads the instruction pointer and stack, and resumes. Sampling showed where the timing code lives without attaching a debugger.

Architecture

Patcher architecture Three front ends, a Python command-line tool, a Rust desktop app built with eframe, and a Tauri v2 app, all apply the same patch steps: find each site by byte signature, verify the expected bytes, back up the file once, write the patch, and support a byte-for-byte revert. Patches go to both game executables, because the launcher runs a different one per resolution setting. Python CLIstdlib only, status + revert Rust GUI (eframe)one ~3.5 MB exe Tauri v2 appRust + HTML/JS Patch steps (same in every front end) 1. find each site by byte signature 2. verify the expected bytes 3. back up the file once 4. write the patch 5. revert restores the original byte for byte (tested) GAME INSTALL exe, resolution A exe, resolution B

Scroll sideways to see the full diagram.

Three ways to apply the same safe procedure. Unknown builds fail the signature check and are refused rather than risked. Is it OK to publish this? →

Key decisions

  • Change the generator over editing the value in memory

    Memory edits, value pinning, and a hardware-breakpoint injector all failed, because eligibility is computed once at gender selection. Patching what the generator produces is the only approach where everything downstream (eligibility, stats, saves) behaves normally.

  • Fit inside the original bytes over adding a code cave

    The timer fix fits exactly in the original instruction bytes, with no new code and no changed branch targets. The smallest possible change is the easiest to verify and to undo.

  • Refuse unknown builds over best-effort patching

    Each patch site is located by signature and checked before any write. It runs on other people’s machines, so failing safely beats patching an unfamiliar file.

Results & status

  • Four patches released and verified in-game: high rolls, text pacing, screen-wipe delay, and the timer fix.
  • Round-trip tested: patch then revert returns the original file byte for byte, checked by automated tests.
  • Open source on GitHub under MIT, with a full technical write-up and a plain-English version.

Stack

  • x86 disassembly
  • Capstone
  • Python
  • Rust
  • eframe
  • Tauri v2
  • UPX unpacking

FAQ

Is it OK to publish this?

The patchers edit a local copy of a game you already own. They redistribute no game files, make no network calls, and collect no telemetry. It is for personal use with a single-player, offline game, and is not affiliated with the rights holders of Wizardry. Use at your own risk.

Why three front ends?

The Python CLI is for people comfortable in a terminal. The standalone Rust GUI is one click and needs no Python installed. The Tauri app carries the same logic with a web-style interface and its own round-trip tests.

Links