#!/usr/bin/env python3
"""Find every dense '0x40 <identifier> NUL' region in the on-disk original Driver -
those are bind/lazy-bind streams. Report their offsets and sizes so we can see
whether a second (lazy) stream survives somewhere."""
import sys, re

sys.stdout.reconfigure(encoding='utf-8')
d = open(r'E:\ios\work319\patch_src_orig\Driver', 'rb').read()
pat = re.compile(rb'\x40[A-Za-z_$][A-Za-z0-9_$]{3,70}\x00')
hits = [m.start() for m in pat.finditer(d)]
print('total 0x40<name> patterns:', len(hits))
# cluster by 64KB bucket
import collections
c = collections.Counter(o >> 16 for o in hits)
print('dense regions (bucket 0x10000, count>=50):')
for k in sorted(c):
    if c[k] >= 50:
        print('   0x%08x-0x%08x : %d' % (k << 16, (k + 1) << 16, c[k]))
