Last active
July 9, 2017 17:31
-
-
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
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
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