Skip to content

Conversation

Copy link

Copilot AI commented Oct 21, 2025

Adds comprehensive examples to the Python script cookbook demonstrating how to work with Binary Ninja files and databases, covering both UI scripting and headless usage scenarios.

Changes Made

UI Scripting Context

  • Explains that the bv magic variable is available when scripting from the Binary Ninja UI (Python console or File -> Run Script...)

Headless Usage (Commercial+)

  • Documents headless file loading using the load() function for standalone scripts
  • Clarifies that headless usage requires Binary Ninja Commercial and above (Commercial, Ultimate, and Enterprise)
  • Includes note that this feature is not available in Personal edition

Code Examples

  • Basic file loading: Shows both context manager pattern (recommended) and manual close pattern
  • Loading with options: Demonstrates customizing load behavior with various options
  • Loading databases: Shows that .bndb files use the same API as regular binaries
  • Controlling analysis: Demonstrates disabling automatic analysis for performance

Implementation Details

  • Added new "Loading Files & Databases" section as the first recipe in the cookbook
  • Follows existing cookbook style and conventions
  • Concise documentation (54 lines) with clear, practical examples

Fixes #7473

Original prompt

This section details on the original issue you should resolve

<issue_title>Python script cookbook should include how to headlessly load a file or database</issue_title>
<issue_description>In https://docs.binary.ninja/dev/cookbook.html</issue_description>

Comments on the Issue (you are @copilot in this section)

@xusheng6 The `load` function can do it and is the preferred way. It would be nice to also include an example of loading the file with options

Fixes #7473


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: xusheng6 <94503187+xusheng6@users.noreply.github.com>
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI changed the title [WIP] Add headless load example to Python script cookbook Add headless file and database loading examples to Python cookbook Oct 21, 2025
Copilot AI requested a review from xusheng6 October 21, 2025 14:12
Copilot finished work on behalf of xusheng6 October 21, 2025 14:12
@xusheng6
Copy link
Member

@copilot

  1. also mention the headless using of binary ninja and loading of a file only works in binary ninja commercial and above. It does not work in the personal version
  2. Consolidate the text a bit -- it is too wordy now

Co-authored-by: xusheng6 <94503187+xusheng6@users.noreply.github.com>
Copy link
Author

Copilot AI commented Oct 21, 2025

@copilot

  1. also mention the headless using of binary ninja and loading of a file only works in binary ninja commercial and above. It does not work in the personal version
    ...

Done. Added a note about Commercial/Enterprise requirement and consolidated the text significantly (reduced from 87 to 54 lines). Changes in commit 3594847.

Copilot finished work on behalf of xusheng6 October 21, 2025 14:19
@xusheng6
Copy link
Member

@copilot better clarify this is only available in Binary Ninja Commercial and above (including Commercial, Ultimate, Enterprise)

…rprise

Co-authored-by: xusheng6 <94503187+xusheng6@users.noreply.github.com>
Copy link
Author

Copilot AI commented Oct 21, 2025

@copilot better clarify this is only available in Binary Ninja Commercial and above (including Commercial, Ultimate, Enterprise)

Updated to explicitly list all editions: "Binary Ninja Commercial and above (Commercial, Ultimate, and Enterprise)". Changes in commit 5e65d0b.

Copilot finished work on behalf of xusheng6 October 21, 2025 14:26
@xusheng6
Copy link
Member

@copilot Add to the start that if you are doing the scripting from the UI, the bv magic variable is already defined and you can directly use it in the Python console or a script loaded via File -> Run Script...

Then mention if you have commercial and above, you can use Binary Ninja headlessly (i.e., using it as a library), and went on to mention the examples

Co-authored-by: xusheng6 <94503187+xusheng6@users.noreply.github.com>
Copy link
Author

Copilot AI commented Oct 21, 2025

@copilot Add to the start that if you are doing the scripting from the UI, the bv magic variable is already defined and you can directly use it in the Python console or a script loaded via File -> R...

Added introductory text explaining that bv magic variable is available when scripting from UI (Python console or File -> Run Script...), followed by explanation that Commercial and above editions enable headless usage as a library. Changes in commit 6a36895.

Copilot AI changed the title Add headless file and database loading examples to Python cookbook Add file and database loading examples to Python cookbook Oct 21, 2025
Copilot finished work on behalf of xusheng6 October 21, 2025 14:35
@xusheng6 xusheng6 marked this pull request as ready for review October 22, 2025 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python script cookbook should include how to headlessly load a file or database

3 participants