#!/usr/bin/env python3 """Read-only full body/support callgraph guards for the isolated component probe.""" import argparse import hashlib import json from pathlib import Path import struct from collision_dispatch import collect as dispatch_collect, POINTERS from collision_response import header from checkpoint_script_state import find_case, read_va from pe_inspect import PE BODIES=( ('body_step',0x479D20,0x47A32A,'5f4b05518bef5e5f0ecc3909ff0de0b43d2c7350c6beae0c4f797d3238a77fa1'), ('friction',0x47A330,0x47A421,'3ac4d0268edb5fa4f5689a87fdc36759c12589caf76b2286b1817f2204a91155'), ('support',0x47B890,0x47BBB0,'5901c9475092af33db8015b58416475e9fa2c527b9e8860e36c0b4cc0ff3f25d'), ('support_query',0x47C6E0,0x47CA8B,'0f6127ef4e4bf7986ef195340002fbd97d3b6f1151377d053b1ad8d0c096cf57'), ('support_triangle',0x469A10,0x469B70,'6acde1608be611364a84ae8dadaa2f2675231f5ee9612445e7cb5e375e5d4e77')) GLOBALS=sorted(set((*POINTERS,0x48D920,0x4D6A08,0x5CFC00,0x5CFC04,0x5CFC08, 0x695D49,0x695D5C,0x695D84,0x695D54,0x695D58,0x695D68,0x5CFC7C, *range(0x5CFC40,0x5CFC70,4)))) def collect(original): report=dispatch_collect(original);pe=PE(find_case(Path(original),'Neutron.exe')) for name,start,end,digest in BODIES: body=read_va(pe,start,end-start) if hashlib.sha256(body).hexdigest()!=digest:raise ValueError(f'Changed body {name}') report['bodies'].append(dict(name=name,va=hex(start),file_offset=hex(pe.offset(start-pe.base)),length=end-start,sha256=digest)) for target in GLOBALS: value=struct.pack('