main.py
ntype = dict() ntype[0] = 'void' ntype[1] = 'reg' ntype[2] = 'mem' ntype[3] = 'phrase' ntype[4] = 'displ' ntype[5] = 'imm' ntype[6] = 'far' ntype[7] = 'near' # .text:0040102A add eax, ecx ea = 0x40102a inslen = idaapi.decode_insn(ea) op0 = idaapi.cmd.Operands[0] op1 = idaapi.cmd.Operands[1] print 'op0 type:{}, reg:{}'.format(ntype[int(op0.type)], idaapi.ph_get_regnames()[int(op0.reg)]) print 'op1 type:{}, reg:{}'.format(ntype[int(op1.type)], idaapi.ph_get_regnames()[int(op1.reg)])
輸出
op0 type:reg, reg:ax op1 type:reg, reg:cx