From ac909374541f32697a065c43e7e12c5d6916f937 Mon Sep 17 00:00:00 2001 From: Jordan Wiens Date: Mon, 10 Nov 2025 23:22:31 -0500 Subject: fix coreversion info and add docs --- docs/dev/cookbook.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'docs/dev') 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 -- cgit v1.3.1