* Added doc/changes-from-1.x
* Added r_core_yank* methods and 'y' command - Update help message * radare2 is now handling -s and -b cmdline flags * Fix r_print_hexdump
This commit is contained in:
parent
777235bb87
commit
20e4696d50
8 changed files with 152 additions and 25 deletions
31
doc/changes-from-1.x
Normal file
31
doc/changes-from-1.x
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
Changes from radare 1.x
|
||||
=======================
|
||||
|
||||
There are some changes between 1.x and 2.x branches, they are
|
||||
obviously structurally completely different. But in essence
|
||||
the user interface has been keeped as much as similar but
|
||||
some changes have been done to fit better the new possibilities
|
||||
of the refactor.
|
||||
|
||||
List of things that has changed:
|
||||
|
||||
- Debugger interface is no longer depending on the io layer
|
||||
|
||||
Now, r_core ships the 'd' command that stands for 'debug'.
|
||||
'ds' for step, 'db' for breakpoint, 'dr' for registers...
|
||||
|
||||
- Everything is a module
|
||||
|
||||
As we have splitted all the basic elements into libraries and
|
||||
all the extensions for each module as plugins we can either
|
||||
extend the program and allow any module directly interact
|
||||
with each other. This fixes the limitation of symbol visibilty
|
||||
between plugins allowing for example to use libr-py from inside
|
||||
the core reusing the already loaded libraries in memory.
|
||||
|
||||
- Source address is now accessible from lot of commands
|
||||
|
||||
To speed up the execution of some commands that dont need to
|
||||
read memory to get a source address they now receive an
|
||||
optional argument to specify the offset. Here's a simple
|
||||
example: "f foo @ 0x300" can be now expressed as "f foo 0x300"
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
NAME=r_core
|
||||
DEPS=r_config r_cons r_line r_io r_cmd r_util r_print r_flags r_asm r_lib r_macro r_debug r_hash r_bin r_lang r_io r_asm r_anal r_config r_macro r_print
|
||||
|
||||
OBJ=core.o cmd.o file.o config.o visual.o io.o
|
||||
OBJ=core.o cmd.o file.o config.o visual.o io.o yank.o
|
||||
|
||||
include ../rules.mk
|
||||
|
|
|
|||
|
|
@ -26,6 +26,41 @@ static int cmd_iopipe(void *data, const char *input)
|
|||
return R_TRUE;
|
||||
}
|
||||
|
||||
static int cmd_yank(void *data, const char *input)
|
||||
{
|
||||
struct r_core_t *core = (struct r_core_t *)data;
|
||||
switch(input[0]) {
|
||||
case ' ':
|
||||
r_core_yank(core, core->seek, atoi(input+1));
|
||||
break;
|
||||
case 'y':
|
||||
r_core_yank_paste(core, r_num_math(&core->num, input+2), 0);
|
||||
break;
|
||||
case '\0':
|
||||
if (core->yank == NULL) {
|
||||
fprintf(stderr, "No buffer yanked already\n");
|
||||
} else {
|
||||
int i;
|
||||
r_cons_printf("0x%08llx %d ",
|
||||
core->yank_off, core->yank_len);
|
||||
for(i=0;i<core->yank_len;i++)
|
||||
r_cons_printf("%02x", core->yank[i]);
|
||||
r_cons_newline();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
r_cons_printf(
|
||||
"Usage: y[y] [len] [[@]addr]\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"
|
||||
" yy 0x3344 ; paste clipboard\n");
|
||||
break;
|
||||
}
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
static int cmd_quit(void *data, const char *input)
|
||||
{
|
||||
struct r_core_t *core = (struct r_core_t *)data;
|
||||
|
|
@ -174,23 +209,30 @@ static int cmd_help(void *data, const char *input)
|
|||
break;
|
||||
case '\0':
|
||||
default:
|
||||
fprintf(stderr,
|
||||
r_cons_printf(
|
||||
"Usage:\n"
|
||||
" b [bsz] ; get or change block size\n"
|
||||
" e [a[=b]] ; list/get/set config evaluable vars\n"
|
||||
" f [name][sz][at] ; set flag at current address\n"
|
||||
" s [addr] ; seek to address\n"
|
||||
" i [file] ; get info about opened file\n"
|
||||
" p?[len] ; print current block with format and length\n"
|
||||
" x [len] ; alias for 'px' (print hexadecimal\n"
|
||||
" w[mode] [arg] ; multiple write operations\n"
|
||||
" V ; enter visual mode\n"
|
||||
" ? [expr] ; evaluate math expression\n"
|
||||
" |[cmd] ; run this command thru the io pipe (no args=list)\n"
|
||||
" #[algo] [len] ; calculate hash checksum of current block\n"
|
||||
" q [ret] ; quit program with a return value\n"
|
||||
"Append '?' to any char command to get detailed help\n"
|
||||
"");
|
||||
" a ; perform analysis of code\n"
|
||||
" b [bsz] ; get or change block size\n"
|
||||
" d[hrscb] ; debugger commands\n"
|
||||
" C[CFf..] ; Code metadata management\n"
|
||||
" e [a[=b]] ; list/get/set config evaluable vars\n"
|
||||
" i ; get info of the current file\n"
|
||||
" f [name][sz][at] ; set flag at current address\n"
|
||||
" s [addr] ; seek to address\n"
|
||||
" i [file] ; get info about opened file\n"
|
||||
" p?[len] ; print current block with format and length\n"
|
||||
" x [len] ; alias for 'px' (print hexadecimal\n"
|
||||
" y [len] [off] ; yank/paste bytes from/to memory\n"
|
||||
" w[mode] [arg] ; multiple write operations\n"
|
||||
" V[vcmds] ; enter visual mode (vcmds=visualvisual keystrokes)\n"
|
||||
" ? [expr] ; help or evaluate math expression\n"
|
||||
" /[xmp/] ; search for bytes, regexps, patterns, ..\n"
|
||||
" |[cmd] ; run this command thru the io pipe (no args=list)\n"
|
||||
" #[algo] [len] ; calculate hash checksum of current block\n"
|
||||
" .[ file|!cmd|cmd|(macro)] ; interpret as radare cmds\n"
|
||||
" (macro arg0 arg1) ; define scripting macros\n"
|
||||
" q [ret] ; quit program with a return value\n"
|
||||
"Append '?' to any char command to get detailed help\n");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -1142,6 +1184,7 @@ int r_core_cmd_init(struct r_core_t *core)
|
|||
r_cmd_add(&core->cmd, "print", "print current block", &cmd_print);
|
||||
r_cmd_add(&core->cmd, "write", "write bytes", &cmd_write);
|
||||
r_cmd_add(&core->cmd, "Code", "code metadata", &cmd_meta);
|
||||
r_cmd_add(&core->cmd, "yank", "yank bytes", &cmd_yank);
|
||||
r_cmd_add(&core->cmd, "Visual", "enter visual mode", &cmd_visual);
|
||||
r_cmd_add(&core->cmd, "!", "run system command", &cmd_system);
|
||||
r_cmd_add(&core->cmd, "|", "run io system command", &cmd_io_system);
|
||||
|
|
|
|||
|
|
@ -96,6 +96,9 @@ int r_core_init(struct r_core_t *core)
|
|||
{
|
||||
core->oobi = NULL;
|
||||
core->oobi_len = 0;
|
||||
core->yank = NULL;
|
||||
core->yank_len = 0;
|
||||
core->yank_off = 0LL;
|
||||
core->num.callback = &num_callback;
|
||||
core->num.userptr = core;
|
||||
r_lang_init(&core->lang);
|
||||
|
|
|
|||
|
|
@ -11,13 +11,15 @@ static struct r_core_t r;
|
|||
|
||||
static int main_help(int line)
|
||||
{
|
||||
printf("Usage: radare2 [-dwnV] [-e k=v] [file] [...]\n");
|
||||
printf("Usage: radare2 [-dwnV] [-s addr] [-b bsz] [-e k=v] [file] [...]\n");
|
||||
if (!line) printf(
|
||||
" -d use 'file' as a program to debug\n"
|
||||
" -w open file in write mode\n"
|
||||
" -n do not run ~/.radarerc\n"
|
||||
" -V show radare2 version\n"
|
||||
" -e k=v evaluate config var\n");
|
||||
" -d use 'file' as a program to debug\n"
|
||||
" -w open file in write mode\n"
|
||||
" -n do not run ~/.radarerc\n"
|
||||
" -s [addr] initial seek\n"
|
||||
" -b [size] initial block size\n"
|
||||
" -V show radare2 version\n"
|
||||
" -e k=v evaluate config var\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -33,13 +35,15 @@ int main(int argc, char **argv)
|
|||
int c, perms = R_IO_READ;
|
||||
int run_rc = 1;
|
||||
int debug = 0;
|
||||
int bsize = 0;
|
||||
int seek = 0; // XXX use 64
|
||||
|
||||
if (argc<2)
|
||||
return main_help(1);
|
||||
|
||||
r_core_init(&r);
|
||||
|
||||
while((c = getopt(argc, argv, "whendV"))!=-1) {
|
||||
while((c = getopt(argc, argv, "whendVs:b:"))!=-1) {
|
||||
switch(c) {
|
||||
case 'd':
|
||||
debug = 1;
|
||||
|
|
@ -58,6 +62,12 @@ int main(int argc, char **argv)
|
|||
case 'w':
|
||||
perms = R_IO_RDWR;
|
||||
break;
|
||||
case 'b':
|
||||
bsize = atoi(optarg); // XXX use r_num
|
||||
break;
|
||||
case 's':
|
||||
seek = atoi(optarg); // XXX use r_num
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -120,6 +130,11 @@ int main(int argc, char **argv)
|
|||
r_core_cmd(&r, "\"e cmd.vprompt=.dr&&s eip\"",0);
|
||||
}
|
||||
|
||||
if (seek)
|
||||
r_core_seek(&r, seek);
|
||||
if (bsize)
|
||||
r_core_block_size(&r, bsize);
|
||||
|
||||
while(r_core_prompt(&r) != -1);
|
||||
|
||||
return r_core_file_close(&r, fh);
|
||||
|
|
|
|||
32
libr/core/yank.c
Normal file
32
libr/core/yank.c
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/* radare - LGPL - Copyright 2009 pancake<nopcode.org> */
|
||||
|
||||
#include "r_core.h"
|
||||
|
||||
int r_core_yank(struct r_core_t *core, u64 addr, int len)
|
||||
{
|
||||
u64 curseek = core->seek;
|
||||
free(core->yank);
|
||||
core->yank = (u8 *)malloc(len);
|
||||
if (addr != core->seek)
|
||||
r_core_seek(core, addr);
|
||||
if (len == 0)
|
||||
len = core->blocksize;
|
||||
if (len > core->blocksize)
|
||||
r_core_block_size(core, len);
|
||||
else memcpy(core->yank, core->block, len);
|
||||
core->yank_off = addr;
|
||||
core->yank_len = len;
|
||||
if (curseek != addr)
|
||||
r_core_seek(core, curseek);
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
int r_core_yank_paste(struct r_core_t *core, u64 addr, int len)
|
||||
{
|
||||
if (len == 0)
|
||||
len = core->yank_len;
|
||||
if (len > core->yank_len)
|
||||
len = core->yank_len;
|
||||
r_core_write_at(core, addr, core->yank, len);
|
||||
return R_TRUE;
|
||||
}
|
||||
|
|
@ -37,6 +37,9 @@ struct r_core_t {
|
|||
u8 *block;
|
||||
u8 *oobi;
|
||||
int oobi_len;
|
||||
u8 *yank;
|
||||
int yank_len;
|
||||
u64 yank_off;
|
||||
/* files */
|
||||
struct r_io_t io;
|
||||
struct r_core_file_t *file;
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ void r_print_hexdump(u64 addr, u8 *buf, int len, int step, int columns, int head
|
|||
}
|
||||
}
|
||||
r_cons_newline();
|
||||
addr+=inc;
|
||||
//addr+=inc;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue