Skip to content

Instantly share code, notes, and snippets.

@HookedBehemoth
Created July 1, 2020 20:50
Show Gist options
  • Save HookedBehemoth/107a681beb056f8fc554c82c2fe1478f to your computer and use it in GitHub Desktop.
Save HookedBehemoth/107a681beb056f8fc554c82c2fe1478f to your computer and use it in GitHub Desktop.
#Imports a file with lines in the form "symbolName 0xADDRESS"
#@category Data
#@author
from ghidra.app.cmd.label import DemanglerCmd
f = askFile("Give me a file to open", "OK!")
def set_demangled_name(addr, name):
cmd = DemanglerCmd(toAddr(addr), name)
return cmd.applyTo(currentProgram, monitor), cmd.getResult()
failed = []
for line in file(f.absolutePath): # note, cannot use open(), since that is in GhidraScript
pieces = line.split()
name = pieces[0]
addr = pieces[1]
res, demangled = set_demangled_name(addr, name)
if res:
print("Applied symbol at %s (%s)" % (addr, demangled))
else:
failed.append((addr, name))
for addr, name in failed:
print("FAILED to apply symbol at %s (%s)" % (addr, name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment