Run body and fire phases during scripted control locks
This commit is contained in:
1 parent
5876da112c
commit
c285b57091
35 files changed
+1503
-45
No files matched your search
@@ -0,0 +1,179 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only CAM/MCA/AI preparation provenance and bounded event projection."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
from dataclasses import dataclass, replace
|
||||
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 = (
|
||||
('cam_already_active_guard', 0x4165AB, '389e800900000f856c040000'),
|
||||
('cam_control_none_branch', 0x4165F8, '0f84fc000000'),
|
||||
('cam_control_null_compare', 0x4165FE, '6864d04e00'),
|
||||
('cam_named_control', 0x41662A, 'ff9218010000'),
|
||||
('cam_raw_owner_guard', 0x416635, 'a1e49950003bc30f84a9000000'),
|
||||
('cam_owner438', 0x41665D, 'ff9038040000'),
|
||||
('cam_owner410', 0x41666B, 'ff9210040000'),
|
||||
('cam_owner_euler', 0x41667E, 'ff9028030000'),
|
||||
('cam_cached_euler', 0x4166A0, '81c174020000'),
|
||||
('cam_flatten_logical_euler', 0x4166E5, 'ff922c030000'),
|
||||
('cam_clear_control', 0x4166F4, 'ff9018010000'),
|
||||
('cam_target_resolution_after_control', 0x416754, 'e817d90500'),
|
||||
('mca_activation_index_reset', 0x4312A7, '899ea40e0000'),
|
||||
('mca_first_none_guard', 0x431300, '0f8462030000'),
|
||||
('mca_first_none_return', 0x431668, '5f5e5d5b83c420c3'),
|
||||
('mca_first_target_lookup', 0x43131A, 'e8512d0400'),
|
||||
('mca_first_target_missing_continues', 0x431330, '0f84e9000000'),
|
||||
('mca_target_animation_prelude', 0x431417, 'ff92e0000000'),
|
||||
('mca_raw_owner_guard', 0x431502, '8b0de49950003bcb0f849d000000'),
|
||||
('mca_owner410', 0x431512, 'ff9210040000'),
|
||||
('mca_owner_euler', 0x431525, 'ff9028030000'),
|
||||
('mca_flatten_logical_euler', 0x431565, 'ff922c030000'),
|
||||
('mca_cached_euler', 0x431578, '0574020000'),
|
||||
('mca_owner438', 0x431598, 'ff9038040000'),
|
||||
('mca_clear_control', 0x4315A7, 'ff9218010000'),
|
||||
('mca_start_first_shot', 0x431600, 'ff90e0000000'),
|
||||
('mca_later_shot_dispatch', 0x430E87, 'ff90e0000000'),
|
||||
('mca_finish_dispatch', 0x430ED8, 'ff92e4000000'),
|
||||
('mca_shot_sound_guard', 0x431771, '83bc86e40d0000ff'),
|
||||
('mca_shot_target_lookup', 0x4317C1, 'e8aa280400'),
|
||||
('mca_shot_sound_start', 0x431838, 'e853bb0400'),
|
||||
('mca_shot_target_animation', 0x431909, 'ff92e0000000'),
|
||||
('mca_completion_null_compare', 0x4311F4, '6864d04e00'),
|
||||
('mca_completion_control', 0x431222, 'ff9218010000'),
|
||||
('ai_interface_to_complete', 0x40CA72, '81c138ffffffe883f8ffff'),
|
||||
('ai_control_descriptor', 0x40C1A5, '8d868c0900006a01506818ce4e00'),
|
||||
('ai_null_control_guard', 0x40C4AD, '8b0de499500085c97466'),
|
||||
('ai_owner410', 0x40C4B9, 'ff9210040000'),
|
||||
('ai_clear_control', 0x40C527, 'ff9218010000'),
|
||||
('ai_marker_root', 0x40C732, 'ff9010030000'),
|
||||
('ai_set_root', 0x40C757, 'ff9214030000'),
|
||||
('ai_yaw_sentinel', 0x40C88F, '81bd940b0000000080bf'),
|
||||
('ai_set_authored_yaw', 0x40C93E, 'ff9274010000'),
|
||||
('ai_set_cached_euler', 0x40C94C, '81c334030000'),
|
||||
('jimmy_prepare_base', 0x42AFC3, 'e888f70000'),
|
||||
('jimmy_prepare_stop', 0x42AFDE, '6840d04e008bceff9250010000'),
|
||||
('prepare_speed_zero', 0x43A758, 'c7860806000000000000'),
|
||||
('prepare_velocity_xyz', 0x43A764, '6a006a006a008bceff90c4020000'),
|
||||
('jimmy438_cleanup', 0x42AE08, '8b8640ffffff8d8e40ffffffff9078010000'),
|
||||
('jimmy438_runtime_flags', 0x42AE1A, 'b0018886651d0000a282814f00'),
|
||||
('default_already_owned', 0x447D5C, '3bc6753f'),
|
||||
('default_restore_control', 0x447E27, 'ff9018010000'),
|
||||
('default_snap_strict', 0x447E9D, 'd81dace54800dfe0f6c441'),
|
||||
('input_owner_guard', 0x475A9C, '8b0de499500085c97409'),
|
||||
('input_owner_dispatch', 0x475AA9, 'ff92cc030000'),
|
||||
('jump_held_raw_checks', 0x4378DC, 'a06598500084c0751fa048985000'),
|
||||
)
|
||||
|
||||
TABLES = (
|
||||
('CAM activation', 0x498060, 0xD8, 0x4165A0),
|
||||
('MCA activation', 0x4A93C8, 0xD8, 0x431280),
|
||||
('MCA per-shot', 0x4A93C8, 0xE0, 0x431750),
|
||||
('MCA completion', 0x4A93C8, 0xE4, 0x4311F0),
|
||||
('Jimmy410', 0x4A373C, 0x410, 0x42AFC0),
|
||||
('Jimmy438', 0x4A373C, 0x438, 0x42AE00),
|
||||
('Jimmy Euler getter', 0x4A373C, 0x328, 0x4723F0),
|
||||
('Jimmy Euler setter', 0x4A373C, 0x32C, 0x472450),
|
||||
('Jimmy position setter', 0x4A373C, 0x314, 0x472360),
|
||||
('Jimmy authored Euler setter', 0x4A373C, 0x174, 0x4716D0),
|
||||
('Jimmy stop sound', 0x4A3BDC, 0x148, 0x429A00),
|
||||
('Jimmy action request', 0x4A3BDC, 0x150, 0x43AFF0),
|
||||
('Jimmy gadget cleanup', 0x4A3BDC, 0x178, 0x427FF0),
|
||||
('Jimmy held jump', 0x4A3BDC, 0x158, 0x4378D0),
|
||||
)
|
||||
|
||||
# Full body identity guards negative claims as well as selected positive sites.
|
||||
BODY_RANGES = (('MCA per-shot', 0x431750, 0x4319A2),
|
||||
('held jump getter', 0x4378D0, 0x43793A))
|
||||
|
||||
|
||||
def preparation_events(kind: str, raw_owner: str | None) -> list[str]:
|
||||
"""Local source-event projection, not an original routine execution.
|
||||
|
||||
Activation preconditions have already reached the inspected preparation
|
||||
block. Real target, sound and skip handling are intentionally not simulated.
|
||||
"""
|
||||
events = []
|
||||
if kind == 'cam_null':
|
||||
if raw_owner:
|
||||
events += [raw_owner + ':438', raw_owner + ':410', raw_owner + ':flatten_euler']
|
||||
events += ['control:NULL']
|
||||
elif kind == 'mca_activation':
|
||||
if raw_owner:
|
||||
events += [raw_owner + ':410', raw_owner + ':flatten_euler', raw_owner + ':438', 'control:NULL']
|
||||
elif kind == 'ai_null':
|
||||
if raw_owner:
|
||||
events += [raw_owner + ':410']
|
||||
events += ['control:NULL']
|
||||
elif kind in ('mca_next_shot', 'default_restore'):
|
||||
pass # Neither boundary dispatches410/438.
|
||||
else:
|
||||
raise ValueError('Unknown preparation boundary')
|
||||
return events
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class JetpackPreparationState:
|
||||
speed: float = 350
|
||||
velocity: tuple[float, float, float] = (10, 20, 30)
|
||||
impulse: tuple[float, float, float] = (1, 2, 3)
|
||||
acceleration: tuple[float, float, float] = (4, 5, 6)
|
||||
mode: int = 1
|
||||
jump: int = 3
|
||||
hold: float = .625
|
||||
fire: float = 6.125
|
||||
selected_gadget: int = 3
|
||||
euler: tuple[float, float, float] = (15, 150, 25)
|
||||
|
||||
|
||||
def project_jetpack_preparation(state: JetpackPreparationState, kind: str):
|
||||
"""Bounded−1/3 selected-gadget projection; do not generalize other gadgets."""
|
||||
if state.selected_gadget not in (-1, 3):
|
||||
raise ValueError('Other gadget cleanup policies are outside this fixture')
|
||||
result = state
|
||||
for event in preparation_events(kind, 'JIM1'):
|
||||
if event.endswith(':410'):
|
||||
result = replace(result, speed=0, velocity=(0, 0, 0))
|
||||
elif event.endswith(':438'):
|
||||
result = replace(result, selected_gadget=-1)
|
||||
elif event.endswith(':flatten_euler'):
|
||||
result = replace(result, euler=(0, result.euler[1], 0))
|
||||
return result
|
||||
|
||||
|
||||
def collect(root):
|
||||
pe = PE(find_case(Path(root), 'Neutron.exe'))
|
||||
if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256:
|
||||
raise ValueError('Unsupported source 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, table, slot, target in TABLES:
|
||||
actual, = struct.unpack('<I', read_va(pe, table+slot, 4))
|
||||
if actual != target:
|
||||
raise ValueError(f'{name} target changed')
|
||||
tables.append(dict(name=name, table=hex(table), slot=hex(slot), target=hex(target),
|
||||
file_offset=hex(pe.offset(table+slot-pe.base))))
|
||||
bodies = []
|
||||
for name, start, end in BODY_RANGES:
|
||||
bodies.append(dict(name=name, start=hex(start), end=hex(end),
|
||||
sha256=hashlib.sha256(read_va(pe, start, end-start)).hexdigest()))
|
||||
return dict(sha256=EXE_SHA256, sites=sites, tables=tables, bodies=bodies,
|
||||
scope='Static source bytes and a bounded interpretation fixture; no source execution.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli = argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument('original', type=Path)
|
||||
print(json.dumps(collect(cli.parse_args().original), indent=2))
|
||||
Reference in new issue
Block a user