Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.