Fixes in analysis, add 'R' in visual to randomize colors

This commit is contained in:
pancake 2013-09-30 04:23:58 +02:00
parent 1f4c8aee8d
commit ab654dea32
5 changed files with 51 additions and 7 deletions

View File

@ -65,6 +65,8 @@ R_API int r_anal_bb(RAnal *anal, RAnalBlock *bb, ut64 addr, ut8 *buf, ut64 len,
}
break;
}
if (oplen<1)
return R_ANAL_RET_END;
idx += oplen;
bb->size += oplen;
bb->ninstr++;

View File

@ -331,6 +331,14 @@ if (
}
static ut64 getaddr (ut64 addr, ut8 *d) {
if (d[2]>>7) {
st32 n = (d[0] + (d[1]<<8) + (d[2]<<16) + (0xff<<24));
n = -n;
return addr - (n*4);
}
return addr + (4*(d[0] + (d[1]<<8) + (d[2]<<16)));
}
static int arm_op64(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *d, int len) {
memset (op, 0, sizeof (RAnalOp));
if (d[3]==0) return -1; // invalid
@ -341,25 +349,25 @@ static int arm_op64(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *d, int len)
op->type = R_ANAL_OP_TYPE_RET;
}
switch (d[3]) {
case 0x71:
case 0xeb:
op->type = R_ANAL_OP_TYPE_CMP;
break;
case 0xb8:
case 0xb9:
case 0xf8:
case 0xa9: // ldp/stp
case 0xf9: // ldr/str
op->type = R_ANAL_OP_TYPE_LOAD;
break;
case 0x91: // mov
case 0x52: // mov
op->type = R_ANAL_OP_TYPE_MOV;
break;
case 0x94: // bl A
case 0x97: // bl A
op->type = R_ANAL_OP_TYPE_CALL;
if (d[2]>>7) {
st32 n = (d[0] + (d[1]<<8) + (d[2]<<16) + (0xff<<24));
n = -n;
op->jump = addr - (n*4);
} else op->jump = addr + (4*(d[0] + (d[1]<<8) + (d[2]<<16)));
op->jump = getaddr (addr, d);
op->fail = addr+4;
break;
case 0x54: // beq A
@ -367,9 +375,10 @@ static int arm_op64(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *d, int len)
op->jump = addr + (4*((d[0]>>4) | (d[1]<<8) | (d[2]<<16)));
op->fail = addr+4;
break;
case 0x17: // b A
case 0x14: // b A
op->type = R_ANAL_OP_TYPE_JMP;
op->jump = addr + (4*(d[0] | (d[1]<<8) | (d[2]<<16)));
op->jump = getaddr (addr, d);
op->fail = addr+4;
break;
}

28
libr/cons/d/lima Normal file
View File

@ -0,0 +1,28 @@
ec comment rgb:255
ec fname rgb:27a
ec fline rgb:5aa
ec flag rgb:252
ec label rgb:d5d
ec flow rgb:25d
ec prompt rgb:d7a
ec offset rgb:272
ec input rgb:7d5
ec other rgb:aad
ec b0x00 rgb:ddd
ec b0x7f rgb:ada
ec b0xff rgb:f72
ec math rgb:5af
ec bin rgb:7da
ec btext rgb:72f
ec push rgb:5ad
ec pop rgb:25d
ec jmp rgb:ad7
ec cjmp rgb:aaf
ec call rgb:25d
ec nop rgb:2da
ec ret rgb:5d5
ec trap rgb:a7a
ec swi rgb:dd5
ec cmp rgb:f55
ec reg rgb:af2
ec num rgb:ddf

View File

@ -298,7 +298,8 @@ R_API int r_core_anal_fcn(RCore *core, ut64 at, ut64 from, int reftype, int dept
if (from != UT64_MAX && at == 0)
return R_FALSE;
if ((at>>63) == 1 || at == UT64_MAX || depth < 0)
//if ((at>>63) == 1 || at == UT64_MAX || depth < 0)
if (at == UT64_MAX || depth < 0)
return R_FALSE;
#warning This must be optimized to use the fcnstore api
r_list_foreach (core->anal->fcns, iter, fcni) {

View File

@ -342,6 +342,9 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
r_cons_set_raw (1);
r_cons_show_cursor (R_FALSE);
break;
case 'R':
r_core_cmd0 (core, "ecr");
break;
case 'e':
r_core_visual_config (core);
break;
@ -777,6 +780,7 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
" _ enter the hud\n"
" . seek to program counter\n"
" / in cursor mode search in current block\n"
" R randomize color palette (ecr)\n"
" :cmd run radare command\n"
" ;[-]cmt add/remove comment\n"
" /*+-[] change block size, [] = resize hex.cols\n"