demangle module¶
- demangle_gnu3(arch, mangled_name: str, options: bool | BinaryView | None = 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 (Optional[Union[bool, BinaryView]]) – (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:
- demangle_llvm(mangled_name: str, options: bool | BinaryView | None = None) List[str] | None [source]¶
demangle_llvm
demangles a mangled name to a Type object.- Parameters:
mangled_name (str) – a mangled (msvc/itanium/rust/dlang) name
options (Optional[Union[bool, BinaryView]]) – (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 demangled name or None on error
- Return type:
Optional[List[str]]
- demangle_ms(archOrPlatform: Architecture | Platform, mangled_name: str, options: bool | BinaryView | None = False)[source]¶
demangle_ms
demangles a mangled Microsoft Visual Studio C++ name to a Type object.- Parameters:
archOrPlatform (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 (Optional[Union[bool, BinaryView]]) – (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:
- Example:
>>> demangle_ms(Platform["x86_64"], "?testf@Foobar@@SA?AW4foo@1@W421@@Z") (<type: public: static enum Foobar::foo __cdecl (enum Foobar::foo)>, ['Foobar', 'testf']) >>>
- get_qualified_name(names: Iterable[str])[source]¶
get_qualified_name
gets a qualified name for the provided name list.
- simplify_name_to_qualified_name(input_name: str | QualifiedName, simplify: bool = 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: str | QualifiedName)[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' >>>