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 #include "wbemprox_private.h"
21 struct enum_class_object
23 IEnumWbemClassObject IEnumWbemClassObject_iface
;
29 static inline struct enum_class_object
*impl_from_IEnumWbemClassObject(
30 IEnumWbemClassObject
*iface
)
32 return CONTAINING_RECORD(iface
, struct enum_class_object
, IEnumWbemClassObject_iface
);
35 static ULONG WINAPI
enum_class_object_AddRef(
36 IEnumWbemClassObject
*iface
)
38 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
39 return InterlockedIncrement( &ec
->refs
);
42 static ULONG WINAPI
enum_class_object_Release(
43 IEnumWbemClassObject
*iface
)
45 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
46 LONG refs
= InterlockedDecrement( &ec
->refs
);
49 TRACE("destroying %p\n", ec
);
50 release_query( ec
->query
);
56 static HRESULT WINAPI
enum_class_object_QueryInterface(
57 IEnumWbemClassObject
*iface
,
61 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
63 TRACE("%p, %s, %p\n", ec
, debugstr_guid( riid
), ppvObject
);
65 if ( IsEqualGUID( riid
, &IID_IEnumWbemClassObject
) ||
66 IsEqualGUID( riid
, &IID_IUnknown
) )
70 else if ( IsEqualGUID( riid
, &IID_IClientSecurity
) )
72 *ppvObject
= &client_security
;
77 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
80 IEnumWbemClassObject_AddRef( iface
);
84 static HRESULT WINAPI
enum_class_object_Reset(
85 IEnumWbemClassObject
*iface
)
87 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
92 return WBEM_S_NO_ERROR
;
95 static HRESULT WINAPI
enum_class_object_Next(
96 IEnumWbemClassObject
*iface
,
99 IWbemClassObject
**apObjects
,
102 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
103 struct view
*view
= ec
->query
->view
;
106 TRACE("%p, %d, %u, %p, %p\n", iface
, lTimeout
, uCount
, apObjects
, puReturned
);
108 if (!uCount
) return WBEM_S_FALSE
;
109 if (!apObjects
|| !puReturned
) return WBEM_E_INVALID_PARAMETER
;
110 if (lTimeout
!= WBEM_INFINITE
) FIXME("timeout not supported\n");
113 if (ec
->index
>= view
->count
) return WBEM_S_FALSE
;
115 hr
= create_class_object( view
->table
->name
, iface
, ec
->index
, NULL
, apObjects
);
116 if (hr
!= S_OK
) return hr
;
120 if (ec
->index
== view
->count
&& uCount
> 1) return WBEM_S_FALSE
;
121 if (uCount
> 1) return WBEM_S_TIMEDOUT
;
122 return WBEM_S_NO_ERROR
;
125 static HRESULT WINAPI
enum_class_object_NextAsync(
126 IEnumWbemClassObject
*iface
,
128 IWbemObjectSink
*pSink
)
130 FIXME("%p, %u, %p\n", iface
, uCount
, pSink
);
134 static HRESULT WINAPI
enum_class_object_Clone(
135 IEnumWbemClassObject
*iface
,
136 IEnumWbemClassObject
**ppEnum
)
138 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
140 TRACE("%p, %p\n", iface
, ppEnum
);
142 return EnumWbemClassObject_create( NULL
, ec
->query
, (void **)ppEnum
);
145 static HRESULT WINAPI
enum_class_object_Skip(
146 IEnumWbemClassObject
*iface
,
150 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( iface
);
151 struct view
*view
= ec
->query
->view
;
153 TRACE("%p, %d, %u\n", iface
, lTimeout
, nCount
);
155 if (lTimeout
!= WBEM_INFINITE
) FIXME("timeout not supported\n");
157 if (!view
->count
) return WBEM_S_FALSE
;
159 if (nCount
> view
->count
- ec
->index
)
161 ec
->index
= view
->count
- 1;
165 return WBEM_S_NO_ERROR
;
168 static const IEnumWbemClassObjectVtbl enum_class_object_vtbl
=
170 enum_class_object_QueryInterface
,
171 enum_class_object_AddRef
,
172 enum_class_object_Release
,
173 enum_class_object_Reset
,
174 enum_class_object_Next
,
175 enum_class_object_NextAsync
,
176 enum_class_object_Clone
,
177 enum_class_object_Skip
180 HRESULT
EnumWbemClassObject_create(
181 IUnknown
*pUnkOuter
, struct query
*query
, LPVOID
*ppObj
)
183 struct enum_class_object
*ec
;
185 TRACE("%p, %p\n", pUnkOuter
, ppObj
);
187 ec
= heap_alloc( sizeof(*ec
) );
188 if (!ec
) return E_OUTOFMEMORY
;
190 ec
->IEnumWbemClassObject_iface
.lpVtbl
= &enum_class_object_vtbl
;
192 ec
->query
= addref_query( query
);
195 *ppObj
= &ec
->IEnumWbemClassObject_iface
;
197 TRACE("returning iface %p\n", *ppObj
);
201 static struct record
*create_record( struct table
*table
)
204 struct record
*record
;
206 if (!(record
= heap_alloc( sizeof(struct record
) ))) return NULL
;
207 if (!(record
->fields
= heap_alloc( table
->num_cols
* sizeof(struct field
) )))
212 for (i
= 0; i
< table
->num_cols
; i
++)
214 record
->fields
[i
].type
= table
->columns
[i
].type
;
215 record
->fields
[i
].vartype
= table
->columns
[i
].vartype
;
216 record
->fields
[i
].u
.ival
= 0;
218 record
->count
= table
->num_cols
;
219 record
->table
= addref_table( table
);
223 void destroy_array( struct array
*array
, CIMTYPE type
)
228 if (type
== CIM_STRING
|| type
== CIM_DATETIME
)
230 size
= get_type_size( type
);
231 for (i
= 0; i
< array
->count
; i
++) heap_free( *(WCHAR
**)((char *)array
->ptr
+ i
* size
) );
233 heap_free( array
->ptr
);
237 static void destroy_record( struct record
*record
)
242 release_table( record
->table
);
243 for (i
= 0; i
< record
->count
; i
++)
245 if (record
->fields
[i
].type
== CIM_STRING
|| record
->fields
[i
].type
== CIM_DATETIME
)
246 heap_free( record
->fields
[i
].u
.sval
);
247 else if (record
->fields
[i
].type
& CIM_FLAG_ARRAY
)
248 destroy_array( record
->fields
[i
].u
.aval
, record
->fields
[i
].type
& CIM_TYPE_MASK
);
250 heap_free( record
->fields
);
256 IWbemClassObject IWbemClassObject_iface
;
259 IEnumWbemClassObject
*iter
;
263 struct record
*record
; /* uncommitted instance */
266 static inline struct class_object
*impl_from_IWbemClassObject(
267 IWbemClassObject
*iface
)
269 return CONTAINING_RECORD(iface
, struct class_object
, IWbemClassObject_iface
);
272 static ULONG WINAPI
class_object_AddRef(
273 IWbemClassObject
*iface
)
275 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
276 return InterlockedIncrement( &co
->refs
);
279 static ULONG WINAPI
class_object_Release(
280 IWbemClassObject
*iface
)
282 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
283 LONG refs
= InterlockedDecrement( &co
->refs
);
286 TRACE("destroying %p\n", co
);
287 if (co
->iter
) IEnumWbemClassObject_Release( co
->iter
);
288 destroy_record( co
->record
);
289 heap_free( co
->name
);
295 static HRESULT WINAPI
class_object_QueryInterface(
296 IWbemClassObject
*iface
,
300 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
302 TRACE("%p, %s, %p\n", co
, debugstr_guid( riid
), ppvObject
);
304 if ( IsEqualGUID( riid
, &IID_IWbemClassObject
) ||
305 IsEqualGUID( riid
, &IID_IUnknown
) )
309 else if (IsEqualGUID( riid
, &IID_IClientSecurity
))
311 *ppvObject
= &client_security
;
316 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
317 return E_NOINTERFACE
;
319 IWbemClassObject_AddRef( iface
);
323 static HRESULT WINAPI
class_object_GetQualifierSet(
324 IWbemClassObject
*iface
,
325 IWbemQualifierSet
**ppQualSet
)
327 FIXME("%p, %p\n", iface
, ppQualSet
);
331 static HRESULT
record_get_value( const struct record
*record
, UINT index
, VARIANT
*var
, CIMTYPE
*type
)
333 VARTYPE vartype
= record
->fields
[index
].vartype
;
335 if (type
) *type
= record
->fields
[index
].type
;
337 if (record
->fields
[index
].type
& CIM_FLAG_ARRAY
)
339 V_VT( var
) = vartype
? vartype
: to_vartype( record
->fields
[index
].type
& CIM_TYPE_MASK
) | VT_ARRAY
;
340 V_ARRAY( var
) = to_safearray( record
->fields
[index
].u
.aval
, record
->fields
[index
].type
& CIM_TYPE_MASK
);
343 switch (record
->fields
[index
].type
)
347 if (!vartype
) vartype
= VT_BSTR
;
348 V_BSTR( var
) = SysAllocString( record
->fields
[index
].u
.sval
);
351 if (!vartype
) vartype
= VT_I4
;
352 V_I4( var
) = record
->fields
[index
].u
.ival
;
355 if (!vartype
) vartype
= VT_UI4
;
356 V_UI4( var
) = record
->fields
[index
].u
.ival
;
359 FIXME("unhandled type %u\n", record
->fields
[index
].type
);
360 return WBEM_E_INVALID_PARAMETER
;
362 V_VT( var
) = vartype
;
366 static HRESULT WINAPI
class_object_Get(
367 IWbemClassObject
*iface
,
374 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
375 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( co
->iter
);
377 TRACE("%p, %s, %08x, %p, %p, %p\n", iface
, debugstr_w(wszName
), lFlags
, pVal
, pType
, plFlavor
);
384 if ((hr
= get_column_index( co
->record
->table
, wszName
, &index
)) != S_OK
) return hr
;
385 return record_get_value( co
->record
, index
, pVal
, pType
);
387 return get_propval( ec
->query
->view
, co
->index
, wszName
, pVal
, pType
, plFlavor
);
390 static HRESULT
record_set_value( struct record
*record
, UINT index
, VARIANT
*var
)
396 if ((hr
= to_longlong( var
, &val
, &type
)) != S_OK
) return hr
;
397 if (type
!= record
->fields
[index
].type
) return WBEM_E_TYPE_MISMATCH
;
399 if (type
& CIM_FLAG_ARRAY
)
401 record
->fields
[index
].u
.aval
= (struct array
*)(INT_PTR
)val
;
408 record
->fields
[index
].u
.sval
= (WCHAR
*)(INT_PTR
)val
;
414 record
->fields
[index
].u
.ival
= val
;
417 FIXME("unhandled type %u\n", type
);
420 return WBEM_E_INVALID_PARAMETER
;
423 static HRESULT WINAPI
class_object_Put(
424 IWbemClassObject
*iface
,
430 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
431 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( co
->iter
);
433 TRACE("%p, %s, %08x, %p, %u\n", iface
, debugstr_w(wszName
), lFlags
, pVal
, Type
);
440 if ((hr
= get_column_index( co
->record
->table
, wszName
, &index
)) != S_OK
) return hr
;
441 return record_set_value( co
->record
, index
, pVal
);
443 return put_propval( ec
->query
->view
, co
->index
, wszName
, pVal
, Type
);
446 static HRESULT WINAPI
class_object_Delete(
447 IWbemClassObject
*iface
,
450 FIXME("%p, %s\n", iface
, debugstr_w(wszName
));
454 static HRESULT WINAPI
class_object_GetNames(
455 IWbemClassObject
*iface
,
456 LPCWSTR wszQualifierName
,
458 VARIANT
*pQualifierVal
,
461 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
462 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( co
->iter
);
464 TRACE("%p, %s, %08x, %s, %p\n", iface
, debugstr_w(wszQualifierName
), lFlags
,
465 debugstr_variant(pQualifierVal
), pNames
);
467 if (wszQualifierName
|| pQualifierVal
)
469 FIXME("qualifier not supported\n");
472 if (lFlags
!= WBEM_FLAG_ALWAYS
)
474 FIXME("flags %08x not supported\n", lFlags
);
477 return get_properties( ec
->query
->view
, pNames
);
480 static HRESULT WINAPI
class_object_BeginEnumeration(
481 IWbemClassObject
*iface
,
484 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
486 TRACE("%p, %08x\n", iface
, lEnumFlags
);
488 if (lEnumFlags
) FIXME("flags 0x%08x not supported\n", lEnumFlags
);
490 co
->index_property
= 0;
494 static HRESULT WINAPI
class_object_Next(
495 IWbemClassObject
*iface
,
502 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
503 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( co
->iter
);
504 struct view
*view
= ec
->query
->view
;
508 TRACE("%p, %08x, %p, %p, %p, %p\n", iface
, lFlags
, strName
, pVal
, pType
, plFlavor
);
510 if (!(property
= get_property_name( co
->name
, co
->index_property
))) return WBEM_S_NO_MORE_DATA
;
511 if ((hr
= get_propval( view
, co
->index
, property
, pVal
, pType
, plFlavor
) != S_OK
))
513 SysFreeString( property
);
517 co
->index_property
++;
521 static HRESULT WINAPI
class_object_EndEnumeration(
522 IWbemClassObject
*iface
)
524 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
526 TRACE("%p\n", iface
);
528 co
->index_property
= 0;
532 static HRESULT WINAPI
class_object_GetPropertyQualifierSet(
533 IWbemClassObject
*iface
,
535 IWbemQualifierSet
**ppQualSet
)
537 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
539 TRACE("%p, %s, %p\n", iface
, debugstr_w(wszProperty
), ppQualSet
);
541 return WbemQualifierSet_create( NULL
, co
->name
, wszProperty
, (void **)ppQualSet
);
544 static HRESULT WINAPI
class_object_Clone(
545 IWbemClassObject
*iface
,
546 IWbemClassObject
**ppCopy
)
548 FIXME("%p, %p\n", iface
, ppCopy
);
552 static BSTR
get_body_text( const struct table
*table
, UINT row
, UINT
*len
)
554 static const WCHAR fmtW
[] = {'\n','\t','%','s',' ','=',' ','%','s',';',0};
560 for (i
= 0; i
< table
->num_cols
; i
++)
562 if ((value
= get_value_bstr( table
, row
, i
)))
564 *len
+= sizeof(fmtW
) / sizeof(fmtW
[0]);
565 *len
+= strlenW( table
->columns
[i
].name
);
566 *len
+= SysStringLen( value
);
567 SysFreeString( value
);
570 if (!(ret
= SysAllocStringLen( NULL
, *len
))) return NULL
;
572 for (i
= 0; i
< table
->num_cols
; i
++)
574 if ((value
= get_value_bstr( table
, row
, i
)))
576 p
+= sprintfW( p
, fmtW
, table
->columns
[i
].name
, value
);
577 SysFreeString( value
);
583 static BSTR
get_object_text( const struct view
*view
, UINT index
)
585 static const WCHAR fmtW
[] =
586 {'\n','i','n','s','t','a','n','c','e',' ','o','f',' ','%','s','\n','{','%','s','\n','}',';',0};
587 UINT len
, len_body
, row
= view
->result
[index
];
590 len
= sizeof(fmtW
) / sizeof(fmtW
[0]);
591 len
+= strlenW( view
->table
->name
);
592 if (!(body
= get_body_text( view
->table
, row
, &len_body
))) return NULL
;
595 if (!(ret
= SysAllocStringLen( NULL
, len
))) return NULL
;
596 sprintfW( ret
, fmtW
, view
->table
->name
, body
);
597 SysFreeString( body
);
601 static HRESULT WINAPI
class_object_GetObjectText(
602 IWbemClassObject
*iface
,
604 BSTR
*pstrObjectText
)
606 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
607 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( co
->iter
);
608 struct view
*view
= ec
->query
->view
;
611 TRACE("%p, %08x, %p\n", iface
, lFlags
, pstrObjectText
);
613 if (lFlags
) FIXME("flags %08x not implemented\n", lFlags
);
615 if (!(text
= get_object_text( view
, co
->index
))) return E_OUTOFMEMORY
;
616 *pstrObjectText
= text
;
620 static HRESULT WINAPI
class_object_SpawnDerivedClass(
621 IWbemClassObject
*iface
,
623 IWbemClassObject
**ppNewClass
)
625 FIXME("%p, %08x, %p\n", iface
, lFlags
, ppNewClass
);
629 static HRESULT WINAPI
class_object_SpawnInstance(
630 IWbemClassObject
*iface
,
632 IWbemClassObject
**ppNewInstance
)
634 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
635 struct enum_class_object
*ec
= impl_from_IEnumWbemClassObject( co
->iter
);
636 struct view
*view
= ec
->query
->view
;
637 struct record
*record
;
639 TRACE("%p, %08x, %p\n", iface
, lFlags
, ppNewInstance
);
641 if (!(record
= create_record( view
->table
))) return E_OUTOFMEMORY
;
643 return create_class_object( co
->name
, NULL
, 0, record
, ppNewInstance
);
646 static HRESULT WINAPI
class_object_CompareTo(
647 IWbemClassObject
*iface
,
649 IWbemClassObject
*pCompareTo
)
651 FIXME("%p, %08x, %p\n", iface
, lFlags
, pCompareTo
);
655 static HRESULT WINAPI
class_object_GetPropertyOrigin(
656 IWbemClassObject
*iface
,
658 BSTR
*pstrClassName
)
660 FIXME("%p, %s, %p\n", iface
, debugstr_w(wszName
), pstrClassName
);
664 static HRESULT WINAPI
class_object_InheritsFrom(
665 IWbemClassObject
*iface
,
666 LPCWSTR strAncestor
)
668 FIXME("%p, %s\n", iface
, debugstr_w(strAncestor
));
672 static UINT
count_instances( IEnumWbemClassObject
*iter
)
675 while (!IEnumWbemClassObject_Skip( iter
, WBEM_INFINITE
, 1 )) count
++;
676 IEnumWbemClassObject_Reset( iter
);
680 static void set_default_value( CIMTYPE type
, UINT val
, BYTE
*ptr
)
688 *(UINT16
*)ptr
= val
;
694 *(UINT32
*)ptr
= val
;
697 FIXME("unhandled type %u\n", type
);
702 static HRESULT
create_signature_columns_and_data( IEnumWbemClassObject
*iter
, UINT
*num_cols
,
703 struct column
**cols
, BYTE
**data
)
705 static const WCHAR parameterW
[] = {'P','a','r','a','m','e','t','e','r',0};
706 static const WCHAR typeW
[] = {'T','y','p','e',0};
707 static const WCHAR varianttypeW
[] = {'V','a','r','i','a','n','t','T','y','p','e',0};
708 static const WCHAR defaultvalueW
[] = {'D','e','f','a','u','l','t','V','a','l','u','e',0};
709 struct column
*columns
;
711 IWbemClassObject
*param
;
713 HRESULT hr
= E_OUTOFMEMORY
;
718 count
= count_instances( iter
);
719 if (!(columns
= heap_alloc( count
* sizeof(struct column
) ))) return E_OUTOFMEMORY
;
720 if (!(row
= heap_alloc_zero( count
* sizeof(LONGLONG
) ))) goto error
;
724 IEnumWbemClassObject_Next( iter
, WBEM_INFINITE
, 1, ¶m
, &count
);
727 hr
= IWbemClassObject_Get( param
, parameterW
, 0, &val
, NULL
, NULL
);
728 if (hr
!= S_OK
) goto error
;
729 columns
[i
].name
= heap_strdupW( V_BSTR( &val
) );
730 VariantClear( &val
);
732 hr
= IWbemClassObject_Get( param
, typeW
, 0, &val
, NULL
, NULL
);
733 if (hr
!= S_OK
) goto error
;
734 columns
[i
].type
= V_UI4( &val
);
736 hr
= IWbemClassObject_Get( param
, varianttypeW
, 0, &val
, NULL
, NULL
);
737 if (hr
!= S_OK
) goto error
;
738 columns
[i
].vartype
= V_UI4( &val
);
740 hr
= IWbemClassObject_Get( param
, defaultvalueW
, 0, &val
, NULL
, NULL
);
741 if (hr
!= S_OK
) goto error
;
742 if (V_UI4( &val
)) set_default_value( columns
[i
].type
, V_UI4( &val
), row
+ offset
);
743 offset
+= get_type_size( columns
[i
].type
);
745 IWbemClassObject_Release( param
);
754 for (; i
>= 0; i
--) heap_free( (WCHAR
*)columns
[i
].name
);
755 heap_free( columns
);
760 static HRESULT
create_signature_table( IEnumWbemClassObject
*iter
, WCHAR
*name
)
764 struct column
*columns
;
768 hr
= create_signature_columns_and_data( iter
, &num_cols
, &columns
, &row
);
769 if (hr
!= S_OK
) return hr
;
771 if (!(table
= create_table( name
, num_cols
, columns
, 1, 1, row
, NULL
)))
773 free_columns( columns
, num_cols
);
775 return E_OUTOFMEMORY
;
777 if (!add_table( table
)) free_table( table
); /* already exists */
781 static WCHAR
*build_signature_table_name( const WCHAR
*class, const WCHAR
*method
, enum param_direction dir
)
783 static const WCHAR fmtW
[] = {'_','_','%','s','_','%','s','_','%','s',0};
784 static const WCHAR outW
[] = {'O','U','T',0};
785 static const WCHAR inW
[] = {'I','N',0};
786 UINT len
= SIZEOF(fmtW
) + SIZEOF(outW
) + strlenW( class ) + strlenW( method
);
789 if (!(ret
= heap_alloc( len
* sizeof(WCHAR
) ))) return NULL
;
790 sprintfW( ret
, fmtW
, class, method
, dir
== PARAM_IN
? inW
: outW
);
791 return struprW( ret
);
794 HRESULT
create_signature( const WCHAR
*class, const WCHAR
*method
, enum param_direction dir
,
795 IWbemClassObject
**sig
)
797 static const WCHAR selectW
[] =
798 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
799 '_','_','P','A','R','A','M','E','T','E','R','S',' ','W','H','E','R','E',' ',
800 'C','l','a','s','s','=','\'','%','s','\'',' ','A','N','D',' ',
801 'M','e','t','h','o','d','=','\'','%','s','\'',' ','A','N','D',' ',
802 'D','i','r','e','c','t','i','o','n','%','s',0};
803 static const WCHAR geW
[] = {'>','=','0',0};
804 static const WCHAR leW
[] = {'<','=','0',0};
805 UINT len
= SIZEOF(selectW
) + SIZEOF(geW
);
806 IEnumWbemClassObject
*iter
;
810 len
+= strlenW( class ) + strlenW( method
);
811 if (!(query
= heap_alloc( len
* sizeof(WCHAR
) ))) return E_OUTOFMEMORY
;
812 sprintfW( query
, selectW
, class, method
, dir
>= 0 ? geW
: leW
);
814 hr
= exec_query( query
, &iter
);
816 if (hr
!= S_OK
) return hr
;
818 if (!(name
= build_signature_table_name( class, method
, dir
)))
820 IEnumWbemClassObject_Release( iter
);
821 return E_OUTOFMEMORY
;
823 hr
= create_signature_table( iter
, name
);
824 IEnumWbemClassObject_Release( iter
);
826 hr
= get_object( name
, sig
);
832 static HRESULT WINAPI
class_object_GetMethod(
833 IWbemClassObject
*iface
,
836 IWbemClassObject
**ppInSignature
,
837 IWbemClassObject
**ppOutSignature
)
839 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
840 IWbemClassObject
*in
, *out
;
843 TRACE("%p, %s, %08x, %p, %p\n", iface
, debugstr_w(wszName
), lFlags
, ppInSignature
, ppOutSignature
);
845 hr
= create_signature( co
->name
, wszName
, PARAM_IN
, &in
);
846 if (hr
!= S_OK
) return hr
;
848 hr
= create_signature( co
->name
, wszName
, PARAM_OUT
, &out
);
851 if (ppInSignature
) *ppInSignature
= in
;
852 else IWbemClassObject_Release( in
);
853 if (ppOutSignature
) *ppOutSignature
= out
;
854 else IWbemClassObject_Release( out
);
856 else IWbemClassObject_Release( in
);
860 static HRESULT WINAPI
class_object_PutMethod(
861 IWbemClassObject
*iface
,
864 IWbemClassObject
*pInSignature
,
865 IWbemClassObject
*pOutSignature
)
867 FIXME("%p, %s, %08x, %p, %p\n", iface
, debugstr_w(wszName
), lFlags
, pInSignature
, pOutSignature
);
871 static HRESULT WINAPI
class_object_DeleteMethod(
872 IWbemClassObject
*iface
,
875 FIXME("%p, %s\n", iface
, debugstr_w(wszName
));
879 static HRESULT WINAPI
class_object_BeginMethodEnumeration(
880 IWbemClassObject
*iface
,
883 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
885 TRACE("%p, %08x\n", iface
, lEnumFlags
);
887 if (lEnumFlags
) FIXME("flags 0x%08x not supported\n", lEnumFlags
);
891 WARN("not allowed on instance\n");
892 return WBEM_E_ILLEGAL_OPERATION
;
894 co
->index_method
= 0;
898 static HRESULT WINAPI
class_object_NextMethod(
899 IWbemClassObject
*iface
,
902 IWbemClassObject
**ppInSignature
,
903 IWbemClassObject
**ppOutSignature
)
905 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
909 TRACE("%p, %08x, %p, %p, %p\n", iface
, lFlags
, pstrName
, ppInSignature
, ppOutSignature
);
911 if (!(method
= get_method_name( co
->name
, co
->index_method
))) return WBEM_S_NO_MORE_DATA
;
913 hr
= create_signature( co
->name
, method
, PARAM_IN
, ppInSignature
);
916 SysFreeString( method
);
919 hr
= create_signature( co
->name
, method
, PARAM_OUT
, ppOutSignature
);
922 SysFreeString( method
);
923 IWbemClassObject_Release( *ppInSignature
);
933 static HRESULT WINAPI
class_object_EndMethodEnumeration(
934 IWbemClassObject
*iface
)
936 struct class_object
*co
= impl_from_IWbemClassObject( iface
);
938 TRACE("%p\n", iface
);
940 co
->index_method
= 0;
944 static HRESULT WINAPI
class_object_GetMethodQualifierSet(
945 IWbemClassObject
*iface
,
947 IWbemQualifierSet
**ppQualSet
)
949 FIXME("%p, %s, %p\n", iface
, debugstr_w(wszMethod
), ppQualSet
);
953 static HRESULT WINAPI
class_object_GetMethodOrigin(
954 IWbemClassObject
*iface
,
955 LPCWSTR wszMethodName
,
958 FIXME("%p, %s, %p\n", iface
, debugstr_w(wszMethodName
), pstrClassName
);
962 static const IWbemClassObjectVtbl class_object_vtbl
=
964 class_object_QueryInterface
,
966 class_object_Release
,
967 class_object_GetQualifierSet
,
971 class_object_GetNames
,
972 class_object_BeginEnumeration
,
974 class_object_EndEnumeration
,
975 class_object_GetPropertyQualifierSet
,
977 class_object_GetObjectText
,
978 class_object_SpawnDerivedClass
,
979 class_object_SpawnInstance
,
980 class_object_CompareTo
,
981 class_object_GetPropertyOrigin
,
982 class_object_InheritsFrom
,
983 class_object_GetMethod
,
984 class_object_PutMethod
,
985 class_object_DeleteMethod
,
986 class_object_BeginMethodEnumeration
,
987 class_object_NextMethod
,
988 class_object_EndMethodEnumeration
,
989 class_object_GetMethodQualifierSet
,
990 class_object_GetMethodOrigin
993 HRESULT
create_class_object( const WCHAR
*name
, IEnumWbemClassObject
*iter
, UINT index
,
994 struct record
*record
, IWbemClassObject
**obj
)
996 struct class_object
*co
;
998 TRACE("%s, %p\n", debugstr_w(name
), obj
);
1000 co
= heap_alloc( sizeof(*co
) );
1001 if (!co
) return E_OUTOFMEMORY
;
1003 co
->IWbemClassObject_iface
.lpVtbl
= &class_object_vtbl
;
1005 if (!name
) co
->name
= NULL
;
1006 else if (!(co
->name
= heap_strdupW( name
)))
1009 return E_OUTOFMEMORY
;
1013 co
->index_method
= 0;
1014 co
->index_property
= 0;
1015 co
->record
= record
;
1016 if (iter
) IEnumWbemClassObject_AddRef( iter
);
1018 *obj
= &co
->IWbemClassObject_iface
;
1020 TRACE("returning iface %p\n", *obj
);