summaryrefslogtreecommitdiff
path: root/docs/dev
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2024-06-10 17:15:25 -0400
committerGlenn Smith <glenn@vector35.com>2024-06-10 17:15:25 -0400
commit9879389091766176705999562870003860338879 (patch)
tree819411d16ebbdb4fa39cc2ab3cfcf4658cdb8afc /docs/dev
parent4520939987007499595285385569591059508700 (diff)
Cookbook entry on adding a magic variable
Diffstat (limited to 'docs/dev')
-rw-r--r--docs/dev/cookbook.md14
1 files changed, 14 insertions, 0 deletions
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