Colorize p- and fix some help messages

This commit is contained in:
pancake 2016-11-22 21:25:04 +01:00
parent 88f4faa037
commit fe39119f4b
4 changed files with 53 additions and 35 deletions

View File

@ -5018,7 +5018,6 @@ static int cmd_anal(void *data, const char *input) {
"ai", " [addr]", "address information (show perms, stack, heap, ...)",
"ao", "[e?] [len]", "analyze Opcodes (or emulate it)",
"aO", "", "Analyze N instructions in M bytes",
"an", "[an-] [...]", "manage no-return addresses/symbols/functions",
"ar", "", "like 'dr' but for the esil vm. (registers)",
"ap", "", "find prelude for current offset",
"ax", "[?ld-*]", "manage refs/xrefs (see also afx?)",

View File

@ -789,15 +789,15 @@ static int cmd_help(void *data, const char *input) {
"/","", "Search for bytes, regexps, patterns, ..",
"!"," [cmd]", "Run given command as in system(3)",
"#","!lang [..]", "Hashbang to run an rlang script",
"a","[?]", "Perform analysis of code",
"b","[?]", "Get or change block size",
"a","[?]", "Analysis commands",
"b","[?]", "Display or change the block size",
"c","[?] [arg]", "Compare block with given data",
"C","[?]", "Code metadata management",
"C","[?]", "Code metadata (comments, format, hints, ..)",
"d","[?]", "Debugger commands",
"e"," [a[=b]]", "List/get/set config evaluable vars",
"f"," [name][sz][at]", "Set flag at current address",
"g"," [arg]", "Go compile shellcodes with r_egg",
"i","[?] [file]", "Get info about opened file",
"f"," [name][sz][at]", "Add flag at current address",
"g"," [arg]", "Generate shellcodes with r_egg",
"i","[?] [file]", "Get info about opened file from r_bin",
"k","[?] [sdb-query]", "Run sdb-query. see k? for help, 'k *', 'k **' ...",
"m","", "Mountpoints commands",
"o","[?] [file] ([offset])", "Open file at optional address",
@ -807,10 +807,10 @@ static int cmd_help(void *data, const char *input) {
"r","[?] [len]", "Resize file",
"s","[?] [addr]", "Seek to address (also for '0x', '0x1' == 's 0x1')",
"S","[?]", "Io section manipulation information",
"t","[?]", "Cparse types management",
"t","[?]", "Types, noreturn, signatures, C parser and more",
"T","[?] [-] [num|msg]", "Text log utility",
"u","[?]", "uname/undo seek/write",
"V","", "Enter visual mode (vcmds=visualvisual keystrokes)",
"V","", "Enter visual mode (V! = panels, VV = fcngraph, VVV = callgraph)",
"w","[?] [str]", "Multiple write operations",
"x","[?] [len]", "Alias for 'px' (print hexadecimal)",
"y","[?] [len] [[[@]addr", "Yank/paste bytes from/to memory",

View File

@ -2427,21 +2427,23 @@ static int cmd_print(void *data, const char *input) {
r_cons_printf ("0x%"PFMT64x" [", from);
}
bool use_color = r_config_get_i (core->config, "scr.color");
len = 0;
for (i=0; i<w; i++) {
for (i = 0; i < w; i++) {
at = from + (piece*i);
ate = at + piece;
p = (at-from)/piece;
p = (at - from) / piece;
switch (mode) {
case 'j':
r_cons_printf ("%s{",len?",":"");
r_cons_printf ("%s{", len? ",": "");
if ((as->block[p].flags)
|| (as->block[p].functions)
|| (as->block[p].comments)
|| (as->block[p].imports)
|| (as->block[p].symbols)
|| (as->block[p].strings))
|| (as->block[p].strings)) {
r_cons_printf ("\"offset\":%"PFMT64d",", at), l++;
}
// TODO: simplify with macro
l = 0;
if (as->block[p].flags) r_cons_printf ("%s\"flags\":%d", l?",":"", as->block[p].flags), l++;
@ -2465,7 +2467,7 @@ static int cmd_print(void *data, const char *input) {
|| (as->block[p].comments)
|| (as->block[p].imports)
|| (as->block[p].symbols)
|| (as->block[p].strings))
|| (as->block[p].strings)) {
r_cons_printf ("| 0x%09"PFMT64x" | %4d %4d %4d %4d %4d %4d |\n", at,
as->block[p].flags,
as->block[p].functions,
@ -2473,41 +2475,59 @@ static int cmd_print(void *data, const char *input) {
as->block[p].imports,
as->block[p].symbols,
as->block[p].strings);
}
break;
default:
if (off>=at && off<ate) {
r_cons_memcat ("^", 1);
} else {
if (as->block[p].strings>0)
RIOSection *s = r_io_section_vget (core->io, at);
if (use_color) {
if (s) {
if (s->rwx & 1) {
r_cons_print (Color_BGBLUE);
} else {
r_cons_print (Color_BGGREEN);
}
} else {
r_cons_print (Color_BGRED);
}
}
if (as->block[p].strings > 0) {
r_cons_memcat ("z", 1);
else if (as->block[p].imports>0)
} else if (as->block[p].imports>0) {
r_cons_memcat ("i", 1);
else if (as->block[p].symbols>0)
} else if (as->block[p].symbols>0) {
r_cons_memcat ("s", 1);
else if (as->block[p].functions>0)
} else if (as->block[p].functions>0) {
r_cons_memcat ("F", 1);
else if (as->block[p].flags>0)
r_cons_memcat ("f", 1);
else if (as->block[p].comments>0)
} else if (as->block[p].comments > 0) {
r_cons_memcat ("c", 1);
else r_cons_memcat (".", 1);
} else if (as->block[p].flags > 3) {
r_cons_memcat ("f", 1);
} else {
r_cons_memcat (".", 1);
}
}
break;
}
}
if (use_color) {
r_cons_print (Color_RESET);
}
switch (mode) {
case 'j':
r_cons_strcat ("]}\n");
break;
case 'h':
//r_cons_printf (" total | flags funcs cmts imps syms str |\n");
r_cons_printf ("|-------------)---------------------------------|\n");
r_cons_printf ("| total | %4d %4d %4d %4d %4d %4d |\n",
total[0], total[1], total[2], total[3], total[4], total[5]);
r_cons_printf ("`-------------'---------------------------------'\n");
break;
default:
r_cons_printf ("] 0x%"PFMT64x"\n", to);
case 'j':
r_cons_strcat ("]}\n");
break;
case 'h':
//r_cons_printf (" total | flags funcs cmts imps syms str |\n");
r_cons_printf ("|-------------)---------------------------------|\n");
r_cons_printf ("| total | %4d %4d %4d %4d %4d %4d |\n",
total[0], total[1], total[2], total[3], total[4], total[5]);
r_cons_printf ("`-------------'---------------------------------'\n");
break;
default:
r_cons_printf ("] 0x%"PFMT64x"\n", to);
}
r_core_anal_stats_free (as);
break;

View File

@ -387,7 +387,6 @@ R_API void r_io_section_free(void *ptr);
R_API RIOSection *r_io_section_add(RIO *io, ut64 offset, ut64 vaddr, ut64 size, ut64 vsize, int rwx, const char *name, ut32 bin_id, int fd);
R_API RIOSection *r_io_section_get_name(RIO *io, const char *name);
R_API RIOSection *r_io_section_get_i(RIO *io, int idx);
R_API RIOSection *r_io_section_getv(RIO *io, ut64 vaddr);
R_API RIOSection *r_io_section_mget_in(RIO *io, ut64 maddr);
R_API RIOSection *r_io_section_mget_prev(RIO *io, ut64 maddr);
R_API RIOSection *r_io_section_vget(RIO *io, ut64 addr);