Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- """Remove the GarageGames Ignition check from Marble Blast Gold 1.4.1 for Linux.
- Usage: patch_ignition.py <marbleblastgold.bin> [output]
- Patches (virtual address -> file offset = va - 0x08048000):
- 0x0821e184 Ignition library validate() -> return 4 (ValidTicket)
- 0x0821e3a0 Ignition library getStatus() -> return 4 (ValidTicket)
- 0x0814f310 IgnitionObject ticket-field fill -> return immediately
- (with no ticket it would insert NULL into the StringTable)
- With validate() reporting ValidTicket, the script-side runIgnition() goes
- straight to the main menu, and the IgnitionEventA check posted on every
- Marble::onAdd never schedules the quit/GUI-swap/delete events (B/C/D).
- """
- import hashlib
- import sys
- ORIGINAL_SHA256 = "31631d3d590227e7389bfa4c429c83179bf63f7cf855c521576c349a79250c0c"
- BASE = 0x08048000
- RET4 = bytes.fromhex("b804000000c3") # mov eax,4 ; ret
- PATCHES = [
- (0x0821E184, bytes.fromhex("5589e55653b8"), RET4),
- (0x0821E3A0, bytes.fromhex("5589e5b80100"), RET4),
- (0x0814F310, bytes.fromhex("53"), bytes.fromhex("c3")),
- ]
- def main():
- if len(sys.argv) not in (2, 3):
- sys.exit(__doc__)
- src = sys.argv[1]
- dst = sys.argv[2] if len(sys.argv) == 3 else src
- data = bytearray(open(src, "rb").read())
- digest = hashlib.sha256(data).hexdigest()
- if digest != ORIGINAL_SHA256:
- sys.exit(f"unexpected input sha256 {digest}; expected the 1.4.1 Linux binary")
- for va, expect, new in PATCHES:
- off = va - BASE
- if data[off:off + len(expect)] != expect:
- sys.exit(f"bytes at {va:#x} do not match; refusing to patch")
- data[off:off + len(new)] = new
- print(f"patched {va:#x} (file offset {off:#x})")
- open(dst, "wb").write(data)
- print(f"wrote {dst} sha256 {hashlib.sha256(data).hexdigest()}")
- if __name__ == "__main__":
- main()
Advertisement