diff options
| author | KyleMiles <krm504@nyu.edu> | 2018-07-13 19:23:31 -0400 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2018-07-13 19:25:15 -0400 |
| commit | 2c7f443ce0b3d92ea44acb440c1891344eacc6d4 (patch) | |
| tree | 2b792808b858de83d7f2b90040b023534a4455a6 /python/demangle.py | |
| parent | b460b9495a91897d9f8ed192c148e5afc366fb59 (diff) | |
Python2/3 String Compatibility Fix
Diffstat (limited to 'python/demangle.py')
| -rw-r--r-- | python/demangle.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/python/demangle.py b/python/demangle.py index 466324bc..2fa1028f 100644 --- a/python/demangle.py +++ b/python/demangle.py @@ -22,9 +22,11 @@ import ctypes # Binary Ninja components from binaryninja import _binaryninjacore as core +from binaryninja import types # 2-3 compatibility from binaryninja import range +from binaryninja import pyNativeStr def get_qualified_name(names): @@ -58,28 +60,26 @@ def demangle_ms(arch, mangled_name): (<type: public: static enum Foobar::foo __cdecl (enum Foobar::foo)>, ['Foobar', 'testf']) >>> """ - from binaryninja import types handle = ctypes.POINTER(core.BNType)() outName = ctypes.POINTER(ctypes.c_char_p)() outSize = ctypes.c_ulonglong() names = [] if core.BNDemangleMS(arch.handle, mangled_name, ctypes.byref(handle), ctypes.byref(outName), ctypes.byref(outSize)): for i in range(outSize.value): - names.append(outName[i].decode('charmap')) + names.append(pyNativeStr(outName[i])) core.BNFreeDemangledName(ctypes.byref(outName), outSize.value) return (types.Type(handle), names) return (None, mangled_name) def demangle_gnu3(arch, mangled_name): - from binaryninja import types handle = ctypes.POINTER(core.BNType)() outName = ctypes.POINTER(ctypes.c_char_p)() outSize = ctypes.c_ulonglong() names = [] if core.BNDemangleGNU3(arch.handle, mangled_name, ctypes.byref(handle), ctypes.byref(outName), ctypes.byref(outSize)): for i in range(outSize.value): - names.append(outName[i].decode('charmap')) + names.append(pyNativeStr(outName[i])) core.BNFreeDemangledName(ctypes.byref(outName), outSize.value) if not handle: return (None, names) |
