mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-26 09:06:02 +00:00
izz/izzj works with -n without using rabin2 (#9561)
This commit is contained in:
parent
0570001038
commit
3c7ee36386
@ -519,9 +519,6 @@ static RList *get_strings(RBinFile *a, int min, int dump) {
|
||||
RBinObject *o = a? a->o: NULL;
|
||||
RList *ret;
|
||||
|
||||
if (!o) {
|
||||
return NULL;
|
||||
}
|
||||
if (dump) {
|
||||
/* dump to stdout, not stored in list */
|
||||
ret = NULL;
|
||||
@ -531,7 +528,7 @@ static RList *get_strings(RBinFile *a, int min, int dump) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (o->sections && !r_list_empty (o->sections) && !a->rawstr) {
|
||||
if (o && o->sections && !r_list_empty (o->sections) && !a->rawstr) {
|
||||
r_list_foreach (o->sections, iter, section) {
|
||||
if (is_data_section (a, section)) {
|
||||
get_strings_range (a, ret, min, section->paddr,
|
||||
@ -2779,12 +2776,15 @@ R_API ut64 r_binfile_get_vaddr(RBinFile *binfile, ut64 paddr, ut64 vaddr) {
|
||||
/* returns vaddr, rebased with the baseaddr of bin, if va is enabled for bin,
|
||||
* paddr otherwise */
|
||||
R_API ut64 r_bin_get_vaddr(RBin *bin, ut64 paddr, ut64 vaddr) {
|
||||
if (!bin || !bin->cur) {
|
||||
if (!bin) {
|
||||
return UT64_MAX;
|
||||
}
|
||||
if (paddr == UT64_MAX) {
|
||||
return UT64_MAX;
|
||||
}
|
||||
if (!bin->cur) {
|
||||
return paddr;
|
||||
}
|
||||
/* hack to realign thumb symbols */
|
||||
if (bin->cur->o && bin->cur->o->info && bin->cur->o->info->arch) {
|
||||
if (bin->cur->o->info->bits == 16) {
|
||||
|
@ -358,12 +358,7 @@ static void _print_strings(RCore *r, RList *list, int mode, int va) {
|
||||
|
||||
static bool bin_raw_strings(RCore *r, int mode, int va) {
|
||||
RBinFile *bf = r_bin_cur (r->bin);
|
||||
if (!bf && r->io && r->io->desc && r->io->desc->uri) {
|
||||
// -n scenario is handled already
|
||||
// eprintf ("Likely you used -nn \n");
|
||||
// eprintf ("try: .!rabin2 -B <baddr> -zzr filename\n");
|
||||
return false;
|
||||
}
|
||||
bool new_bf = false;
|
||||
if (bf && strstr (bf->file, "malloc://")) {
|
||||
//sync bf->buf to search string on it
|
||||
r_io_read_at (r->io, 0, bf->buf->buf, bf->size);
|
||||
@ -372,8 +367,48 @@ static bool bin_raw_strings(RCore *r, int mode, int va) {
|
||||
eprintf ("Core file not open\n");
|
||||
return false;
|
||||
}
|
||||
if (!bf) {
|
||||
bf = R_NEW0 (RBinFile);
|
||||
if (!bf) {
|
||||
return false;
|
||||
}
|
||||
RIODesc *desc = r_io_desc_get (r->io, r->file->fd);
|
||||
if (!desc) {
|
||||
free (bf);
|
||||
return false;
|
||||
}
|
||||
bf->file = desc->name;
|
||||
bf->size = r_io_desc_size (desc);
|
||||
if (bf->size == UT64_MAX) {
|
||||
free (bf);
|
||||
return false;
|
||||
}
|
||||
bf->buf = r_buf_new ();
|
||||
if (!bf->buf) {
|
||||
free (bf);
|
||||
return false;
|
||||
}
|
||||
bf->buf->buf = malloc (bf->size);
|
||||
if (!bf->buf->buf) {
|
||||
free (bf->buf);
|
||||
free (bf);
|
||||
return false;
|
||||
}
|
||||
bf->buf->fd = r->file->fd;
|
||||
bf->buf->length = bf->size;
|
||||
r_io_read_at (r->io, 0, bf->buf->buf, bf->size);
|
||||
bf->o = NULL;
|
||||
bf->rbin = r->bin;
|
||||
new_bf = true;
|
||||
va = false;
|
||||
}
|
||||
RList *l = r_bin_raw_strings (bf, 0);
|
||||
_print_strings (r, l, mode, va);
|
||||
if (new_bf) {
|
||||
free (bf->buf->buf);
|
||||
free (bf->buf);
|
||||
free (bf);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -307,25 +307,6 @@ static void playMsg(RCore *core, const char *n, int len) {
|
||||
}
|
||||
}
|
||||
|
||||
static void print_rabin2_strings (RCore *r, int mode, const char *input) {
|
||||
if (r->io && r->io->desc && r->io->desc->uri) {
|
||||
const char *file = r->io->desc->uri;
|
||||
char cmd;
|
||||
if (mode == R_CORE_BIN_JSON) {
|
||||
cmd = 'j';
|
||||
} else if (mode == R_CORE_BIN_SIMPLE) {
|
||||
cmd = 'q';
|
||||
} else {
|
||||
cmd = ' ';
|
||||
}
|
||||
if (input[2] == 'z') { //izz
|
||||
r_sys_cmdf ("rabin2 -zz%c '%s'", cmd, file);
|
||||
} else {
|
||||
r_sys_cmdf ("rabin2 -z%c '%s'", cmd, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int cmd_info(void *data, const char *input) {
|
||||
RCore *core = (RCore *) data;
|
||||
bool newline = r_config_get_i (core->config, "scr.interactive");
|
||||
@ -334,7 +315,6 @@ static int cmd_info(void *data, const char *input) {
|
||||
int i, va = core->io->va || core->io->debug;
|
||||
int mode = 0; //R_CORE_BIN_SIMPLE;
|
||||
bool rdump = false;
|
||||
RBinFile *bin_file = r_bin_cur (core->bin);
|
||||
int is_array = 0;
|
||||
Sdb *db;
|
||||
|
||||
@ -347,10 +327,6 @@ static int cmd_info(void *data, const char *input) {
|
||||
case 'q': mode = R_CORE_BIN_SIMPLE; break;
|
||||
}
|
||||
}
|
||||
if (!bin_file && *input == 'z') { // when -n is used
|
||||
print_rabin2_strings (core, mode, input);
|
||||
return 0;
|
||||
}
|
||||
if (mode == R_CORE_BIN_JSON) {
|
||||
if (strlen (input + 1) > 1) {
|
||||
is_array = 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user