mirror of
https://github.com/radareorg/radare2.git
synced 2025-03-02 19:26:43 +00:00
* RIOUndo now uses r_list API
* List mount points in radare commands use new syntax * asm.bits triggers syscall_setup * Fix null pointer dereference in RCore.bin_load
This commit is contained in:
parent
3fd59fdbcd
commit
242f9c56d8
@ -607,7 +607,7 @@ static int cmd_mount(void *data, const char *_input) {
|
||||
case '*':
|
||||
eprintf ("List commands in radare format\n");
|
||||
r_list_foreach (core->fs->roots, iter, root) {
|
||||
r_cons_printf ("m %s 0x%"PFMT64x" %s\n", root->p->name, root->delta, root->path);
|
||||
r_cons_printf ("m %s %s 0x%"PFMT64x"\n", root-> path, root->p->name, root->delta);
|
||||
}
|
||||
break;
|
||||
case '\0':
|
||||
|
@ -372,6 +372,13 @@ static int config_asmbits_callback(void *user, void *data) {
|
||||
eprintf ("asm.arch: Cannot setup '%i' bits analysis engine\n", (int)node->i_value);
|
||||
if (core->dbg && core->anal && core->anal->cur)
|
||||
r_debug_set_arch (core->dbg, core->anal->cur->arch, node->i_value);
|
||||
const char *asmos = r_config_get (core->config, "asm.os");
|
||||
const char *asmarch = r_config_get (core->config, "asm.arch");
|
||||
if (!r_syscall_setup (core->anal->syscall, asmarch,
|
||||
asmos, node->i_value)) {
|
||||
//eprintf ("asm.arch: Cannot setup syscall '%s/%s' from '%s'\n",
|
||||
// node->value, asmos, R2_LIBDIR"/radare2/"R2_VERSION"/syscall");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -77,8 +77,11 @@ R_API char *r_core_sysenv_begin(RCore *core, const char *cmd) {
|
||||
R_API int r_core_bin_load(RCore *r, const char *file) {
|
||||
int va = r->io->va || r->io->debug;
|
||||
|
||||
if (file == NULL)
|
||||
if (file == NULL) {
|
||||
if (r->file == NULL)
|
||||
return R_FALSE;
|
||||
file = r->file->filename;
|
||||
}
|
||||
if (!r_bin_load (r->bin, file, 0))
|
||||
return R_FALSE;
|
||||
r->file->obj = r_bin_get_object (r->bin, 0);
|
||||
|
@ -65,7 +65,7 @@ typedef struct r_io_undo_t {
|
||||
int s_enable;
|
||||
int w_enable;
|
||||
/* write stuff */
|
||||
struct list_head w_list;
|
||||
RList *w_list;
|
||||
int w_init;
|
||||
/* seek stuff */
|
||||
ut64 seek[R_IO_UNDOS];
|
||||
@ -80,7 +80,6 @@ typedef struct r_io_undo_w_t {
|
||||
ut8 *o; /* old data */
|
||||
ut8 *n; /* new data */
|
||||
int len; /* length */
|
||||
struct list_head list;
|
||||
} RIOUndoWrite;
|
||||
|
||||
typedef struct r_io_t {
|
||||
|
@ -16,7 +16,7 @@ R_API int r_io_undo_init(struct r_io_t *io) {
|
||||
io->undo.limit = 0;
|
||||
io->undo.s_enable = 0;
|
||||
io->undo.w_enable = 0;
|
||||
INIT_LIST_HEAD(&(io->undo.w_list));
|
||||
io->undo.w_list = r_list_new ();
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
@ -102,20 +102,22 @@ R_API void r_io_wundo_new(struct r_io_t *io, ut64 off, const ut8 *data, int len)
|
||||
memcpy(uw->n, data, len);
|
||||
uw->o = (ut8*) malloc(len);
|
||||
r_io_read_at(io, off, uw->o, len);
|
||||
list_add_tail(&(uw->list), &(io->undo.w_list));
|
||||
r_list_append (io->undo.w_list, uw);
|
||||
}
|
||||
|
||||
R_API void r_io_wundo_clear(struct r_io_t *io) {
|
||||
// XXX memory leak
|
||||
INIT_LIST_HEAD(&(io->undo.w_list));
|
||||
io->undo.w_list = r_list_new ();
|
||||
}
|
||||
|
||||
// rename to r_io_undo_length ?
|
||||
R_API int r_io_wundo_size(struct r_io_t *io) {
|
||||
struct list_head *p;
|
||||
RListIter *iter;
|
||||
struct r_io_undo_w_t *uw;
|
||||
int i = 0;
|
||||
|
||||
if (io->undo.w_init)
|
||||
list_for_each_prev(p, &(io->undo.w_list))
|
||||
r_list_foreach (io->undo.w_list, iter, uw)
|
||||
i++;
|
||||
return i;
|
||||
}
|
||||
@ -123,12 +125,12 @@ 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) {
|
||||
#define BW 8 /* byte wrap */
|
||||
struct list_head *p;
|
||||
RListIter *iter;
|
||||
struct r_io_undo_w_t *u;
|
||||
int i = 0, j, len;
|
||||
|
||||
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);
|
||||
r_list_foreach (io->undo.w_list, iter, u) {
|
||||
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++) io->printf ("%02x ", u->o[j]);
|
||||
@ -156,10 +158,10 @@ R_API int r_io_wundo_apply(struct r_io_t *io, struct r_io_undo_w_t *u, int set)
|
||||
}
|
||||
|
||||
R_API void r_io_wundo_apply_all(struct r_io_t *io, int set) {
|
||||
struct list_head *p;
|
||||
RListIter *iter;
|
||||
struct r_io_undo_w_t *u;
|
||||
|
||||
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_list_foreach_prev (io->undo.w_list, iter, u) {
|
||||
r_io_wundo_apply (io, u, set); //UNDO_WRITE_UNSET);
|
||||
eprintf ("%s 0x%08"PFMT64x"\n", set?"redo":"undo", u->off);
|
||||
}
|
||||
@ -168,13 +170,13 @@ R_API void r_io_wundo_apply_all(struct r_io_t *io, int set) {
|
||||
/* 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) {
|
||||
RListIter *iter;
|
||||
struct r_io_undo_w_t *u = NULL;
|
||||
struct list_head *p;
|
||||
|
||||
int i = 0;
|
||||
if (io->undo.w_init) {
|
||||
list_for_each_prev(p, &(io->undo.w_list)) {
|
||||
r_list_foreach_prev (io->undo.w_list, iter, u) {
|
||||
if (i++ == n) {
|
||||
u = list_entry(p, struct r_io_undo_w_t, list);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user