mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-02 10:16:21 +00:00
Colorize @@, *, r, k, y and $
This commit is contained in:
parent
1407d499b5
commit
2976f30b68
140
libr/core/cmd.c
140
libr/core/cmd.c
@ -146,13 +146,16 @@ static int cmd_alias(void *data, const char *input) {
|
||||
char *p, *q, *buf;
|
||||
RCore *core = (RCore *)data;
|
||||
if (*input=='?') {
|
||||
r_cons_printf ("|Usage: -alias[=cmd] [args...]\n"
|
||||
"| $dis=af,pdf # create command -analyze to show function\n"
|
||||
"| $dis= # undefine alias\n"
|
||||
"| $dis# execute the previously defined alias\n"
|
||||
"| $dis? # show commands aliased by 'analyze'\n"
|
||||
"| $ # list all defined aliases\n"
|
||||
"| $* # sas above, but using r2 commands\n");
|
||||
const char* help_msg[] = {
|
||||
"Usage:", "$alias[=cmd] [args...]", "Alias commands",
|
||||
"$", "", "list all defined aliases",
|
||||
"$", "dis=af,pdf", "create command -analyze to show function",
|
||||
"$*", "", "same as above, but using r2 commands",
|
||||
"$", "dis=", "undefine alias",
|
||||
"$", "dis", "execute the previously defined alias",
|
||||
"$", "dis?", "show commands aliased by 'analyze'",
|
||||
NULL};
|
||||
r_core_cmd_help (core, help_msg);
|
||||
return 0;
|
||||
}
|
||||
i = strlen (input);
|
||||
@ -267,23 +270,26 @@ static int cmd_yank(void *data, const char *input) {
|
||||
case '\0':
|
||||
r_core_yank_dump (core, r_num_math (core->num, input+1));
|
||||
break;
|
||||
default:
|
||||
r_cons_printf (
|
||||
"|Usage: y[ptxy] [len] [[@]addr] # See wd? for memcpy, same as 'yf'.\n"
|
||||
"| y show yank buffer information (srcoff len bytes)\n"
|
||||
"| y 16 copy 16 bytes into clipboard\n"
|
||||
"| y 16 0x200 copy 16 bytes into clipboard from 0x200\n"
|
||||
"| y 16 @ 0x200 copy 16 bytes into clipboard from 0x200\n"
|
||||
"| yz copy up to blocksize zero terminated string bytes into clipboard\n"
|
||||
"| yz 16 copy up to 16 zero terminated string bytes into clipboard\n"
|
||||
"| yz @ 0x200 copy up to blocksize zero terminated string bytes into clipboard from 0x200\n"
|
||||
"| yz 16 @ 0x200 copy up to 16 zero terminated string bytes into clipboard from 0x200\n"
|
||||
"| yp print contents of clipboard\n"
|
||||
"| yx print contents of clipboard in hexadecimal\n"
|
||||
"| yt 64 0x200 copy 64 bytes from current seek to 0x200\n"
|
||||
"| yf 64 0x200 file copy 64 bytes from 0x200 from file (opens w/ io), use -1 for all bytes\n"
|
||||
"| yfa file copy copy all bytes from from file (opens w/ io)\n"
|
||||
"| yy 0x3344 paste clipboard\n");
|
||||
default:{
|
||||
const char* help_msg[] = {
|
||||
"Usage:", "y[ptxy] [len] [[@]addr]", " # See wd? for memcpy, same as 'yf'.",
|
||||
"y", "", "show yank buffer information (srcoff len bytes)",
|
||||
"y", " 16", "copy 16 bytes into clipboard",
|
||||
"y", " 16 0x200", "copy 16 bytes into clipboard from 0x200",
|
||||
"y", " 16 @ 0x200", "copy 16 bytes into clipboard from 0x200",
|
||||
"yz", "", "copy up to blocksize zero terminated string bytes into clipboard",
|
||||
"yz", " 16", "copy up to 16 zero terminated string bytes into clipboard",
|
||||
"yz", " @ 0x200", "copy up to blocksize zero terminated string bytes into clipboard from 0x200",
|
||||
"yz", " 16 @ 0x200", "copy up to 16 zero terminated string bytes into clipboard from 0x200",
|
||||
"yp", "", "print contents of clipboardn",
|
||||
"yx", "", "print contents of clipboard in hexadecimal",
|
||||
"yt", " 64 0x200", "copy 64 bytes from current seek to 0x200",
|
||||
"yf", " 64 0x200", "file copy 64 bytes from 0x200 from file (opens w/ io), use -1 for all bytes",
|
||||
"yfa", " file copy", "copy all bytes from from file (opens w/ io)",
|
||||
"yy", " 0x3344", "paste clipboard",
|
||||
NULL};
|
||||
r_core_cmd_help (core, help_msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return R_TRUE;
|
||||
@ -480,18 +486,22 @@ static int cmd_kuery(void *data, const char *input) {
|
||||
if (out) r_cons_printf ("%s\n", out);
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
eprintf ("|Usage: k[s] [key[=value]]\n"
|
||||
"| k foo=bar # set value\n"
|
||||
"| k foo # show value\n"
|
||||
"| k # list keys\n"
|
||||
"| ks [ns] # enter the sdb query shell\n"
|
||||
"| k anal/meta/* # list kv from anal > meta namespaces\n"
|
||||
"| k anal/** # list namespaces under anal\n"
|
||||
"| k anal/meta/meta.0x80404 # get value for meta.0x80404 key\n"
|
||||
//"| kl ha.sdb # load keyvalue from ha.sdb\n"
|
||||
//"| ks ha.sdb # save keyvalue to ha.sdb\n"
|
||||
);
|
||||
case '?':{
|
||||
const char* help_msg[] = {
|
||||
"Usage:", "k[s] [key[=value]]", "Sdb Query",
|
||||
"k", " foo=bar", "set value",
|
||||
"k", " foo", "show value",
|
||||
"k", "", "list keys",
|
||||
"ks", " [ns]", "enter the sdb query shell",
|
||||
"k", " anal/meta/*", "ist kv from anal > meta namespaces",
|
||||
"k", " anal/**", "list namespaces under anal",
|
||||
"k", " anal/meta/meta.0x80404", "get value for meta.0x80404 key",
|
||||
//"kl", " ha.sdb", "load keyvalue from ha.sdb",
|
||||
//"ks", " ha.sdb", "save keyvalue to ha.sdb",
|
||||
NULL,
|
||||
};
|
||||
r_core_cmd_help (core, help_msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -592,14 +602,17 @@ static int cmd_resize(void *data, const char *input) {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case '?':
|
||||
r_cons_printf (
|
||||
"|Usage: r[+-][ size]\n"
|
||||
"| r display file size\n"
|
||||
"| r size expand or truncate file to given size\n"
|
||||
"| r-num remove num bytes, move following data down\n"
|
||||
"| r+num insert num bytes, move following data up\n"
|
||||
"| rm [file] remove file\n");
|
||||
case '?':{
|
||||
const char* help_msg[] = {
|
||||
"Usage:", "r[+-][ size]", "Resize file",
|
||||
"r", "", "display file size",
|
||||
"r", " size", "expand or truncate file to given size",
|
||||
"r-", "num", "remove num bytes, move following data down",
|
||||
"r+", "num", "insert num bytes, move following data up",
|
||||
"rm" ," [file]", "remove file",
|
||||
NULL};
|
||||
r_core_cmd_help (core, help_msg);
|
||||
}
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
@ -636,15 +649,19 @@ static int cmd_visual(void *data, const char *input) {
|
||||
}
|
||||
|
||||
static int cmd_pointer(void *data, const char *input) {
|
||||
RCore *core = (RCore*) data;
|
||||
int ret = R_TRUE;
|
||||
char *str, *eq;
|
||||
while (*input==' ') input++;
|
||||
if (!*input || *input=='?') {
|
||||
eprintf ("|Usage: *<addr>[=[0x]value]\n"
|
||||
"| *entry0=cc # write trap in entrypoint\n"
|
||||
"| *entry0+10=0x804800 # write value in delta address\n"
|
||||
"| *entry0 # read byte at given address\n"
|
||||
"|TODO: last command should honor asm.bits\n");
|
||||
const char* help_msg[] = {
|
||||
"Usage:", "*<addr>[=[0x]value]", "Pointer read/write data/values",
|
||||
"*", "entry0=cc", "write trap in entrypoint",
|
||||
"*", "entry0+10=0x804800", "write value in delta address",
|
||||
"*", "entry0", "read byte at given address",
|
||||
"TODO: last command should honor asm.bits", "", "",
|
||||
NULL};
|
||||
r_core_cmd_help (core, help_msg);
|
||||
return ret;
|
||||
}
|
||||
str = strdup (input);
|
||||
@ -652,12 +669,12 @@ static int cmd_pointer(void *data, const char *input) {
|
||||
if (eq) {
|
||||
*eq++ = 0;
|
||||
if (!strncmp (eq, "0x", 2)) {
|
||||
ret = r_core_cmdf ((RCore*)data, "wv %s@%s", eq, str);
|
||||
ret = r_core_cmdf (core, "wv %s@%s", eq, str);
|
||||
} else {
|
||||
ret = r_core_cmdf ((RCore*)data, "wx %s@%s", eq, str);
|
||||
ret = r_core_cmdf (core, "wx %s@%s", eq, str);
|
||||
}
|
||||
} else {
|
||||
ret = r_core_cmdf ((RCore*)data, "?v [%s]", input);
|
||||
ret = r_core_cmdf (core, "?v [%s]", input);
|
||||
}
|
||||
free (str);
|
||||
return ret;
|
||||
@ -1266,14 +1283,17 @@ R_API int r_core_cmd_foreach(RCore *core, const char *cmd, char *each) {
|
||||
//r_cons_break();
|
||||
|
||||
switch (each[0]) {
|
||||
case '?':
|
||||
r_cons_printf (
|
||||
"|Foreach '@@' iterator command:\n"
|
||||
"| Repeat a command over a list of offsets.\n"
|
||||
"| x @@ sym.* Run 'x' over all flags matching 'sym.' in current flagspace\n"
|
||||
"| x @@.file \"\" over the offsets specified in the file (one offset per line)\n"
|
||||
"| x @@=off1 off2 .. Manual list of offsets\n"
|
||||
"| x @@=`pdf~call[0]` Run 'x' at every call offset of the current function\n");
|
||||
case '?':{
|
||||
const char* help_msg[] = {
|
||||
"@@", "", " # foreach iterator command:",
|
||||
"Repeat a command over a list of offsets", "", "",
|
||||
"x", " @@ sym.*", "run 'x' over all flags matching 'sym.' in current flagspace",
|
||||
"x", " @@.file", "\"\" over the offsets specified in the file (one offset per line)",
|
||||
"x", " @@=off1 off2 ..", "manual list of offsets",
|
||||
"x", " @@=`pdf~call[0]`", "run 'x' at every call offset of the current function",
|
||||
NULL};
|
||||
r_core_cmd_help (core, help_msg);
|
||||
}
|
||||
break;
|
||||
case '=':
|
||||
/* foreach list of items */
|
||||
|
Loading…
Reference in New Issue
Block a user