()
| 2 | use binaryninja::binary_view::{BinaryViewBase, BinaryViewExt}; |
| 3 | |
| 4 | fn main() { |
| 5 | println!("Starting session..."); |
| 6 | // This loads all the core architecture, platform, etc plugins |
| 7 | let headless_session = |
| 8 | binaryninja::headless::Session::new().expect("Failed to initialize session"); |
| 9 | |
| 10 | println!("Loading binary..."); |
| 11 | let bv = headless_session |
| 12 | .load("/bin/cat") |
| 13 | .expect("Couldn't open `/bin/cat`"); |
| 14 | |
| 15 | println!("Filename: `{}`", bv.file().filename()); |
| 16 | println!("File size: `{:#x}`", bv.len()); |
| 17 | println!("Function count: {}", bv.functions().len()); |
| 18 | |
| 19 | for func in &bv.functions() { |
| 20 | println!("{}:", func.symbol().full_name()); |
| 21 | for basic_block in &func.basic_blocks() { |
| 22 | // TODO : This is intended to be refactored to be more nice to work with soon(TM) |
| 23 | for addr in basic_block.as_ref() { |
| 24 | if let Some((_, tokens)) = func.arch().instruction_text( |
| 25 | bv.read_buffer(addr, func.arch().max_instr_len()) |
| 26 | .unwrap() |
| 27 | .get_data(), |
| 28 | addr, |
| 29 | ) { |
| 30 | let line = tokens |
| 31 | .iter() |
| 32 | .map(|token| token.to_string()) |
| 33 | .collect::<String>(); |
| 34 | println!("{addr} {line}"); |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | } |
nothing calls this directly
no test coverage detected