Binary Ninja API C++: BinaryNinja::StringRecognizer Class Reference

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

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 ()
StringRecognizer::StringRecognizer ( const std::string & name)

◆ StringRecognizer() [2/2]

◆ GetName()

string StringRecognizer::GetName ( ) const

◆ IsValidForType()

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
Returns
true if the expression should be passed to the string recognizer, false otherwise

Reimplemented in BinaryNinja::CoreStringRecognizer.

◆ RecognizeConstant()

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()

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()

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()

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