OK so I want to parse x86 instructions with IDA SDK. However I can't understand the output, I have this code (that is executed after decode_insn
at each operand that is present (type
not 0)):
//op is an operand op_t of some insn_t
//ea1 is current address
if(has_displ(op)) {
msg("%x\n", ea1);
msg("%d\n", x86_base_reg(instr, op));
msg("%d\n", x86_index_reg(instr, op));
msg("%d\n", x86_scale(op));
msg("%d\n", op.addr);
}
And this dissasembly:
.text:0040AE64 lea edx, ds:0[eax*4]
.text:0040AE6B lea edi, [eax+eax*2]
And the output I get for each of the above instruction is:
40AE64
-1
0
2
0
For the second one it doesn't even get into the if. My question is why? And also why 2 in the output is not 4?
Additionally I would greatly appreciate if you could point me to some open source project that utilizes the API for fully parsing an x86 instruction, for reference.