demangle module¶
Class |
Description |
---|---|
Pluggable name demangling interface. See |
|
Pluggable name demangling interface. See |
CoreDemangler¶
- class CoreDemangler[source]¶
Bases:
Demangler
- demangle(arch: Architecture, name: str, view: BinaryView | None = None) Tuple[Type | None, QualifiedName] | None [source]¶
Demangle a raw name into a Type and QualifiedName.
The result of this function is a (Type, QualifiedName) tuple for the demangled name’s details.
Any unresolved named types referenced by the resulting Type will be created as empty structures or void typedefs in the view, if the result is used on a data structure in the view. Given this, the call to
demangle
should NOT cause any side-effects creating types in the view trying to resolve this and instead just return a type with unresolved named type references.The most recently registered demangler that claims a name is a mangled string (returns true from
is_mangled_string
), and then returns a value from this function will determine the result of a call todemangle_generic
. If this call returns None, the next most recently used demangler(s) will be tried instead.If the mangled name has no type information, but a name is still possible to extract, this function may return a successful (None, <name>) result, which will be accepted.
- Parameters:
arch (Architecture) – Architecture for context in which the name exists, eg for pointer sizes
name (str) – Raw mangled name
view (BinaryView | None) – (Optional) BinaryView context in which the name exists, eg for type lookup
- Returns:
Tuple of (Type, Name) if successful, None if not. Type may be None if only a demangled name can be recovered from the raw name.
- Return type:
Tuple[Type | None, QualifiedName] | None
- is_mangled_string(name: str) bool [source]¶
Determine if a given name is mangled and this demangler can process it
The most recently registered demangler that claims a name is a mangled string (returns true from this function), and then returns a value from
demangle
will determine the result of a call todemangle_generic
. Returning True from this does not require the demangler to succeed the call todemangle
, but simply implies that it may succeed.
Demangler¶
- class Demangler[source]¶
Bases:
object
Pluggable name demangling interface. See
register
anddemangle
for details on the process of this interface.The list of Demanglers can be queried:
>>> list(Demangler) [<Demangler: MS>, <Demangler: GNU3>]
- demangle(arch: Architecture, name: str, view: BinaryView | None = None) Tuple[Type, QualifiedName] | None [source]¶
Demangle a raw name into a Type and QualifiedName.
The result of this function is a (Type, QualifiedName) tuple for the demangled name’s details.
Any unresolved named types referenced by the resulting Type will be created as empty structures or void typedefs in the view, if the result is used on a data structure in the view. Given this, the call to
demangle
should NOT cause any side-effects creating types in the view trying to resolve this and instead just return a type with unresolved named type references.The most recently registered demangler that claims a name is a mangled string (returns true from
is_mangled_string
), and then returns a value from this function will determine the result of a call todemangle_generic
. If this call returns None, the next most recently used demangler(s) will be tried instead.If the mangled name has no type information, but a name is still possible to extract, this function may return a successful (None, <name>) result, which will be accepted.
- Parameters:
arch (Architecture) – Architecture for context in which the name exists, eg for pointer sizes
name (str) – Raw mangled name
view (BinaryView | None) – (Optional) BinaryView context in which the name exists, eg for type lookup
- Returns:
Tuple of (Type, Name) if successful, None if not. Type may be None if only a demangled name can be recovered from the raw name.
- Return type:
Tuple[Type, QualifiedName] | None
- is_mangled_string(name: str) bool [source]¶
Determine if a given name is mangled and this demangler can process it
The most recently registered demangler that claims a name is a mangled string (returns true from this function), and then returns a value from
demangle
will determine the result of a call todemangle_generic
. Returning True from this does not require the demangler to succeed the call todemangle
, but simply implies that it may succeed.
- classmethod promote(demangler)[source]¶
Promote a demangler to the highest-priority position.
>>> list(Demangler) [<Demangler: MS>, <Demangler: GNU3>] >>> Demangler.promote(list(Demangler)[0]) >>> list(Demangler) [<Demangler: GNU3>, <Demangler: MS>]
- Parameters:
demangler – Demangler to promote
- classmethod register()[source]¶
Register a custom Demangler. Newly registered demanglers will get priority over previously registered demanglers and built-in demanglers.
- name = None¶