Bunch of miscellaneous updates

I've dropped the ball on making smaller commits so now here's a big one

- Update sig for post-6.40 exes
- Some packet handlers have switches for packet sizes. Added a heuristic
  to capture this information
- Consolidated vtable alignment warnings
- Added script to debug similarity matrix
This commit is contained in:
Flawed
2023-08-21 14:38:38 -07:00
parent a394fd32eb
commit 367765871b
8 changed files with 145 additions and 15 deletions
+43
View File
@@ -0,0 +1,43 @@
import click
from vtable_alignment import Similarity
from utils import HexIntParamType
@click.command()
@click.argument(
"similarity_json_file",
type=click.Path(exists=True, dir_okay=False, resolve_path=True),
)
@click.argument("opcode", type=HexIntParamType())
def debug_similarity_matrix(similarity_json_file, opcode):
"""
Given an old opcode, debug prints a row of the similarity matrix generated
from generate_similarity_matrix.py.
Example:
python debug_similarity_matrix.py similarity.json 0x200
"""
entries = dict()
similarity = Similarity(similarity_json_file)
for new_opcode in similarity.new_opcodes:
entries[new_opcode] = similarity.lookup(opcode, new_opcode)
max_opcode = 0
max_score = -9999
print(f"Similarities for {hex(opcode)}")
for new_opcode, similarity in entries.items():
print(f"\t{hex(new_opcode)} => {similarity}")
if similarity > max_score:
max_opcode = new_opcode
max_score = similarity
print("Best match")
print(f"{hex(max_opcode)} => {max_score}")
if __name__ == "__main__":
debug_similarity_matrix()