Document architecture checkpoint and restore original task callback order
This commit is contained in:
1 parent
69d0187a21
commit
531883aaac
45 files changed
+2935
-43
No files matched your search
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only camera/audio/UI checkpoint anchors, with PE-mapped offsets.
|
||||
|
||||
Run from GamePort: python3 tools/binary/checkpoint_camera_audio_ui.py ../Original
|
||||
This checks immutable source instructions; it neither executes nor writes originals.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import struct
|
||||
|
||||
from pe_inspect import PE
|
||||
|
||||
EXE_SHA256 = 'f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8'
|
||||
DLL_SHA256 = '3ec41ead011adf56387a6dbd4580e5b5a9721b5f8020c8a56420f42824354943'
|
||||
|
||||
# Deliberately selected instruction sequences, rather than matching whole functions.
|
||||
ANCHORS = (
|
||||
('follow_default_eye_y200', 0x437742, 'c781cc07000000004843'),
|
||||
('follow_virtual_ray_callback', 0x439714, 'ff966c010000'),
|
||||
('follow_x_gain', 0x4397B1, 'd88d54080000d84c2414d88c2480000000'),
|
||||
('follow_y_extra_gain', 0x4397C2, 'd98558080000dc05d02a4a00'),
|
||||
('follow_viewport_position', 0x4397F8, 'a1509a5000'),
|
||||
('follow_ray_call', 0x43B874, 'e897090400'),
|
||||
('follow_hit_adjustment', 0x43B8AD, 'd826d80dacd54900'),
|
||||
('follow_hit_gain', 0x43B8F7, 'd90538314a00'),
|
||||
('jimmy_complete_vtable_ray_slot', 0x4A3D48, '20b84300'),
|
||||
('cam_interface_update_slot', 0x497FC0, '905f4100'),
|
||||
('cam_complete_activate_slot', 0x498138, 'a0654100'),
|
||||
('mca_interface_update_slot', 0x4A9328, 'a00d4300'),
|
||||
('mca_complete_activate_slot', 0x4A94A0, '80124300'),
|
||||
('default_local_eye', 0x447E2F, '680000fac3680000fa43'),
|
||||
('default_snap_threshold', 0x447E9D, 'd81dace54800dfe0f6c441'),
|
||||
('default_snap_store', 0x447EAA, 'd95944'),
|
||||
('cam_voice_poll', 0x415FC2, '8b8eb408000051e8c2780600'),
|
||||
('cam_music_bank', 0x416776, 'a104606900'),
|
||||
('cam_effect_bank_release_gate', 0x416813, '891d08606900881d34844f00'),
|
||||
('mca_effect_bank_release_gate', 0x4315C2, '891d08606900881d34844f00'),
|
||||
('default_effect_bank_restore_gate', 0x447F64, 'a30860690085c07406881d34844f00'),
|
||||
('voice_duration_and_repeat_flag', 0x47D8CB, 'ff50148b44240c85c075078a463084c07405'),
|
||||
('ui_dispatch_base_first', 0x404080, '83ec1453558b6c242056578bf155e8adf10600'),
|
||||
('ui_controlled_clock_then_draw', 0x4043D9,
|
||||
'391de49950000f8495000000d90588814f00d84424288bced91d88814f008b16ff92d0040000'),
|
||||
('modal_pause_game', 0x407022, '8b0d48995000538b01ff9068010000'),
|
||||
)
|
||||
|
||||
CONSTANTS = (
|
||||
('default_snap_distance', 0x48E5AC, 'f', 1000.0),
|
||||
('ray_hit_weight', 0x49D5AC, 'f', .75),
|
||||
('ray_hit_follow_gain', 0x4A3138, 'f', 1.5),
|
||||
('follow_y_gain_extra', 0x4A2AD0, 'd', .2),
|
||||
('special_eye_state_threshold', 0x495338, 'd', 1.7),
|
||||
('special_eye_back_multiplier', 0x4AFCF0, 'd', 3.7),
|
||||
('look_target_height_multiplier', 0x4AFCE8, 'd', 1.9),
|
||||
)
|
||||
|
||||
GLOBALS = (('viewport', 0x509A50), ('controlled', 0x5099E4),
|
||||
('music_database', 0x696004), ('current_wave_database', 0x696008),
|
||||
('sound_engine', 0x69600C), ('default_positional_sfx_gate', 0x4F8434),
|
||||
('objective_timer', 0x4F8188), ('objective_selector', 0x4F8194),
|
||||
('modal_active', 0x4F8198), ('modal_type', 0x4F8048))
|
||||
|
||||
|
||||
def recover(original):
|
||||
original = Path(original)
|
||||
pe = PE(original / 'Neutron.exe')
|
||||
exe_hash = hashlib.sha256(pe.data).hexdigest()
|
||||
dll_hash = hashlib.sha256((original / 'OMT2.dll').read_bytes()).hexdigest()
|
||||
if exe_hash != EXE_SHA256 or dll_hash != DLL_SHA256:
|
||||
raise ValueError('Unrecognized original module hash; do not apply preferred-VA evidence')
|
||||
result = {'module_hashes': {'Neutron.exe': exe_hash, 'OMT2.dll': dll_hash},
|
||||
'anchors': [], 'constants': [], 'globals': []}
|
||||
for name, va, expected in ANCHORS:
|
||||
off = pe.offset(va - pe.base)
|
||||
actual = pe.data[off:off + len(bytes.fromhex(expected))].hex()
|
||||
if actual != expected:
|
||||
raise ValueError(f'{name}: expected instruction bytes differ at {va:#x}')
|
||||
result['anchors'].append({'name': name, 'va': hex(va),
|
||||
'file_offset': hex(off), 'bytes': actual})
|
||||
for name, va, fmt, expected in CONSTANTS:
|
||||
off = pe.offset(va - pe.base)
|
||||
actual = struct.unpack_from('<' + fmt, pe.data, off)[0]
|
||||
if actual != expected:
|
||||
raise ValueError(f'{name}: constant differs')
|
||||
result['constants'].append({'name': name, 'va': hex(va),
|
||||
'file_offset': hex(off), 'value': actual, 'format': fmt})
|
||||
for name, va in GLOBALS:
|
||||
try:
|
||||
off = hex(pe.offset(va - pe.base))
|
||||
except ValueError:
|
||||
off = None # PE zero-fill; a VA is not automatically a physical file offset.
|
||||
result['globals'].append({'name': name, 'va': hex(va), 'file_offset': off})
|
||||
return result
|
||||
|
||||
|
||||
def obstructed_eye(look, hit):
|
||||
"""43B8AD..43B8F4 algebra, independent of unrecovered ray layer/filter rules."""
|
||||
return tuple(a - (a - b) * .75 for a, b in zip(look, hit, strict=True))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('original', type=Path)
|
||||
args = parser.parse_args()
|
||||
print(json.dumps(recover(args.original), indent=2))
|
||||
@@ -0,0 +1,156 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only C5 ray evidence and bounded grid-order reference (not runtime code)."""
|
||||
import argparse
|
||||
from collections import Counter
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
from pathlib import Path
|
||||
import struct
|
||||
import sys
|
||||
|
||||
from pe_inspect import PE
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'extractors'))
|
||||
from omt import Database, read_shape
|
||||
|
||||
EXE_HASH = 'f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8'
|
||||
CELL_SCALE = struct.unpack('<f', bytes.fromhex('6f12033b'))[0]
|
||||
CELL_ORIGIN = 130.0
|
||||
GRID_SIZE = 260
|
||||
ANCHORS = (
|
||||
('enabled_gate', 0x47C210, 'a0e5694f005684c0745c'),
|
||||
('wall_query_return_on_hit', 0x47C23D, 'e83e00000083c42484c07404b0015ec3'),
|
||||
('all_query_fallback', 0x47C26C, 'e83f020000'),
|
||||
('wall_cell_list', 0x47C3DF, '8b04ad249b5000'),
|
||||
('wall_triangle_return_first', 0x47C442, 'e8c9d5feff83c42484c0753d'),
|
||||
('wall_next_fifo_node', 0x47C44E, '8b368b04ad249b50003bf07591'),
|
||||
('inclusive_z_then_x_loop', 0x47C463, '43663bda0f8e37ffffff8b5c241041663b4c2414894c24180f8e1affffff'),
|
||||
('first_hit_identity', 0x47C48B, '8b4704a3585d69008b0f5f5e5d890d545d6900b0015b'),
|
||||
('all_cell_list', 0x47C60F, '8b04ad7cfc5c00'),
|
||||
('all_triangle_return_first', 0x47C672, 'e899d3feff83c42484c0753d'),
|
||||
('fifo_append_tail', 0x4798A2, '8947048b4804890183c00885c0'),
|
||||
('wall_normal_filter', 0x4798B3, 'd94424148b8680fc5c00d81d74d9480040898680fc5c00dfe0f6c401743d'),
|
||||
('caller_actor_getter_first', 0x43B83F, 'ff9010030000'),
|
||||
('caller_actor_getter_second', 0x43B84E, 'ff9210030000'),
|
||||
('caller_end_and_false_sidedness', 0x43B854, '8b74242c6a0083ec108bcc56e8fbe6fcff'),
|
||||
('caller_incoming_look_vector', 0x43B865, '83ec108d5424408bcc52e8ece6fcffe897090400'),
|
||||
('getter_reads_interface_position', 0x472304, '8b91140200008910'),
|
||||
('jimmy_getter_slot', 0x4A3A4C, '00234700'),
|
||||
('default_camera_adjustment10', 0x438CC6, 'c7854c08000000002041'),
|
||||
('mouse_relative_camera_adjustment', 0x438C78, 'd8854c080000d99d4c080000'),
|
||||
('one_sided_triangle_gate', 0x469C7E, '8a84248000000084c00f8491010000'),
|
||||
('negative_t_reject', 0x469DDD, '753f'),
|
||||
('strict_endpoint_reject', 0x469DEE, '752e'),
|
||||
('nc_shape_skip', 0x44DD64, '83f86374078b178bcfff522c'),
|
||||
('terrain_register_call', 0x464B18, 'e823460100'),
|
||||
('checkpoint_filter', 0x4791C7, '5355e8f202000083c40884'),
|
||||
('game_filter', 0x4791D9, '5355e8c005000083c40884c0740c'),
|
||||
('polygon_array_step48', 0x479473, '8b838c00000083c5303be889'),
|
||||
('shape_id_increment', 0x44DEAF, '46'),
|
||||
('lab_game_polygon_filter_slot', 0x4C3E04, 'd05c4700'),
|
||||
('vr04_game_polygon_filter_slot', 0x4CEA44, 'd05c4700'),
|
||||
('outside_game_polygon_filter_slot', 0x4C5BB4, 'd05c4700'),
|
||||
('route_game_filter_false', 0x475CD0, '32c0c21800'),
|
||||
)
|
||||
|
||||
|
||||
def cell_coordinate(value):
|
||||
"""Stored float scale, x87 truncation, then signed16 comparison domain.
|
||||
|
||||
Python double arithmetic is a bounded order oracle, not an x87 boundary oracle.
|
||||
"""
|
||||
if not math.isfinite(value):
|
||||
raise ValueError('Finite grid coordinate required')
|
||||
number = math.trunc(value * CELL_SCALE + CELL_ORIGIN)
|
||||
return (number + 32768) % 65536 - 32768
|
||||
|
||||
|
||||
def cells_between(a, b):
|
||||
"""Inclusive endpoint XZ rectangle, increasing X then increasing Z."""
|
||||
xmin, xmax = sorted((cell_coordinate(a[0]), cell_coordinate(b[0])))
|
||||
zmin, zmax = sorted((cell_coordinate(a[2]), cell_coordinate(b[2])))
|
||||
# Skipping out-of-grid indices is equivalent to the source's loop rejection.
|
||||
for x in range(max(0, xmin), min(GRID_SIZE - 1, xmax) + 1):
|
||||
for z in range(max(0, zmin), min(GRID_SIZE - 1, zmax) + 1):
|
||||
yield x, z
|
||||
|
||||
|
||||
def first_hit(start, end, walls, all_polygons, accept, enabled=True, two_sided=False):
|
||||
"""Order contract only; accept owns the separately recovered triangle kernel.
|
||||
|
||||
Grid values are FIFO polygon identities. Repeated polygons in multiple cells
|
||||
are intentionally not deduplicated. Return first hit, not nearest distance.
|
||||
"""
|
||||
if not enabled:
|
||||
return None
|
||||
cells = tuple(cells_between(start, end))
|
||||
for grid in (walls, all_polygons):
|
||||
for cell in cells:
|
||||
for polygon in grid.get(cell, ()):
|
||||
hit = accept(polygon, start, end, two_sided)
|
||||
if hit is not None:
|
||||
return polygon, hit
|
||||
return None
|
||||
|
||||
|
||||
def route_geometry(original):
|
||||
result = {}
|
||||
checkpoint_names = {'cstart', *(f'ccheck{i}' for i in range(1, 10))}
|
||||
for name in ('level1b.omt', 'VR04.omt', 'level1.omt'):
|
||||
path = Path(original) / 'omt' / name
|
||||
database = Database(path)
|
||||
materials = {e.id: e.name for e in database.entries if e.type == '3DMa'}
|
||||
corners = Counter()
|
||||
ids, walls, checkpoint, excluded = [], 0, 0, 0
|
||||
for entry in database.entries:
|
||||
if entry.type != '3DSh':
|
||||
continue
|
||||
shape = read_shape(database.payload(entry))
|
||||
if (entry.name or '').lower().startswith('nc'):
|
||||
excluded += len(shape['polygons'])
|
||||
continue
|
||||
ids.append(entry.id)
|
||||
for polygon in shape['polygons']:
|
||||
material = polygon['material']
|
||||
if material and materials.get(material['id']) in checkpoint_names:
|
||||
checkpoint += 1
|
||||
continue
|
||||
corners[len(polygon['corners'])] += 1
|
||||
walls += polygon['normal'][1] < struct.unpack('<f', bytes.fromhex('3333333f'))[0]
|
||||
result[name] = {'sha256': hashlib.sha256(path.read_bytes()).hexdigest(),
|
||||
'registered_polygon_corner_counts': dict(corners),
|
||||
'wall_grid_polygons': walls, 'nc_polygons_excluded': excluded,
|
||||
'checkpoint_polygons_excluded': checkpoint,
|
||||
'shape_ids_ascending': ids == sorted(ids)}
|
||||
return result
|
||||
|
||||
|
||||
def recover(original):
|
||||
pe = PE(Path(original) / 'Neutron.exe')
|
||||
if hashlib.sha256(pe.data).hexdigest() != EXE_HASH:
|
||||
raise ValueError('Unrecognized executable hash')
|
||||
anchors = []
|
||||
for name, va, expected in ANCHORS:
|
||||
offset = pe.offset(va - pe.base)
|
||||
actual = pe.data[offset:offset + len(expected) // 2].hex()
|
||||
if actual != expected:
|
||||
raise ValueError(f'Instruction mismatch: {name} at {va:#x}')
|
||||
anchors.append({'name': name, 'va': hex(va), 'file_offset': hex(offset), 'bytes': actual})
|
||||
constants = []
|
||||
for name, va, fmt in (('cell_scale', 0x4D6A04, 'f'), ('cell_origin', 0x49B1FC, 'f'),
|
||||
('wall_normal_threshold', 0x48D974, 'f'),
|
||||
('enabled_default', 0x4F69E5, 'B')):
|
||||
offset = pe.offset(va - pe.base)
|
||||
constants.append({'name': name, 'va': hex(va), 'file_offset': hex(offset),
|
||||
'value': struct.unpack_from('<' + fmt, pe.data, offset)[0]})
|
||||
return {'exe_sha256': EXE_HASH, 'anchors': anchors, 'constants': constants,
|
||||
'route_geometry': route_geometry(original),
|
||||
'limits': 'Static source/order evidence; no original execution, x87 boundary or GPU comparison'}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('original', type=Path)
|
||||
args = parser.parse_args()
|
||||
print(json.dumps(recover(args.original), indent=2))
|
||||
@@ -0,0 +1,104 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only original input/frame bridge anchors; never executes legacy binaries."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import struct
|
||||
|
||||
from pe_inspect import PE
|
||||
|
||||
|
||||
HASHES = {
|
||||
'Neutron.exe': 'f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8',
|
||||
'OMT2.dll': '3ec41ead011adf56387a6dbd4580e5b5a9721b5f8020c8a56420f42824354943',
|
||||
}
|
||||
# The byte assertions cover indirect dispatch that a direct-call search misses.
|
||||
ANCHORS = {
|
||||
'Neutron.exe': [
|
||||
(0x473758, 'ff5010', 'registry calls interface slot10'),
|
||||
(0x4702C5, 'ff92c4030000', 'normal wrapper calls slot3C4'),
|
||||
(0x475AA9, 'ff92cc030000', 'controlled input calls slot3CC'),
|
||||
(0x475A8A, '8b8674ffffff8d8e74ffffff', 'game interface converts complete by subtracting8C'),
|
||||
(0x4747A5, 'ff1530d24800', 'game OMT update forwards to base element'),
|
||||
(0x462265, 'ff1544d24800', 'Jimmy OMT update forwards to morph animation'),
|
||||
(0x47E6DF, 'ff1504d34800', 'base viewport draw after game pass'),
|
||||
],
|
||||
'OMT2.dll': [
|
||||
(0x100215D4, '68a4fdffff', 'logic message -604'),
|
||||
(0x100215E8, '68a3fdffff', 'render message -605 follows logic'),
|
||||
(0x100F989D, '897e58', 'world timer mode1 default'),
|
||||
(0x100F98A0, 'c7465c28000000', 'world period40 default'),
|
||||
(0x100F98A7, 'c74660f4010000', 'world maxperiod500 default'),
|
||||
(0x100F98AE, '897e64', 'world minperiod1 default'),
|
||||
(0x100F8D18, 'ff150c411110', 'engine clock GetTickCount import'),
|
||||
(0x100F9B45, '7603', 'maxperiod clamps elapsed'),
|
||||
(0x100F9B5B, '0f82c9000000', 'minperiod skips logic if elapsed below bound'),
|
||||
],
|
||||
}
|
||||
SLOTS = [
|
||||
(0x4C2C84, 0x10, 0x470280, 'CJimmyGame interface+8C wrapper'),
|
||||
(0x4C2C84, 0x3C4, 0x44DF80, 'CJimmyGame normal update'),
|
||||
(0x4C386C, 0x10, 0x470280, 'CLevel01BGame interface+8C wrapper'),
|
||||
(0x4C386C, 0x3C4, 0x44DF80, 'CLevel01BGame normal update'),
|
||||
(0x4C3CD0, 0x3C, 0x4747A0, 'CLevel01BGame OMT logic uses base element'),
|
||||
(0x4A373C, 0x3C4, 0x424600, 'Jimmy interface+C0 ordinary update'),
|
||||
(0x4A373C, 0x3CC, 0x426030, 'Jimmy interface+C0 input'),
|
||||
(0x4A3BDC, 0x3C, 0x462260, 'Jimmy complete OMT update'),
|
||||
]
|
||||
CALLS = [
|
||||
(0x47E554, 0x479BC0, 'physics'),
|
||||
(0x47E582, 0x473740, 'all game objects'),
|
||||
(0x47E587, 0x473770, 'all logical-to-visual transforms'),
|
||||
(0x44DF89, 0x45F510, 'game timer/event records before input'),
|
||||
(0x44DF94, 0x475A70, 'game input dispatcher'),
|
||||
(0x426084, 0x438A60, 'Jimmy base movement input'),
|
||||
]
|
||||
|
||||
|
||||
def read_va(pe, va, size):
|
||||
offset = pe.offset(va - pe.base)
|
||||
data = pe.data[offset:offset + size]
|
||||
if len(data) != size:
|
||||
raise ValueError('Truncated evidence range')
|
||||
return offset, data
|
||||
|
||||
|
||||
def collect(original):
|
||||
results = []
|
||||
for module, expected_hash in HASHES.items():
|
||||
pe = PE(Path(original) / module)
|
||||
digest = hashlib.sha256(pe.data).hexdigest()
|
||||
if digest != expected_hash:
|
||||
raise ValueError(f'{module}: unsupported hash {digest}')
|
||||
for va, hex_bytes, label in ANCHORS[module]:
|
||||
expected = bytes.fromhex(hex_bytes)
|
||||
off, actual = read_va(pe, va, len(expected))
|
||||
if actual != expected:
|
||||
raise ValueError(f'{module} {va:#x}: {actual.hex()} != {expected.hex()}')
|
||||
results.append(dict(module=module, va=hex(va), file_offset=hex(off),
|
||||
bytes=actual.hex(), evidence=label))
|
||||
if module == 'Neutron.exe':
|
||||
for table, slot, target, label in SLOTS:
|
||||
va = table + slot
|
||||
off, data = read_va(pe, va, 4)
|
||||
actual, = struct.unpack('<I', data)
|
||||
if actual != target:
|
||||
raise ValueError(f'{label}: {actual:#x} != {target:#x}')
|
||||
results.append(dict(module=module, va=hex(va), file_offset=hex(off),
|
||||
target=hex(target), evidence=label))
|
||||
for va, target, label in CALLS:
|
||||
off, data = read_va(pe, va, 5)
|
||||
if data[0] != 0xE8 or va + 5 + struct.unpack('<i', data[1:])[0] != target:
|
||||
raise ValueError(f'{label}: call target mismatch at {va:#x}')
|
||||
results.append(dict(module=module, va=hex(va), file_offset=hex(off),
|
||||
target=hex(target), evidence=label))
|
||||
return dict(hashes=HASHES, evidence=results,
|
||||
boundary='Static source evidence; cadence and original runtime remain unverified.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('original', nargs='?', type=Path,
|
||||
default=Path(__file__).resolve().parents[3] / 'Original')
|
||||
print(json.dumps(collect(parser.parse_args().original), indent=2))
|
||||
@@ -0,0 +1,108 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Check the bounded fresh-lab registry construction proof against original bytes."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import struct
|
||||
import sys
|
||||
|
||||
from pe_inspect import PE
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'levels'))
|
||||
from gam import parse
|
||||
|
||||
EXE_HASH = 'f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8'
|
||||
GAM_HASH = '316fff40db565c2add5b07cbccdef640ddb67c64d6625fea1429ce2a0542a234'
|
||||
|
||||
CALLS = [
|
||||
(0x46E335, 0x459CB0, 'loader constructs header game before reading entities'),
|
||||
(0x45D3FD, 0x44F300, 'LV1B factory constructor'),
|
||||
(0x44F358, 0x44D2B0, 'lab constructor calls JimmyGame base'),
|
||||
(0x44D306, 0x4745A0, 'JimmyGame calls game base'),
|
||||
(0x47460A, 0x4586F0, 'game base constructs interface at complete+8C'),
|
||||
(0x458712, 0x46FBE0, 'interface base owns registry insertion'),
|
||||
(0x46E3B9, 0x459CB0, 'loader first fresh entity factory'),
|
||||
(0x45B1E2, 0x422160, '3JIM factory constructor'),
|
||||
(0x4221B1, 0x437280, 'Jimmy calls player base'),
|
||||
(0x4372DA, 0x40D110, 'player calls animated base'),
|
||||
(0x40D162, 0x462040, 'animated calls object base'),
|
||||
(0x4620AA, 0x4586F0, 'object base constructs interface at complete+C0'),
|
||||
(0x4374DF, 0x421D80, 'player constructs owned jetpack fire'),
|
||||
(0x421DD2, 0x40D110, 'fire calls animated base and registers'),
|
||||
(0x42250C, 0x43F640, 'Jimmy constructs owned shadow'),
|
||||
(0x43F692, 0x4352F0, 'shadow calls picture base'),
|
||||
(0x435341, 0x463F10, 'picture calls sprite base'),
|
||||
(0x463F74, 0x4586F0, 'sprite base constructs interface at complete+C8'),
|
||||
(0x46E49A, 0x459CB0, 'loader remaining fresh entities factory'),
|
||||
(0x423C98, 0x41C810, 'Jimmy postload creates absent Goddard'),
|
||||
(0x41C861, 0x407A40, 'Goddard calls AI base'),
|
||||
(0x407A92, 0x40D110, 'AI calls animated base and registers'),
|
||||
(0x41C95F, 0x43F640, 'Goddard constructs owned shadow'),
|
||||
]
|
||||
ANCHORS = [
|
||||
(0x46FF4A, '8b359c9950006a0c8b7e04', 'registry sentinel,12-byte node,old tail'),
|
||||
(0x46FF6D, '8978048946048b48048901', 'link node before sentinel after old tail'),
|
||||
(0x46FF7F, '8928', 'node payload receives interface pointer'),
|
||||
(0x46E36A, 'ffd6', 'read entity count after header construction'),
|
||||
(0x46E37F, 'ffd6', 'read first entity code after count'),
|
||||
(0x46E61A, 'ff920c040000', 'postload pass calls interface40C'),
|
||||
(0x4374EF, '8985f8070000', 'Jimmy complete+7F8 owns fire complete pointer'),
|
||||
(0x42251C, '89852c0a0000', 'Jimmy complete+A2C owns shadow complete pointer'),
|
||||
(0x41C96F, '898694090000', 'Goddard complete+994 owns shadow complete pointer'),
|
||||
(0x42275A, 'c685c900000001', 'Jimmy enables interface+09 reuse flag'),
|
||||
(0x41C9C0, 'c686c900000001', 'Goddard enables interface+09 reuse flag'),
|
||||
(0x46E6B9, '3bb00404000075078a580984db750d', 'reuse requires matching class code and interface+09'),
|
||||
]
|
||||
SLOTS = [
|
||||
(0x4D5EA0, 0x128, 0x46E570, 'supervisor postload pass'),
|
||||
(0x4D5EA0, 0x110, 0x46E6E0, 'supervisor existing class lookup'),
|
||||
(0x4D5EA0, 0x11C, 0x46E6A0, 'supervisor class reuse predicate'),
|
||||
(0x4A373C, 0x40C, 0x423610, 'Jimmy postload contains Goddard creation'),
|
||||
]
|
||||
|
||||
|
||||
def collect(original):
|
||||
original = Path(original)
|
||||
pe = PE(original / 'Neutron.exe')
|
||||
gam_data = (original / 'gam' / 'level1b.gam').read_bytes()
|
||||
if hashlib.sha256(pe.data).hexdigest() != EXE_HASH:
|
||||
raise ValueError('Unsupported Neutron.exe hash')
|
||||
if hashlib.sha256(gam_data).hexdigest() != GAM_HASH:
|
||||
raise ValueError('Unsupported lab GAM hash')
|
||||
evidence = []
|
||||
for va, expected, label in ANCHORS:
|
||||
off = pe.offset(va - pe.base)
|
||||
actual = pe.data[off:off + len(expected)//2].hex()
|
||||
if actual != expected:
|
||||
raise ValueError(f'{label} {va:#x}: {actual} != {expected}')
|
||||
evidence.append(dict(va=hex(va), file_offset=hex(off), bytes=actual, evidence=label))
|
||||
for va, target, label in CALLS:
|
||||
off = pe.offset(va - pe.base)
|
||||
data = pe.data[off:off + 5]
|
||||
if data[0] != 0xE8 or va + 5 + struct.unpack('<i', data[1:])[0] != target:
|
||||
raise ValueError(f'{label}: invalid direct call at {va:#x}')
|
||||
evidence.append(dict(va=hex(va), file_offset=hex(off), target=hex(target), evidence=label))
|
||||
for table, slot, target, label in SLOTS:
|
||||
va = table + slot
|
||||
off = pe.offset(va - pe.base)
|
||||
if pe.u32(off) != target:
|
||||
raise ValueError(f'{label}: invalid vtable entry at {va:#x}')
|
||||
evidence.append(dict(va=hex(va), file_offset=hex(off), target=hex(target), evidence=label))
|
||||
lab = parse(gam_data)
|
||||
return dict(hashes={'Neutron.exe': EXE_HASH, 'gam/level1b.gam': GAM_HASH},
|
||||
evidence=evidence, lab=dict(code=lab.code, entities=len(lab.entities),
|
||||
first_record=dict(kind=lab.entities[0].kind, offset=hex(lab.entities[0].offset),
|
||||
tag=lab.entities[0].values().get('ObjectTag')),
|
||||
serialized_goddards=sum(e.kind == '3GOD' for e in lab.entities)),
|
||||
fresh_partial_order=['LV1B game', 'Jimmy', 'Jimmy fire', 'Jimmy shadow',
|
||||
'remaining serialized entities', 'postload Goddard', 'Goddard shadow'],
|
||||
boundary='Partial order, not absolute indices: other constructor helpers intervene. '
|
||||
'Retained/reused transition ordering and original runtime remain unverified.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('original', nargs='?', type=Path,
|
||||
default=Path(__file__).resolve().parents[3] / 'Original')
|
||||
print(json.dumps(collect(parser.parse_args().original), indent=2))
|
||||
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only, bounded anchors for the architecture checkpoint (not a disassembler)."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import struct
|
||||
|
||||
from pe_inspect import PE
|
||||
|
||||
EXE_SHA256 = 'f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8'
|
||||
FRAME_CALLS = [(0x47E554, 0x479BC0), (0x47E560, 0x462A20),
|
||||
(0x47E56B, 0x4693A0), (0x47E57A, 0x47D8F0),
|
||||
(0x47E582, 0x473740), (0x47E587, 0x473770),
|
||||
(0x47E6B1, 0x477DB0)]
|
||||
ANCHORS = {
|
||||
'viewport_constructor': (0x47E374, 'c706c4744d00'),
|
||||
'viewport_render_import': (0x47E6DF, 'ff1504d34800'),
|
||||
'registry_update_slot10': (0x473758, 'ff5010'),
|
||||
'registry_next_after_callback': (0x47375B, '8b36'),
|
||||
'registry_sync_slot3dc': (0x473784, 'ff90dc030000'),
|
||||
'registry_sync_slot3e0': (0x47378E, 'ff92e0030000'),
|
||||
'tail_link': (0x46FF70, '894604'),
|
||||
'registry_interface_payload': (0x46FF7F, '8928'),
|
||||
'normal_update_slot3c4': (0x4702C5, 'ff92c4030000'),
|
||||
'controlled_input_slot3cc': (0x475AA9, 'ff92cc030000'),
|
||||
'morph_logic_import': (0x462265, 'ff1544d24800'),
|
||||
}
|
||||
|
||||
|
||||
def recover(original):
|
||||
exe = PE(Path(original) / 'Neutron.exe')
|
||||
digest = hashlib.sha256(exe.data).hexdigest()
|
||||
if digest != EXE_SHA256:
|
||||
raise ValueError('Unsupported original EXE hash')
|
||||
result = {'sha256': digest, 'calls': [], 'anchors': []}
|
||||
for va, expected in FRAME_CALLS:
|
||||
off = exe.offset(va - exe.base)
|
||||
if exe.data[off] != 0xE8:
|
||||
raise ValueError(f'Expected direct call at {va:#x}')
|
||||
target = va + 5 + struct.unpack_from('<i', exe.data, off + 1)[0]
|
||||
if target != expected:
|
||||
raise ValueError(f'Changed call at {va:#x}')
|
||||
result['calls'].append({'va': f'{va:#x}', 'file_offset': f'{off:#x}',
|
||||
'target': f'{target:#x}'})
|
||||
for name, (va, expected) in ANCHORS.items():
|
||||
off = exe.offset(va - exe.base)
|
||||
raw = bytes.fromhex(expected)
|
||||
if exe.data[off:off + len(raw)] != raw:
|
||||
raise ValueError(f'Changed anchor {name}')
|
||||
result['anchors'].append({'name': name, 'va': f'{va:#x}',
|
||||
'file_offset': f'{off:#x}', 'bytes': expected})
|
||||
vtable = 0x4D74C4
|
||||
off = exe.offset(vtable + 0xB8 - exe.base)
|
||||
if exe.u32(off) != 0x47E4F0:
|
||||
raise ValueError('Viewport vtable slot B8 changed')
|
||||
result['viewport_slot_b8'] = {'va': hex(vtable + 0xB8), 'file_offset': hex(off),
|
||||
'target': '0x47e4f0'}
|
||||
return result
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('original', type=Path)
|
||||
print(json.dumps(recover(parser.parse_args().original), indent=2))
|
||||
@@ -0,0 +1,108 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only ordinary scene-loader ownership and keyboard-reset byte 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
|
||||
|
||||
SITES = (
|
||||
("editor_constructor_vtable", 0x46B200, "c74500a05e4d00"),
|
||||
("editor_global_owner", 0x46B237, "892d80995000"),
|
||||
("request_pending", 0x46DF76, "c6814c07000001"),
|
||||
("request_filename", 0x46DF7D, "8d914d070000"),
|
||||
("update_pending_dispatch", 0x46C05E, "ff9204010000"),
|
||||
("teardown_first_filter", 0x46E032, "ff9200020000"),
|
||||
("teardown_first_uninit", 0x46E054, "ff5220"),
|
||||
("teardown_second_uninit", 0x46E091, "ff5234"),
|
||||
("teardown_delete_mark", 0x46E0CA, "c6460601"),
|
||||
("teardown_delete_sweep", 0x46E0D9, "e832560000"),
|
||||
("teardown_database_close", 0x46E117, "e8e4ceffff"),
|
||||
("ordinary_gam_load", 0x46E152, "ff90fc000000"),
|
||||
("ordinary_pending_clear", 0x46E158, "c6854c07000000"),
|
||||
("object_reuse_test", 0x46E45A, "ff921c010000"),
|
||||
("object_reuse_lookup", 0x46E46E, "ff9010010000"),
|
||||
("object_factory", 0x46E49A, "e811b8feff"),
|
||||
("ordinary_postload_registry", 0x46E4FF, "ff9228010000"),
|
||||
("registry_init_callback", 0x46E5C3, "ff5228"),
|
||||
("registry_postload_callback", 0x46E61A, "ff920c040000"),
|
||||
("registry_timer_reset", 0x46E694, "e8d7fd0000"),
|
||||
("destruction_predicate", 0x4719B0, "8a8139010000c3"),
|
||||
("destruction_predicate_set", 0x4719C4, "888139010000"),
|
||||
("persistent_flag_setter", 0x470F47, "884111ff9204020000"),
|
||||
("jimmy_constructor_flag", 0x4226BF, "e87ce80400"),
|
||||
("goddard_constructor_flag", 0x41C99E, "e89d450500"),
|
||||
("jimmy_constructor_reusable", 0x42275A, "c685c900000001"),
|
||||
("goddard_constructor_reusable", 0x41C9C0, "c686c900000001"),
|
||||
("load_prefix_caption_cleanup", 0x46E26C, "e86f840000"),
|
||||
("load_prefix_physics_cleanup", 0x46E271, "e88aad0000"),
|
||||
("lab_constructor_base", 0x44F358, "e853dfffff"),
|
||||
("game_constructor_base", 0x44D306, "e895720200"),
|
||||
("game_constructor_clear_control", 0x474683, "e8b8130000"),
|
||||
("game_constructor_current_game", 0x474688, "893548995000"),
|
||||
("lab_game_preserve_predicate", 0x44D472, "ff9004020000"),
|
||||
("keyboard_down_array", 0x46A370, "c6803898500001"),
|
||||
("keyboard_up_array", 0x46A390, "c6803898500000"),
|
||||
("acquired_reset_key_test", 0x4235D8, "a08a98500084c07423"),
|
||||
("acquired_reset_count", 0x4235E2, "b968100000"),
|
||||
("acquired_reset_address", 0x4235E9, "bf38844f00f3ab"),
|
||||
)
|
||||
|
||||
VTABLES = (
|
||||
("editor update", 0x4D5EA0, 0xC4, 0x46BEC0),
|
||||
("editor load GAM", 0x4D5EA0, 0xFC, 0x46E170),
|
||||
("editor request load", 0x4D5EA0, 0x100, 0x46DF70),
|
||||
("editor consume load", 0x4D5EA0, 0x104, 0x46DFF0),
|
||||
("editor cleanup", 0x4D5EA0, 0x10C, 0x46E710),
|
||||
("editor find reusable", 0x4D5EA0, 0x110, 0x46E6E0),
|
||||
("editor test reusable", 0x4D5EA0, 0x11C, 0x46E6A0),
|
||||
("editor reset/postload", 0x4D5EA0, 0x128, 0x46E570),
|
||||
("Jimmy destruction predicate", 0x4A373C, 0x200, 0x4719B0),
|
||||
("Jimmy initialization", 0x4A373C, 0x28, 0x437890),
|
||||
("Jimmy placement PostLoad", 0x4A373C, 0x40C, 0x423610),
|
||||
("Jimmy key-gated reset", 0x4A373C, 0x3C8, 0x4235B0),
|
||||
("lab game destruction predicate", 0x4C386C, 0x200, 0x4719B0),
|
||||
("lab game predicate setter", 0x4C386C, 0x204, 0x4719C0),
|
||||
)
|
||||
|
||||
|
||||
def collect(root: Path) -> dict:
|
||||
pe = PE(find_case(root, "Neutron.exe"))
|
||||
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:
|
||||
target = 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(target), matches=target == expected))
|
||||
digest = hashlib.sha256(pe.data).hexdigest()
|
||||
return dict(module="Neutron.exe", sha256=digest, known_binary=digest == EXE_SHA256,
|
||||
sites=sites, vtables=tables, acquired_reset_virtual_key=0x50988A-0x509838,
|
||||
scope="Static source instructions only, no original runtime execution.")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
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)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,144 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only script/task/RETURN checkpoint evidence from the supplied originals.
|
||||
|
||||
Reports preferred-base VAs, PE-mapped file offsets, exact bytes and dependencies.
|
||||
No original code is executed. Assertions establish the inspected binary identity
|
||||
and call/field provenance, not original-game runtime behavior.
|
||||
"""
|
||||
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))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "levels"))
|
||||
from pe_inspect import PE
|
||||
import gam
|
||||
|
||||
EXE_SHA256 = "f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8"
|
||||
|
||||
# Small decisive sites, independently checked against objdump. Offsets are never
|
||||
# assumed to equal RVA: PE.offset performs the actual section mapping.
|
||||
SITES = (
|
||||
("task_objective_before_records", 0x45FB5B, "e8f073faff"),
|
||||
("task_record_mutation", 0x45FB7F, "895f64"),
|
||||
("task_entity_callback", 0x45FBD9, "ff9024040000"),
|
||||
("carl_query_scene", 0x413F3D, "e85ebf0400"),
|
||||
("carl_generic_callback", 0x413F4E, "e8eda3ffff"),
|
||||
("carl_lab_derived_branch", 0x414068, "85db0f8c9800000083fb3c"),
|
||||
("carl_marker_state", 0x4140AA, "6a06ff9024010000"),
|
||||
("carl_marker_root", 0x4140E0, "ff9214030000"),
|
||||
("pickup_checkpoint_level", 0x42AF1B, "898e481e0000"),
|
||||
("pickup_checkpoint_root", 0x42AF30, "81c6381e0000"),
|
||||
("stage_preserve_test", 0x43B78E, "8a83a509000084c07537"),
|
||||
("stage_root_write", 0x43B7B1, "8d8ba8090000"),
|
||||
("stage_game_load_request", 0x43B7F1, "ff9200010000"),
|
||||
("return_suppress_start", 0x458014, "889054090000"),
|
||||
("return_preserve_root", 0x458028, "8890a5090000"),
|
||||
("return_stage_dispatch", 0x45815C, "ff9268010000"),
|
||||
("scene_postload_dispatch", 0x46E61A, "ff920c040000"),
|
||||
("jimmy_postload_return_root", 0x423ABF, "ff926c010000"),
|
||||
("jimmy_postload_control", 0x423B3D, "ff9218010000"),
|
||||
("tsk_setter_call", 0x460CE2, "e8a9ecffff"),
|
||||
("tsk_second_matching_callback", 0x460D2E, "ff9024040000"),
|
||||
("tsk_all_entity_420", 0x460D87, "ff9220040000"),
|
||||
("load_request_pending", 0x460E7B, "c6057cc64f0001"),
|
||||
("load_update_reader", 0x460EF0, "e8fbf4ffff"),
|
||||
("load_update_clear_pending", 0x460EF8, "c6057cc64f0000"),
|
||||
)
|
||||
|
||||
VTABLES = (
|
||||
("Jimmy complete transition", 0x4A3BDC, 0x168, 0x43B5A0),
|
||||
("Jimmy complete pickup capture", 0x4A3BDC, 0x1E8, 0x42AF00),
|
||||
("Jimmy complete capture/effect", 0x4A3BDC, 0x1EC, 0x42AF50),
|
||||
("Carl game task callback", 0x495364, 0x424, 0x413F30),
|
||||
("Carl game post-task hook", 0x495364, 0x420, 0x413EB0),
|
||||
("Jimmy game post-task hook", 0x4A373C, 0x420, 0x472970),
|
||||
("Jimmy game placement PostLoad", 0x4A373C, 0x40C, 0x423610),
|
||||
("LOAD game task callback", 0x4D025C, 0x424, 0x458880),
|
||||
)
|
||||
|
||||
|
||||
def find_case(root: Path, relative: str) -> Path:
|
||||
current = root
|
||||
for component in Path(relative).parts:
|
||||
matches = [p for p in current.iterdir() if p.name.casefold() == component.casefold()]
|
||||
if len(matches) != 1:
|
||||
raise ValueError(f"missing or ambiguous original path: {relative}")
|
||||
current = matches[0]
|
||||
return current
|
||||
|
||||
|
||||
def read_va(pe: PE, va: int, size: int) -> bytes:
|
||||
if size < 0:
|
||||
raise ValueError("negative byte count")
|
||||
start = pe.offset(va - pe.base)
|
||||
if size and pe.offset(va + size - 1 - pe.base) != start + size - 1:
|
||||
raise ValueError("VA range is not contiguous file data")
|
||||
result = pe.data[start:start + size]
|
||||
if len(result) != size:
|
||||
raise ValueError("truncated VA range")
|
||||
return result
|
||||
|
||||
|
||||
def rel_call_target(pe: PE, va: int) -> int:
|
||||
raw = read_va(pe, va, 5)
|
||||
if raw[0] != 0xE8:
|
||||
raise ValueError(f"not a direct relative call at {va:#x}")
|
||||
return va + 5 + struct.unpack_from("<i", raw, 1)[0]
|
||||
|
||||
|
||||
def collect(root: Path) -> dict:
|
||||
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()
|
||||
site = 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"):
|
||||
site["direct_call_target"] = hex(rel_call_target(pe, va))
|
||||
sites.append(site)
|
||||
vtables = []
|
||||
for name, table, slot, expected in VTABLES:
|
||||
va = table + slot
|
||||
actual = struct.unpack("<I", read_va(pe, va, 4))[0]
|
||||
vtables.append(dict(name=name, table=hex(table), slot=hex(slot),
|
||||
va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
|
||||
target=hex(actual), matches=actual == expected))
|
||||
route = []
|
||||
for filename, tags in (("gam/level1b.gam", {"startexp", "shrinkray", "neutron1a", "labtoneigh"}),
|
||||
("gam/VR04.gam", {"phonebooth"})):
|
||||
path = find_case(root, filename)
|
||||
raw = path.read_bytes()
|
||||
level = gam.parse(raw)
|
||||
selected = []
|
||||
for entity in level.entities:
|
||||
fields = entity.values()
|
||||
tag = str(fields.get("ObjectTag", ""))
|
||||
if tag.casefold() in tags or entity.kind == "LOAD":
|
||||
selected.append(dict(kind=entity.kind, file_offset=hex(entity.offset),
|
||||
fields=fields))
|
||||
route.append(dict(file=filename, sha256=hashlib.sha256(raw).hexdigest(),
|
||||
code=level.code, entities=selected))
|
||||
return dict(module="Neutron.exe", sha256=digest, known_binary=digest == EXE_SHA256,
|
||||
sites=sites, vtables=vtables, route=route,
|
||||
scope="Static bytes/data only; no original runtime execution.")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
cli = argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument("original", type=Path)
|
||||
args = cli.parse_args()
|
||||
result = collect(args.original)
|
||||
print(json.dumps(result, indent=2, allow_nan=False))
|
||||
if not result["known_binary"] or not all(s["matches"] for s in result["sites"] + result["vtables"]):
|
||||
raise SystemExit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only evidence: sound completion uses inherited software timing, not GetStatus."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import struct
|
||||
|
||||
from pe_inspect import PE
|
||||
from checkpoint_camera_audio_ui import EXE_SHA256, DLL_SHA256
|
||||
|
||||
ANCHORS = [
|
||||
(0x10071E50, '8b461c85c0', 'duration field guards status'),
|
||||
(0x10071E65, 'e8866e0800', 'status uses engine millisecond clock'),
|
||||
(0x10071E7C, '8b4e1c3bc17602b301', 'strict elapsed greater than duration expires'),
|
||||
(0x10071E87, '890f', 'second output is duration, not hardware status'),
|
||||
(0x1003B32B, '8a9c24f4000000', 'DX repeat argument'),
|
||||
(0x1003B338, '84db0f95c1516a006a0057ff5030', 'repeat boolean sent to buffer play flags'),
|
||||
(0x1003B46B, '885e30', 'DX stores repeat flag at30'),
|
||||
(0x1003B46E, 'd94544dc0d50541110dc0548541110', 'sound duration seconds times1000 plus.5'),
|
||||
(0x1003B657, '885f30895f1c', 'DX stop clears repeat and duration'),
|
||||
(0x100F8893, '8a5c2424', 'Win repeat argument'),
|
||||
(0x100F8917, '885e30', 'Win stores repeat flag at30'),
|
||||
(0x100F8996, 'c6463000', 'Win stop clears repeat'),
|
||||
]
|
||||
|
||||
|
||||
def collect(original):
|
||||
original = Path(original)
|
||||
dll = PE(original / 'OMT2.dll')
|
||||
exe = PE(original / 'Neutron.exe')
|
||||
if hashlib.sha256(dll.data).hexdigest() != DLL_SHA256 or hashlib.sha256(exe.data).hexdigest() != EXE_SHA256:
|
||||
raise ValueError('Unsupported original identity')
|
||||
result = {'anchors': [], 'vtables': [], 'constants': []}
|
||||
for va, expected, label in ANCHORS:
|
||||
off = dll.offset(va - dll.base)
|
||||
raw = bytes.fromhex(expected)
|
||||
if dll.data[off:off + len(raw)] != raw:
|
||||
raise ValueError(f'Changed {label} at {va:#x}')
|
||||
result['anchors'].append(dict(va=hex(va), file_offset=hex(off), bytes=expected, label=label))
|
||||
for table in [0x10115420, 0x1011629C, 0x10116B3C]:
|
||||
va = table + 0x14
|
||||
off = dll.offset(va - dll.base)
|
||||
target = dll.u32(off)
|
||||
if target != 0x10071E40:
|
||||
raise ValueError('SoundChannel slot14 no longer inherited software clock')
|
||||
result['vtables'].append(dict(va=hex(va), file_offset=hex(off), target=hex(target)))
|
||||
for va, expected in [(0x10115448, .5), (0x10115450, 1000.0)]:
|
||||
off = dll.offset(va - dll.base)
|
||||
actual = struct.unpack_from('<d', dll.data, off)[0]
|
||||
if actual != expected:
|
||||
raise ValueError('Duration constant changed')
|
||||
result['constants'].append(dict(va=hex(va), file_offset=hex(off), value=actual))
|
||||
return result
|
||||
|
||||
|
||||
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