constantrenderer module

Class

Description

binaryninja.constantrenderer.ConstantRenderer

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

binaryninja.constantrenderer.CoreConstantRenderer

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

ConstantRenderer

class ConstantRenderer[source]

Bases: object

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

The render_constant method will be called when rendering constants that aren’t pointers, while the render_constant_pointer method will be called when rendering constant pointers. The is_valid_for_type method can be optionally overridden to call the rendering methods only when the expression type matches a custom filter.

__init__(handle=None)[source]
is_valid_for_type(func: HighLevelILFunction, type: Type) bool[source]

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:
  • func (HighLevelILFunction) – HighLevelILFunction representing the high level function to be rendered

  • type (Type) – Type of the expression

Returns:

True if the constant should be passed to the rendering methods, False otherwise

Return type:

bool

register()[source]

Registers the constant renderer.

render_constant(instr: HighLevelILInstruction, type: Type, val: int, tokens: HighLevelILTokenEmitter, settings: DisassemblySettings | None, precedence: OperatorPrecedence) bool[source]

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:
Returns:

True if the constant was rendered, False otherwise

Return type:

bool

render_constant_pointer(instr: HighLevelILInstruction, type: Type, val: int, tokens: HighLevelILTokenEmitter, settings: DisassemblySettings | None, symbol_display: SymbolDisplayType, precedence: OperatorPrecedence) bool[source]

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 pointer, emit the tokens to the tokens object and return True.

Parameters:
Returns:

True if the constant was rendered, False otherwise

Return type:

bool

property name: str
renderer_name = None

CoreConstantRenderer

class CoreConstantRenderer[source]

Bases: ConstantRenderer

__init__(handle: BNConstantRenderer)[source]
Parameters:

handle (BNConstantRenderer) –

is_valid_for_type(func: HighLevelILFunction, type: Type) bool[source]

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:
  • func (HighLevelILFunction) – HighLevelILFunction representing the high level function to be rendered

  • type (Type) – Type of the expression

Returns:

True if the constant should be passed to the rendering methods, False otherwise

Return type:

bool

render_constant(instr: HighLevelILInstruction, type: Type, val: int, tokens: HighLevelILTokenEmitter, settings: DisassemblySettings | None, precedence: OperatorPrecedence) bool[source]

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:
Returns:

True if the constant was rendered, False otherwise

Return type:

bool

render_constant_pointer(instr: HighLevelILInstruction, type: Type, val: int, tokens: HighLevelILTokenEmitter, settings: DisassemblySettings | None, symbol_display: SymbolDisplayType, precedence: OperatorPrecedence) bool[source]

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 pointer, emit the tokens to the tokens object and return True.

Parameters:
Returns:

True if the constant was rendered, False otherwise

Return type:

bool