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

StringRecognizer recognizes custom strings found in high level expressions. More...

Detailed Description

StringRecognizer recognizes custom strings found in high level expressions.

Public Member Functions

 StringRecognizer (const std::string &name)
 StringRecognizer (BNStringRecognizer *renderer)
std::string GetName () const
virtual bool IsValidForType (HighLevelILFunction *func, Type *type)
 Determines if the string recognizer should be called for the given expression type.
virtual std::optional< DerivedStringRecognizeConstant (const HighLevelILInstruction &instr, Type *type, int64_t val)
 Can be overridden to recognize strings for a constant that is not a pointer.
virtual std::optional< DerivedStringRecognizeConstantPointer (const HighLevelILInstruction &instr, Type *type, int64_t val)
 Can be overridden to recognize strings for a constant pointer.
virtual std::optional< DerivedStringRecognizeExternPointer (const HighLevelILInstruction &instr, Type *type, int64_t val, uint64_t offset)
 Can be overridden to recognize strings for an external symbol.
virtual std::optional< DerivedStringRecognizeImport (const HighLevelILInstruction &instr, Type *type, int64_t val)
 Can be overridden to recognize strings for an imported symbol.
Public Member Functions inherited from BinaryNinja::StaticCoreRefCountObject< BNStringRecognizer >
 StaticCoreRefCountObject ()
virtual ~StaticCoreRefCountObject ()
BNStringRecognizerGetObject () const
void AddRef ()
void Release ()
void AddRefForRegistration ()
void AddRefForCallback ()
void ReleaseForCallback ()

Static Public Member Functions

static void Register (StringRecognizer *recognizer)
 Registers the string recognizer.
static Ref< StringRecognizerGetByName (const std::string &name)
static std::vector< Ref< StringRecognizer > > GetRecognizers ()

Additional Inherited Members

Public Attributes inherited from BinaryNinja::StaticCoreRefCountObject< BNStringRecognizer >
std::atomic< int > m_refs
BNStringRecognizerm_object

Constructor & Destructor Documentation

◆ StringRecognizer() [1/2]

StringRecognizer::StringRecognizer ( const std::string & name)

◆ StringRecognizer() [2/2]

StringRecognizer::StringRecognizer ( BNStringRecognizer * renderer)

Member Function Documentation

◆ GetName()

string StringRecognizer::GetName ( ) const

◆ IsValidForType()

bool StringRecognizer::IsValidForType ( HighLevelILFunction * func,
Type * type )
virtual

Determines if the string recognizer should be called for the given expression type.

It is optional to override this method. If the method isn't overridden, all expression types are passed to the string recognizer.

Parameters
funcHighLevelILFunction representing the high level function to be queried
typeType of the expression
Returns
true if the expression should be passed to the string recognizer, false otherwise

Reimplemented in BinaryNinja::CoreStringRecognizer.

◆ RecognizeConstant()

std::optional< DerivedString > StringRecognizer::RecognizeConstant ( const HighLevelILInstruction & instr,
Type * type,
int64_t val )
virtual

Can be overridden to recognize strings for a constant that is not a pointer.

The expression type and value of the expression are given. If no string is found for this expression, this method should return std::nullopt

If a string is found, return a DerivedString with the string information.

Parameters
instrHigh level expression
typeType of the expression
valValue of the expression
Returns
Optional DerivedString for any string that is found

Reimplemented in BinaryNinja::CoreStringRecognizer.

◆ RecognizeConstantPointer()

std::optional< DerivedString > StringRecognizer::RecognizeConstantPointer ( const HighLevelILInstruction & instr,
Type * type,
int64_t val )
virtual

Can be overridden to recognize strings for a constant pointer.

The expression type and value of the expression are given. If no string is found for this expression, this method should return std::nullopt

If a string is found, return a DerivedString with the string information.

Parameters
instrHigh level expression
typeType of the expression
valValue of the expression
Returns
Optional DerivedString for any string that is found

Reimplemented in BinaryNinja::CoreStringRecognizer.

◆ RecognizeExternPointer()

std::optional< DerivedString > StringRecognizer::RecognizeExternPointer ( const HighLevelILInstruction & instr,
Type * type,
int64_t val,
uint64_t offset )
virtual

Can be overridden to recognize strings for an external symbol.

The expression type and value of the expression are given. If no string is found for this expression, this method should return std::nullopt

If a string is found, return a DerivedString with the string information.

Parameters
instrHigh level expression
typeType of the expression
valValue of the expression
offsetOffset into the external symbol
Returns
Optional DerivedString for any string that is found

Reimplemented in BinaryNinja::CoreStringRecognizer.

◆ RecognizeImport()

std::optional< DerivedString > StringRecognizer::RecognizeImport ( const HighLevelILInstruction & instr,
Type * type,
int64_t val )
virtual

Can be overridden to recognize strings for an imported symbol.

The expression type and value of the expression are given. If no string is found for this expression, this method should return std::nullopt

If a string is found, return a DerivedString with the string information.

Parameters
instrHigh level expression
typeType of the expression
valValue of the expression
Returns
Optional DerivedString for any string that is found

Reimplemented in BinaryNinja::CoreStringRecognizer.

◆ Register()

void StringRecognizer::Register ( StringRecognizer * recognizer)
static

Registers the string recognizer.

Parameters
recognizerThe string recognizer to register.

◆ GetByName()

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

◆ GetRecognizers()

vector< Ref< StringRecognizer > > StringRecognizer::GetRecognizers ( )
static