Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/wbemdisp/locator.c | 82 ++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 41 deletions(-)
diff --git a/dlls/wbemdisp/locator.c b/dlls/wbemdisp/locator.c index 867a19c1ab2..deef4d83fb8 100644 --- a/dlls/wbemdisp/locator.c +++ b/dlls/wbemdisp/locator.c @@ -1059,50 +1059,52 @@ static HRESULT WINAPI object_GetTypeInfo( return E_NOTIMPL; }
+static BOOL object_reserve_member( struct object *object, unsigned int count, unsigned int *capacity ) +{ + unsigned int new_capacity, max_capacity; + struct member *new_members; + + if (count <= *capacity) + return TRUE; + + max_capacity = ~0u / sizeof(*object->members); + if (count > max_capacity) + return FALSE; + + new_capacity = max(4, *capacity); + while (new_capacity < count && new_capacity <= max_capacity / 2) + new_capacity *= 2; + if (new_capacity < count) + new_capacity = max_capacity; + + if (!(new_members = heap_realloc( object->members, new_capacity * sizeof(*new_members) ))) + return FALSE; + + object->members = new_members; + *capacity = new_capacity; + + return TRUE; +} + static HRESULT init_members( struct object *object ) { IWbemClassObject *sig_in, *sig_out; - LONG i = 0, count = 0; - BSTR name; + unsigned int i, capacity = 0, count = 0; HRESULT hr; + BSTR name;
if (object->members) return S_OK;
- hr = IWbemClassObject_BeginEnumeration( object->object, 0 ); - if (SUCCEEDED( hr )) - { - while (IWbemClassObject_Next( object->object, 0, NULL, NULL, NULL, NULL ) == S_OK) count++; - IWbemClassObject_EndEnumeration( object->object ); - } - - hr = IWbemClassObject_BeginMethodEnumeration( object->object, 0 ); - if (SUCCEEDED( hr )) - { - while (IWbemClassObject_NextMethod( object->object, 0, &name, &sig_in, &sig_out ) == S_OK) - { - count++; - SysFreeString( name ); - if (sig_in) IWbemClassObject_Release( sig_in ); - if (sig_out) IWbemClassObject_Release( sig_out ); - } - IWbemClassObject_EndMethodEnumeration( object->object ); - } - - if (!(object->members = heap_alloc( sizeof(struct member) * count ))) return E_OUTOFMEMORY; - hr = IWbemClassObject_BeginEnumeration( object->object, 0 ); if (SUCCEEDED( hr )) { while (IWbemClassObject_Next( object->object, 0, &name, NULL, NULL, NULL ) == S_OK) { - object->members[i].name = name; - object->members[i].is_method = FALSE; - object->members[i].dispid = 0; - if (++i > count) - { - IWbemClassObject_EndEnumeration( object->object ); - goto error; - } + if (!object_reserve_member( object, count + 1, &capacity )) goto error; + object->members[count].name = name; + object->members[count].is_method = FALSE; + object->members[count].dispid = 0; + count++; TRACE( "added property %s\n", debugstr_w(name) ); } IWbemClassObject_EndEnumeration( object->object ); @@ -1113,14 +1115,11 @@ static HRESULT init_members( struct object *object ) { while (IWbemClassObject_NextMethod( object->object, 0, &name, &sig_in, &sig_out ) == S_OK) { - object->members[i].name = name; - object->members[i].is_method = TRUE; - object->members[i].dispid = 0; - if (++i > count) - { - IWbemClassObject_EndMethodEnumeration( object->object ); - goto error; - } + if (!object_reserve_member( object, count + 1, &capacity )) goto error; + object->members[count].name = name; + object->members[count].is_method = TRUE; + object->members[count].dispid = 0; + count++; if (sig_in) IWbemClassObject_Release( sig_in ); if (sig_out) IWbemClassObject_Release( sig_out ); TRACE( "added method %s\n", debugstr_w(name) ); @@ -1133,7 +1132,8 @@ static HRESULT init_members( struct object *object ) return S_OK;
error: - for (--i; i >= 0; i--) SysFreeString( object->members[i].name ); + for (i = 0; i < count; ++i) + SysFreeString( object->members[i].name ); heap_free( object->members ); object->members = NULL; object->nb_members = 0;
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/wbemdisp/locator.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dlls/wbemdisp/locator.c b/dlls/wbemdisp/locator.c index deef4d83fb8..59a8150a155 100644 --- a/dlls/wbemdisp/locator.c +++ b/dlls/wbemdisp/locator.c @@ -527,6 +527,7 @@ struct member BSTR name; BOOL is_method; DISPID dispid; + CIMTYPE type; };
struct object @@ -1090,6 +1091,7 @@ static HRESULT init_members( struct object *object ) { IWbemClassObject *sig_in, *sig_out; unsigned int i, capacity = 0, count = 0; + CIMTYPE type; HRESULT hr; BSTR name;
@@ -1098,12 +1100,13 @@ static HRESULT init_members( struct object *object ) hr = IWbemClassObject_BeginEnumeration( object->object, 0 ); if (SUCCEEDED( hr )) { - while (IWbemClassObject_Next( object->object, 0, &name, NULL, NULL, NULL ) == S_OK) + while (IWbemClassObject_Next( object->object, 0, &name, NULL, &type, NULL ) == S_OK) { if (!object_reserve_member( object, count + 1, &capacity )) goto error; object->members[count].name = name; object->members[count].is_method = FALSE; object->members[count].dispid = 0; + object->members[count].type = type; count++; TRACE( "added property %s\n", debugstr_w(name) ); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=86264
Your paranoid android.
=== debiant2 (build log) ===
Task: WineTest did not produce the win32 report
=== debiant2 (build log) ===
Task: WineTest did not produce the wow32 report
Signed-off-by: Hans Leidekker hans@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/wbemdisp/locator.c | 54 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 4 deletions(-)
diff --git a/dlls/wbemdisp/locator.c b/dlls/wbemdisp/locator.c index 59a8150a155..8c37cc92eb1 100644 --- a/dlls/wbemdisp/locator.c +++ b/dlls/wbemdisp/locator.c @@ -1199,16 +1199,51 @@ static HRESULT WINAPI object_GetIDsOfNames( return S_OK; }
-static BSTR get_member_name( struct object *object, DISPID dispid ) +static BSTR get_member_name( struct object *object, DISPID dispid, CIMTYPE *type ) { UINT i; for (i = 0; i < object->nb_members; i++) { - if (object->members[i].dispid == dispid) return object->members[i].name; + if (object->members[i].dispid == dispid) + { + *type = object->members[i].type; + return object->members[i].name; + } } return NULL; }
+static VARTYPE to_vartype( CIMTYPE type ) +{ + switch (type) + { + case CIM_BOOLEAN: return VT_BOOL; + + case CIM_STRING: + case CIM_REFERENCE: + case CIM_DATETIME: return VT_BSTR; + + case CIM_SINT8: return VT_I1; + case CIM_UINT8: return VT_UI1; + case CIM_SINT16: return VT_I2; + + case CIM_UINT16: + case CIM_SINT32: return VT_I4; + + case CIM_UINT32: return VT_UI4; + + case CIM_SINT64: return VT_I8; + case CIM_UINT64: return VT_UI8; + + case CIM_REAL32: return VT_R4; + + default: + ERR("unhandled type %u\n", type); + break; + } + return 0; +} + static HRESULT WINAPI object_Invoke( ISWbemObject *iface, DISPID member, @@ -1223,6 +1258,9 @@ static HRESULT WINAPI object_Invoke( struct object *object = impl_from_ISWbemObject( iface ); BSTR name; ITypeInfo *typeinfo; + VARTYPE vartype; + VARIANT value; + CIMTYPE type; HRESULT hr;
TRACE( "%p, %x, %s, %u, %x, %p, %p, %p, %p\n", object, member, debugstr_guid(riid), @@ -1240,7 +1278,7 @@ static HRESULT WINAPI object_Invoke( return hr; }
- if (!(name = get_member_name( object, member ))) + if (!(name = get_member_name( object, member, &type ))) return DISP_E_MEMBERNOTFOUND;
if (flags == (DISPATCH_METHOD|DISPATCH_PROPERTYGET)) @@ -1255,7 +1293,15 @@ static HRESULT WINAPI object_Invoke( WARN( "Missing put property value\n" ); return E_INVALIDARG; } - return IWbemClassObject_Put( object->object, name, 0, params->rgvarg, 0 ); + + vartype = to_vartype( type ); + V_VT( &value ) = VT_EMPTY; + if (SUCCEEDED(hr = VariantChangeType( &value, params->rgvarg, 0, vartype ))) + { + hr = IWbemClassObject_Put( object->object, name, 0, &value, 0 ); + VariantClear( &value ); + } + return hr; } else {
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=86265
Your paranoid android.
=== debiant2 (build log) ===
Task: WineTest did not produce the win32 report
=== debiant2 (build log) ===
Task: WineTest did not produce the wow32 report
Signed-off-by: Hans Leidekker hans@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/wbemdisp/locator.c | 43 ++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-)
diff --git a/dlls/wbemdisp/locator.c b/dlls/wbemdisp/locator.c index 8c37cc92eb1..e2bcf09c6e3 100644 --- a/dlls/wbemdisp/locator.c +++ b/dlls/wbemdisp/locator.c @@ -35,6 +35,22 @@
WINE_DEFAULT_DEBUG_CHANNEL(wbemdisp);
+struct namedvalueset +{ + ISWbemNamedValueSet ISWbemNamedValueSet_iface; + LONG refs; + + IWbemContext *context; +}; + +static struct namedvalueset *unsafe_valueset_impl_from_IDispatch(IDispatch *iface); + +static IWbemContext * unsafe_get_context_from_namedvalueset( IDispatch *disp ) +{ + struct namedvalueset *valueset = unsafe_valueset_impl_from_IDispatch( disp ); + return valueset ? valueset->context : NULL; +} + static WCHAR *heap_strdupW( const WCHAR *src ) { WCHAR *dst; @@ -2751,6 +2767,7 @@ static HRESULT WINAPI locator_ConnectServer( { struct locator *locator = impl_from_ISWbemLocator( iface ); IWbemServices *services; + IWbemContext *context; BSTR resource; HRESULT hr;
@@ -2758,8 +2775,6 @@ static HRESULT WINAPI locator_ConnectServer( debugstr_w(strNamespace), debugstr_w(strUser), strPassword, debugstr_w(strLocale), debugstr_w(strAuthority), iSecurityFlags, objWbemNamedValueSet, objWbemServices );
- if (objWbemNamedValueSet) FIXME( "context not supported\n" ); - if (!locator->locator) { hr = CoCreateInstance( &CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER, &IID_IWbemLocator, @@ -2767,9 +2782,11 @@ static HRESULT WINAPI locator_ConnectServer( if (hr != S_OK) return hr; }
+ context = unsafe_get_context_from_namedvalueset( objWbemNamedValueSet ); + if (!(resource = build_resource_string( strServer, strNamespace ))) return E_OUTOFMEMORY; hr = IWbemLocator_ConnectServer( locator->locator, resource, strUser, strPassword, strLocale, - iSecurityFlags, strAuthority, NULL, &services ); + iSecurityFlags, strAuthority, context, &services ); SysFreeString( resource ); if (hr != S_OK) return hr;
@@ -3047,14 +3064,6 @@ static HRESULT ISWbemSecurity_create( ISWbemSecurity **obj ) return S_OK; }
-struct namedvalueset -{ - ISWbemNamedValueSet ISWbemNamedValueSet_iface; - LONG refs; - - IWbemContext *context; -}; - struct namedvalue { ISWbemNamedValue ISWbemNamedValue_iface; @@ -3478,6 +3487,18 @@ static const ISWbemNamedValueSetVtbl namedvalueset_vtbl = namedvalueset_DeleteAll, };
+static struct namedvalueset *unsafe_valueset_impl_from_IDispatch(IDispatch *iface) +{ + if (!iface) + return NULL; + if (iface->lpVtbl != (IDispatchVtbl *)&namedvalueset_vtbl) + { + FIXME( "External implementations are not supported.\n" ); + return NULL; + } + return CONTAINING_RECORD(iface, struct namedvalueset, ISWbemNamedValueSet_iface); +} + HRESULT SWbemNamedValueSet_create( void **obj ) { struct namedvalueset *set;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=86266
Your paranoid android.
=== debiant2 (build log) ===
Task: WineTest did not produce the win32 report
=== debiant2 (build log) ===
Task: WineTest did not produce the wow32 report
Signed-off-by: Hans Leidekker hans@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/wbemdisp/locator.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/wbemdisp/locator.c b/dlls/wbemdisp/locator.c index e2bcf09c6e3..0ef73bdbd56 100644 --- a/dlls/wbemdisp/locator.c +++ b/dlls/wbemdisp/locator.c @@ -2499,6 +2499,7 @@ static HRESULT WINAPI services_ExecMethod( struct services *services = impl_from_ISWbemServices( iface ); IWbemClassObject *out_params = NULL; struct object *in_params; + IWbemContext *context; HRESULT hr;
TRACE( "%p, %s, %s, %p, %#x, %p, %p\n", services, debugstr_w(path), debugstr_w(method), in_sparams, @@ -2507,10 +2508,9 @@ static HRESULT WINAPI services_ExecMethod( in_params = unsafe_object_impl_from_IDispatch( in_sparams ); out_params = NULL;
- if (valueset) - FIXME("Named value set is unused\n"); + context = unsafe_get_context_from_namedvalueset( valueset );
- hr = IWbemServices_ExecMethod( services->services, path, method, flags, NULL, in_params ? in_params->object : NULL, + hr = IWbemServices_ExecMethod( services->services, path, method, flags, context, in_params ? in_params->object : NULL, out_sparams ? &out_params : NULL, NULL );
if (SUCCEEDED(hr) && out_params)
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=86267
Your paranoid android.
=== debiant2 (build log) ===
Task: WineTest did not produce the win32 report
=== debiant2 (build log) ===
Task: WineTest did not produce the wow32 report
Signed-off-by: Hans Leidekker hans@codeweavers.com
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=86263
Your paranoid android.
=== debiant2 (build log) ===
Task: WineTest did not produce the win32 report
=== debiant2 (build log) ===
Task: WineTest did not produce the wow32 report