From cc22a52907a052f37dad319f843f218fe69e1b9a Mon Sep 17 00:00:00 2001 From: Jackson Date: Sat, 9 Mar 2024 19:26:36 -0500 Subject: Update cookbook.md Document how to call plugins headless --- docs/dev/cookbook.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'docs/dev') diff --git a/docs/dev/cookbook.md b/docs/dev/cookbook.md index 9f5164e9..4d9f0d77 100644 --- a/docs/dev/cookbook.md +++ b/docs/dev/cookbook.md @@ -272,3 +272,18 @@ UIActionHandler.globalActions().bindAction("Trigger Range", UIAction(new_range_a Menu.mainMenu("Plugins").addAction("Trigger Range", "Plugins") ``` +### Invoke plugin from the API +```python +from binaryninja import BinaryView, PluginCommand, PluginCommandContext + + +def invoke_plugin(name: str, bv: BinaryView, address=0, length = 0,function=None, instruction=None): + ctx = PluginCommandContext(bv) + ctx.address = address + ctx.length = length + ctx.function = function + ctx.instruction = instruction + + cmds = PluginCommand.get_valid_list(ctx) + cmds[name].execute(ctx) +``` -- cgit v1.3.1