idc.py: Fixed GetOperandValue()

This commit is contained in:
gergely.erdelyi 2008-06-15 16:53:55 +00:00
parent 375606cefd
commit 0315608029

View File

@ -1957,21 +1957,28 @@ def GetOperandValue(ea, n):
otherwise => -1 otherwise => -1
""" """
inslen = idaapi.ua_code(ea) inslen = idaapi.ua_code(ea)
if inslen == 0: if inslen == 0:
return -1 return -1
insn = idaapi.get_current_instruction() insn = idaapi.get_current_instruction()
if not insn: if not insn:
return -1 return -1
op = idaapi.get_instruction_operand(insn, n) op = idaapi.get_instruction_operand(insn, n)
if not op: if not op:
return -1 return -1
return op.value if op.type in [ idaapi.o_mem, idaapi.o_far, idaapi.o_near, idaapi.o_displ ]:
value = op.addr
elif op.type == idaapi.o_reg:
value = op.reg
elif op.type == idaapi.o_imm:
value = op.value
elif op.type == idaapi.o_phrase:
value = op.phrase
else:
value = -1
return value
def LineA(ea, num): def LineA(ea, num):