#!/usr/bin/env python3 """rtcapture2.py — robust runtime capture for a LONG render (host lives minutes). Dumps sections + raw target buffers at module_base+rva (PE ImageBase=0x180000000). """ import subprocess, time, glob, os, struct, sys RPP = sys.argv[1] if len(sys.argv) > 1 else '/home/m/soothe-bt/dual300.rpp' OUT = sys.argv[2] if len(sys.argv) > 2 else '/tmp/rtcap2.log' RVAS = [0x541134, 0x541258, 0x541278, 0x5413c8, 0x541298, 0x541470, 0x541480, 0x541488, 0x5414b0] def find_pe(pid): mem = os.open(f'/proc/{pid}/mem', os.O_RDONLY) seen = set() for line in open(f'/proc/{pid}/maps').read().splitlines(): lo = int(line.split()[0].split('-')[0], 16) if lo in seen: continue seen.add(lo) try: hdr = os.pread(mem, 0x1000, lo) except Exception: continue if hdr[:2] != b'MZ': continue try: x = struct.unpack('9} vsize={hex(vs):>9} chars={hex(ch)}', flush=True) mem = os.open(f'/proc/{host}/mem', os.O_RDONLY) t3 = time.time() last = 0 while proc.poll() is None and time.time() - t3 < 60: try: d = os.pread(mem, 0x20, base + 0x541258) win = struct.unpack('<8f', d[:32]) if len(d) >= 32 else None except Exception: win = None now = time.time() - t3 if now - last >= 2.0 or win is None: print(f'sample t={now:.1f}s win[0:8]={[round(v,5) for v in win] if win else None}', flush=True) for rva in RVAS: d = os.pread(mem, 128, base + rva) fl = struct.unpack('<%df' % (len(d) // 4), d[:len(d) // 4 * 4]) if len(d) >= 4 else [] print(f' {hex(rva)} floats={[round(v,5) for v in fl[:4]]} raw={d[:24].hex()}', flush=True) last = now time.sleep(0.05) os.close(mem) print('render done', flush=True) proc.wait(timeout=10) print('done', flush=True) if __name__ == '__main__': main()