idc.py: Added OpFloat()

idc.py: Stricter type check in SetRegValue(). Thanks to Igor Skochinsky for the patches.
This commit is contained in:
gergely.erdelyi 2009-04-28 16:13:57 +00:00
parent d26536abd4
commit b21e3b5230

View File

@ -444,8 +444,8 @@ def Eval(expr):
def EVAL_FAILURE(code): def EVAL_FAILURE(code):
""" """
Check the result of Eval() for evaluation failures Check the result of Eval() for evaluation failures
@param code: result of Eval() @param code: result of Eval()
@ -1150,6 +1150,19 @@ def OpNumber(ea, n):
return idaapi.op_num(ea, n) return idaapi.op_num(ea, n)
def OpFloat(ea, n):
"""
Convert operand to a floating-point number
@param ea: linear address
@param n: number of operand
- 0 - the first operand
- 1 - the second, third and all other operands
- -1 - all operands
"""
return idaapi.op_flt(ea, n)
def OpAlt(ea, n, opstr): def OpAlt(ea, n, opstr):
""" """
Specify operand represenation manually. Specify operand represenation manually.
@ -6892,6 +6905,16 @@ def SetRegValue(value, name):
A register name in the left side of an assignment will do too. A register name in the left side of an assignment will do too.
""" """
rv = idaapi.regval_t() rv = idaapi.regval_t()
if type(value)==types.StringType:
value = int(value)
elif type(value)!=types.IntType:
print "SetRegValue: value must be integer!"
return BADADDR
if value<0:
#ival_set cannot handle negative numbers
value &= 0xFFFFFFFF
rv.ival = value rv.ival = value
return idaapi.set_reg_val(name, rv) return idaapi.set_reg_val(name, rv)