summaryrefslogtreecommitdiff
path: root/view/bintxt
diff options
context:
space:
mode:
Diffstat (limited to 'view/bintxt')
-rw-r--r--view/bintxt/Cargo.lock7
-rw-r--r--view/bintxt/Cargo.toml12
-rw-r--r--view/bintxt/build.rs15
-rw-r--r--view/bintxt/src/ihex.rs23
-rw-r--r--view/bintxt/src/lib.rs10
-rw-r--r--view/bintxt/src/srec.rs6
-rw-r--r--view/bintxt/src/titxt.rs6
7 files changed, 42 insertions, 37 deletions
diff --git a/view/bintxt/Cargo.lock b/view/bintxt/Cargo.lock
index faf8fc99..1e862160 100644
--- a/view/bintxt/Cargo.lock
+++ b/view/bintxt/Cargo.lock
@@ -16,7 +16,6 @@ name = "binaryninja"
version = "0.1.0"
dependencies = [
"binaryninjacore-sys",
- "lazy_static",
"log",
]
@@ -108,12 +107,6 @@ dependencies = [
]
[[package]]
-name = "lazy_static"
-version = "1.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
-
-[[package]]
name = "libc"
version = "0.2.155"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/view/bintxt/Cargo.toml b/view/bintxt/Cargo.toml
index 0ec7a9c1..47740dbd 100644
--- a/view/bintxt/Cargo.toml
+++ b/view/bintxt/Cargo.toml
@@ -5,15 +5,11 @@ authors = ["Rubens Brandao <git@rubens.io>"]
edition = "2021"
[dependencies]
-binaryninja = { path = "../../rust" }
+binaryninja.workspace = true
+binaryninjacore-sys.workspace = true
ihex = "3.0.0"
-log = "*"
+log = "0.4"
srec = "0.2.0"
[lib]
-crate-type = ["cdylib"]
-
-[profile.release]
-panic = "abort"
-lto = true
-debug = 1
+crate-type = ["cdylib"] \ No newline at end of file
diff --git a/view/bintxt/build.rs b/view/bintxt/build.rs
new file mode 100644
index 00000000..ed6cec7d
--- /dev/null
+++ b/view/bintxt/build.rs
@@ -0,0 +1,15 @@
+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(not(target_os = "windows"))]
+ {
+ println!(
+ "cargo::rustc-link-arg=-Wl,-rpath,{0},-L{0}",
+ link_path.to_string_lossy()
+ );
+ }
+}
diff --git a/view/bintxt/src/ihex.rs b/view/bintxt/src/ihex.rs
index bb694941..b1cbfb80 100644
--- a/view/bintxt/src/ihex.rs
+++ b/view/bintxt/src/ihex.rs
@@ -1,15 +1,15 @@
-use binaryninja::binaryview::*;
-use binaryninja::custombinaryview::*;
-use binaryninja::rc::Ref;
-use binaryninja::segment::SegmentBuilder;
-use ihex::Record;
-use binaryninja::platform::Platform;
-use binaryninja::settings::Settings;
use crate::segment_after_address;
use crate::segment_from_address;
use crate::sort_and_merge_segments;
use crate::MergedSegment;
use crate::UnmergedSegment;
+use binaryninja::binary_view::*;
+use binaryninja::custom_binary_view::*;
+use binaryninja::platform::Platform;
+use binaryninja::rc::Ref;
+use binaryninja::segment::SegmentBuilder;
+use binaryninja::settings::{QueryOptions, Settings};
+use ihex::Record;
fn parse_ihex(string: &str) -> Result<(Vec<u8>, IHexViewData)> {
let mut reader = ihex::Reader::new(&string);
@@ -101,7 +101,7 @@ impl CustomBinaryViewType for IHexViewConstructor {
parent: &BinaryView,
builder: CustomViewBuilder<'builder, Self>,
) -> Result<CustomView<'builder>> {
- let bytes = parent.len();
+ let bytes = parent.len() as usize;
let mut buf = vec![0; bytes];
let bytes_read = parent.read(&mut buf, 0);
if bytes_read != bytes {
@@ -216,15 +216,16 @@ unsafe impl CustomBinaryView for IHexView {
.contains_code(true),
);
}
-
+
// TODO: Because we detached from the raw view this setting will never be set.
+ let mut settings_query_opts = QueryOptions::new_with_view(&self.core);
let _ = self.core.load_settings(self.type_name()).map(|s| {
- let platform_name = s.get_string("loader.platform", Some(&self.core), None);
+ let platform_name = s.get_string_with_opts("loader.platform", &mut settings_query_opts);
if let Some(platform) = Platform::by_name(platform_name) {
self.set_default_platform(&platform);
}
});
-
+
Ok(())
}
}
diff --git a/view/bintxt/src/lib.rs b/view/bintxt/src/lib.rs
index 392fe4ce..4627c654 100644
--- a/view/bintxt/src/lib.rs
+++ b/view/bintxt/src/lib.rs
@@ -7,24 +7,24 @@ use ihex::*;
use srec::*;
use titxt::*;
-use std::ops::Range;
-use log::LevelFilter;
use binaryninja::logger::Logger;
+use log::LevelFilter;
+use std::ops::Range;
#[no_mangle]
#[allow(non_snake_case)]
pub extern "C" fn CorePluginInit() -> bool {
Logger::new("BINTXT").with_level(LevelFilter::Info).init();
- binaryninja::custombinaryview::register_view_type(c"ti-txt", c"TI-TXT", |core| {
+ binaryninja::custom_binary_view::register_view_type(c"ti-txt", c"TI-TXT", |core| {
TiTxtViewConstructor { core }
});
- binaryninja::custombinaryview::register_view_type(c"srec", c"Motorola S-record", |core| {
+ binaryninja::custom_binary_view::register_view_type(c"srec", c"Motorola S-record", |core| {
SRecViewConstructor { core }
});
- binaryninja::custombinaryview::register_view_type(c"ihex", c"Intel HEX", |core| {
+ binaryninja::custom_binary_view::register_view_type(c"ihex", c"Intel HEX", |core| {
IHexViewConstructor { core }
});
diff --git a/view/bintxt/src/srec.rs b/view/bintxt/src/srec.rs
index d11e5fd5..beba98b0 100644
--- a/view/bintxt/src/srec.rs
+++ b/view/bintxt/src/srec.rs
@@ -1,5 +1,5 @@
-use binaryninja::binaryview::{BinaryView, BinaryViewBase, BinaryViewExt};
-use binaryninja::custombinaryview::{
+use binaryninja::binary_view::{BinaryView, BinaryViewBase, BinaryViewExt};
+use binaryninja::custom_binary_view::{
BinaryViewType, BinaryViewTypeBase, CustomBinaryView, CustomBinaryViewType, CustomView,
CustomViewBuilder,
};
@@ -212,7 +212,7 @@ impl CustomBinaryViewType for SRecViewConstructor {
parent: &BinaryView,
builder: CustomViewBuilder<'builder, Self>,
) -> Result<CustomView<'builder>, ()> {
- let bytes = parent.len();
+ let bytes = parent.len() as usize;
let mut buf = vec![0; bytes];
let bytes_read = parent.read(&mut buf, 0);
if bytes_read != bytes {
diff --git a/view/bintxt/src/titxt.rs b/view/bintxt/src/titxt.rs
index 6cb006ab..d9b766e4 100644
--- a/view/bintxt/src/titxt.rs
+++ b/view/bintxt/src/titxt.rs
@@ -1,5 +1,5 @@
-use binaryninja::binaryview::{BinaryView, BinaryViewBase, BinaryViewExt};
-use binaryninja::custombinaryview::{
+use binaryninja::binary_view::{BinaryView, BinaryViewBase, BinaryViewExt};
+use binaryninja::custom_binary_view::{
BinaryViewType, BinaryViewTypeBase, CustomBinaryView, CustomBinaryViewType, CustomView,
CustomViewBuilder,
};
@@ -172,7 +172,7 @@ impl CustomBinaryViewType for TiTxtViewConstructor {
parent: &BinaryView,
builder: CustomViewBuilder<'builder, Self>,
) -> Result<CustomView<'builder>, ()> {
- let bytes = parent.len();
+ let bytes = parent.len() as usize;
let mut buf = vec![0; bytes];
let bytes_read = parent.read(&mut buf, 0);
if bytes_read != bytes {