2 * Copyright 2013 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "wine/debug.h"
32 #include "wbemdisp_private.h"
33 #include "wbemdisp_classes.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(wbemdisp
);
39 ISWbemNamedValueSet ISWbemNamedValueSet_iface
;
42 IWbemContext
*context
;
45 static struct namedvalueset
*unsafe_valueset_impl_from_IDispatch(IDispatch
*iface
);
47 static IWbemContext
* unsafe_get_context_from_namedvalueset( IDispatch
*disp
)
49 struct namedvalueset
*valueset
= unsafe_valueset_impl_from_IDispatch( disp
);
50 return valueset
? valueset
->context
: NULL
;
55 static HRESULT
EnumVARIANT_create( struct services
*, IEnumWbemClassObject
*, IEnumVARIANT
** );
56 static HRESULT
ISWbemSecurity_create( ISWbemSecurity
** );
57 static HRESULT
SWbemObject_create( struct services
*, IWbemClassObject
*, ISWbemObject
** );
65 ISWbemPropertySet_tid
,
68 ISWbemNamedValueSet_tid
,
75 static ITypeLib
*wbemdisp_typelib
;
76 static ITypeInfo
*wbemdisp_typeinfo
[last_tid
];
78 static REFIID wbemdisp_tid_id
[] =
84 &IID_ISWbemPropertySet
,
87 &IID_ISWbemNamedValueSet
,
88 &IID_ISWbemNamedValue
,
93 static HRESULT
get_typeinfo( enum type_id tid
, ITypeInfo
**ret
)
97 if (!wbemdisp_typelib
)
101 hr
= LoadRegTypeLib( &LIBID_WbemScripting
, 1, 2, LOCALE_SYSTEM_DEFAULT
, &typelib
);
104 ERR( "LoadRegTypeLib failed: %#lx\n", hr
);
107 if (InterlockedCompareExchangePointer( (void **)&wbemdisp_typelib
, typelib
, NULL
))
108 ITypeLib_Release( typelib
);
110 if (!wbemdisp_typeinfo
[tid
])
114 hr
= ITypeLib_GetTypeInfoOfGuid( wbemdisp_typelib
, wbemdisp_tid_id
[tid
], &typeinfo
);
117 ERR( "GetTypeInfoOfGuid(%s) failed: %#lx\n", debugstr_guid(wbemdisp_tid_id
[tid
]), hr
);
120 if (InterlockedCompareExchangePointer( (void **)(wbemdisp_typeinfo
+ tid
), typeinfo
, NULL
))
121 ITypeInfo_Release( typeinfo
);
123 *ret
= wbemdisp_typeinfo
[tid
];
124 ITypeInfo_AddRef( *ret
);
130 ISWbemProperty ISWbemProperty_iface
;
132 IWbemClassObject
*object
;
136 static inline struct property
*impl_from_ISWbemProperty( ISWbemProperty
*iface
)
138 return CONTAINING_RECORD( iface
, struct property
, ISWbemProperty_iface
);
141 static ULONG WINAPI
property_AddRef( ISWbemProperty
*iface
)
143 struct property
*property
= impl_from_ISWbemProperty( iface
);
144 return InterlockedIncrement( &property
->refs
);
147 static ULONG WINAPI
property_Release( ISWbemProperty
*iface
)
149 struct property
*property
= impl_from_ISWbemProperty( iface
);
150 LONG refs
= InterlockedDecrement( &property
->refs
);
153 TRACE( "destroying %p\n", property
);
154 IWbemClassObject_Release( property
->object
);
155 SysFreeString( property
->name
);
161 static HRESULT WINAPI
property_QueryInterface( ISWbemProperty
*iface
, REFIID riid
, void **obj
)
163 struct property
*property
= impl_from_ISWbemProperty( iface
);
165 TRACE( "%p %s %p\n", property
, debugstr_guid(riid
), obj
);
167 if (IsEqualGUID( riid
, &IID_ISWbemProperty
) ||
168 IsEqualGUID( riid
, &IID_IDispatch
) ||
169 IsEqualGUID( riid
, &IID_IUnknown
))
175 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
176 return E_NOINTERFACE
;
178 ISWbemProperty_AddRef( iface
);
182 static HRESULT WINAPI
property_GetTypeInfoCount( ISWbemProperty
*iface
, UINT
*count
)
184 struct property
*property
= impl_from_ISWbemProperty( iface
);
185 TRACE( "%p, %p\n", property
, count
);
190 static HRESULT WINAPI
property_GetTypeInfo( ISWbemProperty
*iface
, UINT index
,
191 LCID lcid
, ITypeInfo
**info
)
193 struct property
*property
= impl_from_ISWbemProperty( iface
);
194 TRACE( "%p, %u, %#lx, %p\n", property
, index
, lcid
, info
);
196 return get_typeinfo( ISWbemProperty_tid
, info
);
199 static HRESULT WINAPI
property_GetIDsOfNames( ISWbemProperty
*iface
, REFIID riid
, LPOLESTR
*names
,
200 UINT count
, LCID lcid
, DISPID
*dispid
)
202 struct property
*property
= impl_from_ISWbemProperty( iface
);
206 TRACE( "%p, %s, %p, %u, %#lx, %p\n", property
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
208 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
210 hr
= get_typeinfo( ISWbemProperty_tid
, &typeinfo
);
213 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
214 ITypeInfo_Release( typeinfo
);
219 static HRESULT WINAPI
property_Invoke( ISWbemProperty
*iface
, DISPID member
, REFIID riid
,
220 LCID lcid
, WORD flags
, DISPPARAMS
*params
,
221 VARIANT
*result
, EXCEPINFO
*excep_info
, UINT
*arg_err
)
223 struct property
*property
= impl_from_ISWbemProperty( iface
);
227 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", property
, member
, debugstr_guid(riid
),
228 lcid
, flags
, params
, result
, excep_info
, arg_err
);
230 hr
= get_typeinfo( ISWbemProperty_tid
, &typeinfo
);
233 hr
= ITypeInfo_Invoke( typeinfo
, &property
->ISWbemProperty_iface
, member
, flags
,
234 params
, result
, excep_info
, arg_err
);
235 ITypeInfo_Release( typeinfo
);
240 static HRESULT WINAPI
property_get_Value( ISWbemProperty
*iface
, VARIANT
*value
)
242 struct property
*property
= impl_from_ISWbemProperty( iface
);
244 TRACE( "%p %p\n", property
, value
);
246 return IWbemClassObject_Get( property
->object
, property
->name
, 0, value
, NULL
, NULL
);
249 static HRESULT WINAPI
property_put_Value( ISWbemProperty
*iface
, VARIANT
*varValue
)
255 static HRESULT WINAPI
property_get_Name( ISWbemProperty
*iface
, BSTR
*strName
)
261 static HRESULT WINAPI
property_get_IsLocal( ISWbemProperty
*iface
, VARIANT_BOOL
*bIsLocal
)
267 static HRESULT WINAPI
property_get_Origin( ISWbemProperty
*iface
, BSTR
*strOrigin
)
273 static HRESULT WINAPI
property_get_CIMType( ISWbemProperty
*iface
, WbemCimtypeEnum
*iCimType
)
279 static HRESULT WINAPI
property_get_Qualifiers_( ISWbemProperty
*iface
, ISWbemQualifierSet
**objWbemQualifierSet
)
285 static HRESULT WINAPI
property_get_IsArray( ISWbemProperty
*iface
, VARIANT_BOOL
*bIsArray
)
291 static const ISWbemPropertyVtbl property_vtbl
=
293 property_QueryInterface
,
296 property_GetTypeInfoCount
,
297 property_GetTypeInfo
,
298 property_GetIDsOfNames
,
303 property_get_IsLocal
,
305 property_get_CIMType
,
306 property_get_Qualifiers_
,
310 static HRESULT
SWbemProperty_create( IWbemClassObject
*wbem_object
, BSTR name
, ISWbemProperty
**obj
)
312 struct property
*property
;
314 TRACE( "%p, %p\n", obj
, wbem_object
);
316 if (!(property
= malloc( sizeof(*property
) ))) return E_OUTOFMEMORY
;
317 property
->ISWbemProperty_iface
.lpVtbl
= &property_vtbl
;
319 property
->object
= wbem_object
;
320 IWbemClassObject_AddRef( property
->object
);
321 property
->name
= SysAllocStringLen( name
, SysStringLen( name
) );
322 *obj
= &property
->ISWbemProperty_iface
;
323 TRACE( "returning iface %p\n", *obj
);
329 ISWbemPropertySet ISWbemPropertySet_iface
;
331 IWbemClassObject
*object
;
334 static inline struct propertyset
*impl_from_ISWbemPropertySet(
335 ISWbemPropertySet
*iface
)
337 return CONTAINING_RECORD( iface
, struct propertyset
, ISWbemPropertySet_iface
);
340 static ULONG WINAPI
propertyset_AddRef( ISWbemPropertySet
*iface
)
342 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
343 return InterlockedIncrement( &propertyset
->refs
);
346 static ULONG WINAPI
propertyset_Release( ISWbemPropertySet
*iface
)
348 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
349 LONG refs
= InterlockedDecrement( &propertyset
->refs
);
352 TRACE( "destroying %p\n", propertyset
);
353 IWbemClassObject_Release( propertyset
->object
);
359 static HRESULT WINAPI
propertyset_QueryInterface( ISWbemPropertySet
*iface
,
360 REFIID riid
, void **obj
)
362 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
364 TRACE( "%p %s %p\n", propertyset
, debugstr_guid(riid
), obj
);
366 if (IsEqualGUID( riid
, &IID_ISWbemPropertySet
) ||
367 IsEqualGUID( riid
, &IID_IDispatch
) ||
368 IsEqualGUID( riid
, &IID_IUnknown
))
374 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
375 return E_NOINTERFACE
;
377 ISWbemPropertySet_AddRef( iface
);
381 static HRESULT WINAPI
propertyset_GetTypeInfoCount( ISWbemPropertySet
*iface
, UINT
*count
)
383 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
384 TRACE( "%p, %p\n", propertyset
, count
);
389 static HRESULT WINAPI
propertyset_GetTypeInfo( ISWbemPropertySet
*iface
,
390 UINT index
, LCID lcid
, ITypeInfo
**info
)
392 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
393 TRACE( "%p, %u, %#lx, %p\n", propertyset
, index
, lcid
, info
);
395 return get_typeinfo( ISWbemPropertySet_tid
, info
);
398 static HRESULT WINAPI
propertyset_GetIDsOfNames( ISWbemPropertySet
*iface
, REFIID riid
, LPOLESTR
*names
,
399 UINT count
, LCID lcid
, DISPID
*dispid
)
401 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
405 TRACE( "%p, %s, %p, %u, %#lx, %p\n", propertyset
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
407 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
409 hr
= get_typeinfo( ISWbemPropertySet_tid
, &typeinfo
);
412 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
413 ITypeInfo_Release( typeinfo
);
418 static HRESULT WINAPI
propertyset_Invoke( ISWbemPropertySet
*iface
, DISPID member
, REFIID riid
,
419 LCID lcid
, WORD flags
, DISPPARAMS
*params
,
420 VARIANT
*result
, EXCEPINFO
*excep_info
, UINT
*arg_err
)
422 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
426 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", propertyset
, member
, debugstr_guid(riid
),
427 lcid
, flags
, params
, result
, excep_info
, arg_err
);
429 hr
= get_typeinfo( ISWbemPropertySet_tid
, &typeinfo
);
432 hr
= ITypeInfo_Invoke( typeinfo
, &propertyset
->ISWbemPropertySet_iface
, member
, flags
,
433 params
, result
, excep_info
, arg_err
);
434 ITypeInfo_Release( typeinfo
);
439 static HRESULT WINAPI
propertyset_get__NewEnum( ISWbemPropertySet
*iface
, IUnknown
**unk
)
445 static HRESULT WINAPI
propertyset_Item( ISWbemPropertySet
*iface
, BSTR name
,
446 LONG flags
, ISWbemProperty
**prop
)
448 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
452 TRACE( "%p, %s, %#lx, %p\n", propertyset
, debugstr_w(name
), flags
, prop
);
454 hr
= IWbemClassObject_Get( propertyset
->object
, name
, 0, &var
, NULL
, NULL
);
457 hr
= SWbemProperty_create( propertyset
->object
, name
, prop
);
458 VariantClear( &var
);
463 static HRESULT WINAPI
propertyset_get_Count( ISWbemPropertySet
*iface
, LONG
*count
)
465 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
469 TRACE( "%p, %p\n", propertyset
, count
);
471 hr
= IWbemClassObject_Get( propertyset
->object
, L
"__PROPERTY_COUNT", 0, &val
, NULL
, NULL
);
474 *count
= V_I4( &val
);
479 static HRESULT WINAPI
propertyset_Add( ISWbemPropertySet
*iface
, BSTR name
, WbemCimtypeEnum type
,
480 VARIANT_BOOL is_array
, LONG flags
, ISWbemProperty
**prop
)
486 static HRESULT WINAPI
propertyset_Remove( ISWbemPropertySet
*iface
, BSTR name
, LONG flags
)
492 static const ISWbemPropertySetVtbl propertyset_vtbl
=
494 propertyset_QueryInterface
,
497 propertyset_GetTypeInfoCount
,
498 propertyset_GetTypeInfo
,
499 propertyset_GetIDsOfNames
,
501 propertyset_get__NewEnum
,
503 propertyset_get_Count
,
508 static HRESULT
SWbemPropertySet_create( IWbemClassObject
*wbem_object
, ISWbemPropertySet
**obj
)
510 struct propertyset
*propertyset
;
512 TRACE( "%p, %p\n", obj
, wbem_object
);
514 if (!(propertyset
= malloc( sizeof(*propertyset
) ))) return E_OUTOFMEMORY
;
515 propertyset
->ISWbemPropertySet_iface
.lpVtbl
= &propertyset_vtbl
;
516 propertyset
->refs
= 1;
517 propertyset
->object
= wbem_object
;
518 IWbemClassObject_AddRef( propertyset
->object
);
519 *obj
= &propertyset
->ISWbemPropertySet_iface
;
521 TRACE( "returning iface %p\n", *obj
);
527 ISWbemServices ISWbemServices_iface
;
529 IWbemServices
*services
;
542 ISWbemObject ISWbemObject_iface
;
544 IWbemClassObject
*object
;
545 struct member
*members
;
548 DISPID last_dispid_method
;
549 struct services
*services
;
554 ISWbemMethodSet ISWbemMethodSet_iface
;
556 struct object
*object
;
561 ISWbemMethod ISWbemMethod_iface
;
563 struct methodset
*set
;
567 static struct method
*impl_from_ISWbemMethod( ISWbemMethod
*iface
)
569 return CONTAINING_RECORD( iface
, struct method
, ISWbemMethod_iface
);
572 static HRESULT WINAPI
method_QueryInterface( ISWbemMethod
*iface
, REFIID riid
, void **ppvObject
)
574 struct method
*method
= impl_from_ISWbemMethod( iface
);
576 TRACE( "%p %s %p\n", method
, debugstr_guid(riid
), ppvObject
);
578 if (IsEqualGUID( riid
, &IID_ISWbemMethod
) ||
579 IsEqualGUID( riid
, &IID_IDispatch
) ||
580 IsEqualGUID( riid
, &IID_IUnknown
))
586 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
587 return E_NOINTERFACE
;
589 ISWbemMethod_AddRef( iface
);
593 static ULONG WINAPI
method_AddRef( ISWbemMethod
*iface
)
595 struct method
*method
= impl_from_ISWbemMethod( iface
);
596 return InterlockedIncrement( &method
->refs
);
599 static ULONG WINAPI
method_Release( ISWbemMethod
*iface
)
601 struct method
*method
= impl_from_ISWbemMethod( iface
);
602 LONG refs
= InterlockedDecrement( &method
->refs
);
605 TRACE( "destroying %p\n", method
);
606 ISWbemMethodSet_Release( &method
->set
->ISWbemMethodSet_iface
);
607 free( method
->name
);
613 static HRESULT WINAPI
method_GetTypeInfoCount(
617 struct method
*method
= impl_from_ISWbemMethod( iface
);
619 TRACE( "%p, %p\n", method
, count
);
624 static HRESULT WINAPI
method_GetTypeInfo(
630 struct method
*method
= impl_from_ISWbemMethod( iface
);
632 TRACE( "%p, %u, %#lx, %p\n", method
, index
, lcid
, info
);
634 return get_typeinfo( ISWbemMethod_tid
, info
);
637 static HRESULT WINAPI
method_GetIDsOfNames(
645 struct method
*method
= impl_from_ISWbemMethod( iface
);
649 TRACE( "%p, %s, %p, %u, %#lx, %p\n", method
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
651 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
653 hr
= get_typeinfo( ISWbemMethod_tid
, &typeinfo
);
656 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
657 ITypeInfo_Release( typeinfo
);
662 static HRESULT WINAPI
method_Invoke(
670 EXCEPINFO
*excep_info
,
673 struct method
*method
= impl_from_ISWbemMethod( iface
);
677 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", method
, member
, debugstr_guid(riid
),
678 lcid
, flags
, params
, result
, excep_info
, arg_err
);
680 hr
= get_typeinfo( ISWbemMethod_tid
, &typeinfo
);
683 hr
= ITypeInfo_Invoke( typeinfo
, &method
->ISWbemMethod_iface
, member
, flags
,
684 params
, result
, excep_info
, arg_err
);
685 ITypeInfo_Release( typeinfo
);
690 static HRESULT WINAPI
method_get_Name(
699 static HRESULT WINAPI
method_get_Origin(
708 static HRESULT WINAPI
method_get_InParameters(
710 ISWbemObject
**params
)
712 struct method
*method
= impl_from_ISWbemMethod( iface
);
713 IWbemClassObject
*in_sign
= NULL
, *instance
;
716 TRACE("%p, %p\n", method
, params
);
720 if (SUCCEEDED(hr
= IWbemClassObject_GetMethod( method
->set
->object
->object
,
721 method
->name
, 0, &in_sign
, NULL
)) && in_sign
!= NULL
)
723 hr
= IWbemClassObject_SpawnInstance( in_sign
, 0, &instance
);
724 IWbemClassObject_Release( in_sign
);
727 hr
= SWbemObject_create( method
->set
->object
->services
, instance
, params
);
728 IWbemClassObject_Release( instance
);
735 static HRESULT WINAPI
method_get_OutParameters(
737 ISWbemObject
**params
)
744 static HRESULT WINAPI
method_get_Qualifiers_(
746 ISWbemQualifierSet
**qualifiers
)
753 static const ISWbemMethodVtbl methodvtbl
=
755 method_QueryInterface
,
758 method_GetTypeInfoCount
,
760 method_GetIDsOfNames
,
764 method_get_InParameters
,
765 method_get_OutParameters
,
766 method_get_Qualifiers_
,
769 static HRESULT
SWbemMethod_create( struct methodset
*set
, const WCHAR
*name
, ISWbemMethod
**obj
)
771 struct method
*method
;
773 if (!(method
= malloc( sizeof(*method
) ))) return E_OUTOFMEMORY
;
775 method
->ISWbemMethod_iface
.lpVtbl
= &methodvtbl
;
778 ISWbemMethodSet_AddRef( &method
->set
->ISWbemMethodSet_iface
);
779 if (!(method
->name
= wcsdup( name
)))
781 ISWbemMethod_Release( &method
->ISWbemMethod_iface
);
782 return E_OUTOFMEMORY
;
785 *obj
= &method
->ISWbemMethod_iface
;
790 static struct methodset
*impl_from_ISWbemMethodSet( ISWbemMethodSet
*iface
)
792 return CONTAINING_RECORD( iface
, struct methodset
, ISWbemMethodSet_iface
);
795 static HRESULT WINAPI
methodset_QueryInterface( ISWbemMethodSet
*iface
, REFIID riid
, void **ppvObject
)
797 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
799 TRACE( "%p %s %p\n", set
, debugstr_guid(riid
), ppvObject
);
801 if (IsEqualGUID( riid
, &IID_ISWbemMethodSet
) ||
802 IsEqualGUID( riid
, &IID_IDispatch
) ||
803 IsEqualGUID( riid
, &IID_IUnknown
))
809 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
810 return E_NOINTERFACE
;
812 ISWbemMethodSet_AddRef( iface
);
816 static ULONG WINAPI
methodset_AddRef( ISWbemMethodSet
*iface
)
818 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
819 return InterlockedIncrement( &set
->refs
);
822 static ULONG WINAPI
methodset_Release( ISWbemMethodSet
*iface
)
824 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
825 LONG refs
= InterlockedDecrement( &set
->refs
);
828 TRACE( "destroying %p\n", set
);
829 ISWbemObject_Release( &set
->object
->ISWbemObject_iface
);
835 static HRESULT WINAPI
methodset_GetTypeInfoCount(
836 ISWbemMethodSet
*iface
,
839 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
841 TRACE( "%p, %p\n", set
, count
);
846 static HRESULT WINAPI
methodset_GetTypeInfo( ISWbemMethodSet
*iface
,
851 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
853 TRACE( "%p, %u, %#lx, %p\n", set
, index
, lcid
, info
);
855 return get_typeinfo( ISWbemMethodSet_tid
, info
);
858 static HRESULT WINAPI
methodset_GetIDsOfNames(
859 ISWbemMethodSet
*iface
,
866 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
870 TRACE( "%p, %s, %p, %u, %#lx, %p\n", set
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
872 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
874 hr
= get_typeinfo( ISWbemMethodSet_tid
, &typeinfo
);
877 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
878 ITypeInfo_Release( typeinfo
);
883 static HRESULT WINAPI
methodset_Invoke(
884 ISWbemMethodSet
*iface
,
891 EXCEPINFO
*excep_info
,
894 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
898 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", set
, member
, debugstr_guid(riid
),
899 lcid
, flags
, params
, result
, excep_info
, arg_err
);
901 hr
= get_typeinfo( ISWbemMethodSet_tid
, &typeinfo
);
904 hr
= ITypeInfo_Invoke( typeinfo
, &set
->ISWbemMethodSet_iface
, member
, flags
,
905 params
, result
, excep_info
, arg_err
);
906 ITypeInfo_Release( typeinfo
);
911 static HRESULT WINAPI
methodset_get__NewEnum(
912 ISWbemMethodSet
*iface
,
920 static HRESULT WINAPI
methodset_Item(
921 ISWbemMethodSet
*iface
,
924 ISWbemMethod
**method
)
926 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
927 IWbemClassObject
*in_sign
, *out_sign
;
930 TRACE("%p, %s, %#lx, %p\n", set
, debugstr_w(name
), flags
, method
);
934 if (SUCCEEDED(hr
= IWbemClassObject_GetMethod( set
->object
->object
,
935 name
, flags
, &in_sign
, &out_sign
)))
938 IWbemClassObject_Release( in_sign
);
940 IWbemClassObject_Release( out_sign
);
942 return SWbemMethod_create( set
, name
, method
);
948 static HRESULT WINAPI
methodset_get_Count(
949 ISWbemMethodSet
*iface
,
957 static const ISWbemMethodSetVtbl methodsetvtbl
=
959 methodset_QueryInterface
,
962 methodset_GetTypeInfoCount
,
963 methodset_GetTypeInfo
,
964 methodset_GetIDsOfNames
,
966 methodset_get__NewEnum
,
971 static HRESULT
SWbemMethodSet_create( struct object
*object
, ISWbemMethodSet
**obj
)
973 struct methodset
*set
;
975 if (!(set
= malloc( sizeof(*set
) ))) return E_OUTOFMEMORY
;
977 set
->ISWbemMethodSet_iface
.lpVtbl
= &methodsetvtbl
;
979 set
->object
= object
;
980 ISWbemObject_AddRef( &object
->ISWbemObject_iface
);
982 *obj
= &set
->ISWbemMethodSet_iface
;
987 #define DISPID_BASE 0x1800000
988 #define DISPID_BASE_METHOD 0x1000000
990 static inline struct object
*impl_from_ISWbemObject(
991 ISWbemObject
*iface
)
993 return CONTAINING_RECORD( iface
, struct object
, ISWbemObject_iface
);
996 static ULONG WINAPI
object_AddRef(
997 ISWbemObject
*iface
)
999 struct object
*object
= impl_from_ISWbemObject( iface
);
1000 return InterlockedIncrement( &object
->refs
);
1003 static ULONG WINAPI
object_Release(
1004 ISWbemObject
*iface
)
1006 struct object
*object
= impl_from_ISWbemObject( iface
);
1007 LONG refs
= InterlockedDecrement( &object
->refs
);
1012 TRACE( "destroying %p\n", object
);
1013 IWbemClassObject_Release( object
->object
);
1014 ISWbemServices_Release( &object
->services
->ISWbemServices_iface
);
1015 for (i
= 0; i
< object
->nb_members
; i
++) SysFreeString( object
->members
[i
].name
);
1016 free( object
->members
);
1022 static HRESULT WINAPI
object_QueryInterface(
1023 ISWbemObject
*iface
,
1027 struct object
*object
= impl_from_ISWbemObject( iface
);
1029 TRACE( "%p %s %p\n", object
, debugstr_guid(riid
), ppvObject
);
1031 if (IsEqualGUID( riid
, &IID_ISWbemObject
) ||
1032 IsEqualGUID( riid
, &IID_IDispatch
) ||
1033 IsEqualGUID( riid
, &IID_IUnknown
))
1039 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
1040 return E_NOINTERFACE
;
1042 ISWbemObject_AddRef( iface
);
1046 static HRESULT WINAPI
object_GetTypeInfoCount(
1047 ISWbemObject
*iface
,
1050 struct object
*object
= impl_from_ISWbemObject( iface
);
1052 TRACE( "%p, %p\n", object
, count
);
1057 static HRESULT WINAPI
object_GetTypeInfo(
1058 ISWbemObject
*iface
,
1063 struct object
*object
= impl_from_ISWbemObject( iface
);
1064 FIXME( "%p, %u, %#lx, %p\n", object
, index
, lcid
, info
);
1068 static BOOL
object_reserve_member( struct object
*object
, unsigned int count
, unsigned int *capacity
)
1070 unsigned int new_capacity
, max_capacity
;
1071 struct member
*new_members
;
1073 if (count
<= *capacity
)
1076 max_capacity
= ~0u / sizeof(*object
->members
);
1077 if (count
> max_capacity
)
1080 new_capacity
= max(4, *capacity
);
1081 while (new_capacity
< count
&& new_capacity
<= max_capacity
/ 2)
1083 if (new_capacity
< count
)
1084 new_capacity
= max_capacity
;
1086 if (!(new_members
= realloc( object
->members
, new_capacity
* sizeof(*new_members
) )))
1089 object
->members
= new_members
;
1090 *capacity
= new_capacity
;
1095 static HRESULT
init_members( struct object
*object
)
1097 IWbemClassObject
*sig_in
, *sig_out
;
1098 unsigned int i
, capacity
= 0, count
= 0;
1103 if (object
->members
) return S_OK
;
1105 hr
= IWbemClassObject_BeginEnumeration( object
->object
, 0 );
1106 if (SUCCEEDED( hr
))
1108 while (IWbemClassObject_Next( object
->object
, 0, &name
, NULL
, &type
, NULL
) == S_OK
)
1110 if (!object_reserve_member( object
, count
+ 1, &capacity
)) goto error
;
1111 object
->members
[count
].name
= name
;
1112 object
->members
[count
].is_method
= FALSE
;
1113 object
->members
[count
].dispid
= 0;
1114 object
->members
[count
].type
= type
;
1116 TRACE( "added property %s\n", debugstr_w(name
) );
1118 IWbemClassObject_EndEnumeration( object
->object
);
1121 hr
= IWbemClassObject_BeginMethodEnumeration( object
->object
, 0 );
1122 if (SUCCEEDED( hr
))
1124 while (IWbemClassObject_NextMethod( object
->object
, 0, &name
, &sig_in
, &sig_out
) == S_OK
)
1126 if (!object_reserve_member( object
, count
+ 1, &capacity
)) goto error
;
1127 object
->members
[count
].name
= name
;
1128 object
->members
[count
].is_method
= TRUE
;
1129 object
->members
[count
].dispid
= 0;
1131 if (sig_in
) IWbemClassObject_Release( sig_in
);
1132 if (sig_out
) IWbemClassObject_Release( sig_out
);
1133 TRACE( "added method %s\n", debugstr_w(name
) );
1135 IWbemClassObject_EndMethodEnumeration( object
->object
);
1138 object
->nb_members
= count
;
1139 TRACE( "added %u members\n", object
->nb_members
);
1143 for (i
= 0; i
< count
; ++i
)
1144 SysFreeString( object
->members
[i
].name
);
1145 free( object
->members
);
1146 object
->members
= NULL
;
1147 object
->nb_members
= 0;
1151 static DISPID
get_member_dispid( struct object
*object
, const WCHAR
*name
)
1154 for (i
= 0; i
< object
->nb_members
; i
++)
1156 if (!wcsicmp( object
->members
[i
].name
, name
))
1158 if (!object
->members
[i
].dispid
)
1160 if (object
->members
[i
].is_method
)
1161 object
->members
[i
].dispid
= ++object
->last_dispid_method
;
1163 object
->members
[i
].dispid
= ++object
->last_dispid
;
1165 return object
->members
[i
].dispid
;
1168 return DISPID_UNKNOWN
;
1171 static HRESULT WINAPI
object_GetIDsOfNames(
1172 ISWbemObject
*iface
,
1179 struct object
*object
= impl_from_ISWbemObject( iface
);
1182 ITypeInfo
*typeinfo
;
1184 TRACE( "%p, %s, %p, %u, %#lx, %p\n", object
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
1186 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
1188 hr
= init_members( object
);
1189 if (FAILED( hr
)) return hr
;
1191 hr
= get_typeinfo( ISWbemObject_tid
, &typeinfo
);
1194 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
1195 ITypeInfo_Release( typeinfo
);
1197 if (SUCCEEDED(hr
)) return hr
;
1199 for (i
= 0; i
< count
; i
++)
1201 if ((dispid
[i
] = get_member_dispid( object
, names
[i
] )) == DISPID_UNKNOWN
) break;
1203 if (i
!= count
) return DISP_E_UNKNOWNNAME
;
1207 static BSTR
get_member_name( struct object
*object
, DISPID dispid
, CIMTYPE
*type
)
1210 for (i
= 0; i
< object
->nb_members
; i
++)
1212 if (object
->members
[i
].dispid
== dispid
)
1214 *type
= object
->members
[i
].type
;
1215 return object
->members
[i
].name
;
1221 static VARTYPE
to_vartype( CIMTYPE type
)
1225 case CIM_BOOLEAN
: return VT_BOOL
;
1229 case CIM_DATETIME
: return VT_BSTR
;
1231 case CIM_SINT8
: return VT_I1
;
1232 case CIM_UINT8
: return VT_UI1
;
1233 case CIM_SINT16
: return VT_I2
;
1236 case CIM_SINT32
: return VT_I4
;
1238 case CIM_UINT32
: return VT_UI4
;
1240 case CIM_SINT64
: return VT_I8
;
1241 case CIM_UINT64
: return VT_UI8
;
1243 case CIM_REAL32
: return VT_R4
;
1246 ERR( "unhandled type %lu\n", type
);
1252 static HRESULT WINAPI
object_Invoke(
1253 ISWbemObject
*iface
,
1260 EXCEPINFO
*excep_info
,
1263 struct object
*object
= impl_from_ISWbemObject( iface
);
1265 ITypeInfo
*typeinfo
;
1271 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", object
, member
, debugstr_guid(riid
),
1272 lcid
, flags
, params
, result
, excep_info
, arg_err
);
1274 if (member
<= DISPID_BASE_METHOD
)
1276 hr
= get_typeinfo( ISWbemObject_tid
, &typeinfo
);
1279 hr
= ITypeInfo_Invoke( typeinfo
, &object
->ISWbemObject_iface
, member
, flags
,
1280 params
, result
, excep_info
, arg_err
);
1281 ITypeInfo_Release( typeinfo
);
1286 if (!(name
= get_member_name( object
, member
, &type
)))
1287 return DISP_E_MEMBERNOTFOUND
;
1289 if (flags
== (DISPATCH_METHOD
|DISPATCH_PROPERTYGET
) ||
1290 flags
== DISPATCH_PROPERTYGET
)
1292 memset( params
, 0, sizeof(*params
) );
1293 return IWbemClassObject_Get( object
->object
, name
, 0, result
, NULL
, NULL
);
1295 else if (flags
== DISPATCH_PROPERTYPUT
)
1297 if (!params
->cArgs
|| !params
->rgvarg
)
1299 WARN( "Missing put property value\n" );
1300 return E_INVALIDARG
;
1303 vartype
= to_vartype( type
);
1304 V_VT( &value
) = VT_EMPTY
;
1305 if (SUCCEEDED(hr
= VariantChangeType( &value
, params
->rgvarg
, 0, vartype
)))
1307 hr
= IWbemClassObject_Put( object
->object
, name
, 0, &value
, 0 );
1308 VariantClear( &value
);
1314 FIXME( "flags %#x not supported\n", flags
);
1319 static HRESULT WINAPI
object_Put_(
1320 ISWbemObject
*iface
,
1322 IDispatch
*objWbemNamedValueSet
,
1323 ISWbemObjectPath
**objWbemObjectPath
)
1329 static HRESULT WINAPI
object_PutAsync_(
1330 ISWbemObject
*iface
,
1331 IDispatch
*objWbemSink
,
1333 IDispatch
*objWbemNamedValueSet
,
1334 IDispatch
*objWbemAsyncContext
)
1340 static HRESULT WINAPI
object_Delete_(
1341 ISWbemObject
*iface
,
1343 IDispatch
*objWbemNamedValueSet
)
1349 static HRESULT WINAPI
object_DeleteAsync_(
1350 ISWbemObject
*iface
,
1351 IDispatch
*objWbemSink
,
1353 IDispatch
*objWbemNamedValueSet
,
1354 IDispatch
*objWbemAsyncContext
)
1360 static HRESULT WINAPI
object_Instances_(
1361 ISWbemObject
*iface
,
1363 IDispatch
*objWbemNamedValueSet
,
1364 ISWbemObjectSet
**objWbemObjectSet
)
1370 static HRESULT WINAPI
object_InstancesAsync_(
1371 ISWbemObject
*iface
,
1372 IDispatch
*objWbemSink
,
1374 IDispatch
*objWbemNamedValueSet
,
1375 IDispatch
*objWbemAsyncContext
)
1381 static HRESULT WINAPI
object_Subclasses_(
1382 ISWbemObject
*iface
,
1384 IDispatch
*objWbemNamedValueSet
,
1385 ISWbemObjectSet
**objWbemObjectSet
)
1391 static HRESULT WINAPI
object_SubclassesAsync_(
1392 ISWbemObject
*iface
,
1393 IDispatch
*objWbemSink
,
1395 IDispatch
*objWbemNamedValueSet
,
1396 IDispatch
*objWbemAsyncContext
)
1402 static HRESULT WINAPI
object_Associators_(
1403 ISWbemObject
*iface
,
1405 BSTR strResultClass
,
1408 VARIANT_BOOL bClassesOnly
,
1409 VARIANT_BOOL bSchemaOnly
,
1410 BSTR strRequiredAssocQualifier
,
1411 BSTR strRequiredQualifier
,
1413 IDispatch
*objWbemNamedValueSet
,
1414 ISWbemObjectSet
**objWbemObjectSet
)
1420 static HRESULT WINAPI
object_AssociatorsAsync_(
1421 ISWbemObject
*iface
,
1422 IDispatch
*objWbemSink
,
1424 BSTR strResultClass
,
1427 VARIANT_BOOL bClassesOnly
,
1428 VARIANT_BOOL bSchemaOnly
,
1429 BSTR strRequiredAssocQualifier
,
1430 BSTR strRequiredQualifier
,
1432 IDispatch
*objWbemNamedValueSet
,
1433 IDispatch
*objWbemAsyncContext
)
1439 static HRESULT WINAPI
object_References_(
1440 ISWbemObject
*iface
,
1441 BSTR strResultClass
,
1443 VARIANT_BOOL bClassesOnly
,
1444 VARIANT_BOOL bSchemaOnly
,
1445 BSTR strRequiredQualifier
,
1447 IDispatch
*objWbemNamedValueSet
,
1448 ISWbemObjectSet
**objWbemObjectSet
)
1454 static HRESULT WINAPI
object_ReferencesAsync_(
1455 ISWbemObject
*iface
,
1456 IDispatch
*objWbemSink
,
1457 BSTR strResultClass
,
1459 VARIANT_BOOL bClassesOnly
,
1460 VARIANT_BOOL bSchemaOnly
,
1461 BSTR strRequiredQualifier
,
1463 IDispatch
*objWbemNamedValueSet
,
1464 IDispatch
*objWbemAsyncContext
)
1470 static HRESULT WINAPI
object_ExecMethod_(
1471 ISWbemObject
*iface
,
1473 IDispatch
*in_params
,
1475 IDispatch
*valueset
,
1476 ISWbemObject
**out_params
)
1478 struct object
*object
= impl_from_ISWbemObject( iface
);
1482 TRACE( "%p, %s, %p, %#lx, %p, %p\n", object
, debugstr_w(method
), in_params
, flags
, valueset
, out_params
);
1484 V_VT( &path
) = VT_EMPTY
;
1485 hr
= IWbemClassObject_Get( object
->object
, L
"__PATH", 0, &path
, NULL
, NULL
);
1488 if (V_VT( &path
) != VT_BSTR
)
1490 WARN( "Unexpected object path value type.\n" );
1491 VariantClear( &path
);
1492 return E_UNEXPECTED
;
1495 hr
= ISWbemServices_ExecMethod( &object
->services
->ISWbemServices_iface
, V_BSTR( &path
), method
,
1496 in_params
, flags
, valueset
, out_params
);
1498 VariantClear( &path
);
1504 static HRESULT WINAPI
object_ExecMethodAsync_(
1505 ISWbemObject
*iface
,
1506 IDispatch
*objWbemSink
,
1508 IDispatch
*objWbemInParameters
,
1510 IDispatch
*objWbemNamedValueSet
,
1511 IDispatch
*objWbemAsyncContext
)
1517 static HRESULT WINAPI
object_Clone_(
1518 ISWbemObject
*iface
,
1519 ISWbemObject
**objWbemObject
)
1525 static HRESULT WINAPI
object_GetObjectText_(
1526 ISWbemObject
*iface
,
1530 struct object
*object
= impl_from_ISWbemObject( iface
);
1532 TRACE( "%p, %#lx, %p\n", object
, flags
, text
);
1534 return IWbemClassObject_GetObjectText( object
->object
, flags
, text
);
1537 static HRESULT WINAPI
object_SpawnDerivedClass_(
1538 ISWbemObject
*iface
,
1540 ISWbemObject
**objWbemObject
)
1546 static HRESULT WINAPI
object_SpawnInstance_(
1547 ISWbemObject
*iface
,
1549 ISWbemObject
**objWbemObject
)
1555 static HRESULT WINAPI
object_CompareTo_(
1556 ISWbemObject
*iface
,
1557 IDispatch
*objWbemObject
,
1559 VARIANT_BOOL
*bResult
)
1565 static HRESULT WINAPI
object_get_Qualifiers_(
1566 ISWbemObject
*iface
,
1567 ISWbemQualifierSet
**objWbemQualifierSet
)
1573 static HRESULT WINAPI
object_get_Properties_( ISWbemObject
*iface
, ISWbemPropertySet
**prop_set
)
1575 struct object
*object
= impl_from_ISWbemObject( iface
);
1577 TRACE( "%p, %p\n", object
, prop_set
);
1578 return SWbemPropertySet_create( object
->object
, prop_set
);
1581 static HRESULT WINAPI
object_get_Methods_(
1582 ISWbemObject
*iface
,
1583 ISWbemMethodSet
**set
)
1585 struct object
*object
= impl_from_ISWbemObject( iface
);
1587 TRACE( "%p, %p\n", object
, set
);
1588 return SWbemMethodSet_create( object
, set
);
1591 static HRESULT WINAPI
object_get_Derivation_(
1592 ISWbemObject
*iface
,
1593 VARIANT
*strClassNameArray
)
1599 static HRESULT WINAPI
object_get_Path_(
1600 ISWbemObject
*iface
,
1601 ISWbemObjectPath
**objWbemObjectPath
)
1607 static HRESULT WINAPI
object_get_Security_(
1608 ISWbemObject
*iface
,
1609 ISWbemSecurity
**objWbemSecurity
)
1615 static const ISWbemObjectVtbl object_vtbl
=
1617 object_QueryInterface
,
1620 object_GetTypeInfoCount
,
1622 object_GetIDsOfNames
,
1627 object_DeleteAsync_
,
1629 object_InstancesAsync_
,
1631 object_SubclassesAsync_
,
1632 object_Associators_
,
1633 object_AssociatorsAsync_
,
1635 object_ReferencesAsync_
,
1637 object_ExecMethodAsync_
,
1639 object_GetObjectText_
,
1640 object_SpawnDerivedClass_
,
1641 object_SpawnInstance_
,
1643 object_get_Qualifiers_
,
1644 object_get_Properties_
,
1645 object_get_Methods_
,
1646 object_get_Derivation_
,
1648 object_get_Security_
1651 static struct object
*unsafe_object_impl_from_IDispatch(IDispatch
*iface
)
1655 if (iface
->lpVtbl
!= (IDispatchVtbl
*)&object_vtbl
)
1657 FIXME( "External implementations are not supported.\n" );
1660 return CONTAINING_RECORD(iface
, struct object
, ISWbemObject_iface
);
1663 static HRESULT
SWbemObject_create( struct services
*services
, IWbemClassObject
*wbem_object
,
1664 ISWbemObject
**obj
)
1666 struct object
*object
;
1668 TRACE( "%p, %p\n", obj
, wbem_object
);
1670 if (!(object
= malloc( sizeof(*object
) ))) return E_OUTOFMEMORY
;
1671 object
->ISWbemObject_iface
.lpVtbl
= &object_vtbl
;
1673 object
->object
= wbem_object
;
1674 IWbemClassObject_AddRef( object
->object
);
1675 object
->members
= NULL
;
1676 object
->nb_members
= 0;
1677 object
->last_dispid
= DISPID_BASE
;
1678 object
->last_dispid_method
= DISPID_BASE_METHOD
;
1679 object
->services
= services
;
1680 ISWbemServices_AddRef( &object
->services
->ISWbemServices_iface
);
1682 *obj
= &object
->ISWbemObject_iface
;
1683 TRACE( "returning iface %p\n", *obj
);
1689 ISWbemObjectSet ISWbemObjectSet_iface
;
1691 IEnumWbemClassObject
*objectenum
;
1693 struct services
*services
;
1696 static inline struct objectset
*impl_from_ISWbemObjectSet(
1697 ISWbemObjectSet
*iface
)
1699 return CONTAINING_RECORD( iface
, struct objectset
, ISWbemObjectSet_iface
);
1702 static ULONG WINAPI
objectset_AddRef(
1703 ISWbemObjectSet
*iface
)
1705 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1706 return InterlockedIncrement( &objectset
->refs
);
1709 static ULONG WINAPI
objectset_Release(
1710 ISWbemObjectSet
*iface
)
1712 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1713 LONG refs
= InterlockedDecrement( &objectset
->refs
);
1716 TRACE( "destroying %p\n", objectset
);
1717 IEnumWbemClassObject_Release( objectset
->objectenum
);
1718 ISWbemServices_Release( &objectset
->services
->ISWbemServices_iface
);
1724 static HRESULT WINAPI
objectset_QueryInterface(
1725 ISWbemObjectSet
*iface
,
1729 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1731 TRACE( "%p %s %p\n", objectset
, debugstr_guid(riid
), ppvObject
);
1733 if (IsEqualGUID( riid
, &IID_ISWbemObjectSet
) ||
1734 IsEqualGUID( riid
, &IID_IDispatch
) ||
1735 IsEqualGUID( riid
, &IID_IUnknown
))
1741 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
1742 return E_NOINTERFACE
;
1744 ISWbemObjectSet_AddRef( iface
);
1748 static HRESULT WINAPI
objectset_GetTypeInfoCount(
1749 ISWbemObjectSet
*iface
,
1752 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1753 TRACE( "%p, %p\n", objectset
, count
);
1758 static HRESULT WINAPI
objectset_GetTypeInfo(
1759 ISWbemObjectSet
*iface
,
1764 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1765 TRACE( "%p, %u, %#lx, %p\n", objectset
, index
, lcid
, info
);
1767 return get_typeinfo( ISWbemObjectSet_tid
, info
);
1770 static HRESULT WINAPI
objectset_GetIDsOfNames(
1771 ISWbemObjectSet
*iface
,
1778 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1779 ITypeInfo
*typeinfo
;
1782 TRACE( "%p, %s, %p, %u, %#lx, %p\n", objectset
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
1784 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
1786 hr
= get_typeinfo( ISWbemObjectSet_tid
, &typeinfo
);
1789 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
1790 ITypeInfo_Release( typeinfo
);
1795 static HRESULT WINAPI
objectset_Invoke(
1796 ISWbemObjectSet
*iface
,
1803 EXCEPINFO
*excep_info
,
1806 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1807 ITypeInfo
*typeinfo
;
1810 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", objectset
, member
, debugstr_guid(riid
),
1811 lcid
, flags
, params
, result
, excep_info
, arg_err
);
1813 hr
= get_typeinfo( ISWbemObjectSet_tid
, &typeinfo
);
1816 hr
= ITypeInfo_Invoke( typeinfo
, &objectset
->ISWbemObjectSet_iface
, member
, flags
,
1817 params
, result
, excep_info
, arg_err
);
1818 ITypeInfo_Release( typeinfo
);
1823 static HRESULT WINAPI
objectset_get__NewEnum(
1824 ISWbemObjectSet
*iface
,
1827 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1828 IEnumWbemClassObject
*objectenum
;
1831 TRACE( "%p, %p\n", objectset
, pUnk
);
1833 hr
= IEnumWbemClassObject_Clone( objectset
->objectenum
, &objectenum
);
1834 if (FAILED( hr
)) return hr
;
1836 hr
= EnumVARIANT_create( objectset
->services
, objectenum
, (IEnumVARIANT
**)pUnk
);
1837 IEnumWbemClassObject_Release( objectenum
);
1841 static HRESULT WINAPI
objectset_Item(
1842 ISWbemObjectSet
*iface
,
1845 ISWbemObject
**objWbemObject
)
1851 static HRESULT WINAPI
objectset_get_Count(
1852 ISWbemObjectSet
*iface
,
1855 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1857 TRACE( "%p, %p\n", objectset
, iCount
);
1859 *iCount
= objectset
->count
;
1863 static HRESULT WINAPI
objectset_get_Security_(
1864 ISWbemObjectSet
*iface
,
1865 ISWbemSecurity
**objWbemSecurity
)
1871 static HRESULT WINAPI
objectset_ItemIndex(
1872 ISWbemObjectSet
*iface
,
1874 ISWbemObject
**objWbemObject
)
1876 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1879 IEnumVARIANT
*enum_var
;
1882 TRACE( "%p, %ld, %p\n", objectset
, lIndex
, objWbemObject
);
1884 *objWbemObject
= NULL
;
1885 hr
= ISWbemObjectSet_get_Count( iface
, &count
);
1886 if (FAILED(hr
)) return hr
;
1888 if (lIndex
>= count
) return WBEM_E_NOT_FOUND
;
1890 hr
= ISWbemObjectSet_get__NewEnum( iface
, (IUnknown
**)&enum_var
);
1891 if (FAILED(hr
)) return hr
;
1893 IEnumVARIANT_Reset( enum_var
);
1894 hr
= IEnumVARIANT_Skip( enum_var
, lIndex
);
1896 hr
= IEnumVARIANT_Next( enum_var
, 1, &var
, NULL
);
1897 IEnumVARIANT_Release( enum_var
);
1901 if (V_VT( &var
) == VT_DISPATCH
)
1902 hr
= IDispatch_QueryInterface( V_DISPATCH( &var
), &IID_ISWbemObject
, (void **)objWbemObject
);
1904 hr
= WBEM_E_NOT_FOUND
;
1905 VariantClear( &var
);
1911 static const ISWbemObjectSetVtbl objectset_vtbl
=
1913 objectset_QueryInterface
,
1916 objectset_GetTypeInfoCount
,
1917 objectset_GetTypeInfo
,
1918 objectset_GetIDsOfNames
,
1920 objectset_get__NewEnum
,
1922 objectset_get_Count
,
1923 objectset_get_Security_
,
1927 static LONG
get_object_count( IEnumWbemClassObject
*iter
)
1930 while (IEnumWbemClassObject_Skip( iter
, WBEM_INFINITE
, 1 ) == S_OK
) count
++;
1931 IEnumWbemClassObject_Reset( iter
);
1935 static HRESULT
SWbemObjectSet_create( struct services
*services
, IEnumWbemClassObject
*wbem_objectenum
,
1936 ISWbemObjectSet
**obj
)
1938 struct objectset
*objectset
;
1940 TRACE( "%p, %p\n", obj
, wbem_objectenum
);
1942 if (!(objectset
= malloc( sizeof(*objectset
) ))) return E_OUTOFMEMORY
;
1943 objectset
->ISWbemObjectSet_iface
.lpVtbl
= &objectset_vtbl
;
1944 objectset
->refs
= 1;
1945 objectset
->objectenum
= wbem_objectenum
;
1946 IEnumWbemClassObject_AddRef( objectset
->objectenum
);
1947 objectset
->count
= get_object_count( objectset
->objectenum
);
1948 objectset
->services
= services
;
1949 ISWbemServices_AddRef( &services
->ISWbemServices_iface
);
1951 *obj
= &objectset
->ISWbemObjectSet_iface
;
1952 TRACE( "returning iface %p\n", *obj
);
1958 IEnumVARIANT IEnumVARIANT_iface
;
1960 IEnumWbemClassObject
*objectenum
;
1961 struct services
*services
;
1964 static inline struct enumvar
*impl_from_IEnumVARIANT(
1965 IEnumVARIANT
*iface
)
1967 return CONTAINING_RECORD( iface
, struct enumvar
, IEnumVARIANT_iface
);
1970 static ULONG WINAPI
enumvar_AddRef(
1971 IEnumVARIANT
*iface
)
1973 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1974 return InterlockedIncrement( &enumvar
->refs
);
1977 static ULONG WINAPI
enumvar_Release(
1978 IEnumVARIANT
*iface
)
1980 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1981 LONG refs
= InterlockedDecrement( &enumvar
->refs
);
1984 TRACE( "destroying %p\n", enumvar
);
1985 IEnumWbemClassObject_Release( enumvar
->objectenum
);
1986 ISWbemServices_Release( &enumvar
->services
->ISWbemServices_iface
);
1992 static HRESULT WINAPI
enumvar_QueryInterface(
1993 IEnumVARIANT
*iface
,
1997 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1999 TRACE( "%p %s %p\n", enumvar
, debugstr_guid(riid
), ppvObject
);
2001 if (IsEqualGUID( riid
, &IID_IEnumVARIANT
) ||
2002 IsEqualGUID( riid
, &IID_IUnknown
))
2008 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
2009 return E_NOINTERFACE
;
2011 IEnumVARIANT_AddRef( iface
);
2015 static HRESULT WINAPI
enumvar_Next( IEnumVARIANT
*iface
, ULONG celt
, VARIANT
*var
, ULONG
*fetched
)
2017 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
2018 IWbemClassObject
*obj
;
2021 TRACE( "%p, %lu, %p, %p\n", iface
, celt
, var
, fetched
);
2023 if (celt
) IEnumWbemClassObject_Next( enumvar
->objectenum
, WBEM_INFINITE
, 1, &obj
, &count
);
2029 hr
= SWbemObject_create( enumvar
->services
, obj
, &sobj
);
2030 IWbemClassObject_Release( obj
);
2031 if (FAILED( hr
)) return hr
;
2033 V_VT( var
) = VT_DISPATCH
;
2034 V_DISPATCH( var
) = (IDispatch
*)sobj
;
2036 if (fetched
) *fetched
= count
;
2037 return (count
< celt
) ? S_FALSE
: S_OK
;
2040 static HRESULT WINAPI
enumvar_Skip( IEnumVARIANT
*iface
, ULONG celt
)
2042 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
2044 TRACE( "%p, %lu\n", iface
, celt
);
2046 return IEnumWbemClassObject_Skip( enumvar
->objectenum
, WBEM_INFINITE
, celt
);
2049 static HRESULT WINAPI
enumvar_Reset( IEnumVARIANT
*iface
)
2051 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
2053 TRACE( "%p\n", iface
);
2055 return IEnumWbemClassObject_Reset( enumvar
->objectenum
);
2058 static HRESULT WINAPI
enumvar_Clone( IEnumVARIANT
*iface
, IEnumVARIANT
**penum
)
2060 FIXME( "%p, %p\n", iface
, penum
);
2064 static const struct IEnumVARIANTVtbl enumvar_vtbl
=
2066 enumvar_QueryInterface
,
2075 static HRESULT
EnumVARIANT_create( struct services
*services
, IEnumWbemClassObject
*objectenum
,
2076 IEnumVARIANT
**obj
)
2078 struct enumvar
*enumvar
;
2080 if (!(enumvar
= malloc( sizeof(*enumvar
) ))) return E_OUTOFMEMORY
;
2081 enumvar
->IEnumVARIANT_iface
.lpVtbl
= &enumvar_vtbl
;
2083 enumvar
->objectenum
= objectenum
;
2084 IEnumWbemClassObject_AddRef( enumvar
->objectenum
);
2085 enumvar
->services
= services
;
2086 ISWbemServices_AddRef( &services
->ISWbemServices_iface
);
2088 *obj
= &enumvar
->IEnumVARIANT_iface
;
2089 TRACE( "returning iface %p\n", *obj
);
2093 static inline struct services
*impl_from_ISWbemServices(
2094 ISWbemServices
*iface
)
2096 return CONTAINING_RECORD( iface
, struct services
, ISWbemServices_iface
);
2099 static ULONG WINAPI
services_AddRef(
2100 ISWbemServices
*iface
)
2102 struct services
*services
= impl_from_ISWbemServices( iface
);
2103 return InterlockedIncrement( &services
->refs
);
2106 static ULONG WINAPI
services_Release(
2107 ISWbemServices
*iface
)
2109 struct services
*services
= impl_from_ISWbemServices( iface
);
2110 LONG refs
= InterlockedDecrement( &services
->refs
);
2113 TRACE( "destroying %p\n", services
);
2114 IWbemServices_Release( services
->services
);
2120 static HRESULT WINAPI
services_QueryInterface(
2121 ISWbemServices
*iface
,
2125 struct services
*services
= impl_from_ISWbemServices( iface
);
2127 TRACE( "%p %s %p\n", services
, debugstr_guid(riid
), ppvObject
);
2129 if (IsEqualGUID( riid
, &IID_ISWbemServices
) ||
2130 IsEqualGUID( riid
, &IID_IDispatch
) ||
2131 IsEqualGUID( riid
, &IID_IUnknown
))
2137 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
2138 return E_NOINTERFACE
;
2140 ISWbemServices_AddRef( iface
);
2144 static HRESULT WINAPI
services_GetTypeInfoCount(
2145 ISWbemServices
*iface
,
2148 struct services
*services
= impl_from_ISWbemServices( iface
);
2149 TRACE( "%p, %p\n", services
, count
);
2155 static HRESULT WINAPI
services_GetTypeInfo(
2156 ISWbemServices
*iface
,
2161 struct services
*services
= impl_from_ISWbemServices( iface
);
2162 TRACE( "%p, %u, %#lx, %p\n", services
, index
, lcid
, info
);
2164 return get_typeinfo( ISWbemServices_tid
, info
);
2167 static HRESULT WINAPI
services_GetIDsOfNames(
2168 ISWbemServices
*iface
,
2175 struct services
*services
= impl_from_ISWbemServices( iface
);
2176 ITypeInfo
*typeinfo
;
2179 TRACE( "%p, %s, %p, %u, %#lx, %p\n", services
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
2181 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
2183 hr
= get_typeinfo( ISWbemServices_tid
, &typeinfo
);
2186 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
2187 ITypeInfo_Release( typeinfo
);
2192 static HRESULT WINAPI
services_Invoke(
2193 ISWbemServices
*iface
,
2200 EXCEPINFO
*excep_info
,
2203 struct services
*services
= impl_from_ISWbemServices( iface
);
2204 ITypeInfo
*typeinfo
;
2207 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", services
, member
, debugstr_guid(riid
),
2208 lcid
, flags
, params
, result
, excep_info
, arg_err
);
2210 hr
= get_typeinfo( ISWbemServices_tid
, &typeinfo
);
2213 hr
= ITypeInfo_Invoke( typeinfo
, &services
->ISWbemServices_iface
, member
, flags
,
2214 params
, result
, excep_info
, arg_err
);
2215 ITypeInfo_Release( typeinfo
);
2220 static HRESULT WINAPI
services_Get(
2221 ISWbemServices
*iface
,
2224 IDispatch
*objWbemNamedValueSet
,
2225 ISWbemObject
**objWbemObject
)
2227 struct services
*services
= impl_from_ISWbemServices( iface
);
2228 IWbemClassObject
*obj
;
2231 TRACE( "%p, %s, %#lx, %p, %p\n", iface
, debugstr_w(strObjectPath
), iFlags
, objWbemNamedValueSet
,
2234 if (objWbemNamedValueSet
) FIXME( "ignoring context\n" );
2236 hr
= IWbemServices_GetObject( services
->services
, strObjectPath
, iFlags
, NULL
, &obj
, NULL
);
2237 if (hr
!= S_OK
) return hr
;
2239 hr
= SWbemObject_create( services
, obj
, objWbemObject
);
2240 IWbemClassObject_Release( obj
);
2244 static HRESULT WINAPI
services_GetAsync(
2245 ISWbemServices
*iface
,
2246 IDispatch
*objWbemSink
,
2249 IDispatch
*objWbemNamedValueSet
,
2250 IDispatch
*objWbemAsyncContext
)
2256 static HRESULT WINAPI
services_Delete(
2257 ISWbemServices
*iface
,
2260 IDispatch
*objWbemNamedValueSet
)
2266 static HRESULT WINAPI
services_DeleteAsync(
2267 ISWbemServices
* This
,
2268 IDispatch
*objWbemSink
,
2271 IDispatch
*objWbemNamedValueSet
,
2272 IDispatch
*objWbemAsyncContext
)
2278 static BSTR
build_query_string( const WCHAR
*class )
2280 UINT len
= lstrlenW(class) + ARRAY_SIZE(L
"SELECT * FROM ");
2283 if (!(ret
= SysAllocStringLen( NULL
, len
))) return NULL
;
2284 lstrcpyW( ret
, L
"SELECT * FROM " );
2285 lstrcatW( ret
, class );
2289 static HRESULT WINAPI
services_InstancesOf(
2290 ISWbemServices
*iface
,
2293 IDispatch
*objWbemNamedValueSet
,
2294 ISWbemObjectSet
**objWbemObjectSet
)
2296 BSTR query
, wql
= SysAllocString( L
"WQL" );
2299 TRACE( "%p, %s, %#lx, %p, %p\n", iface
, debugstr_w(strClass
), iFlags
, objWbemNamedValueSet
,
2302 if (!(query
= build_query_string( strClass
)))
2304 SysFreeString( wql
);
2305 return E_OUTOFMEMORY
;
2307 hr
= ISWbemServices_ExecQuery( iface
, query
, wql
, iFlags
, objWbemNamedValueSet
, objWbemObjectSet
);
2308 SysFreeString( wql
);
2309 SysFreeString( query
);
2313 static HRESULT WINAPI
services_InstancesOfAsync(
2314 ISWbemServices
*iface
,
2315 IDispatch
*objWbemSink
,
2318 IDispatch
*objWbemNamedValueSet
,
2319 IDispatch
*objWbemAsyncContext
)
2325 static HRESULT WINAPI
services_SubclassesOf(
2326 ISWbemServices
*iface
,
2329 IDispatch
*objWbemNamedValueSet
,
2330 ISWbemObjectSet
**objWbemObjectSet
)
2336 static HRESULT WINAPI
services_SubclassesOfAsync(
2337 ISWbemServices
*iface
,
2338 IDispatch
*objWbemSink
,
2341 IDispatch
*objWbemNamedValueSet
,
2342 IDispatch
*objWbemAsyncContext
)
2348 static HRESULT WINAPI
services_ExecQuery(
2349 ISWbemServices
*iface
,
2351 BSTR strQueryLanguage
,
2353 IDispatch
*objWbemNamedValueSet
,
2354 ISWbemObjectSet
**objWbemObjectSet
)
2356 struct services
*services
= impl_from_ISWbemServices( iface
);
2357 IEnumWbemClassObject
*iter
;
2360 TRACE( "%p, %s, %s, %#lx, %p, %p\n", iface
, debugstr_w(strQuery
), debugstr_w(strQueryLanguage
),
2361 iFlags
, objWbemNamedValueSet
, objWbemObjectSet
);
2363 if (objWbemNamedValueSet
) FIXME( "ignoring context\n" );
2365 hr
= IWbemServices_ExecQuery( services
->services
, strQueryLanguage
, strQuery
, iFlags
, NULL
, &iter
);
2366 if (hr
!= S_OK
) return hr
;
2368 hr
= SWbemObjectSet_create( services
, iter
, objWbemObjectSet
);
2369 IEnumWbemClassObject_Release( iter
);
2373 static HRESULT WINAPI
services_ExecQueryAsync(
2374 ISWbemServices
*iface
,
2375 IDispatch
*objWbemSink
,
2377 BSTR strQueryLanguage
,
2379 IDispatch
*objWbemNamedValueSet
,
2380 IDispatch
*objWbemAsyncContext
)
2386 static HRESULT WINAPI
services_AssociatorsOf(
2387 ISWbemServices
*iface
,
2390 BSTR strResultClass
,
2393 VARIANT_BOOL bClassesOnly
,
2394 VARIANT_BOOL bSchemaOnly
,
2395 BSTR strRequiredAssocQualifier
,
2396 BSTR strRequiredQualifier
,
2398 IDispatch
*objWbemNamedValueSet
,
2399 ISWbemObjectSet
**objWbemObjectSet
)
2405 static HRESULT WINAPI
services_AssociatorsOfAsync(
2406 ISWbemServices
*iface
,
2407 IDispatch
*objWbemSink
,
2410 BSTR strResultClass
,
2413 VARIANT_BOOL bClassesOnly
,
2414 VARIANT_BOOL bSchemaOnly
,
2415 BSTR strRequiredAssocQualifier
,
2416 BSTR strRequiredQualifier
,
2418 IDispatch
*objWbemNamedValueSet
,
2419 IDispatch
*objWbemAsyncContext
)
2425 static HRESULT WINAPI
services_ReferencesTo(
2426 ISWbemServices
*iface
,
2428 BSTR strResultClass
,
2430 VARIANT_BOOL bClassesOnly
,
2431 VARIANT_BOOL bSchemaOnly
,
2432 BSTR strRequiredQualifier
,
2434 IDispatch
*objWbemNamedValueSet
,
2435 ISWbemObjectSet
**objWbemObjectSet
)
2441 static HRESULT WINAPI
services_ReferencesToAsync(
2442 ISWbemServices
*iface
,
2443 IDispatch
*objWbemSink
,
2445 BSTR strResultClass
,
2447 VARIANT_BOOL bClassesOnly
,
2448 VARIANT_BOOL bSchemaOnly
,
2449 BSTR strRequiredQualifier
,
2451 IDispatch
*objWbemNamedValueSet
,
2452 IDispatch
*objWbemAsyncContext
)
2458 static HRESULT WINAPI
services_ExecNotificationQuery(
2459 ISWbemServices
*iface
,
2461 BSTR strQueryLanguage
,
2463 IDispatch
*objWbemNamedValueSet
,
2464 ISWbemEventSource
**objWbemEventSource
)
2470 static HRESULT WINAPI
services_ExecNotificationQueryAsync(
2471 ISWbemServices
*iface
,
2472 IDispatch
*objWbemSink
,
2474 BSTR strQueryLanguage
,
2476 IDispatch
*objWbemNamedValueSet
,
2477 IDispatch
*objWbemAsyncContext
)
2483 static HRESULT WINAPI
services_ExecMethod(
2484 ISWbemServices
*iface
,
2487 IDispatch
*in_sparams
,
2489 IDispatch
*valueset
,
2490 ISWbemObject
**out_sparams
)
2492 struct services
*services
= impl_from_ISWbemServices( iface
);
2493 IWbemClassObject
*out_params
= NULL
;
2494 struct object
*in_params
;
2495 IWbemContext
*context
;
2498 TRACE( "%p, %s, %s, %p, %#lx, %p, %p\n", services
, debugstr_w(path
), debugstr_w(method
), in_sparams
,
2499 flags
, valueset
, out_sparams
);
2501 in_params
= unsafe_object_impl_from_IDispatch( in_sparams
);
2504 context
= unsafe_get_context_from_namedvalueset( valueset
);
2506 hr
= IWbemServices_ExecMethod( services
->services
, path
, method
, flags
, context
, in_params
? in_params
->object
: NULL
,
2507 out_sparams
? &out_params
: NULL
, NULL
);
2509 if (SUCCEEDED(hr
) && out_params
)
2511 hr
= SWbemObject_create( services
, out_params
, out_sparams
);
2512 IWbemClassObject_Release( out_params
);
2518 static HRESULT WINAPI
services_ExecMethodAsync(
2519 ISWbemServices
*iface
,
2520 IDispatch
*objWbemSink
,
2523 IDispatch
*objWbemInParameters
,
2525 IDispatch
*objWbemNamedValueSet
,
2526 IDispatch
*objWbemAsyncContext
)
2532 static HRESULT WINAPI
services_get_Security_(
2533 ISWbemServices
*iface
,
2534 ISWbemSecurity
**objWbemSecurity
)
2536 TRACE( "%p, %p\n", iface
, objWbemSecurity
);
2538 if (!objWbemSecurity
)
2539 return E_INVALIDARG
;
2541 return ISWbemSecurity_create( objWbemSecurity
);
2544 static const ISWbemServicesVtbl services_vtbl
=
2546 services_QueryInterface
,
2549 services_GetTypeInfoCount
,
2550 services_GetTypeInfo
,
2551 services_GetIDsOfNames
,
2556 services_DeleteAsync
,
2557 services_InstancesOf
,
2558 services_InstancesOfAsync
,
2559 services_SubclassesOf
,
2560 services_SubclassesOfAsync
,
2562 services_ExecQueryAsync
,
2563 services_AssociatorsOf
,
2564 services_AssociatorsOfAsync
,
2565 services_ReferencesTo
,
2566 services_ReferencesToAsync
,
2567 services_ExecNotificationQuery
,
2568 services_ExecNotificationQueryAsync
,
2569 services_ExecMethod
,
2570 services_ExecMethodAsync
,
2571 services_get_Security_
2574 static HRESULT
SWbemServices_create( IWbemServices
*wbem_services
, ISWbemServices
**obj
)
2576 struct services
*services
;
2578 TRACE( "%p, %p\n", obj
, wbem_services
);
2580 if (!(services
= malloc( sizeof(*services
) ))) return E_OUTOFMEMORY
;
2581 services
->ISWbemServices_iface
.lpVtbl
= &services_vtbl
;
2583 services
->services
= wbem_services
;
2584 IWbemServices_AddRef( services
->services
);
2586 *obj
= &services
->ISWbemServices_iface
;
2587 TRACE( "returning iface %p\n", *obj
);
2593 ISWbemLocator ISWbemLocator_iface
;
2595 IWbemLocator
*locator
;
2598 static inline struct locator
*impl_from_ISWbemLocator( ISWbemLocator
*iface
)
2600 return CONTAINING_RECORD( iface
, struct locator
, ISWbemLocator_iface
);
2603 static ULONG WINAPI
locator_AddRef(
2604 ISWbemLocator
*iface
)
2606 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2607 return InterlockedIncrement( &locator
->refs
);
2610 static ULONG WINAPI
locator_Release(
2611 ISWbemLocator
*iface
)
2613 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2614 LONG refs
= InterlockedDecrement( &locator
->refs
);
2617 TRACE( "destroying %p\n", locator
);
2618 if (locator
->locator
)
2619 IWbemLocator_Release( locator
->locator
);
2625 static HRESULT WINAPI
locator_QueryInterface(
2626 ISWbemLocator
*iface
,
2630 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2632 TRACE( "%p, %s, %p\n", locator
, debugstr_guid( riid
), ppvObject
);
2634 if (IsEqualGUID( riid
, &IID_ISWbemLocator
) ||
2635 IsEqualGUID( riid
, &IID_IDispatch
) ||
2636 IsEqualGUID( riid
, &IID_IUnknown
))
2642 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
2643 return E_NOINTERFACE
;
2645 ISWbemLocator_AddRef( iface
);
2649 static HRESULT WINAPI
locator_GetTypeInfoCount(
2650 ISWbemLocator
*iface
,
2653 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2655 TRACE( "%p, %p\n", locator
, count
);
2660 static HRESULT WINAPI
locator_GetTypeInfo(
2661 ISWbemLocator
*iface
,
2666 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2667 TRACE( "%p, %u, %#lx, %p\n", locator
, index
, lcid
, info
);
2669 return get_typeinfo( ISWbemLocator_tid
, info
);
2672 static HRESULT WINAPI
locator_GetIDsOfNames(
2673 ISWbemLocator
*iface
,
2680 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2681 ITypeInfo
*typeinfo
;
2684 TRACE( "%p, %s, %p, %u, %#lx, %p\n", locator
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
2686 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
2688 hr
= get_typeinfo( ISWbemLocator_tid
, &typeinfo
);
2691 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
2692 ITypeInfo_Release( typeinfo
);
2697 static HRESULT WINAPI
locator_Invoke(
2698 ISWbemLocator
*iface
,
2705 EXCEPINFO
*excep_info
,
2708 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2709 ITypeInfo
*typeinfo
;
2712 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", locator
, member
, debugstr_guid(riid
),
2713 lcid
, flags
, params
, result
, excep_info
, arg_err
);
2715 hr
= get_typeinfo( ISWbemLocator_tid
, &typeinfo
);
2718 hr
= ITypeInfo_Invoke( typeinfo
, &locator
->ISWbemLocator_iface
, member
, flags
,
2719 params
, result
, excep_info
, arg_err
);
2720 ITypeInfo_Release( typeinfo
);
2725 static BSTR
build_resource_string( BSTR server
, BSTR
namespace )
2727 ULONG len
, len_server
= 0, len_namespace
= 0;
2730 if (server
&& *server
) len_server
= lstrlenW( server
);
2731 else len_server
= 1;
2732 if (namespace && *namespace) len_namespace
= lstrlenW( namespace );
2733 else len_namespace
= ARRAY_SIZE(L
"root\\default") - 1;
2735 if (!(ret
= SysAllocStringLen( NULL
, 2 + len_server
+ 1 + len_namespace
))) return NULL
;
2737 ret
[0] = ret
[1] = '\\';
2738 if (server
&& *server
) lstrcpyW( ret
+ 2, server
);
2741 len
= len_server
+ 2;
2744 if (namespace && *namespace) lstrcpyW( ret
+ len
, namespace );
2745 else lstrcpyW( ret
+ len
, L
"root\\default" );
2749 static HRESULT WINAPI
locator_ConnectServer(
2750 ISWbemLocator
*iface
,
2757 LONG iSecurityFlags
,
2758 IDispatch
*objWbemNamedValueSet
,
2759 ISWbemServices
**objWbemServices
)
2761 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2762 IWbemServices
*services
;
2763 IWbemContext
*context
;
2767 TRACE( "%p, %s, %s, %s, %p, %s, %s, %#lx, %p, %p\n", iface
, debugstr_w(strServer
),
2768 debugstr_w(strNamespace
), debugstr_w(strUser
), strPassword
, debugstr_w(strLocale
),
2769 debugstr_w(strAuthority
), iSecurityFlags
, objWbemNamedValueSet
, objWbemServices
);
2771 if (!locator
->locator
)
2773 hr
= CoCreateInstance( &CLSID_WbemLocator
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IWbemLocator
,
2774 (void **)&locator
->locator
);
2775 if (hr
!= S_OK
) return hr
;
2778 context
= unsafe_get_context_from_namedvalueset( objWbemNamedValueSet
);
2780 if (!(resource
= build_resource_string( strServer
, strNamespace
))) return E_OUTOFMEMORY
;
2781 hr
= IWbemLocator_ConnectServer( locator
->locator
, resource
, strUser
, strPassword
, strLocale
,
2782 iSecurityFlags
, strAuthority
, context
, &services
);
2783 SysFreeString( resource
);
2784 if (hr
!= S_OK
) return hr
;
2786 hr
= SWbemServices_create( services
, objWbemServices
);
2787 IWbemServices_Release( services
);
2791 static HRESULT WINAPI
locator_get_Security_(
2792 ISWbemLocator
*iface
,
2793 ISWbemSecurity
**objWbemSecurity
)
2795 TRACE( "%p, %p\n", iface
, objWbemSecurity
);
2797 if (!objWbemSecurity
)
2798 return E_INVALIDARG
;
2800 return ISWbemSecurity_create( objWbemSecurity
);
2803 static const ISWbemLocatorVtbl locator_vtbl
=
2805 locator_QueryInterface
,
2808 locator_GetTypeInfoCount
,
2809 locator_GetTypeInfo
,
2810 locator_GetIDsOfNames
,
2812 locator_ConnectServer
,
2813 locator_get_Security_
2816 HRESULT
SWbemLocator_create( void **obj
)
2818 struct locator
*locator
;
2820 TRACE( "%p\n", obj
);
2822 if (!(locator
= malloc( sizeof(*locator
) ))) return E_OUTOFMEMORY
;
2823 locator
->ISWbemLocator_iface
.lpVtbl
= &locator_vtbl
;
2825 locator
->locator
= NULL
;
2827 *obj
= &locator
->ISWbemLocator_iface
;
2828 TRACE( "returning iface %p\n", *obj
);
2834 ISWbemSecurity ISWbemSecurity_iface
;
2836 WbemImpersonationLevelEnum implevel
;
2837 WbemAuthenticationLevelEnum authlevel
;
2840 static inline struct security
*impl_from_ISWbemSecurity( ISWbemSecurity
*iface
)
2842 return CONTAINING_RECORD( iface
, struct security
, ISWbemSecurity_iface
);
2845 static ULONG WINAPI
security_AddRef(
2846 ISWbemSecurity
*iface
)
2848 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2849 return InterlockedIncrement( &security
->refs
);
2852 static ULONG WINAPI
security_Release(
2853 ISWbemSecurity
*iface
)
2855 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2856 LONG refs
= InterlockedDecrement( &security
->refs
);
2859 TRACE( "destroying %p\n", security
);
2865 static HRESULT WINAPI
security_QueryInterface(
2866 ISWbemSecurity
*iface
,
2870 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2871 TRACE( "%p, %s, %p\n", security
, debugstr_guid( riid
), ppvObject
);
2873 if (IsEqualGUID( riid
, &IID_ISWbemSecurity
) ||
2874 IsEqualGUID( riid
, &IID_IDispatch
) ||
2875 IsEqualGUID( riid
, &IID_IUnknown
))
2881 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
2882 return E_NOINTERFACE
;
2884 ISWbemSecurity_AddRef( iface
);
2888 static HRESULT WINAPI
security_GetTypeInfoCount(
2889 ISWbemSecurity
*iface
,
2892 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2893 TRACE( "%p, %p\n", security
, count
);
2899 static HRESULT WINAPI
security_GetTypeInfo(
2900 ISWbemSecurity
*iface
,
2905 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2906 TRACE( "%p, %u, %#lx, %p\n", security
, index
, lcid
, info
);
2908 return get_typeinfo( ISWbemSecurity_tid
, info
);
2911 static HRESULT WINAPI
security_GetIDsOfNames(
2912 ISWbemSecurity
*iface
,
2919 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2920 ITypeInfo
*typeinfo
;
2923 TRACE( "%p, %s, %p, %u, %#lx, %p\n", security
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
2925 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
2927 hr
= get_typeinfo( ISWbemSecurity_tid
, &typeinfo
);
2930 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
2931 ITypeInfo_Release( typeinfo
);
2936 static HRESULT WINAPI
security_Invoke(
2937 ISWbemSecurity
*iface
,
2944 EXCEPINFO
*excep_info
,
2947 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2948 ITypeInfo
*typeinfo
;
2951 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", security
, member
, debugstr_guid(riid
),
2952 lcid
, flags
, params
, result
, excep_info
, arg_err
);
2954 hr
= get_typeinfo( ISWbemSecurity_tid
, &typeinfo
);
2957 hr
= ITypeInfo_Invoke( typeinfo
, &security
->ISWbemSecurity_iface
, member
, flags
,
2958 params
, result
, excep_info
, arg_err
);
2959 ITypeInfo_Release( typeinfo
);
2964 static HRESULT WINAPI
security_get_ImpersonationLevel(
2965 ISWbemSecurity
*iface
,
2966 WbemImpersonationLevelEnum
*impersonation_level
)
2968 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2969 FIXME( "%p, %p: stub\n", security
, impersonation_level
);
2971 if (!impersonation_level
)
2972 return E_INVALIDARG
;
2974 *impersonation_level
= security
->implevel
;
2978 static HRESULT WINAPI
security_put_ImpersonationLevel(
2979 ISWbemSecurity
*iface
,
2980 WbemImpersonationLevelEnum impersonation_level
)
2982 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2983 FIXME( "%p, %d: stub\n", security
, impersonation_level
);
2985 security
->implevel
= impersonation_level
;
2989 static HRESULT WINAPI
security_get_AuthenticationLevel(
2990 ISWbemSecurity
*iface
,
2991 WbemAuthenticationLevelEnum
*authentication_level
)
2993 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2994 FIXME( "%p, %p: stub\n", security
, authentication_level
);
2996 if (!authentication_level
)
2997 return E_INVALIDARG
;
2999 *authentication_level
= security
->authlevel
;
3003 static HRESULT WINAPI
security_put_AuthenticationLevel(
3004 ISWbemSecurity
*iface
,
3005 WbemAuthenticationLevelEnum authentication_level
)
3007 struct security
*security
= impl_from_ISWbemSecurity( iface
);
3008 FIXME( "%p, %d: stub\n", security
, authentication_level
);
3010 security
->authlevel
= authentication_level
;
3014 static HRESULT WINAPI
security_get_Privileges(
3015 ISWbemSecurity
*iface
,
3016 ISWbemPrivilegeSet
**privilege_set
)
3018 struct security
*security
= impl_from_ISWbemSecurity( iface
);
3019 FIXME( "%p, %p: stub\n", security
, privilege_set
);
3022 return E_INVALIDARG
;
3027 static const ISWbemSecurityVtbl security_vtbl
=
3029 security_QueryInterface
,
3032 security_GetTypeInfoCount
,
3033 security_GetTypeInfo
,
3034 security_GetIDsOfNames
,
3036 security_get_ImpersonationLevel
,
3037 security_put_ImpersonationLevel
,
3038 security_get_AuthenticationLevel
,
3039 security_put_AuthenticationLevel
,
3040 security_get_Privileges
3043 static HRESULT
ISWbemSecurity_create( ISWbemSecurity
**obj
)
3045 struct security
*security
;
3047 TRACE( "%p\n", obj
);
3049 if (!(security
= malloc( sizeof(*security
) ))) return E_OUTOFMEMORY
;
3050 security
->ISWbemSecurity_iface
.lpVtbl
= &security_vtbl
;
3052 security
->implevel
= wbemImpersonationLevelImpersonate
;
3053 security
->authlevel
= wbemAuthenticationLevelPktPrivacy
;
3055 *obj
= &security
->ISWbemSecurity_iface
;
3056 TRACE( "returning iface %p\n", *obj
);
3062 ISWbemNamedValue ISWbemNamedValue_iface
;
3066 static struct namedvalueset
*impl_from_ISWbemNamedValueSet( ISWbemNamedValueSet
*iface
)
3068 return CONTAINING_RECORD( iface
, struct namedvalueset
, ISWbemNamedValueSet_iface
);
3071 static struct namedvalue
*impl_from_ISWbemNamedValue( ISWbemNamedValue
*iface
)
3073 return CONTAINING_RECORD( iface
, struct namedvalue
, ISWbemNamedValue_iface
);
3076 static HRESULT WINAPI
namedvalue_QueryInterface(
3077 ISWbemNamedValue
*iface
,
3081 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3083 TRACE( "%p, %s, %p\n", value
, debugstr_guid( riid
), ppvObject
);
3085 if (IsEqualGUID( riid
, &IID_ISWbemNamedValue
) ||
3086 IsEqualGUID( riid
, &IID_IDispatch
) ||
3087 IsEqualGUID( riid
, &IID_IUnknown
))
3093 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
3094 return E_NOINTERFACE
;
3096 ISWbemNamedValue_AddRef( iface
);
3100 static ULONG WINAPI
namedvalue_AddRef(
3101 ISWbemNamedValue
*iface
)
3103 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3104 return InterlockedIncrement( &value
->refs
);
3107 static ULONG WINAPI
namedvalue_Release(
3108 ISWbemNamedValue
*iface
)
3110 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3111 LONG refs
= InterlockedDecrement( &value
->refs
);
3114 TRACE( "destroying %p\n", value
);
3120 static HRESULT WINAPI
namedvalue_GetTypeInfoCount(
3121 ISWbemNamedValue
*iface
,
3124 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3125 TRACE( "%p, %p\n", value
, count
);
3131 static HRESULT WINAPI
namedvalue_GetTypeInfo(
3132 ISWbemNamedValue
*iface
,
3137 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3139 TRACE( "%p, %u, %#lx, %p\n", value
, index
, lcid
, info
);
3141 return get_typeinfo( ISWbemNamedValue_tid
, info
);
3144 static HRESULT WINAPI
namedvalue_GetIDsOfNames(
3145 ISWbemNamedValue
*iface
,
3152 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3153 ITypeInfo
*typeinfo
;
3156 TRACE( "%p, %s, %p, %u, %#lx, %p\n", value
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
3158 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
3160 hr
= get_typeinfo( ISWbemNamedValue_tid
, &typeinfo
);
3163 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
3164 ITypeInfo_Release( typeinfo
);
3169 static HRESULT WINAPI
namedvalue_Invoke(
3170 ISWbemNamedValue
*iface
,
3177 EXCEPINFO
*excep_info
,
3180 struct namedvalue
*set
= impl_from_ISWbemNamedValue( iface
);
3181 ITypeInfo
*typeinfo
;
3184 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", set
, member
, debugstr_guid(riid
),
3185 lcid
, flags
, params
, result
, excep_info
, arg_err
);
3187 hr
= get_typeinfo( ISWbemNamedValue_tid
, &typeinfo
);
3190 hr
= ITypeInfo_Invoke( typeinfo
, &set
->ISWbemNamedValue_iface
, member
, flags
,
3191 params
, result
, excep_info
, arg_err
);
3192 ITypeInfo_Release( typeinfo
);
3197 static HRESULT WINAPI
namedvalue_get_Value(
3198 ISWbemNamedValue
*iface
,
3206 static HRESULT WINAPI
namedvalue_put_Value(
3207 ISWbemNamedValue
*iface
,
3215 static HRESULT WINAPI
namedvalue_get_Name(
3216 ISWbemNamedValue
*iface
,
3224 static const ISWbemNamedValueVtbl namedvaluevtbl
=
3226 namedvalue_QueryInterface
,
3229 namedvalue_GetTypeInfoCount
,
3230 namedvalue_GetTypeInfo
,
3231 namedvalue_GetIDsOfNames
,
3233 namedvalue_get_Value
,
3234 namedvalue_put_Value
,
3238 static HRESULT
namedvalue_create( ISWbemNamedValue
**value
)
3240 struct namedvalue
*object
;
3242 if (!(object
= malloc( sizeof(*object
) ))) return E_OUTOFMEMORY
;
3244 object
->ISWbemNamedValue_iface
.lpVtbl
= &namedvaluevtbl
;
3247 *value
= &object
->ISWbemNamedValue_iface
;
3252 static HRESULT WINAPI
namedvalueset_QueryInterface(
3253 ISWbemNamedValueSet
*iface
,
3257 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3259 TRACE( "%p, %s, %p\n", set
, debugstr_guid( riid
), ppvObject
);
3261 if (IsEqualGUID( riid
, &IID_ISWbemNamedValueSet
) ||
3262 IsEqualGUID( riid
, &IID_IDispatch
) ||
3263 IsEqualGUID( riid
, &IID_IUnknown
))
3269 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
3270 return E_NOINTERFACE
;
3272 ISWbemNamedValueSet_AddRef( iface
);
3276 static ULONG WINAPI
namedvalueset_AddRef(
3277 ISWbemNamedValueSet
*iface
)
3279 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3280 return InterlockedIncrement( &set
->refs
);
3283 static ULONG WINAPI
namedvalueset_Release(
3284 ISWbemNamedValueSet
*iface
)
3286 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3287 LONG refs
= InterlockedDecrement( &set
->refs
);
3290 TRACE( "destroying %p\n", set
);
3292 IWbemContext_Release( set
->context
);
3298 static HRESULT WINAPI
namedvalueset_GetTypeInfoCount(
3299 ISWbemNamedValueSet
*iface
,
3302 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3303 TRACE( "%p, %p\n", set
, count
);
3309 static HRESULT WINAPI
namedvalueset_GetTypeInfo(
3310 ISWbemNamedValueSet
*iface
,
3315 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3317 TRACE( "%p, %u, %#lx, %p\n", set
, index
, lcid
, info
);
3319 return get_typeinfo( ISWbemNamedValueSet_tid
, info
);
3322 static HRESULT WINAPI
namedvalueset_GetIDsOfNames(
3323 ISWbemNamedValueSet
*iface
,
3330 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3331 ITypeInfo
*typeinfo
;
3334 TRACE( "%p, %s, %p, %u, %#lx, %p\n", set
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
3336 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
3338 hr
= get_typeinfo( ISWbemNamedValueSet_tid
, &typeinfo
);
3341 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
3342 ITypeInfo_Release( typeinfo
);
3347 static HRESULT WINAPI
namedvalueset_Invoke(
3348 ISWbemNamedValueSet
*iface
,
3355 EXCEPINFO
*excep_info
,
3358 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3359 ITypeInfo
*typeinfo
;
3362 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", set
, member
, debugstr_guid(riid
),
3363 lcid
, flags
, params
, result
, excep_info
, arg_err
);
3365 hr
= get_typeinfo( ISWbemNamedValueSet_tid
, &typeinfo
);
3368 hr
= ITypeInfo_Invoke( typeinfo
, &set
->ISWbemNamedValueSet_iface
, member
, flags
,
3369 params
, result
, excep_info
, arg_err
);
3370 ITypeInfo_Release( typeinfo
);
3375 static HRESULT WINAPI
namedvalueset_get__NewEnum(
3376 ISWbemNamedValueSet
*iface
,
3384 static HRESULT WINAPI
namedvalueset_Item(
3385 ISWbemNamedValueSet
*iface
,
3388 ISWbemNamedValue
**value
)
3390 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3394 TRACE("%p, %s, %#lx, %p\n", set
, debugstr_w(name
), flags
, value
);
3396 if (SUCCEEDED(hr
= IWbemContext_GetValue( set
->context
, name
, flags
, &var
)))
3398 VariantClear( &var
);
3399 hr
= namedvalue_create( value
);
3405 static HRESULT WINAPI
namedvalueset_get_Count(
3406 ISWbemNamedValueSet
*iface
,
3414 static HRESULT WINAPI
namedvalueset_Add(
3415 ISWbemNamedValueSet
*iface
,
3419 ISWbemNamedValue
**value
)
3421 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3424 TRACE("%p, %s, %s, %#lx, %p\n", set
, debugstr_w(name
), debugstr_variant(var
), flags
, value
);
3426 if (!name
|| !var
|| !value
)
3427 return WBEM_E_INVALID_PARAMETER
;
3429 if (SUCCEEDED(hr
= IWbemContext_SetValue( set
->context
, name
, flags
, var
)))
3431 hr
= namedvalue_create( value
);
3437 static HRESULT WINAPI
namedvalueset_Remove(
3438 ISWbemNamedValueSet
*iface
,
3442 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3444 TRACE("%p, %s, %#lx\n", set
, debugstr_w(name
), flags
);
3446 return IWbemContext_DeleteValue( set
->context
, name
, flags
);
3449 static HRESULT WINAPI
namedvalueset_Clone(
3450 ISWbemNamedValueSet
*iface
,
3451 ISWbemNamedValueSet
**valueset
)
3458 static HRESULT WINAPI
namedvalueset_DeleteAll(
3459 ISWbemNamedValueSet
*iface
)
3461 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3465 return IWbemContext_DeleteAll( set
->context
);
3468 static const ISWbemNamedValueSetVtbl namedvalueset_vtbl
=
3470 namedvalueset_QueryInterface
,
3471 namedvalueset_AddRef
,
3472 namedvalueset_Release
,
3473 namedvalueset_GetTypeInfoCount
,
3474 namedvalueset_GetTypeInfo
,
3475 namedvalueset_GetIDsOfNames
,
3476 namedvalueset_Invoke
,
3477 namedvalueset_get__NewEnum
,
3479 namedvalueset_get_Count
,
3481 namedvalueset_Remove
,
3482 namedvalueset_Clone
,
3483 namedvalueset_DeleteAll
,
3486 static struct namedvalueset
*unsafe_valueset_impl_from_IDispatch(IDispatch
*iface
)
3490 if (iface
->lpVtbl
!= (IDispatchVtbl
*)&namedvalueset_vtbl
)
3492 FIXME( "External implementations are not supported.\n" );
3495 return CONTAINING_RECORD(iface
, struct namedvalueset
, ISWbemNamedValueSet_iface
);
3498 HRESULT
SWbemNamedValueSet_create( void **obj
)
3500 struct namedvalueset
*set
;
3503 TRACE( "%p\n", obj
);
3505 if (!(set
= calloc( 1, sizeof(*set
) ))) return E_OUTOFMEMORY
;
3506 set
->ISWbemNamedValueSet_iface
.lpVtbl
= &namedvalueset_vtbl
;
3509 if (FAILED(hr
= CoCreateInstance( &CLSID_WbemContext
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IWbemContext
,
3510 (void **)&set
->context
)))
3512 ISWbemNamedValueSet_Release( &set
->ISWbemNamedValueSet_iface
);
3516 *obj
= &set
->ISWbemNamedValueSet_iface
;
3517 TRACE( "returning iface %p\n", *obj
);