Loading...
Searching...
No Matches
BinaryNinja::Demangler Class Referenceabstract

Public Member Functions

std::string GetName () const
 
virtual bool IsMangledString (const std::string &name)=0
 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=nullptr)=0
 Demangle a raw name into a Type and QualifiedName.
 
- Public Member Functions inherited from BinaryNinja::StaticCoreRefCountObject< BNDemangler >
 StaticCoreRefCountObject ()
 
virtual ~StaticCoreRefCountObject ()
 
BNDemanglerGetObject () const
 
void AddRef ()
 
void Release ()
 
void AddRefForRegistration ()
 
void AddRefForCallback ()
 
void ReleaseForCallback ()
 

Static Public Member Functions

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)
 

Protected Member Functions

 Demangler (const std::string &name)
 
 Demangler (BNDemangler *demangler)
 
virtual ~Demangler ()=default
 

Static Protected Member Functions

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)
 

Additional Inherited Members

- Public Attributes inherited from BinaryNinja::StaticCoreRefCountObject< BNDemangler >
std::atomic< int > m_refs
 
BNDemanglerm_object
 

Constructor & Destructor Documentation

◆ Demangler() [1/2]

BinaryNinja::Demangler::Demangler ( const std::string & name)
explicitprotected

◆ Demangler() [2/2]

BinaryNinja::Demangler::Demangler ( BNDemangler * demangler)
protected

◆ ~Demangler()

virtual BinaryNinja::Demangler::~Demangler ( )
protectedvirtualdefault

Member Function Documentation

◆ IsMangledStringCallback()

bool BinaryNinja::Demangler::IsMangledStringCallback ( void * ctxt,
const char * name )
staticprotected

◆ DemangleCallback()

bool BinaryNinja::Demangler::DemangleCallback ( void * ctxt,
BNArchitecture * arch,
const char * name,
BNType ** outType,
BNQualifiedName * outVarName,
BNBinaryView * view )
staticprotected

◆ FreeVarNameCallback()

void BinaryNinja::Demangler::FreeVarNameCallback ( void * ctxt,
BNQualifiedName * name )
staticprotected

◆ Register()

void BinaryNinja::Demangler::Register ( Demangler * demangler)
static

Register a custom Demangler.

Newly registered demanglers will get priority over previously registered demanglers and built-in demanglers.

◆ GetList()

std::vector< Ref< Demangler > > BinaryNinja::Demangler::GetList ( )
static

Get the list of currently registered demanglers, sorted by lowest to highest priority.

Returns
List of demanglers

◆ GetByName()

Ref< Demangler > BinaryNinja::Demangler::GetByName ( const std::string & name)
static

◆ Promote()

void BinaryNinja::Demangler::Promote ( Ref< Demangler > demangler)
static

Promote a demangler to the highest-priority position.

Parameters
demanglerDemangler to promote

◆ GetName()

std::string BinaryNinja::Demangler::GetName ( ) const

◆ IsMangledString()

virtual bool BinaryNinja::Demangler::IsMangledString ( const std::string & name)
pure 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

Implemented in BinaryNinja::CoreDemangler.

◆ Demangle()

virtual bool BinaryNinja::Demangler::Demangle ( Ref< Architecture > arch,
const std::string & name,
Ref< Type > & outType,
QualifiedName & outVarName,
Ref< BinaryView > view = nullptr )
pure 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

Implemented in BinaryNinja::CoreDemangler.