mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-11 15:04:23 +00:00
Handle ^C debug mode for aav
This commit is contained in:
parent
ee477660b6
commit
e00c7bc358
@ -3829,18 +3829,26 @@ static void cmd_anal_aav(RCore *core, const char *input) {
|
|||||||
#define set(x,y) r_config_set(core->config, x, y);
|
#define set(x,y) r_config_set(core->config, x, y);
|
||||||
#define seti(x,y) r_config_set_i(core->config, x, y);
|
#define seti(x,y) r_config_set_i(core->config, x, y);
|
||||||
#define geti(x) r_config_get_i(core->config, x);
|
#define geti(x) r_config_get_i(core->config, x);
|
||||||
RIOSection *s = r_io_section_vget (core->io, core->offset);
|
RIOSection *s;
|
||||||
ut64 o_align = geti ("search.align");
|
ut64 o_align = geti ("search.align");
|
||||||
ut64 from, to, ptr;
|
ut64 from, to, ptr;
|
||||||
ut64 vmin, vmax;
|
ut64 vmin, vmax;
|
||||||
bool asterisk = false;
|
bool asterisk = false;
|
||||||
if (s) {
|
bool is_debug = r_config_get_i (core->config, "cfg.debug");
|
||||||
from = s->vaddr;
|
|
||||||
to = s->vaddr + s->size;
|
if (is_debug) {
|
||||||
|
//
|
||||||
|
r_list_free (r_core_get_boundaries_prot (core, 0, "dbg.map", &from, &to));
|
||||||
} else {
|
} else {
|
||||||
eprintf ("aav: Cannot find section at this address\n");
|
s = r_io_section_vget (core->io, core->offset);
|
||||||
// TODO: look in debug maps
|
if (s) {
|
||||||
return;
|
from = s->vaddr;
|
||||||
|
to = s->vaddr + s->size;
|
||||||
|
} else {
|
||||||
|
eprintf ("aav: Cannot find section at this address\n");
|
||||||
|
// TODO: look in debug maps
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
seti ("search.align", 4);
|
seti ("search.align", 4);
|
||||||
|
|
||||||
@ -3848,29 +3856,26 @@ static void cmd_anal_aav(RCore *core, const char *input) {
|
|||||||
if (arg) {
|
if (arg) {
|
||||||
ptr = r_num_math (core->num, arg + 1);
|
ptr = r_num_math (core->num, arg + 1);
|
||||||
s = r_io_section_vget (core->io, ptr);
|
s = r_io_section_vget (core->io, ptr);
|
||||||
} else {
|
|
||||||
eprintf ("aav: using from to %llx %llx\n", from, to);
|
|
||||||
from = r_config_get_i (core->config, "bin.baddr");
|
|
||||||
to = from + ((core->file)? r_io_desc_size (core->io, core->file->desc): 0);
|
|
||||||
}
|
|
||||||
if (!s) {
|
|
||||||
eprintf ("aav: Cannot find section at 0x%"PFMT64d"\n", ptr);
|
|
||||||
return; // WTF!
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
RList *ret;
|
RList *ret;
|
||||||
if (r_config_get_i (core->config, "cfg.debug")) {
|
if (is_debug) {
|
||||||
ret = r_core_get_boundaries_prot (core, 0, "dbg.maps", &vmin, &vmax);
|
ret = r_core_get_boundaries_prot (core, 0, "dbg.map", &vmin, &vmax);
|
||||||
} else {
|
} else {
|
||||||
|
from = r_config_get_i (core->config, "bin.baddr");
|
||||||
|
to = from + ((core->file)? r_io_desc_size (core->io, core->file->desc): 0);
|
||||||
|
if (!s) {
|
||||||
|
eprintf ("aav: Cannot find section at 0x%"PFMT64d"\n", ptr);
|
||||||
|
return; // WTF!
|
||||||
|
}
|
||||||
ret = r_core_get_boundaries_prot (core, 0, "io.sections", &vmin, &vmax);
|
ret = r_core_get_boundaries_prot (core, 0, "io.sections", &vmin, &vmax);
|
||||||
}
|
}
|
||||||
r_list_free (ret);
|
r_list_free (ret);
|
||||||
}
|
}
|
||||||
//eprintf ("from to %llx %llx\n", from, to);
|
eprintf ("aav: using from to 0x%"PFMT64x" 0x%"PFMT64x"\n", from, to);
|
||||||
//eprintf ("from to %llx %llx\n", vmin, vmax);
|
eprintf ("Using vmin 0x%"PFMT64x" and vmax 0x%"PFMT64x"\n", vmin, vmax);
|
||||||
int vsize = 4; // 32bit dword
|
int vsize = 4; // 32bit dword
|
||||||
(void)cmd_search_value_in_range (core,
|
(void)cmd_search_value_in_range (core, from, to, vmin, vmax, vsize);
|
||||||
from, to, vmin, vmax, vsize);
|
|
||||||
// TODO: for each hit . must set flag, xref and metadata Cd 4
|
// TODO: for each hit . must set flag, xref and metadata Cd 4
|
||||||
if (asterisk) {
|
if (asterisk) {
|
||||||
r_cons_printf ("f-hit*\n");
|
r_cons_printf ("f-hit*\n");
|
||||||
|
@ -137,22 +137,32 @@ static void cmd_search_bin(RCore *core, ut64 from, ut64 to) {
|
|||||||
|
|
||||||
R_API int cmd_search_value_in_range(RCore *core, ut64 from, ut64 to, ut64 vmin, ut64 vmax, int vsize) {
|
R_API int cmd_search_value_in_range(RCore *core, ut64 from, ut64 to, ut64 vmin, ut64 vmax, int vsize) {
|
||||||
int i, match, align = core->search->align, hitctr = 0;
|
int i, match, align = core->search->align, hitctr = 0;
|
||||||
bool asterisk = false;
|
|
||||||
ut8 buf[4096];
|
ut8 buf[4096];
|
||||||
const int sz = sizeof (buf);
|
bool asterisk = false;
|
||||||
ut64 v64, n = 0;
|
ut64 v64, n = 0;
|
||||||
ut32 v32;
|
ut32 v32;
|
||||||
ut16 v16;
|
ut16 v16;
|
||||||
|
if (from >= to) {
|
||||||
|
eprintf ("Error: from must be lower than to\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (vmin >= vmax) {
|
if (vmin >= vmax) {
|
||||||
eprintf ("Error: vmin must be lower than vmax\n");
|
eprintf ("Error: vmin must be lower than vmax\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
while (from < to) {
|
while (from < to) {
|
||||||
memset (buf, 0, sz); // probably unnecessary
|
memset (buf, 0, sizeof (buf)); // probably unnecessary
|
||||||
(void)r_io_read_at (core->io, from, buf, sz);
|
(void)r_io_read_at (core->io, from, buf, sizeof (buf));
|
||||||
for (i=0; i<sizeof (buf)-vsize; i++) {
|
if (r_cons_is_breaked ()) {
|
||||||
void *v = (buf+i);
|
goto beach;
|
||||||
if (align && (from+i)%align)
|
}
|
||||||
|
for (i=0; i < sizeof (buf) - vsize; i++) {
|
||||||
|
void *v = (buf + i);
|
||||||
|
if (r_cons_is_breaked ()) {
|
||||||
|
eprintf ("BEACH\n");
|
||||||
|
goto beach;
|
||||||
|
}
|
||||||
|
if (align && (from + i) % align)
|
||||||
continue;
|
continue;
|
||||||
match = false;
|
match = false;
|
||||||
switch (vsize) {
|
switch (vsize) {
|
||||||
@ -176,8 +186,10 @@ R_API int cmd_search_value_in_range(RCore *core, ut64 from, ut64 to, ut64 vmin,
|
|||||||
hitctr++;
|
hitctr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
from += sz;
|
from += sizeof (buf);
|
||||||
}
|
}
|
||||||
|
beach:
|
||||||
|
r_cons_break_end ();
|
||||||
return hitctr;
|
return hitctr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -590,6 +602,7 @@ R_API RList *r_core_get_boundaries_prot(RCore *core, int protection, const char
|
|||||||
*from = map->addr;
|
*from = map->addr;
|
||||||
*to = map->addr_end;
|
*to = map->addr_end;
|
||||||
perm = map->perm;
|
perm = map->perm;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (perm) {
|
if (perm) {
|
||||||
@ -631,7 +644,7 @@ R_API RList *r_core_get_boundaries_prot(RCore *core, int protection, const char
|
|||||||
if (nmap->from < *from) {
|
if (nmap->from < *from) {
|
||||||
*from = nmap->from;
|
*from = nmap->from;
|
||||||
}
|
}
|
||||||
if (nmap->to < *to) {
|
if (nmap->to > *to) {
|
||||||
*to = nmap->to;
|
*to = nmap->to;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user