Integrate source airborne tilt and logical-root rendering
This commit is contained in:
1 parent
a61f1b0284
commit
27be8ed630
36 files changed
+1953
-62
No files matched your search
@@ -0,0 +1,120 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only Jimmy destination-Euler and retained air-pitch ownership evidence."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
import struct
|
||||
from pathlib import Path
|
||||
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va
|
||||
from pe_inspect import PE
|
||||
from retained_streamer import collect as collect_streamer
|
||||
|
||||
REA_ID = 'ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904'
|
||||
SITES = (
|
||||
('constructor_forward_pitch', 0x437445, 'c785ec070000000020c2'),
|
||||
('constructor_backward_pitch', 0x43744f, 'c785f007000000002041'),
|
||||
('ordinary_apply_forward_pitch', 0x437fbc, 'c786ec070000000020c2'),
|
||||
('ordinary_apply_backward_pitch', 0x437fc6, 'c786f007000000002041'),
|
||||
('bubble_apply_forward_pitch', 0x43880a, 'c787ec070000000020c1'),
|
||||
('bubble_apply_backward_pitch', 0x438814, 'c787f007000000002041'),
|
||||
('destination_x', 0x472668, '898174020000'),
|
||||
('destination_y', 0x472672, '899178020000'),
|
||||
('destination_z', 0x472678, '89817c020000'),
|
||||
('destination_marks_dirty', 0x47267e, 'c6410a01'),
|
||||
('init_clears_destination_x', 0x4709ca, '898674020000'),
|
||||
('init_clears_destination_y', 0x4709d0, '898678020000'),
|
||||
('init_clears_destination_z', 0x4709d6, '89867c020000'),
|
||||
('init_enables_facing', 0x4709e2, 'c6460501'),
|
||||
('init_clears_facing_dirty', 0x4709e6, '88460a'),
|
||||
('init_other_yaw_scalar', 0x4378c1, '89961c060000'),
|
||||
('ground_auto_turn_destination', 0x43957c, 'ff926c030000'),
|
||||
('ground_auto_destination', 0x439599, 'ff926c030000'),
|
||||
('ground_ordinary_destination', 0x4395c9, 'ff936c030000'),
|
||||
('air_destination', 0x439e2d, 'ff956c030000'),
|
||||
('base_update_before_owner_gate', 0x43796a, 'e8e166fdff'),
|
||||
('raw_owner_gate', 0x437a1b, '8b0de4995000'),
|
||||
('facing_enabled_read', 0x43a433, '8a4605'),
|
||||
('facing_dirty_read', 0x43a43e, '8a460a'),
|
||||
('facing_clears_dirty', 0x43a44f, 'c6460a00'),
|
||||
('bubble_cleanup_mode', 0x42804f, '66899ec4070000'),
|
||||
('start_authored_rotation_get', 0x4239b2, 'ff9070010000'),
|
||||
('start_full_rotation_set', 0x4239e6, 'ff9674010000'),
|
||||
('authored_rotation_calls_current', 0x471702, 'ff9030030000'),
|
||||
('current_euler_x', 0x472428, '898124020000'),
|
||||
('current_euler_y', 0x472432, '899128020000'),
|
||||
('current_euler_z', 0x472438, '89812c020000'),
|
||||
)
|
||||
SLOTS = ((0x28,0x437890),(0x170,0x4716a0),(0x174,0x4716d0),
|
||||
(0x328,0x4723f0),(0x330,0x472420),(0x334,0x458f90),
|
||||
(0x36c,0x472660),(0x3d8,0x43a420),(0x410,0x42afc0))
|
||||
RANGES = ((0x437890,0x4378cc),(0x437c40,0x437f7f),
|
||||
(0x43915d,0x4395cf),(0x439900,0x439e33),
|
||||
(0x472660,0x472685),(0x43a420,0x43a5cd),
|
||||
(0x4709c8,0x4709f8),(0x428037,0x4280cc),
|
||||
(0x4239a3,0x4239ec),(0x4716d0,0x471716),
|
||||
(0x472420,0x472441))
|
||||
|
||||
|
||||
def collect(root, rea_disassembly=None):
|
||||
root=Path(root)
|
||||
pe=PE(find_case(root,'Neutron.exe'))
|
||||
if hashlib.sha256(pe.data).hexdigest()!=EXE_SHA256:
|
||||
raise ValueError('Unsupported original EXE identity')
|
||||
sites=[]
|
||||
for name,va,expected in SITES:
|
||||
actual=read_va(pe,va,len(bytes.fromhex(expected))).hex()
|
||||
if actual!=expected:raise ValueError(f'Changed source {name} at {va:#x}')
|
||||
sites.append(dict(name=name,va=hex(va),file_offset=hex(pe.offset(va-pe.base)),bytes=actual))
|
||||
slots=[]
|
||||
for slot,target in SLOTS:
|
||||
actual=struct.unpack('<I',read_va(pe,0x4a373c+slot,4))[0]
|
||||
if actual!=target:raise ValueError(f'Changed Jimmy virtual slot {slot:#x}')
|
||||
slots.append(dict(table='0x4a373c',slot=hex(slot),target=hex(target),
|
||||
file_offset=hex(pe.offset(0x4a373c+slot-pe.base))))
|
||||
streamer=collect_streamer(root)
|
||||
if not streamer['known_binary'] or not all(r['exact_descriptor_set'] for r in streamer['route']):
|
||||
raise ValueError('Unsupported retained property/route evidence')
|
||||
fields={0x72c,0x730} #Complete7EC/7F0 are game-interface72C/730.
|
||||
if any(int(d['interface_offset'],16) in fields for d in streamer['descriptors']):
|
||||
raise ValueError('Route descriptor unexpectedly owns an air pitch field')
|
||||
route=[]
|
||||
#Reuse the same bounded reader already used by the registered-property audit.
|
||||
import gam
|
||||
for filename in ('gam/level1b.gam','gam/VR04.gam','gam/level1.gam'):
|
||||
path=find_case(root,filename);level=gam.parse(path.read_bytes())
|
||||
jimmy=next(e for e in level.entities if e.kind=='3JIM');j=jimmy.values()
|
||||
start=next(e for e in level.entities if e.kind=='STRT' and e.values().get('ObjectTag')==j['StartPoint'])
|
||||
v=start.values()
|
||||
route.append(dict(file=filename,sha256=hashlib.sha256(path.read_bytes()).hexdigest(),
|
||||
player_offset=hex(jimmy.offset),start_offset=hex(start.offset),
|
||||
start_tag=j['StartPoint'],rotation=[v['Rotation'+axis] for axis in 'XYZ']))
|
||||
result=dict(source_sha256=EXE_SHA256,rea_evidence_id=REA_ID,sites=sites,slots=slots,
|
||||
ranges=[dict(va=hex(a),file_offset=hex(pe.offset(a-pe.base)),length=b-a,
|
||||
sha256=hashlib.sha256(read_va(pe,a,b-a)).hexdigest()) for a,b in RANGES],
|
||||
pitch_seed_fields=dict(complete=['0x7ec','0x7f0'],interface=['0x72c','0x730']),
|
||||
current_euler_fields=['0x224','0x228','0x22c'],
|
||||
destination_euler_fields=['0x274','0x278','0x27c'],
|
||||
route=route,scope='Static source/route evidence; no new original execution or live-port conformance claim.')
|
||||
if rea_disassembly:
|
||||
r=json.loads(Path(rea_disassembly).read_text())['records'][0]
|
||||
if r['evidence_id']!=REA_ID or r['subject']['digest']['sha256']!=EXE_SHA256:
|
||||
raise ValueError('Unexpected retained REA artifact identity')
|
||||
rows=[]
|
||||
for line in r['raw_result']['stdout'].splitlines():
|
||||
m=re.match(r'\s*([0-9a-f]+):',line)
|
||||
if m:rows.append((int(m[1],16),line))
|
||||
result['bounded_rea_scalar_references']=[dict(va=hex(va),instruction=l.strip()) for va,l in rows
|
||||
if 0x437290<=va<0x43b820 and ('0x61c(' in l or '0x6dc(' in l)]
|
||||
result['bounded_rea_ground_apply_calls']=[dict(va=hex(va),instruction=l.strip()) for va,l in rows
|
||||
if 0x437c40<=va<0x437f7f and '\tcall ' in l]
|
||||
return result
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
p=argparse.ArgumentParser(description=__doc__)
|
||||
p.add_argument('original',type=Path)
|
||||
p.add_argument('--rea-disassembly',type=Path)
|
||||
a=p.parse_args()
|
||||
print(json.dumps(collect(a.original,a.rea_disassembly),indent=2))
|
||||
Reference in new issue
Block a user