about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2014-10-16 15:05:09 +0200
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2014-10-16 15:05:09 +0200
commite9473b2e4a85ae2cc924086fbfc8d789908ec20d (patch)
treedf6a807c4463a14c23506e3f256d5852ec1a827f
parent4717e8f6295c46fbfc7e27cc750df7ccf7a599be (diff)
downloadmiasm-e9473b2e4a85ae2cc924086fbfc8d789908ec20d.tar.gz
miasm-e9473b2e4a85ae2cc924086fbfc8d789908ec20d.zip
win_32_api: update createfile
-rw-r--r--miasm2/os_dep/win_api_x86_32.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/miasm2/os_dep/win_api_x86_32.py b/miasm2/os_dep/win_api_x86_32.py
index f3571cbf..f09116e0 100644
--- a/miasm2/os_dep/win_api_x86_32.py
+++ b/miasm2/os_dep/win_api_x86_32.py
@@ -556,7 +556,7 @@ def kernel32_CreateFile(jitter, funcname, get_str):
         fname = fname.replace('\\', "/").lower()
         # go in sandbox files
         f = os.path.join('file_sb', fname)
-        if access & 0x80000000:
+        if access & 0x80000000 or access == 1:
             # read
             if dwcreationdisposition == 2:
                 # create_always
@@ -589,6 +589,17 @@ def kernel32_CreateFile(jitter, funcname, get_str):
                     open(f, 'w')
                     h = open(f, 'rb+')
                     ret = winobjs.handle_pool.add(f, h)
+            elif dwcreationdisposition == 4:
+                # open_always
+                if os.access(f, os.R_OK):
+                    s = os.stat(f)
+                    if stat.S_ISDIR(s.st_mode):
+                        ret = winobjs.handle_pool.add(f, 0x1337)
+                    else:
+                        h = open(f, 'rb+')
+                        ret = winobjs.handle_pool.add(f, h)
+                else:
+                    raise NotImplementedError("Untested case")
             else:
                 raise NotImplementedError("Untested case")
         elif access & 0x40000000: