diff options
| author | KyleMiles <krm504@nyu.edu> | 2022-08-31 15:39:41 -0400 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2022-08-31 16:00:50 -0400 |
| commit | 8a66d88d33253bce6f1efc278abe805575e81c1d (patch) | |
| tree | b6b717cbe6f6600b7b8516724d6ac56e53e360af /rust/src/headless.rs | |
| parent | 568050e3cf5e96e134931181de14885e5b64d735 (diff) | |
Rust API : Major docs update (still need detailed module and function documentation)
Diffstat (limited to 'rust/src/headless.rs')
| -rw-r--r-- | rust/src/headless.rs | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/rust/src/headless.rs b/rust/src/headless.rs index 5f56a881..fb73535c 100644 --- a/rust/src/headless.rs +++ b/rust/src/headless.rs @@ -66,6 +66,9 @@ fn binja_path() -> PathBuf { use binaryninjacore_sys::{BNInitPlugins, BNInitRepoPlugins, BNSetBundledPluginDirectory}; +/// Loads plugins, core architecture, platform, etc. +/// +/// ⚠️ Important! Must be called at the beginning of scripts. Plugins do not need to call this. ⚠️ pub fn init() { unsafe { let path = binja_path().join("plugins").into_os_string(); @@ -77,26 +80,25 @@ pub fn init() { } } +/// Unloads plugins, stops all worker threads, and closes open logs +/// +/// ⚠️ Important! Must be called at the end of scripts. ⚠️ pub fn shutdown() { - //! Unloads plugins, stops all worker threads, and closes open logs - //! Important! : Must be called at the end of scripts - unsafe { binaryninjacore_sys::BNShutdown() }; } +/// Prelued-postlued helper function (calls [`init`] and [`shutdown`] for you) +/// ```rust +/// fn main() { +/// binaryninja::headless::script_helper(|| { +/// binaryninja::open_view("/bin/cat") +/// .expect("Couldn't open `/bin/cat`") +/// .iter() +/// .for_each(|func| println!(" `{}`", func.symbol().full_name())); +/// }); +/// } +/// ``` pub fn script_helper(func: fn()) { - //! Prelued-postlued helper function: - //! ``` - //! fn main() { - //! binaryninja::headless::script_helper(|| { - //! binaryninja::open_view("/bin/cat") - //! .expect("Couldn't open `/bin/cat`") - //! .iter() - //! .for_each(|func| println!(" `{}`", func.symbol().full_name())); - //! }); - //! } - //! ``` - init(); func(); shutdown(); |
