Loading...
Searching...
No Matches
BinaryNinja::CoreDemangler Class Reference

Public Member Functions

 CoreDemangler (BNDemangler *demangler)
 
virtual ~CoreDemangler ()=default
 
virtual bool IsMangledString (const std::string &name)
 Determine if a given name is mangled and this demangler can process it.
 
virtual bool Demangle (Ref< Architecture > arch, const std::string &name, Ref< Type > &outType, QualifiedName &outVarName, Ref< BinaryView > view)
 Demangle a raw name into a Type and QualifiedName.
 
- Public Member Functions inherited from BinaryNinja::Demangler
std::string GetName () const
 
- Public Member Functions inherited from BinaryNinja::StaticCoreRefCountObject< BNDemangler >
 StaticCoreRefCountObject ()
 
virtual ~StaticCoreRefCountObject ()
 
BNDemanglerGetObject () const
 
void AddRef ()
 
void Release ()
 
void AddRefForRegistration ()
 
void AddRefForCallback ()
 
void ReleaseForCallback ()
 

Additional Inherited Members

- Static Public Member Functions inherited from BinaryNinja::Demangler
static void Register (Demangler *demangler)
 Register a custom Demangler.
 
static std::vector< Ref< Demangler > > GetList ()
 Get the list of currently registered demanglers, sorted by lowest to highest priority.
 
static Ref< DemanglerGetByName (const std::string &name)
 
static void Promote (Ref< Demangler > demangler)
 Promote a demangler to the highest-priority position.
 
- Static Public Member Functions inherited from BinaryNinja::StaticCoreRefCountObject< BNDemangler >
static BNDemanglerGetObject (StaticCoreRefCountObject *obj)
 
- Public Attributes inherited from BinaryNinja::StaticCoreRefCountObject< BNDemangler >
std::atomic< int > m_refs
 
BNDemanglerm_object
 
- Protected Member Functions inherited from BinaryNinja::Demangler
 Demangler (const std::string &name)
 
 Demangler (BNDemangler *demangler)
 
virtual ~Demangler ()=default
 
- Static Protected Member Functions inherited from BinaryNinja::Demangler
static bool IsMangledStringCallback (void *ctxt, const char *name)
 
static bool DemangleCallback (void *ctxt, BNArchitecture *arch, const char *name, BNType **outType, BNQualifiedName *outVarName, BNBinaryView *view)
 
static void FreeVarNameCallback (void *ctxt, BNQualifiedName *name)
 

Constructor & Destructor Documentation

◆ CoreDemangler()

BinaryNinja::CoreDemangler::CoreDemangler ( BNDemangler * demangler)

◆ ~CoreDemangler()

virtual BinaryNinja::CoreDemangler::~CoreDemangler ( )
virtualdefault

Member Function Documentation

◆ IsMangledString()

bool BinaryNinja::CoreDemangler::IsMangledString ( const std::string & name)
virtual

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 to DemangleGeneric. Returning True from this does not require the demangler to succeed the call to Demangle, but simply implies that it may succeed.

Parameters
nameRaw mangled name string
Returns
True if the demangler thinks it can handle the name

Implements BinaryNinja::Demangler.

◆ Demangle()

bool BinaryNinja::CoreDemangler::Demangle ( Ref< Architecture > arch,
const std::string & name,
Ref< Type > & outType,
QualifiedName & outVarName,
Ref< BinaryView > view )
virtual

Demangle a raw name into a Type and QualifiedName.

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 IsMangledString), and then returns a value from this function will determine the result of a call to DemangleGeneric. 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 result with outType=nullptr, which will be accepted.

Parameters
archArchitecture for context in which the name exists, eg for pointer sizes
nameRaw mangled name
outTypeResulting type, if one can be deduced, will be written here. Otherwise nullptr will be written
outVarNameResulting variable name
view(Optional) BinaryView context in which the name exists, eg for type lookup
Returns
True if demangling was successful and results were stored into out-parameters

Implements BinaryNinja::Demangler.