diff options
| author | Glenn Smith <glenn@vector35.com> | 2024-06-10 17:15:25 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2024-06-10 17:15:25 -0400 |
| commit | 9879389091766176705999562870003860338879 (patch) | |
| tree | 819411d16ebbdb4fa39cc2ab3cfcf4658cdb8afc /docs/dev | |
| parent | 4520939987007499595285385569591059508700 (diff) | |
Cookbook entry on adding a magic variable
Diffstat (limited to 'docs/dev')
| -rw-r--r-- | docs/dev/cookbook.md | 14 |
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 |
