Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ members = [
"arch/riscv",
"arch/msp430",
"rust/plugin_examples/data_renderer",
"rust/plugin_examples/flowgraph_layout",
"view/minidump",
"plugins/dwarf/dwarf_import",
"plugins/dwarf/dwarf_import/demo",
Expand Down
3 changes: 2 additions & 1 deletion about.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ accepted = [
"LicenseRef-scancode-google-patent-license-fuchsia",
"MPL-2.0",
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause"
"BSD-2-Clause",
"Zlib"
]
17 changes: 16 additions & 1 deletion arch/msp430/src/architecture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ fn generate_jxx_tokens(inst: &impl Jxx, addr: u64) -> Vec<InstructionTextToken>
InstructionTextTokenKind::CodeRelativeAddress {
value: fixed_addr,
size: None,
operand: None,
},
));

Expand Down Expand Up @@ -560,6 +561,7 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
InstructionTextTokenKind::Integer {
value: *i as u64,
size: None,
operand: None,
},
),
InstructionTextToken::new("(", InstructionTextTokenKind::Text),
Expand All @@ -579,6 +581,7 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
InstructionTextTokenKind::Integer {
value: *i as u64,
size: None,
operand: None,
},
),
InstructionTextToken::new("(", InstructionTextTokenKind::Text),
Expand All @@ -598,6 +601,7 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
InstructionTextTokenKind::Integer {
value: *i as u64,
size: None,
operand: None,
},
),
InstructionTextToken::new("(", InstructionTextTokenKind::Text),
Expand All @@ -617,6 +621,7 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
InstructionTextTokenKind::Integer {
value: *i as u64,
size: None,
operand: None,
},
),
InstructionTextToken::new("(", InstructionTextTokenKind::Text),
Expand All @@ -636,6 +641,7 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
InstructionTextTokenKind::Integer {
value: *i as u64,
size: None,
operand: None,
},
),
InstructionTextToken::new("(", InstructionTextTokenKind::Text),
Expand Down Expand Up @@ -673,7 +679,11 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
let value = (addr as i64 + *i as i64) as u64;
vec![InstructionTextToken::new(
format!("{value:#x}"),
InstructionTextTokenKind::CodeRelativeAddress { value, size: None },
InstructionTextTokenKind::CodeRelativeAddress {
value,
size: None,
operand: None,
},
)]
}
Operand::Immediate(i) => {
Expand All @@ -683,6 +693,7 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
InstructionTextTokenKind::CodeRelativeAddress {
value: *i as u64,
size: None,
operand: None,
},
)]
} else {
Expand All @@ -691,6 +702,7 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
InstructionTextTokenKind::PossibleAddress {
value: *i as u64,
size: None,
operand: None,
},
)]
}
Expand All @@ -702,6 +714,7 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
InstructionTextTokenKind::CodeRelativeAddress {
value: *a as u64,
size: None,
operand: None,
},
)]
} else {
Expand All @@ -710,6 +723,7 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
InstructionTextTokenKind::PossibleAddress {
value: *a as u64,
size: None,
operand: None,
},
)]
}
Expand All @@ -728,6 +742,7 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
InstructionTextTokenKind::Integer {
value: *i as u64,
size: None,
operand: None,
},
),
]
Expand Down
3 changes: 3 additions & 0 deletions arch/riscv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ impl<D: RiscVDisassembler> Architecture for RiscVArch<D> {
CodeRelativeAddress {
value: target,
size: Some(self.address_size()),
operand: None,
},
));
}
Expand All @@ -1137,6 +1138,7 @@ impl<D: RiscVDisassembler> Architecture for RiscVArch<D> {
Integer {
value: i as u64,
size: None,
operand: None,
},
));
}
Expand All @@ -1155,6 +1157,7 @@ impl<D: RiscVDisassembler> Architecture for RiscVArch<D> {
Integer {
value: i as u64,
size: None,
operand: None,
},
));

Expand Down
2 changes: 2 additions & 0 deletions plugins/bntl_utils/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
name = "bntl_cli"
version = "0.1.0"
edition = "2024"
license = "Apache-2.0"
publish = false

[dependencies]
binaryninja.workspace = true
Expand Down
12 changes: 11 additions & 1 deletion plugins/dwarf/dwarfdump/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ fn get_info_string<R: Reader>(
InstructionTextTokenKind::Integer {
value: addr,
size: None,
operand: None,
},
));
} else if let Ok(attr_reader) = dwarf.attr_string(unit, attr.value()) {
Expand Down Expand Up @@ -180,6 +181,7 @@ fn get_info_string<R: Reader>(
InstructionTextTokenKind::Integer {
value: 1,
size: None,
operand: None,
},
));
} else if let Flag(false) = attr.value() {
Expand All @@ -188,6 +190,7 @@ fn get_info_string<R: Reader>(
InstructionTextTokenKind::Integer {
value: 0,
size: None,
operand: None,
},
));

Expand All @@ -199,6 +202,7 @@ fn get_info_string<R: Reader>(
InstructionTextTokenKind::Integer {
value: value as u64,
size: None,
operand: None,
},
));
} else if let Some(value) = attr.u16_value() {
Expand All @@ -208,13 +212,18 @@ fn get_info_string<R: Reader>(
InstructionTextTokenKind::Integer {
value: value as u64,
size: None,
operand: None,
},
));
} else if let Some(value) = attr.udata_value() {
let value_string = format!("{}", value);
attr_line.push(InstructionTextToken::new(
&value_string,
InstructionTextTokenKind::Integer { value, size: None },
InstructionTextTokenKind::Integer {
value,
size: None,
operand: None,
},
));
} else if let Some(value) = attr.sdata_value() {
let value_string = format!("{}", value);
Expand All @@ -223,6 +232,7 @@ fn get_info_string<R: Reader>(
InstructionTextTokenKind::Integer {
value: value as u64,
size: None,
operand: None,
},
));
} else {
Expand Down
2 changes: 2 additions & 0 deletions plugins/warp/examples/headless/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
name = "warp_headless"
version = "0.1.0"
edition = "2021"
license = "Apache-2.0"
publish = false

[dependencies]
clap = { version = "4.5", features = ["derive"] }
Expand Down
4 changes: 3 additions & 1 deletion rust/examples/flowgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use binaryninja::{
disassembly::{DisassemblyTextLine, InstructionTextToken, InstructionTextTokenKind},
flowgraph::{EdgePenStyle, FlowGraph, ThemeColor},
};
use std::time::Duration;

pub struct GraphPrinter;

Expand Down Expand Up @@ -134,8 +135,9 @@ fn main() {
test_graph();

for func in bv.functions().iter().take(5) {
// TODO: Why are the nodes empty? Python its empty until its shown...
let graph = func.create_graph(FunctionViewType::MediumLevelIL, None);
// It is important to call this, otherwise no nodes will be placed.
graph.request_layout_and_wait(Duration::from_secs(5));
let func_name = func.symbol().short_name();
let title = func_name.to_string_lossy();
bv.show_graph_report(&title, &graph);
Expand Down
1 change: 1 addition & 0 deletions rust/plugin_examples/data_renderer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "example_data_renderer"
version = "0.1.0"
edition = "2021"
license = "Apache-2.0"
publish = false

[lib]
Expand Down
15 changes: 15 additions & 0 deletions rust/plugin_examples/flowgraph_layout/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "example_flowgraph_layout"
version = "0.1.0"
edition = "2021"
license = "Apache-2.0"
publish = false

[lib]
crate-type = ["cdylib"]

[dependencies]
binaryninjacore-sys = { path = "../../binaryninjacore-sys" }
binaryninja = { path = "../.." }
rust-sugiyama = "0.4.0"
petgraph = "0.8"
16 changes: 16 additions & 0 deletions rust/plugin_examples/flowgraph_layout/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# FlowGraph Layout Example

This example implements a simple flow graph layout using the rust crate `rust-sugiyama`. After building and placing this
in the plugin directory, override the default flow graph layout setting `rendering.graph.defaultLayout`.

This example is complete _except_ for edge routing, we simply draw the edge from the outgoing nodes bottom to the
incoming nodes top, a real layout would route the edges around nodes to avoid overlaps and other rendering oddities.

## Building

```sh
# Build from the root directory (binaryninja-api)
cargo build -p example_flowgraph_layout
# Link binary on macOS
ln -sf $PWD/target/debug/libexample_flowgraph_layout.dylib ~/Library/Application\ Support/Binary\ Ninja/plugins
```
25 changes: 25 additions & 0 deletions rust/plugin_examples/flowgraph_layout/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
fn main() {
let link_path = std::env::var_os("DEP_BINARYNINJACORE_PATH")
.expect("DEP_BINARYNINJACORE_PATH not specified");

println!("cargo::rustc-link-lib=dylib=binaryninjacore");
println!("cargo::rustc-link-search={}", link_path.to_str().unwrap());

#[cfg(target_os = "linux")]
{
println!(
"cargo::rustc-link-arg=-Wl,-rpath,{0},-L{0}",
link_path.to_string_lossy()
);
}

#[cfg(target_os = "macos")]
{
let crate_name = std::env::var("CARGO_PKG_NAME").expect("CARGO_PKG_NAME not set");
let lib_name = crate_name.replace('-', "_");
println!(
"cargo::rustc-link-arg=-Wl,-install_name,@rpath/lib{}.dylib",
lib_name
);
}
}
Loading
Loading