Initial implementation of asm.reladdr
This commit is contained in:
parent
d9d9ac827b
commit
3b3fa3584f
23
TODO.md
23
TODO.md
|
@ -4,15 +4,9 @@
|
|||
|__\__|_|__|___/__|__|_\__\___\ |____(_)____/
|
||||
|
||||
|
||||
0.9.8
|
||||
=====
|
||||
--> add test * pdr doesnt works well with antidisasm tricks
|
||||
* option to disable aslr in rarun2?
|
||||
* rafind2 : add support for unicode/widestring search
|
||||
* .dr- # documented... but not working
|
||||
* libr/debug/p/drx.c <- not used .. debug must have a hw reg api for drx and gpio
|
||||
* ah -> add hint to define calls that do not return
|
||||
* continue execution until condition happen (reg, mem, ..)
|
||||
* rabin2 -x should not work on non-fatmach0 files
|
||||
* foldable stuff .. was in r1..redo?
|
||||
* cmp rip+xx -> not resolved wtf
|
||||
|
@ -20,11 +14,9 @@
|
|||
- analyze the destination address of each call destination
|
||||
* integrate dwarf parser with disassembler and debugger
|
||||
* step back .. log all state changes on every debugger stop
|
||||
* show analized functions in 'aa' -> discuss
|
||||
* timeout for code analysis (check timestamp)
|
||||
- add analysis points continuation, so 'aa' can be used progressively
|
||||
* Allow to seek to branch N like in visual, but from cmdline
|
||||
* Colorize multiple ranges of chars in hexdump -- cparse
|
||||
* refactor vmenus.c -> refresh function must be redefined for each menu
|
||||
// show hints for
|
||||
0x100005eca ff2540130000 jmp qword [rip+0x1340] [1]
|
||||
|
@ -56,9 +48,8 @@ BUGS
|
|||
- shellforge.. and review current shellcodes :?
|
||||
* rasm2 must support binary creation help message or so..
|
||||
- rabin2 integration must be easier
|
||||
* rabin2 -z /dev/sda1 TAKES TOO LONG. opening r2 /tmp/fs is SLOW as shit.
|
||||
|
||||
* Add support for classes in c++, objc binaries
|
||||
* Add support for classes in c++, objc, java, swift binaries
|
||||
- command to add new classes
|
||||
* Tracing support for the debugger
|
||||
- "e cmd.trace=dr=;.dr*;pd 2@eip"
|
||||
|
@ -80,8 +71,6 @@ BUGS
|
|||
* Add r_cons_prompt () ... calling set_prompt + fgets -- this api needs cleanup
|
||||
- set prompt, set line, fgets
|
||||
- strict width in visual
|
||||
* REFACTOR of disasm loop XDDDDD -1 (r2<1.0 plzz)
|
||||
- arch dependent anal code must be removed from disasm loop +1
|
||||
|
||||
nibble
|
||||
------
|
||||
|
@ -136,14 +125,7 @@ Assembler
|
|||
- So one can change from one arch to another with a pointer
|
||||
- Cool for defining ranges of memory
|
||||
|
||||
* r_io
|
||||
- We need a way to get the underlying file which responds
|
||||
to the read call (this way we can know which library
|
||||
lives at a specified offset. (is this already done?)
|
||||
|
||||
* radare2
|
||||
- Use r_bin with r_io to get symbols
|
||||
- The offset to read will define the module to analyze and retrieve syms
|
||||
- Import msdn doc as comments
|
||||
|
||||
RDB
|
||||
|
@ -164,7 +146,7 @@ RSearch
|
|||
- Enable/disable nested hits? (discuss+ implement in parent app?)
|
||||
- Just skip bytes until end of keyword
|
||||
* AES/RSA Key finding
|
||||
http://citp.princeton.edu/memory/code/ <- implement this stuff in r2
|
||||
http://citp.princeton.edu/memory/code/ <- implement this
|
||||
|
||||
|
||||
Binaries
|
||||
|
@ -221,7 +203,6 @@ pancake
|
|||
* fork/clone child . inject code to create new threads or pids
|
||||
* Functions in r_util to get lil/big ut8,16,32 from ut8*
|
||||
- already done..must find better names probably
|
||||
* rarc2 allows to compile invalid code like calling puts() out of context
|
||||
* Implement RAnalCall (analyze function arguments, return values, propagate types..)
|
||||
- define number of arguments for given function
|
||||
- warn if signature and analysis differs in number of args or so..
|
||||
|
|
|
@ -1199,7 +1199,7 @@ static int cmd_print(void *data, const char *input) {
|
|||
#define P(x) (IS_PRINTABLE(x)?x:'.')
|
||||
#define SPLIT_BITS(x) memmove (x+5, x+4, 5); x[4]=0
|
||||
for (i=c=0; i<len; i++,c++) {
|
||||
if (c==0) r_print_offset (core->print, core->offset+i, 0, 0);
|
||||
if (c==0) r_print_offset (core->print, core->offset+i, 0, 0, 0);
|
||||
r_str_bits (buf, core->block+i, 8, NULL);
|
||||
SPLIT_BITS (buf);
|
||||
r_cons_printf ("%s.%s ", buf, buf+5);
|
||||
|
@ -2148,29 +2148,49 @@ static int cmd_hexdump(void *data, const char *input) {
|
|||
return cmd_print (data, input-1);
|
||||
}
|
||||
|
||||
static int lenof (ut64 off, int two) {
|
||||
char buf[64];
|
||||
buf[0] = 0;
|
||||
if (two) snprintf (buf, sizeof (buf), "+0x%"PFMT64x, off);
|
||||
else snprintf (buf, sizeof (buf), "0x%08"PFMT64x, off);
|
||||
|
||||
return strlen (buf);
|
||||
}
|
||||
// TODO : move to r_util? .. depends on r_cons...
|
||||
R_API void r_print_offset(RPrint *p, ut64 off, int invert, int opt) {
|
||||
R_API void r_print_offset(RPrint *p, ut64 off, int invert, int offseg, int delta) {
|
||||
int show_color = p->flags & R_PRINT_FLAGS_COLOR;
|
||||
if (show_color) {
|
||||
const char *k = r_cons_singleton ()->pal.offset; // TODO etooslow. must cache
|
||||
if (invert)
|
||||
r_cons_invert (R_TRUE, R_TRUE);
|
||||
if (opt) {
|
||||
if (offseg) {
|
||||
ut32 s, a;
|
||||
a = off & 0xffff;
|
||||
s = (off-a)>>4;
|
||||
r_cons_printf ("%s%04x:%04x"Color_RESET,
|
||||
k, s&0xFFFF, a&0xFFFF);
|
||||
} else r_cons_printf ("%s0x%08"PFMT64x""Color_RESET, k, off);
|
||||
} else {
|
||||
int sz = lenof (off, 0);
|
||||
int sz2 = lenof (delta, 1);
|
||||
const char *pad = r_str_pad (' ', sz-sz2);
|
||||
if (delta>0) {
|
||||
r_cons_printf ("%s+0x%x"Color_RESET, pad, delta);
|
||||
} else r_cons_printf ("%s0x%08"PFMT64x""Color_RESET, k, off);
|
||||
}
|
||||
r_cons_puts (" ");
|
||||
} else {
|
||||
if (opt) {
|
||||
if (offseg) {
|
||||
ut32 s, a;
|
||||
a = off & 0xffff;
|
||||
s = (off-a)>>4;
|
||||
r_cons_printf ("%04x:%04x", s&0xFFFF, a&0xFFFF);
|
||||
} else {
|
||||
r_cons_printf ("0x%08"PFMT64x" ", off);
|
||||
int sz = lenof (off, 0);
|
||||
int sz2 = lenof (delta, 1);
|
||||
const char *pad = r_str_pad (' ', sz-5-sz2-3);
|
||||
if (delta>0) {
|
||||
r_cons_printf ("%s+0x%x"Color_RESET, pad, delta);
|
||||
} else r_cons_printf ("0x%08"PFMT64x" ", off);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -911,6 +911,7 @@ R_API int r_core_config_init(RCore *core) {
|
|||
SETICB("asm.lineswidth", 7, &cb_asmlineswidth, "Number of columns for program flow arrows");
|
||||
SETPREF("asm.middle", "false", "Allow disassembling jumps in the middle of an instruction");
|
||||
SETPREF("asm.offset", "true", "Show offsets at disassembly");
|
||||
SETPREF("asm.reladdr", "false", "Show delta offsets instead of absolute address in disasm");
|
||||
SETPREF("asm.section", "false", "Show section name before offset");
|
||||
SETPREF("asm.pseudo", "false", "Enable pseudo syntax"); // DEPRECATED ?
|
||||
SETPREF("asm.size", "false", "Show size of opcodes in disassembly (pd)");
|
||||
|
|
|
@ -64,6 +64,7 @@ typedef struct r_disam_options_t {
|
|||
int show_offseg;
|
||||
int show_flags;
|
||||
int show_bytes;
|
||||
int show_reladdr;
|
||||
int show_comments;
|
||||
int cmtcol;
|
||||
int show_fcnlines;
|
||||
|
@ -275,6 +276,7 @@ static RDisasmState * handle_init_ds (RCore * core) {
|
|||
ds->show_offseg = r_config_get_i (core->config, "asm.segoff");
|
||||
ds->show_flags = r_config_get_i (core->config, "asm.flags");
|
||||
ds->show_bytes = r_config_get_i (core->config, "asm.bytes");
|
||||
ds->show_reladdr = r_config_get_i (core->config, "asm.reladdr");
|
||||
ds->show_fcnlines = r_config_get_i (core->config, "asm.fcnlines");
|
||||
ds->show_comments = r_config_get_i (core->config, "asm.comments");
|
||||
ds->show_calls = r_config_get_i (core->config, "asm.calls");
|
||||
|
@ -1091,9 +1093,13 @@ static void handle_print_offset (RCore *core, RDisasmState *ds) {
|
|||
core->screen_bounds = ds->at;
|
||||
}
|
||||
}
|
||||
if (ds->show_offset)
|
||||
if (ds->show_offset) {
|
||||
int delta = 0;
|
||||
if (ds->show_reladdr)
|
||||
delta = ds->at - core->offset;
|
||||
r_print_offset (core->print, ds->at, (ds->at==ds->dest),
|
||||
ds->show_offseg);
|
||||
ds->show_offseg, delta);
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_print_op_size (RCore *core, RDisasmState *ds) {
|
||||
|
|
|
@ -94,7 +94,7 @@ R_API void r_print_code(RPrint *p, ut64 addr, ut8 *buf, int len, char lang);
|
|||
R_API int r_print_format_struct_size(const char *format, RPrint *p);
|
||||
R_API int r_print_format(RPrint *p, ut64 seek, const ut8* buf, const int len, const char *fmt, int elem, const char *setval, char *field);
|
||||
R_API int r_print_format_length (const char *fmt);
|
||||
R_API void r_print_offset(RPrint *p, ut64 off, int invert, int opt);
|
||||
R_API void r_print_offset(RPrint *p, ut64 off, int invert, int opt, int delta);
|
||||
#define R_PRINT_STRING_WIDE 1
|
||||
#define R_PRINT_STRING_ZEROEND 2
|
||||
#define R_PRINT_STRING_URLENCODE 4
|
||||
|
|
|
@ -366,6 +366,7 @@ static inline void r_str_rmch (char *s, char ch) {
|
|||
}
|
||||
}
|
||||
#define r_str_array(x,y) ((y>=0 && y<(sizeof(x)/sizeof(*x)))?x[y]:"")
|
||||
R_API const char *r_str_pad(const char ch, int len);
|
||||
R_API const char *r_str_rchr(const char *base, const char *p, int ch);
|
||||
R_API const char *r_str_closer_chr (const char *b, const char *s);
|
||||
R_API int r_str_bounds(const char *str, int *h);
|
||||
|
|
|
@ -1495,3 +1495,13 @@ R_API const char * r_str_tok (const char *str1, const char b, size_t len) {
|
|||
if (i == len) p = NULL;
|
||||
return p;
|
||||
}
|
||||
|
||||
R_API const char *r_str_pad(const char ch, int sz) {
|
||||
static char pad[1024];
|
||||
if (sz<0) sz = 0;
|
||||
memset (pad, ch, R_MIN (sz, sizeof (pad)));
|
||||
if (sz<sizeof(pad))
|
||||
pad[sz] = 0;
|
||||
pad[sizeof(pad)-1] = 0;
|
||||
return pad;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue