demangle module¶
- 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 directly
- Returns:
returns tuple of (Type, demangled_name) or (None, mangled_name) on error
- Return type:
Tuple
- demangle_ms(archOrPlatform: Union[Architecture, Platform], mangled_name: str, options=False)[source]¶
demangle_ms
demangles a mangled Microsoft Visual Studio C++ name to a Type object.- Parameters:
archOrPlatform (Union[Architecture, Platform]) – Architecture or Platform for the symbol. Required for pointer/integer sizes and calling conventions.
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 directly
archOrPlatform –
- Returns:
returns tuple of (Type, demangled_name) or (None, mangled_name) on error
- Return type:
Tuple
- Example:
>>> demangle_ms(Platform["x86_64"], "[email protected]@@[email protected]@W421@@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:
- Returns:
a qualified name
- Return type:
- Example:
>>> type, name = demangle_ms(Architecture["x86_64"], "[email protected]@@[email protected]@W421@@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 (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:
- 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:
- Example:
>>> demangle.simplify_name_to_string("std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >") 'std::string' >>>