about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2014-09-19 10:43:32 +0200
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2014-09-19 10:43:32 +0200
commit3674bace8dbc185aefca1b4fa85983adfe73956b (patch)
tree3868dca81348cc0ef76b024d2d151293e9a911d9
parent3f11ce8a64d4dcc37587c4750ae5381a808695ef (diff)
downloadmiasm-3674bace8dbc185aefca1b4fa85983adfe73956b.tar.gz
miasm-3674bace8dbc185aefca1b4fa85983adfe73956b.zip
merge
-rw-r--r--example/unpack_upx.py6
-rw-r--r--miasm2/arch/mips32/arch.py1
-rw-r--r--miasm2/arch/mips32/sem.py6
-rw-r--r--miasm2/arch/x86/sem.py27
-rw-r--r--test/arch/mips32/arch.py2
5 files changed, 17 insertions, 25 deletions
diff --git a/example/unpack_upx.py b/example/unpack_upx.py
index 05e3f4b7..6805c82d 100644
--- a/example/unpack_upx.py
+++ b/example/unpack_upx.py
@@ -96,7 +96,7 @@ if args.graph is True:
 # User defined methods
 
 
-def mygetproc(myjit):
+def kernel32_GetProcAddress(myjit):
     global libs
     ret_ad, args = myjit.func_args_stdcall(2)
     libbase, fname = args
@@ -113,10 +113,6 @@ def mygetproc(myjit):
     ad = libs.lib_get_add_func(libbase, fname, dst_ad)
     myjit.func_ret_stdcall(ret_ad, ad)
 
-
-def kernel32_GetProcAddress(myjit):
-    return mygetproc(myjit)
-
 # Set libs for win_32 api
 win_api_x86_32.winobjs.runtime_dll = libs
 if args.verbose is True:
diff --git a/miasm2/arch/mips32/arch.py b/miasm2/arch/mips32/arch.py
index 8a49c4f8..b3bbc3ff 100644
--- a/miasm2/arch/mips32/arch.py
+++ b/miasm2/arch/mips32/arch.py
@@ -688,6 +688,7 @@ mips32op("ext",     [bs('011111'), rs, rt, esize, epos, bs('000000')], [rt, rs,
 mips32op("ins",     [bs('011111'), rs, rt, eposh, epos, bs('000100')], [rt, rs, epos, eposh])
 
 mips32op("seb",     [bs('011111'), bs('00000'), rt, rd, bs('10000'), bs('100000')], [rd, rt])
+mips32op("seh",     [bs('011111'), bs('00000'), rt, rd, bs('11000'), bs('100000')], [rd, rt])
 mips32op("wsbh",    [bs('011111'), bs('00000'), rt, rd, bs('00010'), bs('100000')], [rd, rt])
 
 mips32op("di",      [bs('010000'), bs('01011'), rt, bs('01100'), bs('00000'), bs('0'), bs('00'), bs('000')])
diff --git a/miasm2/arch/mips32/sem.py b/miasm2/arch/mips32/sem.py
index e83d9b48..365444d7 100644
--- a/miasm2/arch/mips32/sem.py
+++ b/miasm2/arch/mips32/sem.py
@@ -225,6 +225,11 @@ def seb(ir, instr, a, b):
     e.append(ExprAff(a, b[:8].signExtend(32)))
     return e, []
 
+def seh(ir, instr, a, b):
+    e = []
+    e.append(ExprAff(a, b[:16].signExtend(32)))
+    return e, []
+
 def bltz(ir, instr, a, b):
     e = []
     n = ExprId(ir.get_next_break_label(instr))
@@ -475,6 +480,7 @@ mnemo_func = {
     "xori" : l_xor,
     "xor" : l_xor,
     "seb" : seb,
+    "seh" : seh,
     "bltz" : bltz,
     "blez" : blez,
     "wsbh" : wsbh,
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py
index c304def6..46302de3 100644
--- a/miasm2/arch/x86/sem.py
+++ b/miasm2/arch/x86/sem.py
@@ -1340,10 +1340,10 @@ def loop(ir, instr, dst):
 
     n = ExprId(ir.get_next_label(instr), instr.mode)
     c = myecx - ExprInt_from(myecx, 1)
+    dst_o = ExprCond(c, dst, n).zeroExtend(instr.mode)
     e.append(ExprAff(myecx, c))
-    e.append(ExprAff(meip, ExprCond(c, dst, n).zeroExtend(instr.mode)))
-    e.append(ExprAff(ir.IRDst, ExprCond(myecx, dst, n).zeroExtend(instr.mode)))
-    #dst_o = ExprCond(myecx, dst, n).zeroExtend(instr.mode)
+    e.append(ExprAff(meip, dst_o))
+    e.append(ExprAff(ir.IRDst, dst_o))
     return e, []
 
 
@@ -1362,15 +1362,9 @@ def loopne(ir, instr, dst):
     c &= zf ^ ExprInt1(1)
 
     e.append(ExprAff(myecx, myecx - ExprInt_from(myecx, 1)))
-    e.append(ExprAff(meip, ExprCond(c, dst, n).zeroExtend(instr.mode)))
-
-    # for dst, ecx has been modified!
-    c = ExprCond(mRCX[instr.mode][:s],
-                 ExprInt1(1),
-                 ExprInt1(0))
-    c &= zf ^ ExprInt1(1)
-    #dst_o = ExprCond(c, dst, n).zeroExtend(instr.mode)
-    e.append(ExprAff(ir.IRDst, ExprCond(c, dst, n).zeroExtend(instr.mode)))
+    dst_o = ExprCond(c, dst, n).zeroExtend(instr.mode)
+    e.append(ExprAff(meip, dst_o))
+    e.append(ExprAff(ir.IRDst, dst_o))
     return e, []
 
 
@@ -1389,14 +1383,7 @@ def loope(ir, instr, dst):
     e.append(ExprAff(myecx, myecx - ExprInt_from(myecx, 1)))
     dst_o = ExprCond(c, dst, n).zeroExtend(instr.mode)
     e.append(ExprAff(meip, dst_o))
-
-    # for dst, ecx has been modified!
-    c = ExprCond(mRCX[instr.mode][:s],
-                 ExprInt1(1),
-                 ExprInt1(0))
-    c &= zf
-    #dst_o = ExprCond(c, dst, n).zeroExtend(instr.mode)
-    e.append(ExprAff(ir.IRDst, ExprCond(c, dst, n).zeroExtend(instr.mode)))
+    e.append(ExprAff(ir.IRDst, dst_o))
     return e, []
 
 
diff --git a/test/arch/mips32/arch.py b/test/arch/mips32/arch.py
index 8ecb0a5a..899748ce 100644
--- a/test/arch/mips32/arch.py
+++ b/test/arch/mips32/arch.py
@@ -192,6 +192,8 @@ reg_tests_mips32 = [
      "38630011"),
     ("8BA0F37C    SEB        S6, V0",
      "7C02B420"),
+    ("XXXXXXXX    SEH        V0, A3",
+     "7c071620"),
     ("8BA0F468    DI         ZERO",
      "41606000"),
     ("XXXXXXXX    EI         ZERO",