Apply recovered player phases, static camera query and level availability
This commit is contained in:
1 parent
117db77c7b
commit
09cf1172bf
33 files changed
+1500
-99
No files matched your search
@@ -0,0 +1,136 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only retained-character initialization and PostLoad evidence."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import struct
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va, rel_call_target
|
||||
from pe_inspect import PE
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'levels'))
|
||||
import gam
|
||||
|
||||
SITES = (
|
||||
('player_init_base', 0x437896, 'e8550f0200'),
|
||||
('player_init_speed_zero', 0x4378A1, '898608060000'),
|
||||
('player_init_turn_zero', 0x4378A7, '898614060000'),
|
||||
('player_init_618_zero', 0x4378AD, '898618060000'),
|
||||
('player_init_euler_getter', 0x4378B8, 'ff9028030000'),
|
||||
('player_init_yaw_capture', 0x4378BE, '8b500489961c060000'),
|
||||
('euler_getter_y', 0x4723FC, '8b9128020000'),
|
||||
('postload_jump_zero', 0x42378B, '6689bd28070000'),
|
||||
('postload_normal_radius60', 0x4236A3, '6800007042'),
|
||||
('postload_normal_support_factor', 0x4236B3, '6885eba13f'),
|
||||
('postload_animation_pause_disable', 0x42370A, 'ff901c010000'),
|
||||
('stage_sound_stop', 0x43B7FB, 'ff9248010000'),
|
||||
('sound_stop_only_handle', 0x429A19, 'c786440a0000ffffffff'),
|
||||
('fire_constructor_preservation', 0x421E51, 'e8eaf00400'),
|
||||
('fire_constructor_owner_zero', 0x421E62, '899ebc060000'),
|
||||
('fire_constructor_timer_zero', 0x421E68, '899ec0060000'),
|
||||
('fire_owner_assignment', 0x437525, '8981bc060000'),
|
||||
('fire_grounded_owner_clear', 0x421FE9, 'c7860006000000000000'),
|
||||
('fire_timer_tick', 0x421FF3, 'd98600060000d8642418'),
|
||||
('player_constructor_mode_zero', 0x43748A, '66899dc4070000'),
|
||||
('goddard_init_base_jump', 0x41E6A0, 'e90b98feff'),
|
||||
('goddard_init_authored_state', 0x407EBC, '8b867c080000898608060000'),
|
||||
('goddard_init_waypoint_clear', 0x407EC8, 'c7860008000000000000'),
|
||||
('goddard_postload_base', 0x41E593, 'e8e8aefeff'),
|
||||
('goddard_reuse_callback', 0x423CE2, 'ff9074010000'),
|
||||
('inventory_disable_compare_one', 0x40389E, '66833801751166c7000400'),
|
||||
('inventory_enable_compare_four', 0x4038AA, '66833804750566c7000100'),
|
||||
('tutorial_level_lower_bound', 0x423E52, '3d31305256'),
|
||||
('tutorial_level_upper_bound', 0x423E5D, '3d38305256'),
|
||||
('tutorial_mode_flag', 0x423E6A, 'c6853809000001'),
|
||||
('tutorial_objective_hidden', 0x423EC6, 'c70588814f000000a041'),
|
||||
)
|
||||
|
||||
VTABLES = (
|
||||
('Jimmy Init', 0x4A373C, 0x28, 0x437890),
|
||||
('Jimmy PostLoad', 0x4A373C, 0x40C, 0x423610),
|
||||
('Jimmy Euler getter', 0x4A373C, 0x328, 0x4723F0),
|
||||
('Jimmy transition stop sound', 0x4A3BDC, 0x148, 0x429A00),
|
||||
('Jimmy animation pause', 0x4A3BDC, 0x11C, 0x40D350),
|
||||
('Fire Init', 0x4A3160, 0x28, 0x4587F0),
|
||||
('Fire PostLoad', 0x4A3160, 0x40C, 0x40E7B0),
|
||||
('Goddard Init', 0x49F480, 0x28, 0x41E6A0),
|
||||
('Goddard PostLoad', 0x49F480, 0x40C, 0x41E590),
|
||||
('Shadow Init', 0x4B37B8, 0x28, 0x4587F0),
|
||||
('Shadow PostLoad', 0x4B37B8, 0x40C, 0x43F810),
|
||||
)
|
||||
|
||||
GADGET_INDICES = (7, 3, 0, 5, 1, 6, 2, 4)
|
||||
ENABLE_CALLS = (0x423DEF, 0x423DFA, 0x423E05, 0x423E10,
|
||||
0x423E1B, 0x423E26, 0x423E34, 0x423E3F)
|
||||
DISABLE_CALLS = (0x423E71, 0x423E7C, 0x423E87, 0x423E92,
|
||||
0x423E9D, 0x423EA8, 0x423EB6, 0x423EC1)
|
||||
|
||||
|
||||
def gadget_postload(states, tutorial):
|
||||
"""Bounded state oracle: source403870 preserves values other than1/4."""
|
||||
values = list(states)
|
||||
if len(values) < 8:
|
||||
raise ValueError('Need all eight group0 gadget entries')
|
||||
for index in GADGET_INDICES:
|
||||
if values[index] == 4:
|
||||
values[index] = 1
|
||||
if tutorial:
|
||||
for index in GADGET_INDICES:
|
||||
if values[index] == 1:
|
||||
values[index] = 4
|
||||
return values
|
||||
|
||||
|
||||
def collect(root: Path):
|
||||
pe = PE(find_case(root, 'Neutron.exe'))
|
||||
digest = hashlib.sha256(pe.data).hexdigest()
|
||||
sites = []
|
||||
for name, va, expected in SITES:
|
||||
actual = read_va(pe, va, len(bytes.fromhex(expected))).hex()
|
||||
item = dict(name=name, va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
|
||||
expected=expected, actual=actual, matches=actual == expected)
|
||||
if actual.startswith('e8'):
|
||||
item['direct_call_target'] = hex(rel_call_target(pe, va))
|
||||
sites.append(item)
|
||||
tables = []
|
||||
for name, table, slot, expected in VTABLES:
|
||||
actual = struct.unpack('<I', read_va(pe, table + slot, 4))[0]
|
||||
tables.append(dict(name=name, table=hex(table), slot=hex(slot),
|
||||
file_offset=hex(pe.offset(table+slot-pe.base)),
|
||||
target=hex(actual), matches=actual == expected))
|
||||
calls = []
|
||||
for disabled, addresses in ((0, ENABLE_CALLS), (1, DISABLE_CALLS)):
|
||||
for index, va in zip(GADGET_INDICES, addresses, strict=True):
|
||||
target = rel_call_target(pe, va)
|
||||
# Each site is preceded by push bool; push item; push group0.
|
||||
expected = bytes((0x6A, disabled, 0x6A, index, 0x6A, 0))
|
||||
# First tutorial call inserts its mode flag write after the pushes.
|
||||
argument_start = va - (13 if va == 0x423E71 else 6)
|
||||
actual = read_va(pe, argument_start, 6)
|
||||
calls.append(dict(va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
|
||||
group=0, index=index, disabled=disabled,
|
||||
target=hex(target), matches=actual == expected and target == 0x403870))
|
||||
route = []
|
||||
for relative in ('gam/level1b.gam', 'gam/VR04.gam', 'gam/level1.gam'):
|
||||
path = find_case(root, relative)
|
||||
level = gam.parse(path.read_bytes())
|
||||
jimmy = next(e for e in level.entities if e.kind == '3JIM')
|
||||
route.append(dict(file=relative, code=level.code, offset=hex(jimmy.offset),
|
||||
sha256=hashlib.sha256(path.read_bytes()).hexdigest(),
|
||||
player_properties=sorted(jimmy.values())))
|
||||
return dict(known_binary=digest == EXE_SHA256, sha256=digest,
|
||||
sites=sites, vtables=tables, gadget_calls=calls, route=route,
|
||||
scope='Static source bytes/data only; no original runtime execution.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli = argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument('original', type=Path)
|
||||
result = collect(cli.parse_args().original)
|
||||
print(json.dumps(result, indent=2))
|
||||
if not result['known_binary'] or not all(x['matches'] for key in ('sites', 'vtables', 'gadget_calls') for x in result[key]):
|
||||
raise SystemExit(1)
|
||||
@@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only proof that ordinary initialization restores a level game's teardown flag."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import struct
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va, rel_call_target
|
||||
from pe_inspect import PE
|
||||
|
||||
SITES = (
|
||||
("generic_stored_flag_one", 0x46FDB3, "6a018bcde884110000"),
|
||||
("stored_flag_getter", 0x470F30, "8a4111c3"),
|
||||
("stored_flag_setter", 0x470F47, "884111ff9204020000"),
|
||||
("live_flag_getter", 0x4719B0, "8a8139010000c3"),
|
||||
("live_flag_setter", 0x4719C0, "8a442404888139010000c20400"),
|
||||
("defaults_only_live_zero", 0x44D456, "6a00"),
|
||||
("defaults_live_setter", 0x44D472, "ff9004020000"),
|
||||
("lab_init_to_base", 0x44D4E0, "e90bb30000"),
|
||||
("base_init_to_common", 0x4587F3, "e8487d0100"),
|
||||
("common_init_get_stored", 0x4705B3, "ff978c000000"),
|
||||
("common_init_set_live", 0x4705B9, "508bceff9704020000"),
|
||||
("loader_init_slot", 0x46E5C3, "ff5228"),
|
||||
("loader_postload_slot", 0x46E61A, "ff920c040000"),
|
||||
("teardown_first_predicate", 0x46E032, "ff920002000084c0741b"),
|
||||
("teardown_second_predicate", 0x46E06F, "ff900002000084c0741b"),
|
||||
("teardown_third_predicate", 0x46E0AC, "ff900002000084c07418"),
|
||||
("teardown_delete_mark", 0x46E0CA, "c6460601"),
|
||||
("teardown_delete_sweep", 0x46E0D9, "e832560000"),
|
||||
("delete_sweep_flag", 0x473720, "8a590684db7508"),
|
||||
("delete_sweep_virtual_destructor", 0x473733, "8b016a01ff10ebd6"),
|
||||
("lab_destructor_thunk", 0x44F610, "83e95ce9d8fdffff"),
|
||||
("lab_destructor_base", 0x44F499, "e8f2deffff"),
|
||||
("game_destructor_base", 0x44D3C2, "e919730200"),
|
||||
("game_destructor_interface", 0x47476A, "e87140feff"),
|
||||
("interface_destructor_base", 0x4587E6, "e975780100"),
|
||||
("common_destructor_registry", 0x4700E5, "a19c995000"),
|
||||
("common_destructor_payload_match", 0x4700F2, "397e087516"),
|
||||
("common_destructor_registry_erase", 0x470101, "b998995000e88593ffff"),
|
||||
("jimmy_stored_zero", 0x4226B5, "538bcf66899d0c0a0000e87ce80400"),
|
||||
("goddard_stored_zero", 0x41C99B, "538bcfe89d450500"),
|
||||
)
|
||||
|
||||
TABLES = (
|
||||
("lab", 0x4C386C, 0x28, 0x44D4E0),
|
||||
("tutorial", 0x4CE4AC, 0x28, 0x44D4E0),
|
||||
("outside", 0x4C561C, 0x28, 0x44D4E0),
|
||||
("lab", 0x4C386C, 0x8C, 0x470F30),
|
||||
("tutorial", 0x4CE4AC, 0x8C, 0x470F30),
|
||||
("outside", 0x4C561C, 0x8C, 0x470F30),
|
||||
("lab", 0x4C386C, 0x200, 0x4719B0),
|
||||
("lab", 0x4C386C, 0x204, 0x4719C0),
|
||||
("tutorial", 0x4CE4AC, 0x204, 0x4719C0),
|
||||
("outside", 0x4C561C, 0x204, 0x4719C0),
|
||||
("lab", 0x4C386C, 0, 0x44F610),
|
||||
("Jimmy", 0x4A373C, 0x8C, 0x470F30),
|
||||
("Jimmy", 0x4A373C, 0x204, 0x4719C0),
|
||||
)
|
||||
|
||||
|
||||
def collect(original: Path) -> dict:
|
||||
pe = PE(find_case(original, "Neutron.exe"))
|
||||
digest = hashlib.sha256(pe.data).hexdigest()
|
||||
sites = []
|
||||
for label, va, expected in SITES:
|
||||
actual = read_va(pe, va, len(expected) // 2).hex()
|
||||
item = dict(label=label, va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
|
||||
expected=expected, actual=actual, matches=actual == expected)
|
||||
if actual.startswith("e8"):
|
||||
item["target"] = hex(rel_call_target(pe, va))
|
||||
sites.append(item)
|
||||
tables = []
|
||||
for name, table, slot, expected in TABLES:
|
||||
va = table + slot
|
||||
actual, = struct.unpack("<I", read_va(pe, va, 4))
|
||||
tables.append(dict(owner=name, table=hex(table), slot=hex(slot),
|
||||
va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
|
||||
target=hex(actual), matches=actual == expected))
|
||||
return dict(sha256=digest, known_binary=digest == EXE_SHA256, sites=sites,
|
||||
vtables=tables, scope="Static source bytes only; no original runtime execution.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli = argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument("original", type=Path)
|
||||
result = collect(cli.parse_args().original)
|
||||
print(json.dumps(result, indent=2))
|
||||
if not result["known_binary"] or not all(s["matches"] for s in result["sites"] + result["vtables"]):
|
||||
raise SystemExit(1)
|
||||
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only anchors for the implemented player/input/body phase boundary."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from pe_inspect import PE
|
||||
|
||||
SHA256 = 'f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8'
|
||||
ANCHORS = [
|
||||
(0x438B1E, '0fbf8604070000', 'input dispatch reads stored interface704 mode'),
|
||||
(0x438B2A, 'ff2485a48b4300', 'input dispatch uses mode table'),
|
||||
(0x437A96, '66c786040700000100', 'held jump selects air mode during player update'),
|
||||
(0x437B9E, '66899e2807000066899e04070000899e14060000',
|
||||
'grounded release resets jump state, mode, then turn rate'),
|
||||
(0x437BC5, 'ff9034010000', 'player air apply virtual134'),
|
||||
(0x437C1C, 'ff9230010000', 'player ground apply virtual130'),
|
||||
(0x47E554, 'e867b6ffff', 'physics before object registry'),
|
||||
(0x47E582, 'e8b951ffff', 'object registry callback pass'),
|
||||
(0x47E587, 'e8e451ffff', 'logical-to-visual sync after callbacks'),
|
||||
]
|
||||
|
||||
|
||||
def collect(original):
|
||||
root = Path(original)
|
||||
paths = [p for p in root.iterdir() if p.name.casefold() == 'neutron.exe']
|
||||
if len(paths) != 1:
|
||||
raise ValueError('Original EXE missing or ambiguous')
|
||||
pe = PE(paths[0])
|
||||
if hashlib.sha256(pe.data).hexdigest() != SHA256:
|
||||
raise ValueError('Unsupported EXE identity')
|
||||
result = []
|
||||
for va, expected, label in ANCHORS:
|
||||
offset = pe.offset(va - pe.base)
|
||||
raw = bytes.fromhex(expected)
|
||||
if pe.data[offset:offset + len(raw)] != raw:
|
||||
raise ValueError(f'Changed source contract at {va:#x}')
|
||||
result.append(dict(va=hex(va), file_offset=hex(offset), bytes=expected, label=label))
|
||||
return {'sha256': SHA256, 'sites': result,
|
||||
'limits': 'Static source anchors; port capsule/grounding and cadence remain provisional.'}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('original', type=Path)
|
||||
print(json.dumps(collect(parser.parse_args().original), indent=2))
|
||||
Reference in new issue
Block a user