From 2c7f443ce0b3d92ea44acb440c1891344eacc6d4 Mon Sep 17 00:00:00 2001 From: KyleMiles Date: Fri, 13 Jul 2018 19:23:31 -0400 Subject: Python2/3 String Compatibility Fix --- python/demangle.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'python/demangle.py') 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): (, ['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) -- cgit v1.3.1