Recover dynamic box shared-context ownership and kernel winding
This commit is contained in:
1 parent
346d350176
commit
135ff3642a
18 files changed
+640
-1
No files matched your search
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Guard/generate complete mode2 context and static reclip component evidence."""
|
||||
import argparse,hashlib,json,struct
|
||||
from pathlib import Path
|
||||
from collision_dispatch import collect as dispatch_collect,POINTERS
|
||||
from collision_response import header
|
||||
from checkpoint_script_state import find_case,read_va
|
||||
from pe_inspect import PE
|
||||
|
||||
START,END=0x47a5e0,0x47b3dc
|
||||
DIGEST='9bb2c187d12f73a73f4ac2f31e19072d9010f919ce93fb6884e2be35b2fac894'
|
||||
|
||||
|
||||
def collect(original):
|
||||
report=dispatch_collect(original);pe=PE(find_case(Path(original),'Neutron.exe'))
|
||||
body=read_va(pe,START,END-START)
|
||||
if hashlib.sha256(body).hexdigest()!=DIGEST:raise ValueError('Changed mode2 routine/table')
|
||||
report['bodies'].append(dict(name='mode2_box',va=hex(START),file_offset=hex(pe.offset(START-pe.base)),length=END-START,sha256=DIGEST))
|
||||
jumps=struct.unpack('<12I',read_va(pe,0x47b3ac,48))
|
||||
for target in sorted(set((*POINTERS,0x695d45,0x47b3ac,*jumps))):
|
||||
encoded=struct.pack('<I',target)
|
||||
for i in range(len(body)-3):
|
||||
if body[i:i+4]==encoded:report['probe_operands'].append(dict(va=START+i,target=target))
|
||||
report['probe_operands'].sort(key=lambda p:p['va'])
|
||||
report['omt_sha256']=hashlib.sha256(find_case(Path(original),'OMT2.dll').read_bytes()).hexdigest()
|
||||
report['scope']='Full copied mode2 box, static dispatcher and kernel; synthetic actor getters/transform/contact callbacks and grid, not full original scene.'
|
||||
return report
|
||||
|
||||
|
||||
def generate(original,output):
|
||||
original,output=Path(original).resolve(),Path(output).resolve()
|
||||
if output.is_relative_to(original) or original.is_relative_to(output):raise ValueError('Separate output required')
|
||||
if output.exists() and any(p.is_symlink() for p in output.rglob('*')):raise ValueError('Generated output contains symlinks')
|
||||
report=collect(original);output.mkdir(parents=True,exist_ok=True)
|
||||
for name in ('dynamic_context_probe.c','collision_dispatch_probe.c','collision_response_probe.c'):
|
||||
text=Path(__file__).with_name(name).read_text()
|
||||
if name=='collision_dispatch_probe.c':text=text.split('int main(void)')[0]
|
||||
(output/name).write_text(text)
|
||||
(output/'collision_response_relocations.h').write_text(header(report))
|
||||
(output/'source.json').write_text(json.dumps(report,indent=2)+'\n')
|
||||
return dict(guarded_bodies=len(report['bodies']),relocations=len(report['probe_operands']))
|
||||
|
||||
|
||||
def capture(output,directory):
|
||||
output,directory=Path(output),Path(directory);sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
|
||||
source=json.loads((output/'source.json').read_text());metadata=json.loads((directory/'capture.json').read_text())
|
||||
log=(directory/'wine.log').read_text()
|
||||
if metadata['captures'][-1]['wineExit']!=0 or 'DYNAMIC_CONTEXT_COMPLETE' not in log:raise ValueError('Incomplete component execution')
|
||||
for filename,key in [('Neutron.exe','sha256'),('OMT2.dll','omt_sha256')]:
|
||||
if sha(find_case(directory/'game',filename))!=source[key]:raise ValueError('Copied source mismatch')
|
||||
if json.loads((directory/'probe-identity.json').read_text())['sha256']!=sha(output/'probe.exe'):raise ValueError('Probe identity mismatch')
|
||||
cases=[json.loads(l[8:]) for l in log.splitlines() if l.startswith('DYNAMIC ')]
|
||||
if len(cases)!=17 or len({c['name'] for c in cases})!=17:raise ValueError('Missing cases')
|
||||
triangles=[json.loads(l[17:]) for l in log.splitlines() if l.startswith('KERNEL_TRIANGLES ')]
|
||||
if len(triangles)!=1 or len(triangles[0])!=12:raise ValueError('Missing kernel argument capture')
|
||||
for a,b,c,n in triangles[0]:
|
||||
u=[b[i]-a[i] for i in range(3)];v=[c[i]-a[i] for i in range(3)]
|
||||
cross=[u[1]*v[2]-u[2]*v[1],u[2]*v[0]-u[0]*v[2],u[0]*v[1]-u[1]*v[0]]
|
||||
if sum(cross[i]*n[i] for i in range(3))>=0:raise ValueError('Kernel winding/normal relationship changed')
|
||||
files=[directory/'wine.log',directory/'capture.json',directory/'probe-identity.json',output/'source.json',
|
||||
*(output/name for name in ('dynamic_context_probe.c','collision_dispatch_probe.c',
|
||||
'collision_response_probe.c','collision_response_relocations.h','probe.exe'))]
|
||||
result=dict(cases=cases,kernel_triangles=triangles[0],provenance={str(p):sha(p) for p in files},scope=source['scope'])
|
||||
(output/'observations.json').write_text(json.dumps(result,indent=2)+'\n')
|
||||
return dict(cases=len(cases),scope=source['scope'])
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
cli=argparse.ArgumentParser(description=__doc__);cli.add_argument('original',type=Path)
|
||||
cli.add_argument('--output',type=Path);cli.add_argument('--capture',type=Path);args=cli.parse_args()
|
||||
if args.capture and not args.output:cli.error('--capture requires --output')
|
||||
print(json.dumps(capture(args.output,args.capture) if args.capture else generate(args.original,args.output) if args.output else collect(args.original),indent=2))
|
||||
@@ -0,0 +1,85 @@
|
||||
/* Full copied47A5E0 plus static dispatcher/kernel; synthetic actor/box transforms.
|
||||
Global context is seeded deliberately. No original entry point or real actors. */
|
||||
#include "collision_dispatch_probe.c"
|
||||
static unsigned char box_object[0x500],sphere_object[0x500];
|
||||
static uintptr_t box_table[0x440/4],sphere_table[0x440/4];
|
||||
static Vec box_root,low,high,sphere_root,sphere_previous;
|
||||
static float box_radius,sphere_radius;
|
||||
static int geometry,other_mode,inhibit,rotate_box,mutate;
|
||||
static unsigned dynamic_callbacks,static_callbacks,setters;
|
||||
static Vec kernel_arguments[12][4];static unsigned kernel_calls;static unsigned char kernel_prefix[5];
|
||||
static void hook_jump(void*destination,void*target){unsigned char*p=destination;*p=0xe9;int32_t d=(unsigned char*)target-p-5;memcpy(p+1,&d,4);}
|
||||
static unsigned capture_kernel(Vec a,Vec b,Vec c,Vec n,Vec previous,Vec*current,float radius,int edges){
|
||||
if(kernel_calls<12){kernel_arguments[kernel_calls][0]=a;kernel_arguments[kernel_calls][1]=b;kernel_arguments[kernel_calls][2]=c;kernel_arguments[kernel_calls][3]=n;}kernel_calls++;
|
||||
memcpy(AT(0x47bd80),kernel_prefix,5);
|
||||
unsigned result=((Kernel)AT(0x47bd80))(a,b,c,n,previous,current,radius,edges);
|
||||
hook_jump(AT(0x47bd80),capture_kernel);return result;
|
||||
}
|
||||
static float TC get_radius(void*self){return self==box_object?box_radius:sphere_radius;}
|
||||
static int TC get_geometry(void*self){(void)self;return geometry;}
|
||||
static int TC get_mode(void*self){(void)self;return other_mode;}
|
||||
static int TC get_inhibit(void*self){(void)self;return inhibit;}
|
||||
static Vec*TC get_root(void*self,Vec*out){*out=self==box_object?box_root:sphere_root;return out;}
|
||||
static Vec*TC get_previous(void*self,Vec*out){(void)self;*out=sphere_previous;return out;}
|
||||
static Vec*TC get_low(void*self,Vec*out){(void)self;*out=low;return out;}
|
||||
static Vec*TC get_high(void*self,Vec*out){(void)self;*out=high;return out;}
|
||||
static Vec*TC point(void*self,Vec*out,float x,float y,float z){
|
||||
(void)self;*out=rotate_box?(Vec){z+box_root.x,y+box_root.y,-x+box_root.z,1}:
|
||||
(Vec){x+box_root.x,y+box_root.y,z+box_root.z,1};return out;
|
||||
}
|
||||
static void TC set_root(void*self,Vec value){require(self==sphere_object,"root setter owner");sphere_root=value;setters++;}
|
||||
static void TC on_contact(void*self,Vec n,void*p){
|
||||
require(self==sphere_object,"contact owner");(void)n;
|
||||
if(p)static_callbacks++;else dynamic_callbacks++;
|
||||
if(mutate)sphere_root=(Vec){777,888,999,2};
|
||||
}
|
||||
static void reset(void){
|
||||
memset(box_object,0,sizeof(box_object));memset(sphere_object,0,sizeof(sphere_object));
|
||||
memset(box_table,0,sizeof(box_table));memset(sphere_table,0,sizeof(sphere_table));
|
||||
*(void**)box_object=box_table;*(void**)sphere_object=sphere_table;
|
||||
box_table[0x260/4]=sphere_table[0x260/4]=(uintptr_t)get_radius;
|
||||
box_table[0x310/4]=sphere_table[0x310/4]=(uintptr_t)get_root;
|
||||
box_table[0x2e4/4]=(uintptr_t)get_low;box_table[0x2dc/4]=(uintptr_t)get_high;
|
||||
box_table[0x384/4]=(uintptr_t)point;box_table[0x1e0/4]=(uintptr_t)get_inhibit;
|
||||
sphere_table[0x1d0/4]=(uintptr_t)get_geometry;sphere_table[0x178/4]=(uintptr_t)get_mode;
|
||||
sphere_table[0x2f8/4]=(uintptr_t)get_previous;sphere_table[0x314/4]=(uintptr_t)set_root;
|
||||
sphere_table[0x374/4]=sphere_table[0x370/4]=(uintptr_t)on_contact;
|
||||
box_root=(Vec){0,0,0,1};low=(Vec){-50,-50,-10,1};high=(Vec){50,50,10,1};
|
||||
sphere_previous=(Vec){0,0,50,1};sphere_root=(Vec){0,0,15,1};box_radius=40;sphere_radius=10;
|
||||
geometry=1;other_mode=inhibit=rotate_box=mutate=0;dynamic_callbacks=static_callbacks=setters=0;
|
||||
empty_grid();*(Vec*)(polygon[0]+8)=(Vec){0,0,1,0};
|
||||
*(void**)AT(0x695d4c)=polygon[0];*(float*)AT(0x695d5c)=77;*(float*)AT(0x5cfbe0)=88;
|
||||
*(Vec*)AT(0x5cfbe8)=(Vec){111,222,333,1};*(unsigned*)AT(0x695d74)=0;
|
||||
*(unsigned*)AT(0x695d70)=*(unsigned*)AT(0x695d78)=0;
|
||||
*(unsigned char*)AT(0x4f69e5)=1;*(unsigned char*)AT(0x695d46)=*(unsigned char*)AT(0x695d45)=0;
|
||||
}
|
||||
static void query(const char*name){
|
||||
int hit=((int(__cdecl*)(void*,void*))AT(0x47a5e0))(box_object,sphere_object)&255;
|
||||
Vec h=*(Vec*)AT(0x5cfbe8);
|
||||
printf("DYNAMIC {\"name\":\"%s\",\"contact\":%d,\"root\":[%.9g,%.9g,%.9g,%.9g],\"face\":%.9g,\"edge\":%.9g,\"hit\":[%.9g,%.9g,%.9g,%.9g],\"last\":%d,\"dynamicCallbacks\":%u,\"staticCallbacks\":%u,\"setters\":%u,\"passes\":%u,\"mode\":%u}\n",
|
||||
name,hit,sphere_root.x,sphere_root.y,sphere_root.z,sphere_root.w,*(float*)AT(0x695d5c),*(float*)AT(0x5cfbe0),h.x,h.y,h.z,h.w,
|
||||
*(void**)AT(0x695d4c)==polygon[0],dynamic_callbacks,static_callbacks,setters,*(unsigned*)AT(0x695d78),*(unsigned*)AT(0x695d74));
|
||||
}
|
||||
int main(void){
|
||||
setbuf(stdout,NULL);map_copy();
|
||||
memcpy(kernel_prefix,AT(0x47bd80),5);hook_jump(AT(0x47bd80),capture_kernel);
|
||||
reset();query("face_stale_polygon");
|
||||
reset();*(void**)AT(0x695d4c)=NULL;query("face_no_polygon");
|
||||
reset();inhibit=1;query("inhibited");
|
||||
reset();geometry=0;query("geometry_off");
|
||||
reset();sphere_root.z=200;query("broadphase_reject");
|
||||
reset();other_mode=2;query("other_box_overlap");
|
||||
reset();other_mode=2;sphere_root.z=51;query("other_box_reject");
|
||||
reset();sphere_previous.z=100;sphere_root.z=80;query("no_triangle_hit");
|
||||
reset();mutate=1;query("callback_root_overwritten");
|
||||
reset();mutate=inhibit=1;query("inhibited_callback_root_survives");
|
||||
reset();*(unsigned char*)AT(0x4f69e5)=0;query("static_geometry_off_stale_polygon");
|
||||
reset();sphere_object[0x42c]=1;query("forced_static_mode");
|
||||
reset();sphere_root=(Vec){0,45,15,1};sphere_previous=(Vec){0,45,50,1};query("near_top_edge");
|
||||
reset();box_root.x=100;sphere_root.x=sphere_previous.x=100;query("translated_box");
|
||||
reset();rotate_box=1;sphere_root=(Vec){15,0,0,1};sphere_previous=(Vec){50,0,0,1};query("rotated_box");
|
||||
reset();query("chain_first");sphere_previous=sphere_root;sphere_root.z=25;query("chain_away");
|
||||
printf("KERNEL_TRIANGLES [");
|
||||
for(unsigned i=0;i<12;i++){printf("%s[",i?",":"");for(unsigned j=0;j<4;j++){Vec v=kernel_arguments[i][j];printf("%s[%.9g,%.9g,%.9g,%.9g]",j?",":"",v.x,v.y,v.z,v.w);}printf("]");}puts("]");
|
||||
puts("DYNAMIC_CONTEXT_COMPLETE");return 0;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only default Jeep teardown eligibility, distinct from helper retention."""
|
||||
import argparse,hashlib,json,struct
|
||||
from pathlib import Path
|
||||
from checkpoint_script_state import EXE_SHA256,find_case,read_va,rel_call_target
|
||||
from pe_inspect import PE
|
||||
|
||||
SITES=(
|
||||
('Jeep constructor requests deletion predicate true',0x42129a,'6a01'),
|
||||
('stored predicate getter',0x470f30,'8a4111c3'),
|
||||
('stored predicate setter and live dispatch',0x470f47,'884111ff9204020000'),
|
||||
('live predicate getter',0x4719b0,'8a8139010000c3'),
|
||||
('live predicate setter',0x4719c4,'888139010000'),
|
||||
('generic Init stored predicate query',0x4705b3,'ff978c000000'),
|
||||
('generic Init live predicate restore',0x4705bc,'ff9704020000'),
|
||||
('teardown first predicate query',0x46e032,'ff9200020000'),
|
||||
('teardown second predicate query',0x46e06f,'ff9000020000'),
|
||||
('teardown final predicate query',0x46e0ac,'ff9000020000'),
|
||||
('teardown deletion flag',0x46e0ca,'c6460601'),
|
||||
('Jeep UnInitObject bridge',0x4213e0,'e9ab0f0400'),
|
||||
('generic second cleanup conditional',0x458c50,'8a81b004000084c07408'),
|
||||
)
|
||||
|
||||
|
||||
def collect(original):
|
||||
pe=PE(find_case(Path(original),'Neutron.exe'))
|
||||
if hashlib.sha256(pe.data).hexdigest()!=EXE_SHA256:raise ValueError('Unsupported original')
|
||||
sites=[]
|
||||
for name,va,expected in SITES:
|
||||
if read_va(pe,va,len(bytes.fromhex(expected))).hex()!=expected:raise ValueError(name)
|
||||
sites.append(dict(name=name,va=hex(va),file_offset=hex(pe.offset(va-pe.base)),bytes=expected))
|
||||
if rel_call_target(pe,0x4212a8)!=0x470f40:raise ValueError('Jeep constructor predicate target')
|
||||
bindings=[]
|
||||
for slot,target in [(0x8c,0x470f30),(0x200,0x4719b0),(0x204,0x4719c0),(0x20,0x4213e0),(0x34,0x458c50)]:
|
||||
if struct.unpack('<I',read_va(pe,0x4a2aec+slot,4))[0]!=target:raise ValueError('Jeep binding')
|
||||
bindings.append(dict(table='0x4a2aec',slot=hex(slot),target=hex(target),file_offset=hex(pe.offset(0x4a2aec+slot-pe.base))))
|
||||
return dict(source_sha256=EXE_SHA256,sites=sites,bindings=bindings,
|
||||
scope='Default constructor/Init deletion eligibility and re-read boundaries only. Cleanup callbacks, active vehicle mutations, child deletion and complete retained order are not executed here.')
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
cli=argparse.ArgumentParser(description=__doc__);cli.add_argument('original',type=Path)
|
||||
print(json.dumps(collect(cli.parse_args().original),indent=2))
|
||||
Reference in new issue
Block a user