refactor r_core_cmd_init and add more help messages (#8171)

This commit is contained in:
Fangrui Song 2017-08-10 02:52:13 -07:00 committed by radare
parent 4b214d8627
commit 335f2c62fc
3 changed files with 247 additions and 235 deletions

View File

@ -3237,6 +3237,58 @@ static void cmd_descriptor_init(RCore *core) {
}
R_API void r_core_cmd_init(RCore *core) {
struct {
const char *cmd;
const char *description;
r_cmd_callback(cb);
void (*descriptor_init)(RCore *core);
} cmds[] = {
{"0x", "alias for px", cmd_ox},
{"x", "alias for px", cmd_hexdump},
{"mount", "mount filesystem", cmd_mount, cmd_mount_init},
{"analysis", "analysis", cmd_anal, cmd_anal_init},
{"flag", "get/set flags", cmd_flag, cmd_flag_init},
{"g", "egg manipulation", cmd_egg, cmd_egg_init},
{"debug", "debugger operations", cmd_debug, cmd_debug_init},
{"ls", "list files and directories", cmd_ls},
{"info", "get file info", cmd_info, cmd_info_init},
{"cmp", "compare memory", cmd_cmp},
{"seek", "seek to an offset", cmd_seek, cmd_seek_init},
{"Text", "Text log utility", cmd_log, cmd_log_init},
{"t", "type information (cparse)", cmd_type, cmd_type_init},
{"zign", "zignatures", cmd_zign, cmd_zign_init},
{"Section", "setup section io information", cmd_section, cmd_section_init},
{"bsize", "change block size", cmd_bsize},
{"kuery", "perform sdb query", cmd_kuery},
{"eval", "evaluate configuration variable", cmd_eval, cmd_eval_init},
{"print", "print current block", cmd_print, cmd_print_init},
{"write", "write bytes", cmd_write, cmd_write_init},
{"Code", "code metadata", cmd_meta, cmd_meta_init},
{"Project", "project", cmd_project, cmd_project_init},
{"open", "open or map file", cmd_open, cmd_open_init},
{"yank", "yank bytes", cmd_yank},
{"resize", "change file size", cmd_resize},
{"Visual", "enter visual mode", cmd_visual},
{"visual", "enter visual mode", cmd_visual},
{"*", "pointer read/write", cmd_pointer},
{"&", "threading capabilities", cmd_thread},
{"%", "short version of 'env' command", cmd_env},
{"!", "run system command", cmd_system},
{"=", "io pipe", cmd_rap},
{"\\", "alias for =!", cmd_rap_run},
{"#", "calculate hash", cmd_hash},
{"?", "help message", cmd_help, cmd_help_init},
{"$", "alias", cmd_alias},
{".", "interpret", cmd_interpret},
{"/", "search kw, pattern aes", cmd_search, cmd_search_init},
{"-", "open cfg.editor and run script", cmd_stdin},
{"(", "macro", cmd_macro},
{"u", "uname/undo", cmd_uname},
{"quit", "exit program session", cmd_quit, cmd_quit_init},
{"Q", "alias for q!", cmd_Quit},
{"L", "manage dynamically loaded plugins", cmd_plugins},
};
core->rcmd = r_cmd_new ();
core->rcmd->macro.user = core;
core->rcmd->macro.num = core->num;
@ -3246,69 +3298,12 @@ R_API void r_core_cmd_init(RCore *core) {
r_cmd_set_data (core->rcmd, core);
core->cmd_descriptors = r_list_newf (free);
r_cmd_add (core->rcmd, "0x", "alias for px", &cmd_ox);
r_cmd_add (core->rcmd, "x", "alias for px", &cmd_hexdump);
r_cmd_add (core->rcmd, "mount", "mount filesystem", &cmd_mount);
r_cmd_add (core->rcmd, "analysis", "analysis", &cmd_anal);
r_cmd_add (core->rcmd, "flag", "get/set flags", &cmd_flag);
r_cmd_add (core->rcmd, "g", "egg manipulation", &cmd_egg);
r_cmd_add (core->rcmd, "debug", "debugger operations", &cmd_debug);
r_cmd_add (core->rcmd, "ls", "list files and directories", &cmd_ls);
r_cmd_add (core->rcmd, "info", "get file info", &cmd_info);
r_cmd_add (core->rcmd, "cmp", "compare memory", &cmd_cmp);
r_cmd_add (core->rcmd, "seek", "seek to an offset", &cmd_seek);
r_cmd_add (core->rcmd, "Text", "Text log utility", &cmd_log);
r_cmd_add (core->rcmd, "t", "type information (cparse)", &cmd_type);
r_cmd_add (core->rcmd, "zign", "zignatures", &cmd_zign);
r_cmd_add (core->rcmd, "Section", "setup section io information", &cmd_section);
r_cmd_add (core->rcmd, "bsize", "change block size", &cmd_bsize);
r_cmd_add (core->rcmd, "kuery", "perform sdb query", &cmd_kuery);
r_cmd_add (core->rcmd, "eval", "evaluate configuration variable", &cmd_eval);
r_cmd_add (core->rcmd, "print", "print current block", &cmd_print);
r_cmd_add (core->rcmd, "write", "write bytes", &cmd_write);
r_cmd_add (core->rcmd, "Code", "code metadata", &cmd_meta);
r_cmd_add (core->rcmd, "Project", "project", &cmd_project);
r_cmd_add (core->rcmd, "open", "open or map file", &cmd_open);
r_cmd_add (core->rcmd, "yank", "yank bytes", &cmd_yank);
r_cmd_add (core->rcmd, "resize", "change file size", &cmd_resize);
r_cmd_add (core->rcmd, "Visual", "enter visual mode", &cmd_visual);
r_cmd_add (core->rcmd, "visual", "enter visual mode", &cmd_visual);
r_cmd_add (core->rcmd, "*", "pointer read/write", &cmd_pointer);
r_cmd_add (core->rcmd, "&", "threading capabilities", &cmd_thread);
r_cmd_add (core->rcmd, "%", "short version of 'env' command", &cmd_env);
r_cmd_add (core->rcmd, "!", "run system command", &cmd_system);
r_cmd_add (core->rcmd, "=", "io pipe", &cmd_rap);
r_cmd_add (core->rcmd, "\\", "alias for =!", &cmd_rap_run);
r_cmd_add (core->rcmd, "#", "calculate hash", &cmd_hash);
r_cmd_add (core->rcmd, "?", "help message", &cmd_help);
r_cmd_add (core->rcmd, "$", "alias", &cmd_alias);
r_cmd_add (core->rcmd, ".", "interpret", &cmd_interpret);
r_cmd_add (core->rcmd, "/", "search kw, pattern aes", &cmd_search);
r_cmd_add (core->rcmd, "-", "open cfg.editor and run script", &cmd_stdin);
r_cmd_add (core->rcmd, "(", "macro", &cmd_macro);
r_cmd_add (core->rcmd, "u", "uname/undo", &cmd_uname);
r_cmd_add (core->rcmd, "quit", "exit program session", &cmd_quit);
r_cmd_add (core->rcmd, "Q", "alias for q!", &cmd_Quit);
r_cmd_add (core->rcmd, "L", "manage dynamically loaded plugins", &cmd_plugins);
cmd_search_init (core);
cmd_anal_init (core);
cmd_meta_init (core);
cmd_debug_init (core);
cmd_eval_init (core);
cmd_flag_init (core);
cmd_info_init (core);
cmd_log_init (core);
cmd_mount_init (core);
cmd_open_init (core);
cmd_print_init (core);
cmd_project_init (core);
cmd_quit_init (core);
cmd_seek_init (core);
cmd_section_init (core);
cmd_type_init (core);
cmd_write_init (core);
cmd_zign_init (core);
for (int i = 0; i < R_ARRAY_SIZE (cmds); i++) {
r_cmd_add (core->rcmd, cmds[i].cmd, cmds[i].description, cmds[i].cb);
if (cmds[i].descriptor_init) {
cmds[i].descriptor_init (core);
}
}
DEFINE_CMD_DESCRIPTOR_SPECIAL (core, $, dollar);
DEFINE_CMD_DESCRIPTOR_SPECIAL (core, %, percent);
DEFINE_CMD_DESCRIPTOR_SPECIAL (core, *, star);

View File

@ -4,6 +4,26 @@
#include "r_core.h"
#include "r_egg.h"
static const char *help_msg_g[] = {
"Usage:", "g[wcilper] [arg]", "Go compile shellcodes",
"g", " foo.r", "Compile r_egg source file",
"gw", "", "Compile and write",
"gc", " cmd=/bin/ls", "Set config option for shellcodes and encoders",
"gc", "", "List all config options",
"gl", "[?]", "List plugins (shellcodes, encoders)",
"gs", " name args", "Compile syscall name(args)",
"gi", " [type]", "Compile shellcode. like ragg2 -i (see gl or ragg2 -L)",
"gp", " padding", "Define padding for command",
"ge", " xor", "Specify an encoder",
"gr", "", "Reset r_egg",
"EVAL VARS:", "", "asm.arch, asm.bits, asm.os",
NULL
};
static void cmd_egg_init(RCore *core) {
DEFINE_CMD_DESCRIPTOR (core, g);
}
static void cmd_egg_option(REgg *egg, const char *key, const char *input) {
if (!*input) {
return;
@ -198,26 +218,9 @@ static int cmd_egg(void *data, const char *input) {
break;
}
break;
case '?': {
const char *help_msg[] = {
"Usage:", "g[wcilper] [arg]", "Go compile shellcodes",
"g", " foo.r", "Compile r_egg source file",
"gw", "", "Compile and write",
"gc", " cmd=/bin/ls", "Set config option for shellcodes and encoders",
"gc", "", "List all config options",
"gl", "[?]", "List plugins (shellcodes, encoders)",
"gs", " name args", "Compile syscall name(args)",
"gi", " [type]", "Compile shellcode. like ragg2 -i (see gl or ragg2 -L)",
"gp", " padding", "Define padding for command",
"ge", " xor", "Specify an encoder",
"gr", "", "Reset r_egg",
"EVAL VARS:", "", "asm.arch, asm.bits, asm.os",
NULL
};
r_core_cmd_help (core, help_msg);
}
case '?':
r_core_cmd_help (core, help_msg_g);
break;
}
return true;
}

View File

@ -5,6 +5,163 @@
#include "r_core.h"
#include "r_util.h"
static const char *help_msg_root[] = {
"%var", "=value", "Alias for 'env' command",
"*", "[?] off[=[0x]value]", "Pointer read/write data/values (see ?v, wx, wv)",
"(macro arg0 arg1)", "", "Manage scripting macros",
".", "[?] [-|(m)|f|!sh|cmd]", "Define macro or load r2, cparse or rlang file",
"=","[?] [cmd]", "Send/Listen for Remote Commands (rap://, http://, <fd>)",
"/","[?]", "Search for bytes, regexps, patterns, ..",
"!","[?] [cmd]", "Run given command as in system(3)",
"#","[?] !lang [..]", "Hashbang to run an rlang script",
"a","[?]", "Analysis commands",
"b","[?]", "Display or change the block size",
"c","[?] [arg]", "Compare block with given data",
"C","[?]", "Code metadata (comments, format, hints, ..)",
"d","[?]", "Debugger commands",
"e","[?] [a[=b]]", "List/get/set config evaluable vars",
"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 **' ...",
"L","[?] [-] [plugin]", "list, unload load r2 plugins",
"m","[?]", "Mountpoints commands",
"o","[?] [file] ([offset])", "Open file at optional address",
"p","[?] [len]", "Print current block with format and length",
"P","[?]", "Project management utilities",
"q","[?] [ret]", "Quit program with a return value",
"r","[?] [len]", "Resize file",
"s","[?] [addr]", "Seek to address (also for '0x', '0x1' == 's 0x1')",
"S","[?]", "Io section manipulation information",
"t","[?]", "Types, noreturn, signatures, C parser and more",
"T","[?] [-] [num|msg]", "Text log utility",
"u","[?]", "uname/undo seek/write",
"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",
"z", "[?]", "Zignatures management",
"?[??]","[expr]", "Help or evaluate math expression",
"?$?", "", "Show available '$' variables and aliases",
"?@?", "", "Misc help for '@' (seek), '~' (grep) (see ~?""?)",
"?:?", "", "List and manage core plugins",
NULL
};
static const char *help_msg_question[] = {
"Usage: ?[?[?]] expression", "", "",
"?", " eip-0x804800", "show hex and dec result for this math expr",
"?:", "", "list core cmd plugins",
"?*", " [cmd]?*", "Recursive help for the given cmd",
"?!", " [cmd]", "run cmd if $? == 0",
"?+", " [cmd]", "run cmd if $? > 0",
"?-", " [cmd]", "run cmd if $? < 0",
"?=", " eip-0x804800", "hex and dec result for this math expr",
"?$", "", "show value all the variables ($)",
"??", "", "show value of operation",
"??", " [cmd]", "run cmd if $? != 0",
"?B", " [elem]", "show range boundaries like 'e?search.in",
"?P", " paddr", "get virtual address for given physical one",
"?S", " addr", "return section name of given address",
"?T", "", "show loading times",
"?V", "", "show library version of r_core",
"?X", " num|expr", "returns the hexadecimal value numeric expr",
"?_", " hudfile", "load hud menu with given file",
"?b", " [num]", "show binary value of number",
"?b64[-]", " [str]", "encode/decode in base64",
"?d[.]", " opcode", "describe opcode for asm.arch",
"?e[ngc]", " string", "echo string, optionally without trailing newline (nonl, gotoxy, column)",
"?f", " [num] [str]", "map each bit of the number as flag string index",
"?h", " [str]", "calculate hash for given string",
"?i", "[ynmkp] arg", "prompt for number or Yes,No,Msg,Key,Path and store in $$?",
"?ik", "", "press any key input dialog",
"?im", " message", "show message centered in screen",
"?in", " prompt", "noyes input prompt",
"?iy", " prompt", "yesno input prompt",
"?l", " str", "returns the length of string",
"?o", " num", "get octal value",
"?O", " [id]", "List mnemonics for current asm.arch / asm.bits",
"?p", " vaddr", "get physical address for given virtual address",
"?r", " [from] [to]", "generate random number between from-to",
"?s", " from to step", "sequence of numbers from to by steps",
"?t", " cmd", "returns the time to run a command",
"?u", " num", "get value in human units (KB, MB, GB, TB)",
"?v", " eip-0x804800", "show hex value of math expr",
"?vi", " rsp-rbp", "show decimal value of math expr",
"?w", " addr", "show what's in this address (like pxr/pxq does)",
"?x", "+num", "like ?v, but in hexpairs honoring cfg.bigendian",
"?x", " str", "returns the hexpair of number or string",
"?x", "-hexst", "convert hexpair into raw string with newline",
"?y", " [str]", "show contents of yank buffer, or set with string",
NULL
};
static const char *help_msg_question_colon[] = {
"Usage:", ":[plugin] [args]", "",
":", "", "list RCore plugins",
":java", "", "run java plugin",
NULL
};
static const char *help_msg_question_v[] = {
"Usage: ?v [$.]","","",
"$$", "", "here (current virtual seek)",
"$?", "", "last comparison value",
"$alias", "=value", "Alias commands (simple macros)",
"$b", "", "block size",
"$B", "", "base address (aligned lowest map address)",
"$f", "", "jump fail address (e.g. jz 0x10 => next instruction)",
"$fl", "", "flag length (size) at current address (fla; pD $l @ entry0)",
"$F", "", "current function size",
"$FB", "", "begin of function",
"$Fb", "", "address of the current basic block",
"$Fs", "", "size of the current basic block",
"$FE", "", "end of function",
"$FS", "", "function size",
"$Fj", "", "function jump destination",
"$Ff", "", "function false destination",
"$FI", "", "function instructions",
"$c,$r", "", "get width and height of terminal",
"$Cn", "", "get nth call of function",
"$Dn", "", "get nth data reference in function",
"$D", "", "current debug map base address ?v $D @ rsp",
"$DD", "", "current debug map size",
"$e", "", "1 if end of block, else 0",
"$j", "", "jump address (e.g. jmp 0x10, jz 0x10 => 0x10)",
"$Ja", "", "get nth jump of function",
"$Xn", "", "get nth xref of function",
"$l", "", "opcode length",
"$m", "", "opcode memory reference (e.g. mov eax,[0x10] => 0x10)",
"$M", "", "map address (lowest map address)",
"$o", "", "here (current disk io offset)",
"$p", "", "getpid()",
"$P", "", "pid of children (only in debug)",
"$s", "", "file size",
"$S", "", "section offset",
"$SS", "", "section size",
"$v", "", "opcode immediate value (e.g. lui a0,0x8010 => 0x8010)",
"$w", "", "get word size, 4 if asm.bits=32, 8 if 64, ...",
"${ev}", "", "get value of eval config variable",
"$k{kv}", "", "get value of an sdb query value",
"RNum", "", "$variables usable in math expressions",
NULL
};
static const char *help_msg_question_V[] = {
"Usage: ?V[jq]","","",
"?V", "", "show version information",
"?Vj", "", "same as above but in JSON",
"?Vq", "", "quiet mode, just show the version number",
NULL
};
static void cmd_help_init(RCore *core) {
DEFINE_CMD_DESCRIPTOR_SPECIAL (core, ?, question);
DEFINE_CMD_DESCRIPTOR_SPECIAL (core, ?:, question_colon);
DEFINE_CMD_DESCRIPTOR_SPECIAL (core, ?v, question_v);
DEFINE_CMD_DESCRIPTOR_SPECIAL (core, ?V, question_V);
}
static const char* findBreakChar(const char *s) {
while (*s) {
if (!r_name_validate_char (*s)) {
@ -96,12 +253,7 @@ static int cmd_help(void *data, const char *input) {
RListIter *iter;
RCorePlugin *cp;
if (input[1]=='?') {
const char* help_msg[] = {
"Usage:", ":[plugin] [args]", "",
":", "", "list RCore plugins",
":java", "", "run java plugin",
NULL};
r_core_cmd_help (core, help_msg);
r_core_cmd_help (core, help_msg_question_colon);
return 0;
}
if (input[1]) {
@ -420,49 +572,7 @@ static int cmd_help(void *data, const char *input) {
break;
case '$':
if (input[1] == '?') {
const char* help_msg[] = {
"Usage: ?v [$.]","","",
"$$", "", "here (current virtual seek)",
"$?", "", "last comparison value",
"$alias", "=value", "Alias commands (simple macros)",
"$b", "", "block size",
"$B", "", "base address (aligned lowest map address)",
"$f", "", "jump fail address (e.g. jz 0x10 => next instruction)",
"$fl", "", "flag length (size) at current address (fla; pD $l @ entry0)",
"$F", "", "current function size",
"$FB", "", "begin of function",
"$Fb", "", "address of the current basic block",
"$Fs", "", "size of the current basic block",
"$FE", "", "end of function",
"$FS", "", "function size",
"$Fj", "", "function jump destination",
"$Ff", "", "function false destination",
"$FI", "", "function instructions",
"$c,$r", "", "get width and height of terminal",
"$Cn", "", "get nth call of function",
"$Dn", "", "get nth data reference in function",
"$D", "", "current debug map base address ?v $D @ rsp",
"$DD", "", "current debug map size",
"$e", "", "1 if end of block, else 0",
"$j", "", "jump address (e.g. jmp 0x10, jz 0x10 => 0x10)",
"$Ja", "", "get nth jump of function",
"$Xn", "", "get nth xref of function",
"$l", "", "opcode length",
"$m", "", "opcode memory reference (e.g. mov eax,[0x10] => 0x10)",
"$M", "", "map address (lowest map address)",
"$o", "", "here (current disk io offset)",
"$p", "", "getpid()",
"$P", "", "pid of children (only in debug)",
"$s", "", "file size",
"$S", "", "section offset",
"$SS", "", "section size",
"$v", "", "opcode immediate value (e.g. lui a0,0x8010 => 0x8010)",
"$w", "", "get word size, 4 if asm.bits=32, 8 if 64, ...",
"${ev}", "", "get value of eval config variable",
"$k{kv}", "", "get value of an sdb query value",
"RNum", "", "$variables usable in math expressions",
NULL};
r_core_cmd_help (core, help_msg);
r_core_cmd_help (core, help_msg_question_v);
} else {
int i = 0;
const char *vars[] = {
@ -480,15 +590,7 @@ static int cmd_help(void *data, const char *input) {
case 'V':
switch (input[1]) {
case '?':
{
const char* help_msg[] = {
"Usage: ?V[jq]","","",
"?V", "", "show version information",
"?Vj", "", "same as above but in JSON",
"?Vq", "", "quiet mode, just show the version number",
NULL};
r_core_cmd_help (core, help_msg);
}
r_core_cmd_help (core, help_msg_question_V);
break;
case 0:
#if R2_VERSION_COMMIT == 0
@ -658,10 +760,10 @@ static int cmd_help(void *data, const char *input) {
core->num->value = !r_num_conditional (core->num, input + 2);
eprintf ("%s\n", r_str_bool (!core->num->value));
break;
case 'm':
case 'm': // "?im"
r_cons_message (input+2);
break;
case 'p':
case 'p': // "?ip"
core->num->value = r_core_yank_hud_path (core, input + 2, 0) == true;
break;
case 'k': // "?ik"
@ -675,7 +777,7 @@ static int cmd_help(void *data, const char *input) {
for (input += 2; *input==' '; input++);
core->num->value = r_cons_yesno (0, "%s? (y/N)", input);
break;
default:
default:
{
char foo[1024];
r_cons_flush ();
@ -720,53 +822,7 @@ static int cmd_help(void *data, const char *input) {
}
break;
}
const char* help_msg[] = {
"Usage: ?[?[?]] expression", "", "",
"?", " eip-0x804800", "show hex and dec result for this math expr",
"?:", "", "list core cmd plugins",
"?*", " [cmd]?*", "Recursive help for the given cmd",
"?!", " [cmd]", "run cmd if $? == 0",
"?+", " [cmd]", "run cmd if $? > 0",
"?-", " [cmd]", "run cmd if $? < 0",
"?=", " eip-0x804800", "hex and dec result for this math expr",
"?$", "", "show value all the variables ($)",
"??", "", "show value of operation",
"??", " [cmd]", "run cmd if $? != 0",
"?B", " [elem]", "show range boundaries like 'e?search.in",
"?P", " paddr", "get virtual address for given physical one",
"?S", " addr", "return section name of given address",
"?T", "", "show loading times",
"?V", "", "show library version of r_core",
"?X", " num|expr", "returns the hexadecimal value numeric expr",
"?_", " hudfile", "load hud menu with given file",
"?b", " [num]", "show binary value of number",
"?b64[-]", " [str]", "encode/decode in base64",
"?d[.]", " opcode", "describe opcode for asm.arch",
"?e[ngc]", " string", "echo string, optionally without trailing newline (nonl, gotoxy, column)",
"?f", " [num] [str]", "map each bit of the number as flag string index",
"?h", " [str]", "calculate hash for given string",
"?i", "[ynmkp] arg", "prompt for number or Yes,No,Msg,Key,Path and store in $$?",
"?ik", "", "press any key input dialog",
"?im", " message", "show message centered in screen",
"?in", " prompt", "noyes input prompt",
"?iy", " prompt", "yesno input prompt",
"?l", " str", "returns the length of string",
"?o", " num", "get octal value",
"?O", " [id]", "List mnemonics for current asm.arch / asm.bits",
"?p", " vaddr", "get physical address for given virtual address",
"?r", " [from] [to]", "generate random number between from-to",
"?s", " from to step", "sequence of numbers from to by steps",
"?t", " cmd", "returns the time to run a command",
"?u", " num", "get value in human units (KB, MB, GB, TB)",
"?v", " eip-0x804800", "show hex value of math expr",
"?vi", " rsp-rbp", "show decimal value of math expr",
"?w", " addr", "show what's in this address (like pxr/pxq does)",
"?x", "+num", "like ?v, but in hexpairs honoring cfg.bigendian",
"?x", " str", "returns the hexpair of number or string",
"?x", "-hexst", "convert hexpair into raw string with newline",
"?y", " [str]", "show contents of yank buffer, or set with string",
NULL};
r_core_cmd_help (core, help_msg);
r_core_cmd_help (core, help_msg_question);
return 0;
} else if (input[1]) {
if (core->num->value) {
@ -780,54 +836,12 @@ static int cmd_help(void *data, const char *input) {
}
break;
case '\0':
default:{
const char* help_message[] = {
"%var", "=value", "Alias for 'env' command",
"*", "[?] off[=[0x]value]", "Pointer read/write data/values (see ?v, wx, wv)",
"(macro arg0 arg1)", "", "Manage scripting macros",
".", "[?] [-|(m)|f|!sh|cmd]", "Define macro or load r2, cparse or rlang file",
"=","[?] [cmd]", "Send/Listen for Remote Commands (rap://, http://, <fd>)",
"/","[?]", "Search for bytes, regexps, patterns, ..",
"!","[?] [cmd]", "Run given command as in system(3)",
"#","[?] !lang [..]", "Hashbang to run an rlang script",
"a","[?]", "Analysis commands",
"b","[?]", "Display or change the block size",
"c","[?] [arg]", "Compare block with given data",
"C","[?]", "Code metadata (comments, format, hints, ..)",
"d","[?]", "Debugger commands",
"e","[?] [a[=b]]", "List/get/set config evaluable vars",
"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 **' ...",
"L","[?] [-] [plugin]", "list, unload load r2 plugins",
"m","[?]", "Mountpoints commands",
"o","[?] [file] ([offset])", "Open file at optional address",
"p","[?] [len]", "Print current block with format and length",
"P","[?]", "Project management utilities",
"q","[?] [ret]", "Quit program with a return value",
"r","[?] [len]", "Resize file",
"s","[?] [addr]", "Seek to address (also for '0x', '0x1' == 's 0x1')",
"S","[?]", "Io section manipulation information",
"t","[?]", "Types, noreturn, signatures, C parser and more",
"T","[?] [-] [num|msg]", "Text log utility",
"u","[?]", "uname/undo seek/write",
"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",
"z", "[?]", "Zignatures management",
"?[??]","[expr]", "Help or evaluate math expression",
"?$?", "", "Show available '$' variables and aliases",
"?@?", "", "Misc help for '@' (seek), '~' (grep) (see ~?""?)",
"?:?", "", "List and manage core plugins",
NULL
};
default:
// TODO #7967 help refactor
r_cons_printf("Usage: [.][times][cmd][~grep][@[@iter]addr!size][|>pipe] ; ...\n"
"Append '?' to any char command to get detailed help\n"
"Prefix with number to repeat command N times (f.ex: 3x)\n");
r_core_cmd_help (core, help_message);
}
r_core_cmd_help (core, help_msg_root);
break;
}
return 0;