Permalink
Browse files

Impl r2 integration

  • Loading branch information...
kriw authored and XVilka committed Aug 11, 2018
1 parent b7e5c96 commit 68d97583d1a65e7afe3f3416a2aa17ade9034a2f
Showing with 53 additions and 23 deletions.
  1. +1 −8 Cargo.toml
  2. +9 −0 Makefile
  3. +6 −0 README.md
  4. +22 −0 p/Makefile
  5. +15 −13 {src/c → p}/core_pdd.c
  6. BIN p/radeco_pdd.so
  7. 0 src/lib.rs
  8. +0 −2 src/main.rs
View
@@ -6,10 +6,6 @@ authors = [
"Sushant <sushant.dinesh94@gmail.com>"
]
[lib]
name = "radeco_pdc"
crate-type = ["dylib"]
[features]
default = []
trace_log = ["radeco-lib/trace_log"]
@@ -20,9 +16,9 @@ rustc-serialize = "*"
log = "*"
base64 = "0.9.2"
rustyline = "1.0.0"
libc = "0.2.0"
[dependencies.r2pipe]
# path = "../r2pipe.rs"
git = "https://github.com/radareorg/r2pipe.rs"
[dependencies.r2api]
@@ -41,6 +37,3 @@ codegen-units = 4
lto = false
opt-level = 0
codegen-units = 4
[build-dependencies]
cc = "1.0.18"
View
@@ -1,8 +1,17 @@
all:
cargo build
make -C p build
run:
cargo run
install:
cargo install
make -C p
uninstall:
cargo uninstall
make -C p uninstall
clean:
cargo clean
View
@@ -40,6 +40,12 @@ fn sym.main () {
>>
```
## Installation
```shell
make install
```
## License
Licensed under The BSD 3-Clause License. Please check [COPYING](https://github.com/radare/radeco/blob/master/COPYING) file for
complete license.
View
@@ -0,0 +1,22 @@
CFLAGS=$(shell pkg-config --cflags r_core)
PLUGDIR=$(shell r2 -H R2_USER_PLUGINS)
LIBEXT=$(shell r2 -H LIBEXT)
TARGET=radeco_pdd.$(LIBEXT)
all:
$(MAKE) build
$(MAKE) install
build:
$(CC) $(CFLAGS) $(LDFLAGS) -shared -fPIC core_pdd.c -o $(TARGET)
install:
mkdir -p $(PLUGDIR)
rm -rf $(PLUGDIR)/$(TARGET)
cp -rf $(TARGET) $(PLUGDIR)/
uninstall:
rm -rf $(PLUGDIR)/$(TARGET)
clean:
rm -rf $(TARGET)
@@ -1,15 +1,12 @@
#include <r_anal.h>
#include <r_cmd.h>
#include <r_cons.h>
#include <r_core.h>
#include <r_lib.h>
#include <r_types.h>
#include <stdlib.h>
#include <string.h>
const int PORT = 8080;
static RCore *core_link = 0;
static char *radeco_path = "./radeco";
#define SETDESC(x, y) r_config_node_desc(x, y)
#define SETPREF(x, y, z) SETDESC(r_config_set(core->config, x, y), z)
const int PORT = 11111;
static char *radeco_path = "radeco";
static FILE *radeco_p = NULL;
void spawn_http_srv(RCore *core) {
@@ -19,6 +16,7 @@ void spawn_http_srv(RCore *core) {
}
if (!is_called) {
char port_str[10];
SETPREF("http.log", "false", "Show HTTP requests processed");
snprintf(port_str, 9, " %d", PORT);
r_core_rtr_http(core, '&', '\0', port_str);
}
@@ -28,26 +26,30 @@ void spawn_http_srv(RCore *core) {
void usage() {
eprintf("Usage: pdd[ ?ac] <func> plugin for radeco\n");
eprintf("| pdd <func> decompile current function\n");
eprintf("| pdd? show this screen\n");
eprintf("| pdd? show this help\n");
eprintf("| pdda <func> analyze current function with radeco\n");
eprintf("| pddc send information to radeco\n");
eprintf("| pddr <cmd> send <cmd> to radeco directly\n");
}
int cmd_pdd(const char *input) {
if (input == NULL) {
return true;
}
const char *func = input + 1;
const char *query = input + 1;
switch (input[0]) {
case ' ':
fprintf(radeco_p, "decompile %s\n", func);
fprintf(radeco_p, "decompile %s\n", query);
break;
case 'a':
fprintf(radeco_p, "analyze %s\n", func);
fprintf(radeco_p, "analyze %s\n", query);
break;
case 'c':
fprintf(radeco_p, "connect %d\n", PORT);
break;
case 'r':
fprintf(radeco_p, "%s\n", query);
break;
case '\0':
case '?':
default:
@@ -73,7 +75,7 @@ int init(void *user, const char *_input) {
RCorePlugin r_core_plugin_test = {.name = "radeco",
.desc = "r2 interface for radeco",
.license = "",
.license = "BSD 3-Clause",
.call = cmd,
.init = init};
View
Binary file not shown.
View
No changes.
View
@@ -31,7 +31,6 @@ use std::process;
use std::rc::Rc;
use std::str;
use std::sync::Arc;
use std::sync::Mutex;
// On unix platforms you can use ANSI escape sequences
#[cfg(unix)]
@@ -52,7 +51,6 @@ fn main() {
let mut terms = line.split_whitespace();
let o1 = terms.next();
let o2 = terms.next();
println!("radeco input: {}", line);
cmd(o1, o2, &mut proj);
}
Err(ReadlineError::Interrupted) |

0 comments on commit 68d9758

Please sign in to comment.