34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
import struct
|
|
data=open('/tmp/snap_all.bin','rb').read()
|
|
i=0; regs=[]
|
|
while i+16<=len(data):
|
|
lo,sz,=struct.unpack_from('<QQ',data,i)
|
|
regs.append((lo,sz,data[i+16:i+16+sz]))
|
|
i+=16+sz
|
|
def readabs(addr,n):
|
|
for lo,sz,body in regs:
|
|
if lo<=addr<lo+sz and addr-lo+n<=sz:
|
|
return body[addr-lo:addr-lo+n]
|
|
return None
|
|
known={0x2a72600,0x2111140,0x2cd0fc0,0x29f2280,0x29fa300,0x2a02340,0x2a0a3c0,0x2a12400}
|
|
cands=[]
|
|
t0=len(regs)
|
|
for ri,(lo,sz,body) in enumerate(regs):
|
|
if sz<0x541000: continue
|
|
# check every 8-aligned offset for the +0x540658 ptr direct
|
|
for off in range(0, sz-0x540660, 8):
|
|
b=body[off+0x540658:off+0x540660]
|
|
if len(b)<8: break
|
|
p=struct.unpack_from('<Q',b)[0]
|
|
if p in known:
|
|
base=lo+off
|
|
u24=readabs(base+0x24,4); u28=readabs(base+0x28,4)
|
|
f40=readabs(base+0x40,0x20); f58=readabs(base+0x58,0x20)
|
|
print('cand base=0x%x reg%d p=0x%x u24=%s u28=%s 40=%s'%(
|
|
base,ri,p,
|
|
struct.unpack('<f',u24)[0] if u24 else None,
|
|
struct.unpack('<f',u28)[0] if u28 else None,
|
|
[round(x,4) for x in struct.unpack('<4d',f40[:32])] if f40 else None))
|
|
cands.append(base)
|
|
print('total cand',len(cands))
|