From b21e3b52301164466979479d17a32b882392da03 Mon Sep 17 00:00:00 2001 From: "gergely.erdelyi" Date: Tue, 28 Apr 2009 16:13:57 +0000 Subject: [PATCH] idc.py: Added OpFloat() idc.py: Stricter type check in SetRegValue(). Thanks to Igor Skochinsky for the patches. --- python/idc.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/python/idc.py b/python/idc.py index ac63413..1de65fe 100644 --- a/python/idc.py +++ b/python/idc.py @@ -444,8 +444,8 @@ def Eval(expr): 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() @@ -1150,6 +1150,19 @@ def OpNumber(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): """ 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. """ 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 return idaapi.set_reg_val(name, rv)