Beispiel #1
0
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
	ebc_command_t cmd = { {0}, {0} };
	int ret = ebc_decode_command (buf, &cmd);
	const char *buf_asm = (cmd.operands[0])
		? sdb_fmt ("%s %s", cmd.instr, cmd.operands): cmd.instr;
	r_asm_op_set_asm (op, buf_asm);
	return op->size = ret;
}
Beispiel #2
0
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
	int ret = 1;
	ebc_command_t cmd = { {0}, {0} };

	ret = ebc_decode_command(buf, &cmd);

	if (cmd.operands[0]) {
		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->size = ret;
	return ret;
}
Beispiel #3
0
static int ebc_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
	int ret;
	ebc_command_t cmd;
	ut8 opcode = buf[0] & EBC_OPCODE_MASK;

	if (!op)
		return 2;

	memset(op, 0, sizeof (RAnalOp));
	op->addr = addr;
	op->jump = op->fail = -1;
	op->ptr = op->val = -1;

	ret = op->size = ebc_decode_command(buf, &cmd);

	if (ret < 0)
		return ret;

	switch (opcode) {
	case EBC_JMP8:
		ebc_anal_jmp8(op, addr, buf);
		break;
	case EBC_JMP:
		ebc_anal_jmp(op, addr, buf);
		break;
	case EBC_MOVBW:
	case EBC_MOVWW:
	case EBC_MOVDW:
	case EBC_MOVQW:
	case EBC_MOVBD:
	case EBC_MOVWD:
	case EBC_MOVDD:
	case EBC_MOVQD:
	case EBC_MOVSNW:
	case EBC_MOVSND:
	case EBC_MOVQQ:
	case EBC_MOVNW:
	case EBC_MOVND:
	case EBC_MOVI:
	case EBC_MOVIN:
	case EBC_MOVREL:
		op->type = R_ANAL_OP_TYPE_MOV;
		break;
	case EBC_RET:
		op->type = R_ANAL_OP_TYPE_RET;
		break;
	case EBC_CMPEQ:
	case EBC_CMPLTE:
	case EBC_CMPGTE:
	case EBC_CMPULTE:
	case EBC_CMPUGTE:
	case EBC_CMPIEQ:
	case EBC_CMPILTE:
	case EBC_CMPIGTE:
	case EBC_CMPIULTE:
	case EBC_CMPIUGTE:
		op->type = R_ANAL_OP_TYPE_CMP;
		break;
	case EBC_SHR:
		op->type = R_ANAL_OP_TYPE_SHR;
		break;
	case EBC_SHL:
		op->type = R_ANAL_OP_TYPE_SHL;
		break;
	case EBC_OR:
		op->type = R_ANAL_OP_TYPE_OR;
		break;
	case EBC_XOR:
		op->type = R_ANAL_OP_TYPE_XOR;
		break;
	case EBC_MUL:
		op->type = R_ANAL_OP_TYPE_MUL;
		break;
	case EBC_PUSH:
		op->type = R_ANAL_OP_TYPE_PUSH;
		break;
	case EBC_POP:
		op->type = R_ANAL_OP_TYPE_POP;
		break;
	case EBC_AND:
		op->type = R_ANAL_OP_TYPE_AND;
		break;
	case EBC_ADD:
		op->type = R_ANAL_OP_TYPE_ADD;
		break;
	case EBC_SUB:
		op->type = R_ANAL_OP_TYPE_SUB;
		break;
	case EBC_NEG:
		op->type = R_ANAL_OP_TYPE_SUB;
		break;
	case EBC_CALL:
		ebc_anal_call(op, addr, buf);
		break;
	case EBC_BREAK:
		op->type = R_ANAL_OP_TYPE_SWI;
		break;
	default:
		op->type = R_ANAL_OP_TYPE_UNK;
		break;
	}

	return ret;
}