29 lines
1.3 KiB
Python
29 lines
1.3 KiB
Python
"""Use the packaged main file via an equal-length AVM2 patch of the original loader."""
|
|
|
|
import hashlib
|
|
from pathlib import Path
|
|
|
|
|
|
def patch(source: Path, output: Path) -> None:
|
|
original = source.read_bytes()
|
|
if hashlib.sha256(original).hexdigest() != "4728d0e23bdf0d6b1468e8cd39f97535e65a09bfa40044e7c73af7e1655af741":
|
|
raise ValueError("Expected the unmodified 1.9.68 MYRDyd.swf")
|
|
start = 0x28A07
|
|
before = bytes.fromhex("60 05 46 0f 00 66 2f 80 14 d5 60 05 2c 80 02 46 2b 01 85 d6")
|
|
# File.applicationDirectory.resolvePath("MYRMain.app").url -> local2.
|
|
after = bytes.fromhex("60 3d 66 43 2c 80 02 46 3f 01 66 41 85 d6 02 02 02 02 02 02")
|
|
if original[start:start + len(before)] != before or len(before) != len(after):
|
|
raise ValueError("Original instruction block mismatch")
|
|
patched = original[:start] + after + original[start + len(before):]
|
|
output.write_bytes(patched)
|
|
print(f"Loader: {len(patched)} bytes, {sum(a != b for a, b in zip(before, after))} changed bytes; all offsets retained")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import argparse
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("source", type=Path)
|
|
parser.add_argument("output", type=Path)
|
|
args = parser.parse_args()
|
|
patch(args.source, args.output)
|