mirror of
https://github.com/radareorg/radare2.git
synced 2024-10-11 12:54:45 +00:00
* Add bb_list() method to RAnalFcn class
* Handle function boundaries in 'pd' * Reset stack_ptr=0 when leaving a function body * Fix 'asm.bytes=false' (display flags as newlines) * Fix 's+' and 's-' (seek redo, seek undo) - Bindied in visual mode as 'u' and 'U' keys - Added 's*' command to list seeking history * Add dummy file.md5 eval var - TODO: must be done by rabin2 and checked by project file
This commit is contained in:
parent
22a6063852
commit
b8e98f3a00
8
TODO
8
TODO
@ -5,6 +5,14 @@
|
||||
|
||||
* r_cmd.vapi not done?!?
|
||||
|
||||
* add file.md5 check support when opening new file or project or so..
|
||||
|
||||
* anal bug:
|
||||
[0x08048eec]> pd 2
|
||||
0x08048eec 0 c20400 ret 0x4
|
||||
-> this opcodes increments the stack 8 bytes (4+4) . it is not handled correctly
|
||||
|
||||
|
||||
----------------------------------------[ todo
|
||||
33 decompilation -- we need better code analysis, but basic decompilation will be in 0.5
|
||||
29 bindiffing (graph) -- nibble is working on this too, pancake has some binary diffing in C
|
||||
|
@ -39,7 +39,6 @@ R_API RAnal *r_anal_free(RAnal *a) {
|
||||
|
||||
R_API RAnal *r_anal_init(RAnal *anal) {
|
||||
int i;
|
||||
|
||||
if (anal) {
|
||||
memset (anal, 0, sizeof (RAnal));
|
||||
anal->bbs = r_anal_bb_list_new ();
|
||||
|
@ -34,6 +34,7 @@ R_API RAnalFcn *r_anal_fcn_init(RAnalFcn *fcn) {
|
||||
if (fcn) {
|
||||
memset (fcn, 0, sizeof (RAnalFcn));
|
||||
fcn->addr = -1;
|
||||
fcn->stack = 0;
|
||||
fcn->vars = r_anal_var_list_new ();
|
||||
fcn->refs = r_anal_ref_list_new ();
|
||||
fcn->xrefs = r_anal_ref_list_new ();
|
||||
@ -61,6 +62,9 @@ R_API int r_anal_fcn(RAnal *anal, RAnalFcn *fcn, ut64 addr, ut8 *buf, ut64 len)
|
||||
fcn->size += oplen;
|
||||
/* TODO: Parse fastargs (R_ANAL_VAR_ARGREG), check negative ref meaning */
|
||||
switch (aop.stackop) {
|
||||
case R_ANAL_STACK_INCSTACK:
|
||||
fcn->stack += aop.value;
|
||||
break;
|
||||
case R_ANAL_STACK_SET:
|
||||
if (aop.ref > 0) {
|
||||
varname = r_str_dup_printf ("arg_%x", aop.ref);
|
||||
@ -137,3 +141,14 @@ R_API int r_anal_fcn_del(RAnal *anal, ut64 addr) {
|
||||
r_list_unlink (anal->fcns, fcni);
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API RList *r_anal_fcn_bb_list(RAnal *anal, RAnalFcn *fcn) {
|
||||
RAnalBB *bbi;
|
||||
RListIter *iter;
|
||||
RList *list = r_list_new ();
|
||||
r_list_foreach (anal->bbs, iter, bbi) {
|
||||
if (bbi->addr>=fcn->addr && bbi->addr<(fcn->addr+fcn->size))
|
||||
r_list_append (list, bbi);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
101
libr/core/cmd.c
101
libr/core/cmd.c
@ -3,6 +3,7 @@
|
||||
/* pancake<nopcode.org> */
|
||||
|
||||
#include "r_core.h"
|
||||
#include "r_io.h"
|
||||
#include "r_flags.h"
|
||||
#include "r_hash.h"
|
||||
#include "r_asm.h"
|
||||
@ -14,6 +15,7 @@
|
||||
#include <stdarg.h>
|
||||
/* TODO: move to print/disasm.c */
|
||||
static void r_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int len, int l) {
|
||||
RAnalFcn *fcni = NULL;
|
||||
int ret, idx, i, j, k;
|
||||
int middle = 0;
|
||||
int stack_ptr = 0, ostack_ptr;
|
||||
@ -50,6 +52,22 @@ static void r_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int len,
|
||||
|
||||
r_asm_set_pc (&core->assembler, core->offset);
|
||||
|
||||
#if 0
|
||||
/* find last function else stackptr=0 */
|
||||
{
|
||||
RAnalFcn *fcni;
|
||||
RListIter *iter;
|
||||
|
||||
r_list_foreach (core->anal.fcns, iter, fcni) {
|
||||
if (addr >= fcni->addr && addr<(fcni->addr+fcni->size)) {
|
||||
stack_ptr = fcni->stack;
|
||||
r_cons_printf ("/* function: %s (%d) */\n", fcni->name, fcni->size, stack_ptr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
reflines = r_anal_reflines_get (&core->anal, core->offset,
|
||||
buf, len, -1, linesout);
|
||||
for (i=idx=ret=0; idx < len && i<l; idx+=ret,i++) {
|
||||
@ -75,12 +93,47 @@ static void r_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int len,
|
||||
if (adistrick)
|
||||
middle = r_anal_reflines_middle (&core->anal,
|
||||
reflines, addr, analop.length);
|
||||
{
|
||||
int found = 0;
|
||||
RListIter *iter;
|
||||
RAnalFcn *f = fcni;
|
||||
r_list_foreach (core->anal.fcns, iter, fcni) {
|
||||
if (addr == fcni->addr) {
|
||||
r_cons_printf ("/* function: %s (%d) */\n", fcni->name, fcni->size);
|
||||
stack_ptr = 0;
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
fcni = f;
|
||||
}
|
||||
if (fcni) {
|
||||
if (addr >= fcni->addr+fcni->size-1) {
|
||||
r_cons_printf ("\\*");
|
||||
fcni = NULL;
|
||||
} else
|
||||
if (addr >= fcni->addr)
|
||||
r_cons_printf (": ");
|
||||
}
|
||||
flag = r_flag_get_i (&core->flags, core->offset+idx);
|
||||
if (flag && !show_bytes) {
|
||||
if (show_lines && line)
|
||||
r_cons_strcat (line);
|
||||
if (show_offset) {
|
||||
if (show_color)
|
||||
r_cons_printf (Color_GREEN"0x%08"PFMT64x" "Color_RESET, core->offset + idx);
|
||||
else r_cons_printf ("0x%08"PFMT64x" ", core->offset + idx);
|
||||
}
|
||||
r_cons_printf ("%s:\n", flag->name);
|
||||
}
|
||||
|
||||
if (show_lines && line)
|
||||
r_cons_strcat (line);
|
||||
if (show_offset) {
|
||||
if (show_color)
|
||||
r_cons_printf (Color_GREEN"0x%08"PFMT64x" "Color_RESET, core->offset + idx);
|
||||
r_cons_printf (Color_GREEN"0x%08"PFMT64x
|
||||
" "Color_RESET, core->offset + idx);
|
||||
else r_cons_printf ("0x%08"PFMT64x" ", core->offset + idx);
|
||||
}
|
||||
if (show_stackptr) {
|
||||
@ -98,10 +151,12 @@ static void r_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int len,
|
||||
break;
|
||||
}
|
||||
}
|
||||
r_cons_printf("%3d%s ", stack_ptr, stack_ptr!=ostack_ptr?"_":" ");
|
||||
r_cons_printf ("%3d%s ", stack_ptr,
|
||||
stack_ptr>ostack_ptr?"+":stack_ptr<ostack_ptr?"-":" ");
|
||||
}
|
||||
flag = r_flag_get_i (&core->flags, core->offset+idx);
|
||||
if (flag || show_bytes) {
|
||||
//flag = r_flag_get_i (&core->flags, core->offset+idx);
|
||||
//if (flag || show_bytes) {
|
||||
if (show_bytes) {
|
||||
char pad[64];
|
||||
char *str, *extra = " ";
|
||||
if (!flag) {
|
||||
@ -135,7 +190,9 @@ static void r_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int len,
|
||||
else r_cons_printf ("*[ %s%s] ", pad, str);
|
||||
} else r_cons_printf (" %s %s %s", pad, str, extra);
|
||||
free (str);
|
||||
} else r_cons_printf ("%*s ", (nb), "");
|
||||
} else {
|
||||
// r_cons_printf ("%*s ", (nb), "");
|
||||
}
|
||||
if (show_color) {
|
||||
switch (analop.type) {
|
||||
case R_ANAL_OP_TYPE_NOP:
|
||||
@ -153,6 +210,7 @@ static void r_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int len,
|
||||
r_cons_printf (Color_MAGENTA);
|
||||
break;
|
||||
case R_ANAL_OP_TYPE_RET:
|
||||
stack_ptr = 0;
|
||||
r_cons_printf (Color_RED);
|
||||
break;
|
||||
case R_ANAL_OP_TYPE_LOAD:
|
||||
@ -199,7 +257,7 @@ static void r_print_disasm(RPrint *p, RCore *core, ut64 addr, ut8 *buf, int len,
|
||||
if (strchr (line, '>'))
|
||||
memset (line, ' ', strlen (line));
|
||||
r_cons_strcat (line);
|
||||
r_cons_strcat ("; ------------------------------------\n");
|
||||
r_cons_strcat ("/* ------------ */\n");
|
||||
}
|
||||
free (line);
|
||||
}
|
||||
@ -750,7 +808,7 @@ static int cmd_seek(void *data, const char *input) {
|
||||
r_core_seek (core, off, 1);
|
||||
} else eprintf ("Usage: 'sr pc' ; seek to register\n");
|
||||
} else
|
||||
if (input[0] && input[1]) {
|
||||
if (input[0]) { // && input[1]) {
|
||||
st32 delta = (input[1]==' ')?2:1;
|
||||
off = r_num_math (&core->num, input + delta);
|
||||
if (input[0]==' ' && (input[1]=='+'||input[1]=='-'))
|
||||
@ -758,14 +816,24 @@ static int cmd_seek(void *data, const char *input) {
|
||||
switch (input[0]) {
|
||||
case ' ':
|
||||
r_core_seek (core, off, 1);
|
||||
r_io_sundo_push (&core->io);
|
||||
break;
|
||||
case '*':
|
||||
r_io_sundo_list (&core->io);
|
||||
break;
|
||||
case '+':
|
||||
if (input[1]=='+') delta = core->blocksize; else delta = off;
|
||||
r_core_seek_delta (core, delta);
|
||||
if (input[1]!='\0') {
|
||||
if (input[1]=='+') delta = core->blocksize; else delta = off;
|
||||
r_core_seek_delta (core, delta);
|
||||
} else if (r_io_sundo_redo (&core->io))
|
||||
r_core_seek (core, core->io.off, 0);
|
||||
break;
|
||||
case '-':
|
||||
if (input[1]=='-') delta = -core->blocksize; else delta = -off;
|
||||
r_core_seek_delta (core, delta);
|
||||
if (input[1]!='\0') {
|
||||
if (input[1]=='-') delta = -core->blocksize; else delta = -off;
|
||||
r_core_seek_delta (core, delta);
|
||||
} else if (r_io_sundo (&core->io))
|
||||
r_core_seek (core, core->io.off, 0);
|
||||
break;
|
||||
case 'a':
|
||||
off = core->blocksize;
|
||||
@ -790,6 +858,9 @@ static int cmd_seek(void *data, const char *input) {
|
||||
r_cons_printf (
|
||||
"Usage: s[+-] [addr]\n"
|
||||
" s 0x320 ; seek to this address\n"
|
||||
" s- ; undo seek\n"
|
||||
" s+ ; redo seek\n"
|
||||
" s* ; list undo seek history\n"
|
||||
" s++ ; seek blocksize bytes forward\n"
|
||||
" s-- ; seek blocksize bytes backward\n"
|
||||
" s+ 512 ; seek 512 bytes forward\n"
|
||||
@ -922,6 +993,7 @@ static int cmd_bsize(void *data, const char *input) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// move it out // r_diff maybe?
|
||||
static int radare_compare(RCore *core, const ut8 *f, const ut8 *d, int len) {
|
||||
int i, eq = 0;
|
||||
@ -939,7 +1011,6 @@ static int radare_compare(RCore *core, const ut8 *f, const ut8 *d, int len) {
|
||||
return len-eq;
|
||||
}
|
||||
|
||||
|
||||
static int cmd_cmp(void *data, const char *input) {
|
||||
RCore *core = data;
|
||||
FILE *fd;
|
||||
@ -1233,6 +1304,7 @@ static int cmd_flag(void *data, const char *input) {
|
||||
|
||||
static void cmd_syscall_do(RCore *core, int num) {
|
||||
int i;
|
||||
char str[64];
|
||||
RSyscallItem *item = r_syscall_get (&core->syscall, num, -1);
|
||||
r_cons_printf ("%d = %s (", item->num, item->name);
|
||||
// TODO: move this to r_syscall
|
||||
@ -1249,13 +1321,11 @@ static void cmd_syscall_do(RCore *core, int num) {
|
||||
r_cons_printf ("%"PFMT64d"", arg);
|
||||
break;
|
||||
case 'z':
|
||||
{ char str[64];
|
||||
r_io_read_at (&core->io, arg, (ut8*)str, sizeof (str));
|
||||
// TODO: filter zero terminated string
|
||||
str[63] = '\0';
|
||||
r_str_filter (str, strlen (str));
|
||||
r_cons_printf ("\"%s\"", str);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
r_cons_printf ("0x%08"PFMT64x"", arg);
|
||||
@ -2904,13 +2974,14 @@ int r_core_cmd_init(RCore *core) {
|
||||
r_cmd_add (&core->cmd, "yank", "yank bytes", &cmd_yank);
|
||||
r_cmd_add (&core->cmd, "Visual", "enter visual mode", &cmd_visual);
|
||||
r_cmd_add (&core->cmd, "!", "run system command", &cmd_system);
|
||||
// XXX WTF DUPPED CMD!?!?! //
|
||||
r_cmd_add (&core->cmd, "|", "run io system command", &cmd_io_system);
|
||||
r_cmd_add (&core->cmd, "|", "io pipe", &cmd_iopipe);
|
||||
r_cmd_add (&core->cmd, "#", "calculate hash", &cmd_hash);
|
||||
r_cmd_add (&core->cmd, "?", "help message", &cmd_help);
|
||||
r_cmd_add (&core->cmd, ".", "interpret", &cmd_interpret);
|
||||
r_cmd_add (&core->cmd, "/", "search kw, pattern aes", &cmd_search);
|
||||
r_cmd_add (&core->cmd, "(", "macro", &cmd_macro);
|
||||
r_cmd_add (&core->cmd, "|", "io pipe", &cmd_iopipe);
|
||||
r_cmd_add (&core->cmd, "quit", "exit program session", &cmd_quit);
|
||||
|
||||
return 0;
|
||||
|
@ -199,6 +199,7 @@ R_API int r_core_config_init(RCore *core) {
|
||||
r_config_set_cb (cfg, "io.va", "false", &config_iova_callback);
|
||||
r_config_set_cb (cfg, "io.cache", "false", &config_iocache_callback);
|
||||
r_config_set (cfg, "file.project", "");
|
||||
r_config_set (cfg, "file.md5", "");
|
||||
r_config_set (cfg, "file.type", "");
|
||||
/* TODO cmd */
|
||||
#if 0
|
||||
|
@ -137,6 +137,7 @@ R_API int r_core_init(RCore *core) {
|
||||
|
||||
core->search = r_search_new(R_SEARCH_KEYWORD);
|
||||
r_io_init (&core->io);
|
||||
r_io_undo_enable (&core->io, 1, 0); // TODO: configurable via eval
|
||||
//r_cmd_macro_init (&core->macro);
|
||||
core->file = NULL;
|
||||
INIT_LIST_HEAD (&core->files);
|
||||
|
@ -541,6 +541,14 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
|
||||
ocursor=-1;
|
||||
} else r_core_cmd (core, "s+1", 0);
|
||||
break;
|
||||
case 'u':
|
||||
if (r_io_sundo (&core->io))
|
||||
r_core_seek (core, core->io.off, 0);
|
||||
break;
|
||||
case 'U':
|
||||
if (r_io_sundo_redo (&core->io))
|
||||
r_core_seek (core, core->io.off, 0);
|
||||
break;
|
||||
case 'j':
|
||||
if (curset) {
|
||||
cursor+=16;
|
||||
@ -619,6 +627,8 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
|
||||
" P||p - rotate print modes\n"
|
||||
" /*+- - change block size\n"
|
||||
" cC - toggle cursor and colors\n"
|
||||
" uU - undo/redo seek\n"
|
||||
" mK/'K - mark/go to Key (any key)\n"
|
||||
" :cmd - run radare command\n"
|
||||
" ;[-]cmt - add/remove comment\n"
|
||||
" q - back to radare shell\n");
|
||||
|
@ -152,6 +152,7 @@ typedef struct r_anal_fcn_t {
|
||||
char *name;
|
||||
ut64 addr;
|
||||
ut64 size;
|
||||
int stack;
|
||||
RList *vars;
|
||||
RList *refs;
|
||||
RList *xrefs;
|
||||
@ -238,6 +239,7 @@ R_API RAnalFcn *r_anal_fcn_init(RAnalFcn *fcn);
|
||||
R_API int r_anal_fcn(RAnal *anal, RAnalFcn *fcn, ut64 addr, ut8 *buf, ut64 len);
|
||||
R_API int r_anal_fcn_add(RAnal *anal, ut64 addr, ut64 size, const char *name);
|
||||
R_API int r_anal_fcn_del(RAnal *anal, ut64 addr);
|
||||
R_API RList *r_anal_fcn_bb_list(RAnal *anal, RAnalFcn *fcn);
|
||||
|
||||
/* ref.c */
|
||||
R_API RAnalRef *r_anal_ref_new();
|
||||
|
@ -221,9 +221,9 @@ R_API ut64 r_io_section_offset_to_vaddr(RIO *io, ut64 offset);
|
||||
R_API int r_io_undo_init(RIO *io);
|
||||
R_API void r_io_undo_enable(RIO *io, int seek, int write);
|
||||
/* seek undo */
|
||||
R_API void r_io_sundo(RIO *io);
|
||||
R_API int r_io_sundo(RIO *io);
|
||||
R_API ut64 r_io_sundo_last(RIO *io);
|
||||
R_API void r_io_sundo_redo(RIO *io);
|
||||
R_API int r_io_sundo_redo(RIO *io);
|
||||
R_API void r_io_sundo_push(RIO *io);
|
||||
R_API void r_io_sundo_reset(RIO *io);
|
||||
R_API void r_io_sundo_list(RIO *io);
|
||||
|
@ -277,7 +277,8 @@ R_API ut64 r_io_seek(struct r_io_t *io, ut64 offset, int whence) {
|
||||
else len = lseek (io->fd, offset, posix_whence);
|
||||
if (len != -1) {
|
||||
io->off = offset;
|
||||
r_io_sundo_push (io);
|
||||
// XXX this can be tricky.. better not to use this .. must be deprecated
|
||||
// r_io_sundo_push (io);
|
||||
ret = io->va ? r_io_section_offset_to_vaddr (io, io->off) : io->off;
|
||||
}
|
||||
return ret;
|
||||
|
109
libr/io/undo.c
109
libr/io/undo.c
@ -1,20 +1,15 @@
|
||||
/* radare - LGPL - Copyright 2007-2009 pancake<nopcode.org> */
|
||||
/* radare - LGPL - Copyright 2007-2010 pancake<nopcode.org> */
|
||||
|
||||
#include <r_io.h>
|
||||
|
||||
#define cons_printf printf
|
||||
#define cons_newline() printf("\n");
|
||||
|
||||
#if 0
|
||||
* TODO:
|
||||
* - make path of indirections shortr (io->undo.foo is slow) */
|
||||
* - Handle changes in write and seeks
|
||||
* - Per-fd history log
|
||||
* - rename undo_seek -> sundo , undo_write -> wundo
|
||||
#endif
|
||||
|
||||
R_API int r_io_undo_init(struct r_io_t *io)
|
||||
{
|
||||
R_API int r_io_undo_init(struct r_io_t *io) {
|
||||
io->undo.w_init = 0;
|
||||
io->undo.w_enable = 0;
|
||||
io->undo.idx = 0;
|
||||
@ -25,70 +20,66 @@ R_API int r_io_undo_init(struct r_io_t *io)
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API void r_io_undo_enable(struct r_io_t *io, int s, int w)
|
||||
{
|
||||
R_API void r_io_undo_enable(struct r_io_t *io, int s, int w) {
|
||||
io->undo.s_enable = s;
|
||||
io->undo.w_enable = w;
|
||||
}
|
||||
|
||||
R_API ut64 r_io_sundo_last(struct r_io_t *io)
|
||||
{
|
||||
R_API ut64 r_io_sundo_last(struct r_io_t *io) {
|
||||
return (io->undo.idx>0)?
|
||||
io->undo.seek[io->undo.idx-2] : io->off;
|
||||
}
|
||||
|
||||
R_API void r_io_sundo(struct r_io_t *io)
|
||||
{
|
||||
if (--io->undo.idx<0)
|
||||
io->undo.idx = 0;
|
||||
else io->off = io->undo.seek[io->undo.idx-1];
|
||||
R_API int r_io_sundo(struct r_io_t *io) {
|
||||
io->undo.idx--;
|
||||
if (io->undo.idx<0)
|
||||
return io->undo.idx = 0;
|
||||
io->off = io->undo.seek[io->undo.idx-1];
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API void r_io_sundo_redo(struct r_io_t *io)
|
||||
{
|
||||
R_API int r_io_sundo_redo(struct r_io_t *io) {
|
||||
if (io->undo.idx<io->undo.limit) {
|
||||
io->undo.idx += 2;
|
||||
if (io->undo.idx>=R_IO_UNDOS) {
|
||||
io->undo.idx -= 2;
|
||||
return R_FALSE;
|
||||
} else io->off = io->undo.seek[io->undo.idx];
|
||||
r_io_sundo(io);
|
||||
return R_TRUE;
|
||||
}
|
||||
return R_FALSE;
|
||||
}
|
||||
|
||||
R_API void r_io_sundo_push(struct r_io_t *io)
|
||||
{
|
||||
int i;
|
||||
R_API void r_io_sundo_push(struct r_io_t *io) {
|
||||
if (!io->undo.s_enable)
|
||||
return;
|
||||
if (io->undo.seek[io->undo.idx-1] == io->off)
|
||||
return;
|
||||
io->undo.seek[io->undo.idx] = io->off;
|
||||
if (io->undo.idx==R_IO_UNDOS-1) {
|
||||
for(i=1;i<R_IO_UNDOS;i++)
|
||||
io->undo.seek[i-1] = io->undo.seek[i];
|
||||
} else io->undo.idx++;
|
||||
|
||||
if (++io->undo.idx==R_IO_UNDOS-1)
|
||||
io->undo.idx--;
|
||||
if (io->undo.limit<io->undo.idx)
|
||||
io->undo.limit = io->undo.idx;
|
||||
}
|
||||
|
||||
R_API void r_io_sundo_reset(struct r_io_t *io)
|
||||
{
|
||||
R_API void r_io_sundo_reset(struct r_io_t *io) {
|
||||
io->undo.idx = 0;
|
||||
}
|
||||
|
||||
R_API void r_io_sundo_list(struct r_io_t *io)
|
||||
{
|
||||
R_API void r_io_sundo_list(struct r_io_t *io) {
|
||||
int i;
|
||||
if (io->undo.idx>0) {
|
||||
cons_printf("f undo_idx @ %d\n", io->undo.idx);
|
||||
io->printf ("f undo_idx @ %d\n", io->undo.idx);
|
||||
for(i=io->undo.idx-1;i!=0;i--)
|
||||
cons_printf("f undo_%d @ 0x%"PFMT64x"\n",
|
||||
io->printf ("f undo_%d @ 0x%"PFMT64x"\n",
|
||||
io->undo.idx-1-i, io->undo.seek[i-1]);
|
||||
} else eprintf("-no seeks done-\n");
|
||||
}
|
||||
|
||||
/* undo writez */
|
||||
|
||||
R_API void r_io_wundo_new(struct r_io_t *io, ut64 off, const ut8 *data, int len)
|
||||
{
|
||||
R_API void r_io_wundo_new(struct r_io_t *io, ut64 off, const ut8 *data, int len) {
|
||||
struct r_io_undo_w_t *uw;
|
||||
|
||||
if (!io->undo.w_enable)
|
||||
@ -106,15 +97,13 @@ R_API void r_io_wundo_new(struct r_io_t *io, ut64 off, const ut8 *data, int len)
|
||||
list_add_tail(&(uw->list), &(io->undo.w_list));
|
||||
}
|
||||
|
||||
R_API void r_io_wundo_clear(struct r_io_t *io)
|
||||
{
|
||||
R_API void r_io_wundo_clear(struct r_io_t *io) {
|
||||
// XXX memory leak
|
||||
INIT_LIST_HEAD(&(io->undo.w_list));
|
||||
}
|
||||
|
||||
// rename to r_io_undo_length ?
|
||||
R_API int r_io_wundo_size(struct r_io_t *io)
|
||||
{
|
||||
R_API int r_io_wundo_size(struct r_io_t *io) {
|
||||
struct list_head *p;
|
||||
int i = 0;
|
||||
if (io->undo.w_init)
|
||||
@ -124,8 +113,7 @@ R_API int r_io_wundo_size(struct r_io_t *io)
|
||||
}
|
||||
|
||||
// TODO: Deprecate or so? iterators must be language-wide, but helpers are useful
|
||||
R_API void r_io_wundo_list(struct r_io_t *io)
|
||||
{
|
||||
R_API void r_io_wundo_list(struct r_io_t *io) {
|
||||
#define BW 8 /* byte wrap */
|
||||
struct list_head *p;
|
||||
int i = 0, j, len;
|
||||
@ -133,20 +121,19 @@ R_API void r_io_wundo_list(struct r_io_t *io)
|
||||
if (io->undo.w_init)
|
||||
list_for_each_prev(p, &(io->undo.w_list)) {
|
||||
struct r_io_undo_w_t *u = list_entry(p, struct r_io_undo_w_t, list);
|
||||
cons_printf("%02d %c %d %08"PFMT64x": ", i, u->set?'+':'-', u->len, u->off);
|
||||
io->printf ("%02d %c %d %08"PFMT64x": ", i, u->set?'+':'-', u->len, u->off);
|
||||
len = (u->len>BW)?BW:u->len;
|
||||
for(j=0;j<len;j++) cons_printf("%02x ", u->o[j]);
|
||||
if (len == BW) cons_printf(".. ");
|
||||
cons_printf ("=> ");
|
||||
for(j=0;j<len;j++) cons_printf("%02x ", u->n[j]);
|
||||
if (len == BW) cons_printf(".. ");
|
||||
cons_newline();
|
||||
for(j=0;j<len;j++) io->printf ("%02x ", u->o[j]);
|
||||
if (len == BW) io->printf (".. ");
|
||||
io->printf ("=> ");
|
||||
for(j=0;j<len;j++) io->printf ("%02x ", u->n[j]);
|
||||
if (len == BW) io->printf (".. ");
|
||||
io->printf ("\n");
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
R_API int r_io_wundo_apply(struct r_io_t *io, struct r_io_undo_w_t *u, int set)
|
||||
{
|
||||
R_API int r_io_wundo_apply(struct r_io_t *io, struct r_io_undo_w_t *u, int set) {
|
||||
int orig = io->undo.w_enable;
|
||||
io->undo.w_enable = 0;
|
||||
if (set) {
|
||||
@ -160,21 +147,19 @@ R_API int r_io_wundo_apply(struct r_io_t *io, struct r_io_undo_w_t *u, int set)
|
||||
return 0;
|
||||
}
|
||||
|
||||
R_API void r_io_wundo_apply_all(struct r_io_t *io, int set)
|
||||
{
|
||||
R_API void r_io_wundo_apply_all(struct r_io_t *io, int set) {
|
||||
struct list_head *p;
|
||||
|
||||
list_for_each_prev(p, &(io->undo.w_list)) {
|
||||
struct r_io_undo_w_t *u = list_entry(p, struct r_io_undo_w_t, list);
|
||||
r_io_wundo_apply(io, u, set); //UNDO_WRITE_UNSET);
|
||||
eprintf("%s 0x%08"PFMT64x"\n", set?"redo":"undo", u->off);
|
||||
list_for_each_prev (p, &(io->undo.w_list)) {
|
||||
struct r_io_undo_w_t *u = list_entry (p, struct r_io_undo_w_t, list);
|
||||
r_io_wundo_apply (io, u, set); //UNDO_WRITE_UNSET);
|
||||
eprintf ("%s 0x%08"PFMT64x"\n", set?"redo":"undo", u->off);
|
||||
}
|
||||
}
|
||||
|
||||
/* sets or unsets the writes done */
|
||||
/* if ( set == 0 ) unset(n) */
|
||||
R_API int r_io_wundo_set(struct r_io_t *io, int n, int set)
|
||||
{
|
||||
R_API int r_io_wundo_set(struct r_io_t *io, int n, int set) {
|
||||
struct r_io_undo_w_t *u = NULL;
|
||||
struct list_head *p;
|
||||
int i = 0;
|
||||
@ -185,8 +170,10 @@ R_API int r_io_wundo_set(struct r_io_t *io, int n, int set)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (u) r_io_wundo_apply(io, u, set);
|
||||
else eprintf("invalid undo-write index\n");
|
||||
} else eprintf("no writes done\n");
|
||||
return 0;
|
||||
if (u) {
|
||||
r_io_wundo_apply(io, u, set);
|
||||
return R_TRUE;
|
||||
} else eprintf ("invalid undo-write index\n");
|
||||
} else eprintf ("no writes done\n");
|
||||
return R_FALSE;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class RAnal {
|
||||
public bool bb_overlap(BasicBlock bb, RList<BasicBlock> bbs);
|
||||
|
||||
[Compact]
|
||||
[CCode (cprefix="r_anal_aop_t")]
|
||||
[CCode (cprefix="r_anal_aop_t", cname="RAnalAop")]
|
||||
public class Opcode {
|
||||
public uint64 addr;
|
||||
public int type;
|
||||
@ -46,7 +46,7 @@ public class RAnal {
|
||||
}
|
||||
|
||||
[Compact]
|
||||
[CCode (cprefix="r_anal_fcn_t", cname="RAnalFcn")]
|
||||
[CCode (lower_case_cprefix="r_anal_fcn_", cprefix="r_anal_fcn_t", cname="RAnalFcn")]
|
||||
public class Function {
|
||||
public string name;
|
||||
public uint64 addr;
|
||||
@ -54,6 +54,7 @@ public class RAnal {
|
||||
public RList<Variable> vars;
|
||||
public RList<uint64> refs;
|
||||
public RList<uint64> xrefs;
|
||||
public RList<BasicBlock> bb_list ();
|
||||
}
|
||||
|
||||
[Compact]
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2009 pancake<@nopcode.org> */
|
||||
/* radare - LGPL - Copyright 2009-2010 pancake<@nopcode.org> */
|
||||
|
||||
namespace Radare {
|
||||
//[Compact]
|
||||
@ -52,7 +52,7 @@ namespace Radare {
|
||||
public static string cmd_str (string command, string? input, out int len=null);
|
||||
}
|
||||
|
||||
[CCode (cheader_filename="r_util.h", cprefix="r_num_", free_function="")]
|
||||
[CCode (cname="RNum", cheader_filename="r_util.h", cprefix="r_num_", free_function="")]
|
||||
public static class RNum {
|
||||
public RNum(RNumCallback cb, void *user);
|
||||
public uint64 get(string str);
|
||||
|
Loading…
Reference in New Issue
Block a user