Reconstruct lab story, interactions, patrol and jet pack practice flow
This commit is contained in:
1 parent
58424120bb
commit
c929f942e1
84 files changed
+7957
-305
No files matched your search
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only checks for the original Level3B/E entity/archive loader paths.
|
||||
|
||||
No original code is executed. Run from GamePort with Python 3.
|
||||
This proves what the loader requests, not normal-gameplay reachability.
|
||||
"""
|
||||
from pathlib import Path
|
||||
import hashlib
|
||||
import json
|
||||
import struct
|
||||
import sys
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
PROJECT = HERE.parent.parent
|
||||
sys.path.insert(0, str(HERE))
|
||||
sys.path.insert(0, str(PROJECT / 'tools/levels'))
|
||||
from pe_inspect import PE
|
||||
from rtti_map import rtti_map
|
||||
from gam import parse
|
||||
|
||||
|
||||
def main():
|
||||
original = PROJECT.parent / 'Original'
|
||||
pe = PE(original / 'Neutron.exe')
|
||||
checks = {
|
||||
'b_ctor_level_code': (0x451ba8, '684233564c'),
|
||||
'b_archive_string_length': (0x451c99, 'bf241f4f00'),
|
||||
'b_archive_string_copy': (0x451cc5, 'be241f4f00'),
|
||||
'b_archive_loader_dispatch': (0x451ce8, 'ff92e4000000'),
|
||||
'e_ctor_level_code': (0x452748, '684533564c'),
|
||||
'e_archive_string_length': (0x452839, 'bffc1f4f00'),
|
||||
'e_archive_string_copy': (0x452865, 'befc1f4f00'),
|
||||
'e_archive_loader_dispatch': (0x452888, 'ff92e4000000'),
|
||||
'loader_omt_directory': (0x44e7ff, '681c1b4f00'),
|
||||
'loader_file_open': (0x44e8b4, 'e8b7780200'),
|
||||
'loader_database_open': (0x44e8ce, 'e82d770200'),
|
||||
'b_factory_ctor': (0x45d635, 'e8b644ffff'),
|
||||
'e_factory_ctor': (0x45d78b, 'e8004fffff'),
|
||||
}
|
||||
for name, (va, expected) in checks.items():
|
||||
off = pe.offset(va - pe.base)
|
||||
actual = pe.data[off:off + len(expected)//2].hex()
|
||||
if actual != expected:
|
||||
raise ValueError(f'{name} at {va:#x}: {actual} != {expected}')
|
||||
directory = pe.cstr(pe.offset(0x4f1b1c - pe.base))
|
||||
assert directory == 'omt'
|
||||
scenes = []
|
||||
for suffix, string_va in [('B', 0x4f1f24), ('E', 0x4f1ffc)]:
|
||||
level_path = original / 'gam' / f'Level3{suffix}.gam'
|
||||
level = parse(level_path.read_bytes())
|
||||
archive_name = pe.cstr(pe.offset(string_va - pe.base))
|
||||
table = next(v for v in rtti_map(pe, f'CLevel03{suffix}Game')['vtables']
|
||||
if v['object_displacement'] == '0x0')
|
||||
methods = {m['slot']: m['va'] for m in table['methods']}
|
||||
assert methods['0xe4'] == '0x44e7b0'
|
||||
matches = [p for p in (original / directory).iterdir()
|
||||
if p.name.casefold() == archive_name.casefold()]
|
||||
scenes.append(dict(
|
||||
gam=str(level_path.relative_to(original)),
|
||||
gam_sha256=hashlib.sha256(level_path.read_bytes()).hexdigest(),
|
||||
gam_bytes=level.size, gam_code=level.code,
|
||||
entity_count=len(level.entities),
|
||||
entity_kinds=[e.kind for e in level.entities],
|
||||
complete_vtable=table['va'], initialize_slot_b4=methods['0xb4'],
|
||||
archive_loader_slot_e4=methods['0xe4'],
|
||||
archive_string_va=hex(string_va), archive=archive_name,
|
||||
matching_files=[str(p.relative_to(original)) for p in matches]))
|
||||
print(json.dumps(dict(
|
||||
executable_sha256=hashlib.sha256(pe.data).hexdigest(),
|
||||
verified_instruction_sequences=len(checks), archive_directory=directory,
|
||||
scenes=scenes,
|
||||
same_gam_bytes_after_header=(
|
||||
(original/'gam/Level3B.gam').read_bytes()[4:] ==
|
||||
(original/'gam/Level3E.gam').read_bytes()[4:]),
|
||||
limitation='Static loader evidence only. Normal-gameplay reachability, unused/stub status and original runtime failure/success remain unverified.'), indent=2))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in new issue
Block a user