* merge heads

This commit is contained in:
pancake 2010-10-26 17:32:34 +02:00
commit b82d826350
13 changed files with 177 additions and 181 deletions

8
TODO
View File

@ -10,13 +10,6 @@ TODO 0.6
pancake
* fix eflags string and str_bits
* fix arm assembler issue reported via twitter (umf :/)
nibble
* fix colorize of cursor selected bytes
* in Visual Debugger mode cursor mode also scrolls O_o
- cursor mode in visual breaks flags too (r2 -d ls ; Vcjjj)
- visual cursor mode and then :f jeje @ addr <- fails!
* Switch to 'arm' code analysis module :?
* mach0 armthumb bin detect
Questions
=========
@ -120,6 +113,7 @@ Refactoring
0.7
===
* Refactor cursor stuff
* r2 -d <pid> > dh native > dp=824 > ... -- not really :) for 0.6
* Create radare2-testsuite project
- tests for ired, rax2, radare2, rabin2 ...

View File

@ -422,9 +422,10 @@ static int rabin_show_info() {
"e asm.arch=%s\n"
"e anal.plugin=%s\n"
"e asm.bits=%i\n"
"e vm.arch=%s\n"
"e asm.dwarf=%s\n",
info->rclass, info->big_endian?"true":"false", info->os,
info->arch, info->arch, info->bits,
info->arch, info->arch, info->bits, info->arch,
R_BIN_DBG_STRIPPED (info->dbg_info)?"false":"true");
} else {
eprintf ("[File info]\n");

View File

@ -7,7 +7,6 @@
#include <getopt.h>
static struct r_core_t r;
static char *rabin_cmd = NULL;
static int main_help(int line) {
printf ("Usage: radare2 [-dwntLV] [-p prj] [-s addr] [-b bsz] [-e k=v] [file]\n");
@ -132,9 +131,8 @@ int main(int argc, char **argv) {
}
if (debug) {
char file[1024];
r_config_set (r.config, "io.va", "false");
r_config_set (r.config, "io.va", "false"); // implicit?
r_config_set (r.config, "cfg.debug", "true");
r.io->va = R_FALSE;
strcpy (file, "dbg://");
if (optind < argc) {
char *ptr = r_file_path (argv[optind]);

View File

@ -9,9 +9,9 @@
typedef struct {
unsigned long off;
int o;
char op[32];
char opstr[32];
char *a0, *a1, *a2;
char op[128];
char opstr[128];
char *a[16];
} ArmOpcode;
typedef struct {
@ -156,25 +156,25 @@ static int getshift(const char *str) {
}
static void arm_opcode_parse(ArmOpcode *ao, const char *str) {
int i;
memset (ao, 0, sizeof (ArmOpcode));
strncpy (ao->op, str, sizeof (ao->op)-1);
strcpy (ao->opstr, str);
ao->a0 = strchr (ao->op, ' ');
if (ao->a0) {
*ao->a0 = 0;
ao->a1 = strchr (++ao->a0, ',');
if (ao->a1) {
*ao->a1 = 0;
ao->a2 = strchr (++ao->a1, ',');
if (ao->a2) {
*ao->a2 = 0;
ao->a2++;
}
}
ao->a[0] = strchr (ao->op, ' ');
for (i=0; i<16; i++) {
if (ao->a[i]) {
*ao->a[i] = 0;
ao->a[i+1] = strchr (++ao->a[i], ',');
} else break;
}
while (ao->a0&&*ao->a0==' ') ao->a0++;
while (ao->a1&&*ao->a1==' ') ao->a1++;
while (ao->a2&&*ao->a2==' ') ao->a2++;
if (ao->a[i]) {
*ao->a[i] = 0;
ao->a[i]++;
}
for (i=0; i<16; i++)
while (ao->a[i]&&*ao->a[i]==' ')
ao->a[i]++;
}
static inline int arm_opcode_cond(ArmOpcode *ao, int delta) {
@ -186,7 +186,7 @@ static inline int arm_opcode_cond(ArmOpcode *ao, int delta) {
char *c = ao->op+delta;
for (i=0; conds[i]; i++) {
if (!strcmp (c, conds[i])) {
cond = i;
cond = i;
break;
}
}
@ -197,11 +197,11 @@ static inline int arm_opcode_cond(ArmOpcode *ao, int delta) {
// TODO: group similar instructions like for non-thumb
static int thumb_assemble(ArmOpcode *ao, const char *str) {
if (!strcmp (ao->op, "ldmia")) {
ao->o = 0xc8 + getreg (ao->a0);
ao->o = 0xc8 + getreg (ao->a[0]);
ao->o |= getlist(ao->opstr) << 8;
} else
if (!strcmp (ao->op, "stmia")) {
ao->o = 0xc0 + getreg (ao->a0);
ao->o = 0xc0 + getreg (ao->a[0]);
ao->o |= getlist(ao->opstr) << 8;
} else
if (!strcmp (ao->op, "nop")) {
@ -221,55 +221,55 @@ static int thumb_assemble(ArmOpcode *ao, const char *str) {
} else
if (!strcmp (ao->op, "bkpt")) {
ao->o = 0xbe;
ao->o |= (0xff & getnum (ao->a0))<<8;
ao->o |= (0xff & getnum (ao->a[0]))<<8;
} else
if (!strcmp (ao->op, "and")) {
ao->o = 0x40;
ao->o |= (0xff & getreg (ao->a0)) << 8;
ao->o |= (0xff & getreg (ao->a1)) << 11;
ao->o |= (0xff & getreg (ao->a[0])) << 8;
ao->o |= (0xff & getreg (ao->a[1])) << 11;
} else
if (!strcmp (ao->op, "svc")) {
ao->o = 0xdf;
ao->o |= (0xff & getnum (ao->a0)) << 8;
ao->o |= (0xff & getnum (ao->a[0])) << 8;
} else
if (!strcmp (ao->op, "b") || !strcmp (ao->op, "b.n")) {
ao->o = 0xe0;
ao->o |= getnum (ao->a0)<<8;
ao->o |= getnum (ao->a[0])<<8;
} else
if (!strcmp (ao->op, "bx")) {
ao->o = 0x47;
ao->o |= getreg (ao->a0)<<11;
ao->o |= getreg (ao->a[0])<<11;
} else
if (!strcmp (ao->op, "bl")) {
ao->o = 0x47;
ao->o |= getnum (ao->a0)<<8;
ao->o |= getnum (ao->a[0])<<8;
// XXX: length = 4
} else
if (*ao->op == 'b') { // conditional branch
ao->o = 0xd0 | arm_opcode_cond (ao, 1);
ao->o |= getnum (ao->a0)<<8;
ao->o |= getnum (ao->a[0])<<8;
} else
if (!strcmp (ao->op, "mov")) {
int reg = getreg (ao->a1);
int reg = getreg (ao->a[1]);
if (reg!=-1) {
ao->o = 0x46;
ao->o |= (getreg (ao->a0))<<8;
ao->o |= (getreg (ao->a[0]))<<8;
ao->o |= reg<<11;
} else {
ao->o = 0x20;
ao->o |= (getreg (ao->a0));
ao->o |= (getnum (ao->a1)&0xff)<<8;
ao->o |= (getreg (ao->a[0]));
ao->o |= (getnum (ao->a[1])&0xff)<<8;
}
} else
if (!memcmp (ao->op, "ldr", 3)) {
getrange (ao->a1);
getrange (ao->a2);
getrange (ao->a[1]);
getrange (ao->a[2]);
if (ao->op[3]=='h') {
int a0 = getreg (ao->a0);
int a1 = getreg (ao->a1);
int a2 = getreg (ao->a2);
int a0 = getreg (ao->a[0]);
int a1 = getreg (ao->a[1]);
int a2 = getreg (ao->a[2]);
if (a2 ==-1) {
a2 = getnum (ao->a2)/8;
a2 = getnum (ao->a[2])/8;
ao->o = 0x88; // | (8+(0xf & a0));
ao->o |= (7&a0)<<8;
ao->o |= (7&a1)<<11;
@ -277,36 +277,36 @@ static int thumb_assemble(ArmOpcode *ao, const char *str) {
} else return 0;
} else
if (ao->op[3]=='b') {
int a0 = getreg (ao->a0);
int a1 = getreg (ao->a1);
int a2 = getreg (ao->a2);
int a0 = getreg (ao->a[0]);
int a1 = getreg (ao->a[1]);
int a2 = getreg (ao->a[2]);
if (a2 ==-1) {
a2 = getnum (ao->a2)/8;
a2 = getnum (ao->a[2])/8;
ao->o = 0x78; // | (8+(0xf & a0));
ao->o |= (7&a0)<<8;
ao->o |= (7&a1)<<11;
ao->o |= (7&a2);
} else return 0;
} else {
if (!strcmp (ao->a1, "sp")) {
if (!strcmp (ao->a[1], "sp")) {
// ldr r0, [sp, n] = a[r0-7][nn]
if (getreg (ao->a2) == -1) {
if (getreg (ao->a[2]) == -1) {
// ldr r0, [sp, n]
ao->o = 0x98 + (0xf & getreg (ao->a0));
ao->o |= (0xff & getnum (ao->a2)/4)<<8;
ao->o = 0x98 + (0xf & getreg (ao->a[0]));
ao->o |= (0xff & getnum (ao->a[2])/4)<<8;
} else return 0;
} else
if (!strcmp (ao->a1, "pc")) {
if (!strcmp (ao->a[1], "pc")) {
// ldr r0, [pc, n] = 4[r0-8][nn*4]
if (getreg (ao->a2) == -1) {
ao->o = 0x40 | (8+(0xf & getreg (ao->a0)));
ao->o |= (0xff & getnum (ao->a2)/4)<<8;
if (getreg (ao->a[2]) == -1) {
ao->o = 0x40 | (8+(0xf & getreg (ao->a[0])));
ao->o |= (0xff & getnum (ao->a[2])/4)<<8;
} else return 0;
} else {
// ldr r0, [rN, rN] = 58[7bits:basereg + 7bits:destreg]
int a0 = getreg (ao->a0);
int a1 = getreg (ao->a1);
int a2 = getreg (ao->a2);
int a0 = getreg (ao->a[0]);
int a1 = getreg (ao->a[1]);
int a2 = getreg (ao->a[2]);
ao->o = 0x58; // | (8+(0xf & a0));
ao->o |= (7&a0)<<8;
ao->o |= (7&a1)<<11;
@ -315,14 +315,14 @@ static int thumb_assemble(ArmOpcode *ao, const char *str) {
}
} else
if (!memcmp (ao->op, "str", 3)) {
getrange (ao->a1);
getrange (ao->a2);
getrange (ao->a[1]);
getrange (ao->a[2]);
if (ao->op[3]=='h') {
int a0 = getreg (ao->a0);
int a1 = getreg (ao->a1);
int a2 = getreg (ao->a2);
int a0 = getreg (ao->a[0]);
int a1 = getreg (ao->a[1]);
int a2 = getreg (ao->a[2]);
if (a2 ==-1) {
a2 = getnum (ao->a2);
a2 = getnum (ao->a[2]);
ao->o = 0x80; // | (8+(0xf & a0));
ao->o |= (7&a0)<<8;
ao->o |= (7&a1)<<11;
@ -330,37 +330,37 @@ static int thumb_assemble(ArmOpcode *ao, const char *str) {
} else return 0;
} else
if (ao->op[3]=='b') {
int a0 = getreg (ao->a0);
int a1 = getreg (ao->a1);
int a2 = getreg (ao->a2);
int a0 = getreg (ao->a[0]);
int a1 = getreg (ao->a[1]);
int a2 = getreg (ao->a[2]);
if (a2 ==-1) {
a2 = getnum (ao->a2);
a2 = getnum (ao->a[2]);
ao->o = 0x70; // | (8+(0xf & a0));
ao->o |= (7&a0)<<8;
ao->o |= (7&a1)<<11;
ao->o |= (7&a2);
} else return 0;
} else {
if (!strcmp (ao->a1, "sp")) {
if (!strcmp (ao->a[1], "sp")) {
// ldr r0, [sp, n] = a[r0-7][nn]
if (getreg (ao->a2) == -1) {
int ret = getnum (ao->a2);
if (getreg (ao->a[2]) == -1) {
int ret = getnum (ao->a[2]);
if (ret%4) {
fprintf (stderr, "ldr index must be aligned to 4");
return 0;
}
ao->o = 0x90 + (0xf & getreg (ao->a0));
ao->o |= (0xff & getnum (ao->a2)/4)<<8;
ao->o = 0x90 + (0xf & getreg (ao->a[0]));
ao->o |= (0xff & getnum (ao->a[2])/4)<<8;
} else return 0;
} else
if (!strcmp (ao->a1, "pc")) {
if (!strcmp (ao->a[1], "pc")) {
return 0;
} else {
int a0 = getreg (ao->a0);
int a1 = getreg (ao->a1);
int a2 = getreg (ao->a2);
int a0 = getreg (ao->a[0]);
int a1 = getreg (ao->a[1]);
int a2 = getreg (ao->a[2]);
if (a2 == -1) {
a2 = getnum (ao->a2);
a2 = getnum (ao->a[2]);
ao->o = 0x60;
ao->o |= (7&a0)<<8;
ao->o |= (7&a1)<<11;
@ -376,48 +376,48 @@ static int thumb_assemble(ArmOpcode *ao, const char *str) {
} else
if (!strcmp (ao->op, "tst")) {
ao->o = 0x42;
ao->o |= (getreg (ao->a0))<<8;
ao->o |= getreg (ao->a1)<<11;
ao->o |= (getreg (ao->a[0]))<<8;
ao->o |= getreg (ao->a[1])<<11;
} else
if (!strcmp (ao->op, "cmp")) {
int reg = getreg (ao->a1);
int reg = getreg (ao->a[1]);
if (reg!=-1) {
ao->o = 0x45;
ao->o |= (getreg (ao->a0))<<8;
ao->o |= (getreg (ao->a[0]))<<8;
ao->o |= reg<<11;
} else {
ao->o = 0x20;
ao->o |= 8+(getreg (ao->a0));
ao->o |= (getnum (ao->a1)&0xff)<<8;
ao->o |= 8+(getreg (ao->a[0]));
ao->o |= (getnum (ao->a[1])&0xff)<<8;
}
} else
if (!strcmp (ao->op, "add")) {
// XXX: signed unsigned ??
// add r, r = 44[7bits,7bits]
// adds r, n = 3[r0-7][nn]
int reg = getreg (ao->a1);
int reg = getreg (ao->a[1]);
if (reg!=-1) {
ao->o = 0x44;
ao->o |= (getreg (ao->a0))<<8;
ao->o |= (getreg (ao->a[0]))<<8;
ao->o |= reg<<11;
} else {
ao->o = 0x30;
ao->o |= (getreg (ao->a0));
ao->o |= (getnum (ao->a1)&0xff)<<8;
ao->o |= (getreg (ao->a[0]));
ao->o |= (getnum (ao->a[1])&0xff)<<8;
}
} else
if (!strcmp (ao->op, "sub")) {
int reg = getreg (ao->a1);
int reg = getreg (ao->a[1]);
if (reg!=-1) {
int n = getnum (ao->a2); // TODO: add limit
int n = getnum (ao->a[2]); // TODO: add limit
ao->o = 0x1e;
ao->o |= (getreg (ao->a0))<<8;
ao->o |= (getreg (ao->a[0]))<<8;
ao->o |= reg<<11;
ao->o |= n/4 | ((n%4)<<14);
} else {
ao->o = 0x30;
ao->o |= 8+(getreg (ao->a0));
ao->o |= (getnum (ao->a1)&0xff)<<8;
ao->o |= 8+(getreg (ao->a[0]));
ao->o |= (getnum (ao->a[1])&0xff)<<8;
}
} else return 0;
return 1;
@ -429,48 +429,44 @@ static int arm_assemble(ArmOpcode *ao, const char *str) {
if (!memcmp(ao->op, ops[i].name, strlen (ops[i].name))) {
ao->o = ops[i].code;
arm_opcode_cond (ao, strlen(ops[i].name));
if (ao->a0)
if (ao->a[0])
switch (ops[i].type) {
case TYPE_MEM:
getrange (ao->a0);
getrange (ao->a1);
getrange (ao->a2);
//printf("a0(%s) a1(%s) a2(%s)\n", ao->a0, ao->a1, ao->a2);
ao->o |= getreg (ao->a0)<<20;
ao->o |= getreg (ao->a1)<<8; // delta
ret = getreg (ao->a2);
getrange (ao->a[0]);
getrange (ao->a[1]);
getrange (ao->a[2]);
ao->o |= getreg (ao->a[0])<<20;
ao->o |= getreg (ao->a[1])<<8; // delta
ret = getreg (ao->a[2]);
if (ret != -1) {
ao->o |= (strstr (str,"],"))?6:7;
ao->o |= (ret&0x0f)<<24;//(getreg(ao->a2)&0x0f);
ao->o |= (ret&0x0f)<<24;//(getreg(ao->a[2])&0x0f);
} else {
ao->o |= (strstr (str,"],"))?4:5;
ao->o |= (getnum (ao->a2)&0x7f)<<24; // delta
ao->o |= (getnum (ao->a[2])&0x7f)<<24; // delta
}
break;
case TYPE_IMM:
if (*ao->a0=='{') {
int reg, regmask, reg2;
getrange (ao->a0+1); // XXX filter regname string
reg = getreg (ao->a0+1);
regmask = (reg>7)? 1<<(reg-8): 1<<(reg+8);
if (reg>=0 && reg<=0xf)
ao->o |= regmask<<16;
if (ao->a1 && *ao->a1) {
getrange (ao->a1);
reg2 = getreg (ao->a1);
if (reg2 != -1)
ao->o |= (reg2-reg+1)<<20;
if (*ao->a[0]++=='{') {
int j, reg;
for (j=0; j<16; j++) {
if (ao->a[j] && *ao->a[j]) {
getrange (ao->a[j]); // XXX filter regname string
reg = getreg (ao->a[j]);
if (reg != -1) {
if (reg<8)
ao->o |= 1<<(24+reg);
else
ao->o |= 1<<(8+reg);
}
}
}
if (ao->a2)
fprintf (stderr, "XXX: push/pop with more than 2 regs is broken\n");
// char *r1 = getrange (ao->a0+1); // XXX: its a bitmask?
//if (r1) ao->o |= getreg(r1)<<24;
} else ao->o |= getnum(ao->a0)<<24; // ???
} else ao->o |= getnum(ao->a[0])<<24; // ???
break;
case TYPE_BRA:
if ((ret = getreg(ao->a0)) == -1) {
if ((ret = getreg(ao->a[0])) == -1) {
// TODO: control if branch out of range
ret = (getnum(ao->a0)-ao->off-8)/4;
ret = (getnum(ao->a[0])-ao->off-8)/4;
ao->o |= ((ret>>8)&0xff)<<16;
ao->o |= ((ret)&0xff)<<24;
} else {
@ -479,37 +475,37 @@ static int arm_assemble(ArmOpcode *ao, const char *str) {
}
break;
case TYPE_BRR:
if ((ret = getreg(ao->a0)) == -1) {
if ((ret = getreg(ao->a[0])) == -1) {
printf("This branch does not accept off as arg\n");
return 0;
} else ao->o |= (getreg (ao->a0)<<24);
} else ao->o |= (getreg (ao->a[0])<<24);
break;
case TYPE_SWI:
ao->o |= (getnum (ao->a0)&0xff)<<24;
ao->o |= ((getnum (ao->a0)>>8)&0xff)<<16;
ao->o |= ((getnum (ao->a0)>>16)&0xff)<<8;
ao->o |= (getnum (ao->a[0])&0xff)<<24;
ao->o |= ((getnum (ao->a[0])>>8)&0xff)<<16;
ao->o |= ((getnum (ao->a[0])>>16)&0xff)<<8;
break;
case TYPE_ARI:
if (!ao->a2) {
ao->a2 = ao->a1;
ao->a1 = ao->a0;
if (!ao->a[2]) {
ao->a[2] = ao->a[1];
ao->a[1] = ao->a[0];
}
ao->o |= getreg (ao->a0)<<20;
ao->o |= getreg (ao->a1)<<8;
ret = getreg (ao->a2);
ao->o |= (ret!=-1)? ret<<24 : 2 | getnum(ao->a2)<<24;
ao->o |= getreg (ao->a[0])<<20;
ao->o |= getreg (ao->a[1])<<8;
ret = getreg (ao->a[2]);
ao->o |= (ret!=-1)? ret<<24 : 2 | getnum(ao->a[2])<<24;
break;
case TYPE_MOV:
ao->o |= getreg (ao->a0)<<20;
ret = getreg (ao->a1);
ao->o |= getreg (ao->a[0])<<20;
ret = getreg (ao->a[1]);
if (ret!=-1) ao->o |= ret<<24;
else ao->o |= 0xa003 | getnum (ao->a1)<<24;
else ao->o |= 0xa003 | getnum (ao->a[1])<<24;
break;
case TYPE_TST:
//ao->o |= getreg(ao->a0)<<20; // ???
ao->o |= getreg (ao->a0)<<8;
ao->o |= getreg (ao->a1)<<24;
ao->o |= getshift (ao->a2)<<16; // shift
//ao->o |= getreg(ao->a[0])<<20; // ???
ao->o |= getreg (ao->a[0])<<8;
ao->o |= getreg (ao->a[1])<<24;
ao->o |= getshift (ao->a[2])<<16; // shift
break;
}
return 1;
@ -529,7 +525,6 @@ int armass_assemble(const char *str, unsigned long off, int thumb) {
printf ("armass: Unknown opcode (%s)\n", str);
return -1;
}
////printf ("PARSE (%s) (%s)(%s)(%s)\n", aop.op, aop.a0, aop.a1, aop.a2);
return aop.o;
}

View File

@ -43,7 +43,7 @@ static const char *r_cons_color_names[CONS_COLORS_SIZE+1] = {
R_API void r_cons_invert(int set, int color) {
if (color) {
if (set) r_cons_strcat("\x1b[7m");
else r_cons_strcat("\x1b[0m");
else r_cons_strcat("\x1b[27m");
} else {
if (set) r_cons_strcat("[");
else r_cons_strcat("]");

View File

@ -40,7 +40,7 @@ R_API int r_cons_w32_print(ut8 *ptr) {
} else
if (ptr[0]=='0'&&ptr[1]==';'&&ptr[2]=='0') {
ptr = ptr + 4;
r_cons_gotoxy(0,0);
r_cons_gotoxy (0,0);
esc = 0;
str = ptr;
continue;

View File

@ -1593,8 +1593,6 @@ static int cmd_flag(void *data, const char *input) {
int len = strlen (input)+1;
char *str = alloca (len);
ut64 off = core->offset;
if (core->print->cur_enabled)
off += core->print->cur;
memcpy (str, input+1, len);
switch (input[0]) {

View File

@ -230,11 +230,17 @@ static int config_asmarch_callback(void *user, void *data) {
if (!r_syscall_setup (core->syscall, node->value,
r_config_get (core->config, "asm.os")))
eprintf ("asm.arch: Cannot setup syscall os/arch for '%s'\n", node->value);
return R_TRUE;
}
static int config_vmarch_callback(void *user, void *data) {
RCore *core = (RCore *) user;
RConfigNode *node = (RConfigNode *) data;
r_vm_set_arch (core->vm, node->value, core->assembler->bits);
return R_TRUE;
}
static int config_asm_parser_callback(void *user, void *data) {
static int config_asmparser_callback(void *user, void *data) {
RCore *core = (RCore*) user;
RConfigNode *node = (RConfigNode*) data;
// XXX this is wrong? snprintf(buf, 127, "parse_%s", node->value),
@ -243,7 +249,7 @@ static int config_asm_parser_callback(void *user, void *data) {
return R_TRUE;
}
static int config_asm_bits_callback(void *user, void *data) {
static int config_asmbits_callback(void *user, void *data) {
RCore *core = (RCore *) user;
RConfigNode *node = (RConfigNode *) data;
int ret = r_asm_set_bits (core->assembler, node->i_value);
@ -283,7 +289,7 @@ R_API int r_core_config_init(RCore *core) {
// XXX: not portable
r_parse_use (core->parser, "x86.pseudo");
r_config_set_cb (cfg, "asm.parser", "x86.pseudo",
&config_asm_parser_callback);
&config_asmparser_callback);
r_config_set (cfg, "dir.plugins", LIBDIR"/radare2/");
/* anal */
@ -293,7 +299,7 @@ R_API int r_core_config_init(RCore *core) {
r_config_set_cb (cfg, "anal.plugin", "x86", &config_analplugin_callback);
/* asm */
r_config_set_i_cb (cfg, "asm.bits", 32,
&config_asm_bits_callback);
&config_asmbits_callback);
r_config_set (cfg, "asm.bytes", "true");
r_config_set (cfg, "asm.middle", "false"); // jump in the middle because of antidisasm tricks
r_config_set (cfg, "asm.comments", "true");
@ -356,6 +362,8 @@ R_API int r_core_config_init(RCore *core) {
r_config_set (cfg, "file.sha1", "");
r_config_set (cfg, "file.type", "");
r_config_set (cfg, "rap.loop", "true");
/* vm */
r_config_set_cb (cfg, "vm.arch", "x86", &config_vmarch_callback);
/* TODO cmd */
#if 0

View File

@ -16,7 +16,12 @@ static ut64 num_callback(RNum *userptr, const char *str, int *ok) {
/* analyze opcode */
switch (str[1]) {
case '$':
return (str[2]=='$')? aop.length:core->offset;
if (str[2]=='$') {
r_anal_aop (core->anal, &aop, core->offset,
core->block, core->blocksize);
return aop.length;
}
return core->offset;
case 'e':
case 'j':
case 'f':

View File

@ -65,10 +65,10 @@ R_API int r_core_bin_load(RCore *r, const char *file) {
r_config_set (r->config, "asm.dwarf", R_BIN_DBG_STRIPPED (info->dbg_info)?"false":"true");
}
r_flag_space_set (r->flags, "symbols");
// M -> Main
RBinAddr *binmain;
r_flag_space_set (r->flags, "symbols");
if ((binmain = r_bin_get_main (r->bin)) != NULL)
r_flag_set (r->flags, "main", va?baddr+binmain->rva:binmain->offset,
r->blocksize, 0);
@ -130,7 +130,7 @@ R_API int r_core_bin_load(RCore *r, const char *file) {
r_meta_add (r->meta, R_META_STRING, va?baddr+string->rva:string->offset,
(va?baddr+string->rva:string->offset)+string->size, string->string+i);
r_flag_name_filter (string->string);
snprintf (str, R_FLAG_NAME_SIZE, "str.%s", string->string+i);
snprintf (str, R_FLAG_NAME_SIZE, "str.%s", string->string);
r_flag_set (r->flags, str, va?baddr+string->rva:string->offset,
string->size, 0);
}

View File

@ -1,6 +1,7 @@
/* radare - LGPL - Copyright 2009 pancake<nopcode.org> */
/* radare - LGPL - Copyright 2009-2010 pancake<nopcode.org> */
#include <r_flags.h>
#include <r_util.h>
#define IS_PRINTABLE(x) (x>=' '&&x<='~')
@ -50,8 +51,7 @@ R_API int r_flag_name_check(const char *name) {
R_API int r_flag_name_filter(char *name) {
int i;
char *oname;
for(;*name==' ';name=name+1);
oname=name;
name = oname = r_str_trim (name);
for (i=0;*name!='\0'; name = name +1,i++) {
if (i>R_FLAG_NAME_SIZE) {
name[0] = '\0';

View File

@ -77,15 +77,15 @@ R_API void r_print_addr(RPrint *p, ut64 addr) {
R_API char *r_print_hexpair(RPrint *p, const char *str, int n) {
const char *s;
char *d, *dst = (char *)malloc ((strlen (str)+2)*6);
int ch, i = 0;
int ch, i;
/* XXX That's hacky as shit.. but partially works O:) */
/* TODO: Use r_print_set_cursor for win support */
int cur = R_MIN (p->cur, p->ocur);
int ocur = R_MAX (p->cur, p->ocur);
if (p->cur_enabled && cur==-1) {
if (p->cur_enabled && cur==-1)
cur = ocur;
ocur++;
}
ocur++;
#if CURDBG
sprintf(dst, "(%d/%d/%d/%d)", p->cur_enabled, cur, ocur, n);
d = dst+ strlen(dst);
@ -95,13 +95,13 @@ d = dst;
// XXX: overflow here
#define memcat(x,y) { memcpy(x,y,strlen(y));x+=strlen(y); }
//for (s=str, d=dst; *s; s+=2, d+=2, i++) {
for (s=str ; *s; s+=2, d+=2, i++) {
for (s=str, i=0 ; *s; s+=2, d+=2, i++) {
if (p->cur_enabled) {
if (i-1==(cur-n))
memcat (d, "\x1b[0m");
if (i>=(cur-n) && i<(ocur-n))
if (i==ocur-n)
memcat (d, "\x1b[27m");
if (i>=cur-n && i<ocur-n)
memcat (d, "\x1b[7m");
} else
}
if (s[0]=='0' && s[1]=='0') {
memcat (d, "\x1b[31m");
} else

View File

@ -248,19 +248,16 @@ R_API int r_sys_rmkdir(const char *dir) {
// XXX: Wrong for w32 (/).. and no errno ?
while ((ptr = strchr (ptr, '/'))) {
*ptr = 0;
if (!r_sys_mkdir (path)) {
if (r_sys_mkdir_failed ()) {
eprintf ("r_sys_rmkdir: fail %s\n", dir);
free (path);
return R_FALSE;
}
if (!r_sys_mkdir (path) && r_sys_mkdir_failed ()) {
eprintf ("r_sys_rmkdir: fail %s\n", dir);
free (path);
return R_FALSE;
}
*ptr = '/';
ptr++;
}
ret = r_sys_mkdir (path);
if (r_sys_mkdir_failed ())
ret = R_TRUE;
if (!r_sys_mkdir (path) && r_sys_mkdir_failed ())
ret = R_FALSE;
free (path);
return ret;
}