Recover retained route state and complete PostLoad availability tails
This commit is contained in:
1 parent
1dddfefc68
commit
9ad5a8ef6b
36 files changed
+1559
-32
No files matched your search
@@ -71,7 +71,11 @@ DISABLE_CALLS = (0x423E71, 0x423E7C, 0x423E87, 0x423E92,
|
||||
|
||||
|
||||
def gadget_postload(states, tutorial):
|
||||
"""Bounded state oracle: source403870 preserves values other than1/4."""
|
||||
"""Common PostLoad prefix only:403870 preserves values other than1/4.
|
||||
|
||||
Later level tails override this result; see retained_return_cleanup.py.
|
||||
This function does not model final scene availability.
|
||||
"""
|
||||
values = list(states)
|
||||
if len(values) < 8:
|
||||
raise ValueError('Need all eight group0 gadget entries')
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/* Isolated original-component probe. Compile at a non-game image base and run
|
||||
* with reference_capture.py --asset-probe against a COPIED Neutron.exe only.
|
||||
* Maps PE sections without running entry points/imports. Executes only proven
|
||||
* leaf vector accessors and 43A750 with an already-invalid sound handle.
|
||||
* Synthetic vtables use the guarded source targets rebased to the mapped copy;
|
||||
* these selected paths use relative calls/fields, never absolute source globals.
|
||||
* Does not execute the full loader, controller, physics or original game. */
|
||||
#include <windows.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#define TC __attribute__((thiscall))
|
||||
typedef struct { float x,y,z,w; } Vec4;
|
||||
typedef void *(TC *GetVector)(void *, void *);
|
||||
typedef void (TC *SetVector)(void *, Vec4);
|
||||
typedef void (TC *Prepare)(void *);
|
||||
static unsigned char *mapped;
|
||||
static void *at(unsigned va) { return mapped+va-0x400000; }
|
||||
static void require(int ok, const char *message) {
|
||||
if (!ok) { fprintf(stderr,"FAIL %s\n",message); exit(2); }
|
||||
}
|
||||
static void map_copy(void) {
|
||||
FILE *f=fopen("Neutron.exe","rb"); require(f!=NULL,"copied EXE available");
|
||||
fseek(f,0,SEEK_END); long size=ftell(f); rewind(f);
|
||||
require(size>0 && size<16000000,"bounded EXE size");
|
||||
unsigned char *data=malloc(size); require(data!=NULL,"file allocation");
|
||||
require(fread(data,1,size,f)==(size_t)size,"read copied EXE"); fclose(f);
|
||||
require(size>64 && *(uint16_t*)data==IMAGE_DOS_SIGNATURE,"DOS header");
|
||||
uint32_t nt_offset=*(uint32_t*)(data+0x3c);
|
||||
require(nt_offset<(uint32_t)size-sizeof(IMAGE_NT_HEADERS32),"NT header bounds");
|
||||
IMAGE_NT_HEADERS32 *nt=(void*)(data+nt_offset);
|
||||
require(nt->Signature==IMAGE_NT_SIGNATURE && nt->FileHeader.Machine==IMAGE_FILE_MACHINE_I386
|
||||
&& nt->OptionalHeader.ImageBase==0x400000 && nt->OptionalHeader.SizeOfImage<16000000,"expected PE32 layout");
|
||||
unsigned char *image=VirtualAlloc(NULL,nt->OptionalHeader.SizeOfImage,
|
||||
MEM_COMMIT|MEM_RESERVE,PAGE_EXECUTE_READWRITE);
|
||||
require(image!=NULL,"component code map"); mapped=image;
|
||||
IMAGE_SECTION_HEADER *sections=IMAGE_FIRST_SECTION(nt);
|
||||
require((unsigned char*)(sections+nt->FileHeader.NumberOfSections)<=data+size,"section table bounds");
|
||||
for (unsigned i=0;i<nt->FileHeader.NumberOfSections;i++) {
|
||||
IMAGE_SECTION_HEADER *s=§ions[i];
|
||||
require((uint64_t)s->PointerToRawData+s->SizeOfRawData<=(uint64_t)size
|
||||
&& (uint64_t)s->VirtualAddress+s->SizeOfRawData<=nt->OptionalHeader.SizeOfImage,"section bounds");
|
||||
memcpy(image+s->VirtualAddress,data+s->PointerToRawData,s->SizeOfRawData);
|
||||
}
|
||||
free(data);
|
||||
}
|
||||
int main(void) {
|
||||
setbuf(stdout,NULL); map_copy();
|
||||
unsigned char complete[0x2100]={0}; unsigned char *object=complete+0xc0;
|
||||
uintptr_t complete_table[0x500/4]={0}, interface_table[0x500/4]={0};
|
||||
complete_table[0x148/4]=(uintptr_t)at(0x429a00);
|
||||
interface_table[0x2c4/4]=(uintptr_t)at(0x471f40);
|
||||
*(uintptr_t*)complete=(uintptr_t)complete_table; *(uintptr_t*)object=(uintptr_t)interface_table;
|
||||
const unsigned getters[]={0x471290,0x4712e0,0x4713d0};
|
||||
const unsigned setters[]={0x471bd0,0x471cc0,0x471f70};
|
||||
const unsigned authored[]={0x3c,0x4c,0x7c}, live[]={0x164,0x174,0x1a4};
|
||||
for (unsigned i=0;i<3;i++) {
|
||||
Vec4 expected={11+i,22+i,33+i,44+i}, result;
|
||||
memcpy(object+authored[i],&expected,sizeof(expected));
|
||||
memset(object+live[i],0xa5,sizeof(expected));
|
||||
((GetVector)at(getters[i]))(object,&result);
|
||||
((SetVector)at(setters[i]))(object,result);
|
||||
require(memcmp(object+live[i],&expected,sizeof(expected))==0,"authored vector reapplied");
|
||||
}
|
||||
puts("PASS original leaf accessors reapply authored acceleration/impulse/velocity including fourth component");
|
||||
*(int32_t*)(complete+0xa44)=-1; // Avoid external sound-stop branch.
|
||||
*(float*)(object+0x608)=345;
|
||||
*(int16_t*)(object+0x704)=1; *(int16_t*)(object+0x728)=3;
|
||||
*(float*)(object+0x7b4)=.625f;
|
||||
unsigned char before[sizeof(complete)]; memcpy(before,complete,sizeof(complete));
|
||||
((Prepare)at(0x43a750))(object);
|
||||
require(*(float*)(object+0x608)==0,"preparation speed cleared");
|
||||
Vec4 *velocity=(void*)(object+0x1a4);
|
||||
require(velocity->x==0 && velocity->y==0 && velocity->z==0 && velocity->w==46,"only velocity XYZ cleared");
|
||||
memset(before+0xc0+0x608,0,4); memset(before+0xc0+0x1a4,0,12);
|
||||
require(memcmp(before,complete,sizeof(complete))==0,"all other sentinel fields preserved");
|
||||
puts("PASS original 43A750 clears speed/velocity XYZ; preserves impulse, acceleration, mode, jump and hold sentinels");
|
||||
puts("LIMIT isolated original routines with invalid sound handle; no whole-loader/game runtime verification");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only Goddard/shadow retained-load callback evidence; no source execution."""
|
||||
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
|
||||
from pe_inspect import PE
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'levels'))
|
||||
import gam
|
||||
|
||||
SITES = (
|
||||
('goddard_complete_table', 0x41c866, 'c70620f94900'),
|
||||
('goddard_interface_table', 0x41c883, 'c70780f44900'),
|
||||
('goddard_retention', 0x41c99b, '538bcfe89d450500'),
|
||||
('goddard_reuse', 0x41c9c0, 'c686c900000001'),
|
||||
('goddard_init_bridge', 0x41e6a0, 'e90b98feff'),
|
||||
('actor_init_base', 0x407eb3, 'e838090500'),
|
||||
('actor_init_active', 0x407eb8, 'c6460a01'),
|
||||
('actor_init_state', 0x407ebc, '8b867c080000898608060000'),
|
||||
('actor_init_waypoint', 0x407ec8, 'c7860008000000000000'),
|
||||
('goddard_postload_base', 0x41e593, 'e8e8aefeff'),
|
||||
('actor_postload_base', 0x409486, 'e825530000'),
|
||||
('target_tag_lookup', 0x40948b, '8d86ac06000050e8d9ab0600'),
|
||||
('target_pointer_store', 0x40949a, '898600060000'),
|
||||
('target_id_store', 0x4094ae, '898e10060000'),
|
||||
('target_root_x', 0x4094c9, '898e28080000'),
|
||||
('target_root_y', 0x4094e5, '898e2c080000'),
|
||||
('target_root_z', 0x4094fd, '898e30080000'),
|
||||
('state_snapshot', 0x409503, '8b96080600008d8e40ffffff89967c080000'),
|
||||
('state_virtual_dispatch', 0x409515, '8b96080600008b0152ff9024010000'),
|
||||
('state_previous_store', 0x4089f8, '898ecc0600008986c8060000'),
|
||||
('state_same_gate', 0x408a18, '3bc10f846e010000'),
|
||||
('authored_rotation_get', 0x40952d, 'ff9070010000'),
|
||||
('logical_rotation_set', 0x409552, 'ff922c030000'),
|
||||
('rotation_cache_start', 0x409569, '81c6740200008916'),
|
||||
('rotation_cache_end', 0x409580, '89460c5e83c410c3'),
|
||||
('normal_range', 0x41e598, 'c786180900000080bb44'),
|
||||
('hide_lv4a', 0x41e5ad, '3d4134564c'),
|
||||
('hide_lv1d', 0x41e5ba, '3d4431564c'),
|
||||
('hide_lv1c', 0x41e5c1, '3d4331564c'),
|
||||
('hide_lev6', 0x41e5cc, '3d3656454c'),
|
||||
('hide_lev7', 0x41e5d3, '3d3756454c'),
|
||||
('hide_lv6a', 0x41e5e0, '3d4136564c'),
|
||||
('special_vr06', 0x41e5e7, '3d36305256'),
|
||||
('tutorial6_range', 0x41e5ee, 'c7861809000000c05a45'),
|
||||
('normal_enable', 0x41e618, '6a018bceff90d0000000'),
|
||||
('normal_collision_enable', 0x41e624, '6a018bceff9214020000'),
|
||||
('normal_submode_zero', 0x41e637, '6a008bcfff927c010000'),
|
||||
('normal_radius130', 0x41e64a, '68000002438bceff9010010000'),
|
||||
('normal_flag928', 0x41e657, 'c6862809000000'),
|
||||
('hidden_disable', 0x41e674, '6a008bceff90d0000000'),
|
||||
('hidden_collision_disable', 0x41e680, '6a008bceff9214020000'),
|
||||
('hidden_flag928', 0x41e68a, 'c6862809000001'),
|
||||
('companion_pointer_branch', 0x423c6a, '8b855c09000085c07560'),
|
||||
('companion_ctor', 0x423c98, 'e8738bffff'),
|
||||
('companion_reused_zero_rotation', 0x423cd4, '8d88c00000006a006a006a008b01ff9074010000'),
|
||||
('rotation_set_authored_y', 0x4716df, '898e00010000'),
|
||||
('rotation_set_authored_z', 0x4716e7, '899604010000'),
|
||||
('rotation_set_authored_x', 0x4716f6, '8986fc000000'),
|
||||
('rotation_set_logical', 0x471702, 'ff9030030000'),
|
||||
('rotation_render_sync', 0x47170c, 'ff92e0030000'),
|
||||
('logical_euler_set_x', 0x472428, '898124020000'),
|
||||
('render_sync_bridge', 0x4624f0, 'e94b100100'),
|
||||
('submode_zero_vector_x', 0x41cc73, 'a100824f008981d4060000'),
|
||||
('submode_zero_vector_y', 0x41cc7e, 'a104824f008981d8060000'),
|
||||
('submode_zero_vector_z', 0x41cc89, 'a108824f008981dc060000'),
|
||||
('submode_zero_state', 0x41cc94, '668991a0090000'),
|
||||
('shadow_complete_table', 0x43f6a0, 'c7031c3c4b00'),
|
||||
('shadow_interface_table', 0x43f6ad, 'c74500b8374b00'),
|
||||
('shadow_postload_base', 0x43f814, 'e8a75cffff'),
|
||||
('shadow_authored_size', 0x43f819, '0fbf86220500000fbf9620050000'),
|
||||
('shadow_runtime_size', 0x43f83e, 'd999ac000000d999b0000000'),
|
||||
('shadow_render_flags', 0x43f84a, 'c781b400000002000000c781b800000000000000'),
|
||||
('shadow_authored_db', 0x4354c3, '8d86bc04000050e8f1570300'),
|
||||
('shadow_resource_attach', 0x4354f5, 'ff92c8000000'),
|
||||
('shadow_resource_flags', 0x435503, 'b8010000008d4e24894660894664'),
|
||||
('shadow_fallback_db', 0x435518, '68c0024f00e89e570300'),
|
||||
('shadow_fallback_attach', 0x43553f, '6a0350ff92c8000000'),
|
||||
)
|
||||
|
||||
VTABLES = (
|
||||
('Goddard Init', 0x49f480, 0x28, 0x41e6a0),
|
||||
('Goddard PostLoad', 0x49f480, 0x40c, 0x41e590),
|
||||
('Goddard authored Euler getter', 0x49f480, 0x170, 0x4716a0),
|
||||
('Goddard authored Euler setter', 0x49f480, 0x174, 0x4716d0),
|
||||
('Goddard logical Euler vector setter', 0x49f480, 0x32c, 0x472450),
|
||||
('Goddard logical Euler xyz setter', 0x49f480, 0x330, 0x472420),
|
||||
('Goddard rotation sync', 0x49f480, 0x3e0, 0x4624f0),
|
||||
('Goddard state dispatch', 0x49f920, 0x124, 0x4089b0),
|
||||
('Goddard submode dispatch', 0x49f920, 0x17c, 0x41cc30),
|
||||
('Goddard radius setter', 0x49f480, 0x110, 0x471240),
|
||||
('Goddard live radius setter', 0x49f480, 0x264, 0x471b40),
|
||||
('Goddard collision flag', 0x49f480, 0x214, 0x471a00),
|
||||
('Shadow Init', 0x4b37b8, 0x28, 0x4587f0),
|
||||
('Shadow PostLoad', 0x4b37b8, 0x40c, 0x43f810),
|
||||
('Shadow resource attach', 0x4b3c1c, 0xc8, 0x464430),
|
||||
)
|
||||
|
||||
HIDDEN_CODES = frozenset(('LEV6', 'LEV7', 'LV1C', 'LV1D', 'LV4A', 'LV6A'))
|
||||
|
||||
|
||||
def level_policy(code: str):
|
||||
"""Bounded interpretation of41E5A2..41E692, not execution of original code.
|
||||
|
||||
Hidden path does not assign a new radius/submode; None explicitly means
|
||||
untouched by this local branch, not zero or a preservation proof elsewhere.
|
||||
"""
|
||||
if len(code) != 4 or not code.isascii():
|
||||
raise ValueError('Original level codes have four ASCII characters')
|
||||
hidden = code in HIDDEN_CODES
|
||||
return dict(hidden=hidden, range=3500 if code == 'VR06' else 1500,
|
||||
collision_enabled=not hidden, radius=None if hidden else 130,
|
||||
submode=None if hidden else 0, flag928=int(hidden))
|
||||
|
||||
|
||||
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()
|
||||
sites.append(dict(name=name, va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
|
||||
expected=expected, actual=actual, matches=actual == expected))
|
||||
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))
|
||||
route = []
|
||||
for name in ('level1b.gam', 'VR04.gam', 'level1.gam'):
|
||||
path = find_case(root, 'gam/' + name)
|
||||
raw = path.read_bytes()
|
||||
level = gam.parse(raw)
|
||||
route.append(dict(file=name, code=level.code, sha256=hashlib.sha256(raw).hexdigest(),
|
||||
dog_records=[hex(e.offset) for e in level.entities if e.kind == '3DOG'],
|
||||
shadow_records=[hex(e.offset) for e in level.entities if e.kind == '3SHA'],
|
||||
policy=level_policy(level.code)))
|
||||
return dict(known_binary=digest == EXE_SHA256, sha256=digest,
|
||||
sites=sites, vtables=tables, route=route,
|
||||
scope='Static source bytes/data and bounded interpretation only; no original 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 k in ('sites', 'vtables') for x in result[k]):
|
||||
raise SystemExit(1)
|
||||
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only authored/live body reset and cutscene-preparation provenance."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import struct
|
||||
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va
|
||||
from pe_inspect import PE
|
||||
|
||||
SITES = (
|
||||
('init_acceleration_get', 0x4706EA, 'ff921c010000'),
|
||||
('init_acceleration_set', 0x47070F, 'ff9274020000'),
|
||||
('init_impulse_get', 0x47071E, 'ff9024010000'),
|
||||
('init_impulse_set', 0x470743, 'ff9288020000'),
|
||||
('init_velocity_get', 0x4707BA, 'ff903c010000'),
|
||||
('init_velocity_set', 0x4707DF, 'ff92c0020000'),
|
||||
('authored_acceleration', 0x471294, '8b513c'),
|
||||
('authored_impulse', 0x4712E4, '8b514c'),
|
||||
('authored_velocity', 0x4713D4, '8b517c'),
|
||||
('live_acceleration', 0x471BD8, '81c164010000'),
|
||||
('live_impulse', 0x471CC8, '81c174010000'),
|
||||
('live_velocity', 0x471F78, '81c1a4010000'),
|
||||
('physics_impulse_get', 0x479EBB, 'ff9284020000'),
|
||||
('physics_impulse_apply', 0x479EE5, 'ff97cc020000'),
|
||||
('physics_impulse_clear', 0x479EF2, 'ff928c020000'),
|
||||
('physics_acceleration_get', 0x479F01, 'ff9070020000'),
|
||||
('physics_acceleration_apply', 0x479F4A, 'ff92cc020000'),
|
||||
('physics_velocity_get', 0x479F8D, 'ff92bc020000'),
|
||||
('postload_prepare', 0x42447D, 'ff9010040000'),
|
||||
('jimmy_prepare_base', 0x42AFC3, 'e888f70000'),
|
||||
('prepare_speed_clear', 0x43A758, 'c7860806000000000000'),
|
||||
('prepare_velocity_xyz', 0x43A764, '6a006a006a008bceff90c4020000'),
|
||||
('prepare_stop_sound', 0x43A77E, 'ff9248010000'),
|
||||
('invalid_sound_handle_guard', 0x429A09, '83f8ff7415'),
|
||||
('body_velocity_xyz_write', 0x471F48, '8981a4010000'),
|
||||
('game_control_store', 0x475A44, 'a3e4995000'),
|
||||
)
|
||||
TABLES = (
|
||||
('authored acceleration', 0x4A373C, 0x11C, 0x471290),
|
||||
('live acceleration', 0x4A373C, 0x274, 0x471BD0),
|
||||
('authored impulse', 0x4A373C, 0x124, 0x4712E0),
|
||||
('live impulse', 0x4A373C, 0x288, 0x471CC0),
|
||||
('authored velocity', 0x4A373C, 0x13C, 0x4713D0),
|
||||
('live velocity', 0x4A373C, 0x2C0, 0x471F70),
|
||||
('physics impulse', 0x4A373C, 0x284, 0x471C60),
|
||||
('physics impulse clear', 0x4A373C, 0x28C, 0x471C90),
|
||||
('physics velocity', 0x4A373C, 0x2BC, 0x471F10),
|
||||
('velocity XYZ setter', 0x4A373C, 0x2C4, 0x471F40),
|
||||
('velocity adder', 0x4A373C, 0x2CC, 0x471FA0),
|
||||
('Jimmy preparation', 0x4A373C, 0x410, 0x42AFC0),
|
||||
('Jimmy stop sound', 0x4A3BDC, 0x148, 0x429A00),
|
||||
('lab control assignment', 0x4C3CD0, 0x118, 0x475A40),
|
||||
('tutorial control assignment', 0x4CE910, 0x118, 0x475A40),
|
||||
('outside control assignment', 0x4C5A80, 0x118, 0x475A40),
|
||||
)
|
||||
|
||||
|
||||
def collect(root):
|
||||
pe = PE(find_case(Path(root), 'Neutron.exe'))
|
||||
if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256:
|
||||
raise ValueError('Unsupported original EXE')
|
||||
sites = []
|
||||
for name, va, expected in SITES:
|
||||
actual = read_va(pe, va, len(bytes.fromhex(expected))).hex()
|
||||
if actual != expected:
|
||||
raise ValueError(f'{name} changed at {va:#x}: {actual}')
|
||||
sites.append(dict(name=name, va=hex(va), file_offset=hex(pe.offset(va-pe.base)), bytes=actual))
|
||||
tables = []
|
||||
for name, table, slot, target in TABLES:
|
||||
actual = struct.unpack('<I', read_va(pe, table+slot, 4))[0]
|
||||
if actual != target:
|
||||
raise ValueError(f'{name} callback changed')
|
||||
tables.append(dict(name=name, table=hex(table), slot=hex(slot), target=hex(target),
|
||||
file_offset=hex(pe.offset(table+slot-pe.base))))
|
||||
return dict(sha256=EXE_SHA256, sites=sites, tables=tables,
|
||||
scope='Static body-vector provenance; original component execution is a separate C probe.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli = argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument('original', type=Path)
|
||||
print(json.dumps(collect(cli.parse_args().original), indent=2))
|
||||
@@ -0,0 +1,173 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only evidence for RETURN's selected-gadget cleanup, not a load oracle."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
from dataclasses import dataclass, replace
|
||||
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 = (
|
||||
('return_complete_receiver', 0x457FED, '8d8b40ffffff'),
|
||||
('return_cleanup', 0x457FF7, '8b11ff9278010000'),
|
||||
('return_flag', 0x458014, '889054090000'),
|
||||
('return_preserve_departure', 0x458028, '8890a5090000'),
|
||||
('return_stage', 0x45815C, 'ff9268010000'),
|
||||
('practice_yes_stage', 0x40470D, 'ff9268010000'),
|
||||
('stage_clear_7fc', 0x43B5EE, 'c683fc07000000'),
|
||||
('stage_departure_guard', 0x43B78E, '8a83a509000084c07537'),
|
||||
('stage_request', 0x43B7F1, 'ff9200010000'),
|
||||
('stage_sound_callback', 0x43B7FB, 'ff9248010000'),
|
||||
('stage_sound_stop', 0x429A11, 'e8eaef0200'),
|
||||
('stage_sound_handle_reset', 0x429A19, 'c786440a0000ffffffff'),
|
||||
('menu_constructor_call', 0x42238D, 'e89ef0fdff'),
|
||||
('menu_pointer_store', 0x4223A6, '8985180a0000'),
|
||||
('menu_vtable_install', 0x401464, 'c70614d44800'),
|
||||
('cleanup_zero_register', 0x427FFB, '33db'),
|
||||
('cleanup_menu_pointer', 0x427FFE, '8b8e180a00003bcb7418'),
|
||||
('cleanup_menu_select', 0x42800A, '6a03ff90b0040000'),
|
||||
('cleanup_menu_close', 0x42801A, 'ff92c4040000'),
|
||||
('cleanup_selected_signed', 0x428020, '0fbf0588054f00'),
|
||||
('cleanup_range_guard', 0x428027, '83f8070f87ff070000'),
|
||||
('cleanup_dispatch', 0x428030, 'ff248544884200'),
|
||||
('cleanup_case0_mode_zero', 0x42804F, '66899ec4070000'),
|
||||
('cleanup_case1_mode_one', 0x4286EA, '6689aec4070000'),
|
||||
('cleanup_common_selection_reset', 0x42882F, '5f5e5d66c70588054f00ffff5b81c494000000c3'),
|
||||
('postload_cleanup_only_selected5', 0x42373E, '66833d88054f0005750a8b068bceff9078010000'),
|
||||
('postload_jump_zero', 0x42378B, '6689bd28070000'),
|
||||
('control_cleanup', 0x42AE08, '8b8640ffffff8d8e40ffffffff9078010000'),
|
||||
('fire_owner_support_query', 0x421FDD, '8b11ff9218020000'),
|
||||
('fire_grounded_clear', 0x421FE7, '740ac7860006000000000000'),
|
||||
('fire_tick', 0x421FF3, 'd98600060000d8642418'),
|
||||
('takeoff_timer_clear', 0x438387, '8b86f80700003bc5740689a8c0060000'),
|
||||
('route_lab_range_low', 0x423FBB, '3d4031564c0f8e48040000'),
|
||||
('route_lab_range_high', 0x423FC6, '3d4331564c0f8e31010000'),
|
||||
('route_lab_disable1', 0x424102, '6a016a016a00e863f7fdff'),
|
||||
('route_lab_disable7', 0x42410D, '6a016a076a00e858f7fdff'),
|
||||
('route_vr04_select', 0x42418E, '3d343052560f8fcc0100000f8493010000'),
|
||||
('route_vr01_select', 0x42419F, '3d313052560f8f2a0100000f84ff000000'),
|
||||
('route_vr02_vr03_select', 0x4242D4, '2d323052567432480f852c010000'),
|
||||
('route_vr05_vr08_index', 0x424365, '05cbcfada983f8030f879b000000ff248558454200'),
|
||||
('route_vr04_cleanup', 0x424340, 'ff9278010000'),
|
||||
('route_vr04_enable3', 0x424346, '6a006a036a00e81ff5fdff'),
|
||||
('route_vr04_select3', 0x424358, '6a03ff9074010000'),
|
||||
('route_final_control', 0x424472, 'ff9218010000'),
|
||||
('route_final_player410', 0x42447D, 'ff9010040000'),
|
||||
('select_gadget_index', 0x428DCD, '8d460183f8090f87f40a0000ff2485e8984200'),
|
||||
('select_jetpack_auxitem9', 0x428DE0, '6a0953e868abfdff83c408663d02000f85d80a0000'),
|
||||
('select_jetpack_auxload', 0x428E46, 'ff9068010000e97c0a0000'),
|
||||
('final_stop_player_prepare', 0x42AFC3, 'e888f70000'),
|
||||
('final_stop_action', 0x42AFDE, '6840d04e008bceff9250010000'),
|
||||
('stop_animation_dispatch', 0x43B58A, '8b166a01578bceff92e0000000'),
|
||||
)
|
||||
|
||||
VTABLES = (
|
||||
('Jimmy cleanup', 0x4A3BDC, 0x178, 0x427FF0),
|
||||
('Jimmy stage', 0x4A3BDC, 0x168, 0x43B5A0),
|
||||
('Jimmy stage sound', 0x4A3BDC, 0x148, 0x429A00),
|
||||
('Jimmy control cleanup', 0x4A373C, 0x438, 0x42AE00),
|
||||
('Menu select', 0x48D414, 0x4B0, 0x405FB0),
|
||||
('Menu close', 0x48D414, 0x4C4, 0x406590),
|
||||
('Jimmy gadget select', 0x4A3BDC, 0x174, 0x428D50),
|
||||
('Jimmy final410', 0x4A373C, 0x410, 0x42AFC0),
|
||||
('Jimmy action150', 0x4A3BDC, 0x150, 0x43AFF0),
|
||||
('Jimmy animation E0', 0x4A3BDC, 0xE0, 0x40DD90),
|
||||
('Jimmy current animation', 0x4A3BDC, 0x100, 0x40DF80),
|
||||
)
|
||||
|
||||
CLEANUP_TARGETS = (0x428037, 0x4284FB, 0x42810C, 0x42882F,
|
||||
0x4281B3, 0x4280CC, 0x42871D, 0x4287AC)
|
||||
TUTORIAL_ENABLE_CALLS = (0x4242C7, 0x424325, 0x4242FC, 0x42434C,
|
||||
0x424380, 0x4243B4, 0x4243D6, 0x4243FA)
|
||||
TUTORIAL_CLEANUP_CALLS = (0x4242BB, 0x424319, 0x4242F0, 0x424340,
|
||||
0x424394, 0x4243A8, 0x4243CA, 0x4243EE)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class JetpackCleanupProjection:
|
||||
"""Only the caller-visible selected-jetpack branch, before other load phases.
|
||||
|
||||
This excludes the UI resource callbacks, property stream, Init/PostLoad,
|
||||
ownership handoff and any intervening physics/effect tick. It is an
|
||||
interpretation fixture, not execution of original instructions.
|
||||
"""
|
||||
selected: int
|
||||
movement_mode: int
|
||||
jump_state: int
|
||||
hold_seconds: float
|
||||
fire_seconds: float
|
||||
|
||||
|
||||
def project_jetpack_cleanup(state: JetpackCleanupProjection):
|
||||
if state.selected not in (-1, 3):
|
||||
raise ValueError('Only no-selection and selected-jetpack cleanup are modeled')
|
||||
return replace(state, selected=-1)
|
||||
|
||||
|
||||
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), target=hex(actual),
|
||||
file_offset=hex(pe.offset(table+slot-pe.base)), matches=actual == expected))
|
||||
cleanup = []
|
||||
for selected, expected in enumerate(CLEANUP_TARGETS):
|
||||
va = 0x428844 + 4*selected
|
||||
actual = struct.unpack('<I', read_va(pe, va, 4))[0]
|
||||
cleanup.append(dict(selected=selected, va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
|
||||
target=hex(actual), matches=actual == expected))
|
||||
select = []
|
||||
for selected in (-1, 3):
|
||||
va = 0x4298E8 + 4*(selected+1)
|
||||
actual = struct.unpack('<I', read_va(pe, va, 4))[0]
|
||||
select.append(dict(selected=selected, va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
|
||||
target=hex(actual), matches=actual == 0x428DE0))
|
||||
tutorial = []
|
||||
for item, (va, cleanup_va) in enumerate(zip(TUTORIAL_ENABLE_CALLS, TUTORIAL_CLEANUP_CALLS, strict=True)):
|
||||
arguments = read_va(pe, va-6, 6)
|
||||
target = rel_call_target(pe, va)
|
||||
cleanup_instruction = read_va(pe, cleanup_va, 6)
|
||||
tutorial.append(dict(level=f'VR0{item+1}', item=item, disabled=False,
|
||||
va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
|
||||
arguments=arguments.hex(), target=hex(target), cleanup_va=hex(cleanup_va),
|
||||
matches=arguments == bytes((0x6a, 0, 0x6a, item, 0x6a, 0))
|
||||
and target == 0x403870 and cleanup_instruction in (bytes.fromhex('ff9278010000'), bytes.fromhex('ff9078010000'))))
|
||||
tutorial_table = []
|
||||
for item, expected in enumerate((0x42437A, 0x42439C, 0x4243BE, 0x4243E0)):
|
||||
va = 0x424558 + 4*item
|
||||
actual = struct.unpack('<I', read_va(pe, va, 4))[0]
|
||||
tutorial_table.append(dict(level=f'VR0{item+5}', va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
|
||||
target=hex(actual), matches=actual == expected))
|
||||
return dict(known_binary=digest == EXE_SHA256, sha256=digest, sites=sites,
|
||||
vtables=tables, cleanup_table=cleanup,
|
||||
select_table=select, tutorial_tail=tutorial, tutorial_table=tutorial_table,
|
||||
menu_identity=read_va(pe, 0x4EF05C, 32).split(b'\0')[0].decode('ascii'),
|
||||
final_action=read_va(pe, 0x4ED040, 8).split(b'\0')[0].decode('ascii'),
|
||||
scope='Static immutable-source checks and bounded interpretation; no original runtime execution.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli = argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument('original', type=Path)
|
||||
report = collect(cli.parse_args().original)
|
||||
print(json.dumps(report, indent=2))
|
||||
if not report['known_binary'] or not all(x['matches'] for key in ('sites', 'vtables', 'cleanup_table', 'select_table', 'tutorial_tail', 'tutorial_table') for x in report[key]):
|
||||
raise SystemExit(1)
|
||||
@@ -0,0 +1,141 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only GAM retained-object property-stream callback and descriptor 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
|
||||
from pe_inspect import PE
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'levels'))
|
||||
import gam
|
||||
|
||||
DLL_SHA256 = '3ec41ead011adf56387a6dbd4580e5b5a9721b5f8020c8a56420f42824354943'
|
||||
EXTRACTION_NAME = '??5OMediaStreamOperators@@QAEAAV0@PAVOMediaClassStreamer@@@Z'
|
||||
|
||||
# (name, pointer argument LEA VA, exact LEA, interface offset, wire type,
|
||||
# property-name literal VA, push-name VA). These are Jimmy's actual registered
|
||||
# destinations, not inferred destinations from GAM key spelling.
|
||||
DESCRIPTORS = (
|
||||
('ObjectTag', 0x470403, '8d8ea0030000', 0x3A0, 1, 0x4F6044, 0x47040C),
|
||||
('RotateToDest', 0x470427, '8d460a', 0xA, 2, 0x4F6034, 0x47042D),
|
||||
('ObjectID', 0x47043E, '8d8604040000', 0x404, 6, 0x4F6028, 0x470447),
|
||||
('PositionX', 0x470458, '8d86ec000000', 0xEC, 3, 0x4F601C, 0x470461),
|
||||
('PositionY', 0x470472, '8d86f0000000', 0xF0, 3, 0x4F6010, 0x47047B),
|
||||
('PositionZ', 0x47048C, '8d86f4000000', 0xF4, 3, 0x4F6004, 0x470495),
|
||||
('RotationX', 0x4704A6, '8d86fc000000', 0xFC, 3, 0x4F5FF8, 0x4704AF),
|
||||
('RotationY', 0x4704C0, '8d8600010000', 0x100, 3, 0x4F5FEC, 0x4704C9),
|
||||
('RotationZ', 0x4704DA, '8d8604010000', 0x104, 3, 0x4F5FE0, 0x4704E3),
|
||||
('TaskName', 0x45883F, '8d8630040000', 0x430, 1, 0x4F2870, 0x458848),
|
||||
('Debug', 0x458859, '8d86a4040000', 0x4A4, 6, 0x4F2868, 0x458862),
|
||||
('RequiredLevel', 0x40D3CC, '8d8e78050000', 0x578, 6, 0x4ED294, 0x40D3D5),
|
||||
('ExactLevel', 0x40D3E6, '8d867c050000', 0x57C, 6, 0x4ED288, 0x40D3EF),
|
||||
('RemoveLevel', 0x40D400, '8d8680050000', 0x580, 6, 0x4ED27C, 0x40D409),
|
||||
('HasCollision', 0x40D41A, '8d8684050000', 0x584, 6, 0x4ED26C, 0x40D423),
|
||||
('InitiallyVisible', 0x40D434, '8d8688050000', 0x588, 6, 0x4ED258, 0x40D43D),
|
||||
('CanMove', 0x40D44E, '8d868c050000', 0x58C, 6, 0x4ED250, 0x40D457),
|
||||
('SecondPass', 0x40D468, '8d8690050000', 0x590, 6, 0x4ED244, 0x40D471),
|
||||
('PickupLink', 0x40D482, '8d8695050000', 0x595, 1, 0x4ED238, 0x40D48B),
|
||||
('StartPoint', 0x43784F, '8d8664060000', 0x664, 1, 0x4EFB3C, 0x437858),
|
||||
)
|
||||
|
||||
SITES = (
|
||||
('loader_extraction_import', 0x46E3CB, '8b1d90d14800'),
|
||||
('loader_property_call', 0x46E3FC, '56ffd3'),
|
||||
('jimmy_ctor_property_registration', 0x422245, 'e876080000'),
|
||||
('jimmy_properties_parent', 0x422AD7, 'e8544d0100'),
|
||||
('player_properties_parent', 0x437846, 'e8755bfdff'),
|
||||
('actor_properties_parent', 0x40D3C3, 'e8784f0500'),
|
||||
('shape_properties_parent', 0x462356, 'e8c564ffff'),
|
||||
('task_properties_parent', 0x458836, 'e8757b0100'),
|
||||
('reader_name_read', 0x473B94, 'ff1508d24800'),
|
||||
('reader_lookup', 0x473BA3, 'ff9000040000'),
|
||||
('reader_wire_type_metadata', 0x473BC0, '894704'),
|
||||
('reader_type_jump', 0x473BD0, 'ff2485783e4700'),
|
||||
('reader_string_destination', 0x473BEE, '8b47488bce50ff1508d24800'),
|
||||
('reader_int_destination', 0x473C43, '8b57488b4424348902'),
|
||||
('reader_float_destination', 0x473C5F, '8b47488bce50ff15e4d34800'),
|
||||
('reader_long_destination', 0x473CA7, '8b4f48518bceffd3'),
|
||||
('reader_finish_returns', 0x473E6F, '81c4e8000000c20400'),
|
||||
('lookup_returns_descriptor', 0x473F8F, '8b43085f5e5d5b81c408010000c20400'),
|
||||
('register_destination_pointer', 0x473FFA, '8b4c241c894b48'),
|
||||
)
|
||||
|
||||
FUNCTIONS = (
|
||||
('registered-property reader', 0x473B30, 0x473E78,
|
||||
'31d5e0051c36501b2251d136338650d0f1786238c844aea30916c4f9fc976ffb'),
|
||||
('registered-property lookup', 0x473EB0, 0x473F9F,
|
||||
'ee1435c3eb5d2728f10c70c900560afd459585b392e78c9248017ff49908c211'),
|
||||
)
|
||||
|
||||
|
||||
def site(pe, name, va, expected):
|
||||
actual = read_va(pe, va, len(bytes.fromhex(expected))).hex()
|
||||
return dict(name=name, va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
|
||||
expected=expected, actual=actual, matches=actual == expected)
|
||||
|
||||
|
||||
def collect(root: Path):
|
||||
pe = PE(find_case(root, 'Neutron.exe'))
|
||||
dll = PE(find_case(root, 'OMT2.dll'))
|
||||
exe_hash = hashlib.sha256(pe.data).hexdigest()
|
||||
dll_hash = hashlib.sha256(dll.data).hexdigest()
|
||||
sites = [site(pe, *s) for s in SITES]
|
||||
sites.append(site(dll, 'DLL extraction receiver slot4', 0x10073E00,
|
||||
'568bf18b4c2408568b01ff50048bc65ec20400'))
|
||||
tables = []
|
||||
for name, table in (('Jimmy', 0x4A373C), ('fire', 0x4A3160), ('Goddard', 0x49F480)):
|
||||
for slot, expected in ((4, 0x473B30), (0x400, 0x473EB0)):
|
||||
actual = struct.unpack('<I', read_va(pe, table+slot, 4))[0]
|
||||
tables.append(dict(name=name, table=hex(table), slot=hex(slot), target=hex(actual),
|
||||
file_offset=hex(pe.offset(table+slot-pe.base)), matches=actual == expected))
|
||||
descriptors = []
|
||||
for name, va, instruction, field, wire_type, literal, push in DESCRIPTORS:
|
||||
matches = (read_va(pe, va, len(bytes.fromhex(instruction))).hex() == instruction
|
||||
and read_va(pe, push-3, 2) == bytes((0x6A, wire_type))
|
||||
and read_va(pe, push, 5) == b'\x68'+struct.pack('<I', literal)
|
||||
and read_va(pe, literal, len(name)+1) == name.encode()+b'\0')
|
||||
descriptors.append(dict(name=name, argument_va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
|
||||
interface_offset=hex(field), complete_offset=hex(field+0xC0),
|
||||
wire_type=wire_type, literal_va=hex(literal), matches=matches))
|
||||
functions = []
|
||||
for name, begin, end, expected in FUNCTIONS:
|
||||
actual = hashlib.sha256(read_va(pe, begin, end-begin)).hexdigest()
|
||||
functions.append(dict(name=name, begin=hex(begin), end_exclusive=hex(end),
|
||||
file_offset=hex(pe.offset(begin-pe.base)), sha256=actual,
|
||||
matches=actual == expected))
|
||||
route = []
|
||||
for filename in ('gam/level1b.gam', 'gam/VR04.gam', 'gam/level1.gam'):
|
||||
path = find_case(root, filename)
|
||||
level = gam.parse(path.read_bytes())
|
||||
jimmy = next(e for e in level.entities if e.kind == '3JIM')
|
||||
route.append(dict(file=filename, code=level.code, offset=hex(jimmy.offset),
|
||||
sha256=hashlib.sha256(path.read_bytes()).hexdigest(),
|
||||
player_properties=sorted(jimmy.values()),
|
||||
exact_descriptor_set=set(jimmy.values()) == {d[0] for d in DESCRIPTORS}))
|
||||
imported = next(i for i in pe.imports() if int(i['iat'], 16) == 0x48D190)
|
||||
exported = next(e for e in dll.exports() if e['name'] == EXTRACTION_NAME)
|
||||
return dict(known_binary=exe_hash == EXE_SHA256 and dll_hash == DLL_SHA256,
|
||||
exe_sha256=exe_hash, dll_sha256=dll_hash, sites=sites, vtables=tables,
|
||||
descriptors=descriptors, functions=functions, route=route,
|
||||
extraction_import=imported, extraction_export=exported,
|
||||
import_export_matches=(imported['dll'].lower() == 'omt2.dll'
|
||||
and imported['name'] == EXTRACTION_NAME
|
||||
and int(exported['va'], 16) == 0x10073E00),
|
||||
scope='Static bytes/data only; no original execution or runtime claim.')
|
||||
|
||||
|
||||
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 result['import_export_matches']
|
||||
or not all(x['matches'] for key in ('sites', 'vtables', 'descriptors', 'functions') for x in result[key])
|
||||
or not all(x['exact_descriptor_set'] for x in result['route'])):
|
||||
raise SystemExit(1)
|
||||
@@ -97,7 +97,7 @@ def inside(args):
|
||||
try: processes.append(path.parent.name + ': ' + path.read_bytes().replace(b'\x00', b' ').decode('utf8', 'replace'))
|
||||
except OSError: pass
|
||||
(work/'processes.txt').write_text('\n'.join(processes)+'\n')
|
||||
application_name = 'GamePort.exe' if args.port_smoke else 'omt_shape_probe.exe' if args.asset_probe else args.game
|
||||
application_name = 'GamePort.exe' if args.port_smoke else 'isolated-probe.exe' if args.asset_probe else args.game
|
||||
(work/'capture.json').write_text(json.dumps({'game': application_name, 'captures': captures}, indent=2)+'\n')
|
||||
finally:
|
||||
subprocess.run(['/opt/wine-stable/bin/wineserver', '-k'], timeout=10, check=False)
|
||||
@@ -125,6 +125,7 @@ def main():
|
||||
p.add_argument('--asset-probe', action='store_true', help='Run compiled read-only OMT shape probe inside isolated copy')
|
||||
p.add_argument('--probe-model', default=r'ASE\jimstop.ase')
|
||||
p.add_argument('--probe-executable', type=Path, help='Local probe executable to mount read-only for --asset-probe')
|
||||
p.add_argument('--probe-success', default='VERTICES ', help='Required output marker for an isolated component probe')
|
||||
p.add_argument('--output', type=Path)
|
||||
args = p.parse_args()
|
||||
args.port_smoke = args.port_smoke or args.port_window or args.port_walk or args.port_story or args.port_practice or args.port_cutscene_audio or args.port_jetpack or bool(args.port_regression)
|
||||
@@ -201,8 +202,8 @@ def main():
|
||||
else 'Windows port rendered under Wine; native Windows validation is still required')
|
||||
if args.asset_probe:
|
||||
result = json.loads((work/'capture.json').read_text())
|
||||
if result['captures'][-1]['wineExit'] != 0 or 'VERTICES ' not in (work/'wine.log').read_text():
|
||||
raise SystemExit('OMT asset probe did not complete; inspect wine.log')
|
||||
if result['captures'][-1]['wineExit'] != 0 or args.probe_success not in (work/'wine.log').read_text():
|
||||
raise SystemExit('Original component probe did not complete; inspect wine.log')
|
||||
|
||||
|
||||
if __name__ == '__main__': main()
|
||||
Reference in new issue
Block a user