about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorserpilliere <serpilliere@users.noreply.github.com>2020-05-15 11:38:16 +0200
committerGitHub <noreply@github.com>2020-05-15 11:38:16 +0200
commit3b288556c9bedbacccb809641b9caacad5327736 (patch)
treef3f1319edaf5e6eb5fbc39470e4ed370e3b63b50
parentfe3b6e1e91852a36f142a91187c56ca9e9542fec (diff)
parenta33a55cd20d123ed0c5e5ce163c7a9d8053b2d72 (diff)
downloadmiasm-3b288556c9bedbacccb809641b9caacad5327736.tar.gz
miasm-3b288556c9bedbacccb809641b9caacad5327736.zip
Merge pull request #1225 from carolineLe/winapi_shell32
Win_api: fix argv index in shell32_CommandLineToArgvW
Diffstat (limited to '')
-rw-r--r--miasm/os_dep/win_api_x86_32.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/miasm/os_dep/win_api_x86_32.py b/miasm/os_dep/win_api_x86_32.py
index d66f3cb9..2ecb1179 100644
--- a/miasm/os_dep/win_api_x86_32.py
+++ b/miasm/os_dep/win_api_x86_32.py
@@ -606,7 +606,7 @@ def kernel32_CreateFile(jitter, funcname, get_str):
                         h = open(sb_fname, 'r+b')
                         ret = winobjs.handle_pool.add(sb_fname, h)
                 else:
-                    log.warning("FILE %r DOES NOT EXIST!", fname)
+                    log.warning("FILE %r (%s) DOES NOT EXIST!", fname, sb_fname)
             elif args.dwcreationdisposition == 1:
                 # create new
                 if os.access(sb_fname, os.R_OK):
@@ -1114,6 +1114,8 @@ def kernel32_GetCommandLineW(jitter):
 def shell32_CommandLineToArgvW(jitter):
     ret_ad, args = jitter.func_args_stdcall(["pcmd", "pnumargs"])
     cmd = get_win_str_w(jitter, args.pcmd)
+    if cmd.startswith('"') and cmd.endswith('"'):
+        cmd = cmd[1:-1]
     log.info("CommandLineToArgv %r", cmd)
     tks = cmd.split(' ')
     addr = winobjs.heap.alloc(jitter, len(cmd) * 2 + 4 * len(tks))
@@ -1124,11 +1126,10 @@ def shell32_CommandLineToArgvW(jitter):
         jitter.vm.set_u32(addr_ret + 4 * i, addr + o)
         o += len(t)*2 + 2
 
-    jitter.vm.set_u32(addr_ret + 4 * i, 0)
+    jitter.vm.set_u32(addr_ret + 4 * (i+1), 0)
     jitter.vm.set_u32(args.pnumargs, len(tks))
     jitter.func_ret_stdcall(ret_ad, addr_ret)
 
-
 def cryptdll_MD5Init(jitter):
     ret_ad, args = jitter.func_args_stdcall(["ad_ctx"])
     index = len(winobjs.cryptdll_md5_h)