diff options
| author | Jordan Wiens <github@psifertex.com> | 2025-11-10 23:22:31 -0500 |
|---|---|---|
| committer | Jordan Wiens <github@psifertex.com> | 2025-11-10 23:27:25 -0500 |
| commit | ac909374541f32697a065c43e7e12c5d6916f937 (patch) | |
| tree | ab253b65d3e0bcc73320968c6a0cfbbbd4b7b7d4 /docs | |
| parent | 36d99ad88aed9889c741f34bddd045405a68369b (diff) | |
fix coreversion info and add docs
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/dev/cookbook.md | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/docs/dev/cookbook.md b/docs/dev/cookbook.md index df6074d1..5a457806 100644 --- a/docs/dev/cookbook.md +++ b/docs/dev/cookbook.md @@ -375,6 +375,32 @@ context = FileContext(data.file, data, '') execute_on_main_thread(lambda: UIContext.activeContext().openFileContext(context)) ``` +## Version Checking + +### Checking Binary Ninja version + +Plugins often need to check the Binary Ninja version to ensure compatibility or conditionally enable features. Use [`core_version_info()`](https://api.binary.ninja/#binaryninja.core_version_info) and [`CoreVersionInfo`](https://api.binary.ninja/#binaryninja.CoreVersionInfo) for clean version comparisons: + +```python +from binaryninja import core_version_info, CoreVersionInfo + +# Check minimum version requirement +if core_version_info() >= CoreVersionInfo(5, 1, 8104): + # Use API only available in 5.1.8104 and later + print("New API is available") +else: + # Fall back to older API + print("Using legacy API") + +# Parse and compare against a version string +if core_version_info() >= CoreVersionInfo("4.2.0"): + print("Version 4.2.0 or later detected") + +# Access individual version components +version = core_version_info() +print(f"Running Binary Ninja {version.major}.{version.minor}.{version.build}-{version.channel}") +``` + ## Debuging & Logging ### Logging |
