From ce9990d5340295539f65819e473ae833cd360e28 Mon Sep 17 00:00:00 2001 From: MattKC <34096995+itsmattkc@users.noreply.github.com> Date: Mon, 30 Oct 2023 22:08:39 -0700 Subject: [PATCH] add final code to check vtable accuracy --- tools/reccmp/modules/syminfo.py | 9 +++++++++ tools/reccmp/reccmp.py | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/reccmp/modules/syminfo.py b/tools/reccmp/modules/syminfo.py index c1c1cbba..7e028a67 100644 --- a/tools/reccmp/modules/syminfo.py +++ b/tools/reccmp/modules/syminfo.py @@ -246,3 +246,12 @@ def get_recompiled_address_from_name(self, name): return self.names[name] else: logger.error('Failed to find function symbol with name: %s', name) + + def verify_vtable(self, class_name, func_name, offset): + for class_id, c in classes.items(): + if c.name == class_name and c.field_list: + fl = fieldlists[c.field_list] + for v in fl.vtable: + if v.name == func_name and v.offset == offset: + return True + return False diff --git a/tools/reccmp/reccmp.py b/tools/reccmp/reccmp.py index 93aa65fc..f24c17f7 100755 --- a/tools/reccmp/reccmp.py +++ b/tools/reccmp/reccmp.py @@ -400,16 +400,17 @@ def can_resolve_register_differences(original_asm, new_asm): break try: - start_brkt = line.index('(') + start_brkt = line.rindex('(') name_discovery = line[0:start_brkt].split() vtbl_name = name_discovery[len(name_discovery) - 1] break except ValueError: continue except ValueError: - pass + continue - print('Found vtable function %s::%s offset %s' % (in_class, vtbl_name, hex(address))) + if not syminfo.verify_vtable(in_class, vtbl_name, address): + raise Exception('Function %s::%s is not at %s' % (in_class, vtbl_name, hex(address))) else: # NOTE: Naive implementation, won't support vtable functions after a nested class class_discovery = line.split()