From 9879389091766176705999562870003860338879 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Mon, 10 Jun 2024 17:15:25 -0400 Subject: Cookbook entry on adding a magic variable --- docs/dev/cookbook.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'docs/dev') diff --git a/docs/dev/cookbook.md b/docs/dev/cookbook.md index 4d9f0d77..6bf7ee2f 100644 --- a/docs/dev/cookbook.md +++ b/docs/dev/cookbook.md @@ -287,3 +287,17 @@ def invoke_plugin(name: str, bv: BinaryView, address=0, length = 0,function=None cmds = PluginCommand.get_valid_list(ctx) cmds[name].execute(ctx) ``` + +### Add variable to the Python Console +```python +from binaryninja import PythonScriptingProvider, PythonScriptingInstance + +def get_my_foo(instance: PythonScriptingInstance): + # See scriptingprovider.py for details and implementations of other variables + return instance.interpreter.active_addr & 0xffffff + +PythonScriptingProvider.register_magic_variable( + "my_foo", + get_my_foo +) +``` \ No newline at end of file -- cgit v1.3.1