diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 90575780..da9d2ba0 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -238,6 +238,7 @@ patch_enable_all () enable_user32_recursive_activation="$1" enable_uxtheme_CloseThemeClass="$1" enable_version_VerQueryValue="$1" + enable_wbemdisp_ISWbemObject_Invoke="$1" enable_widl_SLTG_Typelib_Support="$1" enable_windowscodecs_GIF_Encoder="$1" enable_windowscodecs_TIFF_Support="$1" @@ -761,6 +762,9 @@ patch_enable () version-VerQueryValue) enable_version_VerQueryValue="$2" ;; + wbemdisp-ISWbemObject-Invoke) + enable_wbemdisp_ISWbemObject_Invoke="$2" + ;; widl-SLTG_Typelib_Support) enable_widl_SLTG_Typelib_Support="$2" ;; @@ -3720,6 +3724,19 @@ if test "$enable_version_VerQueryValue" -eq 1; then patch_apply version-VerQueryValue/0001-version-Test-for-VerQueryValueA-try-2.patch fi +# Patchset wbemdisp-ISWbemObject-Invoke +# | +# | Modified files: +# | * dlls/vbscript/interp.c, dlls/vbscript/tests/lang.vbs, dlls/vbscript/tests/run.c, dlls/vbscript/utils.c, +# | dlls/wbemdisp/locator.c, dlls/wbemprox/query.c +# | +if test "$enable_wbemdisp_ISWbemObject_Invoke" -eq 1; then + patch_apply wbemdisp-ISWbemObject-Invoke/0001-wbemdisp-Support-DISPATCH_METHOD-in-ISWbemObject-Inv.patch + patch_apply wbemdisp-ISWbemObject-Invoke/0002-vbscript-Support-VT_BSTR-VT_ARRAY-Iterator.patch + patch_apply wbemdisp-ISWbemObject-Invoke/0003-wbemprox-Support-VT_BYREF-in-to_longlong.patch + patch_apply wbemdisp-ISWbemObject-Invoke/0004-vbscript-Add-wmi-test.patch +fi + # Patchset windowscodecs-GIF_Encoder # | # | Modified files: diff --git a/patches/wbemdisp-ISWbemObject-Invoke/0001-wbemdisp-Support-DISPATCH_METHOD-in-ISWbemObject-Inv.patch b/patches/wbemdisp-ISWbemObject-Invoke/0001-wbemdisp-Support-DISPATCH_METHOD-in-ISWbemObject-Inv.patch new file mode 100644 index 00000000..8a16a741 --- /dev/null +++ b/patches/wbemdisp-ISWbemObject-Invoke/0001-wbemdisp-Support-DISPATCH_METHOD-in-ISWbemObject-Inv.patch @@ -0,0 +1,109 @@ +From 8c1d537e6ab57e8f358de7b7bc8a40069cbb9c88 Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Wed, 12 May 2021 11:46:48 +1000 +Subject: [PATCH 1/4] wbemdisp: Support DISPATCH_METHOD in ISWbemObject Invoke + +Wine-bug: https://bugs.winehq.org/show_bug.cgi?id=51120 +Wine-bug: https://bugs.winehq.org/show_bug.cgi?id=39463 +--- + dlls/wbemdisp/locator.c | 84 +++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 84 insertions(+) + +diff --git a/dlls/wbemdisp/locator.c b/dlls/wbemdisp/locator.c +index 3e2566d5220..e0a1872d38f 100644 +--- a/dlls/wbemdisp/locator.c ++++ b/dlls/wbemdisp/locator.c +@@ -1302,6 +1302,90 @@ static HRESULT WINAPI object_Invoke( + memset( params, 0, sizeof(*params) ); + return IWbemClassObject_Get( object->object, name, 0, result, NULL, NULL ); + } ++ else if (flags == DISPATCH_METHOD) ++ { ++ IWbemClassObject *sig_in, *in, *out = NULL; ++ VARIANT path; ++ int i; ++ BSTR param; ++ ++ if (!params->cArgs || !params->rgvarg) ++ { ++ WARN( "Missing property value\n" ); ++ return E_INVALIDARG; ++ } ++ ++ hr = IWbemClassObject_GetMethod( object->object, name, 0, &sig_in, NULL ); ++ if (FAILED(hr)) ++ return hr; ++ ++ hr = IWbemClassObject_SpawnInstance( sig_in, 0, &in ); ++ IWbemClassObject_Release( sig_in ); ++ if (FAILED(hr)) ++ return hr; ++ ++ IWbemClassObject_BeginEnumeration( in, 0 ); ++ i = params->cArgs - 1; ++ while (IWbemClassObject_Next( in, 0, ¶m, NULL, NULL, NULL ) == S_OK) ++ { ++ TRACE("Param %s = %s\n", debugstr_w(param), debugstr_variant(¶ms->rgvarg[i])); ++ hr = IWbemClassObject_Put( in, param, 0, ¶ms->rgvarg[i], 0 ); ++ SysFreeString( param ); ++ if (FAILED(hr)) ++ { ++ WARN("Failed to set paramter\n"); ++ break; ++ } ++ i--; ++ } ++ IWbemClassObject_EndEnumeration( in ); ++ ++ V_VT( &path ) = VT_EMPTY; ++ hr = IWbemClassObject_Get( object->object, L"__PATH", 0, &path, NULL, NULL ); ++ if (FAILED(hr)) ++ { ++ IWbemClassObject_Release( in ); ++ return hr; ++ } ++ ++ hr = IWbemServices_ExecMethod( object->services->services, V_BSTR(&path), name, 0, NULL, in, &out, NULL ); ++ IWbemClassObject_Release( in ); ++ VariantClear(&path); ++ if (FAILED(hr)) ++ return hr; ++ ++ IWbemClassObject_BeginEnumeration( out, 0 ); ++ while (IWbemClassObject_Next( out, 0, ¶m, NULL, NULL, NULL ) == S_OK) ++ { ++ TRACE("Output parameter %s\n", debugstr_w(param)); ++ ++ if (i < 0) ++ { ++ ERR("Unexpected output parameter\n"); ++ hr = E_FAIL; ++ break; ++ } ++ if (!lstrcmpiW(param, L"ReturnValue")) ++ { ++ SysFreeString( param ); ++ continue; ++ } ++ hr = IWbemClassObject_Get( out, param, 0, V_VARIANTREF(¶ms->rgvarg[i]), NULL, NULL ); ++ if (FAILED(hr)) ++ { ++ ERR("Failed to get output paramter\n"); ++ break; ++ } ++ ++ SysFreeString( param ); ++ i--; ++ } ++ IWbemClassObject_EndEnumeration( out ); ++ ++ IWbemClassObject_Release( out ); ++ ++ return hr; ++ } + else if (flags == DISPATCH_PROPERTYPUT) + { + if (!params->cArgs || !params->rgvarg) +-- +2.30.2 + diff --git a/patches/wbemdisp-ISWbemObject-Invoke/0002-vbscript-Support-VT_BSTR-VT_ARRAY-Iterator.patch b/patches/wbemdisp-ISWbemObject-Invoke/0002-vbscript-Support-VT_BSTR-VT_ARRAY-Iterator.patch new file mode 100644 index 00000000..07aada9f --- /dev/null +++ b/patches/wbemdisp-ISWbemObject-Invoke/0002-vbscript-Support-VT_BSTR-VT_ARRAY-Iterator.patch @@ -0,0 +1,73 @@ +From 74016f3aae967c669ee1cebdf4d1ebc15c3719b0 Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Mon, 17 May 2021 18:18:44 +1000 +Subject: [PATCH 2/4] vbscript: Support VT_BSTR|VT_ARRAY Iterator + +This isn't correct and the patch 4 show that this is the case. + +The array being returned by Invoke, needs to convert the datatype +on return. + +Signed-off-by: Alistair Leslie-Hughes +--- + dlls/vbscript/interp.c | 1 + + dlls/vbscript/utils.c | 24 ++++++++++++++---------- + 2 files changed, 15 insertions(+), 10 deletions(-) + +diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c +index 11d95e57758..35a6165a819 100644 +--- a/dlls/vbscript/interp.c ++++ b/dlls/vbscript/interp.c +@@ -1422,6 +1422,7 @@ static HRESULT interp_newenum(exec_ctx_t *ctx) + V_UNKNOWN(r) = (IUnknown*)iter; + break; + } ++ case VT_BSTR|VT_ARRAY: + case VT_VARIANT|VT_ARRAY: + case VT_VARIANT|VT_ARRAY|VT_BYREF: { + IEnumVARIANT *iter; +diff --git a/dlls/vbscript/utils.c b/dlls/vbscript/utils.c +index d30842c52eb..c0b8b749038 100644 +--- a/dlls/vbscript/utils.c ++++ b/dlls/vbscript/utils.c +@@ -106,11 +106,20 @@ static HRESULT WINAPI safearray_iter_IEnumVARIANT_Next(IEnumVARIANT *iface, + if(!This->sa->cLocks) + ERR("SAFEARRAY not locked\n"); + +- v = (VARIANT*)(((BYTE*)This->sa->pvData) + This->i * This->sa->cbElements); +- V_VT(rgVar) = VT_EMPTY; +- hres = VariantCopy(rgVar, v); +- if(FAILED(hres)) +- return hres; ++ if (This->sa->fFeatures & FADF_VARIANT) ++ { ++ v = (VARIANT*)(((BYTE*)This->sa->pvData) + This->i * This->sa->cbElements); ++ V_VT(rgVar) = VT_EMPTY; ++ hres = VariantCopy(rgVar, v); ++ if(FAILED(hres)) ++ return hres; ++ } ++ else if (This->sa->fFeatures & FADF_BSTR) ++ { ++ BSTR bstr = *(BSTR*)(((BYTE*)This->sa->pvData) + This->i * This->sa->cbElements); ++ V_VT(rgVar) = VT_BSTR; ++ V_BSTR(rgVar) = SysAllocString(bstr); ++ } + + This->i++; + if(pCeltFetched) +@@ -165,11 +174,6 @@ HRESULT create_safearray_iter(SAFEARRAY *sa, IEnumVARIANT **ev) + safearray_iter *iter; + HRESULT hres; + +- if(sa && !(sa->fFeatures & FADF_VARIANT)) { +- FIXME("enumeration not supported: %x\n", sa->fFeatures); +- return E_NOTIMPL; +- } +- + iter = heap_alloc(sizeof(*iter)); + if(!iter) + return E_OUTOFMEMORY; +-- +2.30.2 + diff --git a/patches/wbemdisp-ISWbemObject-Invoke/0003-wbemprox-Support-VT_BYREF-in-to_longlong.patch b/patches/wbemdisp-ISWbemObject-Invoke/0003-wbemprox-Support-VT_BYREF-in-to_longlong.patch new file mode 100644 index 00000000..9f8866cb --- /dev/null +++ b/patches/wbemdisp-ISWbemObject-Invoke/0003-wbemprox-Support-VT_BYREF-in-to_longlong.patch @@ -0,0 +1,26 @@ +From 197bb91afcc7af54124fd5113f0acdb25fcf959d Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Sat, 29 May 2021 18:02:04 +1000 +Subject: [PATCH 3/4] wbemprox: Support VT_BYREF in to_longlong + +--- + dlls/wbemprox/query.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/dlls/wbemprox/query.c b/dlls/wbemprox/query.c +index ec2a43c3f5f..ccff6aa0b4f 100644 +--- a/dlls/wbemprox/query.c ++++ b/dlls/wbemprox/query.c +@@ -1305,6 +1305,9 @@ HRESULT to_longlong( VARIANT *var, LONGLONG *val, CIMTYPE *type ) + *val = 0; + return S_OK; + } ++ if (V_VT( var ) & VT_BYREF) ++ var = V_VARIANTREF( var ); ++ + if (V_VT( var ) & VT_ARRAY) + { + *val = (INT_PTR)to_array( var, type ); +-- +2.30.2 + diff --git a/patches/wbemdisp-ISWbemObject-Invoke/0004-vbscript-Add-wmi-test.patch b/patches/wbemdisp-ISWbemObject-Invoke/0004-vbscript-Add-wmi-test.patch new file mode 100644 index 00000000..9fea3f3b --- /dev/null +++ b/patches/wbemdisp-ISWbemObject-Invoke/0004-vbscript-Add-wmi-test.patch @@ -0,0 +1,60 @@ +From 78b65f3146f96f2682b7ae6805ed471448c76aba Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Sun, 30 May 2021 16:34:56 +1000 +Subject: [PATCH 4/4] vbscript: Add wmi test + +This shows that the data returned by the EnumKey call isn't the same type +as vbscript. At a source leve EnumKey returns a VT_BSTR|VT_ARRAY whereas +vbscript converts it a VT_ARRAY|VT_VARIANT*. + +--- + dlls/vbscript/tests/lang.vbs | 18 ++++++++++++++++++ + dlls/vbscript/tests/run.c | 5 +++++ + 2 files changed, 23 insertions(+) + +diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs +index a716cdbc65f..b8db3f5becf 100644 +--- a/dlls/vbscript/tests/lang.vbs ++++ b/dlls/vbscript/tests/lang.vbs +@@ -1896,4 +1896,22 @@ f1 not 1 = 0 + + arr (0) = 2 xor -2 + ++function wmi_array_bstr() ++const HKEY_LOCAL_MACHINE = &H80000002 ++Dim oReg ++ ++Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") ++ ++Dim strKeyPath, strSubkey, arrSubKeys ++strKeyPath = "Software\Microsoft\NET Framework Setup\NDP" ++oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys ++ ++Call ok(getVT(arrSubKeys) = "VT_ARRAY|VT_VARIANT*", "getVT(arrSubKeys) = " & getVT(arrSubKeys)) ++For Each strSubkey In arrSubKeys ++Next ++end function ++ ++Call wmi_array_bstr() ++ ++ + reportSuccess() +diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c +index bb33e6576ea..9d0fa1ef7d1 100644 +--- a/dlls/vbscript/tests/run.c ++++ b/dlls/vbscript/tests/run.c +@@ -183,6 +183,11 @@ static const char *vt2a(VARIANT *v) + sprintf(buf, "%s*", vt2a(V_BYREF(v))); + return buf; + } ++ else if(V_VT(v) == (VT_BYREF|VT_VARIANT|VT_ARRAY)) { ++ static char buf[64]; ++ sprintf(buf, "%s*", vt2a(V_BYREF(v))); ++ return buf; ++ } + + switch(V_VT(v)) { + case VT_EMPTY: +-- +2.30.2 + diff --git a/patches/wbemdisp-ISWbemObject-Invoke/definition b/patches/wbemdisp-ISWbemObject-Invoke/definition new file mode 100644 index 00000000..0ae0b2b6 --- /dev/null +++ b/patches/wbemdisp-ISWbemObject-Invoke/definition @@ -0,0 +1,5 @@ +Fixes: [51120] wbemdisp: Support DISPATCH_METHOD in ISWbemObject Invoke. +Fixes: [39463] vbscript: Support looping of data from WMI +# The vbscript patches aren't right but show what needs to be done +# and the first one has already been rejected. The vbscript test is +# what need to pass