Files
soothe2-re/scripts/probe_mem.py
T

26 lines
1.2 KiB
Python

#!/usr/bin/env python3
import struct, subprocess, time, os, glob
def find_host():
for p in glob.glob('/proc/[0-9]*'):
pid=int(os.path.basename(p))
try:
cmd=open('/proc/%d/cmdline'%pid,'rb').read().replace(b'\0',b' ').decode('utf8','replace')
maps=open('/proc/%d/maps'%pid).read()
except Exception: continue
if 'soothe2' in maps and 'reaper' not in cmd: return pid
return None
subprocess.run("pkill -9 -x reaper; pkill -9 -f '[y]abridge'; sleep 1; "
"rm -rf /run/user/1000/yabridge-soothe2_x64-*", shell=True)
proc=subprocess.Popen(['/usr/bin/reaper','-nosplash','-ignoreerrors','-renderproject','/tmp/opencode/multi.rpp'],
stdout=subprocess.DEVNULL,stderr=subprocess.STDOUT)
t0=time.time();host=None
while time.time()-t0<30 and not host: host=find_host();time.sleep(0.002)
print('host',host)
fd=os.open('/proc/%d/mem'%host,os.O_RDONLY)
for addr,nm in ((0x1824ac210,'vtbl'),(0x182617508,'bk-table'),(0x180140ad0,'stub-code'),(0x180533340,'iir-gen')):
try:
b=os.pread(fd,16,addr)
print('%-10s %x OK: %s' % (nm,addr,b[:8].hex()))
except OSError as e:
print('%-10s %x FAIL: %s' % (nm,addr,e))