#!/usr/bin/env python3 """Read-only retained physical registration and logical-root instruction guards.""" 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=( ('loader_clears_registration',0x46E131,'c6819e04000000'), ('jimmy_registration_guard',0x42AB50,'8a819e04000084c07505'), ('jimmy_registration_jump',0x42AB5A,'e971780300'), ('postload_registration_callback',0x4238B4,'ff502c'), ('registration_base_init',0x4623E7,'e82465ffff'), ('registration_authored_root',0x462405,'ff926c010000'), ('registration_authored_euler',0x462451,'ff9074010000'), ('registration_add_body',0x462464,'e8d7750100'), ('add_body_zero_authored_vector',0x479A5F,'6a006a006a00ff9250010000'), ('add_body_repeats_init',0x479A6F,'ff5028'), ('add_body_list',0x479A72,'8b3d3c5d6900'), ('add_body_node_bytes',0x479A78,'6a0c'), ('add_body_interface_payload',0x479AA9,'8930'), ('add_body_count',0x479AAB,'ff05405d6900'), ) TABLES=(('Jimmy InitPhysics',0x2C,0x42AB50), ('authored root',0x16C,0x471630), ('authored Euler',0x174,0x4716D0), ('Jimmy Init',0x28,0x437890)) def collect(original): pe=PE(find_case(Path(original),'Neutron.exe')) if hashlib.sha256(pe.data).hexdigest()!=EXE_SHA256: raise ValueError('Unsupported 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 name,slot,expected in TABLES: actual=struct.unpack('