Getting Started
Installation
The C++ API is available in thebinaryninjaapi repository:
Basic Example
Here’s a simple program that opens a binary and displays basic information:Core Namespace
All C++ API classes are in theBinaryNinja namespace:
Reference Counting
Binary Ninja uses reference-counted smart pointers for memory management. TheRef<T> template provides automatic reference counting:
RefCountObject Base Class
Most API objects inherit fromRefCountObject:
Ref<T> smart pointer automatically calls AddRef() and Release() to manage object lifetimes.
CMake Integration
Building a Plugin
Create aCMakeLists.txt file for your project:
Build Requirements
- C++ Standard: C++20 or later
- CMake: Version 3.15 or later
- Compiler: GCC, Clang, or MSVC with C++20 support
- Binary Ninja: Installation or core library
Building
Key Components
The C++ API is organized into several key areas:Binary Analysis
- BinaryView - Main interface for analyzing binary files
- Function - Represents functions and their properties
- Architecture - CPU architecture definitions and operations
Type System
- Type - Type definitions and type analysis
- Structure - Structured type definitions
- Enumeration - Enumeration type definitions
Intermediate Languages
- LowLevelILFunction - Low-level IL (LLIL) representation
- MediumLevelILFunction - Medium-level IL (MLIL) representation
- HighLevelILFunction - High-level IL (HLIL) representation
Supporting Classes
- BasicBlock - Code basic blocks
- Symbol - Symbol information
- Platform - Platform/OS definitions
- CallingConvention - Function calling conventions
Initialization and Cleanup
All Binary Ninja programs must initialize the plugin system and clean up properly:Examples
The Binary Ninja API repository includes several complete examples:- bin-info - Display binary information
- cmdline_disasm - Command-line disassembler
- llil_parser - Parse and display LLIL
- mlil_parser - Parse and display MLIL
- print_syscalls - Identify system calls
Next Steps
BinaryView
Learn about loading and analyzing binary files
Function
Working with functions and control flow
Architecture
CPU architecture support and disassembly
IL (Intermediate Language)
Analyze code using Binary Ninja’s IL
Resources
- GitHub Repository
- API Header File
- Python API Documentation (similar concepts)