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)
The workspace instance this plugin is associated with
Class Attributes
Human-readable name for the plugin. If None, uses the class name.
Whether this plugin requires a workspace to function
TOOLBAR_BUTTONS
list[tuple[QIcon, str]]
default:"[]"
List of toolbar buttons as (icon, tooltip) tuples
List of menu button text labels
List of custom column names for the functions view
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
The workspace instance (may be None if REQUIRE_WORKSPACE is False)
Methods
teardown
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.
The display name (DISPLAY_NAME if set, otherwise class name)
Generic Callbacks
status_bar_permanent_widgets() -> Generator | None
Yield widgets to add to the right side of the status bar.
Generator yielding QWidget instances, or None
on_workspace_initialized
on_workspace_initialized(workspace: Workspace) -> None
Called right after a workspace is initialized.
The initialized workspace
angrdb_store_entries
angrdb_store_entries() -> Generator | None
Yield key-value pairs to persist in angrDB.
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.
UI Callbacks
color_insn
color_insn(addr: int, selected: bool, disasm_view) -> QColor | None
Return custom background color for an instruction.
Whether the instruction is selected
Custom color, or None to use default
color_block
color_block(addr: int) -> QColor | None
Return custom background color for a basic block.
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.
Custom color, or None to use default
draw_insn
draw_insn(qinsn: QInstruction, painter: QPainter) -> None
Custom drawing for instructions.
QPainter for custom drawing
draw_block
draw_block(qblock: QBlock, painter: QPainter) -> None
Custom drawing for basic blocks.
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.
instrument_code_view
instrument_code_view(cview: CodeView) -> None
Called when a code/pseudocode view is created. Use to add custom functionality.
handle_click_insn
handle_click_insn(qinsn: QInstruction, event: QGraphicsSceneMouseEvent) -> bool
Handle mouse click on an instruction.
The clicked instruction widget
event
QGraphicsSceneMouseEvent
required
The mouse event
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.
event
QGraphicsSceneMouseEvent
required
The mouse event
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.
handle_click_toolbar(idx: int) -> None
Handle click on a toolbar button defined in TOOLBAR_BUTTONS.
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.
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.
Index of the column in FUNC_COLUMNS
Tuple of (sortable_data, rendered_string)
build_context_menu_insn(item: QInstruction) -> Iterable[None | tuple[str, Callable]]
Build context menu items for an instruction.
return
Iterable[None | tuple[str, Callable]]
Iterable of menu items. Use None for separators, or (text, callback) tuples.
build_context_menu_block(item: QBlock) -> Iterable[None | tuple[str, Callable]]
Build context menu items for a basic block.
return
Iterable[None | tuple[str, Callable]]
Iterable of menu items
build_context_menu_node(node) -> Iterable[None | tuple[str, Callable]]
Build context menu items for a graph node.
return
Iterable[None | tuple[str, Callable]]
Iterable of menu items
build_context_menu_functions(funcs: list[Function]) -> Iterable[None | tuple[str, Callable]]
Build context menu items for selected functions.
List of selected functions
return
Iterable[None | tuple[str, Callable]]
Iterable of menu items
build_context_menu_label(addr: int) -> Iterable[None | tuple[str, Callable]]
Build context menu items for a 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.
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.
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.
The function containing the variable
Stack offset of the variable
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(
address: int,
old_cmt: str,
new_cmt: str,
created: bool,
decomp: bool
) -> bool
Called when a comment is changed.
True if this is a new comment
True if this is a decompiler comment
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.
The function that was decompiled
handle_project_save
handle_project_save(file_name: str) -> None
Called when the project is saved.
Name of the saved project file
handle_project_initialization
handle_project_initialization() -> None
Called when a new project is loaded. Use for plugin initialization.