#!/usr/bin/env python3 """Read-only frame/body integration eligibility, independent of raw control.""" import argparse import hashlib import json from pathlib import Path import struct from checkpoint_script_state import EXE_SHA256, find_case, read_va from pe_inspect import PE SITES = ( ('frame_game_gate', 0x47E531, 'e86a77ffff'), ('physics_before_objects', 0x47E554, 'e867b6ffff'), ('game_gate_globals', 0x475CA0, 'a0ab99500084c07409a01c644f0084c07403b001c332c0c3'), ('pause_store', 0x44E458, 'a2ab995000'), ('pause_override_clear', 0x44E465, '880d1c644f00'), ('body_list_enable', 0x479BE9, 'a0e7694f0084c00f8496000000'), ('body_list_payload', 0x479C1A, '8b730885f67450'), ('body_integrate', 0x479C2B, 'e8f0000000'), ('body_integration_gate', 0x479D58, 'ff921002000084c00f84bd050000'), ('integration_flag_get', 0x4719F0, '8a813e010000c3'), ('integration_flag_set', 0x471A04, '88813e010000'), ('init_get_authored_integration', 0x470612, 'ff97b4000000'), ('init_set_live_integration', 0x47061B, 'ff9714020000'), ('constructor_integration_enabled', 0x46FDDF, '6a018bcde848120000'), ('integration_authored_get', 0x471020, '8a4116c3'), ('integration_authored_set', 0x471037, '884116ff9214020000'), ('physics_impulse', 0x479EBB, 'ff9284020000'), ('physics_acceleration', 0x479F01, 'ff9070020000'), ('physics_velocity', 0x479F8D, 'ff92bc020000'), ) TABLES = ( (0x4A373C, 0x210, 0x4719F0), (0x4A373C, 0x214, 0x471A00), (0x4A373C, 0xB4, 0x471020), (0x4C3CD0, 0x168, 0x44E450), (0x4CE910, 0x168, 0x44E450), (0x4C5A80, 0x168, 0x44E450), ) def eligible(*, frame_valid=True, flag5099ab=False, override4f641c=False, supervisor=True, editor=False, bodies_enabled=True, registered=True, body_integration=True, raw_control=None): """Source-gate projection, not original execution; raw owner is not a gate.""" return (frame_valid and (not flag5099ab or override4f641c) and supervisor and not editor and bodies_enabled and registered and body_integration) def collect(root): pe = PE(find_case(Path(root), 'Neutron.exe')) if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256: raise ValueError('Unsupported original EXE') sites = [] for name, va, expected in SITES: actual = read_va(pe, va, len(bytes.fromhex(expected))).hex() if actual != expected: raise ValueError(f'{name} changed at {va:#x}: {actual}') sites.append(dict(name=name, va=hex(va), file_offset=hex(pe.offset(va-pe.base)), bytes=actual)) tables = [] for table, slot, target in TABLES: if struct.unpack('