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
;
53 static WCHAR
*heap_strdupW( const WCHAR
*src
)
56 if (!src
) return NULL
;
57 if ((dst
= malloc( (lstrlenW( src
) + 1) * sizeof(WCHAR
) ))) lstrcpyW( dst
, src
);
63 static HRESULT
EnumVARIANT_create( struct services
*, IEnumWbemClassObject
*, IEnumVARIANT
** );
64 static HRESULT
ISWbemSecurity_create( ISWbemSecurity
** );
65 static HRESULT
SWbemObject_create( struct services
*, IWbemClassObject
*, ISWbemObject
** );
73 ISWbemPropertySet_tid
,
76 ISWbemNamedValueSet_tid
,
83 static ITypeLib
*wbemdisp_typelib
;
84 static ITypeInfo
*wbemdisp_typeinfo
[last_tid
];
86 static REFIID wbemdisp_tid_id
[] =
92 &IID_ISWbemPropertySet
,
95 &IID_ISWbemNamedValueSet
,
96 &IID_ISWbemNamedValue
,
101 static HRESULT
get_typeinfo( enum type_id tid
, ITypeInfo
**ret
)
105 if (!wbemdisp_typelib
)
109 hr
= LoadRegTypeLib( &LIBID_WbemScripting
, 1, 2, LOCALE_SYSTEM_DEFAULT
, &typelib
);
112 ERR( "LoadRegTypeLib failed: %#lx\n", hr
);
115 if (InterlockedCompareExchangePointer( (void **)&wbemdisp_typelib
, typelib
, NULL
))
116 ITypeLib_Release( typelib
);
118 if (!wbemdisp_typeinfo
[tid
])
122 hr
= ITypeLib_GetTypeInfoOfGuid( wbemdisp_typelib
, wbemdisp_tid_id
[tid
], &typeinfo
);
125 ERR( "GetTypeInfoOfGuid(%s) failed: %#lx\n", debugstr_guid(wbemdisp_tid_id
[tid
]), hr
);
128 if (InterlockedCompareExchangePointer( (void **)(wbemdisp_typeinfo
+ tid
), typeinfo
, NULL
))
129 ITypeInfo_Release( typeinfo
);
131 *ret
= wbemdisp_typeinfo
[tid
];
132 ITypeInfo_AddRef( *ret
);
138 ISWbemProperty ISWbemProperty_iface
;
140 IWbemClassObject
*object
;
144 static inline struct property
*impl_from_ISWbemProperty( ISWbemProperty
*iface
)
146 return CONTAINING_RECORD( iface
, struct property
, ISWbemProperty_iface
);
149 static ULONG WINAPI
property_AddRef( ISWbemProperty
*iface
)
151 struct property
*property
= impl_from_ISWbemProperty( iface
);
152 return InterlockedIncrement( &property
->refs
);
155 static ULONG WINAPI
property_Release( ISWbemProperty
*iface
)
157 struct property
*property
= impl_from_ISWbemProperty( iface
);
158 LONG refs
= InterlockedDecrement( &property
->refs
);
161 TRACE( "destroying %p\n", property
);
162 IWbemClassObject_Release( property
->object
);
163 SysFreeString( property
->name
);
169 static HRESULT WINAPI
property_QueryInterface( ISWbemProperty
*iface
, REFIID riid
, void **obj
)
171 struct property
*property
= impl_from_ISWbemProperty( iface
);
173 TRACE( "%p %s %p\n", property
, debugstr_guid(riid
), obj
);
175 if (IsEqualGUID( riid
, &IID_ISWbemProperty
) ||
176 IsEqualGUID( riid
, &IID_IDispatch
) ||
177 IsEqualGUID( riid
, &IID_IUnknown
))
183 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
184 return E_NOINTERFACE
;
186 ISWbemProperty_AddRef( iface
);
190 static HRESULT WINAPI
property_GetTypeInfoCount( ISWbemProperty
*iface
, UINT
*count
)
192 struct property
*property
= impl_from_ISWbemProperty( iface
);
193 TRACE( "%p, %p\n", property
, count
);
198 static HRESULT WINAPI
property_GetTypeInfo( ISWbemProperty
*iface
, UINT index
,
199 LCID lcid
, ITypeInfo
**info
)
201 struct property
*property
= impl_from_ISWbemProperty( iface
);
202 TRACE( "%p, %u, %#lx, %p\n", property
, index
, lcid
, info
);
204 return get_typeinfo( ISWbemProperty_tid
, info
);
207 static HRESULT WINAPI
property_GetIDsOfNames( ISWbemProperty
*iface
, REFIID riid
, LPOLESTR
*names
,
208 UINT count
, LCID lcid
, DISPID
*dispid
)
210 struct property
*property
= impl_from_ISWbemProperty( iface
);
214 TRACE( "%p, %s, %p, %u, %#lx, %p\n", property
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
216 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
218 hr
= get_typeinfo( ISWbemProperty_tid
, &typeinfo
);
221 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
222 ITypeInfo_Release( typeinfo
);
227 static HRESULT WINAPI
property_Invoke( ISWbemProperty
*iface
, DISPID member
, REFIID riid
,
228 LCID lcid
, WORD flags
, DISPPARAMS
*params
,
229 VARIANT
*result
, EXCEPINFO
*excep_info
, UINT
*arg_err
)
231 struct property
*property
= impl_from_ISWbemProperty( iface
);
235 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", property
, member
, debugstr_guid(riid
),
236 lcid
, flags
, params
, result
, excep_info
, arg_err
);
238 hr
= get_typeinfo( ISWbemProperty_tid
, &typeinfo
);
241 hr
= ITypeInfo_Invoke( typeinfo
, &property
->ISWbemProperty_iface
, member
, flags
,
242 params
, result
, excep_info
, arg_err
);
243 ITypeInfo_Release( typeinfo
);
248 static HRESULT WINAPI
property_get_Value( ISWbemProperty
*iface
, VARIANT
*value
)
250 struct property
*property
= impl_from_ISWbemProperty( iface
);
252 TRACE( "%p %p\n", property
, value
);
254 return IWbemClassObject_Get( property
->object
, property
->name
, 0, value
, NULL
, NULL
);
257 static HRESULT WINAPI
property_put_Value( ISWbemProperty
*iface
, VARIANT
*varValue
)
263 static HRESULT WINAPI
property_get_Name( ISWbemProperty
*iface
, BSTR
*strName
)
269 static HRESULT WINAPI
property_get_IsLocal( ISWbemProperty
*iface
, VARIANT_BOOL
*bIsLocal
)
275 static HRESULT WINAPI
property_get_Origin( ISWbemProperty
*iface
, BSTR
*strOrigin
)
281 static HRESULT WINAPI
property_get_CIMType( ISWbemProperty
*iface
, WbemCimtypeEnum
*iCimType
)
287 static HRESULT WINAPI
property_get_Qualifiers_( ISWbemProperty
*iface
, ISWbemQualifierSet
**objWbemQualifierSet
)
293 static HRESULT WINAPI
property_get_IsArray( ISWbemProperty
*iface
, VARIANT_BOOL
*bIsArray
)
299 static const ISWbemPropertyVtbl property_vtbl
=
301 property_QueryInterface
,
304 property_GetTypeInfoCount
,
305 property_GetTypeInfo
,
306 property_GetIDsOfNames
,
311 property_get_IsLocal
,
313 property_get_CIMType
,
314 property_get_Qualifiers_
,
318 static HRESULT
SWbemProperty_create( IWbemClassObject
*wbem_object
, BSTR name
, ISWbemProperty
**obj
)
320 struct property
*property
;
322 TRACE( "%p, %p\n", obj
, wbem_object
);
324 if (!(property
= malloc( sizeof(*property
) ))) return E_OUTOFMEMORY
;
325 property
->ISWbemProperty_iface
.lpVtbl
= &property_vtbl
;
327 property
->object
= wbem_object
;
328 IWbemClassObject_AddRef( property
->object
);
329 property
->name
= SysAllocStringLen( name
, SysStringLen( name
) );
330 *obj
= &property
->ISWbemProperty_iface
;
331 TRACE( "returning iface %p\n", *obj
);
337 ISWbemPropertySet ISWbemPropertySet_iface
;
339 IWbemClassObject
*object
;
342 static inline struct propertyset
*impl_from_ISWbemPropertySet(
343 ISWbemPropertySet
*iface
)
345 return CONTAINING_RECORD( iface
, struct propertyset
, ISWbemPropertySet_iface
);
348 static ULONG WINAPI
propertyset_AddRef( ISWbemPropertySet
*iface
)
350 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
351 return InterlockedIncrement( &propertyset
->refs
);
354 static ULONG WINAPI
propertyset_Release( ISWbemPropertySet
*iface
)
356 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
357 LONG refs
= InterlockedDecrement( &propertyset
->refs
);
360 TRACE( "destroying %p\n", propertyset
);
361 IWbemClassObject_Release( propertyset
->object
);
367 static HRESULT WINAPI
propertyset_QueryInterface( ISWbemPropertySet
*iface
,
368 REFIID riid
, void **obj
)
370 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
372 TRACE( "%p %s %p\n", propertyset
, debugstr_guid(riid
), obj
);
374 if (IsEqualGUID( riid
, &IID_ISWbemPropertySet
) ||
375 IsEqualGUID( riid
, &IID_IDispatch
) ||
376 IsEqualGUID( riid
, &IID_IUnknown
))
382 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
383 return E_NOINTERFACE
;
385 ISWbemPropertySet_AddRef( iface
);
389 static HRESULT WINAPI
propertyset_GetTypeInfoCount( ISWbemPropertySet
*iface
, UINT
*count
)
391 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
392 TRACE( "%p, %p\n", propertyset
, count
);
397 static HRESULT WINAPI
propertyset_GetTypeInfo( ISWbemPropertySet
*iface
,
398 UINT index
, LCID lcid
, ITypeInfo
**info
)
400 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
401 TRACE( "%p, %u, %#lx, %p\n", propertyset
, index
, lcid
, info
);
403 return get_typeinfo( ISWbemPropertySet_tid
, info
);
406 static HRESULT WINAPI
propertyset_GetIDsOfNames( ISWbemPropertySet
*iface
, REFIID riid
, LPOLESTR
*names
,
407 UINT count
, LCID lcid
, DISPID
*dispid
)
409 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
413 TRACE( "%p, %s, %p, %u, %#lx, %p\n", propertyset
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
415 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
417 hr
= get_typeinfo( ISWbemPropertySet_tid
, &typeinfo
);
420 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
421 ITypeInfo_Release( typeinfo
);
426 static HRESULT WINAPI
propertyset_Invoke( ISWbemPropertySet
*iface
, DISPID member
, REFIID riid
,
427 LCID lcid
, WORD flags
, DISPPARAMS
*params
,
428 VARIANT
*result
, EXCEPINFO
*excep_info
, UINT
*arg_err
)
430 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
434 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", propertyset
, member
, debugstr_guid(riid
),
435 lcid
, flags
, params
, result
, excep_info
, arg_err
);
437 hr
= get_typeinfo( ISWbemPropertySet_tid
, &typeinfo
);
440 hr
= ITypeInfo_Invoke( typeinfo
, &propertyset
->ISWbemPropertySet_iface
, member
, flags
,
441 params
, result
, excep_info
, arg_err
);
442 ITypeInfo_Release( typeinfo
);
447 static HRESULT WINAPI
propertyset_get__NewEnum( ISWbemPropertySet
*iface
, IUnknown
**unk
)
453 static HRESULT WINAPI
propertyset_Item( ISWbemPropertySet
*iface
, BSTR name
,
454 LONG flags
, ISWbemProperty
**prop
)
456 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
460 TRACE( "%p, %s, %#lx, %p\n", propertyset
, debugstr_w(name
), flags
, prop
);
462 hr
= IWbemClassObject_Get( propertyset
->object
, name
, 0, &var
, NULL
, NULL
);
465 hr
= SWbemProperty_create( propertyset
->object
, name
, prop
);
466 VariantClear( &var
);
471 static HRESULT WINAPI
propertyset_get_Count( ISWbemPropertySet
*iface
, LONG
*count
)
473 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
477 TRACE( "%p, %p\n", propertyset
, count
);
479 hr
= IWbemClassObject_Get( propertyset
->object
, L
"__PROPERTY_COUNT", 0, &val
, NULL
, NULL
);
482 *count
= V_I4( &val
);
487 static HRESULT WINAPI
propertyset_Add( ISWbemPropertySet
*iface
, BSTR name
, WbemCimtypeEnum type
,
488 VARIANT_BOOL is_array
, LONG flags
, ISWbemProperty
**prop
)
494 static HRESULT WINAPI
propertyset_Remove( ISWbemPropertySet
*iface
, BSTR name
, LONG flags
)
500 static const ISWbemPropertySetVtbl propertyset_vtbl
=
502 propertyset_QueryInterface
,
505 propertyset_GetTypeInfoCount
,
506 propertyset_GetTypeInfo
,
507 propertyset_GetIDsOfNames
,
509 propertyset_get__NewEnum
,
511 propertyset_get_Count
,
516 static HRESULT
SWbemPropertySet_create( IWbemClassObject
*wbem_object
, ISWbemPropertySet
**obj
)
518 struct propertyset
*propertyset
;
520 TRACE( "%p, %p\n", obj
, wbem_object
);
522 if (!(propertyset
= malloc( sizeof(*propertyset
) ))) return E_OUTOFMEMORY
;
523 propertyset
->ISWbemPropertySet_iface
.lpVtbl
= &propertyset_vtbl
;
524 propertyset
->refs
= 1;
525 propertyset
->object
= wbem_object
;
526 IWbemClassObject_AddRef( propertyset
->object
);
527 *obj
= &propertyset
->ISWbemPropertySet_iface
;
529 TRACE( "returning iface %p\n", *obj
);
535 ISWbemServices ISWbemServices_iface
;
537 IWbemServices
*services
;
550 ISWbemObject ISWbemObject_iface
;
552 IWbemClassObject
*object
;
553 struct member
*members
;
556 DISPID last_dispid_method
;
557 struct services
*services
;
562 ISWbemMethodSet ISWbemMethodSet_iface
;
564 struct object
*object
;
569 ISWbemMethod ISWbemMethod_iface
;
571 struct methodset
*set
;
575 static struct method
*impl_from_ISWbemMethod( ISWbemMethod
*iface
)
577 return CONTAINING_RECORD( iface
, struct method
, ISWbemMethod_iface
);
580 static HRESULT WINAPI
method_QueryInterface( ISWbemMethod
*iface
, REFIID riid
, void **ppvObject
)
582 struct method
*method
= impl_from_ISWbemMethod( iface
);
584 TRACE( "%p %s %p\n", method
, debugstr_guid(riid
), ppvObject
);
586 if (IsEqualGUID( riid
, &IID_ISWbemMethod
) ||
587 IsEqualGUID( riid
, &IID_IDispatch
) ||
588 IsEqualGUID( riid
, &IID_IUnknown
))
594 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
595 return E_NOINTERFACE
;
597 ISWbemMethod_AddRef( iface
);
601 static ULONG WINAPI
method_AddRef( ISWbemMethod
*iface
)
603 struct method
*method
= impl_from_ISWbemMethod( iface
);
604 return InterlockedIncrement( &method
->refs
);
607 static ULONG WINAPI
method_Release( ISWbemMethod
*iface
)
609 struct method
*method
= impl_from_ISWbemMethod( iface
);
610 LONG refs
= InterlockedDecrement( &method
->refs
);
613 TRACE( "destroying %p\n", method
);
614 ISWbemMethodSet_Release( &method
->set
->ISWbemMethodSet_iface
);
615 free( method
->name
);
621 static HRESULT WINAPI
method_GetTypeInfoCount(
625 struct method
*method
= impl_from_ISWbemMethod( iface
);
627 TRACE( "%p, %p\n", method
, count
);
632 static HRESULT WINAPI
method_GetTypeInfo(
638 struct method
*method
= impl_from_ISWbemMethod( iface
);
640 TRACE( "%p, %u, %#lx, %p\n", method
, index
, lcid
, info
);
642 return get_typeinfo( ISWbemMethod_tid
, info
);
645 static HRESULT WINAPI
method_GetIDsOfNames(
653 struct method
*method
= impl_from_ISWbemMethod( iface
);
657 TRACE( "%p, %s, %p, %u, %#lx, %p\n", method
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
659 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
661 hr
= get_typeinfo( ISWbemMethod_tid
, &typeinfo
);
664 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
665 ITypeInfo_Release( typeinfo
);
670 static HRESULT WINAPI
method_Invoke(
678 EXCEPINFO
*excep_info
,
681 struct method
*method
= impl_from_ISWbemMethod( iface
);
685 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", method
, member
, debugstr_guid(riid
),
686 lcid
, flags
, params
, result
, excep_info
, arg_err
);
688 hr
= get_typeinfo( ISWbemMethod_tid
, &typeinfo
);
691 hr
= ITypeInfo_Invoke( typeinfo
, &method
->ISWbemMethod_iface
, member
, flags
,
692 params
, result
, excep_info
, arg_err
);
693 ITypeInfo_Release( typeinfo
);
698 static HRESULT WINAPI
method_get_Name(
707 static HRESULT WINAPI
method_get_Origin(
716 static HRESULT WINAPI
method_get_InParameters(
718 ISWbemObject
**params
)
720 struct method
*method
= impl_from_ISWbemMethod( iface
);
721 IWbemClassObject
*in_sign
= NULL
, *instance
;
724 TRACE("%p, %p\n", method
, params
);
728 if (SUCCEEDED(hr
= IWbemClassObject_GetMethod( method
->set
->object
->object
,
729 method
->name
, 0, &in_sign
, NULL
)) && in_sign
!= NULL
)
731 hr
= IWbemClassObject_SpawnInstance( in_sign
, 0, &instance
);
732 IWbemClassObject_Release( in_sign
);
735 hr
= SWbemObject_create( method
->set
->object
->services
, instance
, params
);
736 IWbemClassObject_Release( instance
);
743 static HRESULT WINAPI
method_get_OutParameters(
745 ISWbemObject
**params
)
752 static HRESULT WINAPI
method_get_Qualifiers_(
754 ISWbemQualifierSet
**qualifiers
)
761 static const ISWbemMethodVtbl methodvtbl
=
763 method_QueryInterface
,
766 method_GetTypeInfoCount
,
768 method_GetIDsOfNames
,
772 method_get_InParameters
,
773 method_get_OutParameters
,
774 method_get_Qualifiers_
,
777 static HRESULT
SWbemMethod_create( struct methodset
*set
, const WCHAR
*name
, ISWbemMethod
**obj
)
779 struct method
*method
;
781 if (!(method
= malloc( sizeof(*method
) ))) return E_OUTOFMEMORY
;
783 method
->ISWbemMethod_iface
.lpVtbl
= &methodvtbl
;
786 ISWbemMethodSet_AddRef( &method
->set
->ISWbemMethodSet_iface
);
787 if (!(method
->name
= heap_strdupW( name
)))
789 ISWbemMethod_Release( &method
->ISWbemMethod_iface
);
790 return E_OUTOFMEMORY
;
793 *obj
= &method
->ISWbemMethod_iface
;
798 static struct methodset
*impl_from_ISWbemMethodSet( ISWbemMethodSet
*iface
)
800 return CONTAINING_RECORD( iface
, struct methodset
, ISWbemMethodSet_iface
);
803 static HRESULT WINAPI
methodset_QueryInterface( ISWbemMethodSet
*iface
, REFIID riid
, void **ppvObject
)
805 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
807 TRACE( "%p %s %p\n", set
, debugstr_guid(riid
), ppvObject
);
809 if (IsEqualGUID( riid
, &IID_ISWbemMethodSet
) ||
810 IsEqualGUID( riid
, &IID_IDispatch
) ||
811 IsEqualGUID( riid
, &IID_IUnknown
))
817 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
818 return E_NOINTERFACE
;
820 ISWbemMethodSet_AddRef( iface
);
824 static ULONG WINAPI
methodset_AddRef( ISWbemMethodSet
*iface
)
826 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
827 return InterlockedIncrement( &set
->refs
);
830 static ULONG WINAPI
methodset_Release( ISWbemMethodSet
*iface
)
832 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
833 LONG refs
= InterlockedDecrement( &set
->refs
);
836 TRACE( "destroying %p\n", set
);
837 ISWbemObject_Release( &set
->object
->ISWbemObject_iface
);
843 static HRESULT WINAPI
methodset_GetTypeInfoCount(
844 ISWbemMethodSet
*iface
,
847 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
849 TRACE( "%p, %p\n", set
, count
);
854 static HRESULT WINAPI
methodset_GetTypeInfo( ISWbemMethodSet
*iface
,
859 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
861 TRACE( "%p, %u, %#lx, %p\n", set
, index
, lcid
, info
);
863 return get_typeinfo( ISWbemMethodSet_tid
, info
);
866 static HRESULT WINAPI
methodset_GetIDsOfNames(
867 ISWbemMethodSet
*iface
,
874 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
878 TRACE( "%p, %s, %p, %u, %#lx, %p\n", set
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
880 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
882 hr
= get_typeinfo( ISWbemMethodSet_tid
, &typeinfo
);
885 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
886 ITypeInfo_Release( typeinfo
);
891 static HRESULT WINAPI
methodset_Invoke(
892 ISWbemMethodSet
*iface
,
899 EXCEPINFO
*excep_info
,
902 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
906 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", set
, member
, debugstr_guid(riid
),
907 lcid
, flags
, params
, result
, excep_info
, arg_err
);
909 hr
= get_typeinfo( ISWbemMethodSet_tid
, &typeinfo
);
912 hr
= ITypeInfo_Invoke( typeinfo
, &set
->ISWbemMethodSet_iface
, member
, flags
,
913 params
, result
, excep_info
, arg_err
);
914 ITypeInfo_Release( typeinfo
);
919 static HRESULT WINAPI
methodset_get__NewEnum(
920 ISWbemMethodSet
*iface
,
928 static HRESULT WINAPI
methodset_Item(
929 ISWbemMethodSet
*iface
,
932 ISWbemMethod
**method
)
934 struct methodset
*set
= impl_from_ISWbemMethodSet( iface
);
935 IWbemClassObject
*in_sign
, *out_sign
;
938 TRACE("%p, %s, %#lx, %p\n", set
, debugstr_w(name
), flags
, method
);
942 if (SUCCEEDED(hr
= IWbemClassObject_GetMethod( set
->object
->object
,
943 name
, flags
, &in_sign
, &out_sign
)))
946 IWbemClassObject_Release( in_sign
);
948 IWbemClassObject_Release( out_sign
);
950 return SWbemMethod_create( set
, name
, method
);
956 static HRESULT WINAPI
methodset_get_Count(
957 ISWbemMethodSet
*iface
,
965 static const ISWbemMethodSetVtbl methodsetvtbl
=
967 methodset_QueryInterface
,
970 methodset_GetTypeInfoCount
,
971 methodset_GetTypeInfo
,
972 methodset_GetIDsOfNames
,
974 methodset_get__NewEnum
,
979 static HRESULT
SWbemMethodSet_create( struct object
*object
, ISWbemMethodSet
**obj
)
981 struct methodset
*set
;
983 if (!(set
= malloc( sizeof(*set
) ))) return E_OUTOFMEMORY
;
985 set
->ISWbemMethodSet_iface
.lpVtbl
= &methodsetvtbl
;
987 set
->object
= object
;
988 ISWbemObject_AddRef( &object
->ISWbemObject_iface
);
990 *obj
= &set
->ISWbemMethodSet_iface
;
995 #define DISPID_BASE 0x1800000
996 #define DISPID_BASE_METHOD 0x1000000
998 static inline struct object
*impl_from_ISWbemObject(
999 ISWbemObject
*iface
)
1001 return CONTAINING_RECORD( iface
, struct object
, ISWbemObject_iface
);
1004 static ULONG WINAPI
object_AddRef(
1005 ISWbemObject
*iface
)
1007 struct object
*object
= impl_from_ISWbemObject( iface
);
1008 return InterlockedIncrement( &object
->refs
);
1011 static ULONG WINAPI
object_Release(
1012 ISWbemObject
*iface
)
1014 struct object
*object
= impl_from_ISWbemObject( iface
);
1015 LONG refs
= InterlockedDecrement( &object
->refs
);
1020 TRACE( "destroying %p\n", object
);
1021 IWbemClassObject_Release( object
->object
);
1022 ISWbemServices_Release( &object
->services
->ISWbemServices_iface
);
1023 for (i
= 0; i
< object
->nb_members
; i
++) SysFreeString( object
->members
[i
].name
);
1024 free( object
->members
);
1030 static HRESULT WINAPI
object_QueryInterface(
1031 ISWbemObject
*iface
,
1035 struct object
*object
= impl_from_ISWbemObject( iface
);
1037 TRACE( "%p %s %p\n", object
, debugstr_guid(riid
), ppvObject
);
1039 if (IsEqualGUID( riid
, &IID_ISWbemObject
) ||
1040 IsEqualGUID( riid
, &IID_IDispatch
) ||
1041 IsEqualGUID( riid
, &IID_IUnknown
))
1047 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
1048 return E_NOINTERFACE
;
1050 ISWbemObject_AddRef( iface
);
1054 static HRESULT WINAPI
object_GetTypeInfoCount(
1055 ISWbemObject
*iface
,
1058 struct object
*object
= impl_from_ISWbemObject( iface
);
1060 TRACE( "%p, %p\n", object
, count
);
1065 static HRESULT WINAPI
object_GetTypeInfo(
1066 ISWbemObject
*iface
,
1071 struct object
*object
= impl_from_ISWbemObject( iface
);
1072 FIXME( "%p, %u, %#lx, %p\n", object
, index
, lcid
, info
);
1076 static BOOL
object_reserve_member( struct object
*object
, unsigned int count
, unsigned int *capacity
)
1078 unsigned int new_capacity
, max_capacity
;
1079 struct member
*new_members
;
1081 if (count
<= *capacity
)
1084 max_capacity
= ~0u / sizeof(*object
->members
);
1085 if (count
> max_capacity
)
1088 new_capacity
= max(4, *capacity
);
1089 while (new_capacity
< count
&& new_capacity
<= max_capacity
/ 2)
1091 if (new_capacity
< count
)
1092 new_capacity
= max_capacity
;
1094 if (!(new_members
= realloc( object
->members
, new_capacity
* sizeof(*new_members
) )))
1097 object
->members
= new_members
;
1098 *capacity
= new_capacity
;
1103 static HRESULT
init_members( struct object
*object
)
1105 IWbemClassObject
*sig_in
, *sig_out
;
1106 unsigned int i
, capacity
= 0, count
= 0;
1111 if (object
->members
) return S_OK
;
1113 hr
= IWbemClassObject_BeginEnumeration( object
->object
, 0 );
1114 if (SUCCEEDED( hr
))
1116 while (IWbemClassObject_Next( object
->object
, 0, &name
, NULL
, &type
, NULL
) == S_OK
)
1118 if (!object_reserve_member( object
, count
+ 1, &capacity
)) goto error
;
1119 object
->members
[count
].name
= name
;
1120 object
->members
[count
].is_method
= FALSE
;
1121 object
->members
[count
].dispid
= 0;
1122 object
->members
[count
].type
= type
;
1124 TRACE( "added property %s\n", debugstr_w(name
) );
1126 IWbemClassObject_EndEnumeration( object
->object
);
1129 hr
= IWbemClassObject_BeginMethodEnumeration( object
->object
, 0 );
1130 if (SUCCEEDED( hr
))
1132 while (IWbemClassObject_NextMethod( object
->object
, 0, &name
, &sig_in
, &sig_out
) == S_OK
)
1134 if (!object_reserve_member( object
, count
+ 1, &capacity
)) goto error
;
1135 object
->members
[count
].name
= name
;
1136 object
->members
[count
].is_method
= TRUE
;
1137 object
->members
[count
].dispid
= 0;
1139 if (sig_in
) IWbemClassObject_Release( sig_in
);
1140 if (sig_out
) IWbemClassObject_Release( sig_out
);
1141 TRACE( "added method %s\n", debugstr_w(name
) );
1143 IWbemClassObject_EndMethodEnumeration( object
->object
);
1146 object
->nb_members
= count
;
1147 TRACE( "added %u members\n", object
->nb_members
);
1151 for (i
= 0; i
< count
; ++i
)
1152 SysFreeString( object
->members
[i
].name
);
1153 free( object
->members
);
1154 object
->members
= NULL
;
1155 object
->nb_members
= 0;
1159 static DISPID
get_member_dispid( struct object
*object
, const WCHAR
*name
)
1162 for (i
= 0; i
< object
->nb_members
; i
++)
1164 if (!wcsicmp( object
->members
[i
].name
, name
))
1166 if (!object
->members
[i
].dispid
)
1168 if (object
->members
[i
].is_method
)
1169 object
->members
[i
].dispid
= ++object
->last_dispid_method
;
1171 object
->members
[i
].dispid
= ++object
->last_dispid
;
1173 return object
->members
[i
].dispid
;
1176 return DISPID_UNKNOWN
;
1179 static HRESULT WINAPI
object_GetIDsOfNames(
1180 ISWbemObject
*iface
,
1187 struct object
*object
= impl_from_ISWbemObject( iface
);
1190 ITypeInfo
*typeinfo
;
1192 TRACE( "%p, %s, %p, %u, %#lx, %p\n", object
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
1194 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
1196 hr
= init_members( object
);
1197 if (FAILED( hr
)) return hr
;
1199 hr
= get_typeinfo( ISWbemObject_tid
, &typeinfo
);
1202 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
1203 ITypeInfo_Release( typeinfo
);
1205 if (SUCCEEDED(hr
)) return hr
;
1207 for (i
= 0; i
< count
; i
++)
1209 if ((dispid
[i
] = get_member_dispid( object
, names
[i
] )) == DISPID_UNKNOWN
) break;
1211 if (i
!= count
) return DISP_E_UNKNOWNNAME
;
1215 static BSTR
get_member_name( struct object
*object
, DISPID dispid
, CIMTYPE
*type
)
1218 for (i
= 0; i
< object
->nb_members
; i
++)
1220 if (object
->members
[i
].dispid
== dispid
)
1222 *type
= object
->members
[i
].type
;
1223 return object
->members
[i
].name
;
1229 static VARTYPE
to_vartype( CIMTYPE type
)
1233 case CIM_BOOLEAN
: return VT_BOOL
;
1237 case CIM_DATETIME
: return VT_BSTR
;
1239 case CIM_SINT8
: return VT_I1
;
1240 case CIM_UINT8
: return VT_UI1
;
1241 case CIM_SINT16
: return VT_I2
;
1244 case CIM_SINT32
: return VT_I4
;
1246 case CIM_UINT32
: return VT_UI4
;
1248 case CIM_SINT64
: return VT_I8
;
1249 case CIM_UINT64
: return VT_UI8
;
1251 case CIM_REAL32
: return VT_R4
;
1254 ERR( "unhandled type %lu\n", type
);
1260 static HRESULT WINAPI
object_Invoke(
1261 ISWbemObject
*iface
,
1268 EXCEPINFO
*excep_info
,
1271 struct object
*object
= impl_from_ISWbemObject( iface
);
1273 ITypeInfo
*typeinfo
;
1279 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", object
, member
, debugstr_guid(riid
),
1280 lcid
, flags
, params
, result
, excep_info
, arg_err
);
1282 if (member
<= DISPID_BASE_METHOD
)
1284 hr
= get_typeinfo( ISWbemObject_tid
, &typeinfo
);
1287 hr
= ITypeInfo_Invoke( typeinfo
, &object
->ISWbemObject_iface
, member
, flags
,
1288 params
, result
, excep_info
, arg_err
);
1289 ITypeInfo_Release( typeinfo
);
1294 if (!(name
= get_member_name( object
, member
, &type
)))
1295 return DISP_E_MEMBERNOTFOUND
;
1297 if (flags
== (DISPATCH_METHOD
|DISPATCH_PROPERTYGET
))
1299 memset( params
, 0, sizeof(*params
) );
1300 return IWbemClassObject_Get( object
->object
, name
, 0, result
, NULL
, NULL
);
1302 else if (flags
== DISPATCH_PROPERTYPUT
)
1304 if (!params
->cArgs
|| !params
->rgvarg
)
1306 WARN( "Missing put property value\n" );
1307 return E_INVALIDARG
;
1310 vartype
= to_vartype( type
);
1311 V_VT( &value
) = VT_EMPTY
;
1312 if (SUCCEEDED(hr
= VariantChangeType( &value
, params
->rgvarg
, 0, vartype
)))
1314 hr
= IWbemClassObject_Put( object
->object
, name
, 0, &value
, 0 );
1315 VariantClear( &value
);
1321 FIXME( "flags %#x not supported\n", flags
);
1326 static HRESULT WINAPI
object_Put_(
1327 ISWbemObject
*iface
,
1329 IDispatch
*objWbemNamedValueSet
,
1330 ISWbemObjectPath
**objWbemObjectPath
)
1336 static HRESULT WINAPI
object_PutAsync_(
1337 ISWbemObject
*iface
,
1338 IDispatch
*objWbemSink
,
1340 IDispatch
*objWbemNamedValueSet
,
1341 IDispatch
*objWbemAsyncContext
)
1347 static HRESULT WINAPI
object_Delete_(
1348 ISWbemObject
*iface
,
1350 IDispatch
*objWbemNamedValueSet
)
1356 static HRESULT WINAPI
object_DeleteAsync_(
1357 ISWbemObject
*iface
,
1358 IDispatch
*objWbemSink
,
1360 IDispatch
*objWbemNamedValueSet
,
1361 IDispatch
*objWbemAsyncContext
)
1367 static HRESULT WINAPI
object_Instances_(
1368 ISWbemObject
*iface
,
1370 IDispatch
*objWbemNamedValueSet
,
1371 ISWbemObjectSet
**objWbemObjectSet
)
1377 static HRESULT WINAPI
object_InstancesAsync_(
1378 ISWbemObject
*iface
,
1379 IDispatch
*objWbemSink
,
1381 IDispatch
*objWbemNamedValueSet
,
1382 IDispatch
*objWbemAsyncContext
)
1388 static HRESULT WINAPI
object_Subclasses_(
1389 ISWbemObject
*iface
,
1391 IDispatch
*objWbemNamedValueSet
,
1392 ISWbemObjectSet
**objWbemObjectSet
)
1398 static HRESULT WINAPI
object_SubclassesAsync_(
1399 ISWbemObject
*iface
,
1400 IDispatch
*objWbemSink
,
1402 IDispatch
*objWbemNamedValueSet
,
1403 IDispatch
*objWbemAsyncContext
)
1409 static HRESULT WINAPI
object_Associators_(
1410 ISWbemObject
*iface
,
1412 BSTR strResultClass
,
1415 VARIANT_BOOL bClassesOnly
,
1416 VARIANT_BOOL bSchemaOnly
,
1417 BSTR strRequiredAssocQualifier
,
1418 BSTR strRequiredQualifier
,
1420 IDispatch
*objWbemNamedValueSet
,
1421 ISWbemObjectSet
**objWbemObjectSet
)
1427 static HRESULT WINAPI
object_AssociatorsAsync_(
1428 ISWbemObject
*iface
,
1429 IDispatch
*objWbemSink
,
1431 BSTR strResultClass
,
1434 VARIANT_BOOL bClassesOnly
,
1435 VARIANT_BOOL bSchemaOnly
,
1436 BSTR strRequiredAssocQualifier
,
1437 BSTR strRequiredQualifier
,
1439 IDispatch
*objWbemNamedValueSet
,
1440 IDispatch
*objWbemAsyncContext
)
1446 static HRESULT WINAPI
object_References_(
1447 ISWbemObject
*iface
,
1448 BSTR strResultClass
,
1450 VARIANT_BOOL bClassesOnly
,
1451 VARIANT_BOOL bSchemaOnly
,
1452 BSTR strRequiredQualifier
,
1454 IDispatch
*objWbemNamedValueSet
,
1455 ISWbemObjectSet
**objWbemObjectSet
)
1461 static HRESULT WINAPI
object_ReferencesAsync_(
1462 ISWbemObject
*iface
,
1463 IDispatch
*objWbemSink
,
1464 BSTR strResultClass
,
1466 VARIANT_BOOL bClassesOnly
,
1467 VARIANT_BOOL bSchemaOnly
,
1468 BSTR strRequiredQualifier
,
1470 IDispatch
*objWbemNamedValueSet
,
1471 IDispatch
*objWbemAsyncContext
)
1477 static HRESULT WINAPI
object_ExecMethod_(
1478 ISWbemObject
*iface
,
1480 IDispatch
*in_params
,
1482 IDispatch
*valueset
,
1483 ISWbemObject
**out_params
)
1485 struct object
*object
= impl_from_ISWbemObject( iface
);
1489 TRACE( "%p, %s, %p, %#lx, %p, %p\n", object
, debugstr_w(method
), in_params
, flags
, valueset
, out_params
);
1491 V_VT( &path
) = VT_EMPTY
;
1492 hr
= IWbemClassObject_Get( object
->object
, L
"__PATH", 0, &path
, NULL
, NULL
);
1495 if (V_VT( &path
) != VT_BSTR
)
1497 WARN( "Unexpected object path value type.\n" );
1498 VariantClear( &path
);
1499 return E_UNEXPECTED
;
1502 hr
= ISWbemServices_ExecMethod( &object
->services
->ISWbemServices_iface
, V_BSTR( &path
), method
,
1503 in_params
, flags
, valueset
, out_params
);
1505 VariantClear( &path
);
1511 static HRESULT WINAPI
object_ExecMethodAsync_(
1512 ISWbemObject
*iface
,
1513 IDispatch
*objWbemSink
,
1515 IDispatch
*objWbemInParameters
,
1517 IDispatch
*objWbemNamedValueSet
,
1518 IDispatch
*objWbemAsyncContext
)
1524 static HRESULT WINAPI
object_Clone_(
1525 ISWbemObject
*iface
,
1526 ISWbemObject
**objWbemObject
)
1532 static HRESULT WINAPI
object_GetObjectText_(
1533 ISWbemObject
*iface
,
1537 struct object
*object
= impl_from_ISWbemObject( iface
);
1539 TRACE( "%p, %#lx, %p\n", object
, flags
, text
);
1541 return IWbemClassObject_GetObjectText( object
->object
, flags
, text
);
1544 static HRESULT WINAPI
object_SpawnDerivedClass_(
1545 ISWbemObject
*iface
,
1547 ISWbemObject
**objWbemObject
)
1553 static HRESULT WINAPI
object_SpawnInstance_(
1554 ISWbemObject
*iface
,
1556 ISWbemObject
**objWbemObject
)
1562 static HRESULT WINAPI
object_CompareTo_(
1563 ISWbemObject
*iface
,
1564 IDispatch
*objWbemObject
,
1566 VARIANT_BOOL
*bResult
)
1572 static HRESULT WINAPI
object_get_Qualifiers_(
1573 ISWbemObject
*iface
,
1574 ISWbemQualifierSet
**objWbemQualifierSet
)
1580 static HRESULT WINAPI
object_get_Properties_( ISWbemObject
*iface
, ISWbemPropertySet
**prop_set
)
1582 struct object
*object
= impl_from_ISWbemObject( iface
);
1584 TRACE( "%p, %p\n", object
, prop_set
);
1585 return SWbemPropertySet_create( object
->object
, prop_set
);
1588 static HRESULT WINAPI
object_get_Methods_(
1589 ISWbemObject
*iface
,
1590 ISWbemMethodSet
**set
)
1592 struct object
*object
= impl_from_ISWbemObject( iface
);
1594 TRACE( "%p, %p\n", object
, set
);
1595 return SWbemMethodSet_create( object
, set
);
1598 static HRESULT WINAPI
object_get_Derivation_(
1599 ISWbemObject
*iface
,
1600 VARIANT
*strClassNameArray
)
1606 static HRESULT WINAPI
object_get_Path_(
1607 ISWbemObject
*iface
,
1608 ISWbemObjectPath
**objWbemObjectPath
)
1614 static HRESULT WINAPI
object_get_Security_(
1615 ISWbemObject
*iface
,
1616 ISWbemSecurity
**objWbemSecurity
)
1622 static const ISWbemObjectVtbl object_vtbl
=
1624 object_QueryInterface
,
1627 object_GetTypeInfoCount
,
1629 object_GetIDsOfNames
,
1634 object_DeleteAsync_
,
1636 object_InstancesAsync_
,
1638 object_SubclassesAsync_
,
1639 object_Associators_
,
1640 object_AssociatorsAsync_
,
1642 object_ReferencesAsync_
,
1644 object_ExecMethodAsync_
,
1646 object_GetObjectText_
,
1647 object_SpawnDerivedClass_
,
1648 object_SpawnInstance_
,
1650 object_get_Qualifiers_
,
1651 object_get_Properties_
,
1652 object_get_Methods_
,
1653 object_get_Derivation_
,
1655 object_get_Security_
1658 static struct object
*unsafe_object_impl_from_IDispatch(IDispatch
*iface
)
1662 if (iface
->lpVtbl
!= (IDispatchVtbl
*)&object_vtbl
)
1664 FIXME( "External implementations are not supported.\n" );
1667 return CONTAINING_RECORD(iface
, struct object
, ISWbemObject_iface
);
1670 static HRESULT
SWbemObject_create( struct services
*services
, IWbemClassObject
*wbem_object
,
1671 ISWbemObject
**obj
)
1673 struct object
*object
;
1675 TRACE( "%p, %p\n", obj
, wbem_object
);
1677 if (!(object
= malloc( sizeof(*object
) ))) return E_OUTOFMEMORY
;
1678 object
->ISWbemObject_iface
.lpVtbl
= &object_vtbl
;
1680 object
->object
= wbem_object
;
1681 IWbemClassObject_AddRef( object
->object
);
1682 object
->members
= NULL
;
1683 object
->nb_members
= 0;
1684 object
->last_dispid
= DISPID_BASE
;
1685 object
->last_dispid_method
= DISPID_BASE_METHOD
;
1686 object
->services
= services
;
1687 ISWbemServices_AddRef( &object
->services
->ISWbemServices_iface
);
1689 *obj
= &object
->ISWbemObject_iface
;
1690 TRACE( "returning iface %p\n", *obj
);
1696 ISWbemObjectSet ISWbemObjectSet_iface
;
1698 IEnumWbemClassObject
*objectenum
;
1700 struct services
*services
;
1703 static inline struct objectset
*impl_from_ISWbemObjectSet(
1704 ISWbemObjectSet
*iface
)
1706 return CONTAINING_RECORD( iface
, struct objectset
, ISWbemObjectSet_iface
);
1709 static ULONG WINAPI
objectset_AddRef(
1710 ISWbemObjectSet
*iface
)
1712 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1713 return InterlockedIncrement( &objectset
->refs
);
1716 static ULONG WINAPI
objectset_Release(
1717 ISWbemObjectSet
*iface
)
1719 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1720 LONG refs
= InterlockedDecrement( &objectset
->refs
);
1723 TRACE( "destroying %p\n", objectset
);
1724 IEnumWbemClassObject_Release( objectset
->objectenum
);
1725 ISWbemServices_Release( &objectset
->services
->ISWbemServices_iface
);
1731 static HRESULT WINAPI
objectset_QueryInterface(
1732 ISWbemObjectSet
*iface
,
1736 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1738 TRACE( "%p %s %p\n", objectset
, debugstr_guid(riid
), ppvObject
);
1740 if (IsEqualGUID( riid
, &IID_ISWbemObjectSet
) ||
1741 IsEqualGUID( riid
, &IID_IDispatch
) ||
1742 IsEqualGUID( riid
, &IID_IUnknown
))
1748 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
1749 return E_NOINTERFACE
;
1751 ISWbemObjectSet_AddRef( iface
);
1755 static HRESULT WINAPI
objectset_GetTypeInfoCount(
1756 ISWbemObjectSet
*iface
,
1759 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1760 TRACE( "%p, %p\n", objectset
, count
);
1765 static HRESULT WINAPI
objectset_GetTypeInfo(
1766 ISWbemObjectSet
*iface
,
1771 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1772 TRACE( "%p, %u, %#lx, %p\n", objectset
, index
, lcid
, info
);
1774 return get_typeinfo( ISWbemObjectSet_tid
, info
);
1777 static HRESULT WINAPI
objectset_GetIDsOfNames(
1778 ISWbemObjectSet
*iface
,
1785 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1786 ITypeInfo
*typeinfo
;
1789 TRACE( "%p, %s, %p, %u, %#lx, %p\n", objectset
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
1791 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
1793 hr
= get_typeinfo( ISWbemObjectSet_tid
, &typeinfo
);
1796 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
1797 ITypeInfo_Release( typeinfo
);
1802 static HRESULT WINAPI
objectset_Invoke(
1803 ISWbemObjectSet
*iface
,
1810 EXCEPINFO
*excep_info
,
1813 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1814 ITypeInfo
*typeinfo
;
1817 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", objectset
, member
, debugstr_guid(riid
),
1818 lcid
, flags
, params
, result
, excep_info
, arg_err
);
1820 hr
= get_typeinfo( ISWbemObjectSet_tid
, &typeinfo
);
1823 hr
= ITypeInfo_Invoke( typeinfo
, &objectset
->ISWbemObjectSet_iface
, member
, flags
,
1824 params
, result
, excep_info
, arg_err
);
1825 ITypeInfo_Release( typeinfo
);
1830 static HRESULT WINAPI
objectset_get__NewEnum(
1831 ISWbemObjectSet
*iface
,
1834 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1835 IEnumWbemClassObject
*objectenum
;
1838 TRACE( "%p, %p\n", objectset
, pUnk
);
1840 hr
= IEnumWbemClassObject_Clone( objectset
->objectenum
, &objectenum
);
1841 if (FAILED( hr
)) return hr
;
1843 hr
= EnumVARIANT_create( objectset
->services
, objectenum
, (IEnumVARIANT
**)pUnk
);
1844 IEnumWbemClassObject_Release( objectenum
);
1848 static HRESULT WINAPI
objectset_Item(
1849 ISWbemObjectSet
*iface
,
1852 ISWbemObject
**objWbemObject
)
1858 static HRESULT WINAPI
objectset_get_Count(
1859 ISWbemObjectSet
*iface
,
1862 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1864 TRACE( "%p, %p\n", objectset
, iCount
);
1866 *iCount
= objectset
->count
;
1870 static HRESULT WINAPI
objectset_get_Security_(
1871 ISWbemObjectSet
*iface
,
1872 ISWbemSecurity
**objWbemSecurity
)
1878 static HRESULT WINAPI
objectset_ItemIndex(
1879 ISWbemObjectSet
*iface
,
1881 ISWbemObject
**objWbemObject
)
1883 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1886 IEnumVARIANT
*enum_var
;
1889 TRACE( "%p, %ld, %p\n", objectset
, lIndex
, objWbemObject
);
1891 *objWbemObject
= NULL
;
1892 hr
= ISWbemObjectSet_get_Count( iface
, &count
);
1893 if (FAILED(hr
)) return hr
;
1895 if (lIndex
>= count
) return WBEM_E_NOT_FOUND
;
1897 hr
= ISWbemObjectSet_get__NewEnum( iface
, (IUnknown
**)&enum_var
);
1898 if (FAILED(hr
)) return hr
;
1900 IEnumVARIANT_Reset( enum_var
);
1901 hr
= IEnumVARIANT_Skip( enum_var
, lIndex
);
1903 hr
= IEnumVARIANT_Next( enum_var
, 1, &var
, NULL
);
1904 IEnumVARIANT_Release( enum_var
);
1908 if (V_VT( &var
) == VT_DISPATCH
)
1909 hr
= IDispatch_QueryInterface( V_DISPATCH( &var
), &IID_ISWbemObject
, (void **)objWbemObject
);
1911 hr
= WBEM_E_NOT_FOUND
;
1912 VariantClear( &var
);
1918 static const ISWbemObjectSetVtbl objectset_vtbl
=
1920 objectset_QueryInterface
,
1923 objectset_GetTypeInfoCount
,
1924 objectset_GetTypeInfo
,
1925 objectset_GetIDsOfNames
,
1927 objectset_get__NewEnum
,
1929 objectset_get_Count
,
1930 objectset_get_Security_
,
1934 static LONG
get_object_count( IEnumWbemClassObject
*iter
)
1937 while (IEnumWbemClassObject_Skip( iter
, WBEM_INFINITE
, 1 ) == S_OK
) count
++;
1938 IEnumWbemClassObject_Reset( iter
);
1942 static HRESULT
SWbemObjectSet_create( struct services
*services
, IEnumWbemClassObject
*wbem_objectenum
,
1943 ISWbemObjectSet
**obj
)
1945 struct objectset
*objectset
;
1947 TRACE( "%p, %p\n", obj
, wbem_objectenum
);
1949 if (!(objectset
= malloc( sizeof(*objectset
) ))) return E_OUTOFMEMORY
;
1950 objectset
->ISWbemObjectSet_iface
.lpVtbl
= &objectset_vtbl
;
1951 objectset
->refs
= 1;
1952 objectset
->objectenum
= wbem_objectenum
;
1953 IEnumWbemClassObject_AddRef( objectset
->objectenum
);
1954 objectset
->count
= get_object_count( objectset
->objectenum
);
1955 objectset
->services
= services
;
1956 ISWbemServices_AddRef( &services
->ISWbemServices_iface
);
1958 *obj
= &objectset
->ISWbemObjectSet_iface
;
1959 TRACE( "returning iface %p\n", *obj
);
1965 IEnumVARIANT IEnumVARIANT_iface
;
1967 IEnumWbemClassObject
*objectenum
;
1968 struct services
*services
;
1971 static inline struct enumvar
*impl_from_IEnumVARIANT(
1972 IEnumVARIANT
*iface
)
1974 return CONTAINING_RECORD( iface
, struct enumvar
, IEnumVARIANT_iface
);
1977 static ULONG WINAPI
enumvar_AddRef(
1978 IEnumVARIANT
*iface
)
1980 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1981 return InterlockedIncrement( &enumvar
->refs
);
1984 static ULONG WINAPI
enumvar_Release(
1985 IEnumVARIANT
*iface
)
1987 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1988 LONG refs
= InterlockedDecrement( &enumvar
->refs
);
1991 TRACE( "destroying %p\n", enumvar
);
1992 IEnumWbemClassObject_Release( enumvar
->objectenum
);
1993 ISWbemServices_Release( &enumvar
->services
->ISWbemServices_iface
);
1999 static HRESULT WINAPI
enumvar_QueryInterface(
2000 IEnumVARIANT
*iface
,
2004 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
2006 TRACE( "%p %s %p\n", enumvar
, debugstr_guid(riid
), ppvObject
);
2008 if (IsEqualGUID( riid
, &IID_IEnumVARIANT
) ||
2009 IsEqualGUID( riid
, &IID_IUnknown
))
2015 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
2016 return E_NOINTERFACE
;
2018 IEnumVARIANT_AddRef( iface
);
2022 static HRESULT WINAPI
enumvar_Next( IEnumVARIANT
*iface
, ULONG celt
, VARIANT
*var
, ULONG
*fetched
)
2024 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
2025 IWbemClassObject
*obj
;
2028 TRACE( "%p, %lu, %p, %p\n", iface
, celt
, var
, fetched
);
2030 if (celt
) IEnumWbemClassObject_Next( enumvar
->objectenum
, WBEM_INFINITE
, 1, &obj
, &count
);
2036 hr
= SWbemObject_create( enumvar
->services
, obj
, &sobj
);
2037 IWbemClassObject_Release( obj
);
2038 if (FAILED( hr
)) return hr
;
2040 V_VT( var
) = VT_DISPATCH
;
2041 V_DISPATCH( var
) = (IDispatch
*)sobj
;
2043 if (fetched
) *fetched
= count
;
2044 return (count
< celt
) ? S_FALSE
: S_OK
;
2047 static HRESULT WINAPI
enumvar_Skip( IEnumVARIANT
*iface
, ULONG celt
)
2049 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
2051 TRACE( "%p, %lu\n", iface
, celt
);
2053 return IEnumWbemClassObject_Skip( enumvar
->objectenum
, WBEM_INFINITE
, celt
);
2056 static HRESULT WINAPI
enumvar_Reset( IEnumVARIANT
*iface
)
2058 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
2060 TRACE( "%p\n", iface
);
2062 return IEnumWbemClassObject_Reset( enumvar
->objectenum
);
2065 static HRESULT WINAPI
enumvar_Clone( IEnumVARIANT
*iface
, IEnumVARIANT
**penum
)
2067 FIXME( "%p, %p\n", iface
, penum
);
2071 static const struct IEnumVARIANTVtbl enumvar_vtbl
=
2073 enumvar_QueryInterface
,
2082 static HRESULT
EnumVARIANT_create( struct services
*services
, IEnumWbemClassObject
*objectenum
,
2083 IEnumVARIANT
**obj
)
2085 struct enumvar
*enumvar
;
2087 if (!(enumvar
= malloc( sizeof(*enumvar
) ))) return E_OUTOFMEMORY
;
2088 enumvar
->IEnumVARIANT_iface
.lpVtbl
= &enumvar_vtbl
;
2090 enumvar
->objectenum
= objectenum
;
2091 IEnumWbemClassObject_AddRef( enumvar
->objectenum
);
2092 enumvar
->services
= services
;
2093 ISWbemServices_AddRef( &services
->ISWbemServices_iface
);
2095 *obj
= &enumvar
->IEnumVARIANT_iface
;
2096 TRACE( "returning iface %p\n", *obj
);
2100 static inline struct services
*impl_from_ISWbemServices(
2101 ISWbemServices
*iface
)
2103 return CONTAINING_RECORD( iface
, struct services
, ISWbemServices_iface
);
2106 static ULONG WINAPI
services_AddRef(
2107 ISWbemServices
*iface
)
2109 struct services
*services
= impl_from_ISWbemServices( iface
);
2110 return InterlockedIncrement( &services
->refs
);
2113 static ULONG WINAPI
services_Release(
2114 ISWbemServices
*iface
)
2116 struct services
*services
= impl_from_ISWbemServices( iface
);
2117 LONG refs
= InterlockedDecrement( &services
->refs
);
2120 TRACE( "destroying %p\n", services
);
2121 IWbemServices_Release( services
->services
);
2127 static HRESULT WINAPI
services_QueryInterface(
2128 ISWbemServices
*iface
,
2132 struct services
*services
= impl_from_ISWbemServices( iface
);
2134 TRACE( "%p %s %p\n", services
, debugstr_guid(riid
), ppvObject
);
2136 if (IsEqualGUID( riid
, &IID_ISWbemServices
) ||
2137 IsEqualGUID( riid
, &IID_IDispatch
) ||
2138 IsEqualGUID( riid
, &IID_IUnknown
))
2144 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
2145 return E_NOINTERFACE
;
2147 ISWbemServices_AddRef( iface
);
2151 static HRESULT WINAPI
services_GetTypeInfoCount(
2152 ISWbemServices
*iface
,
2155 struct services
*services
= impl_from_ISWbemServices( iface
);
2156 TRACE( "%p, %p\n", services
, count
);
2162 static HRESULT WINAPI
services_GetTypeInfo(
2163 ISWbemServices
*iface
,
2168 struct services
*services
= impl_from_ISWbemServices( iface
);
2169 TRACE( "%p, %u, %#lx, %p\n", services
, index
, lcid
, info
);
2171 return get_typeinfo( ISWbemServices_tid
, info
);
2174 static HRESULT WINAPI
services_GetIDsOfNames(
2175 ISWbemServices
*iface
,
2182 struct services
*services
= impl_from_ISWbemServices( iface
);
2183 ITypeInfo
*typeinfo
;
2186 TRACE( "%p, %s, %p, %u, %#lx, %p\n", services
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
2188 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
2190 hr
= get_typeinfo( ISWbemServices_tid
, &typeinfo
);
2193 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
2194 ITypeInfo_Release( typeinfo
);
2199 static HRESULT WINAPI
services_Invoke(
2200 ISWbemServices
*iface
,
2207 EXCEPINFO
*excep_info
,
2210 struct services
*services
= impl_from_ISWbemServices( iface
);
2211 ITypeInfo
*typeinfo
;
2214 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", services
, member
, debugstr_guid(riid
),
2215 lcid
, flags
, params
, result
, excep_info
, arg_err
);
2217 hr
= get_typeinfo( ISWbemServices_tid
, &typeinfo
);
2220 hr
= ITypeInfo_Invoke( typeinfo
, &services
->ISWbemServices_iface
, member
, flags
,
2221 params
, result
, excep_info
, arg_err
);
2222 ITypeInfo_Release( typeinfo
);
2227 static HRESULT WINAPI
services_Get(
2228 ISWbemServices
*iface
,
2231 IDispatch
*objWbemNamedValueSet
,
2232 ISWbemObject
**objWbemObject
)
2234 struct services
*services
= impl_from_ISWbemServices( iface
);
2235 IWbemClassObject
*obj
;
2238 TRACE( "%p, %s, %#lx, %p, %p\n", iface
, debugstr_w(strObjectPath
), iFlags
, objWbemNamedValueSet
,
2241 if (objWbemNamedValueSet
) FIXME( "ignoring context\n" );
2243 hr
= IWbemServices_GetObject( services
->services
, strObjectPath
, iFlags
, NULL
, &obj
, NULL
);
2244 if (hr
!= S_OK
) return hr
;
2246 hr
= SWbemObject_create( services
, obj
, objWbemObject
);
2247 IWbemClassObject_Release( obj
);
2251 static HRESULT WINAPI
services_GetAsync(
2252 ISWbemServices
*iface
,
2253 IDispatch
*objWbemSink
,
2256 IDispatch
*objWbemNamedValueSet
,
2257 IDispatch
*objWbemAsyncContext
)
2263 static HRESULT WINAPI
services_Delete(
2264 ISWbemServices
*iface
,
2267 IDispatch
*objWbemNamedValueSet
)
2273 static HRESULT WINAPI
services_DeleteAsync(
2274 ISWbemServices
* This
,
2275 IDispatch
*objWbemSink
,
2278 IDispatch
*objWbemNamedValueSet
,
2279 IDispatch
*objWbemAsyncContext
)
2285 static BSTR
build_query_string( const WCHAR
*class )
2287 UINT len
= lstrlenW(class) + ARRAY_SIZE(L
"SELECT * FROM ");
2290 if (!(ret
= SysAllocStringLen( NULL
, len
))) return NULL
;
2291 lstrcpyW( ret
, L
"SELECT * FROM " );
2292 lstrcatW( ret
, class );
2296 static HRESULT WINAPI
services_InstancesOf(
2297 ISWbemServices
*iface
,
2300 IDispatch
*objWbemNamedValueSet
,
2301 ISWbemObjectSet
**objWbemObjectSet
)
2303 BSTR query
, wql
= SysAllocString( L
"WQL" );
2306 TRACE( "%p, %s, %#lx, %p, %p\n", iface
, debugstr_w(strClass
), iFlags
, objWbemNamedValueSet
,
2309 if (!(query
= build_query_string( strClass
)))
2311 SysFreeString( wql
);
2312 return E_OUTOFMEMORY
;
2314 hr
= ISWbemServices_ExecQuery( iface
, query
, wql
, iFlags
, objWbemNamedValueSet
, objWbemObjectSet
);
2315 SysFreeString( wql
);
2316 SysFreeString( query
);
2320 static HRESULT WINAPI
services_InstancesOfAsync(
2321 ISWbemServices
*iface
,
2322 IDispatch
*objWbemSink
,
2325 IDispatch
*objWbemNamedValueSet
,
2326 IDispatch
*objWbemAsyncContext
)
2332 static HRESULT WINAPI
services_SubclassesOf(
2333 ISWbemServices
*iface
,
2336 IDispatch
*objWbemNamedValueSet
,
2337 ISWbemObjectSet
**objWbemObjectSet
)
2343 static HRESULT WINAPI
services_SubclassesOfAsync(
2344 ISWbemServices
*iface
,
2345 IDispatch
*objWbemSink
,
2348 IDispatch
*objWbemNamedValueSet
,
2349 IDispatch
*objWbemAsyncContext
)
2355 static HRESULT WINAPI
services_ExecQuery(
2356 ISWbemServices
*iface
,
2358 BSTR strQueryLanguage
,
2360 IDispatch
*objWbemNamedValueSet
,
2361 ISWbemObjectSet
**objWbemObjectSet
)
2363 struct services
*services
= impl_from_ISWbemServices( iface
);
2364 IEnumWbemClassObject
*iter
;
2367 TRACE( "%p, %s, %s, %#lx, %p, %p\n", iface
, debugstr_w(strQuery
), debugstr_w(strQueryLanguage
),
2368 iFlags
, objWbemNamedValueSet
, objWbemObjectSet
);
2370 if (objWbemNamedValueSet
) FIXME( "ignoring context\n" );
2372 hr
= IWbemServices_ExecQuery( services
->services
, strQueryLanguage
, strQuery
, iFlags
, NULL
, &iter
);
2373 if (hr
!= S_OK
) return hr
;
2375 hr
= SWbemObjectSet_create( services
, iter
, objWbemObjectSet
);
2376 IEnumWbemClassObject_Release( iter
);
2380 static HRESULT WINAPI
services_ExecQueryAsync(
2381 ISWbemServices
*iface
,
2382 IDispatch
*objWbemSink
,
2384 BSTR strQueryLanguage
,
2386 IDispatch
*objWbemNamedValueSet
,
2387 IDispatch
*objWbemAsyncContext
)
2393 static HRESULT WINAPI
services_AssociatorsOf(
2394 ISWbemServices
*iface
,
2397 BSTR strResultClass
,
2400 VARIANT_BOOL bClassesOnly
,
2401 VARIANT_BOOL bSchemaOnly
,
2402 BSTR strRequiredAssocQualifier
,
2403 BSTR strRequiredQualifier
,
2405 IDispatch
*objWbemNamedValueSet
,
2406 ISWbemObjectSet
**objWbemObjectSet
)
2412 static HRESULT WINAPI
services_AssociatorsOfAsync(
2413 ISWbemServices
*iface
,
2414 IDispatch
*objWbemSink
,
2417 BSTR strResultClass
,
2420 VARIANT_BOOL bClassesOnly
,
2421 VARIANT_BOOL bSchemaOnly
,
2422 BSTR strRequiredAssocQualifier
,
2423 BSTR strRequiredQualifier
,
2425 IDispatch
*objWbemNamedValueSet
,
2426 IDispatch
*objWbemAsyncContext
)
2432 static HRESULT WINAPI
services_ReferencesTo(
2433 ISWbemServices
*iface
,
2435 BSTR strResultClass
,
2437 VARIANT_BOOL bClassesOnly
,
2438 VARIANT_BOOL bSchemaOnly
,
2439 BSTR strRequiredQualifier
,
2441 IDispatch
*objWbemNamedValueSet
,
2442 ISWbemObjectSet
**objWbemObjectSet
)
2448 static HRESULT WINAPI
services_ReferencesToAsync(
2449 ISWbemServices
*iface
,
2450 IDispatch
*objWbemSink
,
2452 BSTR strResultClass
,
2454 VARIANT_BOOL bClassesOnly
,
2455 VARIANT_BOOL bSchemaOnly
,
2456 BSTR strRequiredQualifier
,
2458 IDispatch
*objWbemNamedValueSet
,
2459 IDispatch
*objWbemAsyncContext
)
2465 static HRESULT WINAPI
services_ExecNotificationQuery(
2466 ISWbemServices
*iface
,
2468 BSTR strQueryLanguage
,
2470 IDispatch
*objWbemNamedValueSet
,
2471 ISWbemEventSource
**objWbemEventSource
)
2477 static HRESULT WINAPI
services_ExecNotificationQueryAsync(
2478 ISWbemServices
*iface
,
2479 IDispatch
*objWbemSink
,
2481 BSTR strQueryLanguage
,
2483 IDispatch
*objWbemNamedValueSet
,
2484 IDispatch
*objWbemAsyncContext
)
2490 static HRESULT WINAPI
services_ExecMethod(
2491 ISWbemServices
*iface
,
2494 IDispatch
*in_sparams
,
2496 IDispatch
*valueset
,
2497 ISWbemObject
**out_sparams
)
2499 struct services
*services
= impl_from_ISWbemServices( iface
);
2500 IWbemClassObject
*out_params
= NULL
;
2501 struct object
*in_params
;
2502 IWbemContext
*context
;
2505 TRACE( "%p, %s, %s, %p, %#lx, %p, %p\n", services
, debugstr_w(path
), debugstr_w(method
), in_sparams
,
2506 flags
, valueset
, out_sparams
);
2508 in_params
= unsafe_object_impl_from_IDispatch( in_sparams
);
2511 context
= unsafe_get_context_from_namedvalueset( valueset
);
2513 hr
= IWbemServices_ExecMethod( services
->services
, path
, method
, flags
, context
, in_params
? in_params
->object
: NULL
,
2514 out_sparams
? &out_params
: NULL
, NULL
);
2516 if (SUCCEEDED(hr
) && out_params
)
2518 hr
= SWbemObject_create( services
, out_params
, out_sparams
);
2519 IWbemClassObject_Release( out_params
);
2525 static HRESULT WINAPI
services_ExecMethodAsync(
2526 ISWbemServices
*iface
,
2527 IDispatch
*objWbemSink
,
2530 IDispatch
*objWbemInParameters
,
2532 IDispatch
*objWbemNamedValueSet
,
2533 IDispatch
*objWbemAsyncContext
)
2539 static HRESULT WINAPI
services_get_Security_(
2540 ISWbemServices
*iface
,
2541 ISWbemSecurity
**objWbemSecurity
)
2543 TRACE( "%p, %p\n", iface
, objWbemSecurity
);
2545 if (!objWbemSecurity
)
2546 return E_INVALIDARG
;
2548 return ISWbemSecurity_create( objWbemSecurity
);
2551 static const ISWbemServicesVtbl services_vtbl
=
2553 services_QueryInterface
,
2556 services_GetTypeInfoCount
,
2557 services_GetTypeInfo
,
2558 services_GetIDsOfNames
,
2563 services_DeleteAsync
,
2564 services_InstancesOf
,
2565 services_InstancesOfAsync
,
2566 services_SubclassesOf
,
2567 services_SubclassesOfAsync
,
2569 services_ExecQueryAsync
,
2570 services_AssociatorsOf
,
2571 services_AssociatorsOfAsync
,
2572 services_ReferencesTo
,
2573 services_ReferencesToAsync
,
2574 services_ExecNotificationQuery
,
2575 services_ExecNotificationQueryAsync
,
2576 services_ExecMethod
,
2577 services_ExecMethodAsync
,
2578 services_get_Security_
2581 static HRESULT
SWbemServices_create( IWbemServices
*wbem_services
, ISWbemServices
**obj
)
2583 struct services
*services
;
2585 TRACE( "%p, %p\n", obj
, wbem_services
);
2587 if (!(services
= malloc( sizeof(*services
) ))) return E_OUTOFMEMORY
;
2588 services
->ISWbemServices_iface
.lpVtbl
= &services_vtbl
;
2590 services
->services
= wbem_services
;
2591 IWbemServices_AddRef( services
->services
);
2593 *obj
= &services
->ISWbemServices_iface
;
2594 TRACE( "returning iface %p\n", *obj
);
2600 ISWbemLocator ISWbemLocator_iface
;
2602 IWbemLocator
*locator
;
2605 static inline struct locator
*impl_from_ISWbemLocator( ISWbemLocator
*iface
)
2607 return CONTAINING_RECORD( iface
, struct locator
, ISWbemLocator_iface
);
2610 static ULONG WINAPI
locator_AddRef(
2611 ISWbemLocator
*iface
)
2613 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2614 return InterlockedIncrement( &locator
->refs
);
2617 static ULONG WINAPI
locator_Release(
2618 ISWbemLocator
*iface
)
2620 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2621 LONG refs
= InterlockedDecrement( &locator
->refs
);
2624 TRACE( "destroying %p\n", locator
);
2625 if (locator
->locator
)
2626 IWbemLocator_Release( locator
->locator
);
2632 static HRESULT WINAPI
locator_QueryInterface(
2633 ISWbemLocator
*iface
,
2637 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2639 TRACE( "%p, %s, %p\n", locator
, debugstr_guid( riid
), ppvObject
);
2641 if (IsEqualGUID( riid
, &IID_ISWbemLocator
) ||
2642 IsEqualGUID( riid
, &IID_IDispatch
) ||
2643 IsEqualGUID( riid
, &IID_IUnknown
))
2649 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
2650 return E_NOINTERFACE
;
2652 ISWbemLocator_AddRef( iface
);
2656 static HRESULT WINAPI
locator_GetTypeInfoCount(
2657 ISWbemLocator
*iface
,
2660 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2662 TRACE( "%p, %p\n", locator
, count
);
2667 static HRESULT WINAPI
locator_GetTypeInfo(
2668 ISWbemLocator
*iface
,
2673 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2674 TRACE( "%p, %u, %#lx, %p\n", locator
, index
, lcid
, info
);
2676 return get_typeinfo( ISWbemLocator_tid
, info
);
2679 static HRESULT WINAPI
locator_GetIDsOfNames(
2680 ISWbemLocator
*iface
,
2687 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2688 ITypeInfo
*typeinfo
;
2691 TRACE( "%p, %s, %p, %u, %#lx, %p\n", locator
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
2693 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
2695 hr
= get_typeinfo( ISWbemLocator_tid
, &typeinfo
);
2698 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
2699 ITypeInfo_Release( typeinfo
);
2704 static HRESULT WINAPI
locator_Invoke(
2705 ISWbemLocator
*iface
,
2712 EXCEPINFO
*excep_info
,
2715 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2716 ITypeInfo
*typeinfo
;
2719 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", locator
, member
, debugstr_guid(riid
),
2720 lcid
, flags
, params
, result
, excep_info
, arg_err
);
2722 hr
= get_typeinfo( ISWbemLocator_tid
, &typeinfo
);
2725 hr
= ITypeInfo_Invoke( typeinfo
, &locator
->ISWbemLocator_iface
, member
, flags
,
2726 params
, result
, excep_info
, arg_err
);
2727 ITypeInfo_Release( typeinfo
);
2732 static BSTR
build_resource_string( BSTR server
, BSTR
namespace )
2734 ULONG len
, len_server
= 0, len_namespace
= 0;
2737 if (server
&& *server
) len_server
= lstrlenW( server
);
2738 else len_server
= 1;
2739 if (namespace && *namespace) len_namespace
= lstrlenW( namespace );
2740 else len_namespace
= ARRAY_SIZE(L
"root\\default") - 1;
2742 if (!(ret
= SysAllocStringLen( NULL
, 2 + len_server
+ 1 + len_namespace
))) return NULL
;
2744 ret
[0] = ret
[1] = '\\';
2745 if (server
&& *server
) lstrcpyW( ret
+ 2, server
);
2748 len
= len_server
+ 2;
2751 if (namespace && *namespace) lstrcpyW( ret
+ len
, namespace );
2752 else lstrcpyW( ret
+ len
, L
"root\\default" );
2756 static HRESULT WINAPI
locator_ConnectServer(
2757 ISWbemLocator
*iface
,
2764 LONG iSecurityFlags
,
2765 IDispatch
*objWbemNamedValueSet
,
2766 ISWbemServices
**objWbemServices
)
2768 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2769 IWbemServices
*services
;
2770 IWbemContext
*context
;
2774 TRACE( "%p, %s, %s, %s, %p, %s, %s, %#lx, %p, %p\n", iface
, debugstr_w(strServer
),
2775 debugstr_w(strNamespace
), debugstr_w(strUser
), strPassword
, debugstr_w(strLocale
),
2776 debugstr_w(strAuthority
), iSecurityFlags
, objWbemNamedValueSet
, objWbemServices
);
2778 if (!locator
->locator
)
2780 hr
= CoCreateInstance( &CLSID_WbemLocator
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IWbemLocator
,
2781 (void **)&locator
->locator
);
2782 if (hr
!= S_OK
) return hr
;
2785 context
= unsafe_get_context_from_namedvalueset( objWbemNamedValueSet
);
2787 if (!(resource
= build_resource_string( strServer
, strNamespace
))) return E_OUTOFMEMORY
;
2788 hr
= IWbemLocator_ConnectServer( locator
->locator
, resource
, strUser
, strPassword
, strLocale
,
2789 iSecurityFlags
, strAuthority
, context
, &services
);
2790 SysFreeString( resource
);
2791 if (hr
!= S_OK
) return hr
;
2793 hr
= SWbemServices_create( services
, objWbemServices
);
2794 IWbemServices_Release( services
);
2798 static HRESULT WINAPI
locator_get_Security_(
2799 ISWbemLocator
*iface
,
2800 ISWbemSecurity
**objWbemSecurity
)
2802 TRACE( "%p, %p\n", iface
, objWbemSecurity
);
2804 if (!objWbemSecurity
)
2805 return E_INVALIDARG
;
2807 return ISWbemSecurity_create( objWbemSecurity
);
2810 static const ISWbemLocatorVtbl locator_vtbl
=
2812 locator_QueryInterface
,
2815 locator_GetTypeInfoCount
,
2816 locator_GetTypeInfo
,
2817 locator_GetIDsOfNames
,
2819 locator_ConnectServer
,
2820 locator_get_Security_
2823 HRESULT
SWbemLocator_create( void **obj
)
2825 struct locator
*locator
;
2827 TRACE( "%p\n", obj
);
2829 if (!(locator
= malloc( sizeof(*locator
) ))) return E_OUTOFMEMORY
;
2830 locator
->ISWbemLocator_iface
.lpVtbl
= &locator_vtbl
;
2832 locator
->locator
= NULL
;
2834 *obj
= &locator
->ISWbemLocator_iface
;
2835 TRACE( "returning iface %p\n", *obj
);
2841 ISWbemSecurity ISWbemSecurity_iface
;
2843 WbemImpersonationLevelEnum implevel
;
2844 WbemAuthenticationLevelEnum authlevel
;
2847 static inline struct security
*impl_from_ISWbemSecurity( ISWbemSecurity
*iface
)
2849 return CONTAINING_RECORD( iface
, struct security
, ISWbemSecurity_iface
);
2852 static ULONG WINAPI
security_AddRef(
2853 ISWbemSecurity
*iface
)
2855 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2856 return InterlockedIncrement( &security
->refs
);
2859 static ULONG WINAPI
security_Release(
2860 ISWbemSecurity
*iface
)
2862 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2863 LONG refs
= InterlockedDecrement( &security
->refs
);
2866 TRACE( "destroying %p\n", security
);
2872 static HRESULT WINAPI
security_QueryInterface(
2873 ISWbemSecurity
*iface
,
2877 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2878 TRACE( "%p, %s, %p\n", security
, debugstr_guid( riid
), ppvObject
);
2880 if (IsEqualGUID( riid
, &IID_ISWbemSecurity
) ||
2881 IsEqualGUID( riid
, &IID_IDispatch
) ||
2882 IsEqualGUID( riid
, &IID_IUnknown
))
2888 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
2889 return E_NOINTERFACE
;
2891 ISWbemSecurity_AddRef( iface
);
2895 static HRESULT WINAPI
security_GetTypeInfoCount(
2896 ISWbemSecurity
*iface
,
2899 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2900 TRACE( "%p, %p\n", security
, count
);
2906 static HRESULT WINAPI
security_GetTypeInfo(
2907 ISWbemSecurity
*iface
,
2912 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2913 TRACE( "%p, %u, %#lx, %p\n", security
, index
, lcid
, info
);
2915 return get_typeinfo( ISWbemSecurity_tid
, info
);
2918 static HRESULT WINAPI
security_GetIDsOfNames(
2919 ISWbemSecurity
*iface
,
2926 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2927 ITypeInfo
*typeinfo
;
2930 TRACE( "%p, %s, %p, %u, %#lx, %p\n", security
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
2932 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
2934 hr
= get_typeinfo( ISWbemSecurity_tid
, &typeinfo
);
2937 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
2938 ITypeInfo_Release( typeinfo
);
2943 static HRESULT WINAPI
security_Invoke(
2944 ISWbemSecurity
*iface
,
2951 EXCEPINFO
*excep_info
,
2954 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2955 ITypeInfo
*typeinfo
;
2958 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", security
, member
, debugstr_guid(riid
),
2959 lcid
, flags
, params
, result
, excep_info
, arg_err
);
2961 hr
= get_typeinfo( ISWbemSecurity_tid
, &typeinfo
);
2964 hr
= ITypeInfo_Invoke( typeinfo
, &security
->ISWbemSecurity_iface
, member
, flags
,
2965 params
, result
, excep_info
, arg_err
);
2966 ITypeInfo_Release( typeinfo
);
2971 static HRESULT WINAPI
security_get_ImpersonationLevel(
2972 ISWbemSecurity
*iface
,
2973 WbemImpersonationLevelEnum
*impersonation_level
)
2975 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2976 FIXME( "%p, %p: stub\n", security
, impersonation_level
);
2978 if (!impersonation_level
)
2979 return E_INVALIDARG
;
2981 *impersonation_level
= security
->implevel
;
2985 static HRESULT WINAPI
security_put_ImpersonationLevel(
2986 ISWbemSecurity
*iface
,
2987 WbemImpersonationLevelEnum impersonation_level
)
2989 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2990 FIXME( "%p, %d: stub\n", security
, impersonation_level
);
2992 security
->implevel
= impersonation_level
;
2996 static HRESULT WINAPI
security_get_AuthenticationLevel(
2997 ISWbemSecurity
*iface
,
2998 WbemAuthenticationLevelEnum
*authentication_level
)
3000 struct security
*security
= impl_from_ISWbemSecurity( iface
);
3001 FIXME( "%p, %p: stub\n", security
, authentication_level
);
3003 if (!authentication_level
)
3004 return E_INVALIDARG
;
3006 *authentication_level
= security
->authlevel
;
3010 static HRESULT WINAPI
security_put_AuthenticationLevel(
3011 ISWbemSecurity
*iface
,
3012 WbemAuthenticationLevelEnum authentication_level
)
3014 struct security
*security
= impl_from_ISWbemSecurity( iface
);
3015 FIXME( "%p, %d: stub\n", security
, authentication_level
);
3017 security
->authlevel
= authentication_level
;
3021 static HRESULT WINAPI
security_get_Privileges(
3022 ISWbemSecurity
*iface
,
3023 ISWbemPrivilegeSet
**privilege_set
)
3025 struct security
*security
= impl_from_ISWbemSecurity( iface
);
3026 FIXME( "%p, %p: stub\n", security
, privilege_set
);
3029 return E_INVALIDARG
;
3034 static const ISWbemSecurityVtbl security_vtbl
=
3036 security_QueryInterface
,
3039 security_GetTypeInfoCount
,
3040 security_GetTypeInfo
,
3041 security_GetIDsOfNames
,
3043 security_get_ImpersonationLevel
,
3044 security_put_ImpersonationLevel
,
3045 security_get_AuthenticationLevel
,
3046 security_put_AuthenticationLevel
,
3047 security_get_Privileges
3050 static HRESULT
ISWbemSecurity_create( ISWbemSecurity
**obj
)
3052 struct security
*security
;
3054 TRACE( "%p\n", obj
);
3056 if (!(security
= malloc( sizeof(*security
) ))) return E_OUTOFMEMORY
;
3057 security
->ISWbemSecurity_iface
.lpVtbl
= &security_vtbl
;
3059 security
->implevel
= wbemImpersonationLevelImpersonate
;
3060 security
->authlevel
= wbemAuthenticationLevelPktPrivacy
;
3062 *obj
= &security
->ISWbemSecurity_iface
;
3063 TRACE( "returning iface %p\n", *obj
);
3069 ISWbemNamedValue ISWbemNamedValue_iface
;
3073 static struct namedvalueset
*impl_from_ISWbemNamedValueSet( ISWbemNamedValueSet
*iface
)
3075 return CONTAINING_RECORD( iface
, struct namedvalueset
, ISWbemNamedValueSet_iface
);
3078 static struct namedvalue
*impl_from_ISWbemNamedValue( ISWbemNamedValue
*iface
)
3080 return CONTAINING_RECORD( iface
, struct namedvalue
, ISWbemNamedValue_iface
);
3083 static HRESULT WINAPI
namedvalue_QueryInterface(
3084 ISWbemNamedValue
*iface
,
3088 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3090 TRACE( "%p, %s, %p\n", value
, debugstr_guid( riid
), ppvObject
);
3092 if (IsEqualGUID( riid
, &IID_ISWbemNamedValue
) ||
3093 IsEqualGUID( riid
, &IID_IDispatch
) ||
3094 IsEqualGUID( riid
, &IID_IUnknown
))
3100 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
3101 return E_NOINTERFACE
;
3103 ISWbemNamedValue_AddRef( iface
);
3107 static ULONG WINAPI
namedvalue_AddRef(
3108 ISWbemNamedValue
*iface
)
3110 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3111 return InterlockedIncrement( &value
->refs
);
3114 static ULONG WINAPI
namedvalue_Release(
3115 ISWbemNamedValue
*iface
)
3117 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3118 LONG refs
= InterlockedDecrement( &value
->refs
);
3121 TRACE( "destroying %p\n", value
);
3127 static HRESULT WINAPI
namedvalue_GetTypeInfoCount(
3128 ISWbemNamedValue
*iface
,
3131 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3132 TRACE( "%p, %p\n", value
, count
);
3138 static HRESULT WINAPI
namedvalue_GetTypeInfo(
3139 ISWbemNamedValue
*iface
,
3144 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3146 TRACE( "%p, %u, %#lx, %p\n", value
, index
, lcid
, info
);
3148 return get_typeinfo( ISWbemNamedValue_tid
, info
);
3151 static HRESULT WINAPI
namedvalue_GetIDsOfNames(
3152 ISWbemNamedValue
*iface
,
3159 struct namedvalue
*value
= impl_from_ISWbemNamedValue( iface
);
3160 ITypeInfo
*typeinfo
;
3163 TRACE( "%p, %s, %p, %u, %#lx, %p\n", value
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
3165 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
3167 hr
= get_typeinfo( ISWbemNamedValue_tid
, &typeinfo
);
3170 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
3171 ITypeInfo_Release( typeinfo
);
3176 static HRESULT WINAPI
namedvalue_Invoke(
3177 ISWbemNamedValue
*iface
,
3184 EXCEPINFO
*excep_info
,
3187 struct namedvalue
*set
= impl_from_ISWbemNamedValue( iface
);
3188 ITypeInfo
*typeinfo
;
3191 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", set
, member
, debugstr_guid(riid
),
3192 lcid
, flags
, params
, result
, excep_info
, arg_err
);
3194 hr
= get_typeinfo( ISWbemNamedValue_tid
, &typeinfo
);
3197 hr
= ITypeInfo_Invoke( typeinfo
, &set
->ISWbemNamedValue_iface
, member
, flags
,
3198 params
, result
, excep_info
, arg_err
);
3199 ITypeInfo_Release( typeinfo
);
3204 static HRESULT WINAPI
namedvalue_get_Value(
3205 ISWbemNamedValue
*iface
,
3213 static HRESULT WINAPI
namedvalue_put_Value(
3214 ISWbemNamedValue
*iface
,
3222 static HRESULT WINAPI
namedvalue_get_Name(
3223 ISWbemNamedValue
*iface
,
3231 static const ISWbemNamedValueVtbl namedvaluevtbl
=
3233 namedvalue_QueryInterface
,
3236 namedvalue_GetTypeInfoCount
,
3237 namedvalue_GetTypeInfo
,
3238 namedvalue_GetIDsOfNames
,
3240 namedvalue_get_Value
,
3241 namedvalue_put_Value
,
3245 static HRESULT
namedvalue_create( ISWbemNamedValue
**value
)
3247 struct namedvalue
*object
;
3249 if (!(object
= malloc( sizeof(*object
) ))) return E_OUTOFMEMORY
;
3251 object
->ISWbemNamedValue_iface
.lpVtbl
= &namedvaluevtbl
;
3254 *value
= &object
->ISWbemNamedValue_iface
;
3259 static HRESULT WINAPI
namedvalueset_QueryInterface(
3260 ISWbemNamedValueSet
*iface
,
3264 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3266 TRACE( "%p, %s, %p\n", set
, debugstr_guid( riid
), ppvObject
);
3268 if (IsEqualGUID( riid
, &IID_ISWbemNamedValueSet
) ||
3269 IsEqualGUID( riid
, &IID_IDispatch
) ||
3270 IsEqualGUID( riid
, &IID_IUnknown
))
3276 WARN( "interface %s not implemented\n", debugstr_guid(riid
) );
3277 return E_NOINTERFACE
;
3279 ISWbemNamedValueSet_AddRef( iface
);
3283 static ULONG WINAPI
namedvalueset_AddRef(
3284 ISWbemNamedValueSet
*iface
)
3286 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3287 return InterlockedIncrement( &set
->refs
);
3290 static ULONG WINAPI
namedvalueset_Release(
3291 ISWbemNamedValueSet
*iface
)
3293 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3294 LONG refs
= InterlockedDecrement( &set
->refs
);
3297 TRACE( "destroying %p\n", set
);
3299 IWbemContext_Release( set
->context
);
3305 static HRESULT WINAPI
namedvalueset_GetTypeInfoCount(
3306 ISWbemNamedValueSet
*iface
,
3309 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3310 TRACE( "%p, %p\n", set
, count
);
3316 static HRESULT WINAPI
namedvalueset_GetTypeInfo(
3317 ISWbemNamedValueSet
*iface
,
3322 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3324 TRACE( "%p, %u, %#lx, %p\n", set
, index
, lcid
, info
);
3326 return get_typeinfo( ISWbemNamedValueSet_tid
, info
);
3329 static HRESULT WINAPI
namedvalueset_GetIDsOfNames(
3330 ISWbemNamedValueSet
*iface
,
3337 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3338 ITypeInfo
*typeinfo
;
3341 TRACE( "%p, %s, %p, %u, %#lx, %p\n", set
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
3343 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
3345 hr
= get_typeinfo( ISWbemNamedValueSet_tid
, &typeinfo
);
3348 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
3349 ITypeInfo_Release( typeinfo
);
3354 static HRESULT WINAPI
namedvalueset_Invoke(
3355 ISWbemNamedValueSet
*iface
,
3362 EXCEPINFO
*excep_info
,
3365 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3366 ITypeInfo
*typeinfo
;
3369 TRACE( "%p, %ld, %s, %#lx, %#x, %p, %p, %p, %p\n", set
, member
, debugstr_guid(riid
),
3370 lcid
, flags
, params
, result
, excep_info
, arg_err
);
3372 hr
= get_typeinfo( ISWbemNamedValueSet_tid
, &typeinfo
);
3375 hr
= ITypeInfo_Invoke( typeinfo
, &set
->ISWbemNamedValueSet_iface
, member
, flags
,
3376 params
, result
, excep_info
, arg_err
);
3377 ITypeInfo_Release( typeinfo
);
3382 static HRESULT WINAPI
namedvalueset_get__NewEnum(
3383 ISWbemNamedValueSet
*iface
,
3391 static HRESULT WINAPI
namedvalueset_Item(
3392 ISWbemNamedValueSet
*iface
,
3395 ISWbemNamedValue
**value
)
3397 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3401 TRACE("%p, %s, %#lx, %p\n", set
, debugstr_w(name
), flags
, value
);
3403 if (SUCCEEDED(hr
= IWbemContext_GetValue( set
->context
, name
, flags
, &var
)))
3405 VariantClear( &var
);
3406 hr
= namedvalue_create( value
);
3412 static HRESULT WINAPI
namedvalueset_get_Count(
3413 ISWbemNamedValueSet
*iface
,
3421 static HRESULT WINAPI
namedvalueset_Add(
3422 ISWbemNamedValueSet
*iface
,
3426 ISWbemNamedValue
**value
)
3428 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3431 TRACE("%p, %s, %s, %#lx, %p\n", set
, debugstr_w(name
), debugstr_variant(var
), flags
, value
);
3433 if (!name
|| !var
|| !value
)
3434 return WBEM_E_INVALID_PARAMETER
;
3436 if (SUCCEEDED(hr
= IWbemContext_SetValue( set
->context
, name
, flags
, var
)))
3438 hr
= namedvalue_create( value
);
3444 static HRESULT WINAPI
namedvalueset_Remove(
3445 ISWbemNamedValueSet
*iface
,
3449 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3451 TRACE("%p, %s, %#lx\n", set
, debugstr_w(name
), flags
);
3453 return IWbemContext_DeleteValue( set
->context
, name
, flags
);
3456 static HRESULT WINAPI
namedvalueset_Clone(
3457 ISWbemNamedValueSet
*iface
,
3458 ISWbemNamedValueSet
**valueset
)
3465 static HRESULT WINAPI
namedvalueset_DeleteAll(
3466 ISWbemNamedValueSet
*iface
)
3468 struct namedvalueset
*set
= impl_from_ISWbemNamedValueSet( iface
);
3472 return IWbemContext_DeleteAll( set
->context
);
3475 static const ISWbemNamedValueSetVtbl namedvalueset_vtbl
=
3477 namedvalueset_QueryInterface
,
3478 namedvalueset_AddRef
,
3479 namedvalueset_Release
,
3480 namedvalueset_GetTypeInfoCount
,
3481 namedvalueset_GetTypeInfo
,
3482 namedvalueset_GetIDsOfNames
,
3483 namedvalueset_Invoke
,
3484 namedvalueset_get__NewEnum
,
3486 namedvalueset_get_Count
,
3488 namedvalueset_Remove
,
3489 namedvalueset_Clone
,
3490 namedvalueset_DeleteAll
,
3493 static struct namedvalueset
*unsafe_valueset_impl_from_IDispatch(IDispatch
*iface
)
3497 if (iface
->lpVtbl
!= (IDispatchVtbl
*)&namedvalueset_vtbl
)
3499 FIXME( "External implementations are not supported.\n" );
3502 return CONTAINING_RECORD(iface
, struct namedvalueset
, ISWbemNamedValueSet_iface
);
3505 HRESULT
SWbemNamedValueSet_create( void **obj
)
3507 struct namedvalueset
*set
;
3510 TRACE( "%p\n", obj
);
3512 if (!(set
= calloc( 1, sizeof(*set
) ))) return E_OUTOFMEMORY
;
3513 set
->ISWbemNamedValueSet_iface
.lpVtbl
= &namedvalueset_vtbl
;
3516 if (FAILED(hr
= CoCreateInstance( &CLSID_WbemContext
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IWbemContext
,
3517 (void **)&set
->context
)))
3519 ISWbemNamedValueSet_Release( &set
->ISWbemNamedValueSet_iface
);
3523 *obj
= &set
->ISWbemNamedValueSet_iface
;
3524 TRACE( "returning iface %p\n", *obj
);