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

ConstantRenderer allows custom rendering of constants in high level representations. More...

Detailed Description

ConstantRenderer allows custom rendering of constants in high level representations.

Public Member Functions

 ConstantRenderer (const std::string &name)
 ConstantRenderer (BNConstantRenderer *renderer)
std::string GetName () const
virtual bool IsValidForType (HighLevelILFunction *func, Type *type)
 Determines if the rendering methods should be called for the given expression type.
virtual bool RenderConstant (const HighLevelILInstruction &instr, Type *type, int64_t val, HighLevelILTokenEmitter &tokens, DisassemblySettings *settings, BNOperatorPrecedence precedence)
 Can be overridden to render a constant that is not a pointer.
virtual bool RenderConstantPointer (const HighLevelILInstruction &instr, Type *type, int64_t val, HighLevelILTokenEmitter &tokens, DisassemblySettings *settings, BNSymbolDisplayType symbolDisplay, BNOperatorPrecedence precedence)
 Can be overridden to render a constant pointer.
Public Member Functions inherited from BinaryNinja::StaticCoreRefCountObject< BNConstantRenderer >
 StaticCoreRefCountObject ()
virtual ~StaticCoreRefCountObject ()
BNConstantRendererGetObject () const
void AddRef ()
void Release ()
void AddRefForRegistration ()
void AddRefForCallback ()
void ReleaseForCallback ()

Static Public Member Functions

static void Register (ConstantRenderer *renderer)
 Registers the constant renderer.
static Ref< ConstantRendererGetByName (const std::string &name)
static std::vector< Ref< ConstantRenderer > > GetRenderers ()

Additional Inherited Members

Public Attributes inherited from BinaryNinja::StaticCoreRefCountObject< BNConstantRenderer >
std::atomic< int > m_refs
BNConstantRendererm_object

Constructor & Destructor Documentation

◆ ConstantRenderer() [1/2]

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

◆ ConstantRenderer() [2/2]

ConstantRenderer::ConstantRenderer ( BNConstantRenderer * renderer)

Member Function Documentation

◆ GetName()

string ConstantRenderer::GetName ( ) const

◆ IsValidForType()

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

Determines if the rendering methods 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 rendering methods.

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

Reimplemented in BinaryNinja::CoreConstantRenderer.

◆ RenderConstant()

bool ConstantRenderer::RenderConstant ( const HighLevelILInstruction & instr,
Type * type,
int64_t val,
HighLevelILTokenEmitter & tokens,
DisassemblySettings * settings,
BNOperatorPrecedence precedence )
virtual

Can be overridden to render a constant that is not a pointer.

The expression type and value of the expression are given. If the expression is not handled by this constant renderer, this method should return false

To render a constant, emit the tokens to the tokens object and return true

Parameters
instrHigh level expression
typeType of the expression
valValue of the expression
tokensToken emitter for adding the rendered tokens
settingsSettings for rendering
precedenceOperator precedence of the expression
Returns
true if the constant was rendered, false otherwise

Reimplemented in BinaryNinja::CoreConstantRenderer.

◆ RenderConstantPointer()

bool ConstantRenderer::RenderConstantPointer ( const HighLevelILInstruction & instr,
Type * type,
int64_t val,
HighLevelILTokenEmitter & tokens,
DisassemblySettings * settings,
BNSymbolDisplayType symbolDisplay,
BNOperatorPrecedence precedence )
virtual

Can be overridden to render a constant pointer.

The expression type and value of the expression are given. If the expression is not handled by this constant renderer, this method should return false

To render a constant, emit the tokens to the tokens object and return true

Parameters
instrHigh level expression
typeType of the expression
valValue of the expression
tokensToken emitter for adding the rendered tokens
settingsSettings for rendering
precedenceOperator precedence of the expression
Returns
true if the constant was rendered, false otherwise

Reimplemented in BinaryNinja::CoreConstantRenderer.

◆ Register()

void ConstantRenderer::Register ( ConstantRenderer * renderer)
static

Registers the constant renderer.

Parameters
rendererThe constant renderer to register.

◆ GetByName()

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

◆ GetRenderers()

vector< Ref< ConstantRenderer > > ConstantRenderer::GetRenderers ( )
static