Skip to content

Instantly share code, notes, and snippets.

@thomasfinch
Last active September 3, 2017 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thomasfinch/940c6d914a2e4fbbf6aa72bc3ab694d1 to your computer and use it in GitHub Desktop.
Save thomasfinch/940c6d914a2e4fbbf6aa72bc3ab694d1 to your computer and use it in GitHub Desktop.
A super crappy and kinda slow (it makes network calls!) Visual C++ demangler script for Hopper disassembler. Based on https://github.com/melomac/Hopper/blob/master/Demangle%20Swift.py, uses demangler.com
import urllib, urllib2
def demangle(symbol):
r = urllib2.Request('http://demangler.com/raw', urllib.urlencode({'input': symbol}))
response = urllib2.urlopen(r)
return response.read()
def main():
doc = Document.getCurrentDocument()
current = doc.getCurrentAddress()
for index in xrange(doc.getSegmentCount()):
seg = doc.getSegment(index)
for address in xrange(seg.getStartingAddress(), seg.getStartingAddress() + seg.getLength()):
name = seg.getNameAtAddress(address)
if name is None:
continue
else:
demangled = demangle(name)
doc.moveCursorAtAddress(address)
if name is demangled:
doc.log("Failed to demangle symbol at address: 0x%08x with name: %s" % (address, name))
continue
seg.setNameAtAddress(address, demangled)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment