plugin module

binaryninja.plugin.BackgroundTask([...])

The BackgroundTask class provides a mechanism for reporting progress of an optionally cancelable task to the user via the status bar in the UI.

binaryninja.plugin.BackgroundTaskThread([...])

The BackgroundTaskThread class provides an all-in-one solution for executing a BackgroundTask in a thread.

binaryninja.plugin.MainThreadAction(handle)

binaryninja.plugin.MainThreadActionHandler()

binaryninja.plugin.PluginCommand(cmd)

The class PluginCommand contains all the plugin registration methods as class methods.

binaryninja.plugin.PluginCommandContext(view)

class BackgroundTask(initial_progress_text='', can_cancel=False, handle=None)[source]

Bases: object

The BackgroundTask class provides a mechanism for reporting progress of an optionally cancelable task to the user via the status bar in the UI. If can_cancel is is True, then the task can be cancelled either programmatically (via cancel) or by the user via the UI.

Note this class does not provide a means to execute a task, which is available via the BackgroundTaskThread class.

Parameters:
  • initial_progress_text – text description of the task to display in the status bar in the UI, defaults to “”

  • can_cancel – whether to enable cancellation of the task, defaults to False

cancel()[source]
finish()[source]
property can_cancel

Whether the task can be cancelled (read-only)

property cancelled

Whether the task has been cancelled

property finished

Whether the task has finished

property progress

Text description of the progress of the background task (displayed in status bar of the UI)

class BackgroundTaskThread(initial_progress_text: str = '', can_cancel: bool = False)[source]

Bases: BackgroundTask

The BackgroundTaskThread class provides an all-in-one solution for executing a BackgroundTask in a thread.

See the BackgroundTask for additional information.

Parameters:
  • initial_progress_text (str) – text description of the task to display in the status bar in the UI, defaults to “”

  • can_cancel (bool) – whether to enable cancellation of the task, defaults to False

join(timeout=None)[source]
run()[source]
start()[source]
class MainThreadAction(handle)[source]

Bases: object

execute()[source]
wait()[source]
property done
class MainThreadActionHandler[source]

Bases: object

add_action(action)[source]
register()[source]
class PluginCommand(cmd)[source]

Bases: object

The class PluginCommand contains all the plugin registration methods as class methods.

You shouldn’t need to create an instance of this class, instead see register, register_for_address, register_for_function, and similar class methods for examples on how to register your plugin.

execute(context)[source]

execute Execute a Plugin

Parameters:

context (str) – PluginCommandContext to pass the PluginCommand

Return type:

None

>>> ctx = PluginCommandContext(bv);
>>> PluginCommand.get_valid_list(ctx)[r'PDB\Load'].execute(ctx)

classmethod get_valid_list(context)[source]

Dict of registered plugins

is_valid(context)[source]
classmethod register(name: str, description: str, action: Callable[[BinaryView], None], is_valid: Callable[[BinaryView], bool] | None = None)[source]

register Register a plugin

Parameters:
  • name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)

  • description (str) – description of the plugin

  • action (callback) – function to call with the BinaryView as an argument

  • is_valid (callback) – optional argument of a function passed a BinaryView to determine whether the plugin should be enabled for that view

Return type:

None

Example:
>>> def my_plugin(bv: BinaryView):
>>>     log_info(f"My plugin was called on bv: `{bv}`")
>>> PluginCommand.register("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView) -> bool:
>>>     return False
>>> PluginCommand.register("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True

Warning

Calling register with the same function name will replace the existing function but will leak the memory of the original plugin.

classmethod register_for_address(name: str, description: str, action: Callable[[BinaryView, int], None], is_valid: Callable[[BinaryView, int], bool] | None = None)[source]

register_for_address Register a plugin to be called with an address argument

Parameters:
  • name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)

  • description (str) – description of the plugin

  • action (callback) – function to call with the BinaryView and address as arguments

  • is_valid (callback) – optional argument of a function passed a BinaryView and address to determine whether the plugin should be enabled for that view

Return type:

None

Example:
>>> def my_plugin(bv: BinaryView, address: int):
>>>     log_info(f"My plugin was called on bv: `{bv}` at address {hex(address)}")
>>> PluginCommand.register_for_address("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView, address: int) -> bool:
>>>     return False
>>> PluginCommand.register_for_address("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True

Warning

Calling register_for_address with the same function name will replace the existing function but will leak the memory of the original plugin.

classmethod register_for_function(name: str, description: str, action: Callable[[BinaryView, Function], None], is_valid: Callable[[BinaryView, Function], bool] | None = None)[source]

register_for_function Register a plugin to be called with a function argument

Parameters:
  • name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)

  • description (str) – description of the plugin

  • action (callback) – function to call with the BinaryView and a Function as arguments

  • is_valid (callback) – optional argument of a function passed a BinaryView and Function to determine whether the plugin should be enabled for that view

Return type:

None

Example:
>>> def my_plugin(bv: BinaryView, func: Function):
>>>     log_info(f"My plugin was called on func {func} in bv `{bv}`")
>>> PluginCommand.register_for_function("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView, func: Function) -> bool:
>>>     return False
>>> PluginCommand.register_for_function("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True

Warning

Calling register_for_function with the same function name will replace the existing function but will leak the memory of the original plugin.

classmethod register_for_high_level_il_function(name: str, description: str, action: Callable[[BinaryView, HighLevelILFunction], None], is_valid: Callable[[BinaryView, HighLevelILFunction], bool] | None = None)[source]

register_for_high_level_il_function Register a plugin to be called with a high level IL function argument

Parameters:
  • name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)

  • description (str) – description of the plugin

  • action (callback) – function to call with the BinaryView and a HighLevelILFunction as arguments

  • is_valid (callback) – optional argument of a function passed a BinaryView and HighLevelILFunction to determine whether the plugin should be enabled for that view

Return type:

None

Example:
>>> def my_plugin(bv: BinaryView, func: HighLevelILFunction):
>>>     log_info(f"My plugin was called on func {func} in bv `{bv}`")
>>> PluginCommand.register_for_low_level_il_function("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView, func: HighLevelILFunction) -> bool:
>>>     return False
>>> PluginCommand.register_for_low_level_il_function("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True

Warning

Calling register_for_high_level_il_function with the same function name will replace the existing function but will leak the memory of the original plugin.

classmethod register_for_high_level_il_instruction(name: str, description: str, action: Callable[[BinaryView, HighLevelILInstruction], None], is_valid: Callable[[BinaryView, HighLevelILInstruction], bool] | None = None)[source]

register_for_high_level_il_instruction Register a plugin to be called with a high level IL instruction argument

Parameters:
  • name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)

  • description (str) – description of the plugin

  • action (callback) – function to call with the BinaryView and a HighLevelILInstruction as arguments

  • is_valid (callback) – optional argument of a function passed a BinaryView and HighLevelILInstruction to determine whether the plugin should be enabled for that view

Return type:

None

Example:
>>> def my_plugin(bv: BinaryView, inst: HighLevelILInstruction):
>>>     log_info(f"My plugin was called on inst {inst} in bv `{bv}`")
>>> PluginCommand.register_for_low_level_il_instruction("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView, inst: HighLevelILInstruction) -> bool:
>>>     return False
>>> PluginCommand.register_for_low_level_il_instruction("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True

Warning

Calling register_for_high_level_il_instruction with the same function name will replace the existing function but will leak the memory of the original plugin.

classmethod register_for_low_level_il_function(name: str, description: str, action: Callable[[BinaryView, LowLevelILFunction], None], is_valid: Callable[[BinaryView, LowLevelILFunction], bool] | None = None)[source]

register_for_low_level_il_function Register a plugin to be called with a low level IL function argument

Parameters:
  • name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)

  • description (str) – description of the plugin

  • action (callback) – function to call with the BinaryView and a LowLevelILFunction as arguments

  • is_valid (callback) – optional argument of a function passed a BinaryView and LowLevelILFunction to determine whether the plugin should be enabled for that view

Return type:

None

Example:
>>> def my_plugin(bv: BinaryView, func: LowLevelILFunction):
>>>     log_info(f"My plugin was called on func {func} in bv `{bv}`")
>>> PluginCommand.register_for_low_level_il_function("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView, func: LowLevelILFunction) -> bool:
>>>     return False
>>> PluginCommand.register_for_low_level_il_function("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True

Warning

Calling register_for_low_level_il_function with the same function name will replace the existing function but will leak the memory of the original plugin.

classmethod register_for_low_level_il_instruction(name: str, description: str, action: Callable[[BinaryView, LowLevelILInstruction], None], is_valid: Callable[[BinaryView, LowLevelILInstruction], bool] | None = None)[source]

register_for_low_level_il_instruction Register a plugin to be called with a low level IL instruction argument

Parameters:
  • name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)

  • description (str) – description of the plugin

  • action (callback) – function to call with the BinaryView and a LowLevelILInstruction as arguments

  • is_valid (callback) – optional argument of a function passed a BinaryView and LowLevelILInstruction to determine whether the plugin should be enabled for that view

Return type:

None

Example:
>>> def my_plugin(bv: BinaryView, inst: LowLevelILInstruction):
>>>     log_info(f"My plugin was called on inst {inst} in bv `{bv}`")
>>> PluginCommand.register_for_low_level_il_instruction("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView, inst: LowLevelILInstruction) -> bool:
>>>     return False
>>> PluginCommand.register_for_low_level_il_instruction("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True

Warning

Calling register_for_low_level_il_instruction with the same function name will replace the existing function but will leak the memory of the original plugin.

classmethod register_for_medium_level_il_function(name: str, description: str, action: Callable[[BinaryView, MediumLevelILFunction], None], is_valid: Callable[[BinaryView, MediumLevelILFunction], bool] | None = None)[source]

register_for_medium_level_il_function Register a plugin to be called with a medium level IL function argument

Parameters:
  • name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)

  • description (str) – description of the plugin

  • action (callback) – function to call with the BinaryView and a MediumLevelILFunction as arguments

  • is_valid (callback) – optional argument of a function passed a BinaryView and MediumLevelILFunction to determine whether the plugin should be enabled for that view

Return type:

None

Example:
>>> def my_plugin(bv: BinaryView, func: MediumLevelILFunction):
>>>     log_info(f"My plugin was called on func {func} in bv `{bv}`")
>>> PluginCommand.register_for_low_level_il_function("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView, func: MediumLevelILFunction) -> bool:
>>>     return False
>>> PluginCommand.register_for_low_level_il_function("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True

Warning

Calling register_for_medium_level_il_function with the same function name will replace the existing function but will leak the memory of the original plugin.

classmethod register_for_medium_level_il_instruction(name: str, description: str, action: Callable[[BinaryView, MediumLevelILInstruction], None], is_valid: Callable[[BinaryView, MediumLevelILInstruction], bool] | None = None)[source]

register_for_medium_level_il_instruction Register a plugin to be called with a medium level IL instruction argument

Parameters:
  • name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)

  • description (str) – description of the plugin

  • action (callback) – function to call with the BinaryView and a MediumLevelILInstruction as arguments

  • is_valid (callback) – optional argument of a function passed a BinaryView and MediumLevelILInstruction to determine whether the plugin should be enabled for that view

Return type:

None

Example:
>>> def my_plugin(bv: BinaryView, inst: MediumLevelILInstruction):
>>>     log_info(f"My plugin was called on inst {inst} in bv `{bv}`")
>>> PluginCommand.register_for_low_level_il_instruction("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView, inst: MediumLevelILInstruction) -> bool:
>>>     return False
>>> PluginCommand.register_for_low_level_il_instruction("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True

Warning

Calling register_for_medium_level_il_instruction with the same function name will replace the existing function but will leak the memory of the original plugin.

classmethod register_for_range(name: str, description: str, action: Callable[[BinaryView, int, int], None], is_valid: Callable[[BinaryView, int, int], bool] | None = None)[source]

register_for_range Register a plugin to be called with a range argument

Parameters:
  • name (str) – name of the plugin (use ‘Folder\Name’ to have the menu item nested in a folder)

  • description (str) – description of the plugin

  • action (callback) – function to call with the BinaryView, start address, and length as arguments

  • is_valid (callback) – optional argument of a function passed a BinaryView, start address, and length to determine whether the plugin should be enabled for that view

Return type:

None

Example:
>>> def my_plugin(bv: BinaryView, start: int, length: int):
>>>     log_info(f"My plugin was called on bv: `{bv}` at {hex(start)} of length {hex(length)}")
>>> PluginCommand.register_for_range("My Plugin", "My plugin description (not used)", my_plugin)
True
>>> def is_valid(bv: BinaryView, start: int, length: int) -> bool:
>>>     return False
>>> PluginCommand.register_for_range("My Plugin (With Valid Function)", "My plugin description (not used)", my_plugin, is_valid)
True

Warning

Calling register_for_range with the same function name will replace the existing function but will leak the memory of the original plugin.

property command
property description
property name
property type
class PluginCommandContext(view)[source]

Bases: object

property address
property function
property instruction
property length
property view