#!/usr/bin/env python3 """Read-only landing/idle ownership guards and bounded original-code probe.""" import argparse import hashlib import json from pathlib import Path import re import struct import subprocess from checkpoint_script_state import EXE_SHA256,find_case,read_va from pe_inspect import PE REA_ID='ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904' RANGES=((0x438bc0,0x4398f2),(0x437940,0x437c3a),(0x437c40,0x437f7f), (0x429910,0x429963),(0x43aff0,0x43b5a0),(0x4260a6,0x426264), (0x43a420,0x43a5cd),(0x458f90,0x458fb6),(0x472480,0x472570), (0x472660,0x472685),(0x40dd90,0x40df7c)) SITES=(('neutral_skips_destination',0x43951e,'3bf70f84a9000000'), ('grounded_old_mode1_helper140',0x437b12,'ff9240010000'), ('grounded_reset_mode',0x437ba5,'66899e04070000'), ('grounded_reset_turn',0x437bac,'899e14060000'), ('destination_sets_dirty',0x47267e,'c6410a01'), ('fall_impact_latch',0x4261c5,'c686981d000001'), ('impact_latch_clear',0x42623f,'c686981d000000')) def collect(original,rea=None): p=PE(find_case(Path(original),'Neutron.exe')) if hashlib.sha256(p.data).hexdigest()!=EXE_SHA256:raise ValueError('Original EXE identity') sites=[] for name,va,b in SITES: if read_va(p,va,len(bytes.fromhex(b))).hex()!=b:raise ValueError(name) sites.append(dict(name=name,va=hex(va),file_offset=hex(p.offset(va-p.base)),bytes=b)) slots=[] for table,slot,target in ((0x4a3bdc,0x140,0x429910),(0x4a3bdc,0xe0,0x40dd90),(0x4a373c,0x37c,0x472970),(0x4a373c,0x3d8,0x43a420),(0x4a373c,0x36c,0x472660)): if struct.unpack('