about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--miasm/arch/ia32_arch.py2
-rw-r--r--miasm/arch/ia32_sem.py8
-rw-r--r--miasm/expression/expression.py2
-rw-r--r--miasm/tools/emul_lib/libcodenat.c12
-rw-r--r--miasm/tools/emul_lib/libcodenat.h2
-rw-r--r--miasm/tools/to_c_helper.py5
6 files changed, 26 insertions, 5 deletions
diff --git a/miasm/arch/ia32_arch.py b/miasm/arch/ia32_arch.py
index 2493948e..5fd3f4f0 100644
--- a/miasm/arch/ia32_arch.py
+++ b/miasm/arch/ia32_arch.py
@@ -860,7 +860,7 @@ class x86allmncs:
         addop("jmpf",  [0xFF],             d5   , no_rm         , {}                 ,{}                , {bkf:True,dtf:True}         )
 
         addop("lahf",  [0x9F],             noafs, no_rm         , {}                 ,{}                , {},                         )
-        addop("lar",   [0x0F, 0x02],       noafs, no_rm         , {}                 ,{}                , {},                         )
+        addop("lar",   [0x0F, 0x02],       noafs, [rmr]         , {}                 ,{}                , {},                         )
         addop("ldmxcsr",[0x0F, 0xAE],      d2   , no_rm         , {}                 ,{}                , {},                         )
         addop("lds",   [0xC5],             noafs, [rmr]         , {}                 ,{}                , {},                         )
         addop("lss",   [0x0F, 0xB2],       noafs, [rmr]         , {}                 ,{}                , {},                         )
diff --git a/miasm/arch/ia32_sem.py b/miasm/arch/ia32_sem.py
index 059661e4..82c8999a 100644
--- a/miasm/arch/ia32_sem.py
+++ b/miasm/arch/ia32_sem.py
@@ -2299,6 +2299,13 @@ def sahf(info):
     e.append(ExprAff(zf, ExprSlice(tmp, 6, 7)))
     e.append(ExprAff(nf, ExprSlice(tmp, 7, 8)))
     return e
+
+def lar(info, a, b):
+    e = []
+    e.append(ExprAff(a, ExprOp('access_segment', b)))
+    e.append(ExprAff(zf, ExprOp('access_segment_ok', b)))
+    return e
+
 mnemo_func = {'mov': mov,
               'xchg': xchg,
               'movzx': movzx,
@@ -2511,6 +2518,7 @@ mnemo_func = {'mov': mov,
               "lss": lss,
               "lahf": lahf,
               "sahf": sahf,
+              "lar":lar,
               }
 
 
diff --git a/miasm/expression/expression.py b/miasm/expression/expression.py
index acf2cac8..c4317c0b 100644
--- a/miasm/expression/expression.py
+++ b/miasm/expression/expression.py
@@ -456,6 +456,8 @@ class ExprOp(Expr):
                 return "%s(%s)"%(self.op, self.args[0].toC())
             elif self.op in ["-"]:
                 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())
             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 ba491e16..27aac3de 100644
--- a/miasm/tools/emul_lib/libcodenat.c
+++ b/miasm/tools/emul_lib/libcodenat.c
@@ -1589,6 +1589,18 @@ unsigned int _get_memory_page_from_min_ad_py(unsigned int size)
     return ret;
 }
 
+unsigned int access_segment(unsigned int d)
+{
+	// XXX TODO
+	printf("access segment %X\n", d);
+	return 0;
+}
+unsigned int access_segment_ok(unsigned int d)
+{
+	// XXX TODO
+	printf("access segment ok %X\n", d);
+	return 0;
+}
 
 
 
diff --git a/miasm/tools/emul_lib/libcodenat.h b/miasm/tools/emul_lib/libcodenat.h
index d0f4930a..84741a73 100644
--- a/miasm/tools/emul_lib/libcodenat.h
+++ b/miasm/tools/emul_lib/libcodenat.h
@@ -514,6 +514,8 @@ double fadd(double a, double b);
 unsigned int double_to_mem_32(double d);
 uint64_t double_to_mem_64(double d);
 
+unsigned int access_segment(unsigned int d);
+unsigned int access_segment_ok(unsigned int d);
 
 #define shift_right_arith_08(a, b)\
 	((((char)(a)) >> ((int)(b)&0x1f))&0xff)
diff --git a/miasm/tools/to_c_helper.py b/miasm/tools/to_c_helper.py
index 358290e0..ab8317bc 100644
--- a/miasm/tools/to_c_helper.py
+++ b/miasm/tools/to_c_helper.py
@@ -1163,11 +1163,8 @@ def load_pe_in_vm(fname_in, options, all_imp_dll = None, **kargs):
     from miasm.tools import pe_helper
     from miasm.tools import codenat
 
-    parse_resources = True
-    if 'parse_resources' in kargs:
-        parse_resources = kargs['parse_resources']
     e = pe_init.PE(open(fname_in, 'rb').read(),
-                   parse_resources = parse_resources)
+                   parse_resources = options.parse_resources)
 
     vm_init_regs()
     init_memory_page_pool_py()