Skip to content

Commit

Permalink
Makes modifications in accordance with R2Pipe API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmaydd authored and radare committed Jul 15, 2017
1 parent f393f0c commit c259e86
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 20 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 2 additions & 0 deletions minidec/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extern crate radeco_lib;
extern crate r2pipe;
extern crate r2api;
extern crate env_logger;

mod cli;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/valueset/analyzer_wysinwyx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 1 addition & 0 deletions src/backend/lang_c/c_ast_constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/containers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
18 changes: 7 additions & 11 deletions src/frontend/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ 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<FunctionInfo>;
fn instructions_at(&mut self, u64) -> Vec<LOpInfo>;
fn register_profile(&mut self) -> LRegInfo;
fn flags(&mut self) -> Vec<LFlagInfo>;
fn section_map(&mut self) -> Vec<LSectionInfo>;
fn strings(&mut self) -> Vec<LStringInfo>;

fn send(&mut self, _: &str) { }

Expand Down Expand Up @@ -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<FunctionInfo> {
let fns = self.fn_list();
fns.expect("Failed to load funtion info from r2")
Expand All @@ -97,10 +97,6 @@ impl Source for R2 {
self.sections().expect("Failed to get section info from r2")
}

fn strings(&mut self) -> Vec<LStringInfo> {
self.strings(false).expect("Failed to load strings from r2")
}

fn send(&mut self, s: &str) {
self.send(s);
}
Expand Down Expand Up @@ -159,6 +155,10 @@ impl FileSource {
base_name: base_name.to_owned(),
}
}

pub fn strings(&mut self) -> Vec<LStringInfo> {
serde_json::from_str(&self.read_file(suffix::STRING)).expect("Failed to decode json")
}
}

impl Source for FileSource {
Expand All @@ -182,10 +182,6 @@ impl Source for FileSource {
fn section_map(&mut self) -> Vec<LSectionInfo> {
serde_json::from_str(&self.read_file(suffix::SECTION)).expect("Failed to decode json")
}

fn strings(&mut self) -> Vec<LStringInfo> {
serde_json::from_str(&self.read_file(suffix::STRING)).expect("Failed to decode json")
}
}

impl From<R2> for FileSource {
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/ssaconstructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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};
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/middle/regfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion tests/bin_ls_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/complete_test1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c259e86

Please sign in to comment.