Skip to content
Open
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
2 changes: 1 addition & 1 deletion plugins/idb_import/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ crate-type = ["cdylib"]
anyhow = { version = "1.0.86", features = ["backtrace"] }
binaryninja.workspace = true
binaryninjacore-sys.workspace = true
idb-rs = { git = "https://github.com/Vector35/idb-rs", tag = "0.1.12" }
idb-rs = { git = "https://github.com/Vector35/idb-rs", tag = "0.1.13" }
log = "0.4"
36 changes: 20 additions & 16 deletions plugins/idb_import/src/addr_info.rs
Original file line number Diff line number Diff line change
@@ -1,50 +1,54 @@
use std::borrow::Cow;
use std::collections::HashMap;

use anyhow::Result;

use idb_rs::addr_info::all_address_info;
use idb_rs::id0::{ID0Section, Netdelta};
use idb_rs::id0::{ID0Section, RootInfo};
use idb_rs::id1::ID1Section;
use idb_rs::id2::ID2Section;
use idb_rs::{til, Address, IDAKind};
use idb_rs::{til, Address, IDAKind, IDBString};

#[derive(Default)]
pub struct AddrInfo<'a> {
pub struct AddrInfo {
// TODO does binja differentiate comments types on the API?
pub comments: Vec<Vec<u8>>,
pub label: Option<Cow<'a, [u8]>>,
pub comments: Vec<IDBString>,
pub label: Option<IDBString>,
// TODO make this a ref
pub ty: Option<til::Type>,
}

pub fn get_info<'a, K: IDAKind>(
id0: &'a ID0Section<K>,
id1: &ID1Section,
pub fn get_info<K: IDAKind>(
id0: &ID0Section<K>,
id1: &ID1Section<K>,
id2: Option<&ID2Section<K>>,
netdelta: Netdelta<K>,
) -> Result<HashMap<Address<K>, AddrInfo<'a>>> {
root_info: &RootInfo<K>,
) -> Result<HashMap<Address<K>, AddrInfo>> {
let mut addr_info: HashMap<Address<K>, AddrInfo> = HashMap::new();

// comments defined on the address information
let netdelta = root_info.netdelta();
for (info, _info_size) in all_address_info(id0, id1, id2, netdelta) {
let entry = addr_info.entry(info.address()).or_default();
if let Some(comment) = info.comment() {
entry.comments.push(comment.to_vec());
entry.comments.push(comment.to_idb_string());
}
if let Some(comment) = info.comment_repeatable() {
entry.comments.push(comment.to_vec());
entry.comments.push(comment.to_idb_string());
}
if let Some(comment) = info.comment_pre() {
entry.comments.extend(comment.map(|line| line.to_vec()));
entry
.comments
.extend(comment.map(|line| line.to_idb_string()));
}
if let Some(comment) = info.comment_post() {
entry.comments.extend(comment.map(|line| line.to_vec()));
entry
.comments
.extend(comment.map(|line| line.to_idb_string()));
}
if let Some(label) = info.label()? {
entry.label = Some(label);
}
if let Some(ty) = info.tinfo()? {
if let Some(ty) = info.tinfo(root_info)? {
entry.ty = Some(ty);
}
}
Expand Down
Loading