Recover Grappler aim gating and implement verified ray constraint components

This commit is contained in:
UnixNight committed 2026-11-03 22:22:45 -05:00
1 parent 0c913d15aa
commit ffea678e90
21 files changed
+1604 -16

No files matched your search

+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env python3
"""Guarded VR08 ray/caller context and imported original-code probe results."""
import argparse
from collections import Counter
import hashlib
import json
from pathlib import Path
import re
import struct
from grappler import collect as source_contract
from checkpoint_script_state import find_case,read_va
from pe_inspect import PE
from shrink_heading import DLL_SHA256
RANGES=(('aim',0x42a406,0x42a652),('constraint',0x429ea0,0x429fa4),
('impact_post_base',0x42a69b,0x42a6f1),('input_gate',0x426030,0x4260a6),
('input_return',0x4269c3,0x4269cd),('primary_poll',0x42a7a0,0x42a7d6),
('consuming_enter',0x46a3e0,0x46a3fb),('aim_return',0x42a652,0x42a660))
def collect(original):
contract=source_contract(original);original=Path(original)
pe=PE(find_case(original,'Neutron.exe'))
if struct.unpack('<I',read_va(pe,0x4d0204,4))[0]!=0x475cd0:
raise ValueError('Changed VR08 polygon filter virtual')
if read_va(pe,0x475cd0,5)!=bytes.fromhex('32c0c21800'):
raise ValueError('Changed false polygon filter leaf')
if read_va(pe,0x426098,14)!=bytes.fromhex('ff908801000084c00f851d090000'):
raise ValueError('Changed aim-to-active-input return gate')
dll_hash=hashlib.sha256(find_case(original,'OMT2.dll').read_bytes()).hexdigest()
if dll_hash!=DLL_SHA256:raise ValueError('Unexpected original DLL')
return dict(source_sha256=contract['sha256'],dll_sha256=dll_hash,
vr08_filter=dict(table='0x4d00d0',slot='0x134',target='0x475cd0'),
ranges=[dict(kind=k,va=hex(a),end_va=hex(b),file_offset=hex(pe.offset(a-pe.base)),
sha256=hashlib.sha256(read_va(pe,a,b-a)).hexdigest()) for k,a,b in RANGES],
scope='Synthetic ray/material/cursor accessors; original DLL magnitude; constraint before body and contact after stubbed base; no game entrypoint')
def reference(original,log,executable):
report=collect(original);log=Path(log);text=log.read_text()
if 'GRAPPLER_QUERY_CONSTRAINT_COMPLETE' not in text:raise ValueError('Probe incomplete')
cases=[]
for line in text.splitlines():
match=re.fullmatch(r'CASE (aim|constraint|impact) ([\w-]+) in=([^ ]+) out=([^ ]+)',line)
if match:
kind,name,p,o=match.groups();cases.append(dict(kind=kind,name=name,
input=[float(x) for x in p.split(',')],observed=[float(x) for x in o.split(',')]))
if Counter(c['kind'] for c in cases)!=dict(aim=23,constraint=10,impact=9):raise ValueError('Expected42 complete cases')
root=Path(__file__).parent
report.update(cases=cases,generators={name:hashlib.sha256((root/name).read_bytes()).hexdigest()
for name in ('grappler_query_probe.c','grappler_scalar_probe.c')},
executable_sha256=hashlib.sha256(Path(executable).read_bytes()).hexdigest(),
log_sha256=hashlib.sha256(log.read_bytes()).hexdigest())
return report
if __name__=='__main__':
cli=argparse.ArgumentParser(description=__doc__);cli.add_argument('original',type=Path)
cli.add_argument('--log',type=Path);cli.add_argument('--executable',type=Path);cli.add_argument('--output',type=Path)
args=cli.parse_args()
if bool(args.log)!=bool(args.executable):cli.error('--log and --executable are required together')
if args.output and (args.output.resolve().is_relative_to(args.original.resolve())
or args.original.resolve().is_relative_to(args.output.resolve())):cli.error('Output must be separate from originals')
result=reference(args.original,args.log,args.executable) if args.log else collect(args.original)
text=json.dumps(result,indent=2)+'\n'
if args.output:args.output.parent.mkdir(parents=True,exist_ok=True);args.output.write_text(text)
else:print(text,end='')