demangle module

binaryninja.demangle.BinaryView([…])

class BinaryView implements a view on binary data, and presents a queryable interface of a binary file.

binaryninja.demangle.demangle_gnu3(arch, …)

demangle_gnu3 demangles a mangled name to a Type object.

binaryninja.demangle.demangle_ms(arch, …)

demangle_ms demangles a mangled Microsoft Visual Studio C++ name to a Type object.

binaryninja.demangle.get_qualified_name(names)

get_qualified_name gets a qualified name for the provided name list.

binaryninja.demangle.pyNativeStr(arg)

binaryninja.demangle.simplify_name_to_qualified_name(…)

simplify_name_to_qualified_name simplifies a templated C++ name with default arguments and returns a qualified name.

binaryninja.demangle.simplify_name_to_string(…)

simplify_name_to_string simplifies a templated C++ name with default arguments and returns a string

demangle_gnu3(arch, mangled_name, options=None)[source]

demangle_gnu3 demangles a mangled name to a Type object.

Parameters
  • arch (Architecture) – Architecture for the symbol. Required for pointer and integer sizes.

  • mangled_name (str) – a mangled GNU3 name

  • options (Tuple[bool, BinaryView, None]) – (optional) Whether to simplify demangled names : None falls back to user settings, a BinaryView uses that BinaryView’s settings, or a boolean to set it directally

Returns

returns tuple of (Type, demangled_name) or (None, mangled_name) on error

Return type

Tuple

demangle_ms(arch, mangled_name, options=False)[source]

demangle_ms demangles a mangled Microsoft Visual Studio C++ name to a Type object.

Parameters
  • arch (Architecture) – Architecture for the symbol. Required for pointer and integer sizes.

  • mangled_name (str) – a mangled Microsoft Visual Studio C++ name

  • options (Tuple[bool, BinaryView, None]) – (optional) Whether to simplify demangled names : None falls back to user settings, a BinaryView uses that BinaryView’s settings, or a boolean to set it directally

Returns

returns tuple of (Type, demangled_name) or (None, mangled_name) on error

Return type

Tuple

Example
>>> demangle_ms(Architecture["x86_64"], "[email protected]@@[email protected]@[email protected]@Z")
(<type: public: static enum Foobar::foo __cdecl (enum Foobar::foo)>, ['Foobar', 'testf'])
>>>
get_qualified_name(names)[source]

get_qualified_name gets a qualified name for the provided name list.

Parameters

names (list(str)) – name list to qualify

Returns

a qualified name

Return type

str

Example
>>> type, name = demangle_ms(Architecture["x86_64"], "[email protected]@@[email protected]@[email protected]@Z")
>>> get_qualified_name(name)
'Foobar::testf'
>>>
simplify_name_to_qualified_name(input_name, simplify=True)[source]

simplify_name_to_qualified_name simplifies a templated C++ name with default arguments and returns a qualified name. This can also tokenize a string to a qualified name with/without simplifying it

Parameters
  • input_name (Union[str, QualifiedName]) – String or qualified name to be simplified

  • simplify_name (bool) – (optional) Whether to simplify input string (no effect if given a qualified name; will always simplify)

Returns

simplified name (or one-element array containing the input if simplifier fails/cannot simplify)

Return type

QualifiedName

Example
>>> demangle.simplify_name_to_qualified_name(QualifiedName(["std", "__cxx11", "basic_string<wchar, std::char_traits<wchar>, std::allocator<wchar> >"]), True)
'std::wstring'
>>>
simplify_name_to_string(input_name)[source]

simplify_name_to_string simplifies a templated C++ name with default arguments and returns a string

Parameters

input_name (Union[str, QualifiedName]) – String or qualified name to be simplified

Returns

simplified name (or original name if simplifier fails/cannot simplify)

Return type

str

Example
>>> bdemangle.simplify_name_to_string("std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >")
'std::string'
>>>