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@gmx.net>
This commit is contained in:
Robert Wilhelm 2022-08-11 22:03:16 +02:00 committed by Alexandre Julliard
parent b5becc2ee8
commit 484f028338
4 changed files with 14 additions and 11 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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(

View file

@ -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(