Preserve retained Jimmy update order on initial story entry
This commit is contained in:
1 parent
4cd62d3627
commit
ea04210f52
24 files changed
+1209
-22
No files matched your search
@@ -0,0 +1,140 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Guard the original body-context/normal-alignment and visual-sync boundary.
|
||||
|
||||
Reads authoritative files and existing REA Evidence. The generated report is
|
||||
static evidence, not original gameplay or a new component execution.
|
||||
"""
|
||||
import argparse
|
||||
from collections import Counter
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import struct
|
||||
|
||||
from bubble_body import geometry
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va, rel_call_target
|
||||
from jimmy_model_bridge import collect as transform_contract
|
||||
from pe_inspect import PE
|
||||
|
||||
REA_ID = 'ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904'
|
||||
DLL_REA_ID = 'ev_af082632c98b34ccfcedef01466cafa03365e7fbf482496d01a4cda6d2f8f787'
|
||||
LAB_SHA = '5a33d11311fc222631eb8f7384d1863192cb1f55f7e67035caa0ae12fd9892ab'
|
||||
SLOTS = (
|
||||
('Player active constructor alignment setter', 0x4af6c4, 0x1ec, 0x471960),
|
||||
('Jimmy property getter', 0x4a373c, 0xc4, 0x471080),
|
||||
('Jimmy property setter', 0x4a373c, 0xc8, 0x471090),
|
||||
('Jimmy alignment getter', 0x4a373c, 0x1e8, 0x471950),
|
||||
('Jimmy alignment setter', 0x4a373c, 0x1ec, 0x471960),
|
||||
('Jimmy eligible getter', 0x4a373c, 0x210, 0x4719f0),
|
||||
('Jimmy context getter', 0x4a373c, 0x338, 0x472570),
|
||||
('Jimmy current Euler getter', 0x4a373c, 0x328, 0x4723f0),
|
||||
('Jimmy current Euler setter', 0x4a373c, 0x330, 0x472420),
|
||||
('Jimmy position publication', 0x4a373c, 0x3dc, 0x4624b0),
|
||||
('Jimmy Euler publication', 0x4a373c, 0x3e0, 0x4624f0),
|
||||
('Jimmy cached render angle setter', 0x4a373c, 0x3e4, 0x462500),
|
||||
('Lab terrain callback', 0x4c3cd0, 0x130, 0x44e030),
|
||||
('VR04 terrain callback', 0x4ce910, 0x130, 0x44e030),
|
||||
('Outside terrain callback', 0x4c5a80, 0x130, 0x44e030),
|
||||
('Jimmy floor-loop retarget', 0x4a3bdc, 0x1e4, 0x42aec0),
|
||||
)
|
||||
SITES = (
|
||||
('Player constructor clears argument register', 0x43729e, '33db'),
|
||||
('Player installs constructor game table', 0x437332, 'c706c4f64a00'),
|
||||
('player disables alignment property', 0x437426, '538bcee8629c0300'),
|
||||
('property setter mirrors to live field', 0x471090, '8b4424048b1150884110ff92ec010000c20400'),
|
||||
('Init restores live alignment from property', 0x47059c, '8b3e8bceff97c4000000508bceff97ec010000'),
|
||||
('alignment live getter', 0x471950, '8a8138010000c3'),
|
||||
('alignment live setter', 0x471960, '8a442404888138010000c20400'),
|
||||
('body callback precedes alignment gate', 0x46258f, 'ff95300100008b168bceff92e8010000'),
|
||||
('alignment write current XYZ', 0x462630, '8bceff9230030000'),
|
||||
('visual position before angle', 0x473784, 'ff90dc0300008b168bceff92e0030000'),
|
||||
('default terrain sound selector', 0x44e407, 'c7824c05000005000000'),
|
||||
('floor-loop retarget call', 0x44e426, 'ff92e4010000'),
|
||||
)
|
||||
RANGES = (
|
||||
('body-context bridge', 0x462520, 0x462649),
|
||||
('Player constructor alignment initialization', 0x43729e, 0x43743e),
|
||||
('generic property initialization', 0x470540, 0x470610),
|
||||
('property getter and setter', 0x471080, 0x4710a3),
|
||||
('live alignment getter and setter', 0x471950, 0x47196d),
|
||||
('context getter', 0x472570, 0x472577),
|
||||
('current Euler setter', 0x472420, 0x472450),
|
||||
('terrain callback', 0x44e030, 0x44e444),
|
||||
('floor-loop retarget', 0x42aec0, 0x42aef1),
|
||||
('position publication', 0x4624b0, 0x4624f0),
|
||||
('angle publication forwarding and setter', 0x4624f0, 0x46251e),
|
||||
('angle conversion', 0x473540, 0x4735da),
|
||||
('whole-registry transform publication', 0x473770, 0x4737a2),
|
||||
)
|
||||
|
||||
|
||||
def collect(original, rea):
|
||||
original = Path(original)
|
||||
pe = PE(find_case(original, 'Neutron.exe'))
|
||||
if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256:
|
||||
raise ValueError('Unexpected original EXE')
|
||||
evidence = next(r for r in json.loads(Path(rea).read_text())['records']
|
||||
if r['evidence_id'] == REA_ID)
|
||||
if evidence['subject']['digest']['sha256'] != EXE_SHA256:
|
||||
raise ValueError('Wrong REA subject')
|
||||
sites, slots = [], []
|
||||
for name, va, expected in SITES:
|
||||
actual = read_va(pe, va, len(bytes.fromhex(expected))).hex()
|
||||
if actual != expected:
|
||||
raise ValueError(f'Changed {name} at {va:#x}: {actual}')
|
||||
sites.append(dict(name=name, va=hex(va), file_offset=hex(pe.offset(va-pe.base)), bytes=actual))
|
||||
for name, table, slot, expected in SLOTS:
|
||||
actual, = struct.unpack('<I', read_va(pe, table+slot, 4))
|
||||
if actual != expected:
|
||||
raise ValueError(f'Changed {name} binding')
|
||||
slots.append(dict(name=name, table=hex(table), slot=hex(slot), target=hex(actual),
|
||||
file_offset=hex(pe.offset(table+slot-pe.base))))
|
||||
if rel_call_target(pe, 0x437429) != 0x471090:
|
||||
raise ValueError('Changed player property initialization')
|
||||
rows = []
|
||||
for line in evidence['raw_result']['stdout'].splitlines():
|
||||
match = re.match(r'\s*([0-9a-f]+):', line)
|
||||
if match:
|
||||
rows.append((int(match[1], 16), line))
|
||||
extracts = {name: '\n'.join(line for va, line in rows if a <= va < b)+'\n'
|
||||
for name, a, b in RANGES}
|
||||
if any(not value.strip() for value in extracts.values()):
|
||||
raise ValueError('Missing retained REA source range')
|
||||
lab = geometry(original, 'level1b.omt')
|
||||
if lab['sha256'] != LAB_SHA:
|
||||
raise ValueError('Changed lab geometry')
|
||||
ids = Counter(p['texture']['id'] if p['texture'] else None
|
||||
for p in lab['polygons'] if p['registered'])
|
||||
if any(value is not None and not 0 <= value <= 30 for value in ids):
|
||||
raise ValueError('Static lab texture identity outside ordinary terrain branch')
|
||||
transforms = transform_contract(original)
|
||||
return dict(source_sha256=EXE_SHA256, rea_evidence_id=REA_ID,
|
||||
prior_dll_rea_evidence_id=DLL_REA_ID, sites=sites, slots=slots,
|
||||
ranges=[dict(name=name, va=hex(a), file_offset=hex(pe.offset(a-pe.base)),
|
||||
length=b-a, sha256=hashlib.sha256(read_va(pe, a, b-a)).hexdigest())
|
||||
for name, a, b in RANGES], rea_extracts=extracts,
|
||||
static_lab=dict(source='omt/level1b.omt', sha256=lab['sha256'],
|
||||
polygons=lab['polygon_count'], eligible=lab['registered'],
|
||||
texture_counts={str(key) if key is not None else 'missing': value
|
||||
for key, value in ids.items()},
|
||||
shapes=lab['shapes']),
|
||||
prior_transform_contract=transforms,
|
||||
scope='Static known body/context/visual-publication closure, not a whole original frame or new native probe.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('original', type=Path)
|
||||
parser.add_argument('--rea', required=True, type=Path)
|
||||
parser.add_argument('--output', required=True, type=Path)
|
||||
args = parser.parse_args()
|
||||
original, output = args.original.resolve(), args.output.resolve()
|
||||
if output.is_relative_to(original) or original.is_relative_to(output):
|
||||
raise ValueError('Output must be separate from originals')
|
||||
report = collect(original, args.rea)
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
(output/'source.json').write_text(json.dumps(report, indent=2)+'\n')
|
||||
print(json.dumps(dict(sites=len(report['sites']), slots=len(report['slots']),
|
||||
ranges=len(report['ranges']), static_lab=report['static_lab']['texture_counts'],
|
||||
scope=report['scope']), indent=2))
|
||||
@@ -0,0 +1,153 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Guard the original derived Jimmy frame and prepare a bounded caller probe."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import struct
|
||||
import subprocess
|
||||
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va, rel_call_target
|
||||
from pe_inspect import PE
|
||||
|
||||
REA_ID = 'ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904'
|
||||
RANGES = (
|
||||
(0x424600, 0x425110), (0x425120, 0x42516f),
|
||||
(0x425170, 0x425488), (0x425490, 0x4255b4),
|
||||
(0x4255c0, 0x425862), (0x42aac0, 0x42aaf2),
|
||||
(0x409f60, 0x409f80), (0x458960, 0x458985),
|
||||
(0x471a10, 0x471a18), (0x471b40, 0x471b4d),
|
||||
(0x471f10, 0x471f3a), (0x472300, 0x47232a),
|
||||
(0x403a10, 0x403a18), (0x403700, 0x403723),
|
||||
(0x406590, 0x406645),
|
||||
)
|
||||
SLOTS = (
|
||||
(0x4a3bdc, 0x208, 0x424d10), (0x4a3bdc, 0x1a4, 0x425170),
|
||||
(0x4a3bdc, 0x1a8, 0x4252e0), (0x4a3bdc, 0x194, 0x42aac0),
|
||||
(0x4a3bdc, 0x1c8, 0x424e80), (0x4a3bdc, 0x1b4, 0x4255c0),
|
||||
(0x4a3bdc, 0x1b0, 0x425490), (0x4a3bdc, 0x1e0, 0x425120),
|
||||
(0x4a373c, 0x218, 0x458960), (0x4a373c, 0x264, 0x471b40),
|
||||
(0x4a373c, 0x2bc, 0x471f10), (0x4a373c, 0x310, 0x472300),
|
||||
(0x4a373c, 0x314, 0x472360), (0x4a373c, 0x318, 0x472330),
|
||||
(0x4a373c, 0x2c0, 0x471f70), (0x4a3bdc, 0xfc, 0x40dd40),
|
||||
(0x4a3bdc, 0x114, 0x40e4a0), (0x48d414, 0x4a8, 0x403a10),
|
||||
(0x48d414, 0x4c4, 0x406590), (0x48d414, 0x488, 0x403700),
|
||||
(0x48d414, 0x460, 0x4033f0),
|
||||
)
|
||||
SITES = (
|
||||
(0x424721, 'a081814f00', 'menu lock load'),
|
||||
(0x424732, '663d0200', 'menu state2 comparison'),
|
||||
(0x424736, '0f85ca050000', 'locked other state returns'),
|
||||
(0x424744, 'ff9060040000', 'locked state2 menu callback'),
|
||||
(0x424767, 'ff9208020000', 'objective helper before controller'),
|
||||
(0x424bfc, 'ff92a4010000', 'rising helper before controller'),
|
||||
(0x424c08, 'ff90a8010000', 'shadow helper before controller'),
|
||||
(0x424c2b, 'ff9094010000', 'airborne sound cleanup'),
|
||||
(0x424c3f, 'ff92c8010000', 'post-controller Invisible helper'),
|
||||
(0x424c88, 'ff92b4010000', 'post-controller impact helper'),
|
||||
(0x424c94, 'ff90b0010000', 'post-controller root history helper'),
|
||||
(0x425521, 'ff9214030000', 'history root setter'),
|
||||
(0x425142, '668986c4070000', 'ceiling fall mode remains1'),
|
||||
(0x424ea6, '0f8564020000', 'non-Invisible upkeep return'),
|
||||
)
|
||||
|
||||
|
||||
def generate(original, output, rea):
|
||||
original, output = Path(original).resolve(), Path(output).resolve()
|
||||
if output.is_relative_to(original) or original.is_relative_to(output):
|
||||
raise ValueError('Output must be separate from originals')
|
||||
pe = PE(find_case(original, 'Neutron.exe'))
|
||||
if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256:
|
||||
raise ValueError('Unexpected source EXE')
|
||||
record = next(r for r in json.loads(Path(rea).read_text())['records']
|
||||
if r['evidence_id'] == REA_ID)
|
||||
if record['subject']['digest']['sha256'] != EXE_SHA256:
|
||||
raise ValueError('REA subject identity mismatch')
|
||||
for table, slot, target in SLOTS:
|
||||
if struct.unpack('<I', read_va(pe, table+slot, 4))[0] != target:
|
||||
raise ValueError(f'Virtual binding {table:#x}+{slot:#x}')
|
||||
for address, expected, name in SITES:
|
||||
if read_va(pe, address, len(bytes.fromhex(expected))).hex() != expected:
|
||||
raise ValueError(name)
|
||||
if rel_call_target(pe, 0x424c34) != 0x437940:
|
||||
raise ValueError('Controller direct call')
|
||||
rows = []
|
||||
for line in record['raw_result']['stdout'].splitlines():
|
||||
match = re.match(r'\s*([0-9a-f]+):', line)
|
||||
if match:
|
||||
rows.append((int(match[1], 16), line))
|
||||
targets, excerpts = set(), {}
|
||||
for a, b in RANGES:
|
||||
excerpts[hex(a)] = '\n'.join(line for va, line in rows if a <= va < b)+'\n'
|
||||
if not excerpts[hex(a)].strip():
|
||||
raise ValueError('Missing retained REA range')
|
||||
asm = subprocess.run(['objdump', '-d', '-Mintel', f'--start-address={a}',
|
||||
f'--stop-address={b}', str(pe.path)],
|
||||
capture_output=True, text=True, check=True).stdout
|
||||
targets.update(int(v, 16) for v in re.findall(r'ds:0x([0-9a-f]+)', asm))
|
||||
targets.update(int(v, 16) for v in re.findall(r'(?:push|mov\s+\w+,)\s*0x([0-9a-f]+)', asm)
|
||||
if 0x48d000 <= int(v, 16) < 0x699000)
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
source = Path(__file__).with_name('jimmy_derived_frame_probe.c').read_text()
|
||||
source = source.replace('/* RELOCATIONS */', ','.join(hex(v) for v in sorted(targets)))
|
||||
source = source.replace('/* RANGES */', ','.join('{'+hex(a)+','+hex(b)+'}' for a,b in RANGES))
|
||||
(output/'jimmy_derived_frame_probe.c').write_text(source)
|
||||
(output/'grappler_scalar_probe.c').write_text(Path(__file__).with_name('grappler_scalar_probe.c').read_text())
|
||||
result = dict(source_sha256=EXE_SHA256, rea_evidence_id=REA_ID,
|
||||
slots=[dict(table=hex(t), slot=hex(s), target=hex(v), file_offset=hex(pe.offset(t+s-pe.base)))
|
||||
for t,s,v in SLOTS],
|
||||
sites=[dict(va=hex(a), file_offset=hex(pe.offset(a-pe.base)), bytes=e, name=n) for a,e,n in SITES],
|
||||
controller_call=dict(va='0x424c34', target='0x437940'),
|
||||
ranges=[dict(va=hex(a), file_offset=hex(pe.offset(a-pe.base)), length=b-a,
|
||||
sha256=hashlib.sha256(read_va(pe,a,b-a)).hexdigest()) for a,b in RANGES],
|
||||
relocations=[hex(v) for v in sorted(targets)], rea_extracts=excerpts,
|
||||
scope='Derived caller with recorded controller and no-hit queries; no whole physics/gameplay.')
|
||||
(output/'source.json').write_text(json.dumps(result, indent=2)+'\n')
|
||||
return result
|
||||
|
||||
|
||||
def observe(output, capture):
|
||||
output, capture = Path(output), Path(capture)
|
||||
if json.loads((capture/'capture.json').read_text())['captures'][-1]['wineExit'] != 0:
|
||||
raise ValueError('Probe exit was not zero')
|
||||
log = (capture/'wine.log').read_text()
|
||||
if 'JIMMY_DERIVED_FRAME_COMPLETE' not in log or 'DERIVED_FRAME_CASES 50' not in log:
|
||||
raise ValueError('Missing full completion marker')
|
||||
cases = [dict(word.split('=',1) for word in line.split()[1:])
|
||||
for line in log.splitlines() if line.startswith('FRAME_CASE ')]
|
||||
if len(cases) != 50:
|
||||
raise ValueError('Incomplete frame matrix')
|
||||
for row in cases:
|
||||
ticks, lock, state, rising = (int(row[k]) for k in ('ticks','lock','state','rising'))
|
||||
ran = 0 if lock else ticks
|
||||
if int(row['controllers']) != ran or int(row['up']) != (ran if rising else 0) or int(row['down']) != ran:
|
||||
raise ValueError('Controller/query dispatch')
|
||||
if int(row['closed']) != (ticks if lock and state==2 else 0):
|
||||
raise ValueError('Menu transition dispatch')
|
||||
if row['mode'] != '1' or abs(float(row['turn'])-11.666668)>1e-6:
|
||||
raise ValueError('Movement state changed outside controller')
|
||||
if row['current'] != '13,155,17' or row['target'] != '-40,154,-12':
|
||||
raise ValueError('Euler changed outside controller')
|
||||
paths = [output/'probe.exe', output/'jimmy_derived_frame_probe.c', output/'source.json',
|
||||
capture/'wine.log', capture/'capture.json', capture/'game/Neutron.exe']
|
||||
if hashlib.sha256(paths[-1].read_bytes()).hexdigest() != EXE_SHA256:
|
||||
raise ValueError('Executed mapped source copy identity')
|
||||
result = dict(cases=cases, source_sha256=EXE_SHA256, rea_evidence_id=REA_ID,
|
||||
provenance={str(p):hashlib.sha256(p.read_bytes()).hexdigest() for p in paths},
|
||||
scope='50 derived-caller cases; recorded controller, no-hit world queries and UI adapters.')
|
||||
(output.parent/'native-observations.json').write_text(json.dumps(result, indent=2)+'\n')
|
||||
return dict(cases=len(cases), wine_exit=0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('original', type=Path)
|
||||
parser.add_argument('--output', type=Path, required=True)
|
||||
parser.add_argument('--rea', type=Path, required=True)
|
||||
parser.add_argument('--capture', type=Path)
|
||||
args = parser.parse_args()
|
||||
result = generate(args.original, args.output, args.rea)
|
||||
if args.capture:
|
||||
result['observations'] = observe(args.output, args.capture)
|
||||
print(json.dumps({k:v for k,v in result.items() if k != 'rea_extracts'}, indent=2))
|
||||
@@ -0,0 +1,93 @@
|
||||
/* Actual derived424600 and its ordinary pre/post helpers. The controller437940
|
||||
is a recording adapter: this isolates caller-owned writes/gates, not physics.
|
||||
World queries return no hit; UI visibility/menu transitions are adapters. */
|
||||
#define main unused_scalar_main
|
||||
#include "grappler_scalar_probe.c"
|
||||
#undef main
|
||||
|
||||
static uintptr_t game_table[0x450/4], complete_table[0x220/4];
|
||||
static uintptr_t menu_table[0x500/4], helper_table[0x60/4];
|
||||
static unsigned char menu_object[0x600], helper[0x100], current_game[0x600];
|
||||
static int controllers, upward_queries, downward_queries, closed, hidden;
|
||||
#define GF(o) (*(float*)(object+0xc0+(o)))
|
||||
#define MODE (*(short*)(object+0x7c4))
|
||||
|
||||
static void fix(uint32_t a, uint32_t b) {
|
||||
const uint32_t targets[]={/* RELOCATIONS */};
|
||||
for(;a+4<=b;a++) {
|
||||
uint32_t v;memcpy(&v,AT(a),4);
|
||||
for(unsigned i=0;i<sizeof(targets)/sizeof(targets[0]);i++)if(v==targets[i]) {
|
||||
v=(uintptr_t)AT(v);memcpy(AT(a),&v,4);a+=3;break;
|
||||
}
|
||||
}
|
||||
}
|
||||
static LONG CALLBACK exception(EXCEPTION_POINTERS*e) {
|
||||
fprintf(stderr,"PROBE_EXCEPTION source=%lx code=%lx fault=%lx\n",e->ContextRecord->Eip-(uintptr_t)mapped+0x400000,e->ExceptionRecord->ExceptionCode,e->ExceptionRecord->ExceptionInformation[1]);
|
||||
ExitProcess(2);return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
static void TC controller(void*self,float dt) {
|
||||
require(self==object+0xc0&&dt==1.f/60,"controller owner/delta");controllers++;
|
||||
}
|
||||
static void TC close_menu(void*self) {require(self==menu_object,"menu owner");closed++;}
|
||||
static void TC visibility(void*self,int value) {require(self==helper&&value==1,"helper visibility owner");hidden++;}
|
||||
static int no_up_hit(void) {upward_queries++;return 0;}
|
||||
static int no_down_hit(void) {downward_queries++;return 0;}
|
||||
static void draw(void) {require(0,"unexpected HUD draw in ordinary fixture");}
|
||||
|
||||
static void one(int owner,int lock,int state,int supported,int rising,int ticks) {
|
||||
memset(object,0,sizeof(object));memset(menu_object,0,sizeof(menu_object));
|
||||
*(void**)object=complete_table;*(void**)(object+0xc0)=game_table;
|
||||
*(void**)menu_object=menu_table;*(short*)(menu_object+0x4d4)=(short)state;
|
||||
/* Menu layout0 makes actual406590 a no-op; resources are not synthesized. */
|
||||
*(void**)(object+0xa18)=menu_object;
|
||||
*(void**)(object+0xc0+0x1d94)=helper+0xc0;
|
||||
*(void**)helper=helper_table;
|
||||
*(void**)AT(0x509948)=current_game;*(uint32_t*)(current_game+0x490)=0x4c563142;
|
||||
*(void**)AT(0x5099e4)=owner==0?NULL:owner==1?object+0xc0:helper+0xc0;
|
||||
*AT(0x4f8181)=(unsigned char)lock;*AT(0x509a12)=0;*AT(0x4f8210)=0;
|
||||
*(short*)AT(0x4f0588)=-1;F(0x4eefc8)=F(0x4eefd0)=-1;
|
||||
F(0x4f83d4)=100;F(0x4f83c8)=0;F(0x4f8408)=0;
|
||||
*(void**)AT(0x4f7cb0)=*(void**)AT(0x4f8028)=NULL;
|
||||
*(int*)(object+0xc0+0x974)=*(int*)(object+0xc0+0x97c)=-1;
|
||||
*(int*)(object+0x1e08)=-1;
|
||||
object[0xc0+0x13f]=(unsigned char)supported;object[0xc0+0x1d41]=1;
|
||||
GF(0x214)=10;GF(0x218)=20;GF(0x21c)=30;GF(0x220)=1;
|
||||
GF(0x224)=13;GF(0x228)=155;GF(0x22c)=17;GF(0x230)=1;
|
||||
GF(0x274)=-40;GF(0x278)=154;GF(0x27c)=-12;GF(0x280)=1;
|
||||
GF(0x1a8)=rising?100:0;MODE=1;GF(0x614)=11.666668f;object[0xca]=1;
|
||||
unsigned char euler[32];memcpy(euler,object+0x2e4,16);memcpy(euler+16,object+0x334,16);
|
||||
controllers=upward_queries=downward_queries=closed=hidden=0;
|
||||
for(int i=0;i<ticks;i++)((void(TC*)(void*,float))AT(0x424600))(object+0xc0,1.f/60);
|
||||
int ran=lock?0:ticks;
|
||||
require(controllers==ran,"derived controller gate");
|
||||
require(upward_queries==(rising?ran:0)&&downward_queries==ran,"ordinary probe dispatch");
|
||||
require(closed==(lock&&state==2?ticks:0),"menu state2 transition dispatch");
|
||||
require(hidden==(owner==0?ticks:0),"null-control visibility prelude");
|
||||
require(MODE==1&&GF(0x614)==11.666668f,"caller retained movement mode/turn");
|
||||
require(!memcmp(euler,object+0x2e4,16)&&!memcmp(euler+16,object+0x334,16),"caller retained both Euler vectors");
|
||||
printf("FRAME_CASE owner=%d lock=%d state=%d support=%d rising=%d ticks=%d controllers=%d up=%d down=%d closed=%d mode=%d turn=%.9g current=%.9g,%.9g,%.9g target=%.9g,%.9g,%.9g\n",owner,lock,state,supported,rising,ticks,controllers,upward_queries,downward_queries,closed,MODE,GF(0x614),GF(0x224),GF(0x228),GF(0x22c),GF(0x274),GF(0x278),GF(0x27c));
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
setbuf(stdout,NULL);map_source();AddVectoredExceptionHandler(1,exception);
|
||||
const uint32_t ranges[][2]={/* RANGES */};
|
||||
for(unsigned i=0;i<sizeof(ranges)/sizeof(ranges[0]);i++)fix(ranges[i][0],ranges[i][1]);
|
||||
jump(AT(0x437940),controller);jump(AT(0x47c210),no_up_hit);jump(AT(0x47c6e0),no_down_hit);jump(AT(0x468660),draw);
|
||||
game_table[0x218/4]=(uintptr_t)AT(0x458960);
|
||||
game_table[0x264/4]=(uintptr_t)AT(0x471b40);game_table[0x2bc/4]=(uintptr_t)AT(0x471f10);
|
||||
game_table[0x310/4]=(uintptr_t)AT(0x472300);
|
||||
complete_table[0x208/4]=(uintptr_t)AT(0x424d10);
|
||||
complete_table[0x1a4/4]=(uintptr_t)AT(0x425170);complete_table[0x1a8/4]=(uintptr_t)AT(0x4252e0);
|
||||
complete_table[0x194/4]=(uintptr_t)AT(0x42aac0);complete_table[0x1c8/4]=(uintptr_t)AT(0x424e80);
|
||||
complete_table[0x1b4/4]=(uintptr_t)AT(0x4255c0);complete_table[0x1b0/4]=(uintptr_t)AT(0x425490);
|
||||
menu_table[0x4c4/4]=(uintptr_t)AT(0x406590);menu_table[0x4a8/4]=(uintptr_t)AT(0x403a10);
|
||||
menu_table[0x488/4]=(uintptr_t)AT(0x403700);menu_table[0x460/4]=(uintptr_t)close_menu;
|
||||
helper_table[0x58/4]=(uintptr_t)visibility;
|
||||
int cases=0;
|
||||
for(int owner=0;owner<3;owner++)for(int lock=0;lock<2;lock++)for(int state=1;state<3;state++)
|
||||
for(int supported=0;supported<2;supported++)for(int rising=0;rising<2;rising++) {
|
||||
one(owner,lock,state,supported,rising,1);cases++;
|
||||
}
|
||||
for(int owner=0;owner<2;owner++){one(owner,0,1,1,0,180);cases++;}
|
||||
printf("DERIVED_FRAME_CASES %d\n",cases);puts("JIMMY_DERIVED_FRAME_COMPLETE");return 0;
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Guard the original menu background and successful TSK-to-level reuse chain.
|
||||
|
||||
This proves a conditional source lifecycle, not a whole-original Carl capture.
|
||||
Originals remain read-only; output contains source coordinates and evidence.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import struct
|
||||
import sys
|
||||
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va, rel_call_target
|
||||
from pe_inspect import PE
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]/'levels'))
|
||||
import gam
|
||||
|
||||
REA_ID = 'ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904'
|
||||
CALLS = ((0x46a641, 0x46b160), (0x46a660, 0x46a310), (0x46a33d, 0x44d0e0),
|
||||
(0x44d122, 0x459110), (0x404b54, 0x460e70), (0x460ef0, 0x4603f0),
|
||||
(0x4587f3, 0x470540), (0x46e0d9, 0x473710))
|
||||
SITES = (
|
||||
(0x46ba18, '899d08080000', 'initial splash stage0'),
|
||||
(0x46bf07, 'd81da0e54800', 'strict elapsed3s stage gate'),
|
||||
(0x46bfef, 'c7860808000002000000', 'stage1 to stage2'),
|
||||
(0x46bff9, '68004a4f00', 'background level1d.gam'),
|
||||
(0x46c004, 'ff9214010000', 'delayed background request app114'),
|
||||
(0x46dfb6, '66c781fa0700000200', 'two-callback countdown'),
|
||||
(0x46bedf, 'c6864c07000001', 'countdown underflow requests teardown/load'),
|
||||
(0x46c05e, 'ff9204010000', 'consume pending request app104'),
|
||||
(0x46e5c3, 'ff5228', 'every existing nonnull object gets Init28'),
|
||||
(0x4705b3, 'ff978c000000', 'Init reads stored lifetime'),
|
||||
(0x4705bc, 'ff9704020000', 'Init restores live lifetime'),
|
||||
(0x460a50, '8b0de4995000', 'TSK character request requires raw controlled owner'),
|
||||
(0x460a65, 'ff5218', 'TSK owner must accept C3DJIMMY type'),
|
||||
(0x460bd1, 'ff9268010000', 'TSK requests level through player168'),
|
||||
(0x42275a, 'c685c900000001', 'Jimmy reusable game09=1'),
|
||||
)
|
||||
SLOTS = ((0x4d5ea0, 0xc4, 0x46bec0), (0x4d5ea0, 0x114, 0x46dfb0),
|
||||
(0x4d5ea0, 0x104, 0x46dff0), (0x4d5ea0, 0x128, 0x46e570),
|
||||
(0x4d0c0c, 0x28, 0x44d4e0), (0x4c444c, 0x28, 0x44d4e0),
|
||||
(0x4d0c0c, 0x200, 0x4719b0), (0x4c444c, 0x200, 0x4719b0),
|
||||
(0x4d0c0c, 0x420, 0x472970), (0x4c444c, 0x420, 0x472970),
|
||||
(0x4d0c0c, 0x40c, 0x44df30), (0x4c444c, 0x40c, 0x44df30),
|
||||
(0x4a3bdc, 0x168, 0x43b5a0), (0x4a373c, 0x200, 0x4719b0),
|
||||
(0x4a373c, 0x420, 0x472970))
|
||||
RANGES = ((0x46b9e0, 0x46ba2a), (0x46bec0, 0x46c067), (0x46df70, 0x46dfe5),
|
||||
(0x44d0e0, 0x44d161), (0x460e70, 0x460f00), (0x460a50, 0x460bdd),
|
||||
(0x46e570, 0x46e680), (0x46e6a0, 0x46e710), (0x46ff4a, 0x46ff81),
|
||||
(0x4226b5, 0x4226c5), (0x422750, 0x422765), (0x44df30, 0x44df44))
|
||||
|
||||
|
||||
def collect(original, rea):
|
||||
pe = PE(find_case(original, 'Neutron.exe'))
|
||||
if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256:
|
||||
raise ValueError('Unexpected executable')
|
||||
if struct.unpack('<f', read_va(pe, 0x48e5a0, 4))[0] != 3:
|
||||
raise ValueError('Splash duration changed')
|
||||
if read_va(pe, 0x4f4a00, 12) != b'level1d.gam\0':
|
||||
raise ValueError('Background filename changed')
|
||||
if read_va(pe, 0x4ecb20, 9) != b'C3DJIMMY\0':
|
||||
raise ValueError('TSK receiver class changed')
|
||||
for a, b in CALLS:
|
||||
if rel_call_target(pe, a) != b:
|
||||
raise ValueError(f'Call {a:x}')
|
||||
for a, expected, name in SITES:
|
||||
if read_va(pe, a, len(bytes.fromhex(expected))).hex() != expected:
|
||||
raise ValueError(f'{name} at {a:x}')
|
||||
for table, slot, expected in SLOTS:
|
||||
if struct.unpack('<I', read_va(pe, table+slot, 4))[0] != expected:
|
||||
raise ValueError(f'Binding {table:x}+{slot:x}')
|
||||
levels=[]
|
||||
for filename in ('level1d.gam', 'level1b.gam'):
|
||||
path=find_case(original, 'gam/'+filename)
|
||||
level=gam.parse(path.read_bytes())
|
||||
jimmy=next(e for e in level.entities if e.kind=='3JIM')
|
||||
levels.append(dict(file=filename, sha256=hashlib.sha256(path.read_bytes()).hexdigest(),
|
||||
code=level.code, count=len(level.entities), jimmy_offset=jimmy.offset,
|
||||
jimmy_tag=jimmy.values()['ObjectTag']))
|
||||
record=next(r for r in json.loads(Path(rea).read_text())['records'] if r['evidence_id']==REA_ID)
|
||||
if record['subject']['digest']['sha256'] != EXE_SHA256:
|
||||
raise ValueError('REA subject mismatch')
|
||||
rows=[]
|
||||
for line in record['raw_result']['stdout'].splitlines():
|
||||
m=re.match(r'\s*([0-9a-f]+):',line)
|
||||
if m:rows.append((int(m[1],16),line))
|
||||
extracts={hex(a):'\n'.join(l for va,l in rows if a<=va<b)+'\n' for a,b in RANGES}
|
||||
if any(not s.strip() for s in extracts.values()):
|
||||
raise ValueError('Missing retained instructions')
|
||||
return dict(source_sha256=EXE_SHA256, rea_evidence_id=REA_ID, levels=levels,
|
||||
calls=[dict(va=hex(a), target=hex(b), file_offset=hex(pe.offset(a-pe.base)))for a,b in CALLS],
|
||||
sites=[dict(va=hex(a), bytes=e, role=n, file_offset=hex(pe.offset(a-pe.base)))for a,e,n in SITES],
|
||||
slots=[dict(table=hex(t), slot=hex(s), target=hex(v), file_offset=hex(pe.offset(t+s-pe.base)))for t,s,v in SLOTS],
|
||||
ranges=[dict(va=hex(a),length=b-a,file_offset=hex(pe.offset(a-pe.base)),sha256=hashlib.sha256(read_va(pe,a,b-a)).hexdigest())for a,b in RANGES],
|
||||
rea_extracts=extracts,
|
||||
scope='Conditional successful TSK entry reuses existing Jimmy; source lifecycle, not a native Windows/Carl trace.')
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
cli=argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument('original',type=Path)
|
||||
cli.add_argument('--rea',type=Path,required=True)
|
||||
args=cli.parse_args()
|
||||
print(json.dumps(collect(args.original,args.rea),indent=2))
|
||||
@@ -0,0 +1,116 @@
|
||||
/* Diagnose the copied original's black startup under the isolated Wine wrapper.
|
||||
Thread suspension perturbs timing: this is not a gameplay timing reference.
|
||||
No code/actor memory writes; every successfully suspended thread is resumed. */
|
||||
#define main observer_unused_main
|
||||
#include "original_state_observer.c"
|
||||
#undef main
|
||||
#include <tlhelp32.h>
|
||||
|
||||
static void threads(HANDLE process, DWORD pid, unsigned elapsed) {
|
||||
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
|
||||
THREADENTRY32 entry = {0};
|
||||
entry.dwSize = sizeof(entry);
|
||||
if (snapshot == INVALID_HANDLE_VALUE) return;
|
||||
if (Thread32First(snapshot, &entry)) do {
|
||||
if (entry.th32OwnerProcessID != pid) continue;
|
||||
HANDLE thread = OpenThread(THREAD_SUSPEND_RESUME|THREAD_GET_CONTEXT|THREAD_QUERY_INFORMATION,
|
||||
FALSE, entry.th32ThreadID);
|
||||
CONTEXT context = {0};
|
||||
uint32_t stack[64] = {0};
|
||||
int context_ok = 0, stack_ok = 0;
|
||||
if (!thread) continue;
|
||||
DWORD prior = SuspendThread(thread);
|
||||
if (prior != (DWORD)-1) {
|
||||
context.ContextFlags = CONTEXT_CONTROL;
|
||||
context_ok = GetThreadContext(thread, &context);
|
||||
if (context_ok) stack_ok = read_memory(process, context.Esp, stack, sizeof(stack));
|
||||
/* Resume even when context/stack reads fail. Keep prior suspension count. */
|
||||
DWORD resumed = ResumeThread(thread);
|
||||
printf("{\"kind\":\"thread\",\"elapsed_ms\":%u,\"tid\":%lu,\"prior_suspend\":%lu,"
|
||||
"\"resume_ok\":%s,\"context_ok\":%s,\"eip\":%lu,\"esp\":%lu,\"stack_ok\":%s,\"stack\":[",
|
||||
elapsed, entry.th32ThreadID, prior, resumed!=(DWORD)-1?"true":"false",
|
||||
context_ok?"true":"false", context.Eip, context.Esp, stack_ok?"true":"false");
|
||||
for (unsigned i=0; stack_ok && i<sizeof(stack)/sizeof(stack[0]); ++i)
|
||||
printf("%s%lu", i?",":"", (unsigned long)stack[i]);
|
||||
puts("]}");
|
||||
}
|
||||
CloseHandle(thread);
|
||||
} while (Thread32Next(snapshot, &entry));
|
||||
CloseHandle(snapshot);
|
||||
}
|
||||
|
||||
static void modules(DWORD pid) {
|
||||
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pid);
|
||||
MODULEENTRY32 entry = {0};
|
||||
entry.dwSize = sizeof(entry);
|
||||
if (snapshot == INVALID_HANDLE_VALUE) return;
|
||||
if (Module32First(snapshot, &entry)) do {
|
||||
fputs("{\"kind\":\"module\",\"name\":", stdout); json_string(entry.szModule);
|
||||
printf(",\"base\":%lu,\"size\":%lu}\n", (unsigned long)(uintptr_t)entry.modBaseAddr, entry.modBaseSize);
|
||||
} while (Module32Next(snapshot, &entry));
|
||||
CloseHandle(snapshot);
|
||||
}
|
||||
|
||||
static BOOL CALLBACK close_window(HWND window, LPARAM pid) {
|
||||
DWORD actual;
|
||||
GetWindowThreadProcessId(window, &actual);
|
||||
if (actual == (DWORD)pid && IsWindowVisible(window)) PostMessageA(window, WM_CLOSE, 0, 0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char cwd[MAX_PATH], digest[65], command[]="NeutronHDnoCD.exe";
|
||||
STARTUPINFOA start = {0}; PROCESS_INFORMATION child = {0};
|
||||
int acknowledge=0, standard=0;
|
||||
unsigned duration=11;
|
||||
for (int i=1; i<argc; ++i) {
|
||||
if (!strcmp(argv[i],"--acknowledge-repaint")) acknowledge=1;
|
||||
else if (!strcmp(argv[i],"--standard-resolution")) standard=1;
|
||||
else if (!strncmp(argv[i],"--seconds=",10)) {
|
||||
char *end; unsigned long n=strtoul(argv[i]+10,&end,10);
|
||||
if (*end || n<3 || n>60) return 7;
|
||||
duration=(unsigned)n;
|
||||
} else if (strcmp(argv[i],"ASE\\jimstop.ase")) return 7;
|
||||
}
|
||||
const Profile *profile=&profiles[standard?3:2];
|
||||
if (standard) strcpy(command,"NeutronNoCD.exe");
|
||||
setbuf(stdout, NULL);
|
||||
if (!GetCurrentDirectoryA(sizeof(cwd),cwd) || _stricmp(cwd,"Z:\\work\\game")) return 2;
|
||||
HANDLE file = CreateFileA(command,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);
|
||||
if (file == INVALID_HANDLE_VALUE) return 3;
|
||||
if (!sha256(file,digest) || strcmp(digest,profile->sha)) { CloseHandle(file); return 4; }
|
||||
start.cb = sizeof(start);
|
||||
if (!CreateProcessA(command,command,NULL,NULL,FALSE,0,NULL,cwd,&start,&child)) { CloseHandle(file); return 5; }
|
||||
CloseHandle(file); CloseHandle(child.hThread);
|
||||
printf("{\"kind\":\"diagnostic_subject\",\"sha256\":\"%s\",\"pid\":%lu,\"timing_perturbed\":true}\n",digest,child.dwProcessId);
|
||||
DWORD began=GetTickCount(); int identified=0;
|
||||
for (unsigned sample=0; GetTickCount()-began<duration*1000; ++sample) {
|
||||
Sleep(1500);
|
||||
identified=runtime_identity(child.hProcess,profile);
|
||||
if (!identified) continue;
|
||||
Registry state;
|
||||
registry_snapshot(child.hProcess,profile,&state);
|
||||
print_registry(&state,GetTickCount()-began);
|
||||
print_sample(child.hProcess,profile,&state,GetTickCount()-began);
|
||||
uint32_t code=0;
|
||||
if (read_memory(child.hProcess,state.current+0x490,&code,4))
|
||||
printf("{\"kind\":\"level_identity\",\"elapsed_ms\":%lu,\"code\":%lu}\n",GetTickCount()-began,(unsigned long)code);
|
||||
modules(child.dwProcessId);
|
||||
threads(child.hProcess,child.dwProcessId,GetTickCount()-began);
|
||||
if (acknowledge && sample == 1) {
|
||||
HWND window=find_window(child.dwProcessId);
|
||||
RECT rect={0};
|
||||
BOOL pending=window&&GetUpdateRect(window,&rect,FALSE);
|
||||
BOOL acknowledged=window&&ValidateRect(window,NULL);
|
||||
printf("{\"kind\":\"window_repaint_acknowledgement\",\"elapsed_ms\":%lu,\"window\":%lu,"
|
||||
"\"pending\":%s,\"acknowledged\":%s,\"rect\":[%ld,%ld,%ld,%ld]}\n",
|
||||
GetTickCount()-began,(unsigned long)(uintptr_t)window,
|
||||
pending?"true":"false",acknowledged?"true":"false",rect.left,rect.top,rect.right,rect.bottom);
|
||||
}
|
||||
}
|
||||
EnumWindows(close_window,child.dwProcessId);
|
||||
CloseHandle(child.hProcess);
|
||||
if (!identified) return 6;
|
||||
puts("ORIGINAL_STARTUP_DIAGNOSTIC_COMPLETE");
|
||||
return 0;
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
#define CANONICAL_SHA "f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8"
|
||||
#define HD_SHA "b6675b7e7f3fc37512185ddb4d6ce1fbe9a36c8b83f3b4b3ed6979a56db3d2d4"
|
||||
#define HD_NOCD_SHA "8cd5d21997835a40978b8b83e344c97c92217bf6cd6858f7458b76935d64dedb"
|
||||
#define NOCD_SHA "5e1d3bed2d649d16ec62ead02514119a16590380d4d5a6a73103db900a15c62e"
|
||||
|
||||
typedef struct {
|
||||
const char *name, *sha;
|
||||
@@ -28,7 +29,8 @@ typedef struct {
|
||||
static const Profile profiles[] = {
|
||||
{"canonical",CANONICAL_SHA,0x5099e4,0x50999c,0x696030,0x509948,0x4f83e4,0x4f8430,0x4f8198,0x4f8182},
|
||||
{"hd-resolution",HD_SHA,0x5099e4,0x50999c,0x696030,0x509948,0x4f83e4,0x4f8430,0x4f8198,0x4f8182},
|
||||
{"hd-nocd",HD_NOCD_SHA,0x509a04,0x5099bc,0x696050,0x509968,0x4f8404,0x4f8450,0x4f81b8,0x4f81a2}
|
||||
{"hd-nocd",HD_NOCD_SHA,0x509a04,0x5099bc,0x696050,0x509968,0x4f8404,0x4f8450,0x4f81b8,0x4f81a2},
|
||||
{"standard-nocd",NOCD_SHA,0x509a04,0x5099bc,0x696050,0x509968,0x4f8404,0x4f8450,0x4f81b8,0x4f81a2}
|
||||
};
|
||||
|
||||
typedef struct { uint32_t payload, vtable; } Node;
|
||||
|
||||
@@ -58,6 +58,8 @@ def inside(args):
|
||||
frames, mode = 180, ['--smoke-objective-window']
|
||||
elif args.port_regression == 'carl':
|
||||
frames, mode = 60, ['--smoke-carl-cutscene']
|
||||
elif args.port_regression == 'control':
|
||||
frames, mode = 32, ['--smoke-control-phases']
|
||||
elif args.port_jetpack:
|
||||
frames, mode = 300, ['--smoke-jetpack']
|
||||
elif args.port_walk:
|
||||
@@ -126,7 +128,7 @@ def main():
|
||||
p.add_argument('--port-practice', action='store_true', help='Windows port practice modal/input/resize under Wine64')
|
||||
p.add_argument('--port-cutscene-audio', action='store_true', help='Windows port cutscene music lifecycle under Wine64')
|
||||
p.add_argument('--port-jetpack', action='store_true', help='Windows port VR04 powered steering/input/resize under Wine64')
|
||||
p.add_argument('--port-regression', choices=['objectives', 'carl'], help='Windows lab popup or conversation runtime regression under Wine64')
|
||||
p.add_argument('--port-regression', choices=['objectives', 'carl', 'control'], help='Windows lab popup, conversation lock or grounded skip-to-idle regression under Wine64')
|
||||
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-arg', action='append', default=[], help='Additional explicit argument for the generated component probe (repeatable)')
|
||||
|
||||
Reference in new issue
Block a user