Skip to main content

BasePlugin

The BasePlugin class is the base class for all angr management plugins. Plugins can extend the functionality of angr management by adding custom views, UI elements, analyses, and more.

Constructor

BasePlugin(workspace: Workspace)
workspace
Workspace
required
The workspace instance this plugin is associated with

Class Attributes

DISPLAY_NAME
str | None
Human-readable name for the plugin. If None, uses the class name.
REQUIRE_WORKSPACE
bool
default:"True"
Whether this plugin requires a workspace to function
TOOLBAR_BUTTONS
list[tuple[QIcon, str]]
default:"[]"
List of toolbar buttons as (icon, tooltip) tuples
MENU_BUTTONS
list[str]
default:"[]"
List of menu button text labels
FUNC_COLUMNS
list[str]
default:"[]"
List of custom column names for the functions view
URL_ACTIONS
list[str]
default:"[]"
List of custom URL actions this plugin handles
CONFIG_ENTRIES
list[ConfigurationEntry]
default:"[]"
Custom configuration entries for this plugin
OPTIMIZATION_PASSES
list[tuple[type[OptimizationPass], bool]]
default:"[]"
Decompiler optimization passes as (pass_class, enabled) tuples

Properties

workspace
Workspace | None
The workspace instance (may be None if REQUIRE_WORKSPACE is False)

Methods

teardown

teardown() -> None
Clean up plugin resources. Called when the plugin is being unloaded.

get_display_name

@classmethod
get_display_name(cls) -> str
Get the display name for this plugin.
return
str
The display name (DISPLAY_NAME if set, otherwise class name)

Generic Callbacks

status_bar_permanent_widgets

status_bar_permanent_widgets() -> Generator | None
Yield widgets to add to the right side of the status bar.
return
Generator | None
Generator yielding QWidget instances, or None

on_workspace_initialized

on_workspace_initialized(workspace: Workspace) -> None
Called right after a workspace is initialized.
workspace
Workspace
required
The initialized workspace

angrdb_store_entries

angrdb_store_entries() -> Generator | None
Yield key-value pairs to persist in angrDB.
return
Generator | None
Generator yielding (key, value) tuples, or None

angrdb_load_entry

angrdb_load_entry(key: str, value: str) -> None
Called for each persisted entry loaded from angrDB.
key
str
required
The entry key
value
str
required
The entry value

UI Callbacks

color_insn

color_insn(addr: int, selected: bool, disasm_view) -> QColor | None
Return custom background color for an instruction.
addr
int
required
Instruction address
selected
bool
required
Whether the instruction is selected
disasm_view
DisassemblyView
required
The disassembly view
return
QColor | None
Custom color, or None to use default

color_block

color_block(addr: int) -> QColor | None
Return custom background color for a basic block.
addr
int
required
Block address
return
QColor | None
Custom color, or None to use default

color_func

color_func(func: Function) -> QColor | None
Return custom color for a function in the functions view.
func
Function
required
The function
return
QColor | None
Custom color, or None to use default

draw_insn

draw_insn(qinsn: QInstruction, painter: QPainter) -> None
Custom drawing for instructions.
qinsn
QInstruction
required
The instruction widget
painter
QPainter
required
QPainter for custom drawing

draw_block

draw_block(qblock: QBlock, painter: QPainter) -> None
Custom drawing for basic blocks.
qblock
QBlock
required
The block widget
painter
QPainter
required
QPainter for custom drawing

instrument_disassembly_view

instrument_disassembly_view(dview: DisassemblyView) -> None
Called when a disassembly view is created. Use to add custom functionality.
dview
DisassemblyView
required
The disassembly view

instrument_code_view

instrument_code_view(cview: CodeView) -> None
Called when a code/pseudocode view is created. Use to add custom functionality.
cview
CodeView
required
The code view

handle_click_insn

handle_click_insn(qinsn: QInstruction, event: QGraphicsSceneMouseEvent) -> bool
Handle mouse click on an instruction.
qinsn
QInstruction
required
The clicked instruction widget
event
QGraphicsSceneMouseEvent
required
The mouse event
return
bool
True if the event was handled (prevents default behavior), False otherwise

handle_click_block

handle_click_block(qblock: QBlock, event: QGraphicsSceneMouseEvent) -> bool
Handle mouse click on a basic block.
qblock
QBlock
required
The clicked block widget
event
QGraphicsSceneMouseEvent
required
The mouse event
return
bool
True if the event was handled, False otherwise

handle_raise_view

handle_raise_view(view: BaseView) -> None
Called when a view is raised to the front.
view
BaseView
required
The view being raised

handle_click_toolbar

handle_click_toolbar(idx: int) -> None
Handle click on a toolbar button defined in TOOLBAR_BUTTONS.
idx
int
required
Index of the clicked button in TOOLBAR_BUTTONS

handle_click_menu

handle_click_menu(idx: int) -> None
Handle click on a menu button defined in MENU_BUTTONS.
idx
int
required
Index of the clicked menu item in MENU_BUTTONS

extract_func_column

extract_func_column(func: Function, idx: int) -> tuple[Any, str]
Extract data for a custom function column.
func
Function
required
The function
idx
int
required
Index of the column in FUNC_COLUMNS
return
tuple[Any, str]
Tuple of (sortable_data, rendered_string)

Context Menu Callbacks

build_context_menu_insn

build_context_menu_insn(item: QInstruction) -> Iterable[None | tuple[str, Callable]]
Build context menu items for an instruction.
item
QInstruction
required
The instruction widget
return
Iterable[None | tuple[str, Callable]]
Iterable of menu items. Use None for separators, or (text, callback) tuples.

build_context_menu_block

build_context_menu_block(item: QBlock) -> Iterable[None | tuple[str, Callable]]
Build context menu items for a basic block.
item
QBlock
required
The block widget
return
Iterable[None | tuple[str, Callable]]
Iterable of menu items

build_context_menu_node

build_context_menu_node(node) -> Iterable[None | tuple[str, Callable]]
Build context menu items for a graph node.
node
required
The graph node
return
Iterable[None | tuple[str, Callable]]
Iterable of menu items

build_context_menu_functions

build_context_menu_functions(funcs: list[Function]) -> Iterable[None | tuple[str, Callable]]
Build context menu items for selected functions.
funcs
list[Function]
required
List of selected functions
return
Iterable[None | tuple[str, Callable]]
Iterable of menu items

build_context_menu_label

build_context_menu_label(addr: int) -> Iterable[None | tuple[str, Callable]]
Build context menu items for a label.
addr
int
required
Address of the label
return
Iterable[None | tuple[str, Callable]]
Iterable of menu items

build_qblock_annotations

build_qblock_annotations(qblock: QBlock) -> Iterable[QInstructionAnnotation]
Build custom annotations for a basic block.
qblock
QBlock
required
The block widget
return
Iterable[QInstructionAnnotation]
Iterable of annotation widgets

handle_url_action

handle_url_action(action: str, kwargs: dict) -> None
Handle a custom URL action defined in URL_ACTIONS.
action
str
required
The action name
kwargs
dict
required
Arguments for the action

step_callback

step_callback(simgr: SimulationManager) -> None
Called after each step in symbolic execution.
simgr
SimulationManager
required
The simulation manager that stepped

Decompiler Callbacks

handle_stack_var_renamed

handle_stack_var_renamed(func: Function, offset: int, old_name: str, new_name: str) -> bool
Called when a stack variable is renamed.
func
Function
required
The function containing the variable
offset
int
required
Stack offset of the variable
old_name
str
required
Previous name
new_name
str
required
New name
return
bool
True if handled, False otherwise

handle_stack_var_retyped

handle_stack_var_retyped(func: Function, offset: int, old_type, new_type) -> bool
Called when a stack variable’s type is changed.

handle_func_arg_renamed

handle_func_arg_renamed(func: Function, offset: int, old_name: str, new_name: str) -> bool
Called when a function argument is renamed.

handle_func_arg_retyped

handle_func_arg_retyped(func: Function, offset: int, old_type, new_type) -> bool
Called when a function argument’s type is changed.

handle_global_var_renamed

handle_global_var_renamed(address: int, old_name: str, new_name: str) -> bool
Called when a global variable is renamed.

handle_global_var_retyped

handle_global_var_retyped(address: int, old_type, new_type) -> bool
Called when a global variable’s type is changed.

handle_other_var_renamed

handle_other_var_renamed(var, old_name: str, new_name: str) -> bool
Called when any other variable is renamed.

handle_other_var_retyped

handle_other_var_retyped(var, old_type, new_type) -> bool
Called when any other variable’s type is changed.

handle_function_renamed

handle_function_renamed(func: Function, old_name: str, new_name: str) -> bool
Called when a function is renamed.

handle_function_retyped

handle_function_retyped(func: Function, old_type, new_type) -> bool
Called when a function’s type signature is changed.

handle_comment_changed

handle_comment_changed(
    address: int,
    old_cmt: str,
    new_cmt: str,
    created: bool,
    decomp: bool
) -> bool
Called when a comment is changed.
address
int
required
Address of the comment
old_cmt
str
required
Previous comment text
new_cmt
str
required
New comment text
created
bool
required
True if this is a new comment
decomp
bool
required
True if this is a decompiler comment
return
bool
True if handled, False otherwise

handle_struct_changed

handle_struct_changed(old_struct, new_struct) -> bool
Called when a struct definition is changed.

decompile_callback

decompile_callback(func: Function) -> None
Called right after a function is decompiled.
func
Function
required
The function that was decompiled

handle_project_save

handle_project_save(file_name: str) -> None
Called when the project is saved.
file_name
str
required
Name of the saved project file

handle_project_initialization

handle_project_initialization() -> None
Called when a new project is loaded. Use for plugin initialization.

Build docs developers (and LLMs) love