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,147 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only Jimmy ownership gate and control-independent fire callback evidence."""
|
||||
from __future__ import annotations
|
||||
|
||||
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 = (
|
||||
('jimmy_global_elapsed_before_ownership', 0x424600, 'd90508844f00d8442404a1e4995000'),
|
||||
('jimmy_null_cleanup_branch', 0x424622, '7577'),
|
||||
('jimmy_null_sound974_stop', 0x424662, 'e839910500'),
|
||||
('jimmy_null_sound97c_stop', 0x42468D, 'e80e910500'),
|
||||
('jimmy_grounded_query', 0x42469F, 'ff9218020000'),
|
||||
('jimmy_normal_radius60', 0x4246DC, '6800007042'),
|
||||
('jimmy_wrapper_ceiling', 0x424BFC, 'ff92a4010000'),
|
||||
('jimmy_wrapper_ground_distance', 0x424C08, 'ff90a8010000'),
|
||||
('jimmy_wrapper_movement', 0x424C34, 'e8072d0100'),
|
||||
('jimmy_wrapper_late_menu', 0x424C3F, 'ff92c8010000'),
|
||||
('jimmy_wrapper_history', 0x424C88, 'ff92b4010000'),
|
||||
('controller_game_gate', 0x437946, 'e855e30300'),
|
||||
('controller_game_gate_exit', 0x43794D, '0f84e0020000'),
|
||||
('controller_elapsed774', 0x437953, 'd9442414d88674070000'),
|
||||
('controller_base_update', 0x43796A, 'e8e166fdff'),
|
||||
('controller_raw_pointer', 0x437A1B, '8b0de4995000'),
|
||||
('controller_identity_compare', 0x437A29, '3bc8'),
|
||||
('controller_not_jimmy_exit', 0x437A2B, '0f8502020000'),
|
||||
('controller_status_gate83e0', 0x437A31, '381de0834f00'),
|
||||
('controller_modal_gate8181', 0x437A3D, '381d81814f00'),
|
||||
('controller_mode_after_gates', 0x437A49, '0fbf8604070000'),
|
||||
('grounded_release_reset_after_gates', 0x437B9E, '66899e2807000066899e04070000899e14060000'),
|
||||
('controller_air_apply', 0x437BC5, 'ff9034010000'),
|
||||
('controller_ground_apply', 0x437C1C, 'ff9230010000'),
|
||||
('controller_final_speed', 0x437C2D, 'ff926c020000'),
|
||||
('fire_game_gate', 0x421FB6, 'e8e53c0500'),
|
||||
('fire_base_update', 0x421FCA, 'e881c0feff'),
|
||||
('fire_owner', 0x421FCF, '8b8efc050000'),
|
||||
('fire_missing_owner_exit', 0x421FD5, '85c90f84df000000'),
|
||||
('fire_owner_support', 0x421FDF, 'ff9218020000'),
|
||||
('fire_grounded_zero', 0x421FE9, 'c7860006000000000000'),
|
||||
('fire_subtract_dt', 0x421FF3, 'd98600060000d8642418'),
|
||||
('fire_store_then_compare', 0x422003, 'd99600060000d81d14d94800'),
|
||||
('fire_positive_energy', 0x42202B, 'd9442418d9e0dc0dd0e54800'),
|
||||
('fire_energy_helper', 0x42203B, 'e8e0880000'),
|
||||
('fire_owner_position_get', 0x422059, 'ff9010030000'),
|
||||
('fire_position_set', 0x42207E, 'ff9214030000'),
|
||||
('fire_owner_euler_get', 0x422091, 'ff9028030000'),
|
||||
('fire_euler_set', 0x4220B6, 'ff922c030000'),
|
||||
('support_force_override', 0x458960, '8a81a0040000'),
|
||||
('support_flag_fallback', 0x45896D, 'e99e900100'),
|
||||
('support_flag_read', 0x471A10, '8a813f010000c3'),
|
||||
('energy_tutorial_lower', 0x42A92B, '3d31305256'),
|
||||
('energy_tutorial_upper', 0x42A932, '3d38305256'),
|
||||
('ceiling_fire_cancel', 0x425159, 'c780c006000000000000'),
|
||||
('ceiling_jump_reset', 0x425139, '66c786e80700000000'),
|
||||
('ceiling_fall_request', 0x425149, 'ff92e0000000'),
|
||||
)
|
||||
|
||||
TABLES = (
|
||||
('Jimmy normal callback', 0x4A373C, 0x3C4, 0x424600),
|
||||
('Jimmy supported predicate', 0x4A373C, 0x218, 0x458960),
|
||||
('Jimmy complete ground apply', 0x4A3BDC, 0x130, 0x437C40),
|
||||
('Jimmy complete air apply', 0x4A3BDC, 0x134, 0x437F90),
|
||||
('Jimmy complete ceiling test', 0x4A3BDC, 0x1A4, 0x425170),
|
||||
('Jimmy complete distance test', 0x4A3BDC, 0x1A8, 0x4252E0),
|
||||
('Jimmy complete ceiling cancellation', 0x4A3BDC, 0x1E0, 0x425120),
|
||||
('Jimmy complete late menu', 0x4A3BDC, 0x1C8, 0x424E80),
|
||||
('Jimmy complete history', 0x4A3BDC, 0x1B0, 0x425490),
|
||||
('Fire normal callback', 0x4A3160, 0x3C4, 0x421FB0),
|
||||
('Fire logical position setter', 0x4A3160, 0x314, 0x472360),
|
||||
('Fire logical Euler setter', 0x4A3160, 0x32C, 0x472450),
|
||||
)
|
||||
|
||||
BODY_HASHES = (
|
||||
('complete_fire_callback', 0x421FB0, 0x113,
|
||||
'9c4aa99608cebb2c5953b94475dce8b732d7613c8a48be37b3090af4cd238e3a'),
|
||||
('complete_movement_callback', 0x437940, 0x2FA,
|
||||
'9579bfb1c4d9ae6abf2a1c78d6f99544871a63216fb80b9a906e3a76ebe27983'),
|
||||
)
|
||||
|
||||
|
||||
def controller_phases(raw_control, jimmy=0x1000, *, game_enabled=True,
|
||||
status83e0=False, modal8181=False):
|
||||
"""Source-gate projection, not execution of original/controller arithmetic."""
|
||||
phases = ['game_gate']
|
||||
if not game_enabled:
|
||||
return phases
|
||||
phases += ['elapsed774', 'base40E050', 'conditional_timer7A8', 'ownership_check']
|
||||
if raw_control != jimmy or status83e0 or modal8181:
|
||||
return phases
|
||||
return phases + ['controller_modes', 'jump_ground_air', 'speed26C']
|
||||
|
||||
|
||||
def fire_projection(remaining, delta, energy, level_code, *, game_enabled=True,
|
||||
owner=True, grounded=False):
|
||||
"""Bounded effect-state projection; no ownership pointer participates.
|
||||
|
||||
Python arithmetic is not an x87 bit-identity oracle. The base class callback
|
||||
has independent work; this projection covers timer/energy/owner-follow only.
|
||||
"""
|
||||
if not game_enabled or not owner:
|
||||
return remaining, energy, False, False
|
||||
remaining = (0 if grounded else remaining) - delta
|
||||
active = remaining > 0
|
||||
if active and not 0x56523031 <= level_code <= 0x56523038:
|
||||
energy = max(0, min(100, energy - delta * .5))
|
||||
return remaining, energy, active, True
|
||||
|
||||
|
||||
def collect(root):
|
||||
pe = PE(find_case(Path(root), 'Neutron.exe'))
|
||||
if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256:
|
||||
raise ValueError('Unsupported original EXE')
|
||||
sites = []
|
||||
for name, va, expected in SITES:
|
||||
actual = read_va(pe, va, len(bytes.fromhex(expected))).hex()
|
||||
if actual != expected:
|
||||
raise ValueError(f'Changed instruction {name} 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:
|
||||
if struct.unpack('<I', read_va(pe, table+slot, 4))[0] != target:
|
||||
raise ValueError(f'Changed virtual target {name}')
|
||||
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, va, length, expected in BODY_HASHES:
|
||||
raw = read_va(pe, va, length)
|
||||
actual = hashlib.sha256(raw).hexdigest()
|
||||
if actual != expected:
|
||||
raise ValueError(f'Changed source body {name}')
|
||||
bodies.append(dict(name=name, va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
|
||||
length=length, sha256=actual,
|
||||
raw_control_reference=struct.pack('<I', 0x5099E4) in raw))
|
||||
return dict(sha256=EXE_SHA256, sites=sites, tables=tables, bodies=bodies,
|
||||
scope='Static source bytes and explicit gate/state projection; no original 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