diff --git a/Cargo.toml b/Cargo.toml index 2f56683f..09401171 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,8 +30,9 @@ clippy = {version = "0.0.61", optional = true} [dependencies.r2pipe] git = "https://github.com/radare/r2pipe.rs" -#path = "../r2pipe.rs" + +[dependencies.r2api] +git = "https://github.com/radare/radare2-r2pipe-api" [dependencies.esil] git = "https://github.com/radare/esil-rs" -#path = "../esil-rs" diff --git a/minidec/main.rs b/minidec/main.rs index a2f48de5..8498fc7d 100644 --- a/minidec/main.rs +++ b/minidec/main.rs @@ -1,5 +1,6 @@ extern crate radeco_lib; extern crate r2pipe; +extern crate r2api; extern crate env_logger; mod cli; @@ -10,6 +11,7 @@ use std::io::Write; use std::path::{Path, PathBuf}; use r2pipe::r2::R2; +use r2api::api_trait::R2Api; use radeco_lib::analysis::cse::CSE; use radeco_lib::analysis::sccp; use radeco_lib::analysis::valueset::analyzer_wysinwyx::FnAnalyzer; diff --git a/src/analysis/valueset/analyzer_wysinwyx.rs b/src/analysis/valueset/analyzer_wysinwyx.rs index 04906551..082cf161 100644 --- a/src/analysis/valueset/analyzer_wysinwyx.rs +++ b/src/analysis/valueset/analyzer_wysinwyx.rs @@ -28,7 +28,7 @@ use middle::ssa::ssastorage::{NodeData,SSAStorage}; use middle::ir::{MOpcode,MAddress,MArity}; use middle::ir_writer::{IRWriter}; -use r2pipe::structs::{LRegInfo}; +use r2api::structs::{LRegInfo}; //use esil::parser::{Parse, Parser}; //use esil::lexer::{Token, Tokenizer}; diff --git a/src/backend/lang_c/c_ast_constructor.rs b/src/backend/lang_c/c_ast_constructor.rs index 038af083..85ee8b63 100644 --- a/src/backend/lang_c/c_ast_constructor.rs +++ b/src/backend/lang_c/c_ast_constructor.rs @@ -85,6 +85,7 @@ mod test { use analysis::interproc::interproc::analyze_module; use analysis::interproc::summary; use r2pipe::r2::R2; + use r2api::api_trait::R2Api; #[test] #[ignore] diff --git a/src/frontend/containers.rs b/src/frontend/containers.rs index 233b43fe..7cc9c6ab 100644 --- a/src/frontend/containers.rs +++ b/src/frontend/containers.rs @@ -3,7 +3,7 @@ use std::collections::{BTreeSet, HashMap}; use std::{thread, fmt, sync, hash}; -use r2pipe::structs::{FunctionInfo, LOpInfo, LRegInfo, LVarInfo}; +use r2api::structs::{FunctionInfo, LOpInfo, LRegInfo, LVarInfo}; use petgraph::graph::NodeIndex; diff --git a/src/frontend/source.rs b/src/frontend/source.rs index 8443dad6..a45b46c1 100644 --- a/src/frontend/source.rs +++ b/src/frontend/source.rs @@ -6,8 +6,9 @@ use std::io::{Read, Write}; use serde_json; -use r2pipe::structs::{FunctionInfo, LFlagInfo, LOpInfo, LRegInfo, LSectionInfo, LStringInfo}; +use r2api::api_trait::R2Api; use r2pipe::r2::R2; +use r2api::structs::{FunctionInfo, LFlagInfo, LOpInfo, LRegInfo, LSectionInfo, LStringInfo}; pub trait Source { fn functions(&mut self) -> Vec; @@ -15,7 +16,6 @@ pub trait Source { fn register_profile(&mut self) -> LRegInfo; fn flags(&mut self) -> Vec; fn section_map(&mut self) -> Vec; - fn strings(&mut self) -> Vec; fn send(&mut self, _: &str) { } @@ -71,7 +71,7 @@ pub trait Source { } // Implementation of `Source` trait for R2. -impl Source for R2 { +impl Source for R2 where R2: R2Api { fn functions(&mut self) -> Vec { let fns = self.fn_list(); fns.expect("Failed to load funtion info from r2") @@ -97,10 +97,6 @@ impl Source for R2 { self.sections().expect("Failed to get section info from r2") } - fn strings(&mut self) -> Vec { - self.strings(false).expect("Failed to load strings from r2") - } - fn send(&mut self, s: &str) { self.send(s); } @@ -159,6 +155,10 @@ impl FileSource { base_name: base_name.to_owned(), } } + + pub fn strings(&mut self) -> Vec { + serde_json::from_str(&self.read_file(suffix::STRING)).expect("Failed to decode json") + } } impl Source for FileSource { @@ -182,10 +182,6 @@ impl Source for FileSource { fn section_map(&mut self) -> Vec { serde_json::from_str(&self.read_file(suffix::SECTION)).expect("Failed to decode json") } - - fn strings(&mut self) -> Vec { - serde_json::from_str(&self.read_file(suffix::STRING)).expect("Failed to decode json") - } } impl From for FileSource { diff --git a/src/frontend/ssaconstructor.rs b/src/frontend/ssaconstructor.rs index f027e86f..91a7e19f 100644 --- a/src/frontend/ssaconstructor.rs +++ b/src/frontend/ssaconstructor.rs @@ -16,7 +16,7 @@ use std::collections::HashMap; use petgraph::graph::NodeIndex; use std::{fmt, cmp}; -use r2pipe::structs::{LOpInfo, LRegInfo}; +use r2api::structs::{LOpInfo, LRegInfo}; use esil::parser::{Parse, Parser}; use esil::lexer::{Token, Tokenizer}; @@ -505,7 +505,7 @@ mod test { use std::fs::File; use std::io::prelude::*; use serde_json; - use r2pipe::structs::{LFunctionInfo, LRegInfo}; + use r2api::structs::{LFunctionInfo, LRegInfo}; use middle::ssa::ssastorage::SSAStorage; use middle::ir_writer::IRWriter; use middle::{dot, dce}; diff --git a/src/lib.rs b/src/lib.rs index 13113c33..a5ee3449 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,6 +53,7 @@ extern crate num; #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; extern crate r2pipe; +extern crate r2api; extern crate esil; diff --git a/src/middle/regfile.rs b/src/middle/regfile.rs index ce3186c0..50996b01 100644 --- a/src/middle/regfile.rs +++ b/src/middle/regfile.rs @@ -12,7 +12,7 @@ use std::cmp::Ordering; use std::collections::HashMap; use std::convert::From; -use r2pipe::structs::LRegInfo; +use r2api::structs::LRegInfo; use middle::ssa::ssa_traits::ValueType; diff --git a/tests/bin_ls_test.rs b/tests/bin_ls_test.rs index 8840735e..df3a6ac0 100644 --- a/tests/bin_ls_test.rs +++ b/tests/bin_ls_test.rs @@ -7,7 +7,7 @@ extern crate serde_json; use std::fs::File; use std::io::prelude::*; -use r2pipe::structs::{LFunctionInfo, LRegInfo}; +use r2api::structs::{LFunctionInfo, LRegInfo}; use radeco_lib::frontend::ssaconstructor::SSAConstruct; use radeco_lib::middle::ssa::ssastorage::SSAStorage; diff --git a/tests/complete_test1.rs b/tests/complete_test1.rs index f955771e..f02aba91 100644 --- a/tests/complete_test1.rs +++ b/tests/complete_test1.rs @@ -60,7 +60,7 @@ extern crate serde_json; use std::fs::File; use std::io::prelude::*; -use r2pipe::structs::{LFunctionInfo, LRegInfo}; +use r2api::structs::{LFunctionInfo, LRegInfo}; use radeco_lib::frontend::ssaconstructor::SSAConstruct; use radeco_lib::middle::ssa::ssastorage::SSAStorage;