diff options
| author | serpilliere <devnull@localhost> | 2011-11-21 10:56:49 +0100 |
|---|---|---|
| committer | serpilliere <devnull@localhost> | 2011-11-21 10:56:49 +0100 |
| commit | 43d260a7122d68cc03ced5a0fc9e587f90018e83 (patch) | |
| tree | b5b1b4e3b40e0112bc4595eead76e8a4fb7c4374 | |
| parent | e132bbf21e815aaf3c5b85cd4446a430cc72aeea (diff) | |
| download | miasm-43d260a7122d68cc03ced5a0fc9e587f90018e83.tar.gz miasm-43d260a7122d68cc03ced5a0fc9e587f90018e83.zip | |
add fabs;fsqrt..
Diffstat (limited to '')
| -rw-r--r-- | miasm/arch/ia32_arch.py | 4 | ||||
| -rw-r--r-- | miasm/arch/ia32_sem.py | 18 | ||||
| -rw-r--r-- | miasm/expression/expression.py | 2 | ||||
| -rw-r--r-- | miasm/tools/emul_lib/libcodenat.c | 30 | ||||
| -rw-r--r-- | miasm/tools/emul_lib/libcodenat.h | 3 | ||||
| -rw-r--r-- | miasm/tools/win_api.py | 5 |
6 files changed, 57 insertions, 5 deletions
diff --git a/miasm/arch/ia32_arch.py b/miasm/arch/ia32_arch.py index 3524568a..15aa54ac 100644 --- a/miasm/arch/ia32_arch.py +++ b/miasm/arch/ia32_arch.py @@ -161,7 +161,7 @@ unsanity_mnemo = ['nop', 'monitor', 'mwait', 'fadd', 'faddp', 'fiadd', 'fcmovb', 'fdiv', 'fdivr', 'fidivr', 'fdivrp', 'ficom', 'ficomp', 'fild', 'fist', 'fistp', 'fisttp', 'fld', 'fldcw', 'fld1', 'fldl2t', "fldl2e", "fldpi", "fldlg2", "fldln2", "fldz", 'fldenv', 'fmul', 'fimul', 'fmulp', 'fst', 'fstp', 'fnstcw', 'fnstenv', 'f2xm1', 'fnstsw', 'fsub', 'fsubr', 'fisubr', 'fsubrp', 'ftst', 'fucom', 'fucompp', 'fxam', 'fxtract', 'fyl2x', 'fyl2xp1', 'fsqrt', 'fsincos', 'fsin', 'fscale', - 'fcos', 'fdecstp', 'fnop', 'fpatan', 'fprem', 'fprem1', 'fptan', 'frndint', "shl", 'sal', 'sar'] + 'fcos', 'fdecstp', 'fnop', 'fpatan', 'fprem', 'fprem1', 'fptan', 'frndint', "shl", 'sal', 'sar', 'fabs'] mask_drcrsg = {cr:0x100, dr:0x200, sg:0x400} @@ -1078,7 +1078,6 @@ class x86allmncs: addop("mwait", [0x0F, 0x01, 0xC9], noafs, no_rm , {} ,{} , {}, ) #x87 fpu , {} - addop("fabs", [0xD9, 0xE1], noafs, no_rm , {} ,{} , {}, ) addop("fadd", [0xD8], d0, no_rm , {sd:(0,2)} ,{} , {}, ) addop("fadd", [0xD8, 0xC0], reg, [r_eax] , {sw:(0,2)} ,{sd:False,sw:False},{}, ) @@ -1193,6 +1192,7 @@ class x86allmncs: addop("fldcw", [0xD9], d5, no_rm , {} ,{wd:True} , {}, ) addop("fldenv",[0xD9], d4, no_rm , {} ,{wd:False} , {}, ) + addop("fabs", [0xD9, 0xE1], noafs, no_rm , {} ,{} , {}, ) addop("fld1", [0xD9, 0xE8], noafs, no_rm , {} ,{sd:False} , {}, ) addop("fldl2t",[0xD9, 0xE9], noafs, no_rm , {} ,{sd:False} , {}, ) diff --git a/miasm/arch/ia32_sem.py b/miasm/arch/ia32_sem.py index 9e6025e7..3ae64478 100644 --- a/miasm/arch/ia32_sem.py +++ b/miasm/arch/ia32_sem.py @@ -1662,6 +1662,11 @@ def fsin(): e.append(ExprAff(float_st0, ExprOp('fsin', float_st0))) return e +def fcos(): + e = [] + e.append(ExprAff(float_st0, ExprOp('fcos', float_st0))) + return e + def fscale(): e = [] e.append(ExprAff(float_st0, ExprOp('fscale', float_st0, float_st1))) @@ -1672,6 +1677,16 @@ def f2xm1(): e.append(ExprAff(float_st0, ExprOp('f2xm1', float_st0))) return e +def fsqrt(): + e = [] + e.append(ExprAff(float_st0, ExprOp('fsqrt', float_st0))) + return e + +def fabs(): + e = [] + e.append(ExprAff(float_st0, ExprOp('fabs', float_st0))) + return e + def fnstsw(): dst = eax @@ -2018,8 +2033,11 @@ mnemo_func = {'mov': mov, 'fptan':fptan, 'frndint':frndint, 'fsin':fsin, + 'fcos':fcos, 'fscale':fscale, 'f2xm1':f2xm1, + 'fsqrt':fsqrt, + 'fabs':fabs, 'fnstsw':fnstsw, 'fnstcw':fnstcw, 'fldcw':fldcw, diff --git a/miasm/expression/expression.py b/miasm/expression/expression.py index c9aba983..49dc1a50 100644 --- a/miasm/expression/expression.py +++ b/miasm/expression/expression.py @@ -456,7 +456,7 @@ class ExprOp(Expr): return "%s(%s)"%(self.op, self.args[0].toC()) elif self.op.startswith("double_to_mem_"): return "%s(%s)"%(self.op, self.args[0].toC()) - elif self.op in ["ftan", "frndint", "f2xm1", "fsin"]: + elif self.op in ["ftan", "frndint", "f2xm1", "fsin", "fsqrt", "fabs", "fcos"]: return "%s(%s)"%(self.op, self.args[0].toC()) else: print self.op diff --git a/miasm/tools/emul_lib/libcodenat.c b/miasm/tools/emul_lib/libcodenat.c index fdf4670f..79f27429 100644 --- a/miasm/tools/emul_lib/libcodenat.c +++ b/miasm/tools/emul_lib/libcodenat.c @@ -926,6 +926,16 @@ double fsin(double a) return b; } +double fcos(double a) +{ + double b; + b = cos(a); +#ifdef DEBUG_MIASM_DOUBLE + printf("%e %e\n", a, b); +#endif + return b; +} + double fscale(double a, double b) { @@ -947,6 +957,26 @@ double f2xm1(double a) return b; } +double fsqrt(double a) +{ + double b; + b = sqrt(a); +#ifdef DEBUG_MIASM_DOUBLE + printf("%e %e\n", a, b); +#endif + return b; +} + +double fabs(double a) +{ + double b; + b = abs(a); +#ifdef DEBUG_MIASM_DOUBLE + printf("%e %e\n", a, b); +#endif + return b; +} + unsigned int fcom_c0(double a, double b) diff --git a/miasm/tools/emul_lib/libcodenat.h b/miasm/tools/emul_lib/libcodenat.h index 9ae1408c..26d6b850 100644 --- a/miasm/tools/emul_lib/libcodenat.h +++ b/miasm/tools/emul_lib/libcodenat.h @@ -427,8 +427,11 @@ double fdiv(double a, double b); double ftan(double a); double frndint(double a); double fsin(double a); +double fcos(double a); double fscale(double a, double b); double f2xm1(double a); +double fsqrt(double a); +double fabs(double a); unsigned int fcom_c0(double a, double b); unsigned int fcom_c1(double a, double b); unsigned int fcom_c2(double a, double b); diff --git a/miasm/tools/win_api.py b/miasm/tools/win_api.py index cd821013..db5e7eee 100644 --- a/miasm/tools/win_api.py +++ b/miasm/tools/win_api.py @@ -143,6 +143,7 @@ class c_winobjs: self.win_event_num = 0x13370 self.cryptdll_md5_h = {} + self.lastwin32error = 0 winobjs = c_winobjs() @@ -904,7 +905,7 @@ def kernel32_GetLastError(): print whoami(), hex(ret_ad), '(', ')' regs = vm_get_gpreg() regs['eip'] = ret_ad - regs['eax'] = win32error.lastwin32error + regs['eax'] = winobjs.lastwin32error vm_set_gpreg(regs) def kernel32_SetLastError(): @@ -912,7 +913,7 @@ def kernel32_SetLastError(): e = vm_pop_uint32_t() print whoami(), hex(ret_ad), hex(e) - win32error.lastwin32error = e + winobjs.lastwin32error = e regs = vm_get_gpreg() regs['eip'] = ret_ad regs['eax'] = 0 |