datarender module

binaryninja.datarender.BinaryView([…]) class BinaryView implements a view on binary data, and presents a queryable interface of a binary file.
binaryninja.datarender.DataRenderer([context]) DataRenderer objects tell the Linear View how to render specific types.
binaryninja.datarender.DisassemblyTextLine(tokens)
binaryninja.datarender.FileMetadata([…]) class FileMetadata represents the file being analyzed by Binary Ninja.
binaryninja.datarender.InstructionTextToken(…) class InstructionTextToken is used to tell the core about the various components in the disassembly views.
binaryninja.datarender.Type(handle[, …])
binaryninja.datarender.log_error(text) log_error Logs message to console, if run through the GUI it logs with Error icon, focusing the error console.
class DataRenderer(context=None)[source]

Bases: object

DataRenderer objects tell the Linear View how to render specific types.

The perform_is_valid_for_data method returns a boolean to indicate if your derived class is able to render the type, given the addr and context. The context is a list of Type objects which represents the chain of nested objects that is being displayed.

The perform_get_lines_for_data method returns a list of DisassemblyTextLine objects each one representing a single line of Linear View output. The prefix variable is a list of InstructionTextToken’s which have already been generated by other DataRenderer’s.

After defining the DataRenderer subclass you must then register it with the core. This is done by calling either register_type_specific or register_generic. A “generic” type renderer is able to be overridden by a “type specific” renderer. For instance there is a generic struct render which renders any struct that hasn’t been explicitly overridden by a “type specific” renderer.

In the below example we create a data renderer that overrides the default display for struct BAR.

class BarDataRenderer(DataRenderer):
def __init__(self):
DataRenderer.__init__(self)
def perform_is_valid_for_data(self, ctxt, view, addr, type, context):
return DataRenderer.is_type_of_struct_name(type, “BAR”, context)
def perform_get_lines_for_data(self, ctxt, view, addr, type, prefix, width, context):
prefix.append(InstructionTextToken(InstructionTextTokenType.TextToken, “I’m in ur BAR”)) return [DisassemblyTextLine(prefix, addr)]
def __del__(self):
pass

BarDataRenderer().register_type_specific()

classmethod is_type_of_struct_name(type, name, context)[source]
perform_free_object(ctxt)[source]
perform_get_lines_for_data(ctxt, view, addr, type, prefix, width, context)[source]
perform_is_valid_for_data(ctxt, view, addr, type, context)[source]
register_generic()[source]
register_type_specific()[source]