about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorThéo Combe <theo.combe@cea.fr>2021-08-31 10:59:40 +0200
committerThéo Combe <theo.combe@cea.fr>2021-08-31 10:59:40 +0200
commit72cff522c95a2ab702d771f650840ca68aee6efd (patch)
treeb31a65244e3c2e7907529a9de6ca8ebf0626979d
parenta7f9f78b67ab50050172be151b324789f96ac43d (diff)
downloadfocaccia-miasm-72cff522c95a2ab702d771f650840ca68aee6efd.tar.gz
focaccia-miasm-72cff522c95a2ab702d771f650840ca68aee6efd.zip
Fix kernel32_WideCharToMultiByte
-rw-r--r--miasm/os_dep/win_api_x86_32.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/miasm/os_dep/win_api_x86_32.py b/miasm/os_dep/win_api_x86_32.py
index 568a646d..e9c5fd4a 100644
--- a/miasm/os_dep/win_api_x86_32.py
+++ b/miasm/os_dep/win_api_x86_32.py
@@ -1735,7 +1735,10 @@ def kernel32_WideCharToMultiByte(jitter):
       ])
     if args.CodePage != CP_ACP and args.CodePage != CP_1252:
         raise NotImplementedError
-    src = jitter.vm.get_mem(args.lpWideCharStr, args.cchWideChar * 2)
+    cchWideChar = args.cchWideChar
+    if cchWideChar == 0xffffffff:
+        cchWideChar = len(get_win_str_w(jitter, args.lpWideCharStr)) + 1
+    src = jitter.vm.get_mem(args.lpWideCharStr, cchWideChar * 2)
     dst = src.decode("utf-16le").encode("cp1252", errors="replace")
     if args.cbMultiByte > 0:
         # return value is the number of bytes written