#!/usr/bin/env python3 """Guard Scooter frequency ownership and prepare copied positional sound probe.""" import argparse import hashlib import json from pathlib import Path import re import struct import subprocess from checkpoint_script_state import find_case, read_va from checkpoint_camera_audio_ui import EXE_SHA256, DLL_SHA256 from pe_inspect import PE RANGES=(('engine',0x412ed0,0x412f89),('channel_start',0x47d561,0x47d5f6), ('position',0x47d9d0,0x47dc1e)) DLL_RANGE=(0x1003bba0,0x1003bbfa) def collect(original): original=Path(original);exe=PE(find_case(original,'Neutron.exe'));dll=PE(find_case(original,'OMT2.dll')) if hashlib.sha256(exe.data).hexdigest()!=EXE_SHA256 or hashlib.sha256(dll.data).hexdigest()!=DLL_SHA256: raise ValueError('Unexpected source identity') ranges=[dict(kind=k,va=hex(a),file_offset=hex(exe.offset(a-exe.base)),length=b-a, sha256=hashlib.sha256(read_va(exe,a,b-a)).hexdigest()) for k,a,b in RANGES] a,b=DLL_RANGE;ranges.append(dict(kind='dx_frequency',va=hex(a),file_offset=hex(dll.offset(a-dll.base)),length=b-a, sha256=hashlib.sha256(read_va(dll,a,b-a)).hexdigest())) constants={hex(va):struct.unpack('<'+fmt,read_va(exe,va,struct.calcsize(fmt)))[0] for va,fmt in ((0x495310,'d'),(0x495308,'d'),(0x49d5ac,'f'))} if constants!={'0x495310':1/1.9,'0x495308':51.,'0x49d5ac':.75}:raise ValueError('Changed pitch constants') return dict(exe_sha256=EXE_SHA256,dll_sha256=DLL_SHA256,ranges=ranges,constants=constants) TEMPLATE=r''' #define main unused_grappler_main #include "grappler_scalar_probe.c" #undef main typedef struct{float x,y,z,w;}Vec; static unsigned char engine[0x80],channel[0x80],actor[0x100],camera[0x80]; static uintptr_t channels[1],vtable[0x320/4],cvtable[0x30/4]; static int frequency,calls; static Vec TC*root(void*self,Vec*out){(void)self;*out=(Vec){0,0,0,1};return out;} static void TC volume(void*self,int value){(void)self;(void)value;} static void TC pan(void*self,int value){(void)self;(void)value;} static void TC pitch(void*self,unsigned value){(void)self;frequency=value;calls++;} int main(void){ map_source(); const struct{uint32_t va,target;} reloc[]={/* RELOCATIONS */}; for(unsigned i=0;i