Recover sphere response and correct Jimmy ceiling cancellation
This commit is contained in:
1 parent
6a7a53c90d
commit
57dfcc64bb
37 files changed
+1324
-18
No files matched your search
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only retained physical registration and logical-root instruction guards."""
|
||||
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=(
|
||||
('loader_clears_registration',0x46E131,'c6819e04000000'),
|
||||
('jimmy_registration_guard',0x42AB50,'8a819e04000084c07505'),
|
||||
('jimmy_registration_jump',0x42AB5A,'e971780300'),
|
||||
('postload_registration_callback',0x4238B4,'ff502c'),
|
||||
('registration_base_init',0x4623E7,'e82465ffff'),
|
||||
('registration_authored_root',0x462405,'ff926c010000'),
|
||||
('registration_authored_euler',0x462451,'ff9074010000'),
|
||||
('registration_add_body',0x462464,'e8d7750100'),
|
||||
('add_body_zero_authored_vector',0x479A5F,'6a006a006a00ff9250010000'),
|
||||
('add_body_repeats_init',0x479A6F,'ff5028'),
|
||||
('add_body_list',0x479A72,'8b3d3c5d6900'),
|
||||
('add_body_node_bytes',0x479A78,'6a0c'),
|
||||
('add_body_interface_payload',0x479AA9,'8930'),
|
||||
('add_body_count',0x479AAB,'ff05405d6900'),
|
||||
)
|
||||
TABLES=(('Jimmy InitPhysics',0x2C,0x42AB50),
|
||||
('authored root',0x16C,0x471630),
|
||||
('authored Euler',0x174,0x4716D0),
|
||||
('Jimmy Init',0x28,0x437890))
|
||||
|
||||
|
||||
def collect(original):
|
||||
pe=PE(find_case(Path(original),'Neutron.exe'))
|
||||
if hashlib.sha256(pe.data).hexdigest()!=EXE_SHA256: raise ValueError('Unsupported 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,slot,expected in TABLES:
|
||||
actual=struct.unpack('<I',read_va(pe,0x4A373C+slot,4))[0]
|
||||
if actual!=expected: raise ValueError(f'{name} slot changed: {actual:#x}')
|
||||
tables.append(dict(name=name,slot=hex(slot),target=hex(actual)))
|
||||
return dict(sha256=EXE_SHA256,sites=sites,tables=tables,
|
||||
scope='Static registration/reset chain; no original whole-loader execution or inferred collider height.')
|
||||
|
||||
|
||||
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,132 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only shared viewport/default/follow camera handoff evidence."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
from dataclasses import dataclass, replace
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
from pathlib import Path
|
||||
import struct
|
||||
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va
|
||||
from pe_inspect import PE
|
||||
|
||||
SITES = (
|
||||
('default_already_jimmy', 0x447D54, 'a1e499500083c40c3bc6753f'),
|
||||
('default_restore_raw_control', 0x447E27, 'ff9018010000'),
|
||||
('default_local_snap', 0x447E2F, '680000fac3680000fa43'),
|
||||
('default_transform_local', 0x447E42, 'ff9284030000'),
|
||||
('default_current_viewport', 0x447E54, '8b0d509a5000'),
|
||||
('default_current_eye_x', 0x447E5E, 'd94144'),
|
||||
('default_current_eye_y', 0x447E61, 'd94148'),
|
||||
('default_distance_sqrt', 0x447E95, 'd9fa'),
|
||||
('default_strict_threshold', 0x447E9D, 'd81dace54800dfe0f6c441751e'),
|
||||
('default_snap_x', 0x447EAA, 'd95944'),
|
||||
('default_snap_y', 0x447EB6, 'd95848'),
|
||||
('default_snap_z', 0x447EC3, 'd9594c'),
|
||||
('walking_capture_shared_viewport', 0x438EF7, 'a1509a5000'),
|
||||
('walking_previous_x', 0x438F03, 'd94044d99d14070000'),
|
||||
('walking_previous_y', 0x438F17, 'd94148d99d18070000'),
|
||||
('walking_previous_z', 0x438F26, 'd9424cd99d1c070000'),
|
||||
('walking_ray_callback', 0x439714, 'ff966c010000'),
|
||||
('walking_delta_previous_x', 0x439722, 'd8a514070000'),
|
||||
('walking_delta_previous_y', 0x43972C, 'd8a518070000'),
|
||||
('walking_delta_previous_z', 0x439742, 'd8a51c070000'),
|
||||
('walking_normal_x_gain', 0x4397B1, 'd88d54080000'),
|
||||
('walking_normal_y_gain', 0x4397C2, 'd98558080000dc05d02a4a00'),
|
||||
('walking_normal_z_gain', 0x4397E7, 'd88d5c080000'),
|
||||
('walking_add_shared_x', 0x439811, 'd800'),
|
||||
('walking_add_shared_y', 0x43981D, 'd84004d95804'),
|
||||
('walking_add_shared_z', 0x43982A, 'd84008d95808'),
|
||||
('walking_aim_from_previous_x', 0x439834, 'd8a514070000'),
|
||||
('walking_aim_from_previous_y', 0x43984D, 'd8a518070000'),
|
||||
('walking_aim_from_previous_z', 0x43985B, 'd8a51c070000'),
|
||||
('walking_angles_from_vector', 0x439865, 'ff1508d14800'),
|
||||
('walking_angle_wrap', 0x4398A3, '25ff3f0000'),
|
||||
('airborne_capture_shared_viewport', 0x439E33, 'a1509a5000'),
|
||||
('airborne_previous_x', 0x439E40, 'd94044d95c243c'),
|
||||
('airborne_previous_y', 0x439E47, 'd94048d95c2440'),
|
||||
('airborne_previous_z', 0x439E4E, 'd9404c'),
|
||||
('airborne_delta_previous_x', 0x439EF1, 'd864243c'),
|
||||
('airborne_delta_previous_y', 0x439EF9, 'd8642440'),
|
||||
('airborne_delta_previous_z', 0x439F0B, 'd8642444'),
|
||||
('airborne_add_shared_x', 0x43A07D, 'd84044'),
|
||||
('airborne_add_shared_y', 0x43A08F, 'd84004d95804'),
|
||||
('airborne_add_shared_z', 0x43A099, 'd84008d95808'),
|
||||
('airborne_aim_previous_x', 0x43A0A3, 'd8642444'),
|
||||
('airborne_aim_previous_y', 0x43A0BA, 'd8642448'),
|
||||
('airborne_aim_previous_z', 0x43A0C6, 'd864244c'),
|
||||
('airborne_angles_from_vector', 0x43A0CE, 'ff1508d14800'),
|
||||
('mca_shared_eye_x', 0x431677, 'a1509a5000d95844'),
|
||||
('mca_shared_eye_y', 0x431683, '8b0d509a5000'),
|
||||
('mca_shared_eye_z', 0x431694, '8b15509a5000'),
|
||||
('camera_setup_eye_y', 0x437742, 'c781cc07000000004843'),
|
||||
('camera_setup_eye_z', 0x437763, 'c781d00700000000afc3'),
|
||||
)
|
||||
|
||||
TABLES = (
|
||||
('Jimmy walking input/follow', 0x4A3BDC, 0x124, 0x438BC0),
|
||||
('Jimmy airborne input/follow', 0x4A3BDC, 0x128, 0x439900),
|
||||
('Jimmy camera setup', 0x4A3BDC, 0x170, 0x437740),
|
||||
('Jimmy static ray callback', 0x4A3BDC, 0x16C, 0x43B820),
|
||||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CameraProjection:
|
||||
eye: tuple[float, float, float]
|
||||
direction: tuple[float, float, float]
|
||||
|
||||
|
||||
def default_handoff(view: CameraProjection, local_snap_world, already_jimmy: bool):
|
||||
"""Bounded route projection of DEFAULT; orientation is not rewritten here."""
|
||||
distance = math.sqrt(sum((a-b)**2 for a, b in zip(view.eye, local_snap_world, strict=True)))
|
||||
if not already_jimmy and distance > 1000:
|
||||
return replace(view, eye=tuple(local_snap_world))
|
||||
return view
|
||||
|
||||
|
||||
def normal_follow(view: CameraProjection, desired_eye, look_point, dt, ray_gain=1):
|
||||
"""Walking normal-branch interpretation only, not source/x87 execution.
|
||||
|
||||
Desired-eye construction/special fields are intentionally supplied by caller;
|
||||
static ray behavior is separately recovered. Aim uses the pre-update eye.
|
||||
"""
|
||||
gains = (1.6, 1.2, 1.6)
|
||||
eye = tuple(old+(desired-old)*gain*ray_gain*dt
|
||||
for old, desired, gain in zip(view.eye, desired_eye, gains, strict=True))
|
||||
direction = tuple(look-old for look, old in zip(look_point, view.eye, strict=True))
|
||||
return CameraProjection(eye, direction)
|
||||
|
||||
|
||||
def collect(root):
|
||||
pe = PE(find_case(Path(root), 'Neutron.exe'))
|
||||
if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256:
|
||||
raise ValueError('Unsupported original EXE identity')
|
||||
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, expected in TABLES:
|
||||
target, = struct.unpack('<I', read_va(pe, table+slot, 4))
|
||||
if target != expected:
|
||||
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))))
|
||||
threshold, = struct.unpack('<f', read_va(pe, 0x48E5AC, 4))
|
||||
if threshold != 1000:
|
||||
raise ValueError('DEFAULT threshold changed')
|
||||
return dict(sha256=EXE_SHA256, sites=sites, tables=tables,
|
||||
threshold=dict(va='0x48e5ac', file_offset=hex(pe.offset(0x48E5AC-pe.base)), value=threshold),
|
||||
scope='Source-byte evidence plus bounded state projection; no original runtime execution.')
|
||||
|
||||
|
||||
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,170 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only Jimmy ceiling-wrapper evidence and bounded state projection."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
from dataclasses import dataclass, replace
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
from pathlib import Path
|
||||
import struct
|
||||
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va
|
||||
from pe_inspect import PE
|
||||
|
||||
|
||||
SITES = (
|
||||
('wrapper_velocity_before_ceiling', 0x424BE0, 'ff92bc020000d94004d81d14d94800'),
|
||||
('wrapper_only_strictly_upward', 0x424BF1, 'f6c441750c'),
|
||||
('wrapper_ceiling_virtual', 0x424BFC, 'ff92a4010000'),
|
||||
('wrapper_distance_virtual', 0x424C08, 'ff90a8010000'),
|
||||
('wrapper_movement_after_queries', 0x424C34, 'e8072d0100'),
|
||||
('ceiling_logical_root', 0x42519B, 'ff9010030000'),
|
||||
('ceiling_one_sided', 0x4251A3, '6a0083ec10'),
|
||||
('ceiling_root_y_plus150', 0x4251B8, 'd9442438d805343e4a00'),
|
||||
('ceiling_ray_dispatch', 0x4251FC, 'e80f700500'),
|
||||
('ceiling_hit_required', 0x425204, '84c00f84c7000000'),
|
||||
('ceiling_live_velocity_recheck', 0x425215, 'ff92bc020000d94004d81d14d94800'),
|
||||
('ceiling_recheck_strictly_upward', 0x425226, 'f6c4410f85a4000000'),
|
||||
('ceiling_negative_velocity_times_double06', 0x42523E, 'd94004d9e0dc0df8e54800'),
|
||||
('ceiling_minimum_downward85_compare', 0x42524D, 'd81df0e54800'),
|
||||
('ceiling_minimum_downward85_write', 0x425255, 'f6c4417508c744240c0000aac2'),
|
||||
('ceiling_write_velocity_xyz', 0x42528E, 'ff93c4020000'),
|
||||
('ceiling_optional_sound_gate', 0x425294, '66833d88054f0000742b'),
|
||||
('ceiling_sound_elapsed_compare', 0x42529E, 'd9875c1e0000d81d50d94800'),
|
||||
('ceiling_sound47', 0x4252B1, '6a006a2f6affe8c4360300'),
|
||||
('ceiling_sound_elapsed_reset', 0x4252BF, 'c7875c1e000000000000'),
|
||||
('ceiling_cancellation_virtual', 0x4252CD, 'ff92e0010000'),
|
||||
('cancellation_only_mode1', 0x425123, 'b801000000663986c4070000753c'),
|
||||
('cancellation_jump_zero_mode1', 0x425139, '66c786e80700000000668986c4070000'),
|
||||
('cancellation_fall_request', 0x425134, '68e8f34e00'),
|
||||
('cancellation_owned_effect', 0x42514F, '8b86f807000085c0740a'),
|
||||
('cancellation_effect_zero', 0x425159, 'c780c006000000000000'),
|
||||
('cancellation_cleanup_virtual', 0x425167, 'ff9040010000'),
|
||||
('cleanup_base_noop', 0x429913, 'e858900400'),
|
||||
('cleanup_class_flags', 0x429918, 'c686641e000000c786681e000000000000'),
|
||||
('cleanup_saved_sound', 0x429941, '8b863c0a000083f8ff7415'),
|
||||
('cleanup_saved_sound_stop', 0x42994C, '6a0050e8acf00200'),
|
||||
('cleanup_saved_sound_invalid', 0x429957, 'c7863c0a0000ffffffff'),
|
||||
('distance_global_bypass', 0x4252E3, 'a010824f00'),
|
||||
('distance_root_minus2500', 0x425335, 'd9442438d825e80c4a00'),
|
||||
('distance_nearest_ray', 0x425379, 'e862730500'),
|
||||
('distance_shadow_pointer_required', 0x4253AC, '8b8f2c0a000085c9'),
|
||||
('distance_cache_store', 0x42547C, 'd99f6c080000'),
|
||||
)
|
||||
|
||||
TABLES = (
|
||||
('complete_ceiling_query', 0x4A3BDC, 0x1A4, 0x425170),
|
||||
('complete_distance_query', 0x4A3BDC, 0x1A8, 0x4252E0),
|
||||
('complete_ceiling_cancel', 0x4A3BDC, 0x1E0, 0x425120),
|
||||
('complete_animation_request', 0x4A3BDC, 0xE0, 0x40DD90),
|
||||
('complete_gadget_stop', 0x4A3BDC, 0x140, 0x429910),
|
||||
('interface_velocity_get', 0x4A373C, 0x2BC, 0x471F10),
|
||||
('interface_velocity_set', 0x4A373C, 0x2C4, 0x471F40),
|
||||
('interface_root_get', 0x4A373C, 0x310, 0x472300),
|
||||
)
|
||||
|
||||
CONSTANTS = (
|
||||
('root_upward_span', 0x4A3E34, 'f', 150.0),
|
||||
('bounce_coefficient', 0x48E5F8, 'd', 0.6),
|
||||
('maximum_vertical_response', 0x48E5F0, 'f', -85.0),
|
||||
('upward_threshold', 0x48D914, 'f', 0.0),
|
||||
('sound_elapsed_threshold', 0x48D950, 'f', 5.0),
|
||||
('shadow_downward_span', 0x4A0CE8, 'f', 2500.0),
|
||||
)
|
||||
|
||||
BODY_HASHES = (
|
||||
('ceiling_cancellation', 0x425120, 0x4F,
|
||||
'170f31c1f88d09d9f9d4a5cfa69c2d34a77a477ca63bcbf5efe4d0409f6c61d2'),
|
||||
('ceiling_query_response', 0x425170, 0x16C,
|
||||
'8a2555793945f3b0eacecfefd8ffcd838c9820250b109d6120bf0a86ad32c153'),
|
||||
('shadow_distance_refresh', 0x4252E0, 0x1AB,
|
||||
'28482ee15afc15af43f344656b7262b1d61d68c667ebf5125bfb20b20328dc7d'),
|
||||
('derived_cleanup', 0x429910, 0x53,
|
||||
'eca3f8629cdc54c87fe4cb4e7b1f272099d10009a230711d2c1cbcf5fc37d382'),
|
||||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CeilingState:
|
||||
velocity: tuple[float, float, float]
|
||||
mode: int
|
||||
jump: int
|
||||
fire_remaining: float | None
|
||||
hold: float = 0
|
||||
extra_acceleration: float = 0
|
||||
queued_impulse: float = 0
|
||||
|
||||
|
||||
def upward_segment(root):
|
||||
"""425170 root to root+150Y, not a radius/capsule-top segment."""
|
||||
if len(root) != 3 or not all(math.isfinite(v) for v in root):
|
||||
raise ValueError('Finite XYZ root required')
|
||||
return tuple(root), (root[0], root[1] + 150, root[2])
|
||||
|
||||
|
||||
def ceiling_projection(state, hit):
|
||||
"""Bounded response/cancel projection, not original execution or full wrapper.
|
||||
|
||||
hit is supplied by the separately recovered 47C210 static predicate. No
|
||||
ownership input exists. Class sound/gadget cleanup callbacks are events only;
|
||||
Python is not an x87 arithmetic oracle.
|
||||
"""
|
||||
if len(state.velocity) != 3 or not all(math.isfinite(v) for v in state.velocity):
|
||||
raise ValueError('Finite velocity required')
|
||||
if state.velocity[1] <= 0:
|
||||
return state, ()
|
||||
if not hit:
|
||||
return state, ('query47C210',)
|
||||
# Final store is float32; coefficient is the original stored double.
|
||||
reflected = struct.unpack('<f', struct.pack('<f', min(-state.velocity[1] * 0.6, -85.0)))[0]
|
||||
state = replace(state, velocity=(state.velocity[0], reflected, state.velocity[2]))
|
||||
events = ('query47C210', 'velocity2C4', 'cancel1E0')
|
||||
if state.mode == 1:
|
||||
state = replace(state, jump=0,
|
||||
fire_remaining=0 if state.fire_remaining is not None else None)
|
||||
events += ('FALL', 'cleanup140')
|
||||
return state, events
|
||||
|
||||
|
||||
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'Changed instruction {name} 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:
|
||||
if struct.unpack('<I', read_va(pe, table+slot, 4))[0] != target:
|
||||
raise ValueError(f'Changed virtual target {name}')
|
||||
tables.append(dict(name=name, table=hex(table), slot=hex(slot), target=hex(target),
|
||||
file_offset=hex(pe.offset(table+slot-pe.base))))
|
||||
constants = []
|
||||
for name, va, fmt, expected in CONSTANTS:
|
||||
value = struct.unpack('<'+fmt, read_va(pe, va, struct.calcsize(fmt)))[0]
|
||||
if value != expected:
|
||||
raise ValueError(f'Changed constant {name}')
|
||||
constants.append(dict(name=name, va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
|
||||
format=fmt, value=value))
|
||||
bodies = []
|
||||
for name, va, length, expected in BODY_HASHES:
|
||||
actual = hashlib.sha256(read_va(pe, va, length)).hexdigest()
|
||||
if actual != expected:
|
||||
raise ValueError(f'Changed body {name}')
|
||||
bodies.append(dict(name=name, va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
|
||||
length=length, sha256=actual))
|
||||
if read_va(pe, 0x4EF3E8, 5) != b'FALL\0':
|
||||
raise ValueError('Changed FALL animation identity')
|
||||
return dict(sha256=EXE_SHA256, sites=sites, tables=tables, constants=constants, bodies=bodies,
|
||||
scope='Static source bytes and explicit projection; no original runtime or complete solver.')
|
||||
|
||||
|
||||
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,77 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Guard original collision callgraph and emit explicit probe relocation operands.
|
||||
|
||||
No original code is executed here. Relocations apply only to generated in-memory
|
||||
copies in collision_response_probe.c; original files remain unchanged.
|
||||
"""
|
||||
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
|
||||
|
||||
BODIES = (
|
||||
('vector_copy', 0x409F60, 0x409F7F, '488dbddb9d91612e9d16686d3d0c8a7fbc851b9899b24fcd7433007989a8b2ad'),
|
||||
('segment_build', 0x469530, 0x4695AA, '87676d756eda5ce058c2210556bd57fbd54dd72cbede346725e653c2bc5ad66c'),
|
||||
('nearest_triangle_edge', 0x4695B0, 0x469880, '4b358d6ba956a9629bf2e814174c757a3930d891c0b4cbab9b089623dcef6a2a'),
|
||||
('nearest_segment_point', 0x469880, 0x469A05, '040c9805125fe32871183be8c82b9c909e34ce165711405d97af57f3da711965'),
|
||||
('triangle_ray', 0x469B70, 0x469E19, '41bca9254c9ba5c57882cf2bc975a350d266a3ac2b5b9965cad11e585bb4faa0'),
|
||||
('sphere_response', 0x47BD80, 0x47C204, '8f0892a12197cdd142aecacce636ac7de6c7a061516ab16137909b5b17cff156'),
|
||||
)
|
||||
|
||||
# Absolute memory operands in the six bounded functions, cross-checked against
|
||||
# objdump and REA. Debug calls are disabled by695D44; no other imports are bound.
|
||||
TARGETS = (0x48D104, 0x48D914, 0x48D924, 0x48D974, 0x49B1F8, 0x4A3148,
|
||||
0x4D5E40, 0x4D5E44, 0x5CFBE0, 0x5CFBE8, 0x5CFBEC, 0x5CFBF0,
|
||||
0x5CFBF4, 0x695D44, 0x695D5C, 0x695D74)
|
||||
|
||||
|
||||
def collect(original):
|
||||
pe = PE(find_case(Path(original), 'Neutron.exe'))
|
||||
if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256:
|
||||
raise ValueError('Unsupported original EXE')
|
||||
bodies, operands = [], []
|
||||
for name, start, end, digest in BODIES:
|
||||
body = read_va(pe, start, end-start)
|
||||
if hashlib.sha256(body).hexdigest() != digest:
|
||||
raise ValueError(f'Changed function {name}')
|
||||
bodies.append(dict(name=name, va=hex(start), file_offset=hex(pe.offset(start-pe.base)),
|
||||
length=end-start, sha256=digest))
|
||||
for target in TARGETS:
|
||||
encoded = struct.pack('<I', target)
|
||||
for index in range(len(body)-3):
|
||||
if body[index:index+4] == encoded:
|
||||
operands.append(dict(va=start+index, target=target))
|
||||
return dict(sha256=EXE_SHA256, bodies=bodies, probe_operands=sorted(operands, key=lambda x:x['va']),
|
||||
constants={hex(va): struct.unpack('<f',read_va(pe,va,4))[0]
|
||||
for va in (0x48D974,0x49B1F8,0x4A3148)},
|
||||
scope='Static callgraph guard; generated probe relocations are synthetic fixture setup, not source loader behavior.')
|
||||
|
||||
|
||||
def header(report):
|
||||
lines = ['/* Generated guarded absolute operands; never patch on-disk originals. */',
|
||||
'static const struct { unsigned va, target; } relocations[] = {']
|
||||
lines += [f' {{0x{p["va"]:x}, 0x{p["target"]:x}}},' for p in report['probe_operands']]
|
||||
return '\n'.join(lines+['};',''])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli = argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument('original',type=Path)
|
||||
cli.add_argument('--probe-header',type=Path)
|
||||
cli.add_argument('--target-copy',type=Path)
|
||||
args=cli.parse_args()
|
||||
report=collect(args.original)
|
||||
if args.target_copy:
|
||||
target=args.target_copy.resolve(strict=True)
|
||||
if target.is_relative_to(args.original.resolve()): cli.error('Probe target must be a generated copy')
|
||||
if hashlib.sha256(target.read_bytes()).hexdigest()!=report['sha256']:
|
||||
cli.error('Probe copy does not match authoritative EXE')
|
||||
if args.probe_header:
|
||||
output=args.probe_header.resolve()
|
||||
if output.is_relative_to(args.original.resolve()): cli.error('Generated header must be outside originals')
|
||||
output.write_text(header(report))
|
||||
print(json.dumps(report,indent=2))
|
||||
@@ -0,0 +1,80 @@
|
||||
/* Isolated original 47BD80 component probe. Run only through reference_capture
|
||||
* against a generated copied installation. No game entry point or EXE import
|
||||
* initialization is executed. Explicit guarded absolute operands are rebased in
|
||||
* memory; only quick_magnitude's IAT entry is bound to the copied OMT DLL. */
|
||||
#include <windows.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
typedef struct { float x,y,z,w; } Vec;
|
||||
typedef unsigned (__cdecl *Kernel)(Vec,Vec,Vec,Vec,Vec,Vec*,float,int);
|
||||
static unsigned char *mapped;
|
||||
#define AT(va) (mapped+(va)-0x400000)
|
||||
#include "collision_response_relocations.h"
|
||||
static void require(int ok,const char *message) {
|
||||
if(!ok){fprintf(stderr,"FAIL %s\n",message);exit(2);}
|
||||
}
|
||||
static void map_copy(void) {
|
||||
unsigned char *image=VirtualAlloc(NULL,0x299000,
|
||||
MEM_COMMIT|MEM_RESERVE,PAGE_EXECUTE_READWRITE);
|
||||
require(image!=NULL,"component map");mapped=image;
|
||||
FILE *f=fopen("Neutron.exe","rb");require(f!=NULL,"copied EXE");
|
||||
fseek(f,0,SEEK_END);long size=ftell(f);rewind(f);
|
||||
require(size>64&&size<16000000,"bounded EXE");
|
||||
unsigned char *data=malloc(size);require(data!=NULL,"file allocation");
|
||||
require(fread(data,1,size,f)==(size_t)size,"read EXE");fclose(f);
|
||||
require(*(uint16_t*)data==IMAGE_DOS_SIGNATURE,"DOS header");
|
||||
uint32_t offset=*(uint32_t*)(data+0x3c);
|
||||
require(offset<(uint32_t)size-sizeof(IMAGE_NT_HEADERS32),"NT header bounds");
|
||||
IMAGE_NT_HEADERS32 *nt=(void*)(data+offset);
|
||||
require(nt->Signature==IMAGE_NT_SIGNATURE&&nt->FileHeader.Machine==IMAGE_FILE_MACHINE_I386
|
||||
&&nt->OptionalHeader.ImageBase==0x400000&&nt->OptionalHeader.SizeOfImage==0x299000,"PE32 layout");
|
||||
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);
|
||||
for(unsigned i=0;i<sizeof(relocations)/sizeof(relocations[0]);i++) {
|
||||
uint32_t *operand=(void*)AT(relocations[i].va);
|
||||
require(*operand==relocations[i].target,"guarded relocation operand");
|
||||
*operand=(uint32_t)AT(relocations[i].target);
|
||||
}
|
||||
HMODULE omt=LoadLibraryA("Z:\\work\\game\\OMT2.dll");require(omt!=NULL,"copied OMT");
|
||||
FARPROC magnitude=GetProcAddress(omt,"?quick_magnitude@OMedia3DVector@@QBEMXZ");
|
||||
require(magnitude!=NULL,"quick magnitude");
|
||||
*(FARPROC*)AT(0x48d104)=magnitude;
|
||||
*(unsigned char*)AT(0x695d44)=0; // Skip optional debug drawing.
|
||||
}
|
||||
static void sample(const char *name,Vec a,Vec b,Vec c,Vec n,Vec previous,Vec current,
|
||||
float radius,int edge,int mode) {
|
||||
*(float*)AT(0x695d5c)=-1;*(float*)AT(0x5cfbe0)=radius;*(int*)AT(0x695d74)=mode;
|
||||
memset(AT(0x5cfbe8),0,16);
|
||||
unsigned contact=((Kernel)AT(0x47bd80))(a,b,c,n,previous,¤t,radius,edge)&0xff;
|
||||
Vec hit=*(Vec*)AT(0x5cfbe8);
|
||||
printf("CASE %s contact=%u root=%.9g,%.9g,%.9g hit=%.9g,%.9g,%.9g face=%.9g edge=%.9g\n",
|
||||
name,contact,current.x,current.y,current.z,hit.x,hit.y,hit.z,*(float*)AT(0x695d5c),*(float*)AT(0x5cfbe0));
|
||||
require(isfinite(current.x)&&isfinite(current.y)&&isfinite(current.z),"finite result");
|
||||
}
|
||||
int main(void) {
|
||||
setbuf(stdout,NULL);map_copy();
|
||||
Vec a={-100,-100,0,1},b={-100,100,0,1},c={100,100,0,1},n={0,0,1,0};
|
||||
sample("wall_face",a,b,c,n,(Vec){0,20,20,1},(Vec){0,20,5,1},10,1,1);
|
||||
sample("wall_pass",a,b,c,n,(Vec){0,20,20,1},(Vec){0,20,-20,1},10,1,1);
|
||||
sample("wall_depart",a,b,c,n,(Vec){0,20,5,1},(Vec){0,20,20,1},10,1,1);
|
||||
sample("wall_side_edge",a,b,c,n,(Vec){105,100,20,1},(Vec){105,100,5,1},10,1,1);
|
||||
sample("wall_edge_disabled",a,b,c,n,(Vec){105,100,20,1},(Vec){105,100,5,1},10,0,1);
|
||||
sample("wall_edge_below",a,b,c,n,(Vec){0,-110,20,1},(Vec){0,-110,5,1},10,1,0);
|
||||
sample("wall_edge_mode1",a,b,c,n,(Vec){0,-110,20,1},(Vec){0,-110,5,1},10,1,1);
|
||||
sample("upper_edge_mode0",a,b,c,n,(Vec){105,105,20,1},(Vec){105,105,5,1},10,1,0);
|
||||
sample("upper_edge_mode1",a,b,c,n,(Vec){105,105,20,1},(Vec){105,105,5,1},10,1,1);
|
||||
sample("ceiling",(Vec){-100,100,-100,1},(Vec){100,100,100,1},(Vec){100,100,-100,1},
|
||||
(Vec){0,-1,0,0},(Vec){0,80,0,1},(Vec){0,95,0,1},10,1,1);
|
||||
puts("COLLISION_COMPONENT_COMPLETE: isolated original kernel; synthetic geometry, no whole-game runtime");
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user