#!/usr/bin/env python3 """rtdeep2.py — find DSP ctx object via phase-table pointer beacon, then dump window 0x540658 & neighbors.""" import subprocess, time, glob, os, struct, sys import numpy as np RPP = sys.argv[1] if len(sys.argv) > 1 else '/home/m/soothe-bt/dual300.rpp' BEACON = 0x182615608 # VA of phase_table_1024 (static .data) def vst_base(pid): lo = None for line in open(f'/proc/{pid}/maps').read().splitlines(): if 'soothe2' not in line: continue a = int(line.split()[0].split('-')[0], 16) lo = a if lo is None else min(lo, a) return lo def readable_regions(pid): out = [] for line in open(f'/proc/{pid}/maps').read().splitlines(): p = line.split()[0] lo, hi = int(p.split('-')[0], 16), int(p.split('-')[1], 16) if 'vst3' in line: continue # skip module itself out.append((lo, hi)) return out def find_beacon(pid): try: mem = os.open(f'/proc/{pid}/mem', os.O_RDONLY) except Exception: return [] res = [] for lo, hi in readable_regions(pid): sz = (hi - lo) & ~7 if sz <= 0 or sz > 0x200000000: continue try: buf = os.pread(mem, sz, lo) except Exception: continue arr = np.frombuffer(buf, dtype='= -1 and fl.max() <= 2: print(f' ctx={hex(ctx)} WIN@+0x540658 head={[round(float(x),4) for x in fl[:8]]} mid={[round(float(x),4) for x in fl[1024:1032]]}', flush=True) blk = os.pread(mem, 0x8000, ctx + 0x540000) open(f'/tmp/ctx_{ctx:x}_win.bin', 'wb').write(blk) break time.sleep(0.2) os.close(mem) try: proc.wait(timeout=5) except Exception: proc.kill() print('done', flush=True) if __name__ == '__main__': main()