about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorserpilliere <devnull@localhost>2013-02-26 13:47:05 +0100
committerserpilliere <devnull@localhost>2013-02-26 13:47:05 +0100
commitd78bee144a4c0ba0c9dc1352aa19ef8e557226ed (patch)
tree1a12daa3211d98604aff12d55d2a71ee64049aaf
parenta1222ab09f5bb3adb01f0a5eaf3c0274e589aeaf (diff)
downloadmiasm-d78bee144a4c0ba0c9dc1352aa19ef8e557226ed.tar.gz
miasm-d78bee144a4c0ba0c9dc1352aa19ef8e557226ed.zip
ia32_arch: add str; lsl; seh_helper: fix ininitloadorder
-rw-r--r--miasm/arch/ia32_sem.py23
-rw-r--r--miasm/expression/expression.py4
-rw-r--r--miasm/tools/emul_lib/libcodenat.c18
-rw-r--r--miasm/tools/emul_lib/libcodenat.h5
-rw-r--r--miasm/tools/seh_helper.py2
5 files changed, 51 insertions, 1 deletions
diff --git a/miasm/arch/ia32_sem.py b/miasm/arch/ia32_sem.py
index 82c8999a..ad2d71ae 100644
--- a/miasm/arch/ia32_sem.py
+++ b/miasm/arch/ia32_sem.py
@@ -2306,6 +2306,25 @@ def lar(info, a, b):
     e.append(ExprAff(zf, ExprOp('access_segment_ok', b)))
     return e
 
+def lsl(info, a, b):
+    e = []
+    e.append(ExprAff(a, ExprOp('load_segment_limit', b)))
+    e.append(ExprAff(zf, ExprOp('load_segment_limit_ok', b)))
+    return e
+
+def fclex(info):
+    # XXX TODO
+    return []
+
+def fnclex(info):
+    # XXX TODO
+    return []
+
+def l_str(info, a):
+    e = []
+    e.append(ExprAff(a, ExprOp('load_tr_segment_selector', ExprInt32(0))))
+    return e
+
 mnemo_func = {'mov': mov,
               'xchg': xchg,
               'movzx': movzx,
@@ -2519,6 +2538,10 @@ mnemo_func = {'mov': mov,
               "lahf": lahf,
               "sahf": sahf,
               "lar":lar,
+              "lsl":lsl,
+              "fclex":fclex,
+              "fnclex":fnclex,
+              "str":l_str,
               }
 
 
diff --git a/miasm/expression/expression.py b/miasm/expression/expression.py
index c4317c0b..6bba7526 100644
--- a/miasm/expression/expression.py
+++ b/miasm/expression/expression.py
@@ -458,6 +458,10 @@ class ExprOp(Expr):
                 return "%s(%s)"%(self.op, self.args[0].toC())
             elif self.op in ["access_segment", "access_segment_ok"]:
                 return "%s(%s)"%(self.op, self.args[0].toC())
+            elif self.op in ["load_segment_limit", "load_segment_limit_ok"]:
+                return "%s(%s)"%(self.op, self.args[0].toC())
+            elif self.op in ["load_tr_segment_selector"]:
+                return "%s(%s)"%(self.op, self.args[0].toC())
             else:
                 print self.op
                 raise ValueError('unknown op!!', str(self.op))
diff --git a/miasm/tools/emul_lib/libcodenat.c b/miasm/tools/emul_lib/libcodenat.c
index 27aac3de..e1cd54f5 100644
--- a/miasm/tools/emul_lib/libcodenat.c
+++ b/miasm/tools/emul_lib/libcodenat.c
@@ -1602,6 +1602,24 @@ unsigned int access_segment_ok(unsigned int d)
 	return 0;
 }
 
+unsigned int load_segment_limit(unsigned int d)
+{
+	// XXX TODO
+	printf("load segment limit %X\n", d);
+	return 0;
+}
+unsigned int load_segment_limit_ok(unsigned int d)
+{
+	// XXX TODO
+	printf("load segment limit ok %X\n", d);
+	return 0;
+}
+
+unsigned int load_tr_segment_selector(unsigned int d)
+{
+	// XXX TODO
+	return 0;
+}
 
 
 //#include "libcodenat_interface.c"
diff --git a/miasm/tools/emul_lib/libcodenat.h b/miasm/tools/emul_lib/libcodenat.h
index 84741a73..5e9a3b60 100644
--- a/miasm/tools/emul_lib/libcodenat.h
+++ b/miasm/tools/emul_lib/libcodenat.h
@@ -517,6 +517,11 @@ uint64_t double_to_mem_64(double d);
 unsigned int access_segment(unsigned int d);
 unsigned int access_segment_ok(unsigned int d);
 
+unsigned int load_segment_limit(unsigned int d);
+unsigned int load_segment_limit_ok(unsigned int d);
+
+unsigned int load_tr_segment_selector(unsigned int d);
+
 #define shift_right_arith_08(a, b)\
 	((((char)(a)) >> ((int)(b)&0x1f))&0xff)
 #define shift_right_arith_16(a, b)\
diff --git a/miasm/tools/seh_helper.py b/miasm/tools/seh_helper.py
index efdd7191..25fb44ec 100644
--- a/miasm/tools/seh_helper.py
+++ b/miasm/tools/seh_helper.py
@@ -397,7 +397,7 @@ def fix_InInitializationOrderModuleList(module_info):
         e, bname, addr = olist[i]
         p_e, p_bname, p_addr = olist[(i-1)%len(olist)]
         n_e, n_bname, n_addr = olist[(i+1)%len(olist)]
-        vm_set_mem(addr+0x10, pdw(p_addr)+pdw(n_addr))
+        vm_set_mem(addr+0x10, pdw(n_addr+0x10)+pdw(p_addr+0x10))
 
 
 def add_process_env():