From 26eaf724f49c2f998b800780b128b6ff688065a6 Mon Sep 17 00:00:00 2001 From: Flawed <33593723+ff14wed@users.noreply.github.com> Date: Mon, 2 Oct 2023 02:52:40 -0700 Subject: [PATCH] Add warning to vtable diff if sizes don't match --- vtable_diff.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/vtable_diff.py b/vtable_diff.py index fa6e73a..690922a 100644 --- a/vtable_diff.py +++ b/vtable_diff.py @@ -28,7 +28,6 @@ def get_opcode_offset(r2): def extract_opcode_data(exe_file): - r2 = r2pipe.open(exe_file, ["-2"]) eprint(f"Radare loaded {exe_file}") @@ -72,7 +71,7 @@ def extract_opcode_data(exe_file): def find_opcode_matches(old_opcodes_db, new_opcodes_db): matches = [] - for (offset, old_opcode) in old_opcodes_db.items(): + for offset, old_opcode in old_opcodes_db.items(): if offset in new_opcodes_db: matches.append((old_opcode, new_opcodes_db[offset])) @@ -110,10 +109,15 @@ def vtable_diff(old_exe, new_exe): old_opcodes_db = extract_opcode_data(old_exe) new_opcodes_db = extract_opcode_data(new_exe) + if len(old_opcodes_db) != len(new_opcodes_db): + eprint( + f"WARNING: vtables have different sizes: {len(old_opcodes_db)} != {len(new_opcodes_db)}. Matches may not be correct." + ) + opcodes_found = find_opcode_matches(old_opcodes_db, new_opcodes_db) opcodes_object = [] - for (old, new) in opcodes_found: + for old, new in opcodes_found: opcodes_object.append( { "old": [hex(old)],