You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: rust/src/command.rs
+28-10Lines changed: 28 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -16,12 +16,16 @@
16
16
//!
17
17
//! All plugins need to provide one of the following functions for Binary Ninja to call:
18
18
//!
19
-
//! ```rust
20
-
//! pub extern "C" fn CorePluginInit() -> bool {}
19
+
//! ```no_run
20
+
//! pub extern "C" fn CorePluginInit() -> bool {
21
+
//! todo!();
22
+
//! }
21
23
//! ```
22
24
//!
23
-
//! ```rust
24
-
//! pub extern "C" fn UIPluginInit() -> bool {}
25
+
//! ```no_run
26
+
//! pub extern "C" fn UIPluginInit() -> bool {
27
+
//! todo!();
28
+
//! }
25
29
//! ```
26
30
//!
27
31
//! Both of these functions can call any of the following registration functions, though `CorePluginInit` is called during Binary Ninja core initialization, and `UIPluginInit` is called during Binary Ninja UI initialization.
@@ -62,7 +66,9 @@ where
62
66
/// The function call required for generic commands; commands added in this way will be in the `Plugins` submenu of the menu bar.
63
67
///
64
68
/// # Example
65
-
/// ```rust
69
+
/// ```no_run
70
+
/// # use binaryninja::command::Command;
71
+
/// # use binaryninja::binaryview::BinaryView;
66
72
/// struct MyCommand;
67
73
///
68
74
/// impl Command for MyCommand {
@@ -76,6 +82,7 @@ where
76
82
/// }
77
83
/// }
78
84
///
85
+
/// # use binaryninja::command::register;
79
86
/// #[no_mangle]
80
87
/// pub extern "C" fn CorePluginInit() -> bool {
81
88
/// register(
@@ -160,7 +167,9 @@ where
160
167
/// The function call required for generic commands; commands added in this way will be in the `Plugins` submenu of the menu bar.
161
168
///
162
169
/// # Example
163
-
/// ```rust
170
+
/// ```no_run
171
+
/// # use binaryninja::command::AddressCommand;
172
+
/// # use binaryninja::binaryview::BinaryView;
164
173
/// struct MyCommand;
165
174
///
166
175
/// impl AddressCommand for MyCommand {
@@ -174,6 +183,7 @@ where
174
183
/// }
175
184
/// }
176
185
///
186
+
/// # use binaryninja::command::register_for_address;
177
187
/// #[no_mangle]
178
188
/// pub extern "C" fn CorePluginInit() -> bool {
179
189
/// register_for_address(
@@ -258,10 +268,13 @@ where
258
268
/// The function call required for generic commands; commands added in this way will be in the `Plugins` submenu of the menu bar.
//! `DebugInfo` will then be automatically applied to binary views that contain debug information (via the setting `analysis.debugInfo.internal`), binary views that provide valid external debug info files (`analysis.debugInfo.external`), or manually fetched/applied as below:
56
-
//! ```
57
-
//! let valid_parsers = DebugInfoParser::parsers_for_view(bv);
58
-
//! let parser = valid_parsers[0];
59
-
//! let debug_info = parser.parse_debug_info(bv);
60
-
//! bv.apply_debug_info(debug_info);
57
+
//! ```no_run
58
+
//! # use binaryninja::debuginfo::DebugInfoParser;
59
+
//! # use binaryninja::binaryview::BinaryViewExt;
60
+
//! let bv = binaryninja::load("example").unwrap();
61
+
//! let valid_parsers = DebugInfoParser::parsers_for_view(&bv);
62
+
//! let parser = valid_parsers.get(0);
63
+
//! let debug_info = parser.parse_debug_info(&bv, &bv, None, None).unwrap();
64
+
//! bv.apply_debug_info(&debug_info);
61
65
//! ```
62
66
//!
63
67
//! Multiple debug-info parsers can manually contribute debug info for a binary view by simply calling `parse_debug_info` with the
@@ -277,6 +281,14 @@ unsafe impl CoreOwnedArrayProvider for DebugInfoParser {
Copy file name to clipboardExpand all lines: rust/src/lib.rs
+6-4Lines changed: 6 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -49,7 +49,7 @@
49
49
//!
50
50
//! Create a new library (`cargo new --lib <plugin-name>`) and include the following in your `Cargo.toml`:
51
51
//!
52
-
//! ```
52
+
//! ```toml
53
53
//! [lib]
54
54
//! crate-type = ["cdylib"]
55
55
//!
@@ -73,17 +73,19 @@
73
73
//!
74
74
//! ### `main.rs`
75
75
//! Standalone binaries need to initialize Binary Ninja before they can work. You can do this through [`headless::Session`], [`headless::script_helper`], or [`headless::init()`] at start and [`headless::shutdown()`] at shutdown.
76
-
//! ```rust
76
+
//! ```no_run
77
77
//! // This loads all the core architecture, platform, etc plugins
78
78
//! // Standalone executables need to call this, but plugins do not
79
79
//! let headless_session = binaryninja::headless::Session::new();
80
80
//!
81
81
//! println!("Loading binary...");
82
82
//! let bv = headless_session.load("/bin/cat").expect("Couldn't open `/bin/cat`");
/// The main way to open and load files (with options) into Binary Ninja. Make sure you've properly initialized the core before calling this function. See [`crate::headless::init()`]
217
219
///
218
-
/// ```rust
220
+
/// ```no_run
219
221
/// let settings = [("analysis.linearSweep.autorun", false)].into();
220
222
///
221
223
/// let bv = binaryninja::load_with_options("/bin/cat", true, Some(settings))
0 commit comments