Created
August 9, 2019 10:10
-
-
Save SiD3W4y/bb65362d6a7fddb0f9a79edce4928286 to your computer and use it in GitHub Desktop.
Binary ninja snippet script to add trace based function detection on gba roms (through mgba)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Trace function detection | |
# | |
# Binary ninja script for trace based function detection on gba using | |
# the 'tracing' branch of this fork: https://github.com/SiD3W4y/mgba | |
path = get_open_filename_input("mgba trace file") | |
if not path: | |
show_message_box("Function detection", "Please specify a file") | |
lines = open(path, "r").readlines() | |
funcs = [] | |
for line in lines: | |
line = line.strip() | |
if len(line) > 5: | |
chks = line.split(" ") | |
if len(chks) == 2: | |
funcs.append(int(chks[0], 16)) | |
duplicates = 0 | |
for fnaddr in funcs: | |
fns = bv.get_functions_containing(fnaddr) | |
# We found a new function | |
if not fns: | |
bv.create_user_function(fnaddr, plat=Architecture["thumb2"].standalone_platform) | |
else: | |
duplicates += 1 | |
show_message_box("Function detection", "{} functions found ({} duplicates)".format(len(funcs), duplicates)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment