diff --git a/binr/radare2/radare2.c b/binr/radare2/radare2.c index eb08d2ab41..6a6f9f68b0 100644 --- a/binr/radare2/radare2.c +++ b/binr/radare2/radare2.c @@ -97,7 +97,8 @@ static int main_help(int line) { " -t load rabin2 info in thread\n" #endif " -v, -V show radare2 version (-V show lib versions)\n" - " -w open file in write mode\n"); + " -w open file in write mode\n" + " -z, -zz do not load strings or load them even in raw\n"); if (line==2) printf ( "Scripts:\n" @@ -171,6 +172,7 @@ int main(int argc, char **argv, char **envp) { const char *prj = NULL; //int threaded = R_FALSE; int debug = 0; + int zflag = 0; int do_analysis = 0; int do_connect = 0; int fullfile = 0; @@ -238,7 +240,7 @@ int main(int argc, char **argv, char **envp) { argv++; } else prefile = 0; - while ((c = getopt (argc, argv, "0ACwfhm:e:nk:Ndqs:p:b:B:a:Lui:l:P:c:D:vVS" + while ((c = getopt (argc, argv, "0ACwfhm:e:nk:Ndqs:p:b:B:a:Lui:l:P:c:D:vVSz" #if USE_THREADS "t" #endif @@ -253,6 +255,7 @@ int main(int argc, char **argv, char **envp) { quiet = R_TRUE; break; case 'a': asmarch = optarg; break; + case 'z': zflag++; break; case 'A': do_analysis = R_TRUE; break; @@ -357,6 +360,15 @@ int main(int argc, char **argv, char **envp) { return 0; } + switch (zflag) { + case 1: + r_config_set (r.config, "bin.strings", "false"); + break; + case 2: + r_config_set (r.config, "bin.rawstr", "true"); + break; + } + switch (va) { case 0: r_config_set_i (r.config, "io.va", 0); diff --git a/libr/core/bin.c b/libr/core/bin.c index 96092dc138..dec6d73e1f 100644 --- a/libr/core/bin.c +++ b/libr/core/bin.c @@ -116,12 +116,16 @@ static int bin_strings (RCore *r, int mode, ut64 baddr, int va) { if (!(hasstr = r_config_get_i (r->config, "bin.strings"))) return 0; + if (!plugin) return 0; - if (!plugin->info) { - if (!rawstr) { - eprintf ("WARN: Use '-e bin.rawstr=true' or 'rabin2 -zz'" - " to find strings on unknown file types\n"); - return R_FALSE; + if (plugin->info && plugin->name) { + if (!strcmp (plugin->name, "any")) { + if (!rawstr) { + eprintf ("NOTE: Use '-e bin.rawstr=true' or 'r2 -zz' or '.!rabin2 -zz $FILE'" + " to find strings on unknown file types\n"); + return R_FALSE; + + } } } diff --git a/libr/core/file.c b/libr/core/file.c index 1d9f1017a9..d4f8648836 100644 --- a/libr/core/file.c +++ b/libr/core/file.c @@ -263,9 +263,11 @@ static int r_core_file_do_load_for_debug (RCore *r, ut64 loadaddr, const char *f } if (!r_bin_load (r->bin, filenameuri, baseaddr, loadaddr, xtr_idx, desc->fd, treat_as_rawstr)) { - treat_as_rawstr ++; - if (!r_bin_load (r->bin, filenameuri, baseaddr, loadaddr, xtr_idx, desc->fd, treat_as_rawstr)) { - return R_FALSE; + if (r_config_get_i (r->config, "bin.rawstr")) { + treat_as_rawstr = R_TRUE; + if (!r_bin_load (r->bin, filenameuri, baseaddr, loadaddr, xtr_idx, desc->fd, treat_as_rawstr)) { + return R_FALSE; + } } } @@ -275,7 +277,7 @@ static int r_core_file_do_load_for_debug (RCore *r, ut64 loadaddr, const char *f if ( plugin && strncmp (plugin->name, "any", 5)==0 ) { // set use of raw strings r_config_set_i (r->config, "io.va", 0); - r_config_set (r->config, "bin.rawstr", "true"); + //\\ r_config_set (r->config, "bin.rawstr", "true"); // get bin.minstr r->bin->minstrlen = r_config_get_i (r->config, "bin.minstr"); } else if (binfile) { @@ -313,7 +315,7 @@ static int r_core_file_do_load_for_io_plugin (RCore *r, ut64 baseaddr, ut64 load if ( plugin && strncmp (plugin->name, "any", 5)==0 ) { // set use of raw strings r_config_set_i (r->config, "io.va", 0); - r_config_set (r->config, "bin.rawstr", "true"); + // r_config_set (r->config, "bin.rawstr", "true"); // get bin.minstr r->bin->minstrlen = r_config_get_i (r->config, "bin.minstr"); } else if (binfile) { @@ -448,7 +450,7 @@ R_API int r_core_bin_load(RCore *r, const char *filenameuri, ut64 baddr) { plugin = r_bin_file_cur_plugin (binfile); if (plugin && plugin->name && !strncmp (plugin->name, "any", 3)) { // set use of raw strings - r_config_set (r->config, "bin.rawstr", "true"); + //r_config_set (r->config, "bin.rawstr", "true"); r_config_set_i (r->config, "io.va", 0); // get bin.minstr r->bin->minstrlen = r_config_get_i (r->config, "bin.minstr");