summaryrefslogtreecommitdiff
path: root/rust/examples
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-05-10 23:09:22 -0400
committerMason Reed <35282038+emesare@users.noreply.github.com>2025-05-12 17:45:24 -0400
commite901a6a4ce4aff281b46ef87363b8c56d35f70af (patch)
tree6c6d8300ba0709abf69745ac5310e683607695c7 /rust/examples
parent5ebbd0620903403fb30a61157b16f33c89afb584 (diff)
[Rust] Flowgraph API improvements
Diffstat (limited to 'rust/examples')
-rw-r--r--rust/examples/flowgraph.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/rust/examples/flowgraph.rs b/rust/examples/flowgraph.rs
index 515d52fe..ce91d62f 100644
--- a/rust/examples/flowgraph.rs
+++ b/rust/examples/flowgraph.rs
@@ -15,7 +15,7 @@ use binaryninja::{
pub struct GraphPrinter;
impl GraphPrinter {
- pub fn print_graph(&self, _view: &BinaryView, graph: &FlowGraph) {
+ pub fn print_graph(&self, graph: &FlowGraph) {
println!("Printing flow graph:");
for node in &graph.nodes() {
// Print all disassembly lines in the node
@@ -60,16 +60,16 @@ impl InteractionHandler for GraphPrinter {
false
}
- fn show_plain_text_report(&mut self, _view: &BinaryView, title: &str, contents: &str) {
+ fn show_plain_text_report(&mut self, _view: Option<&BinaryView>, title: &str, contents: &str) {
println!("Plain text report");
println!("Title: {}", title);
println!("Contents: {}", contents);
}
- fn show_graph_report(&mut self, view: &BinaryView, title: &str, graph: &FlowGraph) {
+ fn show_graph_report(&mut self, _view: Option<&BinaryView>, title: &str, graph: &FlowGraph) {
println!("Graph report");
println!("Title: {}", title);
- self.print_graph(view, graph);
+ self.print_graph(graph);
}
fn get_form_input(&mut self, _form: &mut Form) -> bool {
@@ -77,7 +77,7 @@ impl InteractionHandler for GraphPrinter {
}
}
-fn test_graph(view: &BinaryView) {
+fn test_graph() {
let graph = FlowGraph::new();
let disassembly_lines_a = vec![DisassemblyTextLine::new(vec![
@@ -110,7 +110,7 @@ fn test_graph(view: &BinaryView) {
EdgeStyle::default(),
);
- view.show_graph_report("Rust Graph Title", &graph);
+ graph.show("Rust Example Graph");
}
fn main() {
@@ -127,10 +127,11 @@ fn main() {
// Register the interaction handler so we can see the graph report headlessly.
register_interaction_handler(GraphPrinter);
- test_graph(&bv);
+ test_graph();
for func in bv.functions().iter().take(5) {
let graph = func.create_graph(FunctionViewType::MediumLevelIL, None);
+ // TODO: Why are the nodes empty? Python its empty until its shown...
assert!(!graph.nodes().is_empty());
let func_name = func.symbol().short_name();
let title = func_name.to_string_lossy();