# Prints the vtable slots of an MSVC RTTI class straight from the exe (TypeDescriptor -> CompleteObjectLocator -> vftable). # Usage: vtable.py exe functions.tsv ClassName [maxslots] import struct, sys, re data = open(sys.argv[1], 'rb').read() names = {} for line in open(sys.argv[2]): p = line.rstrip('\n').split('\t') if len(p) >= 2: names[int(p[0], 16)] = p[1] pe = struct.unpack_from(' 4 else 40 sig = ('.?AV' + cls + '@IsaacRepentancePlus@@').encode() starts = [m.start() for m in re.finditer(re.escape(sig), data)] if not starts: sig = ('.?AV' + cls + '@@').encode(); starts = [m.start() for m in re.finditer(re.escape(sig), data)] for s in starts: tdoff = s - 8 # TypeDescriptor: vfptr, spare, name tdva = off2va(tdoff) # find COLs referencing tdva at offset 12 key = struct.pack(' 0xb20000: break print(' %2d %08x %s' % (i, f, names.get(f, '?')))