1.1 --- a/tools/ida_scripts/vtable_dump.py Fri Aug 10 21:54:03 2012 -0400
1.2 +++ b/tools/ida_scripts/vtable_dump.py Wed Aug 15 16:05:16 2012 +0100
1.3 @@ -49,7 +49,7 @@
1.4 global offsetdata
1.5
1.6 # Param needed to support old IDAPython versions
1.7 - end = NextHead(ea, 4294967295)
1.8 + end = NextNotTail(ea)
1.9
1.10 # Skip vtable
1.11 ea += 4
1.12 @@ -65,7 +65,7 @@
1.13 innerclass = name
1.14 catchclass = False
1.15
1.16 - print "%*s%s" % (level, "", name)
1.17 + print " %*s%s" % (level, "", name)
1.18
1.19 if not ea < end: # Base Type
1.20 pass
1.21 @@ -105,8 +105,7 @@
1.22 # Param needed to support old IDAPython versions
1.23 ea = PrevHead(ea, 0)
1.24
1.25 - # Param needed to support old IDAPython versions
1.26 - end = NextHead(ea, 4294967295)
1.27 + end = NextNotTail(ea)
1.28
1.29 name = Demangle(Name(ea), GetLongPrm(INF_LONG_DN))
1.30 if ea == BADADDR or name is None or not re.search(r"vf?table(?: |'\{)for", name):
1.31 @@ -136,7 +135,11 @@
1.32 ExtractTypeInfo(typeinfo)
1.33
1.34 while ea < end and isCode(GetFlags(Dword(ea))):
1.35 - name = Demangle(Name(Dword(ea)), GetLongPrm(INF_LONG_DN))
1.36 + name = Name(Dword(ea))
1.37 + demangled = Demangle(name, GetLongPrm(INF_LONG_DN))
1.38 + #print "Name: %s, Demangled: %s" % (name, demangled)
1.39 +
1.40 + name = demangled if demangled else name
1.41
1.42 if offset == 0:
1.43 linux_vtable.append(name)
1.44 @@ -201,13 +204,17 @@
1.45 windows_vtable.append(overload_stack.pop())
1.46
1.47 print "\nVTable for %s: (0, 0)" % (classname)
1.48 - print "Lin Win Function"
1.49 + print " Lin Win Function"
1.50 for i, v in enumerate(linux_vtable):
1.51 + if "__cxa_pure_virtual" in v:
1.52 + print "P%3d" % (i)
1.53 + continue
1.54 +
1.55 winindex = windows_vtable.index(v) if v in windows_vtable else None
1.56 if winindex is not None:
1.57 - print "%3d %3d %s" % (i, winindex, v)
1.58 + print "%4d %4d %s" % (i, winindex, v)
1.59 else:
1.60 - print "%3d %s" % (i, v)
1.61 + print "%4d %s" % (i, v)
1.62
1.63 for k in temp_other_windows_vtables:
1.64 for i, v in enumerate(temp_other_windows_vtables[k]):
1.65 @@ -227,7 +234,9 @@
1.66 if function == prev_function:
1.67 if len(overload_stack) == 0:
1.68 other_windows_vtables[k].pop()
1.69 + #print "Storing '%s' (!)" % (prev_symbol)
1.70 overload_stack.append(prev_symbol)
1.71 + #print "Storing '%s'" % (v)
1.72 overload_stack.append(v)
1.73 else:
1.74 if len(overload_stack) > 0:
1.75 @@ -239,13 +248,17 @@
1.76
1.77 for k in other_linux_vtables:
1.78 print "\nVTable for %s: (%d, %d)" % (offsetdata[k], offsetdata.keys().index(k) + 1, k)
1.79 - print "Lin Win Function"
1.80 + print " Lin Win Function"
1.81 for i, v in enumerate(other_linux_vtables[k]):
1.82 + if "__cxa_pure_virtual" in v:
1.83 + print "P%3d" % (i)
1.84 + continue
1.85 +
1.86 winindex = other_windows_vtables[k].index(v)
1.87 if v not in other_thunk_linux_vtables[k]:
1.88 - print "%3d %3d %s" % (i, winindex, v)
1.89 + print "%4d %4d %s" % (i, winindex, v)
1.90 else:
1.91 - print "T%2d %3d %s" % (i, winindex, v)
1.92 + print "T%3d %4d %s" % (i, winindex, v)
1.93
1.94 SetStatus(IDA_STATUS_READY)
1.95