Simplify vtable name check

This commit is contained in:
disinvite 2024-03-23 17:06:58 -04:00
parent f0ef4f7835
commit bae788fc45

View File

@ -358,21 +358,24 @@ def match_function(self, addr: int, name: str) -> bool:
def match_vtable( def match_vtable(
self, addr: int, name: str, base_class: Optional[str] = None self, addr: int, name: str, base_class: Optional[str] = None
) -> bool: ) -> bool:
temp_base = base_class if base_class is not None else name # Only allow a match against "Class:`vftable'"
# if this is the derived class.
name_option0 = f"{name}::`vftable'" name = (
name_option1 = f"{name}::`vftable'{{for `{temp_base}'}}" f"{name}::`vftable'"
if base_class is None or base_class == name
else f"{name}::`vftable'{{for `{base_class}'}}"
)
row = self._db.execute( row = self._db.execute(
""" """
SELECT recomp_addr SELECT recomp_addr
FROM `symbols` FROM `symbols`
WHERE orig_addr IS NULL WHERE orig_addr IS NULL
AND (name = ? OR name = ?) AND name = ?
AND (compare_type = ?) AND (compare_type = ?)
LIMIT 1 LIMIT 1
""", """,
(name_option0, name_option1, SymbolType.VTABLE.value), (name, SymbolType.VTABLE.value),
).fetchone() ).fetchone()
if row is not None and self.set_pair(addr, row[0], SymbolType.VTABLE): if row is not None and self.set_pair(addr, row[0], SymbolType.VTABLE):