#!/usr/bin/env python3 """Read-only VR04 serialized registration inventory and copied-code loop probe.""" import argparse from collections import Counter 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 from rtti_map import rtti_map sys.path.insert(0, str(Path(__file__).resolve().parents[1]/'levels')) from gam import parse REA_ID = 'ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904' # Own registration sites, not counts of nested helpers or live runtime nodes. # PostLoad sites dispatch virtual2C; constructor sites directly call the bridge. CLASSES = ( ('3JIM','C3DJimmy',0x422160,0x4a373c,0xc0,'postload',0x4238b4,None), ('3ROC','C3DRocketShip',0x43d840,0x4b25ac,0xc0,'postload',0x43db22,None), ('STRT','C3DStartPoint',0x4422d0,0x4b7654,0xc8,'constructor',0x44249d,0x464210), ('3PHO','C3DPhoneBooth',0x4355a0,0x4adf6c,0xc0,'constructor',0x4356a0,0x4623d0), ('3PAT','C3DPatrolPoint',0x434b30,0x4acee4,0xc8,'constructor',0x434d44,0x464210), ('3PIC','C3DPickupItem',0x4358b0,0x4ae548,0xc8,'constructor',0x435a37,0x464210), ('3SOL','C3DYokianSoldier',0x44bee0,0x4c19c4,0xc0,'constructor',0x44bfa4,0x4623d0), ('3TRO','C3DVRTrophy',0x448c60,0x4be404,0xc0,'constructor',0x448d33,0x4623d0), ('3SM1','C3DSmoke',0x440530,0x4b4f08,0xc8,'no_own_call_in_inspected_chain',None,None), ('3CAM','C3DCutSceneCamera',0x415a00,0x497bfc,0xc8,'no_own_call_in_inspected_chain',None,None), ('3AIT','C3DAITrigger',0x40ba70,0x48f8c0,0xc8,'constructor',0x40be5b,0x464210), ('3CHK','C3DCheckPoint',0x414190,0x4959a8,0xc8,'constructor',0x414323,0x464210), ('LOAD','CLoadLevel',0x457b10,0x4d025c,0xc8,'constructor',0x457cca,0x464210), ) RANGES = ( (0x4623d0,0x46246e,'51906b2746390b64d79865a4ea0cddd03733aa5625d562bbf57264b7fa9b3d63'), (0x464210,0x46429f,'a99be3694789b6b6284b7e171eec0f2f26b59eef6a366265646bf6c8cbd92000'), (0x458910,0x45892b,'9631a8979eaae01bbf611aa19759788fb03daa8888f753dc64a58b7b7982070e'), (0x479a40,0x479aba,'cd3225de887694ae93f8ae226eeecf71322038438c7b587a81c14a504b10ae98'), (0x42ab50,0x42ab5f,'faf97e04eb625de47a2541a07db3a483ca05cd9b9fee870c7ca33d272e6e7e7a'), (0x46e570,0x46e69f,'ef42fea8b45653bbd21064e5d2da15011ddadc1790a7356997c2a7ba363d3c9c'), ) TARGETS = (0x48e5b4,0x695d3c,0x695d40,0x50999c) def collect(original): original = Path(original) pe = PE(find_case(original,'Neutron.exe')) if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256: raise ValueError('Unsupported executable') classes = {} for kind,name,ctor,table,displacement,phase,site,target in CLASSES: tables = rtti_map(pe,name)['vtables'] if not any(int(t['va'],16)==table and int(t['object_displacement'],16)==displacement for t in tables): raise ValueError('RTTI/table identity mismatch') if site: if target and rel_call_target(pe,site)!=target: raise ValueError('Registration bridge call changed') if target is None and read_va(pe,site,3)!=b'\xff\x50\x2c': raise ValueError('PostLoad InitPhysics dispatch changed') methods = {hex(slot):hex(struct.unpack('