Browse Source

Ignore decreasing vtable spans when walking up parents

nosoop 10 months ago
parent
commit
d4948bcac1
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/smgdc/vtable.py

+ 6 - 1
src/smgdc/vtable.py

@@ -55,7 +55,12 @@ def get_windows_vtables_from(bin: "LinuxBinary", vt: Symbol) -> VTable:
         if not vt_parent:
             continue
         vt_parent_first, *_ = vtda.get_vfptrs_from_table(vt_parent)
-        vt_parent_spans.append(len(vt_parent_first))
+
+        # it's possible for a parent table to have more functions than its child
+        # e.g. CAutoGameSystemPerFrame has more functions present than CGameRules
+        span = len(vt_parent_first)
+        if span > vt_parent_spans[-1]:
+            vt_parent_spans.append(span)
 
     vt_first, *vt_others = get_vtables_from_address(bin, vt)
     thunk_fns = set()