Skip to content

Instantly share code, notes, and snippets.

@jrsa
Last active July 9, 2017 17:31
Show Gist options
  • Save jrsa/43dbba70e568e01ea194dce60941aa05 to your computer and use it in GitHub Desktop.
Save jrsa/43dbba70e568e01ea194dce60941aa05 to your computer and use it in GitHub Desktop.
hopper script that tags functions which refer to the same global (or static) variable
doc = Document.getCurrentDocument()
textseg = doc.getSegmentByName('__TEXT')
dataseg = doc.getSegmentByName('__TEXT')
addr = doc.getCurrentAddress()
seg = doc.getSegment(doc.getSegmentIndexAtAddress(addr))
xrefs = seg.getReferencesOfAddress(addr)
doc.log("found {} xrefs to {}".format(len(xrefs), addr))
tagstr = doc.ask("tag to apply? (press cancel for no changes)")
if tagstr:
tag = doc.buildTag(tagstr)
for i, x in enumerate(xrefs):
refseg = doc.getSegment(doc.getSegmentIndexAtAddress(x))
proc = refseg.getProcedureAtAddress(x)
if proc:
proc.addTag(tag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment