#!/usr/bin/env python3 """Guard the original menu background and successful TSK-to-level reuse chain. This proves a conditional source lifecycle, not a whole-original Carl capture. Originals remain read-only; output contains source coordinates and evidence. """ import argparse import hashlib import json from pathlib import Path import re import struct import sys from checkpoint_script_state import EXE_SHA256, find_case, read_va, rel_call_target from pe_inspect import PE sys.path.insert(0, str(Path(__file__).resolve().parents[1]/'levels')) import gam REA_ID = 'ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904' CALLS = ((0x46a641, 0x46b160), (0x46a660, 0x46a310), (0x46a33d, 0x44d0e0), (0x44d122, 0x459110), (0x404b54, 0x460e70), (0x460ef0, 0x4603f0), (0x4587f3, 0x470540), (0x46e0d9, 0x473710)) SITES = ( (0x46ba18, '899d08080000', 'initial splash stage0'), (0x46bf07, 'd81da0e54800', 'strict elapsed3s stage gate'), (0x46bfef, 'c7860808000002000000', 'stage1 to stage2'), (0x46bff9, '68004a4f00', 'background level1d.gam'), (0x46c004, 'ff9214010000', 'delayed background request app114'), (0x46dfb6, '66c781fa0700000200', 'two-callback countdown'), (0x46bedf, 'c6864c07000001', 'countdown underflow requests teardown/load'), (0x46c05e, 'ff9204010000', 'consume pending request app104'), (0x46e5c3, 'ff5228', 'every existing nonnull object gets Init28'), (0x4705b3, 'ff978c000000', 'Init reads stored lifetime'), (0x4705bc, 'ff9704020000', 'Init restores live lifetime'), (0x460a50, '8b0de4995000', 'TSK character request requires raw controlled owner'), (0x460a65, 'ff5218', 'TSK owner must accept C3DJIMMY type'), (0x460bd1, 'ff9268010000', 'TSK requests level through player168'), (0x42275a, 'c685c900000001', 'Jimmy reusable game09=1'), ) SLOTS = ((0x4d5ea0, 0xc4, 0x46bec0), (0x4d5ea0, 0x114, 0x46dfb0), (0x4d5ea0, 0x104, 0x46dff0), (0x4d5ea0, 0x128, 0x46e570), (0x4d0c0c, 0x28, 0x44d4e0), (0x4c444c, 0x28, 0x44d4e0), (0x4d0c0c, 0x200, 0x4719b0), (0x4c444c, 0x200, 0x4719b0), (0x4d0c0c, 0x420, 0x472970), (0x4c444c, 0x420, 0x472970), (0x4d0c0c, 0x40c, 0x44df30), (0x4c444c, 0x40c, 0x44df30), (0x4a3bdc, 0x168, 0x43b5a0), (0x4a373c, 0x200, 0x4719b0), (0x4a373c, 0x420, 0x472970)) RANGES = ((0x46b9e0, 0x46ba2a), (0x46bec0, 0x46c067), (0x46df70, 0x46dfe5), (0x44d0e0, 0x44d161), (0x460e70, 0x460f00), (0x460a50, 0x460bdd), (0x46e570, 0x46e680), (0x46e6a0, 0x46e710), (0x46ff4a, 0x46ff81), (0x4226b5, 0x4226c5), (0x422750, 0x422765), (0x44df30, 0x44df44)) def collect(original, rea): pe = PE(find_case(original, 'Neutron.exe')) if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256: raise ValueError('Unexpected executable') if struct.unpack('