#!/usr/bin/env python3
"""Search the ON-DISK original Driver for the bind streams (0x40 <name> NUL)."""
import sys

sys.stdout.reconfigure(encoding='utf-8')
d = open(r'E:\ios\work319\patch_src_orig\Driver', 'rb').read()
print('size 0x%x' % len(d))

names = [b'\x40_objc_msgSend\x00', b'\x40_objc_retain\x00',
         b'\x40_NSClassFromString\x00', b'\x40_OBJC_CLASS_$_', b'\x40$s']
for nm in names:
    offs = []
    i = d.find(nm)
    while i >= 0 and len(offs) < 6:
        offs.append(i)
        i = d.find(nm, i + 1)
    print(nm[1:26].decode('latin1'), '->', [hex(o) for o in offs])

# memory bind stream found at mem 0x20df928 -> file 0x20df928 - 0x64000 = 0x207b928
for fo in (0x207b928, 0x2093ff7):
    print('\non-disk @0x%x:' % fo)
    print('  hex  :', d[fo:fo + 56].hex(' '))
    print('  ascii:', repr(d[fo:fo + 56]))
