Robert Wilhelm : wshom: Use signed type for ExitCode in IWshShell3::Run().

Alexandre Julliard julliard at winehq.org
Sat Aug 13 14:18:09 CDT 2022


Module: wine
Branch: master
Commit: 484f028338f3a3ff26c2a8a0da17daed8d433c59
URL:    https://gitlab.winehq.org/wine/wine/-/commit/484f028338f3a3ff26c2a8a0da17daed8d433c59

Author: Robert Wilhelm <robert.wilhelm at gmx.net>
Date:   Thu Aug 11 22:03:16 2022 +0200

wshom: Use signed type for ExitCode in IWshShell3::Run().

DWORD is unsigned and will be converted to VT_UI4 variant when used from VBScript.
But VT_UI4 is no VBScript data type and should not be used as retval.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53542
Signed-off-by: Robert Wilhelm <robert.wilhelm at gmx.net>

---

 dlls/wshom.ocx/shell.c         |  6 ++++--
 dlls/wshom.ocx/tests/wshom.c   | 15 ++++++++-------
 dlls/wshom.ocx/tests/wshom.idl |  2 +-
 dlls/wshom.ocx/wshom.idl       |  2 +-
 4 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/dlls/wshom.ocx/shell.c b/dlls/wshom.ocx/shell.c
index e04844458b1..41913dcadd5 100644
--- a/dlls/wshom.ocx/shell.c
+++ b/dlls/wshom.ocx/shell.c
@@ -1329,7 +1329,7 @@ static WCHAR *split_command( BSTR cmd, WCHAR **params )
     return ret;
 }
 
-static HRESULT WINAPI WshShell3_Run(IWshShell3 *iface, BSTR cmd, VARIANT *style, VARIANT *wait, DWORD *exit_code)
+static HRESULT WINAPI WshShell3_Run(IWshShell3 *iface, BSTR cmd, VARIANT *style, VARIANT *wait, int *exit_code)
 {
     SHELLEXECUTEINFOW info;
     int waitforprocess;
@@ -1384,9 +1384,11 @@ static HRESULT WINAPI WshShell3_Run(IWshShell3 *iface, BSTR cmd, VARIANT *style,
     {
         if (waitforprocess)
         {
+            DWORD code;
             WaitForSingleObject(info.hProcess, INFINITE);
-            GetExitCodeProcess(info.hProcess, exit_code);
+            GetExitCodeProcess(info.hProcess, &code);
             CloseHandle(info.hProcess);
+            *exit_code = code;
         }
         else
             *exit_code = 0;
diff --git a/dlls/wshom.ocx/tests/wshom.c b/dlls/wshom.ocx/tests/wshom.c
index 0e30ea9ed9a..4867843678a 100644
--- a/dlls/wshom.ocx/tests/wshom.c
+++ b/dlls/wshom.ocx/tests/wshom.c
@@ -81,7 +81,8 @@ static void test_wshshell(void)
     EXCEPINFO ei;
     VARIANT arg, res, arg2;
     BSTR str, ret;
-    DWORD retval, attrs;
+    int retval;
+    DWORD attrs;
     UINT err;
 
     hr = CoCreateInstance(&CLSID_WshShell, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
@@ -227,19 +228,19 @@ static void test_wshshell(void)
     retval = 10;
     hr = IWshShell3_Run(sh3, str, NULL, &arg2, &retval);
     ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
-    ok(retval == 10, "Unexpected retval %lu.\n", retval);
+    ok(retval == 10, "Unexpected retval %d.\n", retval);
 
     retval = 10;
     hr = IWshShell3_Run(sh3, str, &arg, NULL, &retval);
     ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
-    ok(retval == 10, "Unexpected retval %lu.\n", retval);
+    ok(retval == 10, "Unexpected retval %d.\n", retval);
 
     retval = 10;
     V_VT(&arg2) = VT_ERROR;
     V_ERROR(&arg2) = 0;
     hr = IWshShell3_Run(sh3, str, &arg, &arg2, &retval);
     ok(hr == DISP_E_TYPEMISMATCH, "Unexpected hr %#lx.\n", hr);
-    ok(retval == 10, "Unexpected retval %lu.\n", retval);
+    ok(retval == 10, "Unexpected retval %d.\n", retval);
     SysFreeString(str);
 
     V_VT(&arg2) = VT_BOOL;
@@ -249,14 +250,14 @@ static void test_wshshell(void)
     str = SysAllocString(L"cmd.exe /c rd /s /q c:\\nosuchdir");
     hr = IWshShell3_Run(sh3, str, &arg, &arg2, &retval);
     ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
-    todo_wine ok(retval == ERROR_FILE_NOT_FOUND, "Unexpected retval %lu.\n", retval);
+    todo_wine ok(retval == ERROR_FILE_NOT_FOUND, "Unexpected retval %d.\n", retval);
     SysFreeString(str);
 
     retval = 0xdeadbeef;
     str = SysAllocString(L"\"cmd.exe \" /c rd /s /q c:\\nosuchdir");
     hr = IWshShell3_Run(sh3, str, &arg, &arg2, &retval);
     ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
-    todo_wine ok(retval == ERROR_FILE_NOT_FOUND, "Unexpected retval %lu.\n", retval);
+    todo_wine ok(retval == ERROR_FILE_NOT_FOUND, "Unexpected retval %d.\n", retval);
     SysFreeString(str);
 
     GetSystemDirectoryW(path, ARRAY_SIZE(path));
@@ -280,7 +281,7 @@ static void test_wshshell(void)
     str = SysAllocString(buf);
     hr = IWshShell3_Run(sh3, str, &arg, &arg2, &retval);
     ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
-    todo_wine ok(retval == ERROR_FILE_NOT_FOUND, "Unexpected retval %lu.\n", retval);
+    todo_wine ok(retval == ERROR_FILE_NOT_FOUND, "Unexpected retval %d.\n", retval);
     SysFreeString(str);
 
     DeleteFileW(path2);
diff --git a/dlls/wshom.ocx/tests/wshom.idl b/dlls/wshom.ocx/tests/wshom.idl
index 00391d52838..a0175bb1604 100644
--- a/dlls/wshom.ocx/tests/wshom.idl
+++ b/dlls/wshom.ocx/tests/wshom.idl
@@ -528,7 +528,7 @@ library IWshRuntimeLibrary
             [in] BSTR Command,
             [in, optional] VARIANT* WindowStyle,
             [in, optional] VARIANT* WaitOnReturn,
-            [out, retval] DWORD* out_ExitCode);
+            [out, retval] int* out_ExitCode);
 
         [id(0x03e9)]
         HRESULT Popup(
diff --git a/dlls/wshom.ocx/wshom.idl b/dlls/wshom.ocx/wshom.idl
index 8d4a8f03e17..c69362d6fac 100644
--- a/dlls/wshom.ocx/wshom.idl
+++ b/dlls/wshom.ocx/wshom.idl
@@ -528,7 +528,7 @@ library IWshRuntimeLibrary
             [in] BSTR Command,
             [in, optional] VARIANT* WindowStyle,
             [in, optional] VARIANT* WaitOnReturn,
-            [out, retval] DWORD* out_ExitCode);
+            [out, retval] int* out_ExitCode);
 
         [id(0x03e9)]
         HRESULT Popup(




More information about the wine-cvs mailing list