"""count_vtable_instances.py Count how many objects in the dump have as their first DWORD. Print the count and a few sample addresses. """ import struct, sys from minidump.minidumpfile import MinidumpFile 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]) vt = int(sys.argv[2], 16) rdr = 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)) count = 0 samples = [] for base, size in scan: try: rdr.move(base); buf = rdr.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("