MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / main

Function main

rust/examples/workflow.rs:48–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

46}
47
48pub fn main() {
49 println!("Starting session...");
50 // This loads all the core architecture, platform, etc plugins
51 let headless_session =
52 binaryninja::headless::Session::new().expect("Failed to initialize session");
53
54 println!("Registering workflow...");
55 let old_meta_workflow = Workflow::instance("core.function.metaAnalysis");
56 let meta_workflow = old_meta_workflow.clone_to("core.function.metaAnalysis");
57 let activity = Activity::new_with_action(RUST_ACTIVITY_CONFIG, example_activity);
58 meta_workflow.register_activity(&activity).unwrap();
59 meta_workflow.insert("core.function.runFunctionRecognizers", [RUST_ACTIVITY_NAME]);
60 // Re-register the meta workflow with our changes.
61 meta_workflow.register().unwrap();
62
63 println!("Loading binary...");
64 let bv = headless_session
65 .load("/bin/cat")
66 .expect("Couldn't open `/bin/cat`");
67
68 // traverse all llil expressions and look for the constant 0x1337
69 for func in &bv.functions() {
70 if let Ok(llil) = func.low_level_il() {
71 for block in &llil.basic_blocks() {
72 for instr in block.iter() {
73 instr.visit_tree(&mut |expr| {
74 if let LowLevelILExpressionKind::Const(value) = expr.kind() {
75 if value.value() == 0x1337 {
76 println!(
77 "Found constant 0x1337 at instruction 0x{:x} in function {}",
78 instr.address(),
79 func.start()
80 );
81 }
82 }
83 VisitorAction::Descend
84 });
85 }
86 }
87 }
88 }
89}

Callers

nothing calls this directly

Calls 13

instanceFunction · 0.85
clone_toMethod · 0.80
register_activityMethod · 0.45
insertMethod · 0.45
registerMethod · 0.45
loadMethod · 0.45
functionsMethod · 0.45
low_level_ilMethod · 0.45
basic_blocksMethod · 0.45
iterMethod · 0.45
visit_treeMethod · 0.45
kindMethod · 0.45

Tested by

no test coverage detected