Match Jimmy controller arithmetic and facing to original probes
This commit is contained in:
1 parent
42ea2b8cd5
commit
0e2f426d42
60 files changed
+6027
-48
No files matched your search
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Guard/capture original437F90 jump suffix using the airborne prefix harness."""
|
||||
import argparse,hashlib,json,re,struct,subprocess
|
||||
from pathlib import Path
|
||||
from checkpoint_script_state import EXE_SHA256,find_case,read_va
|
||||
from pe_inspect import PE
|
||||
RANGES=((0x437f90,0x4387d8),(0x4723f0,0x472420),(0x472480,0x472570),(0x472b10,0x472c10))
|
||||
def collect(original):
|
||||
pe=PE(find_case(Path(original),'Neutron.exe'))
|
||||
if hashlib.sha256(pe.data).hexdigest()!=EXE_SHA256:raise ValueError('Unexpected original EXE')
|
||||
report=dict(source_sha256=EXE_SHA256,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])
|
||||
targets={0x48d10c,0x4387ac,0x4387c4,0x4f0608,0x4ef3e8,0x4eca60,0x4f05ec,0x4f05f4}
|
||||
for a,b in RANGES:
|
||||
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))
|
||||
#Jump table bytes are data; reject spurious disassembled absolute operands.
|
||||
targets={t for t in targets if 0x400000<=t<0x699000}
|
||||
report['relocations']=[]
|
||||
for a,b in RANGES:
|
||||
data=read_va(pe,a,b-a)
|
||||
for t in sorted(targets):
|
||||
report['relocations'].extend(dict(va=a+m.start(),target=t) for m in re.finditer(re.escape(struct.pack('<I',t)),data))
|
||||
return report
|
||||
|
||||
def generate(original,output):
|
||||
original=Path(original).resolve();output=Path(output).resolve()
|
||||
if output.is_relative_to(original) or original.is_relative_to(output):raise ValueError('Separate output required')
|
||||
report=collect(original);output.mkdir(parents=True,exist_ok=True)
|
||||
#Reuse only synthetic actor/trig setup; retain the entire original jump suffix.
|
||||
shared=Path(__file__).with_name('jimmy_air_motion_probe.c').read_text().split('static void input(')[0]
|
||||
shared=shared.replace('jump(AT(0x43812a),AT(0x4387a1));','')
|
||||
shared=shared.replace('/* RELOCATIONS */',','.join('{0x%x,0x%x}'%(r['va'],r['target']) for r in report['relocations']))
|
||||
body=Path(__file__).with_name('jimmy_jump_motion_probe.c').read_text()
|
||||
(output/'jimmy_jump_motion_probe.c').write_text(shared+body)
|
||||
(output/'source.json').write_text(json.dumps(report,indent=2)+'\n');return report
|
||||
if __name__=='__main__':
|
||||
p=argparse.ArgumentParser();p.add_argument('original',type=Path);p.add_argument('--generate-probe',type=Path);a=p.parse_args()
|
||||
print(json.dumps(generate(a.original,a.generate_probe) if a.generate_probe else collect(a.original),indent=2))
|
||||
Reference in new issue
Block a user