Browse Source

Finish migrating vtable helpers to disambiguator

nosoop 10 months ago
parent
commit
836279d2eb
3 changed files with 4 additions and 33 deletions
  1. 2 3
      src/smgdc/validate.py
  2. 0 27
      src/smgdc/vtable.py
  3. 2 3
      tests/test_vtable.py

+ 2 - 3
src/smgdc/validate.py

@@ -18,7 +18,6 @@ import typing
 import angr
 import msgspec
 
-from . import vtable as vt_helpers
 from .angr.vtable_disamb import VTableConstraintDict, VtableDisambiguator
 from .types import ByteSequence, ByteSignature, Code, IntLiteral
 
@@ -207,8 +206,8 @@ class VirtualFunctionEntry(BaseEntry, tag="vfn"):
         vtsym = bin.angr.loader.find_symbol(f"_ZTV{self.typename}")
         if not vtsym:
             raise ValueError(f"Could not find vtable symbol _ZTV{self.typename}")
-        orig_vtable, *thunk_vtables = vt_helpers.get_vtables_from_address(bin, vtsym)
-        win_vtable = vt_helpers.get_windows_vtables_from(bin, vtsym)
+        orig_vtable, *thunk_vtables = bin.vtable_disambiguator.get_vtables_from_address(vtsym)
+        win_vtable = bin.vtable_disambiguator.get_windows_vtables_from(vtsym)
 
         sym = bin.angr.loader.find_symbol(self.symbol)
         return {

+ 0 - 27
src/smgdc/vtable.py

@@ -1,27 +0,0 @@
-#!/usr/bin/python3
-
-# vtable helpers
-# this should probably be cleaned up and moved somewhere else
-
-import typing
-
-from cle.backends.symbol import Symbol
-
-if typing.TYPE_CHECKING:
-    from .validate import LinuxBinary
-
-VTable = list[Symbol]
-
-
-def get_windows_vtables_from(bin: "LinuxBinary", vt: Symbol) -> VTable:
-    return bin.vtable_disambiguator.get_windows_vtables_from(vt)
-
-
-def get_constrained_vfn(
-    bin: "LinuxBinary", vt: Symbol, vfnidx: int, candidate_fnsyms: set[Symbol]
-) -> Symbol | None:
-    return bin.vtable_disambiguator.get_constrained_vfn(vt, vfnidx, candidate_fnsyms)
-
-
-def get_vtables_from_address(bin: "LinuxBinary", vt: Symbol) -> list[VTable]:
-    return bin.vtable_disambiguator.get_vtables_from_address(vt)

+ 2 - 3
tests/test_vtable.py

@@ -9,7 +9,6 @@ import typing
 
 import pytest
 import smgdc.angr
-import smgdc.vtable as vt_helpers
 from smgdc.validate import LinuxBinary
 
 
@@ -88,8 +87,8 @@ def test_vtable(game_bin: LinuxBinary, vtsym_name: str, vtasserts: list[VTableCh
     # tests vtable translation
     vtsym = game_bin.angr.loader.find_symbol(vtsym_name)
     assert vtsym, f"Could not find vtable symbol {vtsym_name}"
-    orig_vtable, *thunk_vtables = vt_helpers.get_vtables_from_address(game_bin, vtsym)
-    win_vtable = vt_helpers.get_windows_vtables_from(game_bin, vtsym)
+    orig_vtable, *thunk_vtables = game_bin.vtable_disambiguator.get_vtables_from_address(vtsym)
+    win_vtable = game_bin.vtable_disambiguator.get_windows_vtables_from(vtsym)
 
     for check in map(VTableCheck._make, vtasserts):
         symbol = game_bin.angr.loader.find_symbol(check.symbol_name)