Document architecture checkpoint and restore original task callback order
This commit is contained in:
1 parent
69d0187a21
commit
531883aaac
45 files changed
+2935
-43
No files matched your search
@@ -0,0 +1,108 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only ordinary scene-loader ownership and keyboard-reset byte evidence."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import struct
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va, rel_call_target
|
||||
from pe_inspect import PE
|
||||
|
||||
SITES = (
|
||||
("editor_constructor_vtable", 0x46B200, "c74500a05e4d00"),
|
||||
("editor_global_owner", 0x46B237, "892d80995000"),
|
||||
("request_pending", 0x46DF76, "c6814c07000001"),
|
||||
("request_filename", 0x46DF7D, "8d914d070000"),
|
||||
("update_pending_dispatch", 0x46C05E, "ff9204010000"),
|
||||
("teardown_first_filter", 0x46E032, "ff9200020000"),
|
||||
("teardown_first_uninit", 0x46E054, "ff5220"),
|
||||
("teardown_second_uninit", 0x46E091, "ff5234"),
|
||||
("teardown_delete_mark", 0x46E0CA, "c6460601"),
|
||||
("teardown_delete_sweep", 0x46E0D9, "e832560000"),
|
||||
("teardown_database_close", 0x46E117, "e8e4ceffff"),
|
||||
("ordinary_gam_load", 0x46E152, "ff90fc000000"),
|
||||
("ordinary_pending_clear", 0x46E158, "c6854c07000000"),
|
||||
("object_reuse_test", 0x46E45A, "ff921c010000"),
|
||||
("object_reuse_lookup", 0x46E46E, "ff9010010000"),
|
||||
("object_factory", 0x46E49A, "e811b8feff"),
|
||||
("ordinary_postload_registry", 0x46E4FF, "ff9228010000"),
|
||||
("registry_init_callback", 0x46E5C3, "ff5228"),
|
||||
("registry_postload_callback", 0x46E61A, "ff920c040000"),
|
||||
("registry_timer_reset", 0x46E694, "e8d7fd0000"),
|
||||
("destruction_predicate", 0x4719B0, "8a8139010000c3"),
|
||||
("destruction_predicate_set", 0x4719C4, "888139010000"),
|
||||
("persistent_flag_setter", 0x470F47, "884111ff9204020000"),
|
||||
("jimmy_constructor_flag", 0x4226BF, "e87ce80400"),
|
||||
("goddard_constructor_flag", 0x41C99E, "e89d450500"),
|
||||
("jimmy_constructor_reusable", 0x42275A, "c685c900000001"),
|
||||
("goddard_constructor_reusable", 0x41C9C0, "c686c900000001"),
|
||||
("load_prefix_caption_cleanup", 0x46E26C, "e86f840000"),
|
||||
("load_prefix_physics_cleanup", 0x46E271, "e88aad0000"),
|
||||
("lab_constructor_base", 0x44F358, "e853dfffff"),
|
||||
("game_constructor_base", 0x44D306, "e895720200"),
|
||||
("game_constructor_clear_control", 0x474683, "e8b8130000"),
|
||||
("game_constructor_current_game", 0x474688, "893548995000"),
|
||||
("lab_game_preserve_predicate", 0x44D472, "ff9004020000"),
|
||||
("keyboard_down_array", 0x46A370, "c6803898500001"),
|
||||
("keyboard_up_array", 0x46A390, "c6803898500000"),
|
||||
("acquired_reset_key_test", 0x4235D8, "a08a98500084c07423"),
|
||||
("acquired_reset_count", 0x4235E2, "b968100000"),
|
||||
("acquired_reset_address", 0x4235E9, "bf38844f00f3ab"),
|
||||
)
|
||||
|
||||
VTABLES = (
|
||||
("editor update", 0x4D5EA0, 0xC4, 0x46BEC0),
|
||||
("editor load GAM", 0x4D5EA0, 0xFC, 0x46E170),
|
||||
("editor request load", 0x4D5EA0, 0x100, 0x46DF70),
|
||||
("editor consume load", 0x4D5EA0, 0x104, 0x46DFF0),
|
||||
("editor cleanup", 0x4D5EA0, 0x10C, 0x46E710),
|
||||
("editor find reusable", 0x4D5EA0, 0x110, 0x46E6E0),
|
||||
("editor test reusable", 0x4D5EA0, 0x11C, 0x46E6A0),
|
||||
("editor reset/postload", 0x4D5EA0, 0x128, 0x46E570),
|
||||
("Jimmy destruction predicate", 0x4A373C, 0x200, 0x4719B0),
|
||||
("Jimmy initialization", 0x4A373C, 0x28, 0x437890),
|
||||
("Jimmy placement PostLoad", 0x4A373C, 0x40C, 0x423610),
|
||||
("Jimmy key-gated reset", 0x4A373C, 0x3C8, 0x4235B0),
|
||||
("lab game destruction predicate", 0x4C386C, 0x200, 0x4719B0),
|
||||
("lab game predicate setter", 0x4C386C, 0x204, 0x4719C0),
|
||||
)
|
||||
|
||||
|
||||
def collect(root: Path) -> dict:
|
||||
pe = PE(find_case(root, "Neutron.exe"))
|
||||
sites = []
|
||||
for name, va, expected in SITES:
|
||||
actual = read_va(pe, va, len(bytes.fromhex(expected))).hex()
|
||||
item = dict(name=name, va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
|
||||
expected=expected, actual=actual, matches=actual == expected)
|
||||
if actual.startswith("e8"):
|
||||
item["direct_call_target"] = hex(rel_call_target(pe, va))
|
||||
sites.append(item)
|
||||
tables = []
|
||||
for name, table, slot, expected in VTABLES:
|
||||
target = struct.unpack("<I", read_va(pe, table + slot, 4))[0]
|
||||
tables.append(dict(name=name, table=hex(table), slot=hex(slot),
|
||||
file_offset=hex(pe.offset(table+slot-pe.base)),
|
||||
target=hex(target), matches=target == expected))
|
||||
digest = hashlib.sha256(pe.data).hexdigest()
|
||||
return dict(module="Neutron.exe", sha256=digest, known_binary=digest == EXE_SHA256,
|
||||
sites=sites, vtables=tables, acquired_reset_virtual_key=0x50988A-0x509838,
|
||||
scope="Static source instructions only, no original runtime execution.")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
cli = argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument("original", type=Path)
|
||||
result = collect(cli.parse_args().original)
|
||||
print(json.dumps(result, indent=2))
|
||||
if not result["known_binary"] or not all(s["matches"] for s in result["sites"] + result["vtables"]):
|
||||
raise SystemExit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user