New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate with r2 #23

Merged
merged 9 commits into from Aug 12, 2018

Minor fixes

  • Loading branch information...
kriw committed Aug 11, 2018
commit 5d64e07cfb4666b327c3e3a61e054dc98dffd711
View
@@ -8,7 +8,7 @@ all:
$(MAKE) install
build:
$(CC) $(CFLAGS) $(LDFLAGS) -shared -fPIC core_pdd.c -o $(TARGET)
$(CC) $(CFLAGS) $(LDFLAGS) -shared -fPIC radeco_pdd.c -o $(TARGET)
install:
mkdir -p $(PLUGDIR)
@@ -55,7 +55,7 @@ int cmd_pdd(const char *input) {
fprintf(radeco_p, "analyze %s\n", query);
break;
case 'c':
fprintf(radeco_p, "connect %d\n", PORT);
fprintf(radeco_p, "connect http://localhost:%d\n", PORT);
break;
case 'r':
fprintf(radeco_p, "%s\n", query);
View
@@ -79,8 +79,13 @@ fn cmd(op1: Option<&str>, op2: Option<&str>, proj_opt: &mut Option<RadecoProject
*proj_opt = Some(load_proj_by_path(path));
return;
}
(Some(command::CONNECT), Some(port)) => {
match load_proj_by_tcp(port) {
(Some(command::CONNECT), Some(url)) => {
let p_opt = if url.starts_with("http://") {
load_proj_http(&url[7..])
} else {
load_proj_tcp(&url[6..])
};
match p_opt {
Ok(proj) => *proj_opt = Some(proj),
Err(msg) => println!("{}", msg),
}
@@ -170,16 +175,25 @@ fn load_proj_by_path(path: &str) -> RadecoProject {
p
}
fn load_proj_by_tcp(port: &str) -> Result<RadecoProject, &'static str> {
let r2p = R2Pipe::http(&format!("localhost:{}", port))?;
fn load_proj_tcp(url: &str) -> Result<RadecoProject, &'static str> {
let r2p = R2Pipe::tcp(url)?;
Ok(load_project_by_r2pipe(r2p))
}
fn load_proj_http(url: &str) -> Result<RadecoProject, &'static str> {
let r2p = R2Pipe::http(url)?;
Ok(load_project_by_r2pipe(r2p))
}
fn load_project_by_r2pipe(r2p: R2Pipe) -> RadecoProject {
let r2 = R2::from(r2p);
let r2w = Rc::new(RefCell::new(r2));
let mut p = ProjectLoader::new().source(Rc::new(r2w)).load();
let regfile = p.regfile().clone();
for mut xy in p.iter_mut() {
analyze_mod(regfile.clone(), xy.module);
}
Ok(p)
p
}
fn fn_list(proj: &RadecoProject) -> Vec<String> {
ProTip! Use n and p to navigate between commits in a pull request.