"""probe_gmui_size.py Measure spacing between adjacent gm*UI instances in the same region to derive a real per-instance allocation size. """ import struct, sys from minidump.minidumpfile import MinidumpFile from collections import Counter GM_NOTICE_VT = 0x007ccb60 GM_NOTICE_OFFSET = 0x5f8 def _ei(v): if v is None: return 0 if hasattr(v, 'value'): return int(v.value) return int(v) md = MinidumpFile.parse(sys.argv[1]) reader = md.get_reader().get_buffered_reader() scan = [] for r in md.memory_info.infos: st, ty, pr = _ei(r.State), _ei(r.Type), _ei(r.Protect) & 0xff if st != 0x1000 or ty == 0x1000000 or pr not in (0x04, 0x40): continue scan.append((r.BaseAddress, r.RegionSize)) # Find outer-object addresses outers = [] for base, size in scan: try: reader.move(base); buf = reader.read(size) except Exception: continue if not buf: continue end = (len(buf) // 4) * 4 for off in range(0, end - 4, 4): if struct.unpack_from("6}) x{n}") # Also probe MEM_PRIVATE region sizes that *contain* gm*UI outers sizes = Counter() for o in outers: for base, size in scan: if base <= o < base + size: sizes[size] += 1 break print() print("region sizes containing gm*UI outers:") for s, n in sizes.most_common(15): print(f" size={s:>9} ({s/1024:>6.1f}KB) x{n}")