Last active
September 3, 2017 16:23
-
-
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
This file contains 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
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