105 lines
4.8 KiB
Python
105 lines
4.8 KiB
Python
#!/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))
|