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

RenderLayer is a plugin class that allows you to customize the presentation of Linear and Graph view output, adding, changing, or removing lines before they are presented in the UI. More...

Detailed Description

RenderLayer is a plugin class that allows you to customize the presentation of Linear and Graph view output, adding, changing, or removing lines before they are presented in the UI.

Public Member Functions

std::string GetName () const
 Get the name of a Render Layer.
 
BNRenderLayerDefaultEnableState GetDefaultEnableState () const
 Get whether the Render Layer is enabled by default.
 
virtual void ApplyToDisassemblyBlock (Ref< BasicBlock > block, std::vector< DisassemblyTextLine > &lines)
 Apply this Render Layer to a single Basic Block of Disassembly lines.
 
virtual void ApplyToLowLevelILBlock (Ref< BasicBlock > block, std::vector< DisassemblyTextLine > &lines)
 Apply this Render Layer to a single Basic Block of Low Level IL lines.
 
virtual void ApplyToMediumLevelILBlock (Ref< BasicBlock > block, std::vector< DisassemblyTextLine > &lines)
 Apply this Render Layer to a single Basic Block of Medium Level IL lines.
 
virtual void ApplyToHighLevelILBlock (Ref< BasicBlock > block, std::vector< DisassemblyTextLine > &lines)
 Apply this Render Layer to a single Basic Block of High Level IL lines.
 
virtual void ApplyToHighLevelILBody (Ref< Function > function, std::vector< LinearDisassemblyLine > &lines)
 Apply this Render Layer to the entire body of a High Level IL function.
 
virtual void ApplyToMiscLinearLines (Ref< LinearViewObject > obj, Ref< LinearViewObject > prev, Ref< LinearViewObject > next, std::vector< LinearDisassemblyLine > &lines)
 Apply to lines generated by Linear View that are not part of a function.
 
virtual void ApplyToBlock (Ref< BasicBlock > block, std::vector< DisassemblyTextLine > &lines)
 Apply to lines generated by a Basic Block, of any type.
 
virtual void ApplyToFlowGraph (Ref< FlowGraph > graph)
 Apply this Render Layer to a Flow Graph, potentially modifying its nodes, their edges, their lines, and their lines' content.
 
virtual void ApplyToLinearViewObject (Ref< LinearViewObject > obj, Ref< LinearViewObject > prev, Ref< LinearViewObject > next, std::vector< LinearDisassemblyLine > &lines)
 Apply this Render Layer to the lines produced by a LinearViewObject for rendering in Linear View, potentially modifying the lines and their contents.
 
- Public Member Functions inherited from BinaryNinja::StaticCoreRefCountObject< BNRenderLayer >
 StaticCoreRefCountObject ()
 
virtual ~StaticCoreRefCountObject ()
 
BNRenderLayerGetObject () const
 
void AddRef ()
 
void Release ()
 
void AddRefForRegistration ()
 
void AddRefForCallback ()
 
void ReleaseForCallback ()
 

Static Public Member Functions

static void Register (RenderLayer *layer, BNRenderLayerDefaultEnableState enableState=DisabledByDefaultRenderLayerDefaultEnableState)
 Register a custom Render Layer.
 
static std::vector< Ref< RenderLayer > > GetList ()
 Get the list of all currently registered Render Layers.
 
static Ref< RenderLayerGetByName (const std::string &name)
 Look up a Render Layer by its name.
 
- Static Public Member Functions inherited from BinaryNinja::StaticCoreRefCountObject< BNRenderLayer >
static BNRenderLayerGetObject (StaticCoreRefCountObject *obj)
 

Protected Member Functions

 RenderLayer (const std::string &name)
 
 RenderLayer (BNRenderLayer *layer)
 
virtual ~RenderLayer ()=default
 

Static Protected Member Functions

static void ApplyToFlowGraphCallback (void *ctxt, BNFlowGraph *graph)
 
static void ApplyToLinearViewObjectCallback (void *ctxt, BNLinearViewObject *obj, BNLinearViewObject *prev, BNLinearViewObject *next, BNLinearDisassemblyLine *inLines, size_t inLineCount, BNLinearDisassemblyLine **outLines, size_t *outLineCount)
 
static void FreeLinesCallback (void *ctxt, BNLinearDisassemblyLine *lines, size_t count)
 

Additional Inherited Members

- Public Attributes inherited from BinaryNinja::StaticCoreRefCountObject< BNRenderLayer >
std::atomic< int > m_refs
 
BNRenderLayerm_object
 

Constructor & Destructor Documentation

◆ RenderLayer() [1/2]

RenderLayer::RenderLayer ( const std::string & name)
explicitprotected

◆ RenderLayer() [2/2]

RenderLayer::RenderLayer ( BNRenderLayer * layer)
protected

◆ ~RenderLayer()

virtual BinaryNinja::RenderLayer::~RenderLayer ( )
protectedvirtualdefault

Member Function Documentation

◆ ApplyToFlowGraphCallback()

void RenderLayer::ApplyToFlowGraphCallback ( void * ctxt,
BNFlowGraph * graph )
staticprotected

◆ ApplyToLinearViewObjectCallback()

void RenderLayer::ApplyToLinearViewObjectCallback ( void * ctxt,
BNLinearViewObject * obj,
BNLinearViewObject * prev,
BNLinearViewObject * next,
BNLinearDisassemblyLine * inLines,
size_t inLineCount,
BNLinearDisassemblyLine ** outLines,
size_t * outLineCount )
staticprotected

◆ FreeLinesCallback()

void RenderLayer::FreeLinesCallback ( void * ctxt,
BNLinearDisassemblyLine * lines,
size_t count )
staticprotected

◆ Register()

void RenderLayer::Register ( RenderLayer * layer,
BNRenderLayerDefaultEnableState enableState = DisabledByDefaultRenderLayerDefaultEnableState )
static

Register a custom Render Layer.

Specify enableState to change whether the layer is enabled by default in the UI. If it is set to AlwaysEnabled, the Render Layer will always be enabled and will not be displayed in the UI.

Parameters
layerRender Layer to register
enableStateWhether the layer should be enabled by default

◆ GetList()

std::vector< Ref< RenderLayer > > RenderLayer::GetList ( )
static

Get the list of all currently registered Render Layers.

Returns
List of Render Layers

◆ GetByName()

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

Look up a Render Layer by its name.

Parameters
nameName of Render Layer
Returns
Render Layer, if it exists. Otherwise, nullptr.

◆ GetName()

std::string RenderLayer::GetName ( ) const

Get the name of a Render Layer.

Returns
Render Layer's name

◆ GetDefaultEnableState()

BNRenderLayerDefaultEnableState RenderLayer::GetDefaultEnableState ( ) const

Get whether the Render Layer is enabled by default.

Returns
Default enable state

◆ ApplyToDisassemblyBlock()

virtual void BinaryNinja::RenderLayer::ApplyToDisassemblyBlock ( Ref< BasicBlock > block,
std::vector< DisassemblyTextLine > & lines )
inlinevirtual

Apply this Render Layer to a single Basic Block of Disassembly lines.

Subclasses should modify the input `lines` list to make modifications to the presentation of the block.

Note
This function will only handle Disassembly lines, and not any ILs.
Parameters
blockBasic Block containing those lines
linesLines of text for the block, to be modified by this function

◆ ApplyToLowLevelILBlock()

virtual void BinaryNinja::RenderLayer::ApplyToLowLevelILBlock ( Ref< BasicBlock > block,
std::vector< DisassemblyTextLine > & lines )
inlinevirtual

Apply this Render Layer to a single Basic Block of Low Level IL lines.

Subclasses should modify the input `lines` list to make modifications to the presentation of the block.

Note
This function will only handle Lifted IL/LLIL/LLIL(SSA) lines. You can use the block's `function_graph_type` property to determine which is being handled.
Parameters
blockBasic Block containing those lines
linesLines of text for the block, to be modified by this function

◆ ApplyToMediumLevelILBlock()

virtual void BinaryNinja::RenderLayer::ApplyToMediumLevelILBlock ( Ref< BasicBlock > block,
std::vector< DisassemblyTextLine > & lines )
inlinevirtual

Apply this Render Layer to a single Basic Block of Medium Level IL lines.

Subclasses should modify the input `lines` list to make modifications to the presentation of the block.

Note
This function will only handle MLIL/MLIL(SSA)/Mapped MLIL/Mapped MLIL(SSA) lines. You can use the block's `function_graph_type` property to determine which is being handled.
Parameters
blockBasic Block containing those lines
linesLines of text for the block, to be modified by this function

◆ ApplyToHighLevelILBlock()

virtual void BinaryNinja::RenderLayer::ApplyToHighLevelILBlock ( Ref< BasicBlock > block,
std::vector< DisassemblyTextLine > & lines )
inlinevirtual

Apply this Render Layer to a single Basic Block of High Level IL lines.

Subclasses should modify the input `lines` list to make modifications to the presentation of the block.

Note
This function will only handle HLIL/HLIL(SSA)/Language Representation lines. You can use the block's `function_graph_type` property to determine which is being handled.
Warning
This function will NOT apply to High Level IL bodies as displayed in Linear View! Those are handled by `ApplyToHighLevelILBody` instead as they do not have a Basic Block associated with them.
Parameters
blockBasic Block containing those lines
linesLines of text for the block, to be modified by this function

◆ ApplyToHighLevelILBody()

virtual void BinaryNinja::RenderLayer::ApplyToHighLevelILBody ( Ref< Function > function,
std::vector< LinearDisassemblyLine > & lines )
inlinevirtual

Apply this Render Layer to the entire body of a High Level IL function.

Subclasses should modify the input `lines` list to make modifications to the presentation of the function.

Warning
This function only applies to Linear View, and not to Graph View! If you want to handle Graph View too, you will need to use `ApplyToHighLevelILBlock` and handle the lines one block at a time.
Parameters
functionFunction containing those lines
linesLines of text for the function, to be modified by this function

◆ ApplyToMiscLinearLines()

virtual void BinaryNinja::RenderLayer::ApplyToMiscLinearLines ( Ref< LinearViewObject > obj,
Ref< LinearViewObject > prev,
Ref< LinearViewObject > next,
std::vector< LinearDisassemblyLine > & lines )
inlinevirtual

Apply to lines generated by Linear View that are not part of a function.

It is up to your implementation to figure out which type of Linear View Object lines these are, and what to do with them.

Parameters
objLinear View Object being rendered
prevLinear View Object located directly above this one
nextLinear View Object located directly below this one
linesLines rendered by `obj`, to be modified by this function

◆ ApplyToBlock()

void RenderLayer::ApplyToBlock ( Ref< BasicBlock > block,
std::vector< DisassemblyTextLine > & lines )
virtual

Apply to lines generated by a Basic Block, of any type.

If not overridden, this function will call the appropriate ApplyToXLevelILBlock function.

Parameters
blockBasic Block containing those lines
linesLines of text for the block, to be modified by this function

◆ ApplyToFlowGraph()

void RenderLayer::ApplyToFlowGraph ( Ref< FlowGraph > graph)
virtual

Apply this Render Layer to a Flow Graph, potentially modifying its nodes, their edges, their lines, and their lines' content.

Note
If you override this function, you will need to call the parent implementation if you want to use the higher level ApplyToXLevelILBlock functionality.
Parameters
graphGraph to modify

Reimplemented in BinaryNinja::CoreRenderLayer.

◆ ApplyToLinearViewObject()

void RenderLayer::ApplyToLinearViewObject ( Ref< LinearViewObject > obj,
Ref< LinearViewObject > prev,
Ref< LinearViewObject > next,
std::vector< LinearDisassemblyLine > & lines )
virtual

Apply this Render Layer to the lines produced by a LinearViewObject for rendering in Linear View, potentially modifying the lines and their contents.

Note
If you override this function, you will need to call the parent implementation if you want to use the higher level ApplyToXLevelILBlock functionality.
Parameters
objLinear View Object being rendered
prevLinear View Object located directly above this one
nextLinear View Object located directly below this one
linesLines originally rendered by the Linear View Object
Returns
Updated set of lines to display in Linear View

Reimplemented in BinaryNinja::CoreRenderLayer.