Rename {RAsmRAnal}Op inst_len and length to size

This commit is contained in:
pancake 2013-12-06 05:04:17 +01:00
parent b71bf37622
commit 230efd1f05
52 changed files with 145 additions and 146 deletions

View File

@ -6,6 +6,7 @@
0.9.8
=====
* Rename anal.plugin into anal.arch ??? to keep in sync with asm.arch
* use __unused if available
* rafind2 : add support for unicode/widestring search
* .dr- # documented... but not working

View File

@ -111,9 +111,9 @@ R_API int r_anal_bb(RAnal *anal, RAnalBlock *bb, ut64 addr, ut8 *buf, ut64 len,
if (dst && dst->reg && !strcmp (src->reg->name, pc)) {
int memref = anal->bits/8;
ut8 b[8];
ut64 ptr = idx+addr+src->delta; //+op->length;
ut64 ptr = idx+addr+src->delta;
anal->iob.read_at (anal->iob.io, ptr, b, memref);
r_anal_ref_add (anal, ptr, addr+idx-op->length, 'd');
r_anal_ref_add (anal, ptr, addr+idx-op->size, 'd');
}
}
}

View File

@ -45,7 +45,7 @@ static int i8051_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len
op->jump = o.addr;
op->fail = addr+o.length;
}
return op->length = o.length;
return op->size = o.length;
}
struct r_anal_plugin_t r_anal_plugin_8051 = {

View File

@ -17,11 +17,11 @@ static int arcompact_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, in
highbyte = anal->big_endian? 1: 0;
if (((b[lowbyte]&0xf8) >0x38) && ((b[lowbyte]&0xf8) != 0x48)) {
op->length = 2;
op->size = 2;
} else {
op->length = 4;
op->size = 4;
}
// some ops are 6 and others are 8 byte length
// some ops are 6 and others are 8 byte size
op->fail = addr + 4;
//eprintf ("----> ST %x\n", subopcode);
//eprintf ("BC = 0x%x\n", basecode);
@ -60,7 +60,7 @@ static int arcompact_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, in
break;
default:
/* This is 16 bit instruction */
op->length = 2;
op->size = 2;
op->fail = addr + 2;
basecode = (b[1] & 0xf8) >> 3;
switch (basecode) {
@ -91,7 +91,7 @@ static int arcompact_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, in
}
break;
}
return op->length;
return op->size;
}
static int arc_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len) {
@ -101,7 +101,7 @@ static int arc_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len)
/* ARCtangent A4 */
if (anal->bits == 16)
return arcompact_op (anal, op, addr, data, len);
op->length = 4;
op->size = 4;
op->fail = addr + 4;
ut8 basecode = (b[3] & 0xf8) >> 3;
switch (basecode) {
@ -143,7 +143,7 @@ static int arc_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len)
default:
break;
}
return op->length;
return op->size;
}
struct r_anal_plugin_t r_anal_plugin_arc = {

View File

@ -41,7 +41,7 @@ static int op_thumb(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int le
arm_set_thumb(arminsn, R_TRUE);
arm_set_input_buffer(arminsn, data);
arm_set_pc(arminsn, addr);
op->length = arm_disasm_one_insn(arminsn);
op->size = arm_disasm_one_insn(arminsn);
op->jump = arminsn->jmp;
op->fail = arminsn->fail;
arm_free(arminsn);
@ -52,20 +52,20 @@ static int op_thumb(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int le
if (((ins & B4(B1110,0,0,0)) == B4(B0010,0,0,0) )
&& (1 == (ins & B4(1,B1000,0,0)) >> 11)) { // dp3
op->type = R_ANAL_OP_TYPE_CMP;
return op->length;
return op->size;
}
if ( (ins & B4(B1111,B1100,0,0)) == B4(B0100,0,0,0) ) {
op_code = (ins & B4(0,B0011,B1100,0)) >> 6;
if (op_code == 8 || op_code == 10) { // dp5
op->type = R_ANAL_OP_TYPE_CMP;
return op->length;
return op->size;
}
}
if ( (ins & B4(B1111,B1100,0,0)) == B4(B0100,B0100,0,0) ) {
op_code = (ins & B4(0,B0011,0,0)) >> 8; // dp8
if (op_code== 1) {
op->type = R_ANAL_OP_TYPE_CMP;
return op->length;
return op->size;
}
}
if (ins == 0xbf) {
@ -121,7 +121,7 @@ static int op_thumb(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int le
op->type = R_ANAL_OP_TYPE_SWI;
op->val = (ut64)(ins>>8);
}
return op->length;
return op->size;
}
#if 0
@ -184,7 +184,7 @@ static int arm_op32(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int le
#endif
if (anal->bits==16)
return op_thumb (anal, op, addr, data, len);
op->length = 4;
op->size = 4;
#if 0
fprintf(stderr, "CODE %02x %02x %02x %02x\n",
codeA[0], codeA[1], codeA[2], codeA[3]);
@ -348,7 +348,7 @@ if (
//op->jump = arminsn->jmp;
//op->fail = arminsn->fail;
arm_free(arminsn);
return op->length;
return op->size;
}
@ -364,7 +364,7 @@ static ut64 getaddr (ut64 addr, const ut8 *d) {
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
op->length = 4;
op->size = 4;
op->type = R_ANAL_OP_TYPE_NULL;
if (d[0]==0xc0 && d[3]==0xd6) {
// defaults to x30 reg. but can be different
@ -402,7 +402,7 @@ static int arm_op64(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *d, int len)
op->fail = addr+4;
break;
}
return op->length;
return op->size;
}
static int arm_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len) {

View File

@ -14,7 +14,7 @@ static int avr_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len)
if (op == NULL)
return 2;
op->length = 2;
op->size = 2;
if (*ins == 0) {
op->type = R_ANAL_OP_TYPE_NOP;
} else
@ -67,7 +67,7 @@ static int avr_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len)
op->eob = R_TRUE;
//op->stackptr =
} else op->type = R_ANAL_OP_TYPE_UNK;
return op->length;
return op->size;
}
RAnalPlugin r_anal_plugin_avr = {

View File

@ -10,7 +10,7 @@ static int bf_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
if (op == NULL)
return 1;
memset (op, 0, sizeof (RAnalOp));
op->length = 1;
op->size = 1;
op->esil[0] = 0;
switch (buf[0]) {
case '[': op->type = R_ANAL_OP_TYPE_CMP; break;
@ -36,7 +36,7 @@ static int bf_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
op->type = R_ANAL_OP_TYPE_TRAP; break;
default: op->type = R_ANAL_OP_TYPE_NOP; break;
}
return op->length;
return op->size;
}
struct r_anal_plugin_t r_anal_plugin_bf = {

View File

@ -24,7 +24,7 @@ static int c55plus_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int l
op->addr = addr;
op->jump = op->fail = -1;
op->ptr = op->val = -1;
op->length = ins_len;
op->size = ins_len;
if (ins_len >= 1 && *ins == 0x20) {
op->type = R_ANAL_OP_TYPE_NOP;
@ -75,7 +75,7 @@ static int c55plus_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int l
op->type = R_ANAL_OP_TYPE_UNK;
}
return op->length;
return op->size;
}
struct r_anal_plugin_t r_anal_plugin_c55plus = {

View File

@ -73,7 +73,7 @@ static int csr_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *bytes, int len
memset (op, 0, sizeof (RAnalOp));
op->type = R_ANAL_OP_TYPE_UNK;
op->length = 2;
op->size = 2;
switch (i2ut16 (in)) {
case INST_NOP:
@ -212,7 +212,7 @@ static int csr_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *bytes, int len
}
break;
}
return op->length;
return op->size;
}
struct r_anal_plugin_t r_anal_plugin_csr = {

View File

@ -16,7 +16,7 @@ static int dalvik_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int l
memset (op, '\0', sizeof (RAnalOp));
op->type = R_ANAL_OP_TYPE_UNK;
op->length = sz;
op->size = sz;
op->nopcode = 1; // Necesary??
switch(data[0]) {

View File

@ -17,7 +17,7 @@ static int ebc_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len)
if (op == NULL)
return 2;
ret = op->length = ebc_decode_command(buf, &cmd);
ret = op->size = ebc_decode_command(buf, &cmd);
if (ret < 0)
return ret;

View File

@ -143,7 +143,7 @@ static int i8080_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int le
op->type = R_ANAL_OP_TYPE_CALL;
break;
}
return op->length = ilen;
return op->size = ilen;
}
struct r_anal_plugin_t r_anal_plugin_i8080 = {

View File

@ -40,7 +40,7 @@ static int java_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len
memset (op, '\0', sizeof (RAnalOp));
op->type = R_ANAL_OP_TYPE_UNK;
op->length = sz;
op->size= sz;
switch (data[0]) {
case 0xa9: // ret

View File

@ -9,7 +9,7 @@
static int m68k_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len) {
if (op == NULL)
return 4;
op->length = 4;
op->size = 4;
switch(b[0] &0xf0) {
case 0xb0:
op->type = R_ANAL_OP_TYPE_CMP;
@ -44,7 +44,7 @@ static int m68k_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len) {
op->type = R_ANAL_OP_TYPE_UNK;
break;
}
return op->length;
return op->size;
}
struct r_anal_plugin_t r_anal_plugin_m68k = {

View File

@ -16,7 +16,7 @@ static int mips_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len) {
memset (op, 0, sizeof (RAnalOp));
op->type = R_ANAL_OP_TYPE_UNK;
op->length = oplen;
op->size = oplen;
op->delay = 4;
op->esil[0] = 0;
@ -347,7 +347,7 @@ static int mips_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len) {
mul.s fd, fs, ft 000010 10000
sub.s fd, fs, ft 000001 10000
#endif
return op->length;
return op->size;
}
struct r_anal_plugin_t r_anal_plugin_mips = {

View File

@ -23,7 +23,7 @@ static int ppc_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *_bytes, int le
memset (op, '\0', sizeof (RAnalOp));
op->addr = addr;
op->type = 0;
op->length = 4;
op->size = 4;
//eprintf("OPCODE IS %08x : %02x (opcode=%d) baddr = %d\n", addr, bytes[0], opcode, baddr);
@ -74,8 +74,8 @@ static int ppc_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *_bytes, int le
op->eob = 1;
break;
}
op->length = 4;
return op->length;
op->size = 4;
return op->size;
}
static int set_reg_profile(RAnal *anal) {

View File

@ -205,14 +205,14 @@ static int first_nibble_is_0(RAnal* anal, RAnalOp* op, ut16 code){
}
//TODO Check missing insns, specially STC might be interesting
return op->length;
return op->size;
}
static int movl_reg_rdisp(RAnal* anal, RAnalOp* op, ut16 code){
op->type = R_ANAL_OP_TYPE_MOV;
op->src[0] = anal_fill_ai_rg(anal,GET_SOURCE_REG(code));
op->dst = anal_fill_reg_disp_mem(anal,GET_TARGET_REG(code),code&0x0F,LONG_SIZE);
return op->length;
return op->size;
}
@ -246,7 +246,7 @@ static int first_nibble_is_2(RAnal* anal, RAnalOp* op, ut16 code){
}
//TODO Handle 'pushes' (mov Rm,@-Rn)
//TODO Handle CMP/STR ??
return op->length;
return op->size;
}
@ -261,7 +261,7 @@ static int first_nibble_is_3(RAnal* anal, RAnalOp* op, ut16 code){
op->src[0] = anal_fill_ai_rg(anal,GET_SOURCE_REG(code));
op->dst = anal_fill_ai_rg(anal,GET_TARGET_REG(code));
}
return op->length;
return op->size;
}
static int first_nibble_is_4(RAnal* anal, RAnalOp* op, ut16 code){
@ -276,14 +276,14 @@ static int first_nibble_is_4(RAnal* anal, RAnalOp* op, ut16 code){
op->eob = R_TRUE;
}
//TODO shifts + many system insns + CMP/P[L|Z]??
return op->length;
return op->size;
}
static int movl_rdisp_reg(RAnal* anal, RAnalOp* op, ut16 code){
op->type = R_ANAL_OP_TYPE_MOV;
op->dst = anal_fill_ai_rg(anal,GET_TARGET_REG(code));
op->src[0] = anal_fill_reg_disp_mem(anal,GET_SOURCE_REG(code),code&0x0F,LONG_SIZE);
return op->length;
return op->size;
}
@ -306,7 +306,7 @@ static int first_nibble_is_6(RAnal* anal, RAnalOp* op, ut16 code){
op->dst = anal_fill_ai_rg(anal,GET_TARGET_REG(code));
}
//TODO neg(c) + MOV.L @Rm+,Rn
return op->length;
return op->size;
}
@ -314,7 +314,7 @@ static int add_imm(RAnal* anal, RAnalOp* op, ut16 code){
op->type = R_ANAL_OP_TYPE_ADD;
op->src[0] = anal_fill_im(anal, (st8)(code&0xFF)); //Casting to (st8) forces sign-extension.
op->dst = anal_fill_ai_rg(anal,GET_TARGET_REG(code));
return op->length;
return op->size;
}
static int first_nibble_is_8(RAnal* anal, RAnalOp* op, ut16 code){
@ -335,14 +335,14 @@ static int first_nibble_is_8(RAnal* anal, RAnalOp* op, ut16 code){
op->src[0] = anal_fill_reg_disp_mem(anal,GET_SOURCE_REG(code),code&0x0F,WORD_SIZE);
}
//TODO some movs + CMP/EQ??
return op->length;
return op->size;
}
static int movw_pcdisp_reg(RAnal* anal, RAnalOp* op, ut16 code){
op->type = R_ANAL_OP_TYPE_MOV;
op->dst = anal_fill_ai_rg(anal, GET_TARGET_REG(code));
op->src[0] = anal_fill_reg_disp_mem(anal,PC_IDX,code&0xFF,WORD_SIZE);
return op->length;
return op->size;
}
static int bra(RAnal* anal, RAnalOp* op, ut16 code){
@ -351,7 +351,7 @@ static int bra(RAnal* anal, RAnalOp* op, ut16 code){
op->delay = 1;
op->jump = disarm_12bit_offset(op,GET_BRA_OFFSET(code));
op->eob = R_TRUE;
return op->length;
return op->size;
}
static int bsr(RAnal* anal, RAnalOp* op, ut16 code){
@ -359,7 +359,7 @@ static int bsr(RAnal* anal, RAnalOp* op, ut16 code){
op->type = R_ANAL_OP_TYPE_CALL;
op->jump = disarm_12bit_offset(op,GET_BRA_OFFSET(code));
op->delay = 1;
return op->length;
return op->size;
}
@ -385,27 +385,27 @@ static int first_nibble_is_c(RAnal* anal, RAnalOp* op, ut16 code){
op->dst = anal_fill_ai_rg(anal,0); //Always R0
}
//TODO Logic insns referencing GBR
return op->length;
return op->size;
}
static int movl_pcdisp_reg(RAnal* anal, RAnalOp* op, ut16 code){
op->type = R_ANAL_OP_TYPE_MOV;
op->src[0] = anal_pcrel_disp_mov(anal,op,code&0x0F);
op->dst = anal_fill_ai_rg(anal,GET_TARGET_REG(code));
return op->length;
return op->size;
}
static int mov_imm_reg(RAnal* anal, RAnalOp* op, ut16 code){
op->type = R_ANAL_OP_TYPE_MOV;
op->dst = anal_fill_ai_rg(anal,GET_TARGET_REG(code));
op->src[0] = anal_fill_im(anal,(st8)(code & 0xFF));
return op->length;
return op->size;
}
static int fpu_insn(RAnal* anal, RAnalOp* op, ut16 code){
//Not interested on FPU stuff for now
op->family = R_ANAL_OP_FAMILY_FPU;
return op->length;
return op->size;
}
/* Table of routines for further analysis based on 1st nibble */
@ -445,7 +445,7 @@ static int sh_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len)
op->jump = op->fail = -1;
op->ptr = op->val = -1;
op->length = 2;
op->size = 2;
ret = first_nibble_decode[(b>>4) & 0x0F](anal,op,code);
return ret;

View File

@ -450,7 +450,7 @@ static int sparc_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int le
memset (op, 0, sizeof (RAnalOp));
op->family = R_ANAL_OP_FAMILY_CPU;
op->addr = addr;
op->length = sz;
op->size = sz;
op->jump = op->fail = -1;
op->ptr = op->val = -1;

View File

@ -801,7 +801,7 @@ static int x86_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len)
if (!memcmp ("\xf3\xc3", data, 2)) {
op->type = R_ANAL_OP_TYPE_RET;
return op->length = 2;
return op->size = 2;
}
ret = -1;
if (anal->bits==64)
@ -924,10 +924,10 @@ static int x86_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len)
else
if (io.id == X86IM_IO_ID_LEAVE) /* leave */
op->type = R_ANAL_OP_TYPE_LEAVE;
op->length = io.len;
op->size = io.len;
op->nopcode = io.opcode_count;
}
return op->length;
return op->size;
}
static int set_reg_profile(RAnal *anal) {

View File

@ -98,7 +98,7 @@ static int myop(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
break;
case 0xf4: // hlt
op->type = R_ANAL_OP_TYPE_RET;
op->length = 1;
op->size = 1;
break;
case 0xc3: // ret
case 0xc2: // ret + 2 bytes
@ -163,7 +163,7 @@ static int myop(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
break;
case 0x90:
op->type = R_ANAL_OP_TYPE_NOP;
op->length = 1;
op->size = 1;
break;
case 0x0f: // 3 byte nop
//0fbe55ff movsx edx, byte [ebp-0x1]
@ -177,19 +177,19 @@ static int myop(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
} else
if (buf[1]>=0x18 && buf[1]<=0x1f) {
op->type = R_ANAL_OP_TYPE_NOP;
op->length = 3;
op->size = 3;
} else
if (buf[1]>=0x80 && buf[1]<=0x8f) {
op->type = R_ANAL_OP_TYPE_CJMP;
op->jump = addr+6+buf[2]+(buf[3]<<8)+(buf[4]<<16)+(buf[5]<<24);//((unsigned long)((buf+2))+6);
op->fail = addr+6;
op->length = 6;
op->size = 6;
//op->eob = 1;
} else
if (buf[1]>=0x40 && buf[1]<=0x4f) { /* Conditional MOV */
op->type = R_ANAL_OP_TYPE_MOV;
op->eob = 0;
op->length = 4;
op->size = 4;
return 4;
}
break;
@ -199,7 +199,7 @@ static int myop(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
op->type = R_ANAL_OP_TYPE_SWI;
break;
case 0xf1: // int1
op->length = 1;
op->size = 1;
op->val = 1;
op->type = R_ANAL_OP_TYPE_SWI;
break;
@ -214,13 +214,13 @@ static int myop(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
op->ptr = (st64)((int)buf[1]+(buf[2]<<8)+(buf[3]<<16)+(buf[4]<<24));//((unsigned long)((buf+2))+6);
break;
case 0xcd:
op->length = 2;
op->size = 2;
op->type = R_ANAL_OP_TYPE_SWI;
op->val = buf[1];
break;
case 0xe8: // call
op->type = R_ANAL_OP_TYPE_CALL;
op->length = 5;
op->size = 5;
//op->jump = addr+*ptr+5; //(unsigned long)((buf+1)+5);
op->jump = addr+5+buf[1]+(buf[2]<<8)+(buf[3]<<16)+(buf[4]<<24);//((unsigned long)((buf+2))+6);
op->fail = addr+5;
@ -229,7 +229,7 @@ static int myop(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
break;
case 0xe9: // jmp
op->type = R_ANAL_OP_TYPE_JMP;
op->length = 5;
op->size = 5;
//op->jump = (unsigned long)((buf+1)+5);
op->jump = addr+5+buf[1]+(buf[2]<<8)+(buf[3]<<16)+(buf[4]<<24);//((unsigned long)((buf+2))+6);
op->fail = 0L;
@ -237,7 +237,7 @@ static int myop(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
break;
case 0xeb: // short jmp
op->type = R_ANAL_OP_TYPE_JMP;
op->length = 2;
op->size = 2;
op->jump = addr+((unsigned long)((char)buf[1])+2);
op->fail = 0L;
op->eob = 1;
@ -245,7 +245,7 @@ static int myop(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
case 0xf2: // repnz
case 0xf3: // repz
op->type = R_ANAL_OP_TYPE_REP;
//op->length = dislen((unsigned char *)&buf); //instLength(buf, 16, 0);
//op->size = dislen((unsigned char *)&buf); //instLength(buf, 16, 0);
op->jump = 0L;
op->fail = 0L;
break;
@ -268,14 +268,14 @@ static int myop(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
} else
if (buf[1]>=0xd0 && buf[1]<=0xd7) {
op->type = R_ANAL_OP_TYPE_CALL;
op->length = 2;
op->size = 2;
op->eob = 1;
//op->jump = vm_arch_x86_regs[VM_X86_EAX+buf[1]-0xd0];
op->fail = addr+2;
} else
if (buf[1]>=0xe0 && buf[1]<=0xe7) {
op->type = R_ANAL_OP_TYPE_UJMP;
op->length = 2;
op->size = 2;
//op->jump = vm_arch_x86_regs[VM_X86_EAX+buf[1]-0xd0];
op->eob = 1;
}
@ -307,14 +307,14 @@ static int myop(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
case 0x5e:
case 0x5f:
op->type = R_ANAL_OP_TYPE_POP;
op->length = 1;
op->size = 1;
op->stackptr = -4;
break;
case 0x2e: // 2e64796e jns 0xb770a4ab !!
if (buf[1]>=0x64 && buf[1]<=0x67) {
int ret = myop (anal, op, addr, buf+1, len-1);
op->jump++;
op->length++;
op->size++;
return ret;
}
break;
@ -324,8 +324,8 @@ static int myop(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
case 0x67:
op->type = R_ANAL_OP_TYPE_CJMP;
op->jump = addr+3+buf[2]; //+(buf[2]<<8)+(buf[3]<<16); // XXX
op->length = 3;
op->fail = addr+op->length;
op->size = 3;
op->fail = addr+op->size;
//op->eob = 1;
break;
case 0x68:
@ -372,7 +372,7 @@ static int myop(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
op->src[1]->base = buf[2];
// 83f821 cmp eax, 0x21
op->type = R_ANAL_OP_TYPE_CMP;
op->length = 3;
op->size = 3;
}
break;
case 0xec:
@ -463,7 +463,7 @@ static int myop(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
/* conditional jump */
if (buf[1]>=0x80&&buf[1]<=0x8F) {
op->type = R_ANAL_OP_TYPE_CJMP;
op->length = 6;
op->size = 6;
op->jump = (unsigned long)((buf+2)+6);
op->fail = addr+6;
op->eob = 1;
@ -491,7 +491,7 @@ static int myop(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
/* conditional jump */
//if (buf[1]>=0x80&&buf[1]<=0x8F) {
op->type = R_ANAL_OP_TYPE_CJMP;
op->length = 2;
op->size = 2;
// op->jump = (unsigned long)((buf+2)+6);
op->jump = addr+bo+2; //(unsigned long)((buf+1)+5);
op->fail = addr+2;
@ -503,12 +503,12 @@ static int myop(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
//op->type = R_ANAL_OP_TYPE_UNK;
}
//if (op->length == 0)
op->length = dislen ((unsigned char *)buf, 64); //instLength(buf, 16, 0);
//op->length = instLength(buf, 16, 0);
//if (op->size == 0)
op->size = dislen ((unsigned char *)buf, 64); //instLength(buf, 16, 0);
//op->size = instLength(buf, 16, 0);
if (!(op->jump>>33))
op->jump &= 0xFFFFFFFF; // XXX may break on 64 bits here
return op->length;
return op->size;
}
struct r_anal_plugin_t r_anal_plugin_x86_simple = {

View File

@ -161,7 +161,7 @@ int x86_udis86_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len)
op->addr = addr;
op->jump = op->fail = -1;
op->ptr = op->val = -1;
oplen = op->length = ud_insn_len (&u);
oplen = op->size = ud_insn_len (&u);
op->esil[0] = 0;
if (anal->decode)
@ -187,7 +187,7 @@ int x86_udis86_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len)
switch (u.mnemonic) {
case UD_Iinvalid:
oplen = op->length = -1;
oplen = op->size = -1;
return -1;
break;
case UD_Itest:

View File

@ -140,7 +140,7 @@ static int z80_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len)
op->type = R_ANAL_OP_TYPE_CALL;
break;
}
return op->length = ilen;
return op->size= ilen;
}
struct r_anal_plugin_t r_anal_plugin_z80 = {

View File

@ -27,12 +27,12 @@ int c55plus_disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
// decode instruction
ins_decoded = decode(0, &next_ins_pos);
if (!ins_decoded) {
op->inst_len = 0;
op->size = 0;
return 0;
}
// opcode length
op->inst_len = next_ins_pos;
op->size = next_ins_pos;
ins_decoded_len = strlen(ins_decoded);
for (i = 0; i < ins_decoded_len; i++)
ins_decoded[i] = tolower(ins_decoded[i]);

View File

@ -140,7 +140,7 @@ int GetSingleMSILInstr(const u8 *pMemory, ut32 MemorySize, DISASMSIL_OFFSET Code
//
demsil_get(pCurInstr, CurInstr, u8);
if (CurInstr >= 0x00 && CurInstr <= 0xE0)
if (CurInstr <= 0xE0)
goto getinstr;
//

View File

@ -14,7 +14,7 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
*op->buf_asm = 0;
if (!o.name) return 0; // invalid instruction
do8051disasm (o, a->pc, op->buf_asm, sizeof (op->buf_asm));
return (op->inst_len = o.length);
return (op->size = o.length);
}
RAsmPlugin r_asm_plugin_8051 = {

View File

@ -77,12 +77,12 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
op->buf_asm[0]='\0';
if (a->bits==16)
op->inst_len = ARCompact_decodeInstr ((bfd_vma)Offset, &disasm_obj);
else op->inst_len = ARCTangent_decodeInstr ((bfd_vma)Offset, &disasm_obj);
op->size = ARCompact_decodeInstr ((bfd_vma)Offset, &disasm_obj);
else op->size = ARCTangent_decodeInstr ((bfd_vma)Offset, &disasm_obj);
if (op->inst_len == -1)
if (op->size == -1)
strncpy (op->buf_asm, " (data)", R_ASM_BUFSIZE);
return op->inst_len;
return op->size;
}
RAsmPlugin r_asm_plugin_arc = {

View File

@ -159,16 +159,16 @@ oldcpucode = cpucode;
obj.disassembler_options = NULL;
/* is endianness ignored on 64bits? */
//r_mem_copyendian (bytes, buf, 4, !a->big_endian);
op->inst_len = print_insn_aarch64 ((bfd_vma)Offset, &obj);
op->size = print_insn_aarch64 ((bfd_vma)Offset, &obj);
} else {
obj.disassembler_options = options;
op->inst_len = obj.endian?
op->size = obj.endian?
print_insn_little_arm ((bfd_vma)Offset, &obj):
print_insn_big_arm ((bfd_vma)Offset, &obj);
}
if (op->inst_len == -1)
if (op->size == -1)
strncpy (op->buf_asm, " (data)", R_ASM_BUFSIZE);
return op->inst_len;
return op->size;
}
static int assemble(RAsm *a, RAsmOp *op, const char *buf) {

View File

@ -20,11 +20,11 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
} else {
arm_set_input_buffer (arminsn, buf);
}
op->inst_len = arm_disasm_one_insn (arminsn);
op->size = arm_disasm_one_insn (arminsn);
strncpy (op->buf_asm, arm_insn_asm (arminsn), R_ASM_BUFSIZE);
strncpy (op->buf_hex, arm_insn_hex (arminsn), R_ASM_BUFSIZE);
arm_free (arminsn);
return op->inst_len;
return op->size;
}
RAsmPlugin r_asm_plugin_arm_winedbg = {

View File

@ -12,7 +12,7 @@
#include "../arch/avr/disasm.c"
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
return op->inst_len = avrdis (op->buf_asm, a->pc, buf, len);
return op->size = avrdis (op->buf_asm, a->pc, buf, len);
}
RAsmPlugin r_asm_plugin_avr = {

View File

@ -66,7 +66,7 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
if (i<1) i=1; else i++;
free (buf_cp);
op->inst_len = i;
op->size = i;
return i;
}

View File

@ -30,7 +30,7 @@ static int arch_csr_disasm(char *str, const unsigned char *buf, ut64 seek) {
}
static int disassemble(RAsm *a, struct r_asm_op_t *op, const ut8 *buf, int len) {
arch_csr_disasm (op->buf_asm, buf, a->pc);
return (op->inst_len=2);
return (op->size=2);
}
RAsmPlugin r_asm_plugin_csr = {

View File

@ -381,13 +381,13 @@ static int dalvik_disassemble (RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
}
} else if (len>0) {
strcpy (op->buf_asm, "invalid ");
op->inst_len = len;
op->size = len;
size = len;
}
op->payload = payload;
size += payload; // XXX
// align to 2
op->inst_len = size;
op->size = size;
return size;
}
@ -400,8 +400,8 @@ static int dalvik_assemble(RAsm *a, RAsmOp *op, const char *buf) {
for (i=0; i<256; i++)
if (!strcmp (dalvik_opcodes[i].name, buf)) {
r_mem_copyendian (op->buf, (void*)&i, 4, a->big_endian);
op->inst_len = dalvik_opcodes[i].len;
return op->inst_len;
op->size = dalvik_opcodes[i].len;
return op->size;
}
return 0;
}

View File

@ -12,10 +12,10 @@
// ut64 for length here is overkill!
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
if (len<2) return -1; // at least 2 bytes!
op->inst_len = dcpu16_disasm (op->buf_asm, (const ut16*)buf, len, NULL);
if (op->inst_len == -1)
op->size = dcpu16_disasm (op->buf_asm, (const ut16*)buf, len, NULL);
if (op->size == -1)
strcpy (op->buf_asm, " (data)");
return op->inst_len;
return op->size;
}
static int assemble(RAsm *a, RAsmOp *op, const char *buf) {

View File

@ -19,7 +19,7 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
snprintf(op->buf_asm, R_ASM_BUFSIZE, "%s %s", cmd.instr, cmd.operands);
else snprintf(op->buf_asm, R_ASM_BUFSIZE, "%s", cmd.instr);
op->inst_len = ret;
op->size = ret;
return ret;
}

View File

@ -19,7 +19,7 @@ static int assemble(RAsm *a, RAsmOp *op, const char *buf) {
memcpy (op->buf, out, len<=R_ASM_BUFSIZE?len:R_ASM_BUFSIZE);
free (out);
}
op->inst_len = len;
op->size = len;
return len;
}

View File

@ -12,7 +12,7 @@
static int disassemble(RAsm *a, RAsmOp *r_op, const ut8 *buf, ut64 len) {
int dlen = gbDisass(r_op,buf,len);
if(dlen<0) dlen=0;
r_op->inst_len=dlen;
r_op->size=dlen;
return dlen;
}

View File

@ -10,8 +10,8 @@
static int do_disassemble(RAsm *a, struct r_asm_op_t *op, const ut8 *buf, int len) {
int dlen = i8080_disasm (buf, op->buf_asm, len);
if (dlen<0) dlen = 0;
op->inst_len = dlen;
return op->inst_len;
op->size = dlen;
return op->size;
}
RAsmPlugin r_asm_plugin_i8080 = {

View File

@ -19,13 +19,13 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
if (obj) r_java_set_obj (obj);
}
}
return op->inst_len = r_java_disasm (a->pc, buf,
return op->size = r_java_disasm (a->pc, buf,
op->buf_asm, sizeof (op->buf_asm));
}
static int assemble(RAsm *a, RAsmOp *op, const char *buf) {
// TODO: get class info from bin if possible
return op->inst_len = r_java_assemble (op->buf, buf);
return op->size = r_java_assemble (op->buf, buf);
}
RAsmPlugin r_asm_plugin_java = {

View File

@ -25,9 +25,9 @@ static int disassemble(RAsm *a, RAsmOp *aop, const ut8 *buf, int len) {
dp.instr = bof;
M68k_Disassemble(&dp);
snprintf (aop->buf_asm, R_ASM_BUFSIZE, "%s %s", opcode, operands);
aop->inst_len = 4;
aop->size = 4;
return aop->inst_len;
return aop->size;
}
RAsmPlugin r_asm_plugin_m68k = {

View File

@ -79,11 +79,11 @@ static int disassemble(struct r_asm_t *a, struct r_asm_op_t *op, const ut8 *buf,
op->buf_asm[0] = '\0';
if (a->big_endian)
op->inst_len = print_insn_big_mips ((bfd_vma)Offset, &disasm_obj);
else op->inst_len = print_insn_little_mips ((bfd_vma)Offset, &disasm_obj);
if (op->inst_len == -1)
op->size = print_insn_big_mips ((bfd_vma)Offset, &disasm_obj);
else op->size = print_insn_little_mips ((bfd_vma)Offset, &disasm_obj);
if (op->size == -1)
strncpy (op->buf_asm, " (data)", R_ASM_BUFSIZE);
return op->inst_len;
return op->size;
}
static int assemble(RAsm *a, RAsmOp *op, const char *str) {

View File

@ -22,7 +22,7 @@ static int arch_msil_disasm(char *str, const ut8 *buf, ut64 seek) {
static int disassemble(RAsm *a, struct r_asm_op_t *op, const ut8 *buf, int len) {
arch_msil_disasm (op->buf_asm, buf, a->pc);
return (op->inst_len=2);
return (op->size=2);
}
RAsmPlugin r_asm_plugin_msil = {

View File

@ -79,13 +79,13 @@ static int disassemble(RAsm *a, struct r_asm_op_t *op, const ut8 *buf, int len)
op->buf_asm[0]='\0';
if (a->big_endian)
op->inst_len = print_insn_big_powerpc((bfd_vma)Offset, &disasm_obj);
else op->inst_len = print_insn_little_powerpc((bfd_vma)Offset, &disasm_obj);
op->size = print_insn_big_powerpc((bfd_vma)Offset, &disasm_obj);
else op->size = print_insn_little_powerpc((bfd_vma)Offset, &disasm_obj);
if (op->inst_len == -1)
if (op->size == -1)
strncpy (op->buf_asm, " (data)", R_ASM_BUFSIZE);
return op->inst_len;
return op->size;
}
RAsmPlugin r_asm_plugin_ppc = {

View File

@ -18,7 +18,7 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
// XXX: This is wrong, some opcodes are 32bit in thumb mode
static int assemble(RAsm *a, RAsmOp *op, const char *str) {
Bitbuf b = {.out = op->buf, .bits = 0};
return op->inst_len = rarvm_assemble (&b, str);
return op->size = rarvm_assemble (&b, str);
}
RAsmPlugin r_asm_plugin_rar = {

View File

@ -70,12 +70,12 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
disasm_obj.fprintf_func = &buf_fprintf;
disasm_obj.stream = stdout;
op->buf_asm[0]='\0';
op->inst_len = print_insn_shl ((bfd_vma)Offset, &disasm_obj);
op->buf_asm[0] = '\0';
op->size = print_insn_shl ((bfd_vma)Offset, &disasm_obj);
if (op->inst_len == -1)
if (op->size == -1)
strncpy (op->buf_asm, " (data)", R_ASM_BUFSIZE);
return op->inst_len;
return op->size;
}
RAsmPlugin r_asm_plugin_sh = {

View File

@ -720,9 +720,7 @@ eprintf ("XXX: This command conflicts with 'ar'\n");
if (ptr != NULL) {
RAnalOp *op = r_core_op_anal (core, addr);
if (op != NULL) {
//eprintf("at(0x%08"PFMT64x")=%d (%s)\n", addr, atoi(ptr+1), ptr+1);
//trace_set_times(addr, atoi(ptr+1));
RDebugTracepoint *tp = r_debug_trace_add (core->dbg, addr, op->length);
RDebugTracepoint *tp = r_debug_trace_add (core->dbg, addr, op->size);
tp->count = atoi (ptr+1);
r_anal_trace_bb (core->anal, addr);
r_anal_op_free (op);

View File

@ -219,7 +219,7 @@ static void cmd_debug_backtrace (RCore *core, const char *input) {
// XXX Do asm.arch should define the max size of opcode?
r_core_read_at (core, addr, buf, 32); // XXX longer opcodes?
r_anal_op (core->anal, &analop, addr, buf, sizeof (buf));
} while (r_bp_traptrace_at (core->dbg->bp, addr, analop.length));
} while (r_bp_traptrace_at (core->dbg->bp, addr, analop.size));
r_bp_traptrace_enable (core->dbg->bp, R_FALSE);
}
}
@ -959,7 +959,7 @@ static int cmd_debug(void *data, const char *input) {
eprintf ("Dont know how to skip this instruction\n");
break;
}
addr += aop.length;
addr += aop.size;
}
r_debug_reg_set (core->dbg, "pc", addr);
}

View File

@ -909,7 +909,7 @@ static int cmd_print(void *data, const char *input) {
} else {
r_cons_printf ("0x%08"PFMT64x" %16s %s\n",
core->offset+pdn_offset, asmop.buf_hex, asmop.buf_asm);
pdn_offset += (go_by_instr? asmop.inst_len: 1);
pdn_offset += (go_by_instr? asmop.size: 1);
}
}
if (buf != core->block) free (buf);

View File

@ -218,8 +218,8 @@ static ut64 findprevopsz(RCore *core, ut64 addr) {
r_io_read_at (core->io, base, buf, sizeof (buf));
for (i=0; i<16; i++) {
if (r_anal_op (core->anal, &aop, addr-i, buf+120-i, 16+i)) {
if (aop.length<1) break;
if (i == aop.length) {
if (aop.size<1) break;
if (i == aop.size) {
switch (aop.type) {
case R_ANAL_OP_TYPE_ILL:
case R_ANAL_OP_TYPE_TRAP:
@ -268,7 +268,7 @@ static int r_core_search_rop(RCore *core, ut64 from, ut64 to, int opt) {
ropat = prev2;
else ropat = prev;
} else ropat = from+i;
roplen = from - ropat + i + aop.length;
roplen = from - ropat + i + aop.size;
r_core_cmdf (core, "pD %d @ 0x%"PFMT64x,
roplen, ropat);
break;

View File

@ -14,7 +14,7 @@ static int prevopsz (RCore *core, ut64 addr) {
ret = r_anal_op (core->anal, &op, base+i,
buf+i, sizeof (buf)-i);
if (!ret) continue;
len = op.length;
len = op.size;
r_anal_op_fini (&op); // XXX
if (len<1) continue;
i += len-1;

View File

@ -121,7 +121,7 @@ static ut64 num_callback(RNum *userptr, const char *str, int *ok) {
case 'j': return op.jump;
case 'f': return op.fail;
case 'm': return op.ptr; // memref
case 'l': return op.length;
case 'l': return op.size;
case 'b': return core->blocksize;
case 's': return core->file->size;
case 'w': return r_config_get_i (core->config, "asm.bits") / 8;

View File

@ -554,7 +554,7 @@ typedef struct r_anal_op_t {
ut64 type; /* type of opcode */
int stackop; /* operation on stack? */
int cond; /* condition type */
int length; /* length in bytes of opcode */
int size; /* size in bytes of opcode */
int nopcode; /* number of bytes representing the opcode (not the arguments) */
int family; /* family of opcode */
int eob; /* end of block (boolean) */

View File

@ -57,7 +57,7 @@ enum {
};
typedef struct r_asm_op_t {
int inst_len; // rename to size or length
int size; // instruction size
int payload; // size of payload (opsize = (intstlen-payload))
// But this is pretty slow..so maybe we should add some accessors
ut8 buf[R_ASM_BUFSIZE];