85 lines
3.9 KiB
Python
85 lines
3.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Read-only identity, branch-range and ASE guards for Jimmy's turn poses.
|
|
|
|
The retained REA disassembly is interpreted in docs/gameplay/jimmy-turn-animation.md.
|
|
This validates that the original bytes and morph resources still match that evidence;
|
|
it neither executes the original nor substitutes a Python gameplay implementation.
|
|
"""
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import struct
|
|
import sys
|
|
|
|
from checkpoint_script_state import EXE_SHA256, find_case, read_va
|
|
from pe_inspect import PE
|
|
|
|
RANGES = (
|
|
(0x422b40, 40, '80c05deb52453d14b4db0e74254ea9ab6775358392551681cea7d4b5b5747347'),
|
|
(0x437ac9, 213, '2b8559afb06bcb3f04c033bbac31f4db8cff4ca07309cedd34c464bb9d162a7f'),
|
|
(0x438f6e, 7, '6f5f444126a0866a854c30e2818fe8d36d75447a14c06b2868067ebac52b7284'),
|
|
(0x4391bd, 7, 'f292143f7a0fa307f5d198fc1763b11f4bb3758e299df5147f04e3970af5bd28'),
|
|
(0x439230, 9, '007abea151f3b1ae7ed194e44693e2a101950bf49b27a4ef045ecba829f60fec'),
|
|
(0x42a7a0, 54, 'c8fa10f42eefe68a195d9980f1a57558a240cd7877bfeab567e7868c0ddf419f'),
|
|
(0x43aff8, 34, 'e72f29b0659f469c3482e539ffd8af9659858b526c4101deb5de419aeee0cc7e'),
|
|
(0x43b273, 23, '46fb502f80298f10195873eb9637301bde63a644431d128aeb64ff0259f9da1c'),
|
|
(0x43b32a, 156, '27d0d59eed50895c9405c25273802e0e74b5fa10c015343ecec86cae25022074'),
|
|
(0x40de95, 137, 'bdae5e890787e8b0f0d8d94b0f518f37f0cf5ab8bb8794e9530a5b124cf6e8cd'),
|
|
)
|
|
ASSETS = {
|
|
'jimstop.ase': 'b294d090ac5c4ec449d845db6d837f2cbedf5f7b812f5b6ed2bb70f85246f1d0',
|
|
'jimleft.ase': '08772d0b0f539ceb61d92b5f84663e62255beafb970a903548f96ab2b14d20e0',
|
|
'jimright.ase': 'b5578a5df2e84a8d78d9e00fa8cf57e9744cd12dcc7fdbfba241e4730edf2adf',
|
|
}
|
|
STRINGS = {
|
|
0x4ef230: b'HIRIGHT\0', 0x4ef238: b'jimright.ase\0',
|
|
0x4ef248: b'HILEFT\0', 0x4ef250: b'jimleft.ase\0',
|
|
0x4f05dc: b'RIGHT\0', 0x4f05e4: b'LEFT\0', 0x4ed3dc: b'HI\0',
|
|
}
|
|
|
|
|
|
def collect(original):
|
|
original = Path(original)
|
|
pe = PE(find_case(original, 'Neutron.exe'))
|
|
if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256:
|
|
raise ValueError('Unexpected original EXE')
|
|
ranges = []
|
|
for va, length, expected in RANGES:
|
|
digest = hashlib.sha256(read_va(pe, va, length)).hexdigest()
|
|
if digest != expected:
|
|
raise ValueError(f'Changed evidence range {va:#x}')
|
|
ranges.append(dict(va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
|
|
length=length, sha256=digest))
|
|
for va, expected in STRINGS.items():
|
|
if read_va(pe, va, len(expected)) != expected:
|
|
raise ValueError(f'Changed string at {va:#x}')
|
|
if struct.unpack('<f', read_va(pe, 0x48e5ec, 4))[0] != 10.0:
|
|
raise ValueError('Changed run threshold')
|
|
if struct.unpack('<f', read_va(pe, 0x48d914, 4))[0] != 0.0:
|
|
raise ValueError('Changed backpedal guard')
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]/'extractors'))
|
|
from ase import read_ase
|
|
assets = []
|
|
for name, expected in ASSETS.items():
|
|
path = find_case(find_case(original, 'ASE'), name)
|
|
animation = read_ase(path)
|
|
if animation['sha256'] != expected:
|
|
raise ValueError(f'Changed ASE resource {name}')
|
|
assets.append(dict(source=path.name, sha256=expected,
|
|
frames_per_second=animation['framesPerSecond'],
|
|
ticks_per_frame=animation['ticksPerFrame'],
|
|
objects=[dict(name=o['name'], samples=len(o['samples']),
|
|
times=[s['time'] for s in o['samples']],
|
|
vertex_counts=sorted({len(s['vertices']) for s in o['samples']}))
|
|
for o in animation['objects']]))
|
|
return dict(source_sha256=EXE_SHA256,
|
|
rea_evidence='ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904',
|
|
ranges=ranges, assets=assets)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('original', type=Path)
|
|
print(json.dumps(collect(parser.parse_args().original), indent=2))
|