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
32 #include "wine/debug.h"
33 #include "wine/heap.h"
34 #include "wine/unicode.h"
35 #include "wbemdisp_private.h"
36 #include "wbemdisp_classes.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(wbemdisp
);
40 static HRESULT
EnumVARIANT_create( IEnumWbemClassObject
*, IEnumVARIANT
** );
41 static HRESULT
ISWbemSecurity_create( ISWbemSecurity
** );
49 ISWbemPropertySet_tid
,
55 static ITypeLib
*wbemdisp_typelib
;
56 static ITypeInfo
*wbemdisp_typeinfo
[last_tid
];
58 static REFIID wbemdisp_tid_id
[] =
64 &IID_ISWbemPropertySet
,
69 static HRESULT
get_typeinfo( enum type_id tid
, ITypeInfo
**ret
)
73 if (!wbemdisp_typelib
)
77 hr
= LoadRegTypeLib( &LIBID_WbemScripting
, 1, 2, LOCALE_SYSTEM_DEFAULT
, &typelib
);
80 ERR( "LoadRegTypeLib failed: %08x\n", hr
);
83 if (InterlockedCompareExchangePointer( (void **)&wbemdisp_typelib
, typelib
, NULL
))
84 ITypeLib_Release( typelib
);
86 if (!wbemdisp_typeinfo
[tid
])
90 hr
= ITypeLib_GetTypeInfoOfGuid( wbemdisp_typelib
, wbemdisp_tid_id
[tid
], &typeinfo
);
93 ERR( "GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(wbemdisp_tid_id
[tid
]), hr
);
96 if (InterlockedCompareExchangePointer( (void **)(wbemdisp_typeinfo
+ tid
), typeinfo
, NULL
))
97 ITypeInfo_Release( typeinfo
);
99 *ret
= wbemdisp_typeinfo
[tid
];
100 ITypeInfo_AddRef( *ret
);
106 ISWbemProperty ISWbemProperty_iface
;
108 IWbemClassObject
*object
;
112 static inline struct property
*impl_from_ISWbemProperty( ISWbemProperty
*iface
)
114 return CONTAINING_RECORD( iface
, struct property
, ISWbemProperty_iface
);
117 static ULONG WINAPI
property_AddRef( ISWbemProperty
*iface
)
119 struct property
*property
= impl_from_ISWbemProperty( iface
);
120 return InterlockedIncrement( &property
->refs
);
123 static ULONG WINAPI
property_Release( ISWbemProperty
*iface
)
125 struct property
*property
= impl_from_ISWbemProperty( iface
);
126 LONG refs
= InterlockedDecrement( &property
->refs
);
129 TRACE( "destroying %p\n", property
);
130 IWbemClassObject_Release( property
->object
);
131 SysFreeString( property
->name
);
132 heap_free( property
);
137 static HRESULT WINAPI
property_QueryInterface( ISWbemProperty
*iface
, REFIID riid
, void **obj
)
139 struct property
*property
= impl_from_ISWbemProperty( iface
);
141 TRACE( "%p %s %p\n", property
, debugstr_guid(riid
), obj
);
143 if (IsEqualGUID( riid
, &IID_ISWbemProperty
) ||
144 IsEqualGUID( riid
, &IID_IDispatch
) ||
145 IsEqualGUID( riid
, &IID_IUnknown
))
151 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
152 return E_NOINTERFACE
;
154 ISWbemProperty_AddRef( iface
);
158 static HRESULT WINAPI
property_GetTypeInfoCount( ISWbemProperty
*iface
, UINT
*count
)
160 struct property
*property
= impl_from_ISWbemProperty( iface
);
161 TRACE( "%p, %p\n", property
, count
);
166 static HRESULT WINAPI
property_GetTypeInfo( ISWbemProperty
*iface
, UINT index
,
167 LCID lcid
, ITypeInfo
**info
)
169 struct property
*property
= impl_from_ISWbemProperty( iface
);
170 TRACE( "%p, %u, %u, %p\n", property
, index
, lcid
, info
);
172 return get_typeinfo( ISWbemProperty_tid
, info
);
175 static HRESULT WINAPI
property_GetIDsOfNames( ISWbemProperty
*iface
, REFIID riid
, LPOLESTR
*names
,
176 UINT count
, LCID lcid
, DISPID
*dispid
)
178 struct property
*property
= impl_from_ISWbemProperty( iface
);
182 TRACE( "%p, %s, %p, %u, %u, %p\n", property
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
184 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
186 hr
= get_typeinfo( ISWbemProperty_tid
, &typeinfo
);
189 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
190 ITypeInfo_Release( typeinfo
);
195 static HRESULT WINAPI
property_Invoke( ISWbemProperty
*iface
, DISPID member
, REFIID riid
,
196 LCID lcid
, WORD flags
, DISPPARAMS
*params
,
197 VARIANT
*result
, EXCEPINFO
*excep_info
, UINT
*arg_err
)
199 struct property
*property
= impl_from_ISWbemProperty( iface
);
203 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", property
, member
, debugstr_guid(riid
),
204 lcid
, flags
, params
, result
, excep_info
, arg_err
);
206 hr
= get_typeinfo( ISWbemProperty_tid
, &typeinfo
);
209 hr
= ITypeInfo_Invoke( typeinfo
, &property
->ISWbemProperty_iface
, member
, flags
,
210 params
, result
, excep_info
, arg_err
);
211 ITypeInfo_Release( typeinfo
);
216 static HRESULT WINAPI
property_get_Value( ISWbemProperty
*iface
, VARIANT
*value
)
218 struct property
*property
= impl_from_ISWbemProperty( iface
);
220 TRACE( "%p %p\n", property
, value
);
222 return IWbemClassObject_Get( property
->object
, property
->name
, 0, value
, NULL
, NULL
);
225 static HRESULT WINAPI
property_put_Value( ISWbemProperty
*iface
, VARIANT
*varValue
)
231 static HRESULT WINAPI
property_get_Name( ISWbemProperty
*iface
, BSTR
*strName
)
237 static HRESULT WINAPI
property_get_IsLocal( ISWbemProperty
*iface
, VARIANT_BOOL
*bIsLocal
)
243 static HRESULT WINAPI
property_get_Origin( ISWbemProperty
*iface
, BSTR
*strOrigin
)
249 static HRESULT WINAPI
property_get_CIMType( ISWbemProperty
*iface
, WbemCimtypeEnum
*iCimType
)
255 static HRESULT WINAPI
property_get_Qualifiers_( ISWbemProperty
*iface
, ISWbemQualifierSet
**objWbemQualifierSet
)
261 static HRESULT WINAPI
property_get_IsArray( ISWbemProperty
*iface
, VARIANT_BOOL
*bIsArray
)
267 static const ISWbemPropertyVtbl property_vtbl
=
269 property_QueryInterface
,
272 property_GetTypeInfoCount
,
273 property_GetTypeInfo
,
274 property_GetIDsOfNames
,
279 property_get_IsLocal
,
281 property_get_CIMType
,
282 property_get_Qualifiers_
,
286 static HRESULT
SWbemProperty_create( IWbemClassObject
*wbem_object
, BSTR name
, ISWbemProperty
**obj
)
288 struct property
*property
;
290 TRACE( "%p, %p\n", obj
, wbem_object
);
292 if (!(property
= heap_alloc( sizeof(*property
) ))) return E_OUTOFMEMORY
;
293 property
->ISWbemProperty_iface
.lpVtbl
= &property_vtbl
;
295 property
->object
= wbem_object
;
296 IWbemClassObject_AddRef( property
->object
);
297 property
->name
= SysAllocStringLen( name
, SysStringLen( name
) );
298 *obj
= &property
->ISWbemProperty_iface
;
299 TRACE( "returning iface %p\n", *obj
);
305 ISWbemPropertySet ISWbemPropertySet_iface
;
307 IWbemClassObject
*object
;
310 static inline struct propertyset
*impl_from_ISWbemPropertySet(
311 ISWbemPropertySet
*iface
)
313 return CONTAINING_RECORD( iface
, struct propertyset
, ISWbemPropertySet_iface
);
316 static ULONG WINAPI
propertyset_AddRef( ISWbemPropertySet
*iface
)
318 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
319 return InterlockedIncrement( &propertyset
->refs
);
322 static ULONG WINAPI
propertyset_Release( ISWbemPropertySet
*iface
)
324 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
325 LONG refs
= InterlockedDecrement( &propertyset
->refs
);
328 TRACE( "destroying %p\n", propertyset
);
329 IWbemClassObject_Release( propertyset
->object
);
330 heap_free( propertyset
);
335 static HRESULT WINAPI
propertyset_QueryInterface( ISWbemPropertySet
*iface
,
336 REFIID riid
, void **obj
)
338 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
340 TRACE( "%p %s %p\n", propertyset
, debugstr_guid(riid
), obj
);
342 if (IsEqualGUID( riid
, &IID_ISWbemPropertySet
) ||
343 IsEqualGUID( riid
, &IID_IDispatch
) ||
344 IsEqualGUID( riid
, &IID_IUnknown
))
350 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
351 return E_NOINTERFACE
;
353 ISWbemPropertySet_AddRef( iface
);
357 static HRESULT WINAPI
propertyset_GetTypeInfoCount( ISWbemPropertySet
*iface
, UINT
*count
)
359 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
360 TRACE( "%p, %p\n", propertyset
, count
);
365 static HRESULT WINAPI
propertyset_GetTypeInfo( ISWbemPropertySet
*iface
,
366 UINT index
, LCID lcid
, ITypeInfo
**info
)
368 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
369 TRACE( "%p, %u, %u, %p\n", propertyset
, index
, lcid
, info
);
371 return get_typeinfo( ISWbemPropertySet_tid
, info
);
374 static HRESULT WINAPI
propertyset_GetIDsOfNames( ISWbemPropertySet
*iface
, REFIID riid
, LPOLESTR
*names
,
375 UINT count
, LCID lcid
, DISPID
*dispid
)
377 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
381 TRACE( "%p, %s, %p, %u, %u, %p\n", propertyset
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
383 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
385 hr
= get_typeinfo( ISWbemPropertySet_tid
, &typeinfo
);
388 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
389 ITypeInfo_Release( typeinfo
);
394 static HRESULT WINAPI
propertyset_Invoke( ISWbemPropertySet
*iface
, DISPID member
, REFIID riid
,
395 LCID lcid
, WORD flags
, DISPPARAMS
*params
,
396 VARIANT
*result
, EXCEPINFO
*excep_info
, UINT
*arg_err
)
398 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
402 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", propertyset
, member
, debugstr_guid(riid
),
403 lcid
, flags
, params
, result
, excep_info
, arg_err
);
405 hr
= get_typeinfo( ISWbemPropertySet_tid
, &typeinfo
);
408 hr
= ITypeInfo_Invoke( typeinfo
, &propertyset
->ISWbemPropertySet_iface
, member
, flags
,
409 params
, result
, excep_info
, arg_err
);
410 ITypeInfo_Release( typeinfo
);
415 static HRESULT WINAPI
propertyset_get__NewEnum( ISWbemPropertySet
*iface
, IUnknown
**unk
)
421 static HRESULT WINAPI
propertyset_Item( ISWbemPropertySet
*iface
, BSTR name
,
422 LONG flags
, ISWbemProperty
**prop
)
424 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
428 TRACE( "%p, %s, %08x, %p\n", propertyset
, debugstr_w(name
), flags
, prop
);
430 hr
= IWbemClassObject_Get( propertyset
->object
, name
, 0, &var
, NULL
, NULL
);
433 hr
= SWbemProperty_create( propertyset
->object
, name
, prop
);
434 VariantClear( &var
);
439 static HRESULT WINAPI
propertyset_get_Count( ISWbemPropertySet
*iface
, LONG
*count
)
441 static const WCHAR propcountW
[] = {'_','_','P','R','O','P','E','R','T','Y','_','C','O','U','N','T',0};
442 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
446 TRACE( "%p, %p\n", propertyset
, count
);
448 hr
= IWbemClassObject_Get( propertyset
->object
, propcountW
, 0, &val
, NULL
, NULL
);
451 *count
= V_I4( &val
);
456 static HRESULT WINAPI
propertyset_Add( ISWbemPropertySet
*iface
, BSTR name
, WbemCimtypeEnum type
,
457 VARIANT_BOOL is_array
, LONG flags
, ISWbemProperty
**prop
)
463 static HRESULT WINAPI
propertyset_Remove( ISWbemPropertySet
*iface
, BSTR name
, LONG flags
)
469 static const ISWbemPropertySetVtbl propertyset_vtbl
=
471 propertyset_QueryInterface
,
474 propertyset_GetTypeInfoCount
,
475 propertyset_GetTypeInfo
,
476 propertyset_GetIDsOfNames
,
478 propertyset_get__NewEnum
,
480 propertyset_get_Count
,
485 static HRESULT
SWbemPropertySet_create( IWbemClassObject
*wbem_object
, ISWbemPropertySet
**obj
)
487 struct propertyset
*propertyset
;
489 TRACE( "%p, %p\n", obj
, wbem_object
);
491 if (!(propertyset
= heap_alloc( sizeof(*propertyset
) ))) return E_OUTOFMEMORY
;
492 propertyset
->ISWbemPropertySet_iface
.lpVtbl
= &propertyset_vtbl
;
493 propertyset
->refs
= 1;
494 propertyset
->object
= wbem_object
;
495 IWbemClassObject_AddRef( propertyset
->object
);
496 *obj
= &propertyset
->ISWbemPropertySet_iface
;
498 TRACE( "returning iface %p\n", *obj
);
502 #define DISPID_BASE 0x1800000
503 #define DISPID_BASE_METHOD 0x1000000
514 ISWbemObject ISWbemObject_iface
;
516 IWbemClassObject
*object
;
517 struct member
*members
;
520 DISPID last_dispid_method
;
523 static inline struct object
*impl_from_ISWbemObject(
524 ISWbemObject
*iface
)
526 return CONTAINING_RECORD( iface
, struct object
, ISWbemObject_iface
);
529 static ULONG WINAPI
object_AddRef(
530 ISWbemObject
*iface
)
532 struct object
*object
= impl_from_ISWbemObject( iface
);
533 return InterlockedIncrement( &object
->refs
);
536 static ULONG WINAPI
object_Release(
537 ISWbemObject
*iface
)
539 struct object
*object
= impl_from_ISWbemObject( iface
);
540 LONG refs
= InterlockedDecrement( &object
->refs
);
545 TRACE( "destroying %p\n", object
);
546 IWbemClassObject_Release( object
->object
);
547 for (i
= 0; i
< object
->nb_members
; i
++) SysFreeString( object
->members
[i
].name
);
548 heap_free( object
->members
);
554 static HRESULT WINAPI
object_QueryInterface(
559 struct object
*object
= impl_from_ISWbemObject( iface
);
561 TRACE( "%p %s %p\n", object
, debugstr_guid(riid
), ppvObject
);
563 if (IsEqualGUID( riid
, &IID_ISWbemObject
) ||
564 IsEqualGUID( riid
, &IID_IDispatch
) ||
565 IsEqualGUID( riid
, &IID_IUnknown
))
571 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
572 return E_NOINTERFACE
;
574 ISWbemObject_AddRef( iface
);
578 static HRESULT WINAPI
object_GetTypeInfoCount(
582 struct object
*object
= impl_from_ISWbemObject( iface
);
584 TRACE( "%p, %p\n", object
, count
);
589 static HRESULT WINAPI
object_GetTypeInfo(
595 struct object
*object
= impl_from_ISWbemObject( iface
);
596 FIXME( "%p, %u, %u, %p\n", object
, index
, lcid
, info
);
600 static HRESULT
init_members( struct object
*object
)
602 IWbemClassObject
*sig_in
, *sig_out
;
603 LONG i
= 0, count
= 0;
607 if (object
->members
) return S_OK
;
609 hr
= IWbemClassObject_BeginEnumeration( object
->object
, 0 );
612 while (IWbemClassObject_Next( object
->object
, 0, NULL
, NULL
, NULL
, NULL
) == S_OK
) count
++;
613 IWbemClassObject_EndEnumeration( object
->object
);
616 hr
= IWbemClassObject_BeginMethodEnumeration( object
->object
, 0 );
619 while (IWbemClassObject_NextMethod( object
->object
, 0, &name
, &sig_in
, &sig_out
) == S_OK
)
622 SysFreeString( name
);
623 IWbemClassObject_Release( sig_in
);
624 IWbemClassObject_Release( sig_out
);
626 IWbemClassObject_EndMethodEnumeration( object
->object
);
629 if (!(object
->members
= heap_alloc( sizeof(struct member
) * count
))) return E_OUTOFMEMORY
;
631 hr
= IWbemClassObject_BeginEnumeration( object
->object
, 0 );
634 while (IWbemClassObject_Next( object
->object
, 0, &name
, NULL
, NULL
, NULL
) == S_OK
)
636 object
->members
[i
].name
= name
;
637 object
->members
[i
].is_method
= FALSE
;
638 object
->members
[i
].dispid
= 0;
641 IWbemClassObject_EndEnumeration( object
->object
);
644 TRACE( "added property %s\n", debugstr_w(name
) );
646 IWbemClassObject_EndEnumeration( object
->object
);
649 hr
= IWbemClassObject_BeginMethodEnumeration( object
->object
, 0 );
652 while (IWbemClassObject_NextMethod( object
->object
, 0, &name
, &sig_in
, &sig_out
) == S_OK
)
654 object
->members
[i
].name
= name
;
655 object
->members
[i
].is_method
= TRUE
;
656 object
->members
[i
].dispid
= 0;
659 IWbemClassObject_EndMethodEnumeration( object
->object
);
662 IWbemClassObject_Release( sig_in
);
663 IWbemClassObject_Release( sig_out
);
664 TRACE( "added method %s\n", debugstr_w(name
) );
666 IWbemClassObject_EndMethodEnumeration( object
->object
);
669 object
->nb_members
= count
;
670 TRACE( "added %u members\n", object
->nb_members
);
674 for (--i
; i
>= 0; i
--) SysFreeString( object
->members
[i
].name
);
675 heap_free( object
->members
);
676 object
->members
= NULL
;
677 object
->nb_members
= 0;
681 static DISPID
get_member_dispid( struct object
*object
, const WCHAR
*name
)
684 for (i
= 0; i
< object
->nb_members
; i
++)
686 if (!strcmpiW( object
->members
[i
].name
, name
))
688 if (!object
->members
[i
].dispid
)
690 if (object
->members
[i
].is_method
)
691 object
->members
[i
].dispid
= ++object
->last_dispid_method
;
693 object
->members
[i
].dispid
= ++object
->last_dispid
;
695 return object
->members
[i
].dispid
;
698 return DISPID_UNKNOWN
;
701 static HRESULT WINAPI
object_GetIDsOfNames(
709 struct object
*object
= impl_from_ISWbemObject( iface
);
714 TRACE( "%p, %s, %p, %u, %u, %p\n", object
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
716 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
718 hr
= init_members( object
);
719 if (FAILED( hr
)) return hr
;
721 hr
= get_typeinfo( ISWbemObject_tid
, &typeinfo
);
724 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
725 ITypeInfo_Release( typeinfo
);
727 if (SUCCEEDED(hr
)) return hr
;
729 for (i
= 0; i
< count
; i
++)
731 if ((dispid
[i
] = get_member_dispid( object
, names
[i
] )) == DISPID_UNKNOWN
) break;
733 if (i
!= count
) return DISP_E_UNKNOWNNAME
;
737 static BSTR
get_member_name( struct object
*object
, DISPID dispid
)
740 for (i
= 0; i
< object
->nb_members
; i
++)
742 if (object
->members
[i
].dispid
== dispid
) return object
->members
[i
].name
;
747 static HRESULT WINAPI
object_Invoke(
755 EXCEPINFO
*excep_info
,
758 struct object
*object
= impl_from_ISWbemObject( iface
);
763 TRACE( "%p, %x, %s, %u, %x, %p, %p, %p, %p\n", object
, member
, debugstr_guid(riid
),
764 lcid
, flags
, params
, result
, excep_info
, arg_err
);
766 if (member
<= DISPID_BASE_METHOD
)
768 hr
= get_typeinfo( ISWbemObject_tid
, &typeinfo
);
771 hr
= ITypeInfo_Invoke( typeinfo
, &object
->ISWbemObject_iface
, member
, flags
,
772 params
, result
, excep_info
, arg_err
);
773 ITypeInfo_Release( typeinfo
);
778 if (flags
!= (DISPATCH_METHOD
|DISPATCH_PROPERTYGET
))
780 FIXME( "flags %x not supported\n", flags
);
783 if (!(name
= get_member_name( object
, member
)))
784 return DISP_E_MEMBERNOTFOUND
;
786 memset( params
, 0, sizeof(*params
) );
787 return IWbemClassObject_Get( object
->object
, name
, 0, result
, NULL
, NULL
);
790 static HRESULT WINAPI
object_Put_(
793 IDispatch
*objWbemNamedValueSet
,
794 ISWbemObjectPath
**objWbemObjectPath
)
800 static HRESULT WINAPI
object_PutAsync_(
802 IDispatch
*objWbemSink
,
804 IDispatch
*objWbemNamedValueSet
,
805 IDispatch
*objWbemAsyncContext
)
811 static HRESULT WINAPI
object_Delete_(
814 IDispatch
*objWbemNamedValueSet
)
820 static HRESULT WINAPI
object_DeleteAsync_(
822 IDispatch
*objWbemSink
,
824 IDispatch
*objWbemNamedValueSet
,
825 IDispatch
*objWbemAsyncContext
)
831 static HRESULT WINAPI
object_Instances_(
834 IDispatch
*objWbemNamedValueSet
,
835 ISWbemObjectSet
**objWbemObjectSet
)
841 static HRESULT WINAPI
object_InstancesAsync_(
843 IDispatch
*objWbemSink
,
845 IDispatch
*objWbemNamedValueSet
,
846 IDispatch
*objWbemAsyncContext
)
852 static HRESULT WINAPI
object_Subclasses_(
855 IDispatch
*objWbemNamedValueSet
,
856 ISWbemObjectSet
**objWbemObjectSet
)
862 static HRESULT WINAPI
object_SubclassesAsync_(
864 IDispatch
*objWbemSink
,
866 IDispatch
*objWbemNamedValueSet
,
867 IDispatch
*objWbemAsyncContext
)
873 static HRESULT WINAPI
object_Associators_(
879 VARIANT_BOOL bClassesOnly
,
880 VARIANT_BOOL bSchemaOnly
,
881 BSTR strRequiredAssocQualifier
,
882 BSTR strRequiredQualifier
,
884 IDispatch
*objWbemNamedValueSet
,
885 ISWbemObjectSet
**objWbemObjectSet
)
891 static HRESULT WINAPI
object_AssociatorsAsync_(
893 IDispatch
*objWbemSink
,
898 VARIANT_BOOL bClassesOnly
,
899 VARIANT_BOOL bSchemaOnly
,
900 BSTR strRequiredAssocQualifier
,
901 BSTR strRequiredQualifier
,
903 IDispatch
*objWbemNamedValueSet
,
904 IDispatch
*objWbemAsyncContext
)
910 static HRESULT WINAPI
object_References_(
914 VARIANT_BOOL bClassesOnly
,
915 VARIANT_BOOL bSchemaOnly
,
916 BSTR strRequiredQualifier
,
918 IDispatch
*objWbemNamedValueSet
,
919 ISWbemObjectSet
**objWbemObjectSet
)
925 static HRESULT WINAPI
object_ReferencesAsync_(
927 IDispatch
*objWbemSink
,
930 VARIANT_BOOL bClassesOnly
,
931 VARIANT_BOOL bSchemaOnly
,
932 BSTR strRequiredQualifier
,
934 IDispatch
*objWbemNamedValueSet
,
935 IDispatch
*objWbemAsyncContext
)
941 static HRESULT WINAPI
object_ExecMethod_(
944 IDispatch
*objWbemInParameters
,
946 IDispatch
*objWbemNamedValueSet
,
947 ISWbemObject
**objWbemOutParameters
)
953 static HRESULT WINAPI
object_ExecMethodAsync_(
955 IDispatch
*objWbemSink
,
957 IDispatch
*objWbemInParameters
,
959 IDispatch
*objWbemNamedValueSet
,
960 IDispatch
*objWbemAsyncContext
)
966 static HRESULT WINAPI
object_Clone_(
968 ISWbemObject
**objWbemObject
)
974 static HRESULT WINAPI
object_GetObjectText_(
977 BSTR
*strObjectText
)
983 static HRESULT WINAPI
object_SpawnDerivedClass_(
986 ISWbemObject
**objWbemObject
)
992 static HRESULT WINAPI
object_SpawnInstance_(
995 ISWbemObject
**objWbemObject
)
1001 static HRESULT WINAPI
object_CompareTo_(
1002 ISWbemObject
*iface
,
1003 IDispatch
*objWbemObject
,
1005 VARIANT_BOOL
*bResult
)
1011 static HRESULT WINAPI
object_get_Qualifiers_(
1012 ISWbemObject
*iface
,
1013 ISWbemQualifierSet
**objWbemQualifierSet
)
1019 static HRESULT WINAPI
object_get_Properties_( ISWbemObject
*iface
, ISWbemPropertySet
**prop_set
)
1021 struct object
*object
= impl_from_ISWbemObject( iface
);
1023 TRACE( "%p, %p\n", object
, prop_set
);
1024 return SWbemPropertySet_create( object
->object
, prop_set
);
1027 static HRESULT WINAPI
object_get_Methods_(
1028 ISWbemObject
*iface
,
1029 ISWbemMethodSet
**objWbemMethodSet
)
1035 static HRESULT WINAPI
object_get_Derivation_(
1036 ISWbemObject
*iface
,
1037 VARIANT
*strClassNameArray
)
1043 static HRESULT WINAPI
object_get_Path_(
1044 ISWbemObject
*iface
,
1045 ISWbemObjectPath
**objWbemObjectPath
)
1051 static HRESULT WINAPI
object_get_Security_(
1052 ISWbemObject
*iface
,
1053 ISWbemSecurity
**objWbemSecurity
)
1059 static const ISWbemObjectVtbl object_vtbl
=
1061 object_QueryInterface
,
1064 object_GetTypeInfoCount
,
1066 object_GetIDsOfNames
,
1071 object_DeleteAsync_
,
1073 object_InstancesAsync_
,
1075 object_SubclassesAsync_
,
1076 object_Associators_
,
1077 object_AssociatorsAsync_
,
1079 object_ReferencesAsync_
,
1081 object_ExecMethodAsync_
,
1083 object_GetObjectText_
,
1084 object_SpawnDerivedClass_
,
1085 object_SpawnInstance_
,
1087 object_get_Qualifiers_
,
1088 object_get_Properties_
,
1089 object_get_Methods_
,
1090 object_get_Derivation_
,
1092 object_get_Security_
1095 static HRESULT
SWbemObject_create( IWbemClassObject
*wbem_object
, ISWbemObject
**obj
)
1097 struct object
*object
;
1099 TRACE( "%p, %p\n", obj
, wbem_object
);
1101 if (!(object
= heap_alloc( sizeof(*object
) ))) return E_OUTOFMEMORY
;
1102 object
->ISWbemObject_iface
.lpVtbl
= &object_vtbl
;
1104 object
->object
= wbem_object
;
1105 IWbemClassObject_AddRef( object
->object
);
1106 object
->members
= NULL
;
1107 object
->nb_members
= 0;
1108 object
->last_dispid
= DISPID_BASE
;
1109 object
->last_dispid_method
= DISPID_BASE_METHOD
;
1111 *obj
= &object
->ISWbemObject_iface
;
1112 TRACE( "returning iface %p\n", *obj
);
1118 ISWbemObjectSet ISWbemObjectSet_iface
;
1120 IEnumWbemClassObject
*objectenum
;
1124 static inline struct objectset
*impl_from_ISWbemObjectSet(
1125 ISWbemObjectSet
*iface
)
1127 return CONTAINING_RECORD( iface
, struct objectset
, ISWbemObjectSet_iface
);
1130 static ULONG WINAPI
objectset_AddRef(
1131 ISWbemObjectSet
*iface
)
1133 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1134 return InterlockedIncrement( &objectset
->refs
);
1137 static ULONG WINAPI
objectset_Release(
1138 ISWbemObjectSet
*iface
)
1140 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1141 LONG refs
= InterlockedDecrement( &objectset
->refs
);
1144 TRACE( "destroying %p\n", objectset
);
1145 IEnumWbemClassObject_Release( objectset
->objectenum
);
1146 heap_free( objectset
);
1151 static HRESULT WINAPI
objectset_QueryInterface(
1152 ISWbemObjectSet
*iface
,
1156 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1158 TRACE( "%p %s %p\n", objectset
, debugstr_guid(riid
), ppvObject
);
1160 if (IsEqualGUID( riid
, &IID_ISWbemObjectSet
) ||
1161 IsEqualGUID( riid
, &IID_IDispatch
) ||
1162 IsEqualGUID( riid
, &IID_IUnknown
))
1168 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
1169 return E_NOINTERFACE
;
1171 ISWbemObjectSet_AddRef( iface
);
1175 static HRESULT WINAPI
objectset_GetTypeInfoCount(
1176 ISWbemObjectSet
*iface
,
1179 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1180 TRACE( "%p, %p\n", objectset
, count
);
1185 static HRESULT WINAPI
objectset_GetTypeInfo(
1186 ISWbemObjectSet
*iface
,
1191 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1192 TRACE( "%p, %u, %u, %p\n", objectset
, index
, lcid
, info
);
1194 return get_typeinfo( ISWbemObjectSet_tid
, info
);
1197 static HRESULT WINAPI
objectset_GetIDsOfNames(
1198 ISWbemObjectSet
*iface
,
1205 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1206 ITypeInfo
*typeinfo
;
1209 TRACE( "%p, %s, %p, %u, %u, %p\n", objectset
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
1211 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
1213 hr
= get_typeinfo( ISWbemObjectSet_tid
, &typeinfo
);
1216 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
1217 ITypeInfo_Release( typeinfo
);
1222 static HRESULT WINAPI
objectset_Invoke(
1223 ISWbemObjectSet
*iface
,
1230 EXCEPINFO
*excep_info
,
1233 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1234 ITypeInfo
*typeinfo
;
1237 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", objectset
, member
, debugstr_guid(riid
),
1238 lcid
, flags
, params
, result
, excep_info
, arg_err
);
1240 hr
= get_typeinfo( ISWbemObjectSet_tid
, &typeinfo
);
1243 hr
= ITypeInfo_Invoke( typeinfo
, &objectset
->ISWbemObjectSet_iface
, member
, flags
,
1244 params
, result
, excep_info
, arg_err
);
1245 ITypeInfo_Release( typeinfo
);
1250 static HRESULT WINAPI
objectset_get__NewEnum(
1251 ISWbemObjectSet
*iface
,
1254 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1255 IEnumWbemClassObject
*objectenum
;
1258 TRACE( "%p, %p\n", objectset
, pUnk
);
1260 hr
= IEnumWbemClassObject_Clone( objectset
->objectenum
, &objectenum
);
1261 if (FAILED( hr
)) return hr
;
1263 hr
= EnumVARIANT_create( objectenum
, (IEnumVARIANT
**)pUnk
);
1264 IEnumWbemClassObject_Release( objectenum
);
1268 static HRESULT WINAPI
objectset_Item(
1269 ISWbemObjectSet
*iface
,
1272 ISWbemObject
**objWbemObject
)
1278 static HRESULT WINAPI
objectset_get_Count(
1279 ISWbemObjectSet
*iface
,
1282 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1284 TRACE( "%p, %p\n", objectset
, iCount
);
1286 *iCount
= objectset
->count
;
1290 static HRESULT WINAPI
objectset_get_Security_(
1291 ISWbemObjectSet
*iface
,
1292 ISWbemSecurity
**objWbemSecurity
)
1298 static HRESULT WINAPI
objectset_ItemIndex(
1299 ISWbemObjectSet
*iface
,
1301 ISWbemObject
**objWbemObject
)
1303 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1306 IEnumVARIANT
*enum_var
;
1309 TRACE( "%p, %d, %p\n", objectset
, lIndex
, objWbemObject
);
1311 *objWbemObject
= NULL
;
1312 hr
= ISWbemObjectSet_get_Count( iface
, &count
);
1313 if (FAILED(hr
)) return hr
;
1315 if (lIndex
>= count
) return WBEM_E_NOT_FOUND
;
1317 hr
= ISWbemObjectSet_get__NewEnum( iface
, (IUnknown
**)&enum_var
);
1318 if (FAILED(hr
)) return hr
;
1320 IEnumVARIANT_Reset( enum_var
);
1321 hr
= IEnumVARIANT_Skip( enum_var
, lIndex
);
1323 hr
= IEnumVARIANT_Next( enum_var
, 1, &var
, NULL
);
1324 IEnumVARIANT_Release( enum_var
);
1328 if (V_VT( &var
) == VT_DISPATCH
)
1329 hr
= IDispatch_QueryInterface( V_DISPATCH( &var
), &IID_ISWbemObject
, (void **)objWbemObject
);
1331 hr
= WBEM_E_NOT_FOUND
;
1332 VariantClear( &var
);
1338 static const ISWbemObjectSetVtbl objectset_vtbl
=
1340 objectset_QueryInterface
,
1343 objectset_GetTypeInfoCount
,
1344 objectset_GetTypeInfo
,
1345 objectset_GetIDsOfNames
,
1347 objectset_get__NewEnum
,
1349 objectset_get_Count
,
1350 objectset_get_Security_
,
1354 static LONG
get_object_count( IEnumWbemClassObject
*iter
)
1357 while (IEnumWbemClassObject_Skip( iter
, WBEM_INFINITE
, 1 ) == S_OK
) count
++;
1358 IEnumWbemClassObject_Reset( iter
);
1362 static HRESULT
SWbemObjectSet_create( IEnumWbemClassObject
*wbem_objectenum
, ISWbemObjectSet
**obj
)
1364 struct objectset
*objectset
;
1366 TRACE( "%p, %p\n", obj
, wbem_objectenum
);
1368 if (!(objectset
= heap_alloc( sizeof(*objectset
) ))) return E_OUTOFMEMORY
;
1369 objectset
->ISWbemObjectSet_iface
.lpVtbl
= &objectset_vtbl
;
1370 objectset
->refs
= 1;
1371 objectset
->objectenum
= wbem_objectenum
;
1372 IEnumWbemClassObject_AddRef( objectset
->objectenum
);
1373 objectset
->count
= get_object_count( objectset
->objectenum
);
1375 *obj
= &objectset
->ISWbemObjectSet_iface
;
1376 TRACE( "returning iface %p\n", *obj
);
1382 IEnumVARIANT IEnumVARIANT_iface
;
1384 IEnumWbemClassObject
*objectenum
;
1387 static inline struct enumvar
*impl_from_IEnumVARIANT(
1388 IEnumVARIANT
*iface
)
1390 return CONTAINING_RECORD( iface
, struct enumvar
, IEnumVARIANT_iface
);
1393 static ULONG WINAPI
enumvar_AddRef(
1394 IEnumVARIANT
*iface
)
1396 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1397 return InterlockedIncrement( &enumvar
->refs
);
1400 static ULONG WINAPI
enumvar_Release(
1401 IEnumVARIANT
*iface
)
1403 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1404 LONG refs
= InterlockedDecrement( &enumvar
->refs
);
1407 TRACE( "destroying %p\n", enumvar
);
1408 IEnumWbemClassObject_Release( enumvar
->objectenum
);
1409 heap_free( enumvar
);
1414 static HRESULT WINAPI
enumvar_QueryInterface(
1415 IEnumVARIANT
*iface
,
1419 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1421 TRACE( "%p %s %p\n", enumvar
, debugstr_guid(riid
), ppvObject
);
1423 if (IsEqualGUID( riid
, &IID_IEnumVARIANT
) ||
1424 IsEqualGUID( riid
, &IID_IUnknown
))
1430 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
1431 return E_NOINTERFACE
;
1433 IEnumVARIANT_AddRef( iface
);
1437 static HRESULT WINAPI
enumvar_Next( IEnumVARIANT
*iface
, ULONG celt
, VARIANT
*var
, ULONG
*fetched
)
1439 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1440 IWbemClassObject
*obj
;
1443 TRACE( "%p, %u, %p, %p\n", iface
, celt
, var
, fetched
);
1445 if (celt
) IEnumWbemClassObject_Next( enumvar
->objectenum
, WBEM_INFINITE
, 1, &obj
, &count
);
1451 hr
= SWbemObject_create( obj
, &sobj
);
1452 IWbemClassObject_Release( obj
);
1453 if (FAILED( hr
)) return hr
;
1455 V_VT( var
) = VT_DISPATCH
;
1456 V_DISPATCH( var
) = (IDispatch
*)sobj
;
1458 if (fetched
) *fetched
= count
;
1459 return (count
< celt
) ? S_FALSE
: S_OK
;
1462 static HRESULT WINAPI
enumvar_Skip( IEnumVARIANT
*iface
, ULONG celt
)
1464 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1466 TRACE( "%p, %u\n", iface
, celt
);
1468 return IEnumWbemClassObject_Skip( enumvar
->objectenum
, WBEM_INFINITE
, celt
);
1471 static HRESULT WINAPI
enumvar_Reset( IEnumVARIANT
*iface
)
1473 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1475 TRACE( "%p\n", iface
);
1477 return IEnumWbemClassObject_Reset( enumvar
->objectenum
);
1480 static HRESULT WINAPI
enumvar_Clone( IEnumVARIANT
*iface
, IEnumVARIANT
**penum
)
1482 FIXME( "%p, %p\n", iface
, penum
);
1486 static const struct IEnumVARIANTVtbl enumvar_vtbl
=
1488 enumvar_QueryInterface
,
1497 static HRESULT
EnumVARIANT_create( IEnumWbemClassObject
*objectenum
, IEnumVARIANT
**obj
)
1499 struct enumvar
*enumvar
;
1501 if (!(enumvar
= heap_alloc( sizeof(*enumvar
) ))) return E_OUTOFMEMORY
;
1502 enumvar
->IEnumVARIANT_iface
.lpVtbl
= &enumvar_vtbl
;
1504 enumvar
->objectenum
= objectenum
;
1505 IEnumWbemClassObject_AddRef( enumvar
->objectenum
);
1507 *obj
= &enumvar
->IEnumVARIANT_iface
;
1508 TRACE( "returning iface %p\n", *obj
);
1514 ISWbemServices ISWbemServices_iface
;
1516 IWbemServices
*services
;
1519 static inline struct services
*impl_from_ISWbemServices(
1520 ISWbemServices
*iface
)
1522 return CONTAINING_RECORD( iface
, struct services
, ISWbemServices_iface
);
1525 static ULONG WINAPI
services_AddRef(
1526 ISWbemServices
*iface
)
1528 struct services
*services
= impl_from_ISWbemServices( iface
);
1529 return InterlockedIncrement( &services
->refs
);
1532 static ULONG WINAPI
services_Release(
1533 ISWbemServices
*iface
)
1535 struct services
*services
= impl_from_ISWbemServices( iface
);
1536 LONG refs
= InterlockedDecrement( &services
->refs
);
1539 TRACE( "destroying %p\n", services
);
1540 IWbemServices_Release( services
->services
);
1541 heap_free( services
);
1546 static HRESULT WINAPI
services_QueryInterface(
1547 ISWbemServices
*iface
,
1551 struct services
*services
= impl_from_ISWbemServices( iface
);
1553 TRACE( "%p %s %p\n", services
, debugstr_guid(riid
), ppvObject
);
1555 if (IsEqualGUID( riid
, &IID_ISWbemServices
) ||
1556 IsEqualGUID( riid
, &IID_IDispatch
) ||
1557 IsEqualGUID( riid
, &IID_IUnknown
))
1563 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
1564 return E_NOINTERFACE
;
1566 ISWbemServices_AddRef( iface
);
1570 static HRESULT WINAPI
services_GetTypeInfoCount(
1571 ISWbemServices
*iface
,
1574 struct services
*services
= impl_from_ISWbemServices( iface
);
1575 TRACE( "%p, %p\n", services
, count
);
1581 static HRESULT WINAPI
services_GetTypeInfo(
1582 ISWbemServices
*iface
,
1587 struct services
*services
= impl_from_ISWbemServices( iface
);
1588 TRACE( "%p, %u, %u, %p\n", services
, index
, lcid
, info
);
1590 return get_typeinfo( ISWbemServices_tid
, info
);
1593 static HRESULT WINAPI
services_GetIDsOfNames(
1594 ISWbemServices
*iface
,
1601 struct services
*services
= impl_from_ISWbemServices( iface
);
1602 ITypeInfo
*typeinfo
;
1605 TRACE( "%p, %s, %p, %u, %u, %p\n", services
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
1607 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
1609 hr
= get_typeinfo( ISWbemServices_tid
, &typeinfo
);
1612 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
1613 ITypeInfo_Release( typeinfo
);
1618 static HRESULT WINAPI
services_Invoke(
1619 ISWbemServices
*iface
,
1626 EXCEPINFO
*excep_info
,
1629 struct services
*services
= impl_from_ISWbemServices( iface
);
1630 ITypeInfo
*typeinfo
;
1633 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", services
, member
, debugstr_guid(riid
),
1634 lcid
, flags
, params
, result
, excep_info
, arg_err
);
1636 hr
= get_typeinfo( ISWbemServices_tid
, &typeinfo
);
1639 hr
= ITypeInfo_Invoke( typeinfo
, &services
->ISWbemServices_iface
, member
, flags
,
1640 params
, result
, excep_info
, arg_err
);
1641 ITypeInfo_Release( typeinfo
);
1646 static HRESULT WINAPI
services_Get(
1647 ISWbemServices
*iface
,
1650 IDispatch
*objWbemNamedValueSet
,
1651 ISWbemObject
**objWbemObject
)
1653 struct services
*services
= impl_from_ISWbemServices( iface
);
1654 IWbemClassObject
*obj
;
1657 TRACE( "%p, %s, %d, %p, %p\n", iface
, debugstr_w(strObjectPath
), iFlags
, objWbemNamedValueSet
,
1660 if (objWbemNamedValueSet
) FIXME( "ignoring context\n" );
1662 hr
= IWbemServices_GetObject( services
->services
, strObjectPath
, iFlags
, NULL
, &obj
, NULL
);
1663 if (hr
!= S_OK
) return hr
;
1665 hr
= SWbemObject_create( obj
, objWbemObject
);
1666 IWbemClassObject_Release( obj
);
1670 static HRESULT WINAPI
services_GetAsync(
1671 ISWbemServices
*iface
,
1672 IDispatch
*objWbemSink
,
1675 IDispatch
*objWbemNamedValueSet
,
1676 IDispatch
*objWbemAsyncContext
)
1682 static HRESULT WINAPI
services_Delete(
1683 ISWbemServices
*iface
,
1686 IDispatch
*objWbemNamedValueSet
)
1692 static HRESULT WINAPI
services_DeleteAsync(
1693 ISWbemServices
* This
,
1694 IDispatch
*objWbemSink
,
1697 IDispatch
*objWbemNamedValueSet
,
1698 IDispatch
*objWbemAsyncContext
)
1704 static BSTR
build_query_string( const WCHAR
*class )
1706 static const WCHAR selectW
[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',0};
1707 UINT len
= strlenW(class) + ARRAY_SIZE(selectW
);
1710 if (!(ret
= SysAllocStringLen( NULL
, len
))) return NULL
;
1711 strcpyW( ret
, selectW
);
1712 strcatW( ret
, class );
1716 static HRESULT WINAPI
services_InstancesOf(
1717 ISWbemServices
*iface
,
1720 IDispatch
*objWbemNamedValueSet
,
1721 ISWbemObjectSet
**objWbemObjectSet
)
1723 static const WCHAR wqlW
[] = {'W','Q','L',0};
1724 BSTR query
, wql
= SysAllocString( wqlW
);
1727 TRACE( "%p, %s, %x, %p, %p\n", iface
, debugstr_w(strClass
), iFlags
, objWbemNamedValueSet
,
1730 if (!(query
= build_query_string( strClass
)))
1732 SysFreeString( wql
);
1733 return E_OUTOFMEMORY
;
1735 hr
= ISWbemServices_ExecQuery( iface
, query
, wql
, iFlags
, objWbemNamedValueSet
, objWbemObjectSet
);
1736 SysFreeString( wql
);
1737 SysFreeString( query
);
1741 static HRESULT WINAPI
services_InstancesOfAsync(
1742 ISWbemServices
*iface
,
1743 IDispatch
*objWbemSink
,
1746 IDispatch
*objWbemNamedValueSet
,
1747 IDispatch
*objWbemAsyncContext
)
1753 static HRESULT WINAPI
services_SubclassesOf(
1754 ISWbemServices
*iface
,
1757 IDispatch
*objWbemNamedValueSet
,
1758 ISWbemObjectSet
**objWbemObjectSet
)
1764 static HRESULT WINAPI
services_SubclassesOfAsync(
1765 ISWbemServices
*iface
,
1766 IDispatch
*objWbemSink
,
1769 IDispatch
*objWbemNamedValueSet
,
1770 IDispatch
*objWbemAsyncContext
)
1776 static HRESULT WINAPI
services_ExecQuery(
1777 ISWbemServices
*iface
,
1779 BSTR strQueryLanguage
,
1781 IDispatch
*objWbemNamedValueSet
,
1782 ISWbemObjectSet
**objWbemObjectSet
)
1784 struct services
*services
= impl_from_ISWbemServices( iface
);
1785 IEnumWbemClassObject
*iter
;
1788 TRACE( "%p, %s, %s, %x, %p, %p\n", iface
, debugstr_w(strQuery
), debugstr_w(strQueryLanguage
),
1789 iFlags
, objWbemNamedValueSet
, objWbemObjectSet
);
1791 if (objWbemNamedValueSet
) FIXME( "ignoring context\n" );
1793 hr
= IWbemServices_ExecQuery( services
->services
, strQueryLanguage
, strQuery
, iFlags
, NULL
, &iter
);
1794 if (hr
!= S_OK
) return hr
;
1796 hr
= SWbemObjectSet_create( iter
, objWbemObjectSet
);
1797 IEnumWbemClassObject_Release( iter
);
1801 static HRESULT WINAPI
services_ExecQueryAsync(
1802 ISWbemServices
*iface
,
1803 IDispatch
*objWbemSink
,
1805 BSTR strQueryLanguage
,
1807 IDispatch
*objWbemNamedValueSet
,
1808 IDispatch
*objWbemAsyncContext
)
1814 static HRESULT WINAPI
services_AssociatorsOf(
1815 ISWbemServices
*iface
,
1818 BSTR strResultClass
,
1821 VARIANT_BOOL bClassesOnly
,
1822 VARIANT_BOOL bSchemaOnly
,
1823 BSTR strRequiredAssocQualifier
,
1824 BSTR strRequiredQualifier
,
1826 IDispatch
*objWbemNamedValueSet
,
1827 ISWbemObjectSet
**objWbemObjectSet
)
1833 static HRESULT WINAPI
services_AssociatorsOfAsync(
1834 ISWbemServices
*iface
,
1835 IDispatch
*objWbemSink
,
1838 BSTR strResultClass
,
1841 VARIANT_BOOL bClassesOnly
,
1842 VARIANT_BOOL bSchemaOnly
,
1843 BSTR strRequiredAssocQualifier
,
1844 BSTR strRequiredQualifier
,
1846 IDispatch
*objWbemNamedValueSet
,
1847 IDispatch
*objWbemAsyncContext
)
1853 static HRESULT WINAPI
services_ReferencesTo(
1854 ISWbemServices
*iface
,
1856 BSTR strResultClass
,
1858 VARIANT_BOOL bClassesOnly
,
1859 VARIANT_BOOL bSchemaOnly
,
1860 BSTR strRequiredQualifier
,
1862 IDispatch
*objWbemNamedValueSet
,
1863 ISWbemObjectSet
**objWbemObjectSet
)
1869 static HRESULT WINAPI
services_ReferencesToAsync(
1870 ISWbemServices
*iface
,
1871 IDispatch
*objWbemSink
,
1873 BSTR strResultClass
,
1875 VARIANT_BOOL bClassesOnly
,
1876 VARIANT_BOOL bSchemaOnly
,
1877 BSTR strRequiredQualifier
,
1879 IDispatch
*objWbemNamedValueSet
,
1880 IDispatch
*objWbemAsyncContext
)
1886 static HRESULT WINAPI
services_ExecNotificationQuery(
1887 ISWbemServices
*iface
,
1889 BSTR strQueryLanguage
,
1891 IDispatch
*objWbemNamedValueSet
,
1892 ISWbemEventSource
**objWbemEventSource
)
1898 static HRESULT WINAPI
services_ExecNotificationQueryAsync(
1899 ISWbemServices
*iface
,
1900 IDispatch
*objWbemSink
,
1902 BSTR strQueryLanguage
,
1904 IDispatch
*objWbemNamedValueSet
,
1905 IDispatch
*objWbemAsyncContext
)
1911 static HRESULT WINAPI
services_ExecMethod(
1912 ISWbemServices
*iface
,
1915 IDispatch
*objWbemInParameters
,
1917 IDispatch
*objWbemNamedValueSet
,
1918 ISWbemObject
**objWbemOutParameters
)
1924 static HRESULT WINAPI
services_ExecMethodAsync(
1925 ISWbemServices
*iface
,
1926 IDispatch
*objWbemSink
,
1929 IDispatch
*objWbemInParameters
,
1931 IDispatch
*objWbemNamedValueSet
,
1932 IDispatch
*objWbemAsyncContext
)
1938 static HRESULT WINAPI
services_get_Security_(
1939 ISWbemServices
*iface
,
1940 ISWbemSecurity
**objWbemSecurity
)
1942 TRACE( "%p, %p\n", iface
, objWbemSecurity
);
1944 if (!objWbemSecurity
)
1945 return E_INVALIDARG
;
1947 return ISWbemSecurity_create( objWbemSecurity
);
1950 static const ISWbemServicesVtbl services_vtbl
=
1952 services_QueryInterface
,
1955 services_GetTypeInfoCount
,
1956 services_GetTypeInfo
,
1957 services_GetIDsOfNames
,
1962 services_DeleteAsync
,
1963 services_InstancesOf
,
1964 services_InstancesOfAsync
,
1965 services_SubclassesOf
,
1966 services_SubclassesOfAsync
,
1968 services_ExecQueryAsync
,
1969 services_AssociatorsOf
,
1970 services_AssociatorsOfAsync
,
1971 services_ReferencesTo
,
1972 services_ReferencesToAsync
,
1973 services_ExecNotificationQuery
,
1974 services_ExecNotificationQueryAsync
,
1975 services_ExecMethod
,
1976 services_ExecMethodAsync
,
1977 services_get_Security_
1980 static HRESULT
SWbemServices_create( IWbemServices
*wbem_services
, ISWbemServices
**obj
)
1982 struct services
*services
;
1984 TRACE( "%p, %p\n", obj
, wbem_services
);
1986 if (!(services
= heap_alloc( sizeof(*services
) ))) return E_OUTOFMEMORY
;
1987 services
->ISWbemServices_iface
.lpVtbl
= &services_vtbl
;
1989 services
->services
= wbem_services
;
1990 IWbemServices_AddRef( services
->services
);
1992 *obj
= &services
->ISWbemServices_iface
;
1993 TRACE( "returning iface %p\n", *obj
);
1999 ISWbemLocator ISWbemLocator_iface
;
2001 IWbemLocator
*locator
;
2004 static inline struct locator
*impl_from_ISWbemLocator( ISWbemLocator
*iface
)
2006 return CONTAINING_RECORD( iface
, struct locator
, ISWbemLocator_iface
);
2009 static ULONG WINAPI
locator_AddRef(
2010 ISWbemLocator
*iface
)
2012 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2013 return InterlockedIncrement( &locator
->refs
);
2016 static ULONG WINAPI
locator_Release(
2017 ISWbemLocator
*iface
)
2019 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2020 LONG refs
= InterlockedDecrement( &locator
->refs
);
2023 TRACE( "destroying %p\n", locator
);
2024 if (locator
->locator
)
2025 IWbemLocator_Release( locator
->locator
);
2026 heap_free( locator
);
2031 static HRESULT WINAPI
locator_QueryInterface(
2032 ISWbemLocator
*iface
,
2036 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2038 TRACE( "%p, %s, %p\n", locator
, debugstr_guid( riid
), ppvObject
);
2040 if (IsEqualGUID( riid
, &IID_ISWbemLocator
) ||
2041 IsEqualGUID( riid
, &IID_IDispatch
) ||
2042 IsEqualGUID( riid
, &IID_IUnknown
))
2048 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
2049 return E_NOINTERFACE
;
2051 ISWbemLocator_AddRef( iface
);
2055 static HRESULT WINAPI
locator_GetTypeInfoCount(
2056 ISWbemLocator
*iface
,
2059 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2061 TRACE( "%p, %p\n", locator
, count
);
2066 static HRESULT WINAPI
locator_GetTypeInfo(
2067 ISWbemLocator
*iface
,
2072 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2073 TRACE( "%p, %u, %u, %p\n", locator
, index
, lcid
, info
);
2075 return get_typeinfo( ISWbemLocator_tid
, info
);
2078 static HRESULT WINAPI
locator_GetIDsOfNames(
2079 ISWbemLocator
*iface
,
2086 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2087 ITypeInfo
*typeinfo
;
2090 TRACE( "%p, %s, %p, %u, %u, %p\n", locator
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
2092 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
2094 hr
= get_typeinfo( ISWbemLocator_tid
, &typeinfo
);
2097 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
2098 ITypeInfo_Release( typeinfo
);
2103 static HRESULT WINAPI
locator_Invoke(
2104 ISWbemLocator
*iface
,
2111 EXCEPINFO
*excep_info
,
2114 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2115 ITypeInfo
*typeinfo
;
2118 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", locator
, member
, debugstr_guid(riid
),
2119 lcid
, flags
, params
, result
, excep_info
, arg_err
);
2121 hr
= get_typeinfo( ISWbemLocator_tid
, &typeinfo
);
2124 hr
= ITypeInfo_Invoke( typeinfo
, &locator
->ISWbemLocator_iface
, member
, flags
,
2125 params
, result
, excep_info
, arg_err
);
2126 ITypeInfo_Release( typeinfo
);
2131 static BSTR
build_resource_string( BSTR server
, BSTR
namespace )
2133 static const WCHAR defaultW
[] = {'r','o','o','t','\\','d','e','f','a','u','l','t',0};
2134 ULONG len
, len_server
= 0, len_namespace
= 0;
2137 if (server
&& *server
) len_server
= strlenW( server
);
2138 else len_server
= 1;
2139 if (namespace && *namespace) len_namespace
= strlenW( namespace );
2140 else len_namespace
= ARRAY_SIZE(defaultW
) - 1;
2142 if (!(ret
= SysAllocStringLen( NULL
, 2 + len_server
+ 1 + len_namespace
))) return NULL
;
2144 ret
[0] = ret
[1] = '\\';
2145 if (server
&& *server
) strcpyW( ret
+ 2, server
);
2148 len
= len_server
+ 2;
2151 if (namespace && *namespace) strcpyW( ret
+ len
, namespace );
2152 else strcpyW( ret
+ len
, defaultW
);
2156 static HRESULT WINAPI
locator_ConnectServer(
2157 ISWbemLocator
*iface
,
2164 LONG iSecurityFlags
,
2165 IDispatch
*objWbemNamedValueSet
,
2166 ISWbemServices
**objWbemServices
)
2168 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2169 IWbemServices
*services
;
2173 TRACE( "%p, %s, %s, %s, %p, %s, %s, 0x%08x, %p, %p\n", iface
, debugstr_w(strServer
),
2174 debugstr_w(strNamespace
), debugstr_w(strUser
), strPassword
, debugstr_w(strLocale
),
2175 debugstr_w(strAuthority
), iSecurityFlags
, objWbemNamedValueSet
, objWbemServices
);
2177 if (objWbemNamedValueSet
) FIXME( "context not supported\n" );
2179 if (!locator
->locator
)
2181 hr
= CoCreateInstance( &CLSID_WbemLocator
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IWbemLocator
,
2182 (void **)&locator
->locator
);
2183 if (hr
!= S_OK
) return hr
;
2186 if (!(resource
= build_resource_string( strServer
, strNamespace
))) return E_OUTOFMEMORY
;
2187 hr
= IWbemLocator_ConnectServer( locator
->locator
, resource
, strUser
, strPassword
, strLocale
,
2188 iSecurityFlags
, strAuthority
, NULL
, &services
);
2189 SysFreeString( resource
);
2190 if (hr
!= S_OK
) return hr
;
2192 hr
= SWbemServices_create( services
, objWbemServices
);
2193 IWbemServices_Release( services
);
2197 static HRESULT WINAPI
locator_get_Security_(
2198 ISWbemLocator
*iface
,
2199 ISWbemSecurity
**objWbemSecurity
)
2201 TRACE( "%p, %p\n", iface
, objWbemSecurity
);
2203 if (!objWbemSecurity
)
2204 return E_INVALIDARG
;
2206 return ISWbemSecurity_create( objWbemSecurity
);
2209 static const ISWbemLocatorVtbl locator_vtbl
=
2211 locator_QueryInterface
,
2214 locator_GetTypeInfoCount
,
2215 locator_GetTypeInfo
,
2216 locator_GetIDsOfNames
,
2218 locator_ConnectServer
,
2219 locator_get_Security_
2222 HRESULT
SWbemLocator_create( void **obj
)
2224 struct locator
*locator
;
2226 TRACE( "%p\n", obj
);
2228 if (!(locator
= heap_alloc( sizeof(*locator
) ))) return E_OUTOFMEMORY
;
2229 locator
->ISWbemLocator_iface
.lpVtbl
= &locator_vtbl
;
2231 locator
->locator
= NULL
;
2233 *obj
= &locator
->ISWbemLocator_iface
;
2234 TRACE( "returning iface %p\n", *obj
);
2240 ISWbemSecurity ISWbemSecurity_iface
;
2242 WbemImpersonationLevelEnum implevel
;
2243 WbemAuthenticationLevelEnum authlevel
;
2246 static inline struct security
*impl_from_ISWbemSecurity( ISWbemSecurity
*iface
)
2248 return CONTAINING_RECORD( iface
, struct security
, ISWbemSecurity_iface
);
2251 static ULONG WINAPI
security_AddRef(
2252 ISWbemSecurity
*iface
)
2254 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2255 return InterlockedIncrement( &security
->refs
);
2258 static ULONG WINAPI
security_Release(
2259 ISWbemSecurity
*iface
)
2261 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2262 LONG refs
= InterlockedDecrement( &security
->refs
);
2265 TRACE( "destroying %p\n", security
);
2266 heap_free( security
);
2271 static HRESULT WINAPI
security_QueryInterface(
2272 ISWbemSecurity
*iface
,
2276 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2277 TRACE( "%p, %s, %p\n", security
, debugstr_guid( riid
), ppvObject
);
2279 if (IsEqualGUID( riid
, &IID_ISWbemSecurity
) ||
2280 IsEqualGUID( riid
, &IID_IDispatch
) ||
2281 IsEqualGUID( riid
, &IID_IUnknown
))
2287 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
2288 return E_NOINTERFACE
;
2290 ISWbemSecurity_AddRef( iface
);
2294 static HRESULT WINAPI
security_GetTypeInfoCount(
2295 ISWbemSecurity
*iface
,
2298 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2299 TRACE( "%p, %p\n", security
, count
);
2305 static HRESULT WINAPI
security_GetTypeInfo(
2306 ISWbemSecurity
*iface
,
2311 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2312 TRACE( "%p, %u, %u, %p\n", security
, index
, lcid
, info
);
2314 return get_typeinfo( ISWbemSecurity_tid
, info
);
2317 static HRESULT WINAPI
security_GetIDsOfNames(
2318 ISWbemSecurity
*iface
,
2325 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2326 ITypeInfo
*typeinfo
;
2329 TRACE( "%p, %s, %p, %u, %u, %p\n", security
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
2331 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
2333 hr
= get_typeinfo( ISWbemSecurity_tid
, &typeinfo
);
2336 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
2337 ITypeInfo_Release( typeinfo
);
2342 static HRESULT WINAPI
security_Invoke(
2343 ISWbemSecurity
*iface
,
2350 EXCEPINFO
*excep_info
,
2353 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2354 ITypeInfo
*typeinfo
;
2357 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", security
, member
, debugstr_guid(riid
),
2358 lcid
, flags
, params
, result
, excep_info
, arg_err
);
2360 hr
= get_typeinfo( ISWbemSecurity_tid
, &typeinfo
);
2363 hr
= ITypeInfo_Invoke( typeinfo
, &security
->ISWbemSecurity_iface
, member
, flags
,
2364 params
, result
, excep_info
, arg_err
);
2365 ITypeInfo_Release( typeinfo
);
2370 static HRESULT WINAPI
security_get_ImpersonationLevel(
2371 ISWbemSecurity
*iface
,
2372 WbemImpersonationLevelEnum
*impersonation_level
)
2374 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2375 FIXME( "%p, %p: stub\n", security
, impersonation_level
);
2377 if (!impersonation_level
)
2378 return E_INVALIDARG
;
2380 *impersonation_level
= security
->implevel
;
2384 static HRESULT WINAPI
security_put_ImpersonationLevel(
2385 ISWbemSecurity
*iface
,
2386 WbemImpersonationLevelEnum impersonation_level
)
2388 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2389 FIXME( "%p, %d: stub\n", security
, impersonation_level
);
2391 security
->implevel
= impersonation_level
;
2395 static HRESULT WINAPI
security_get_AuthenticationLevel(
2396 ISWbemSecurity
*iface
,
2397 WbemAuthenticationLevelEnum
*authentication_level
)
2399 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2400 FIXME( "%p, %p: stub\n", security
, authentication_level
);
2402 if (!authentication_level
)
2403 return E_INVALIDARG
;
2405 *authentication_level
= security
->authlevel
;
2409 static HRESULT WINAPI
security_put_AuthenticationLevel(
2410 ISWbemSecurity
*iface
,
2411 WbemAuthenticationLevelEnum authentication_level
)
2413 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2414 FIXME( "%p, %d: stub\n", security
, authentication_level
);
2416 security
->authlevel
= authentication_level
;
2420 static HRESULT WINAPI
security_get_Privileges(
2421 ISWbemSecurity
*iface
,
2422 ISWbemPrivilegeSet
**privilege_set
)
2424 struct security
*security
= impl_from_ISWbemSecurity( iface
);
2425 FIXME( "%p, %p: stub\n", security
, privilege_set
);
2428 return E_INVALIDARG
;
2433 static const ISWbemSecurityVtbl security_vtbl
=
2435 security_QueryInterface
,
2438 security_GetTypeInfoCount
,
2439 security_GetTypeInfo
,
2440 security_GetIDsOfNames
,
2442 security_get_ImpersonationLevel
,
2443 security_put_ImpersonationLevel
,
2444 security_get_AuthenticationLevel
,
2445 security_put_AuthenticationLevel
,
2446 security_get_Privileges
2449 static HRESULT
ISWbemSecurity_create( ISWbemSecurity
**obj
)
2451 struct security
*security
;
2453 TRACE( "%p\n", obj
);
2455 if (!(security
= heap_alloc( sizeof(*security
) ))) return E_OUTOFMEMORY
;
2456 security
->ISWbemSecurity_iface
.lpVtbl
= &security_vtbl
;
2458 security
->implevel
= wbemImpersonationLevelImpersonate
;
2459 security
->authlevel
= wbemAuthenticationLevelPktPrivacy
;
2461 *obj
= &security
->ISWbemSecurity_iface
;
2462 TRACE( "returning iface %p\n", *obj
);