2 * Copyright 2012 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
19 #define WIN32_NO_STATUS
21 #define COM_NO_WINDOWS_H
33 #include "wine/debug.h"
34 #include "wbemprox_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox
);
38 struct enum_class_object
40 IEnumWbemClassObject IEnumWbemClassObject_iface
;
46 static inline struct enum_class_object
*impl_from_IEnumWbemClassObject(
47 IEnumWbemClassObject
*iface
)
49 return CONTAINING_RECORD(iface
, struct enum_class_object
, IEnumWbemClassObject_iface
);
52 static ULONG WINAPI
enum_class_object_AddRef(
53 IEnumWbemClassObject
*iface
)
55 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
56 return InterlockedIncrement( &ec
->refs
);
59 static ULONG WINAPI
enum_class_object_Release(
60 IEnumWbemClassObject
*iface
)
62 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
63 LONG refs
= InterlockedDecrement( &ec
->refs
);
66 TRACE("destroying %p\n", ec
);
67 release_query( ec
->query
);
73 static HRESULT WINAPI
enum_class_object_QueryInterface(
74 IEnumWbemClassObject
*iface
,
78 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
80 TRACE("%p, %s, %p\n", ec
, debugstr_guid( riid
), ppvObject
);
82 if ( IsEqualGUID( riid
, &IID_IEnumWbemClassObject
) ||
83 IsEqualGUID( riid
, &IID_IUnknown
) )
87 else if ( IsEqualGUID( riid
, &IID_IClientSecurity
) )
89 *ppvObject
= &client_security
;
94 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
97 IEnumWbemClassObject_AddRef( iface
);
101 static HRESULT WINAPI
enum_class_object_Reset(
102 IEnumWbemClassObject
*iface
)
104 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
106 TRACE("%p\n", iface
);
109 return WBEM_S_NO_ERROR
;
112 static HRESULT WINAPI
enum_class_object_Next(
113 IEnumWbemClassObject
*iface
,
116 IWbemClassObject
**apObjects
,
119 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
120 struct view
*view
= ec
->query
->view
;
123 TRACE("%p, %d, %u, %p, %p\n", iface
, lTimeout
, uCount
, apObjects
, puReturned
);
125 if (!uCount
) return WBEM_S_FALSE
;
126 if (!apObjects
|| !puReturned
) return WBEM_E_INVALID_PARAMETER
;
127 if (lTimeout
!= WBEM_INFINITE
) FIXME("timeout not supported\n");
130 if (ec
->index
>= view
->count
) return WBEM_S_FALSE
;
132 hr
= create_class_object( view
->table
->name
, iface
, ec
->index
, NULL
, apObjects
);
133 if (hr
!= S_OK
) return hr
;
137 if (ec
->index
== view
->count
) return WBEM_S_FALSE
;
138 if (uCount
> 1) return WBEM_S_TIMEDOUT
;
139 return WBEM_S_NO_ERROR
;
142 static HRESULT WINAPI
enum_class_object_NextAsync(
143 IEnumWbemClassObject
*iface
,
145 IWbemObjectSink
*pSink
)
147 FIXME("%p, %u, %p\n", iface
, uCount
, pSink
);
151 static HRESULT WINAPI
enum_class_object_Clone(
152 IEnumWbemClassObject
*iface
,
153 IEnumWbemClassObject
**ppEnum
)
155 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
157 TRACE("%p, %p\n", iface
, ppEnum
);
159 return EnumWbemClassObject_create( NULL
, ec
->query
, (void **)ppEnum
);
162 static HRESULT WINAPI
enum_class_object_Skip(
163 IEnumWbemClassObject
*iface
,
167 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
168 struct view
*view
= ec
->query
->view
;
170 TRACE("%p, %d, %u\n", iface
, lTimeout
, nCount
);
172 if (lTimeout
!= WBEM_INFINITE
) FIXME("timeout not supported\n");
174 if (!view
->count
) return WBEM_S_FALSE
;
176 if (nCount
> view
->count
- ec
->index
)
178 ec
->index
= view
->count
- 1;
182 return WBEM_S_NO_ERROR
;
185 static const IEnumWbemClassObjectVtbl enum_class_object_vtbl
=
187 enum_class_object_QueryInterface
,
188 enum_class_object_AddRef
,
189 enum_class_object_Release
,
190 enum_class_object_Reset
,
191 enum_class_object_Next
,
192 enum_class_object_NextAsync
,
193 enum_class_object_Clone
,
194 enum_class_object_Skip
197 HRESULT
EnumWbemClassObject_create(
198 IUnknown
*pUnkOuter
, struct query
*query
, LPVOID
*ppObj
)
200 struct enum_class_object
*ec
;
202 TRACE("%p, %p\n", pUnkOuter
, ppObj
);
204 ec
= heap_alloc( sizeof(*ec
) );
205 if (!ec
) return E_OUTOFMEMORY
;
207 ec
->IEnumWbemClassObject_iface
.lpVtbl
= &enum_class_object_vtbl
;
209 ec
->query
= addref_query( query
);
212 *ppObj
= &ec
->IEnumWbemClassObject_iface
;
214 TRACE("returning iface %p\n", *ppObj
);
218 static struct record
*create_record( struct table
*table
)
221 struct record
*record
;
223 if (!(record
= heap_alloc( sizeof(struct record
) ))) return NULL
;
224 if (!(record
->fields
= heap_alloc( table
->num_cols
* sizeof(struct field
) )))
229 for (i
= 0; i
< table
->num_cols
; i
++)
231 record
->fields
[i
].type
= table
->columns
[i
].type
;
232 record
->fields
[i
].vartype
= table
->columns
[i
].vartype
;
233 record
->fields
[i
].u
.ival
= 0;
235 record
->count
= table
->num_cols
;
236 record
->table
= addref_table( table
);
240 void destroy_array( struct array
*array
, CIMTYPE type
)
245 if (type
== CIM_STRING
|| type
== CIM_DATETIME
)
247 size
= get_type_size( type
);
248 for (i
= 0; i
< array
->count
; i
++) heap_free( *(WCHAR
**)((char *)array
->ptr
+ i
* size
) );
250 heap_free( array
->ptr
);
254 static void destroy_record( struct record
*record
)
259 release_table( record
->table
);
260 for (i
= 0; i
< record
->count
; i
++)
262 if (record
->fields
[i
].type
== CIM_STRING
|| record
->fields
[i
].type
== CIM_DATETIME
)
263 heap_free( record
->fields
[i
].u
.sval
);
264 else if (record
->fields
[i
].type
& CIM_FLAG_ARRAY
)
265 destroy_array( record
->fields
[i
].u
.aval
, record
->fields
[i
].type
& CIM_TYPE_MASK
);
267 heap_free( record
->fields
);
273 IWbemClassObject IWbemClassObject_iface
;
276 IEnumWbemClassObject
*iter
;
280 struct record
*record
; /* uncommitted instance */
283 static inline struct class_object
*impl_from_IWbemClassObject(
284 IWbemClassObject
*iface
)
286 return CONTAINING_RECORD(iface
, struct class_object
, IWbemClassObject_iface
);
289 static ULONG WINAPI
class_object_AddRef(
290 IWbemClassObject
*iface
)
292 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
293 return InterlockedIncrement( &co
->refs
);
296 static ULONG WINAPI
class_object_Release(
297 IWbemClassObject
*iface
)
299 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
300 LONG refs
= InterlockedDecrement( &co
->refs
);
303 TRACE("destroying %p\n", co
);
304 if (co
->iter
) IEnumWbemClassObject_Release( co
->iter
);
305 destroy_record( co
->record
);
306 heap_free( co
->name
);
312 static HRESULT WINAPI
class_object_QueryInterface(
313 IWbemClassObject
*iface
,
317 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
319 TRACE("%p, %s, %p\n", co
, debugstr_guid( riid
), ppvObject
);
321 if ( IsEqualGUID( riid
, &IID_IWbemClassObject
) ||
322 IsEqualGUID( riid
, &IID_IUnknown
) )
326 else if (IsEqualGUID( riid
, &IID_IClientSecurity
))
328 *ppvObject
= &client_security
;
333 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
334 return E_NOINTERFACE
;
336 IWbemClassObject_AddRef( iface
);
340 static HRESULT WINAPI
class_object_GetQualifierSet(
341 IWbemClassObject
*iface
,
342 IWbemQualifierSet
**ppQualSet
)
344 FIXME("%p, %p\n", iface
, ppQualSet
);
348 static HRESULT
record_get_value( const struct record
*record
, UINT index
, VARIANT
*var
, CIMTYPE
*type
)
350 VARTYPE vartype
= record
->fields
[index
].vartype
;
352 if (type
) *type
= record
->fields
[index
].type
;
354 if (record
->fields
[index
].type
& CIM_FLAG_ARRAY
)
356 V_VT( var
) = vartype
? vartype
: to_vartype( record
->fields
[index
].type
& CIM_TYPE_MASK
) | VT_ARRAY
;
357 V_ARRAY( var
) = to_safearray( record
->fields
[index
].u
.aval
, record
->fields
[index
].type
& CIM_TYPE_MASK
);
360 switch (record
->fields
[index
].type
)
364 if (!vartype
) vartype
= VT_BSTR
;
365 V_BSTR( var
) = SysAllocString( record
->fields
[index
].u
.sval
);
368 if (!vartype
) vartype
= VT_I4
;
369 V_I4( var
) = record
->fields
[index
].u
.ival
;
372 if (!vartype
) vartype
= VT_UI4
;
373 V_UI4( var
) = record
->fields
[index
].u
.ival
;
376 FIXME("unhandled type %u\n", record
->fields
[index
].type
);
377 return WBEM_E_INVALID_PARAMETER
;
379 V_VT( var
) = vartype
;
383 static HRESULT WINAPI
class_object_Get(
384 IWbemClassObject
*iface
,
391 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
392 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( co
->iter
);
394 TRACE("%p, %s, %08x, %p, %p, %p\n", iface
, debugstr_w(wszName
), lFlags
, pVal
, pType
, plFlavor
);
401 if ((hr
= get_column_index( co
->record
->table
, wszName
, &index
)) != S_OK
) return hr
;
402 return record_get_value( co
->record
, index
, pVal
, pType
);
404 return get_propval( ec
->query
->view
, co
->index
, wszName
, pVal
, pType
, plFlavor
);
407 static HRESULT
record_set_value( struct record
*record
, UINT index
, VARIANT
*var
)
413 if ((hr
= to_longlong( var
, &val
, &type
)) != S_OK
) return hr
;
414 if (type
!= record
->fields
[index
].type
) return WBEM_E_TYPE_MISMATCH
;
416 if (type
& CIM_FLAG_ARRAY
)
418 record
->fields
[index
].u
.aval
= (struct array
*)(INT_PTR
)val
;
425 record
->fields
[index
].u
.sval
= (WCHAR
*)(INT_PTR
)val
;
431 record
->fields
[index
].u
.ival
= val
;
434 FIXME("unhandled type %u\n", type
);
437 return WBEM_E_INVALID_PARAMETER
;
440 static HRESULT WINAPI
class_object_Put(
441 IWbemClassObject
*iface
,
447 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
448 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( co
->iter
);
450 TRACE("%p, %s, %08x, %p, %u\n", iface
, debugstr_w(wszName
), lFlags
, pVal
, Type
);
457 if ((hr
= get_column_index( co
->record
->table
, wszName
, &index
)) != S_OK
) return hr
;
458 return record_set_value( co
->record
, index
, pVal
);
460 return put_propval( ec
->query
->view
, co
->index
, wszName
, pVal
, Type
);
463 static HRESULT WINAPI
class_object_Delete(
464 IWbemClassObject
*iface
,
467 FIXME("%p, %s\n", iface
, debugstr_w(wszName
));
471 static HRESULT WINAPI
class_object_GetNames(
472 IWbemClassObject
*iface
,
473 LPCWSTR wszQualifierName
,
475 VARIANT
*pQualifierVal
,
478 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
479 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( co
->iter
);
481 TRACE("%p, %s, %08x, %s, %p\n", iface
, debugstr_w(wszQualifierName
), lFlags
,
482 debugstr_variant(pQualifierVal
), pNames
);
484 if (wszQualifierName
|| pQualifierVal
)
486 FIXME("qualifier not supported\n");
489 if (lFlags
!= WBEM_FLAG_ALWAYS
)
491 FIXME("flags %08x not supported\n", lFlags
);
494 return get_properties( ec
->query
->view
, pNames
);
497 static HRESULT WINAPI
class_object_BeginEnumeration(
498 IWbemClassObject
*iface
,
501 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
503 TRACE("%p, %08x\n", iface
, lEnumFlags
);
505 if (lEnumFlags
) FIXME("flags 0x%08x not supported\n", lEnumFlags
);
507 co
->index_property
= 0;
511 static HRESULT WINAPI
class_object_Next(
512 IWbemClassObject
*iface
,
519 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
520 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( co
->iter
);
521 struct view
*view
= ec
->query
->view
;
525 TRACE("%p, %08x, %p, %p, %p, %p\n", iface
, lFlags
, strName
, pVal
, pType
, plFlavor
);
527 if (!(property
= get_property_name( co
->name
, co
->index_property
))) return WBEM_S_NO_MORE_DATA
;
528 if ((hr
= get_propval( view
, co
->index
, property
, pVal
, pType
, plFlavor
) != S_OK
))
530 SysFreeString( property
);
534 co
->index_property
++;
538 static HRESULT WINAPI
class_object_EndEnumeration(
539 IWbemClassObject
*iface
)
541 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
543 TRACE("%p\n", iface
);
545 co
->index_property
= 0;
549 static HRESULT WINAPI
class_object_GetPropertyQualifierSet(
550 IWbemClassObject
*iface
,
552 IWbemQualifierSet
**ppQualSet
)
554 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
556 TRACE("%p, %s, %p\n", iface
, debugstr_w(wszProperty
), ppQualSet
);
558 return WbemQualifierSet_create( NULL
, co
->name
, wszProperty
, (void **)ppQualSet
);
561 static HRESULT WINAPI
class_object_Clone(
562 IWbemClassObject
*iface
,
563 IWbemClassObject
**ppCopy
)
565 FIXME("%p, %p\n", iface
, ppCopy
);
569 static BSTR
get_body_text( const struct table
*table
, UINT row
, UINT
*len
)
571 static const WCHAR fmtW
[] = {'\n','\t','%','s',' ','=',' ','%','s',';',0};
577 for (i
= 0; i
< table
->num_cols
; i
++)
579 if ((value
= get_value_bstr( table
, row
, i
)))
581 *len
+= sizeof(fmtW
) / sizeof(fmtW
[0]);
582 *len
+= strlenW( table
->columns
[i
].name
);
583 *len
+= SysStringLen( value
);
584 SysFreeString( value
);
587 if (!(ret
= SysAllocStringLen( NULL
, *len
))) return NULL
;
589 for (i
= 0; i
< table
->num_cols
; i
++)
591 if ((value
= get_value_bstr( table
, row
, i
)))
593 p
+= sprintfW( p
, fmtW
, table
->columns
[i
].name
, value
);
594 SysFreeString( value
);
600 static BSTR
get_object_text( const struct view
*view
, UINT index
)
602 static const WCHAR fmtW
[] =
603 {'\n','i','n','s','t','a','n','c','e',' ','o','f',' ','%','s','\n','{','%','s','\n','}',';',0};
604 UINT len
, len_body
, row
= view
->result
[index
];
607 len
= sizeof(fmtW
) / sizeof(fmtW
[0]);
608 len
+= strlenW( view
->table
->name
);
609 if (!(body
= get_body_text( view
->table
, row
, &len_body
))) return NULL
;
612 if (!(ret
= SysAllocStringLen( NULL
, len
))) return NULL
;
613 sprintfW( ret
, fmtW
, view
->table
->name
, body
);
614 SysFreeString( body
);
618 static HRESULT WINAPI
class_object_GetObjectText(
619 IWbemClassObject
*iface
,
621 BSTR
*pstrObjectText
)
623 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
624 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( co
->iter
);
625 struct view
*view
= ec
->query
->view
;
628 TRACE("%p, %08x, %p\n", iface
, lFlags
, pstrObjectText
);
630 if (lFlags
) FIXME("flags %08x not implemented\n", lFlags
);
632 if (!(text
= get_object_text( view
, co
->index
))) return E_OUTOFMEMORY
;
633 *pstrObjectText
= text
;
637 static HRESULT WINAPI
class_object_SpawnDerivedClass(
638 IWbemClassObject
*iface
,
640 IWbemClassObject
**ppNewClass
)
642 FIXME("%p, %08x, %p\n", iface
, lFlags
, ppNewClass
);
646 static HRESULT WINAPI
class_object_SpawnInstance(
647 IWbemClassObject
*iface
,
649 IWbemClassObject
**ppNewInstance
)
651 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
652 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( co
->iter
);
653 struct view
*view
= ec
->query
->view
;
654 struct record
*record
;
656 TRACE("%p, %08x, %p\n", iface
, lFlags
, ppNewInstance
);
658 if (!(record
= create_record( view
->table
))) return E_OUTOFMEMORY
;
660 return create_class_object( co
->name
, NULL
, 0, record
, ppNewInstance
);
663 static HRESULT WINAPI
class_object_CompareTo(
664 IWbemClassObject
*iface
,
666 IWbemClassObject
*pCompareTo
)
668 FIXME("%p, %08x, %p\n", iface
, lFlags
, pCompareTo
);
672 static HRESULT WINAPI
class_object_GetPropertyOrigin(
673 IWbemClassObject
*iface
,
675 BSTR
*pstrClassName
)
677 FIXME("%p, %s, %p\n", iface
, debugstr_w(wszName
), pstrClassName
);
681 static HRESULT WINAPI
class_object_InheritsFrom(
682 IWbemClassObject
*iface
,
683 LPCWSTR strAncestor
)
685 FIXME("%p, %s\n", iface
, debugstr_w(strAncestor
));
689 static UINT
count_instances( IEnumWbemClassObject
*iter
)
692 while (!IEnumWbemClassObject_Skip( iter
, WBEM_INFINITE
, 1 )) count
++;
693 IEnumWbemClassObject_Reset( iter
);
697 static void set_default_value( CIMTYPE type
, UINT val
, BYTE
*ptr
)
705 *(UINT16
*)ptr
= val
;
711 *(UINT32
*)ptr
= val
;
714 FIXME("unhandled type %u\n", type
);
719 static HRESULT
create_signature_columns_and_data( IEnumWbemClassObject
*iter
, UINT
*num_cols
,
720 struct column
**cols
, BYTE
**data
)
722 static const WCHAR parameterW
[] = {'P','a','r','a','m','e','t','e','r',0};
723 static const WCHAR typeW
[] = {'T','y','p','e',0};
724 static const WCHAR varianttypeW
[] = {'V','a','r','i','a','n','t','T','y','p','e',0};
725 static const WCHAR defaultvalueW
[] = {'D','e','f','a','u','l','t','V','a','l','u','e',0};
726 struct column
*columns
;
728 IWbemClassObject
*param
;
730 HRESULT hr
= E_OUTOFMEMORY
;
735 count
= count_instances( iter
);
736 if (!(columns
= heap_alloc( count
* sizeof(struct column
) ))) return E_OUTOFMEMORY
;
737 if (!(row
= heap_alloc_zero( count
* sizeof(LONGLONG
) ))) goto error
;
741 IEnumWbemClassObject_Next( iter
, WBEM_INFINITE
, 1, ¶m
, &count
);
744 hr
= IWbemClassObject_Get( param
, parameterW
, 0, &val
, NULL
, NULL
);
745 if (hr
!= S_OK
) goto error
;
746 columns
[i
].name
= heap_strdupW( V_BSTR( &val
) );
747 VariantClear( &val
);
749 hr
= IWbemClassObject_Get( param
, typeW
, 0, &val
, NULL
, NULL
);
750 if (hr
!= S_OK
) goto error
;
751 columns
[i
].type
= V_UI4( &val
);
753 hr
= IWbemClassObject_Get( param
, varianttypeW
, 0, &val
, NULL
, NULL
);
754 if (hr
!= S_OK
) goto error
;
755 columns
[i
].vartype
= V_UI4( &val
);
757 hr
= IWbemClassObject_Get( param
, defaultvalueW
, 0, &val
, NULL
, NULL
);
758 if (hr
!= S_OK
) goto error
;
759 if (V_UI4( &val
)) set_default_value( columns
[i
].type
, V_UI4( &val
), row
+ offset
);
760 offset
+= get_type_size( columns
[i
].type
);
762 IWbemClassObject_Release( param
);
771 for (; i
>= 0; i
--) heap_free( (WCHAR
*)columns
[i
].name
);
772 heap_free( columns
);
777 static HRESULT
create_signature_table( IEnumWbemClassObject
*iter
, WCHAR
*name
)
781 struct column
*columns
;
785 hr
= create_signature_columns_and_data( iter
, &num_cols
, &columns
, &row
);
786 if (hr
!= S_OK
) return hr
;
788 if (!(table
= create_table( name
, num_cols
, columns
, 1, row
, NULL
)))
790 free_columns( columns
, num_cols
);
792 return E_OUTOFMEMORY
;
794 if (!add_table( table
)) free_table( table
); /* already exists */
798 static WCHAR
*build_signature_table_name( const WCHAR
*class, const WCHAR
*method
, enum param_direction dir
)
800 static const WCHAR fmtW
[] = {'_','_','%','s','_','%','s','_','%','s',0};
801 static const WCHAR outW
[] = {'O','U','T',0};
802 static const WCHAR inW
[] = {'I','N',0};
803 UINT len
= SIZEOF(fmtW
) + SIZEOF(outW
) + strlenW( class ) + strlenW( method
);
806 if (!(ret
= heap_alloc( len
* sizeof(WCHAR
) ))) return NULL
;
807 sprintfW( ret
, fmtW
, class, method
, dir
== PARAM_IN
? inW
: outW
);
808 return struprW( ret
);
811 HRESULT
create_signature( const WCHAR
*class, const WCHAR
*method
, enum param_direction dir
,
812 IWbemClassObject
**sig
)
814 static const WCHAR selectW
[] =
815 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
816 '_','_','P','A','R','A','M','E','T','E','R','S',' ','W','H','E','R','E',' ',
817 'C','l','a','s','s','=','\'','%','s','\'',' ','A','N','D',' ',
818 'M','e','t','h','o','d','=','\'','%','s','\'',' ','A','N','D',' ',
819 'D','i','r','e','c','t','i','o','n','%','s',0};
820 static const WCHAR geW
[] = {'>','=','0',0};
821 static const WCHAR leW
[] = {'<','=','0',0};
822 UINT len
= SIZEOF(selectW
) + SIZEOF(geW
);
823 IEnumWbemClassObject
*iter
;
827 len
+= strlenW( class ) + strlenW( method
);
828 if (!(query
= heap_alloc( len
* sizeof(WCHAR
) ))) return E_OUTOFMEMORY
;
829 sprintfW( query
, selectW
, class, method
, dir
>= 0 ? geW
: leW
);
831 hr
= exec_query( query
, &iter
);
833 if (hr
!= S_OK
) return hr
;
835 if (!(name
= build_signature_table_name( class, method
, dir
)))
837 IEnumWbemClassObject_Release( iter
);
838 return E_OUTOFMEMORY
;
840 hr
= create_signature_table( iter
, name
);
841 IEnumWbemClassObject_Release( iter
);
843 hr
= get_object( name
, sig
);
849 static HRESULT WINAPI
class_object_GetMethod(
850 IWbemClassObject
*iface
,
853 IWbemClassObject
**ppInSignature
,
854 IWbemClassObject
**ppOutSignature
)
856 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
857 IWbemClassObject
*in
, *out
;
860 TRACE("%p, %s, %08x, %p, %p\n", iface
, debugstr_w(wszName
), lFlags
, ppInSignature
, ppOutSignature
);
862 hr
= create_signature( co
->name
, wszName
, PARAM_IN
, &in
);
863 if (hr
!= S_OK
) return hr
;
865 hr
= create_signature( co
->name
, wszName
, PARAM_OUT
, &out
);
868 if (ppInSignature
) *ppInSignature
= in
;
869 else IWbemClassObject_Release( in
);
870 if (ppOutSignature
) *ppOutSignature
= out
;
871 else IWbemClassObject_Release( out
);
873 else IWbemClassObject_Release( in
);
877 static HRESULT WINAPI
class_object_PutMethod(
878 IWbemClassObject
*iface
,
881 IWbemClassObject
*pInSignature
,
882 IWbemClassObject
*pOutSignature
)
884 FIXME("%p, %s, %08x, %p, %p\n", iface
, debugstr_w(wszName
), lFlags
, pInSignature
, pOutSignature
);
888 static HRESULT WINAPI
class_object_DeleteMethod(
889 IWbemClassObject
*iface
,
892 FIXME("%p, %s\n", iface
, debugstr_w(wszName
));
896 static HRESULT WINAPI
class_object_BeginMethodEnumeration(
897 IWbemClassObject
*iface
,
900 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
902 TRACE("%p, %08x\n", iface
, lEnumFlags
);
904 if (lEnumFlags
) FIXME("flags 0x%08x not supported\n", lEnumFlags
);
908 WARN("not allowed on instance\n");
909 return WBEM_E_ILLEGAL_OPERATION
;
911 co
->index_method
= 0;
915 static HRESULT WINAPI
class_object_NextMethod(
916 IWbemClassObject
*iface
,
919 IWbemClassObject
**ppInSignature
,
920 IWbemClassObject
**ppOutSignature
)
922 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
926 TRACE("%p, %08x, %p, %p, %p\n", iface
, lFlags
, pstrName
, ppInSignature
, ppOutSignature
);
928 if (!(method
= get_method_name( co
->name
, co
->index_method
))) return WBEM_S_NO_MORE_DATA
;
930 hr
= create_signature( co
->name
, method
, PARAM_IN
, ppInSignature
);
933 SysFreeString( method
);
936 hr
= create_signature( co
->name
, method
, PARAM_OUT
, ppOutSignature
);
939 SysFreeString( method
);
940 IWbemClassObject_Release( *ppInSignature
);
950 static HRESULT WINAPI
class_object_EndMethodEnumeration(
951 IWbemClassObject
*iface
)
953 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
955 TRACE("%p\n", iface
);
957 co
->index_method
= 0;
961 static HRESULT WINAPI
class_object_GetMethodQualifierSet(
962 IWbemClassObject
*iface
,
964 IWbemQualifierSet
**ppQualSet
)
966 FIXME("%p, %s, %p\n", iface
, debugstr_w(wszMethod
), ppQualSet
);
970 static HRESULT WINAPI
class_object_GetMethodOrigin(
971 IWbemClassObject
*iface
,
972 LPCWSTR wszMethodName
,
975 FIXME("%p, %s, %p\n", iface
, debugstr_w(wszMethodName
), pstrClassName
);
979 static const IWbemClassObjectVtbl class_object_vtbl
=
981 class_object_QueryInterface
,
983 class_object_Release
,
984 class_object_GetQualifierSet
,
988 class_object_GetNames
,
989 class_object_BeginEnumeration
,
991 class_object_EndEnumeration
,
992 class_object_GetPropertyQualifierSet
,
994 class_object_GetObjectText
,
995 class_object_SpawnDerivedClass
,
996 class_object_SpawnInstance
,
997 class_object_CompareTo
,
998 class_object_GetPropertyOrigin
,
999 class_object_InheritsFrom
,
1000 class_object_GetMethod
,
1001 class_object_PutMethod
,
1002 class_object_DeleteMethod
,
1003 class_object_BeginMethodEnumeration
,
1004 class_object_NextMethod
,
1005 class_object_EndMethodEnumeration
,
1006 class_object_GetMethodQualifierSet
,
1007 class_object_GetMethodOrigin
1010 HRESULT
create_class_object( const WCHAR
*name
, IEnumWbemClassObject
*iter
, UINT index
,
1011 struct record
*record
, IWbemClassObject
**obj
)
1013 struct class_object
*co
;
1015 TRACE("%s, %p\n", debugstr_w(name
), obj
);
1017 co
= heap_alloc( sizeof(*co
) );
1018 if (!co
) return E_OUTOFMEMORY
;
1020 co
->IWbemClassObject_iface
.lpVtbl
= &class_object_vtbl
;
1022 if (!name
) co
->name
= NULL
;
1023 else if (!(co
->name
= heap_strdupW( name
)))
1026 return E_OUTOFMEMORY
;
1030 co
->index_method
= 0;
1031 co
->index_property
= 0;
1032 co
->record
= record
;
1033 if (iter
) IEnumWbemClassObject_AddRef( iter
);
1035 *obj
= &co
->IWbemClassObject_iface
;
1037 TRACE("returning iface %p\n", *obj
);