From 2857102a432983b2753b5b81e2cc17dc2d270474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Tue, 8 Sep 2020 19:22:26 +0200 Subject: [PATCH] tools: Add a script to rename functions in IDA --- tools/rename_functions_in_ida.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tools/rename_functions_in_ida.py diff --git a/tools/rename_functions_in_ida.py b/tools/rename_functions_in_ida.py new file mode 100644 index 00000000..209cdb62 --- /dev/null +++ b/tools/rename_functions_in_ida.py @@ -0,0 +1,25 @@ +# Renames functions in an IDA database to match the function names +# in the decompiled source code. +# This script needs to be compatible with Python 2.7. + +import csv +import idc +import os + +csv_path = os.path.join(os.path.dirname(__file__), "../data/uking_functions.csv") + +MARKERS = ("|", "?", "!") + +with open(csv_path, "r") as f: + reader = csv.reader(f) + for fn in reader: + addr = int(fn[0], 16) + decomp_name = fn[3] + if not decomp_name: + continue + + # Get rid of status markers. + if decomp_name[-1] in MARKERS: + decomp_name = decomp_name[:-1] + + idc.MakeName(addr, decomp_name)