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/unicode.h"
34 #include "wbemdisp_private.h"
35 #include "wbemdisp_classes.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(wbemdisp
);
39 static HRESULT
EnumVARIANT_create( IEnumWbemClassObject
*, IEnumVARIANT
** );
47 ISWbemPropertySet_tid
,
52 static ITypeLib
*wbemdisp_typelib
;
53 static ITypeInfo
*wbemdisp_typeinfo
[last_tid
];
55 static REFIID wbemdisp_tid_id
[] =
61 &IID_ISWbemPropertySet
,
65 static HRESULT
get_typeinfo( enum type_id tid
, ITypeInfo
**ret
)
69 if (!wbemdisp_typelib
)
73 hr
= LoadRegTypeLib( &LIBID_WbemScripting
, 1, 2, LOCALE_SYSTEM_DEFAULT
, &typelib
);
76 ERR( "LoadRegTypeLib failed: %08x\n", hr
);
79 if (InterlockedCompareExchangePointer( (void **)&wbemdisp_typelib
, typelib
, NULL
))
80 ITypeLib_Release( typelib
);
82 if (!wbemdisp_typeinfo
[tid
])
86 hr
= ITypeLib_GetTypeInfoOfGuid( wbemdisp_typelib
, wbemdisp_tid_id
[tid
], &typeinfo
);
89 ERR( "GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(wbemdisp_tid_id
[tid
]), hr
);
92 if (InterlockedCompareExchangePointer( (void **)(wbemdisp_typeinfo
+ tid
), typeinfo
, NULL
))
93 ITypeInfo_Release( typeinfo
);
95 *ret
= wbemdisp_typeinfo
[tid
];
96 ITypeInfo_AddRef( *ret
);
102 ISWbemProperty ISWbemProperty_iface
;
104 IWbemClassObject
*object
;
108 static inline struct property
*impl_from_ISWbemProperty( ISWbemProperty
*iface
)
110 return CONTAINING_RECORD( iface
, struct property
, ISWbemProperty_iface
);
113 static ULONG WINAPI
property_AddRef( ISWbemProperty
*iface
)
115 struct property
*property
= impl_from_ISWbemProperty( iface
);
116 return InterlockedIncrement( &property
->refs
);
119 static ULONG WINAPI
property_Release( ISWbemProperty
*iface
)
121 struct property
*property
= impl_from_ISWbemProperty( iface
);
122 LONG refs
= InterlockedDecrement( &property
->refs
);
125 TRACE( "destroying %p\n", property
);
126 IWbemClassObject_Release( property
->object
);
127 SysFreeString( property
->name
);
128 heap_free( property
);
133 static HRESULT WINAPI
property_QueryInterface( ISWbemProperty
*iface
, REFIID riid
, void **obj
)
135 struct property
*property
= impl_from_ISWbemProperty( iface
);
137 TRACE( "%p %s %p\n", property
, debugstr_guid(riid
), obj
);
139 if (IsEqualGUID( riid
, &IID_ISWbemProperty
) ||
140 IsEqualGUID( riid
, &IID_IDispatch
) ||
141 IsEqualGUID( riid
, &IID_IUnknown
))
147 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
148 return E_NOINTERFACE
;
150 ISWbemProperty_AddRef( iface
);
154 static HRESULT WINAPI
property_GetTypeInfoCount( ISWbemProperty
*iface
, UINT
*count
)
156 struct property
*property
= impl_from_ISWbemProperty( iface
);
157 TRACE( "%p, %p\n", property
, count
);
162 static HRESULT WINAPI
property_GetTypeInfo( ISWbemProperty
*iface
, UINT index
,
163 LCID lcid
, ITypeInfo
**info
)
165 struct property
*property
= impl_from_ISWbemProperty( iface
);
166 TRACE( "%p, %u, %u, %p\n", property
, index
, lcid
, info
);
168 return get_typeinfo( ISWbemProperty_tid
, info
);
171 static HRESULT WINAPI
property_GetIDsOfNames( ISWbemProperty
*iface
, REFIID riid
, LPOLESTR
*names
,
172 UINT count
, LCID lcid
, DISPID
*dispid
)
174 struct property
*property
= impl_from_ISWbemProperty( iface
);
178 TRACE( "%p, %s, %p, %u, %u, %p\n", property
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
180 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
182 hr
= get_typeinfo( ISWbemProperty_tid
, &typeinfo
);
185 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
186 ITypeInfo_Release( typeinfo
);
191 static HRESULT WINAPI
property_Invoke( ISWbemProperty
*iface
, DISPID member
, REFIID riid
,
192 LCID lcid
, WORD flags
, DISPPARAMS
*params
,
193 VARIANT
*result
, EXCEPINFO
*excep_info
, UINT
*arg_err
)
195 struct property
*property
= impl_from_ISWbemProperty( iface
);
199 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", property
, member
, debugstr_guid(riid
),
200 lcid
, flags
, params
, result
, excep_info
, arg_err
);
202 hr
= get_typeinfo( ISWbemProperty_tid
, &typeinfo
);
205 hr
= ITypeInfo_Invoke( typeinfo
, &property
->ISWbemProperty_iface
, member
, flags
,
206 params
, result
, excep_info
, arg_err
);
207 ITypeInfo_Release( typeinfo
);
212 static HRESULT WINAPI
property_get_Value( ISWbemProperty
*iface
, VARIANT
*value
)
214 struct property
*property
= impl_from_ISWbemProperty( iface
);
216 TRACE( "%p %p\n", property
, value
);
218 return IWbemClassObject_Get( property
->object
, property
->name
, 0, value
, NULL
, NULL
);
221 static HRESULT WINAPI
property_put_Value( ISWbemProperty
*iface
, VARIANT
*varValue
)
227 static HRESULT WINAPI
property_get_Name( ISWbemProperty
*iface
, BSTR
*strName
)
233 static HRESULT WINAPI
property_get_IsLocal( ISWbemProperty
*iface
, VARIANT_BOOL
*bIsLocal
)
239 static HRESULT WINAPI
property_get_Origin( ISWbemProperty
*iface
, BSTR
*strOrigin
)
245 static HRESULT WINAPI
property_get_CIMType( ISWbemProperty
*iface
, WbemCimtypeEnum
*iCimType
)
251 static HRESULT WINAPI
property_get_Qualifiers_( ISWbemProperty
*iface
, ISWbemQualifierSet
**objWbemQualifierSet
)
257 static HRESULT WINAPI
property_get_IsArray( ISWbemProperty
*iface
, VARIANT_BOOL
*bIsArray
)
263 static const ISWbemPropertyVtbl property_vtbl
=
265 property_QueryInterface
,
268 property_GetTypeInfoCount
,
269 property_GetTypeInfo
,
270 property_GetIDsOfNames
,
275 property_get_IsLocal
,
277 property_get_CIMType
,
278 property_get_Qualifiers_
,
282 static HRESULT
SWbemProperty_create( IWbemClassObject
*wbem_object
, BSTR name
, ISWbemProperty
**obj
)
284 struct property
*property
;
286 TRACE( "%p, %p\n", obj
, wbem_object
);
288 if (!(property
= heap_alloc( sizeof(*property
) ))) return E_OUTOFMEMORY
;
289 property
->ISWbemProperty_iface
.lpVtbl
= &property_vtbl
;
291 property
->object
= wbem_object
;
292 IWbemClassObject_AddRef( property
->object
);
293 property
->name
= SysAllocStringLen( name
, SysStringLen( name
) );
294 *obj
= &property
->ISWbemProperty_iface
;
295 TRACE( "returning iface %p\n", *obj
);
301 ISWbemPropertySet ISWbemPropertySet_iface
;
303 IWbemClassObject
*object
;
306 static inline struct propertyset
*impl_from_ISWbemPropertySet(
307 ISWbemPropertySet
*iface
)
309 return CONTAINING_RECORD( iface
, struct propertyset
, ISWbemPropertySet_iface
);
312 static ULONG WINAPI
propertyset_AddRef( ISWbemPropertySet
*iface
)
314 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
315 return InterlockedIncrement( &propertyset
->refs
);
318 static ULONG WINAPI
propertyset_Release( ISWbemPropertySet
*iface
)
320 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
321 LONG refs
= InterlockedDecrement( &propertyset
->refs
);
324 TRACE( "destroying %p\n", propertyset
);
325 IWbemClassObject_Release( propertyset
->object
);
326 heap_free( propertyset
);
331 static HRESULT WINAPI
propertyset_QueryInterface( ISWbemPropertySet
*iface
,
332 REFIID riid
, void **obj
)
334 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
336 TRACE( "%p %s %p\n", propertyset
, debugstr_guid(riid
), obj
);
338 if (IsEqualGUID( riid
, &IID_ISWbemPropertySet
) ||
339 IsEqualGUID( riid
, &IID_IDispatch
) ||
340 IsEqualGUID( riid
, &IID_IUnknown
))
346 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
347 return E_NOINTERFACE
;
349 ISWbemPropertySet_AddRef( iface
);
353 static HRESULT WINAPI
propertyset_GetTypeInfoCount( ISWbemPropertySet
*iface
, UINT
*count
)
355 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
356 TRACE( "%p, %p\n", propertyset
, count
);
361 static HRESULT WINAPI
propertyset_GetTypeInfo( ISWbemPropertySet
*iface
,
362 UINT index
, LCID lcid
, ITypeInfo
**info
)
364 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
365 TRACE( "%p, %u, %u, %p\n", propertyset
, index
, lcid
, info
);
367 return get_typeinfo( ISWbemPropertySet_tid
, info
);
370 static HRESULT WINAPI
propertyset_GetIDsOfNames( ISWbemPropertySet
*iface
, REFIID riid
, LPOLESTR
*names
,
371 UINT count
, LCID lcid
, DISPID
*dispid
)
373 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
377 TRACE( "%p, %s, %p, %u, %u, %p\n", propertyset
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
379 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
381 hr
= get_typeinfo( ISWbemPropertySet_tid
, &typeinfo
);
384 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
385 ITypeInfo_Release( typeinfo
);
390 static HRESULT WINAPI
propertyset_Invoke( ISWbemPropertySet
*iface
, DISPID member
, REFIID riid
,
391 LCID lcid
, WORD flags
, DISPPARAMS
*params
,
392 VARIANT
*result
, EXCEPINFO
*excep_info
, UINT
*arg_err
)
394 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
398 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", propertyset
, member
, debugstr_guid(riid
),
399 lcid
, flags
, params
, result
, excep_info
, arg_err
);
401 hr
= get_typeinfo( ISWbemPropertySet_tid
, &typeinfo
);
404 hr
= ITypeInfo_Invoke( typeinfo
, &propertyset
->ISWbemPropertySet_iface
, member
, flags
,
405 params
, result
, excep_info
, arg_err
);
406 ITypeInfo_Release( typeinfo
);
411 static HRESULT WINAPI
propertyset_get__NewEnum( ISWbemPropertySet
*iface
, IUnknown
**unk
)
417 static HRESULT WINAPI
propertyset_Item( ISWbemPropertySet
*iface
, BSTR name
,
418 LONG flags
, ISWbemProperty
**prop
)
420 struct propertyset
*propertyset
= impl_from_ISWbemPropertySet( iface
);
424 TRACE( "%p, %s, %08x, %p", propertyset
, debugstr_w(name
), flags
, prop
);
426 hr
= IWbemClassObject_Get( propertyset
->object
, name
, 0, &var
, NULL
, NULL
);
429 hr
= SWbemProperty_create( propertyset
->object
, name
, prop
);
430 VariantClear( &var
);
435 static HRESULT WINAPI
propertyset_get_Count( ISWbemPropertySet
*iface
, LONG
*count
)
441 static HRESULT WINAPI
propertyset_Add( ISWbemPropertySet
*iface
, BSTR name
, WbemCimtypeEnum type
,
442 VARIANT_BOOL is_array
, LONG flags
, ISWbemProperty
**prop
)
448 static HRESULT WINAPI
propertyset_Remove( ISWbemPropertySet
*iface
, BSTR name
, LONG flags
)
454 static const ISWbemPropertySetVtbl propertyset_vtbl
=
456 propertyset_QueryInterface
,
459 propertyset_GetTypeInfoCount
,
460 propertyset_GetTypeInfo
,
461 propertyset_GetIDsOfNames
,
463 propertyset_get__NewEnum
,
465 propertyset_get_Count
,
470 static HRESULT
SWbemPropertySet_create( IWbemClassObject
*wbem_object
, ISWbemPropertySet
**obj
)
472 struct propertyset
*propertyset
;
474 TRACE( "%p, %p\n", obj
, wbem_object
);
476 if (!(propertyset
= heap_alloc( sizeof(*propertyset
) ))) return E_OUTOFMEMORY
;
477 propertyset
->ISWbemPropertySet_iface
.lpVtbl
= &propertyset_vtbl
;
478 propertyset
->refs
= 1;
479 propertyset
->object
= wbem_object
;
480 IWbemClassObject_AddRef( propertyset
->object
);
481 *obj
= &propertyset
->ISWbemPropertySet_iface
;
483 TRACE( "returning iface %p\n", *obj
);
487 #define DISPID_BASE 0x1800000
497 ISWbemObject ISWbemObject_iface
;
499 IWbemClassObject
*object
;
500 struct member
*members
;
505 static inline struct object
*impl_from_ISWbemObject(
506 ISWbemObject
*iface
)
508 return CONTAINING_RECORD( iface
, struct object
, ISWbemObject_iface
);
511 static ULONG WINAPI
object_AddRef(
512 ISWbemObject
*iface
)
514 struct object
*object
= impl_from_ISWbemObject( iface
);
515 return InterlockedIncrement( &object
->refs
);
518 static ULONG WINAPI
object_Release(
519 ISWbemObject
*iface
)
521 struct object
*object
= impl_from_ISWbemObject( iface
);
522 LONG refs
= InterlockedDecrement( &object
->refs
);
527 TRACE( "destroying %p\n", object
);
528 IWbemClassObject_Release( object
->object
);
529 for (i
= 0; i
< object
->nb_members
; i
++) SysFreeString( object
->members
[i
].name
);
530 heap_free( object
->members
);
536 static HRESULT WINAPI
object_QueryInterface(
541 struct object
*object
= impl_from_ISWbemObject( iface
);
543 TRACE( "%p %s %p\n", object
, debugstr_guid(riid
), ppvObject
);
545 if (IsEqualGUID( riid
, &IID_ISWbemObject
) ||
546 IsEqualGUID( riid
, &IID_IDispatch
) ||
547 IsEqualGUID( riid
, &IID_IUnknown
))
553 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
554 return E_NOINTERFACE
;
556 ISWbemObject_AddRef( iface
);
560 static HRESULT WINAPI
object_GetTypeInfoCount(
564 struct object
*object
= impl_from_ISWbemObject( iface
);
566 TRACE( "%p, %p\n", object
, count
);
571 static HRESULT WINAPI
object_GetTypeInfo(
577 struct object
*object
= impl_from_ISWbemObject( iface
);
578 FIXME( "%p, %u, %u, %p\n", object
, index
, lcid
, info
);
582 static HRESULT
init_members( struct object
*object
)
588 if (object
->members
) return S_OK
;
590 hr
= IWbemClassObject_GetNames( object
->object
, NULL
, 0, NULL
, &sa
);
591 if (FAILED( hr
)) return hr
;
592 hr
= SafeArrayGetUBound( sa
, 1, &bound
);
595 SafeArrayDestroy( sa
);
598 if (!(object
->members
= heap_alloc( sizeof(struct member
) * (bound
+ 1) )))
600 SafeArrayDestroy( sa
);
601 return E_OUTOFMEMORY
;
603 for (i
= 0; i
<= bound
; i
++)
605 hr
= SafeArrayGetElement( sa
, &i
, &object
->members
[i
].name
);
608 for (i
--; i
>= 0; i
--) SysFreeString( object
->members
[i
].name
);
609 SafeArrayDestroy( sa
);
610 heap_free( object
->members
);
611 object
->members
= NULL
;
612 return E_OUTOFMEMORY
;
614 object
->members
[i
].dispid
= 0;
616 object
->nb_members
= bound
+ 1;
617 SafeArrayDestroy( sa
);
621 static DISPID
get_member_dispid( struct object
*object
, const WCHAR
*name
)
624 for (i
= 0; i
< object
->nb_members
; i
++)
626 if (!strcmpiW( object
->members
[i
].name
, name
))
628 if (!object
->members
[i
].dispid
) object
->members
[i
].dispid
= ++object
->last_dispid
;
629 return object
->members
[i
].dispid
;
632 return DISPID_UNKNOWN
;
635 static HRESULT WINAPI
object_GetIDsOfNames(
643 struct object
*object
= impl_from_ISWbemObject( iface
);
648 TRACE( "%p, %s, %p, %u, %u, %p\n", object
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
650 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
652 hr
= init_members( object
);
653 if (FAILED( hr
)) return hr
;
655 hr
= get_typeinfo( ISWbemObject_tid
, &typeinfo
);
658 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
659 ITypeInfo_Release( typeinfo
);
661 if (SUCCEEDED(hr
)) return hr
;
663 for (i
= 0; i
< count
; i
++)
665 if ((dispid
[i
] = get_member_dispid( object
, names
[i
] )) == DISPID_UNKNOWN
) break;
667 if (i
!= count
) return DISP_E_UNKNOWNNAME
;
671 static BSTR
get_member_name( struct object
*object
, DISPID dispid
)
674 for (i
= 0; i
< object
->nb_members
; i
++)
676 if (object
->members
[i
].dispid
== dispid
) return object
->members
[i
].name
;
681 static HRESULT WINAPI
object_Invoke(
689 EXCEPINFO
*excep_info
,
692 struct object
*object
= impl_from_ISWbemObject( iface
);
697 TRACE( "%p, %x, %s, %u, %x, %p, %p, %p, %p\n", object
, member
, debugstr_guid(riid
),
698 lcid
, flags
, params
, result
, excep_info
, arg_err
);
700 if (member
<= DISPID_BASE
)
702 hr
= get_typeinfo( ISWbemObject_tid
, &typeinfo
);
705 hr
= ITypeInfo_Invoke( typeinfo
, &object
->ISWbemObject_iface
, member
, flags
,
706 params
, result
, excep_info
, arg_err
);
707 ITypeInfo_Release( typeinfo
);
712 if (flags
!= (DISPATCH_METHOD
|DISPATCH_PROPERTYGET
))
714 FIXME( "flags %x not supported\n", flags
);
717 if (!(name
= get_member_name( object
, member
)))
718 return DISP_E_MEMBERNOTFOUND
;
720 memset( params
, 0, sizeof(*params
) );
721 return IWbemClassObject_Get( object
->object
, name
, 0, result
, NULL
, NULL
);
724 static HRESULT WINAPI
object_Put_(
727 IDispatch
*objWbemNamedValueSet
,
728 ISWbemObjectPath
**objWbemObjectPath
)
734 static HRESULT WINAPI
object_PutAsync_(
736 IDispatch
*objWbemSink
,
738 IDispatch
*objWbemNamedValueSet
,
739 IDispatch
*objWbemAsyncContext
)
745 static HRESULT WINAPI
object_Delete_(
748 IDispatch
*objWbemNamedValueSet
)
754 static HRESULT WINAPI
object_DeleteAsync_(
756 IDispatch
*objWbemSink
,
758 IDispatch
*objWbemNamedValueSet
,
759 IDispatch
*objWbemAsyncContext
)
765 static HRESULT WINAPI
object_Instances_(
768 IDispatch
*objWbemNamedValueSet
,
769 ISWbemObjectSet
**objWbemObjectSet
)
775 static HRESULT WINAPI
object_InstancesAsync_(
777 IDispatch
*objWbemSink
,
779 IDispatch
*objWbemNamedValueSet
,
780 IDispatch
*objWbemAsyncContext
)
786 static HRESULT WINAPI
object_Subclasses_(
789 IDispatch
*objWbemNamedValueSet
,
790 ISWbemObjectSet
**objWbemObjectSet
)
796 static HRESULT WINAPI
object_SubclassesAsync_(
798 IDispatch
*objWbemSink
,
800 IDispatch
*objWbemNamedValueSet
,
801 IDispatch
*objWbemAsyncContext
)
807 static HRESULT WINAPI
object_Associators_(
813 VARIANT_BOOL bClassesOnly
,
814 VARIANT_BOOL bSchemaOnly
,
815 BSTR strRequiredAssocQualifier
,
816 BSTR strRequiredQualifier
,
818 IDispatch
*objWbemNamedValueSet
,
819 ISWbemObjectSet
**objWbemObjectSet
)
825 static HRESULT WINAPI
object_AssociatorsAsync_(
827 IDispatch
*objWbemSink
,
832 VARIANT_BOOL bClassesOnly
,
833 VARIANT_BOOL bSchemaOnly
,
834 BSTR strRequiredAssocQualifier
,
835 BSTR strRequiredQualifier
,
837 IDispatch
*objWbemNamedValueSet
,
838 IDispatch
*objWbemAsyncContext
)
844 static HRESULT WINAPI
object_References_(
848 VARIANT_BOOL bClassesOnly
,
849 VARIANT_BOOL bSchemaOnly
,
850 BSTR strRequiredQualifier
,
852 IDispatch
*objWbemNamedValueSet
,
853 ISWbemObjectSet
**objWbemObjectSet
)
859 static HRESULT WINAPI
object_ReferencesAsync_(
861 IDispatch
*objWbemSink
,
864 VARIANT_BOOL bClassesOnly
,
865 VARIANT_BOOL bSchemaOnly
,
866 BSTR strRequiredQualifier
,
868 IDispatch
*objWbemNamedValueSet
,
869 IDispatch
*objWbemAsyncContext
)
875 static HRESULT WINAPI
object_ExecMethod_(
878 IDispatch
*objWbemInParameters
,
880 IDispatch
*objWbemNamedValueSet
,
881 ISWbemObject
**objWbemOutParameters
)
887 static HRESULT WINAPI
object_ExecMethodAsync_(
889 IDispatch
*objWbemSink
,
891 IDispatch
*objWbemInParameters
,
893 IDispatch
*objWbemNamedValueSet
,
894 IDispatch
*objWbemAsyncContext
)
900 static HRESULT WINAPI
object_Clone_(
902 ISWbemObject
**objWbemObject
)
908 static HRESULT WINAPI
object_GetObjectText_(
911 BSTR
*strObjectText
)
917 static HRESULT WINAPI
object_SpawnDerivedClass_(
920 ISWbemObject
**objWbemObject
)
926 static HRESULT WINAPI
object_SpawnInstance_(
929 ISWbemObject
**objWbemObject
)
935 static HRESULT WINAPI
object_CompareTo_(
937 IDispatch
*objWbemObject
,
939 VARIANT_BOOL
*bResult
)
945 static HRESULT WINAPI
object_get_Qualifiers_(
947 ISWbemQualifierSet
**objWbemQualifierSet
)
953 static HRESULT WINAPI
object_get_Properties_( ISWbemObject
*iface
, ISWbemPropertySet
**prop_set
)
955 struct object
*object
= impl_from_ISWbemObject( iface
);
957 TRACE( "%p, %p\n", object
, prop_set
);
958 return SWbemPropertySet_create( object
->object
, prop_set
);
961 static HRESULT WINAPI
object_get_Methods_(
963 ISWbemMethodSet
**objWbemMethodSet
)
969 static HRESULT WINAPI
object_get_Derivation_(
971 VARIANT
*strClassNameArray
)
977 static HRESULT WINAPI
object_get_Path_(
979 ISWbemObjectPath
**objWbemObjectPath
)
985 static HRESULT WINAPI
object_get_Security_(
987 ISWbemSecurity
**objWbemSecurity
)
993 static const ISWbemObjectVtbl object_vtbl
=
995 object_QueryInterface
,
998 object_GetTypeInfoCount
,
1000 object_GetIDsOfNames
,
1005 object_DeleteAsync_
,
1007 object_InstancesAsync_
,
1009 object_SubclassesAsync_
,
1010 object_Associators_
,
1011 object_AssociatorsAsync_
,
1013 object_ReferencesAsync_
,
1015 object_ExecMethodAsync_
,
1017 object_GetObjectText_
,
1018 object_SpawnDerivedClass_
,
1019 object_SpawnInstance_
,
1021 object_get_Qualifiers_
,
1022 object_get_Properties_
,
1023 object_get_Methods_
,
1024 object_get_Derivation_
,
1026 object_get_Security_
1029 static HRESULT
SWbemObject_create( IWbemClassObject
*wbem_object
, ISWbemObject
**obj
)
1031 struct object
*object
;
1033 TRACE( "%p, %p\n", obj
, wbem_object
);
1035 if (!(object
= heap_alloc( sizeof(*object
) ))) return E_OUTOFMEMORY
;
1036 object
->ISWbemObject_iface
.lpVtbl
= &object_vtbl
;
1038 object
->object
= wbem_object
;
1039 IWbemClassObject_AddRef( object
->object
);
1040 object
->members
= NULL
;
1041 object
->nb_members
= 0;
1042 object
->last_dispid
= DISPID_BASE
;
1044 *obj
= &object
->ISWbemObject_iface
;
1045 TRACE( "returning iface %p\n", *obj
);
1051 ISWbemObjectSet ISWbemObjectSet_iface
;
1053 IEnumWbemClassObject
*objectenum
;
1057 static inline struct objectset
*impl_from_ISWbemObjectSet(
1058 ISWbemObjectSet
*iface
)
1060 return CONTAINING_RECORD( iface
, struct objectset
, ISWbemObjectSet_iface
);
1063 static ULONG WINAPI
objectset_AddRef(
1064 ISWbemObjectSet
*iface
)
1066 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1067 return InterlockedIncrement( &objectset
->refs
);
1070 static ULONG WINAPI
objectset_Release(
1071 ISWbemObjectSet
*iface
)
1073 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1074 LONG refs
= InterlockedDecrement( &objectset
->refs
);
1077 TRACE( "destroying %p\n", objectset
);
1078 IEnumWbemClassObject_Release( objectset
->objectenum
);
1079 heap_free( objectset
);
1084 static HRESULT WINAPI
objectset_QueryInterface(
1085 ISWbemObjectSet
*iface
,
1089 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1091 TRACE( "%p %s %p\n", objectset
, debugstr_guid(riid
), ppvObject
);
1093 if (IsEqualGUID( riid
, &IID_ISWbemObjectSet
) ||
1094 IsEqualGUID( riid
, &IID_IDispatch
) ||
1095 IsEqualGUID( riid
, &IID_IUnknown
))
1101 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
1102 return E_NOINTERFACE
;
1104 ISWbemObjectSet_AddRef( iface
);
1108 static HRESULT WINAPI
objectset_GetTypeInfoCount(
1109 ISWbemObjectSet
*iface
,
1112 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1113 TRACE( "%p, %p\n", objectset
, count
);
1118 static HRESULT WINAPI
objectset_GetTypeInfo(
1119 ISWbemObjectSet
*iface
,
1124 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1125 TRACE( "%p, %u, %u, %p\n", objectset
, index
, lcid
, info
);
1127 return get_typeinfo( ISWbemObjectSet_tid
, info
);
1130 static HRESULT WINAPI
objectset_GetIDsOfNames(
1131 ISWbemObjectSet
*iface
,
1138 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1139 ITypeInfo
*typeinfo
;
1142 TRACE( "%p, %s, %p, %u, %u, %p\n", objectset
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
1144 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
1146 hr
= get_typeinfo( ISWbemObjectSet_tid
, &typeinfo
);
1149 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
1150 ITypeInfo_Release( typeinfo
);
1155 static HRESULT WINAPI
objectset_Invoke(
1156 ISWbemObjectSet
*iface
,
1163 EXCEPINFO
*excep_info
,
1166 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1167 ITypeInfo
*typeinfo
;
1170 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", objectset
, member
, debugstr_guid(riid
),
1171 lcid
, flags
, params
, result
, excep_info
, arg_err
);
1173 hr
= get_typeinfo( ISWbemObjectSet_tid
, &typeinfo
);
1176 hr
= ITypeInfo_Invoke( typeinfo
, &objectset
->ISWbemObjectSet_iface
, member
, flags
,
1177 params
, result
, excep_info
, arg_err
);
1178 ITypeInfo_Release( typeinfo
);
1183 static HRESULT WINAPI
objectset_get__NewEnum(
1184 ISWbemObjectSet
*iface
,
1187 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1188 IEnumWbemClassObject
*objectenum
;
1191 TRACE( "%p, %p\n", objectset
, pUnk
);
1193 hr
= IEnumWbemClassObject_Clone( objectset
->objectenum
, &objectenum
);
1194 if (FAILED( hr
)) return hr
;
1196 hr
= EnumVARIANT_create( objectenum
, (IEnumVARIANT
**)pUnk
);
1197 IEnumWbemClassObject_Release( objectenum
);
1201 static HRESULT WINAPI
objectset_Item(
1202 ISWbemObjectSet
*iface
,
1205 ISWbemObject
**objWbemObject
)
1211 static HRESULT WINAPI
objectset_get_Count(
1212 ISWbemObjectSet
*iface
,
1215 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1217 TRACE( "%p, %p\n", objectset
, iCount
);
1219 *iCount
= objectset
->count
;
1223 static HRESULT WINAPI
objectset_get_Security_(
1224 ISWbemObjectSet
*iface
,
1225 ISWbemSecurity
**objWbemSecurity
)
1231 static HRESULT WINAPI
objectset_ItemIndex(
1232 ISWbemObjectSet
*iface
,
1234 ISWbemObject
**objWbemObject
)
1236 struct objectset
*objectset
= impl_from_ISWbemObjectSet( iface
);
1239 IEnumVARIANT
*enum_var
;
1242 TRACE( "%p, %d, %p\n", objectset
, lIndex
, objWbemObject
);
1244 *objWbemObject
= NULL
;
1245 hr
= ISWbemObjectSet_get_Count( iface
, &count
);
1246 if (FAILED(hr
)) return hr
;
1248 if (lIndex
>= count
) return WBEM_E_NOT_FOUND
;
1250 hr
= ISWbemObjectSet_get__NewEnum( iface
, (IUnknown
**)&enum_var
);
1251 if (FAILED(hr
)) return hr
;
1253 IEnumVARIANT_Reset( enum_var
);
1254 hr
= IEnumVARIANT_Skip( enum_var
, lIndex
);
1256 hr
= IEnumVARIANT_Next( enum_var
, 1, &var
, NULL
);
1257 IEnumVARIANT_Release( enum_var
);
1261 if (V_VT( &var
) == VT_DISPATCH
)
1262 hr
= IDispatch_QueryInterface( V_DISPATCH( &var
), &IID_ISWbemObject
, (void **)objWbemObject
);
1264 hr
= WBEM_E_NOT_FOUND
;
1265 VariantClear( &var
);
1271 static const ISWbemObjectSetVtbl objectset_vtbl
=
1273 objectset_QueryInterface
,
1276 objectset_GetTypeInfoCount
,
1277 objectset_GetTypeInfo
,
1278 objectset_GetIDsOfNames
,
1280 objectset_get__NewEnum
,
1282 objectset_get_Count
,
1283 objectset_get_Security_
,
1287 static LONG
get_object_count( IEnumWbemClassObject
*iter
)
1290 while (IEnumWbemClassObject_Skip( iter
, WBEM_INFINITE
, 1 ) == S_OK
) count
++;
1291 IEnumWbemClassObject_Reset( iter
);
1295 static HRESULT
SWbemObjectSet_create( IEnumWbemClassObject
*wbem_objectenum
, ISWbemObjectSet
**obj
)
1297 struct objectset
*objectset
;
1299 TRACE( "%p, %p\n", obj
, wbem_objectenum
);
1301 if (!(objectset
= heap_alloc( sizeof(*objectset
) ))) return E_OUTOFMEMORY
;
1302 objectset
->ISWbemObjectSet_iface
.lpVtbl
= &objectset_vtbl
;
1303 objectset
->refs
= 1;
1304 objectset
->objectenum
= wbem_objectenum
;
1305 IEnumWbemClassObject_AddRef( objectset
->objectenum
);
1306 objectset
->count
= get_object_count( objectset
->objectenum
);
1308 *obj
= &objectset
->ISWbemObjectSet_iface
;
1309 TRACE( "returning iface %p\n", *obj
);
1315 IEnumVARIANT IEnumVARIANT_iface
;
1317 IEnumWbemClassObject
*objectenum
;
1320 static inline struct enumvar
*impl_from_IEnumVARIANT(
1321 IEnumVARIANT
*iface
)
1323 return CONTAINING_RECORD( iface
, struct enumvar
, IEnumVARIANT_iface
);
1326 static ULONG WINAPI
enumvar_AddRef(
1327 IEnumVARIANT
*iface
)
1329 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1330 return InterlockedIncrement( &enumvar
->refs
);
1333 static ULONG WINAPI
enumvar_Release(
1334 IEnumVARIANT
*iface
)
1336 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1337 LONG refs
= InterlockedDecrement( &enumvar
->refs
);
1340 TRACE( "destroying %p\n", enumvar
);
1341 IEnumWbemClassObject_Release( enumvar
->objectenum
);
1342 heap_free( enumvar
);
1347 static HRESULT WINAPI
enumvar_QueryInterface(
1348 IEnumVARIANT
*iface
,
1352 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1354 TRACE( "%p %s %p\n", enumvar
, debugstr_guid(riid
), ppvObject
);
1356 if (IsEqualGUID( riid
, &IID_IEnumVARIANT
) ||
1357 IsEqualGUID( riid
, &IID_IUnknown
))
1363 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
1364 return E_NOINTERFACE
;
1366 IEnumVARIANT_AddRef( iface
);
1370 static HRESULT WINAPI
enumvar_Next( IEnumVARIANT
*iface
, ULONG celt
, VARIANT
*var
, ULONG
*fetched
)
1372 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1373 IWbemClassObject
*obj
;
1376 TRACE( "%p, %u, %p, %p\n", iface
, celt
, var
, fetched
);
1378 if (celt
) IEnumWbemClassObject_Next( enumvar
->objectenum
, WBEM_INFINITE
, 1, &obj
, &count
);
1384 hr
= SWbemObject_create( obj
, &sobj
);
1385 IWbemClassObject_Release( obj
);
1386 if (FAILED( hr
)) return hr
;
1388 V_VT( var
) = VT_DISPATCH
;
1389 V_DISPATCH( var
) = (IDispatch
*)sobj
;
1391 if (fetched
) *fetched
= count
;
1392 return (count
< celt
) ? S_FALSE
: S_OK
;
1395 static HRESULT WINAPI
enumvar_Skip( IEnumVARIANT
*iface
, ULONG celt
)
1397 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1399 TRACE( "%p, %u\n", iface
, celt
);
1401 return IEnumWbemClassObject_Skip( enumvar
->objectenum
, WBEM_INFINITE
, celt
);
1404 static HRESULT WINAPI
enumvar_Reset( IEnumVARIANT
*iface
)
1406 struct enumvar
*enumvar
= impl_from_IEnumVARIANT( iface
);
1408 TRACE( "%p\n", iface
);
1410 return IEnumWbemClassObject_Reset( enumvar
->objectenum
);
1413 static HRESULT WINAPI
enumvar_Clone( IEnumVARIANT
*iface
, IEnumVARIANT
**penum
)
1415 FIXME( "%p, %p\n", iface
, penum
);
1419 static const struct IEnumVARIANTVtbl enumvar_vtbl
=
1421 enumvar_QueryInterface
,
1430 static HRESULT
EnumVARIANT_create( IEnumWbemClassObject
*objectenum
, IEnumVARIANT
**obj
)
1432 struct enumvar
*enumvar
;
1434 if (!(enumvar
= heap_alloc( sizeof(*enumvar
) ))) return E_OUTOFMEMORY
;
1435 enumvar
->IEnumVARIANT_iface
.lpVtbl
= &enumvar_vtbl
;
1437 enumvar
->objectenum
= objectenum
;
1438 IEnumWbemClassObject_AddRef( enumvar
->objectenum
);
1440 *obj
= &enumvar
->IEnumVARIANT_iface
;
1441 TRACE( "returning iface %p\n", *obj
);
1447 ISWbemServices ISWbemServices_iface
;
1449 IWbemServices
*services
;
1452 static inline struct services
*impl_from_ISWbemServices(
1453 ISWbemServices
*iface
)
1455 return CONTAINING_RECORD( iface
, struct services
, ISWbemServices_iface
);
1458 static ULONG WINAPI
services_AddRef(
1459 ISWbemServices
*iface
)
1461 struct services
*services
= impl_from_ISWbemServices( iface
);
1462 return InterlockedIncrement( &services
->refs
);
1465 static ULONG WINAPI
services_Release(
1466 ISWbemServices
*iface
)
1468 struct services
*services
= impl_from_ISWbemServices( iface
);
1469 LONG refs
= InterlockedDecrement( &services
->refs
);
1472 TRACE( "destroying %p\n", services
);
1473 IWbemServices_Release( services
->services
);
1474 heap_free( services
);
1479 static HRESULT WINAPI
services_QueryInterface(
1480 ISWbemServices
*iface
,
1484 struct services
*services
= impl_from_ISWbemServices( iface
);
1486 TRACE( "%p %s %p\n", services
, debugstr_guid(riid
), ppvObject
);
1488 if (IsEqualGUID( riid
, &IID_ISWbemServices
) ||
1489 IsEqualGUID( riid
, &IID_IDispatch
) ||
1490 IsEqualGUID( riid
, &IID_IUnknown
))
1496 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
1497 return E_NOINTERFACE
;
1499 ISWbemServices_AddRef( iface
);
1503 static HRESULT WINAPI
services_GetTypeInfoCount(
1504 ISWbemServices
*iface
,
1507 struct services
*services
= impl_from_ISWbemServices( iface
);
1508 TRACE( "%p, %p\n", services
, count
);
1514 static HRESULT WINAPI
services_GetTypeInfo(
1515 ISWbemServices
*iface
,
1520 struct services
*services
= impl_from_ISWbemServices( iface
);
1521 TRACE( "%p, %u, %u, %p\n", services
, index
, lcid
, info
);
1523 return get_typeinfo( ISWbemServices_tid
, info
);
1526 static HRESULT WINAPI
services_GetIDsOfNames(
1527 ISWbemServices
*iface
,
1534 struct services
*services
= impl_from_ISWbemServices( iface
);
1535 ITypeInfo
*typeinfo
;
1538 TRACE( "%p, %s, %p, %u, %u, %p\n", services
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
1540 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
1542 hr
= get_typeinfo( ISWbemServices_tid
, &typeinfo
);
1545 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
1546 ITypeInfo_Release( typeinfo
);
1551 static HRESULT WINAPI
services_Invoke(
1552 ISWbemServices
*iface
,
1559 EXCEPINFO
*excep_info
,
1562 struct services
*services
= impl_from_ISWbemServices( iface
);
1563 ITypeInfo
*typeinfo
;
1566 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", services
, member
, debugstr_guid(riid
),
1567 lcid
, flags
, params
, result
, excep_info
, arg_err
);
1569 hr
= get_typeinfo( ISWbemServices_tid
, &typeinfo
);
1572 hr
= ITypeInfo_Invoke( typeinfo
, &services
->ISWbemServices_iface
, member
, flags
,
1573 params
, result
, excep_info
, arg_err
);
1574 ITypeInfo_Release( typeinfo
);
1579 static HRESULT WINAPI
services_Get(
1580 ISWbemServices
*iface
,
1583 IDispatch
*objWbemNamedValueSet
,
1584 ISWbemObject
**objWbemObject
)
1586 struct services
*services
= impl_from_ISWbemServices( iface
);
1587 IWbemClassObject
*obj
;
1590 TRACE( "%p, %s, %d, %p, %p\n", iface
, debugstr_w(strObjectPath
), iFlags
, objWbemNamedValueSet
,
1593 if (objWbemNamedValueSet
) FIXME( "ignoring context\n" );
1595 hr
= IWbemServices_GetObject( services
->services
, strObjectPath
, iFlags
, NULL
, &obj
, NULL
);
1596 if (hr
!= S_OK
) return hr
;
1598 hr
= SWbemObject_create( obj
, objWbemObject
);
1599 IWbemClassObject_Release( obj
);
1603 static HRESULT WINAPI
services_GetAsync(
1604 ISWbemServices
*iface
,
1605 IDispatch
*objWbemSink
,
1608 IDispatch
*objWbemNamedValueSet
,
1609 IDispatch
*objWbemAsyncContext
)
1615 static HRESULT WINAPI
services_Delete(
1616 ISWbemServices
*iface
,
1619 IDispatch
*objWbemNamedValueSet
)
1625 static HRESULT WINAPI
services_DeleteAsync(
1626 ISWbemServices
* This
,
1627 IDispatch
*objWbemSink
,
1630 IDispatch
*objWbemNamedValueSet
,
1631 IDispatch
*objWbemAsyncContext
)
1637 static BSTR
build_query_string( const WCHAR
*class )
1639 static const WCHAR selectW
[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',0};
1640 UINT len
= strlenW(class) + sizeof(selectW
) / sizeof(selectW
[0]);
1643 if (!(ret
= SysAllocStringLen( NULL
, len
))) return NULL
;
1644 strcpyW( ret
, selectW
);
1645 strcatW( ret
, class );
1649 static HRESULT WINAPI
services_InstancesOf(
1650 ISWbemServices
*iface
,
1653 IDispatch
*objWbemNamedValueSet
,
1654 ISWbemObjectSet
**objWbemObjectSet
)
1656 static const WCHAR wqlW
[] = {'W','Q','L',0};
1657 BSTR query
, wql
= SysAllocString( wqlW
);
1660 TRACE( "%p, %s, %x, %p, %p\n", iface
, debugstr_w(strClass
), iFlags
, objWbemNamedValueSet
,
1663 if (!(query
= build_query_string( strClass
)))
1665 SysFreeString( wql
);
1666 return E_OUTOFMEMORY
;
1668 hr
= ISWbemServices_ExecQuery( iface
, query
, wql
, iFlags
, objWbemNamedValueSet
, objWbemObjectSet
);
1669 SysFreeString( wql
);
1670 SysFreeString( query
);
1674 static HRESULT WINAPI
services_InstancesOfAsync(
1675 ISWbemServices
*iface
,
1676 IDispatch
*objWbemSink
,
1679 IDispatch
*objWbemNamedValueSet
,
1680 IDispatch
*objWbemAsyncContext
)
1686 static HRESULT WINAPI
services_SubclassesOf(
1687 ISWbemServices
*iface
,
1690 IDispatch
*objWbemNamedValueSet
,
1691 ISWbemObjectSet
**objWbemObjectSet
)
1697 static HRESULT WINAPI
services_SubclassesOfAsync(
1698 ISWbemServices
*iface
,
1699 IDispatch
*objWbemSink
,
1702 IDispatch
*objWbemNamedValueSet
,
1703 IDispatch
*objWbemAsyncContext
)
1709 static HRESULT WINAPI
services_ExecQuery(
1710 ISWbemServices
*iface
,
1712 BSTR strQueryLanguage
,
1714 IDispatch
*objWbemNamedValueSet
,
1715 ISWbemObjectSet
**objWbemObjectSet
)
1717 struct services
*services
= impl_from_ISWbemServices( iface
);
1718 IEnumWbemClassObject
*iter
;
1721 TRACE( "%p, %s, %s, %x, %p, %p\n", iface
, debugstr_w(strQuery
), debugstr_w(strQueryLanguage
),
1722 iFlags
, objWbemNamedValueSet
, objWbemObjectSet
);
1724 if (objWbemNamedValueSet
) FIXME( "ignoring context\n" );
1726 hr
= IWbemServices_ExecQuery( services
->services
, strQueryLanguage
, strQuery
, iFlags
, NULL
, &iter
);
1727 if (hr
!= S_OK
) return hr
;
1729 hr
= SWbemObjectSet_create( iter
, objWbemObjectSet
);
1730 IEnumWbemClassObject_Release( iter
);
1734 static HRESULT WINAPI
services_ExecQueryAsync(
1735 ISWbemServices
*iface
,
1736 IDispatch
*objWbemSink
,
1738 BSTR strQueryLanguage
,
1740 IDispatch
*objWbemNamedValueSet
,
1741 IDispatch
*objWbemAsyncContext
)
1747 static HRESULT WINAPI
services_AssociatorsOf(
1748 ISWbemServices
*iface
,
1751 BSTR strResultClass
,
1754 VARIANT_BOOL bClassesOnly
,
1755 VARIANT_BOOL bSchemaOnly
,
1756 BSTR strRequiredAssocQualifier
,
1757 BSTR strRequiredQualifier
,
1759 IDispatch
*objWbemNamedValueSet
,
1760 ISWbemObjectSet
**objWbemObjectSet
)
1766 static HRESULT WINAPI
services_AssociatorsOfAsync(
1767 ISWbemServices
*iface
,
1768 IDispatch
*objWbemSink
,
1771 BSTR strResultClass
,
1774 VARIANT_BOOL bClassesOnly
,
1775 VARIANT_BOOL bSchemaOnly
,
1776 BSTR strRequiredAssocQualifier
,
1777 BSTR strRequiredQualifier
,
1779 IDispatch
*objWbemNamedValueSet
,
1780 IDispatch
*objWbemAsyncContext
)
1786 static HRESULT WINAPI
services_ReferencesTo(
1787 ISWbemServices
*iface
,
1789 BSTR strResultClass
,
1791 VARIANT_BOOL bClassesOnly
,
1792 VARIANT_BOOL bSchemaOnly
,
1793 BSTR strRequiredQualifier
,
1795 IDispatch
*objWbemNamedValueSet
,
1796 ISWbemObjectSet
**objWbemObjectSet
)
1802 static HRESULT WINAPI
services_ReferencesToAsync(
1803 ISWbemServices
*iface
,
1804 IDispatch
*objWbemSink
,
1806 BSTR strResultClass
,
1808 VARIANT_BOOL bClassesOnly
,
1809 VARIANT_BOOL bSchemaOnly
,
1810 BSTR strRequiredQualifier
,
1812 IDispatch
*objWbemNamedValueSet
,
1813 IDispatch
*objWbemAsyncContext
)
1819 static HRESULT WINAPI
services_ExecNotificationQuery(
1820 ISWbemServices
*iface
,
1822 BSTR strQueryLanguage
,
1824 IDispatch
*objWbemNamedValueSet
,
1825 ISWbemEventSource
**objWbemEventSource
)
1831 static HRESULT WINAPI
services_ExecNotificationQueryAsync(
1832 ISWbemServices
*iface
,
1833 IDispatch
*objWbemSink
,
1835 BSTR strQueryLanguage
,
1837 IDispatch
*objWbemNamedValueSet
,
1838 IDispatch
*objWbemAsyncContext
)
1844 static HRESULT WINAPI
services_ExecMethod(
1845 ISWbemServices
*iface
,
1848 IDispatch
*objWbemInParameters
,
1850 IDispatch
*objWbemNamedValueSet
,
1851 ISWbemObject
**objWbemOutParameters
)
1857 static HRESULT WINAPI
services_ExecMethodAsync(
1858 ISWbemServices
*iface
,
1859 IDispatch
*objWbemSink
,
1862 IDispatch
*objWbemInParameters
,
1864 IDispatch
*objWbemNamedValueSet
,
1865 IDispatch
*objWbemAsyncContext
)
1871 static HRESULT WINAPI
services_get_Security_(
1872 ISWbemServices
*iface
,
1873 ISWbemSecurity
**objWbemSecurity
)
1879 static const ISWbemServicesVtbl services_vtbl
=
1881 services_QueryInterface
,
1884 services_GetTypeInfoCount
,
1885 services_GetTypeInfo
,
1886 services_GetIDsOfNames
,
1891 services_DeleteAsync
,
1892 services_InstancesOf
,
1893 services_InstancesOfAsync
,
1894 services_SubclassesOf
,
1895 services_SubclassesOfAsync
,
1897 services_ExecQueryAsync
,
1898 services_AssociatorsOf
,
1899 services_AssociatorsOfAsync
,
1900 services_ReferencesTo
,
1901 services_ReferencesToAsync
,
1902 services_ExecNotificationQuery
,
1903 services_ExecNotificationQueryAsync
,
1904 services_ExecMethod
,
1905 services_ExecMethodAsync
,
1906 services_get_Security_
1909 static HRESULT
SWbemServices_create( IWbemServices
*wbem_services
, ISWbemServices
**obj
)
1911 struct services
*services
;
1913 TRACE( "%p, %p\n", obj
, wbem_services
);
1915 if (!(services
= heap_alloc( sizeof(*services
) ))) return E_OUTOFMEMORY
;
1916 services
->ISWbemServices_iface
.lpVtbl
= &services_vtbl
;
1918 services
->services
= wbem_services
;
1919 IWbemServices_AddRef( services
->services
);
1921 *obj
= &services
->ISWbemServices_iface
;
1922 TRACE( "returning iface %p\n", *obj
);
1928 ISWbemLocator ISWbemLocator_iface
;
1930 IWbemLocator
*locator
;
1933 static inline struct locator
*impl_from_ISWbemLocator( ISWbemLocator
*iface
)
1935 return CONTAINING_RECORD( iface
, struct locator
, ISWbemLocator_iface
);
1938 static ULONG WINAPI
locator_AddRef(
1939 ISWbemLocator
*iface
)
1941 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
1942 return InterlockedIncrement( &locator
->refs
);
1945 static ULONG WINAPI
locator_Release(
1946 ISWbemLocator
*iface
)
1948 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
1949 LONG refs
= InterlockedDecrement( &locator
->refs
);
1952 TRACE( "destroying %p\n", locator
);
1953 if (locator
->locator
)
1954 IWbemLocator_Release( locator
->locator
);
1955 heap_free( locator
);
1960 static HRESULT WINAPI
locator_QueryInterface(
1961 ISWbemLocator
*iface
,
1965 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
1967 TRACE( "%p, %s, %p\n", locator
, debugstr_guid( riid
), ppvObject
);
1969 if (IsEqualGUID( riid
, &IID_ISWbemLocator
) ||
1970 IsEqualGUID( riid
, &IID_IDispatch
) ||
1971 IsEqualGUID( riid
, &IID_IUnknown
))
1977 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
1978 return E_NOINTERFACE
;
1980 ISWbemLocator_AddRef( iface
);
1984 static HRESULT WINAPI
locator_GetTypeInfoCount(
1985 ISWbemLocator
*iface
,
1988 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
1990 TRACE( "%p, %p\n", locator
, count
);
1995 static HRESULT WINAPI
locator_GetTypeInfo(
1996 ISWbemLocator
*iface
,
2001 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2002 TRACE( "%p, %u, %u, %p\n", locator
, index
, lcid
, info
);
2004 return get_typeinfo( ISWbemLocator_tid
, info
);
2007 static HRESULT WINAPI
locator_GetIDsOfNames(
2008 ISWbemLocator
*iface
,
2015 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2016 ITypeInfo
*typeinfo
;
2019 TRACE( "%p, %s, %p, %u, %u, %p\n", locator
, debugstr_guid(riid
), names
, count
, lcid
, dispid
);
2021 if (!names
|| !count
|| !dispid
) return E_INVALIDARG
;
2023 hr
= get_typeinfo( ISWbemLocator_tid
, &typeinfo
);
2026 hr
= ITypeInfo_GetIDsOfNames( typeinfo
, names
, count
, dispid
);
2027 ITypeInfo_Release( typeinfo
);
2032 static HRESULT WINAPI
locator_Invoke(
2033 ISWbemLocator
*iface
,
2040 EXCEPINFO
*excep_info
,
2043 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2044 ITypeInfo
*typeinfo
;
2047 TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", locator
, member
, debugstr_guid(riid
),
2048 lcid
, flags
, params
, result
, excep_info
, arg_err
);
2050 hr
= get_typeinfo( ISWbemLocator_tid
, &typeinfo
);
2053 hr
= ITypeInfo_Invoke( typeinfo
, &locator
->ISWbemLocator_iface
, member
, flags
,
2054 params
, result
, excep_info
, arg_err
);
2055 ITypeInfo_Release( typeinfo
);
2060 static BSTR
build_resource_string( BSTR server
, BSTR
namespace )
2062 static const WCHAR defaultW
[] = {'r','o','o','t','\\','d','e','f','a','u','l','t',0};
2063 ULONG len
, len_server
= 0, len_namespace
= 0;
2066 if (server
&& *server
) len_server
= strlenW( server
);
2067 else len_server
= 1;
2068 if (namespace && *namespace) len_namespace
= strlenW( namespace );
2069 else len_namespace
= sizeof(defaultW
) / sizeof(defaultW
[0]) - 1;
2071 if (!(ret
= SysAllocStringLen( NULL
, 2 + len_server
+ 1 + len_namespace
))) return NULL
;
2073 ret
[0] = ret
[1] = '\\';
2074 if (server
&& *server
) strcpyW( ret
+ 2, server
);
2077 len
= len_server
+ 2;
2080 if (namespace && *namespace) strcpyW( ret
+ len
, namespace );
2081 else strcpyW( ret
+ len
, defaultW
);
2085 static HRESULT WINAPI
locator_ConnectServer(
2086 ISWbemLocator
*iface
,
2093 LONG iSecurityFlags
,
2094 IDispatch
*objWbemNamedValueSet
,
2095 ISWbemServices
**objWbemServices
)
2097 struct locator
*locator
= impl_from_ISWbemLocator( iface
);
2098 IWbemServices
*services
;
2102 TRACE( "%p, %s, %s, %s, %p, %s, %s, 0x%08x, %p, %p\n", iface
, debugstr_w(strServer
),
2103 debugstr_w(strNamespace
), debugstr_w(strUser
), strPassword
, debugstr_w(strLocale
),
2104 debugstr_w(strAuthority
), iSecurityFlags
, objWbemNamedValueSet
, objWbemServices
);
2106 if (objWbemNamedValueSet
) FIXME( "context not supported\n" );
2108 if (!locator
->locator
)
2110 hr
= CoCreateInstance( &CLSID_WbemLocator
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IWbemLocator
,
2111 (void **)&locator
->locator
);
2112 if (hr
!= S_OK
) return hr
;
2115 if (!(resource
= build_resource_string( strServer
, strNamespace
))) return E_OUTOFMEMORY
;
2116 hr
= IWbemLocator_ConnectServer( locator
->locator
, resource
, strUser
, strPassword
, strLocale
,
2117 iSecurityFlags
, strAuthority
, NULL
, &services
);
2118 SysFreeString( resource
);
2119 if (hr
!= S_OK
) return hr
;
2121 hr
= SWbemServices_create( services
, objWbemServices
);
2122 IWbemServices_Release( services
);
2126 static HRESULT WINAPI
locator_get_Security_(
2127 ISWbemLocator
*iface
,
2128 ISWbemSecurity
**objWbemSecurity
)
2130 FIXME( "%p, %p\n", iface
, objWbemSecurity
);
2134 static const ISWbemLocatorVtbl locator_vtbl
=
2136 locator_QueryInterface
,
2139 locator_GetTypeInfoCount
,
2140 locator_GetTypeInfo
,
2141 locator_GetIDsOfNames
,
2143 locator_ConnectServer
,
2144 locator_get_Security_
2147 HRESULT
SWbemLocator_create( void **obj
)
2149 struct locator
*locator
;
2151 TRACE( "%p\n", obj
);
2153 if (!(locator
= heap_alloc( sizeof(*locator
) ))) return E_OUTOFMEMORY
;
2154 locator
->ISWbemLocator_iface
.lpVtbl
= &locator_vtbl
;
2156 locator
->locator
= NULL
;
2158 *obj
= &locator
->ISWbemLocator_iface
;
2159 TRACE( "returning iface %p\n", *obj
);