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

Function example_activity

rust/examples/workflow.rs:18–46  ·  view source on GitHub ↗
(analysis_context: &AnalysisContext)

Source from the content-addressed store, hash-verified

16}"#;
17
18fn example_activity(analysis_context: &AnalysisContext) {
19 let func = analysis_context.function();
20 println!(
21 "Activity `{}` called in function {} with workflow {:?}!",
22 RUST_ACTIVITY_NAME,
23 func.start(),
24 func.workflow().map(|wf| wf.name())
25 );
26 // If we have llil available, replace that as well.
27 if let Some(llil) = unsafe { analysis_context.llil_function() } {
28 for basic_block in &func.basic_blocks() {
29 for instr in basic_block.iter() {
30 if let Some(llil_instr) = llil.instruction_at(instr) {
31 llil_instr.visit_tree(&mut |expr| {
32 if let LowLevelILExpressionKind::Const(_op) = expr.kind() {
33 // Replace all consts with 0x1337.
34 println!("Replacing llil expression @ 0x{:x} : {}", instr, expr.index);
35 unsafe {
36 llil.replace_expression(expr.index, llil.const_int(4, 0x1337))
37 };
38 }
39 VisitorAction::Descend
40 });
41 }
42 }
43 }
44 analysis_context.set_lifted_il_function(&llil);
45 }
46}
47
48pub fn main() {
49 println!("Starting session...");

Callers

nothing calls this directly

Calls 10

llil_functionMethod · 0.80
replace_expressionMethod · 0.80
const_intMethod · 0.80
functionMethod · 0.45
basic_blocksMethod · 0.45
iterMethod · 0.45
instruction_atMethod · 0.45
visit_treeMethod · 0.45
kindMethod · 0.45

Tested by

no test coverage detected