Add test-r_dehug example and minor bindings update
This commit is contained in:
parent
cf78623a28
commit
5781931227
|
@ -152,3 +152,7 @@ Trust no one, either a zero. Both lie.
|
|||
EIP = 0x41414141
|
||||
/dev/brain: No such file or directory
|
||||
Virtual machines are great, but you lose the ability to kick the hardware
|
||||
Charlie! We are here
|
||||
The door is everything.
|
||||
The door controls time and space.
|
||||
The door can see into your soul.
|
||||
|
|
|
@ -14,7 +14,7 @@ static int backup_fd = -1;
|
|||
|
||||
R_API int r_cons_pipe_open(const char *file, int append) {
|
||||
int fd = r_sandbox_open (file,
|
||||
O_BINARY | O_RDWR | O_CREAT | (append?O_APPEND:O_TRUNC), 0644);
|
||||
O_BINARY | O_RDWR | O_CREAT | (append? O_APPEND: O_TRUNC), 0644);
|
||||
if (fd==-1) {
|
||||
eprintf ("r_cons_pipe_open: Cannot open file '%s'\n", file);
|
||||
return -1;
|
||||
|
@ -26,6 +26,7 @@ R_API int r_cons_pipe_open(const char *file, int append) {
|
|||
if (_dup2 (1, backup_fd) == -1) {
|
||||
#else
|
||||
backup_fd = sysconf (_SC_OPEN_MAX)-(fd-2); // portable getdtablesize()
|
||||
if (backup_fd <2) backup_fd = 2002-(fd-2); // fallback
|
||||
if (dup2 (1, backup_fd) == -1) {
|
||||
#endif
|
||||
eprintf ("Cannot dup stdout to %d\n", backup_fd);
|
||||
|
|
|
@ -699,7 +699,8 @@ R_API int r_core_cmd_pipe(RCore *core, char *radare_cmd, char *shell_cmd) {
|
|||
int fds[2];
|
||||
int stdout_fd;
|
||||
#endif
|
||||
int ret = -1, pipecolor = -1;
|
||||
int olen, ret = -1, pipecolor = -1;
|
||||
char *str, *out = NULL;
|
||||
if (!r_config_get_i (core->config, "scr.pipecolor")) {
|
||||
pipecolor = r_config_get_i (core->config, "scr.color");
|
||||
r_config_set_i (core->config, "scr.color", 0);
|
||||
|
@ -711,8 +712,8 @@ R_API int r_core_cmd_pipe(RCore *core, char *radare_cmd, char *shell_cmd) {
|
|||
*_ptr = '\0';
|
||||
_ptr++;
|
||||
}
|
||||
int olen = 0;
|
||||
char *str, *out = NULL;
|
||||
olen = 0;
|
||||
out = NULL;
|
||||
// TODO: implement foo
|
||||
str = r_core_cmd_str (core, radare_cmd);
|
||||
r_sys_cmd_str_full (shell_cmd+1, str, &out, &olen, NULL);
|
||||
|
|
|
@ -605,7 +605,6 @@ eprintf ("XXX: This command conflicts with 'ar'\n");
|
|||
}
|
||||
break;
|
||||
case 'g':
|
||||
eprintf ("INPUT (%s)\n", input);
|
||||
switch (input[1]) {
|
||||
case 't':
|
||||
{
|
||||
|
@ -685,6 +684,7 @@ eprintf ("XXX: This command conflicts with 'ar'\n");
|
|||
r_core_anal_graph (core, r_num_math (core->num, arg),
|
||||
R_CORE_ANAL_GRAPHBODY);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 't':
|
||||
|
|
|
@ -913,7 +913,7 @@ static int cmd_debug(void *data, const char *input) {
|
|||
}
|
||||
break;
|
||||
case 'f':
|
||||
step_until_eof(core);
|
||||
step_until_eof (core);
|
||||
break;
|
||||
case 'u':
|
||||
r_reg_arena_swap (core->dbg->reg, R_TRUE);
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
#!/usr/bin/python2
|
||||
#
|
||||
# Python example for using loading fatmach0 binaries
|
||||
# test file:
|
||||
# http://radare.org/get/bin/fatmach0-3true
|
||||
import sys
|
||||
try:
|
||||
from r_core import RCore
|
||||
except:
|
||||
from r2.r_core import RCore
|
||||
|
||||
core = RCore()
|
||||
#core.file_open("/bin/ls", False, 0)
|
||||
|
||||
# Detect sub-bins in fatmach0
|
||||
path="/bin/ls"
|
||||
path="./a.out"
|
||||
dbgpath="dbg://"+path
|
||||
core.bin.load (path, 0)
|
||||
print ("Supported archs: %d"%core.bin.narch)
|
||||
|
||||
for i in range (0,core.bin.narch):
|
||||
core.bin.select_idx (i)
|
||||
info = core.bin.get_info ()
|
||||
if info:
|
||||
print ("%d: %s %s"%(i,info.arch,info.bits))
|
||||
|
||||
# Load file in core
|
||||
#core.config.set ("asm.arch", "x86");
|
||||
#core.config.set ("asm.bits", "32");
|
||||
#core.config.set ("asm.bits", "64");
|
||||
core.config.set ("cfg.debug", "true")
|
||||
|
||||
f = core.file_open(dbgpath, False, 0)
|
||||
#core.bin_load (None)
|
||||
core.bin_load (path)
|
||||
|
||||
# show entrypoint
|
||||
print ("Entrypoint : 0x%x"%(core.num.get ("entry0")))
|
||||
|
||||
core.cmd0 ("dpa `i~^fd[1]`")
|
||||
print (core.cmd_str ("dh native")) # TODO must be implicit
|
||||
print (core.cmd_str ("dm"))
|
||||
print (core.cmd_str ("dr="))
|
||||
core.cmd0(".dr*")
|
||||
|
||||
for i in range(1,32):
|
||||
core.cmd0("ds")
|
||||
core.cmd0(".dr*")
|
||||
print (core.cmd_str ("pi 1 @ rip"))
|
||||
|
||||
print (core.cmd_str ("dc"))
|
||||
print ("REASON IS %d"%(core.dbg.reason))
|
||||
print ("SIGNUM IS %d"%(core.dbg.signum))
|
||||
core.cmd0(".dr*")
|
||||
print (core.cmd_str ("dr="))
|
|
@ -38,10 +38,10 @@ namespace Radare {
|
|||
[CCode (cheader_filename="r_cmd.h", cprefix="r_cmd_", cname="RCmd", free_function="r_cmd_free")]
|
||||
public class RCmd {
|
||||
[CCode (has_target=false, cname="RCmdCallback")]
|
||||
public delegate bool RCmdCallback (void *user, string cmd);
|
||||
public delegate bool Callback (void *user, string cmd);
|
||||
public RCmd ();
|
||||
public void set_data (void *data);
|
||||
public bool @add (string cmd, string desc, RCmdCallback cb);
|
||||
public bool @add (string cmd, string desc, Callback cb);
|
||||
public bool add_long (string cmd, string scmd, string desc);
|
||||
public bool del (string cmd);
|
||||
public bool call (string cmd);
|
||||
|
|
|
@ -3,8 +3,33 @@
|
|||
[Compact]
|
||||
[CCode (cheader_filename="r_debug.h", cname="RDebug", free_function="r_debug_free", cprefix="r_debug_")]
|
||||
public class Radare.RDebug {
|
||||
public int arch;
|
||||
public int bits;
|
||||
public int pid;
|
||||
public int tid;
|
||||
public bool swstep;
|
||||
public int steps;
|
||||
public int newstate;
|
||||
public int reason;
|
||||
public int signum;
|
||||
|
||||
public RBreakpoint bp;
|
||||
public RDebug(int hard);
|
||||
/*
|
||||
public int steps;
|
||||
public int pid;
|
||||
public int tid;
|
||||
public bool swstep;
|
||||
public int newstate;
|
||||
//public RDebug.Trace *trace;
|
||||
public RDebug.Trace trace;
|
||||
public bool stop_all_threads;
|
||||
public RReg reg;
|
||||
public RAnal anal;
|
||||
|
||||
public RList<RDebug.Map> maps;
|
||||
public RList<RDebug.Map> maps_user;
|
||||
*/
|
||||
|
||||
public bool use(string plugin);
|
||||
|
||||
|
@ -160,19 +185,6 @@ public class Radare.RDebug {
|
|||
uint64 stamp;
|
||||
}
|
||||
|
||||
public int steps;
|
||||
public int pid;
|
||||
public int tid;
|
||||
public bool swstep;
|
||||
public int newstate;
|
||||
//public RDebug.Trace *trace;
|
||||
public RDebug.Trace trace;
|
||||
public bool stop_all_threads;
|
||||
public RReg reg;
|
||||
public RAnal anal;
|
||||
|
||||
public RList<RDebug.Map> maps;
|
||||
public RList<RDebug.Map> maps_user;
|
||||
|
||||
|
||||
//public int pid_add();
|
||||
|
|
Loading…
Reference in New Issue