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
29 #include "wine/debug.h"
30 #include "wbemprox_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox);
34 struct enum_class_object
36 IEnumWbemClassObject IEnumWbemClassObject_iface;
42 static inline struct enum_class_object *impl_from_IEnumWbemClassObject(
43 IEnumWbemClassObject *iface )
45 return CONTAINING_RECORD(iface, struct enum_class_object, IEnumWbemClassObject_iface);
48 static ULONG WINAPI enum_class_object_AddRef(
49 IEnumWbemClassObject *iface )
51 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( iface );
52 return InterlockedIncrement( &ec->refs );
55 static ULONG WINAPI enum_class_object_Release(
56 IEnumWbemClassObject *iface )
58 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( iface );
59 LONG refs = InterlockedDecrement( &ec->refs );
62 TRACE("destroying %p\n", ec);
63 release_query( ec->query );
69 static HRESULT WINAPI enum_class_object_QueryInterface(
70 IEnumWbemClassObject *iface,
74 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( iface );
76 TRACE("%p, %s, %p\n", ec, debugstr_guid( riid ), ppvObject );
78 if ( IsEqualGUID( riid, &IID_IEnumWbemClassObject ) ||
79 IsEqualGUID( riid, &IID_IUnknown ) )
83 else if ( IsEqualGUID( riid, &IID_IClientSecurity ) )
85 *ppvObject = &client_security;
90 FIXME("interface %s not implemented\n", debugstr_guid(riid));
93 IEnumWbemClassObject_AddRef( iface );
97 static HRESULT WINAPI enum_class_object_Reset(
98 IEnumWbemClassObject *iface )
100 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( iface );
102 TRACE("%p\n", iface);
105 return WBEM_S_NO_ERROR;
108 static HRESULT WINAPI enum_class_object_Next(
109 IEnumWbemClassObject *iface,
112 IWbemClassObject **apObjects,
115 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( iface );
116 struct view *view = ec->query->view;
119 TRACE("%p, %d, %u, %p, %p\n", iface, lTimeout, uCount, apObjects, puReturned);
121 if (!uCount) return WBEM_S_FALSE;
122 if (!apObjects || !puReturned) return WBEM_E_INVALID_PARAMETER;
123 if (lTimeout != WBEM_INFINITE) FIXME("timeout not supported\n");
126 if (ec->index + uCount > view->count) return WBEM_S_FALSE;
128 hr = create_class_object( view->table->name, iface, ec->index, NULL, apObjects );
129 if (hr != S_OK) return hr;
133 if (ec->index == view->count) return WBEM_S_FALSE;
134 if (uCount > 1) return WBEM_S_TIMEDOUT;
135 return WBEM_S_NO_ERROR;
138 static HRESULT WINAPI enum_class_object_NextAsync(
139 IEnumWbemClassObject *iface,
141 IWbemObjectSink *pSink )
143 FIXME("%p, %u, %p\n", iface, uCount, pSink);
147 static HRESULT WINAPI enum_class_object_Clone(
148 IEnumWbemClassObject *iface,
149 IEnumWbemClassObject **ppEnum )
151 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( iface );
153 TRACE("%p, %p\n", iface, ppEnum);
155 return EnumWbemClassObject_create( NULL, ec->query, (void **)ppEnum );
158 static HRESULT WINAPI enum_class_object_Skip(
159 IEnumWbemClassObject *iface,
163 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( iface );
164 struct view *view = ec->query->view;
166 TRACE("%p, %d, %u\n", iface, lTimeout, nCount);
168 if (lTimeout != WBEM_INFINITE) FIXME("timeout not supported\n");
170 if (!view->count) return WBEM_S_FALSE;
172 if (nCount > view->count - ec->index)
174 ec->index = view->count - 1;
178 return WBEM_S_NO_ERROR;
181 static const IEnumWbemClassObjectVtbl enum_class_object_vtbl =
183 enum_class_object_QueryInterface,
184 enum_class_object_AddRef,
185 enum_class_object_Release,
186 enum_class_object_Reset,
187 enum_class_object_Next,
188 enum_class_object_NextAsync,
189 enum_class_object_Clone,
190 enum_class_object_Skip
193 HRESULT EnumWbemClassObject_create(
194 IUnknown *pUnkOuter, struct query *query, LPVOID *ppObj )
196 struct enum_class_object *ec;
198 TRACE("%p, %p\n", pUnkOuter, ppObj);
200 ec = heap_alloc( sizeof(*ec) );
201 if (!ec) return E_OUTOFMEMORY;
203 ec->IEnumWbemClassObject_iface.lpVtbl = &enum_class_object_vtbl;
205 ec->query = addref_query( query );
208 *ppObj = &ec->IEnumWbemClassObject_iface;
210 TRACE("returning iface %p\n", *ppObj);
214 static struct record *create_record( struct table *table )
217 struct record *record;
219 if (!(record = heap_alloc( sizeof(struct record) ))) return NULL;
220 if (!(record->fields = heap_alloc( table->num_cols * sizeof(struct field) )))
225 for (i = 0; i < table->num_cols; i++)
227 record->fields[i].type = table->columns[i].type;
228 record->fields[i].vartype = table->columns[i].vartype;
229 record->fields[i].u.ival = 0;
231 record->count = table->num_cols;
232 record->table = addref_table( table );
236 void destroy_array( struct array *array, CIMTYPE type )
241 if (type == CIM_STRING || type == CIM_DATETIME)
243 size = get_type_size( type );
244 for (i = 0; i < array->count; i++) heap_free( *(WCHAR **)((char *)array->ptr + i * size) );
246 heap_free( array->ptr );
250 static void destroy_record( struct record *record )
255 release_table( record->table );
256 for (i = 0; i < record->count; i++)
258 if (record->fields[i].type == CIM_STRING || record->fields[i].type == CIM_DATETIME)
259 heap_free( record->fields[i].u.sval );
260 else if (record->fields[i].type & CIM_FLAG_ARRAY)
261 destroy_array( record->fields[i].u.aval, record->fields[i].type & CIM_TYPE_MASK );
263 heap_free( record->fields );
269 IWbemClassObject IWbemClassObject_iface;
272 IEnumWbemClassObject *iter;
276 struct record *record; /* uncommitted instance */
279 static inline struct class_object *impl_from_IWbemClassObject(
280 IWbemClassObject *iface )
282 return CONTAINING_RECORD(iface, struct class_object, IWbemClassObject_iface);
285 static ULONG WINAPI class_object_AddRef(
286 IWbemClassObject *iface )
288 struct class_object *co = impl_from_IWbemClassObject( iface );
289 return InterlockedIncrement( &co->refs );
292 static ULONG WINAPI class_object_Release(
293 IWbemClassObject *iface )
295 struct class_object *co = impl_from_IWbemClassObject( iface );
296 LONG refs = InterlockedDecrement( &co->refs );
299 TRACE("destroying %p\n", co);
300 if (co->iter) IEnumWbemClassObject_Release( co->iter );
301 destroy_record( co->record );
302 heap_free( co->name );
308 static HRESULT WINAPI class_object_QueryInterface(
309 IWbemClassObject *iface,
313 struct class_object *co = impl_from_IWbemClassObject( iface );
315 TRACE("%p, %s, %p\n", co, debugstr_guid( riid ), ppvObject );
317 if ( IsEqualGUID( riid, &IID_IWbemClassObject ) ||
318 IsEqualGUID( riid, &IID_IUnknown ) )
322 else if (IsEqualGUID( riid, &IID_IClientSecurity ))
324 *ppvObject = &client_security;
329 FIXME("interface %s not implemented\n", debugstr_guid(riid));
330 return E_NOINTERFACE;
332 IWbemClassObject_AddRef( iface );
336 static HRESULT WINAPI class_object_GetQualifierSet(
337 IWbemClassObject *iface,
338 IWbemQualifierSet **ppQualSet )
340 FIXME("%p, %p\n", iface, ppQualSet);
344 static HRESULT record_get_value( const struct record *record, UINT index, VARIANT *var, CIMTYPE *type )
346 VARTYPE vartype = record->fields[index].vartype;
348 if (type) *type = record->fields[index].type;
350 if (record->fields[index].type & CIM_FLAG_ARRAY)
352 V_VT( var ) = vartype ? vartype : to_vartype( record->fields[index].type & CIM_TYPE_MASK ) | VT_ARRAY;
353 V_ARRAY( var ) = to_safearray( record->fields[index].u.aval, record->fields[index].type & CIM_TYPE_MASK );
356 switch (record->fields[index].type)
360 if (!vartype) vartype = VT_BSTR;
361 V_BSTR( var ) = SysAllocString( record->fields[index].u.sval );
364 if (!vartype) vartype = VT_I4;
365 V_I4( var ) = record->fields[index].u.ival;
368 if (!vartype) vartype = VT_UI4;
369 V_UI4( var ) = record->fields[index].u.ival;
372 FIXME("unhandled type %u\n", record->fields[index].type);
373 return WBEM_E_INVALID_PARAMETER;
375 V_VT( var ) = vartype;
379 static HRESULT WINAPI class_object_Get(
380 IWbemClassObject *iface,
387 struct class_object *co = impl_from_IWbemClassObject( iface );
388 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( co->iter );
390 TRACE("%p, %s, %08x, %p, %p, %p\n", iface, debugstr_w(wszName), lFlags, pVal, pType, plFlavor);
397 if ((hr = get_column_index( co->record->table, wszName, &index )) != S_OK) return hr;
398 return record_get_value( co->record, index, pVal, pType );
400 return get_propval( ec->query->view, co->index, wszName, pVal, pType, plFlavor );
403 static HRESULT record_set_value( struct record *record, UINT index, VARIANT *var )
409 if ((hr = to_longlong( var, &val, &type )) != S_OK) return hr;
410 if (type != record->fields[index].type) return WBEM_E_TYPE_MISMATCH;
412 if (type & CIM_FLAG_ARRAY)
414 record->fields[index].u.aval = (struct array *)(INT_PTR)val;
421 record->fields[index].u.sval = (WCHAR *)(INT_PTR)val;
427 record->fields[index].u.ival = val;
430 FIXME("unhandled type %u\n", type);
433 return WBEM_E_INVALID_PARAMETER;
436 static HRESULT WINAPI class_object_Put(
437 IWbemClassObject *iface,
443 struct class_object *co = impl_from_IWbemClassObject( iface );
444 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( co->iter );
446 TRACE("%p, %s, %08x, %p, %u\n", iface, debugstr_w(wszName), lFlags, pVal, Type);
453 if ((hr = get_column_index( co->record->table, wszName, &index )) != S_OK) return hr;
454 return record_set_value( co->record, index, pVal );
456 return put_propval( ec->query->view, co->index, wszName, pVal, Type );
459 static HRESULT WINAPI class_object_Delete(
460 IWbemClassObject *iface,
463 FIXME("%p, %s\n", iface, debugstr_w(wszName));
467 static HRESULT WINAPI class_object_GetNames(
468 IWbemClassObject *iface,
469 LPCWSTR wszQualifierName,
471 VARIANT *pQualifierVal,
474 struct class_object *co = impl_from_IWbemClassObject( iface );
475 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( co->iter );
477 TRACE("%p, %s, %08x, %p, %p\n", iface, debugstr_w(wszQualifierName), lFlags, pQualifierVal, pNames);
479 if (wszQualifierName || pQualifierVal)
481 FIXME("qualifier not supported\n");
484 if (lFlags != WBEM_FLAG_ALWAYS)
486 FIXME("flags %08x not supported\n", lFlags);
489 return get_properties( ec->query->view, pNames );
492 static HRESULT WINAPI class_object_BeginEnumeration(
493 IWbemClassObject *iface,
496 struct class_object *co = impl_from_IWbemClassObject( iface );
498 TRACE("%p, %08x\n", iface, lEnumFlags);
500 if (lEnumFlags) FIXME("flags 0x%08x not supported\n", lEnumFlags);
502 co->index_property = 0;
506 static HRESULT WINAPI class_object_Next(
507 IWbemClassObject *iface,
514 struct class_object *co = impl_from_IWbemClassObject( iface );
515 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( co->iter );
516 struct view *view = ec->query->view;
520 TRACE("%p, %08x, %p, %p, %p, %p\n", iface, lFlags, strName, pVal, pType, plFlavor);
522 if (!(property = get_property_name( co->name, co->index_property ))) return WBEM_S_NO_MORE_DATA;
523 if ((hr = get_propval( view, co->index, property, pVal, pType, plFlavor ) != S_OK))
525 SysFreeString( property );
529 co->index_property++;
533 static HRESULT WINAPI class_object_EndEnumeration(
534 IWbemClassObject *iface )
536 struct class_object *co = impl_from_IWbemClassObject( iface );
538 TRACE("%p\n", iface);
540 co->index_property = 0;
544 static HRESULT WINAPI class_object_GetPropertyQualifierSet(
545 IWbemClassObject *iface,
547 IWbemQualifierSet **ppQualSet )
549 FIXME("%p, %s, %p\n", iface, debugstr_w(wszProperty), ppQualSet);
553 static HRESULT WINAPI class_object_Clone(
554 IWbemClassObject *iface,
555 IWbemClassObject **ppCopy )
557 FIXME("%p, %p\n", iface, ppCopy);
561 static BSTR get_body_text( const struct table *table, UINT row, UINT *len )
563 static const WCHAR fmtW[] = {'\n','\t','%','s',' ','=',' ','%','s',';',0};
569 for (i = 0; i < table->num_cols; i++)
571 *len += sizeof(fmtW) / sizeof(fmtW[0]);
572 *len += strlenW( table->columns[i].name );
573 value = get_value_bstr( table, row, i );
574 *len += SysStringLen( value );
575 SysFreeString( value );
577 if (!(ret = SysAllocStringLen( NULL, *len ))) return NULL;
579 for (i = 0; i < table->num_cols; i++)
581 value = get_value_bstr( table, row, i );
582 p += sprintfW( p, fmtW, table->columns[i].name, value );
583 SysFreeString( value );
588 static BSTR get_object_text( const struct view *view, UINT index )
590 static const WCHAR fmtW[] =
591 {'\n','i','n','s','t','a','n','c','e',' ','o','f',' ','%','s','\n','{','%','s','\n','}',';',0};
592 UINT len, len_body, row = view->result[index];
595 len = sizeof(fmtW) / sizeof(fmtW[0]);
596 len += strlenW( view->table->name );
597 if (!(body = get_body_text( view->table, row, &len_body ))) return NULL;
600 if (!(ret = SysAllocStringLen( NULL, len ))) return NULL;
601 sprintfW( ret, fmtW, view->table->name, body );
602 SysFreeString( body );
606 static HRESULT WINAPI class_object_GetObjectText(
607 IWbemClassObject *iface,
609 BSTR *pstrObjectText )
611 struct class_object *co = impl_from_IWbemClassObject( iface );
612 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( co->iter );
613 struct view *view = ec->query->view;
616 TRACE("%p, %08x, %p\n", iface, lFlags, pstrObjectText);
618 if (lFlags) FIXME("flags %08x not implemented\n", lFlags);
620 if (!(text = get_object_text( view, co->index ))) return E_OUTOFMEMORY;
621 *pstrObjectText = text;
625 static HRESULT WINAPI class_object_SpawnDerivedClass(
626 IWbemClassObject *iface,
628 IWbemClassObject **ppNewClass )
630 FIXME("%p, %08x, %p\n", iface, lFlags, ppNewClass);
634 static HRESULT WINAPI class_object_SpawnInstance(
635 IWbemClassObject *iface,
637 IWbemClassObject **ppNewInstance )
639 struct class_object *co = impl_from_IWbemClassObject( iface );
640 struct enum_class_object *ec = impl_from_IEnumWbemClassObject( co->iter );
641 struct view *view = ec->query->view;
642 struct record *record;
644 TRACE("%p, %08x, %p\n", iface, lFlags, ppNewInstance);
646 if (!(record = create_record( view->table ))) return E_OUTOFMEMORY;
648 return create_class_object( co->name, NULL, 0, record, ppNewInstance );
651 static HRESULT WINAPI class_object_CompareTo(
652 IWbemClassObject *iface,
654 IWbemClassObject *pCompareTo )
656 FIXME("%p, %08x, %p\n", iface, lFlags, pCompareTo);
660 static HRESULT WINAPI class_object_GetPropertyOrigin(
661 IWbemClassObject *iface,
663 BSTR *pstrClassName )
665 FIXME("%p, %s, %p\n", iface, debugstr_w(wszName), pstrClassName);
669 static HRESULT WINAPI class_object_InheritsFrom(
670 IWbemClassObject *iface,
671 LPCWSTR strAncestor )
673 FIXME("%p, %s\n", iface, debugstr_w(strAncestor));
677 static UINT count_instances( IEnumWbemClassObject *iter )
680 while (!IEnumWbemClassObject_Skip( iter, WBEM_INFINITE, 1 )) count++;
681 IEnumWbemClassObject_Reset( iter );
685 static void set_default_value( CIMTYPE type, UINT val, BYTE *ptr )
693 *(UINT16 *)ptr = val;
699 *(UINT32 *)ptr = val;
702 FIXME("unhandled type %u\n", type);
707 static HRESULT create_signature_columns_and_data( IEnumWbemClassObject *iter, UINT *num_cols,
708 struct column **cols, BYTE **data )
710 static const WCHAR parameterW[] = {'P','a','r','a','m','e','t','e','r',0};
711 static const WCHAR typeW[] = {'T','y','p','e',0};
712 static const WCHAR varianttypeW[] = {'V','a','r','i','a','n','t','T','y','p','e',0};
713 static const WCHAR defaultvalueW[] = {'D','e','f','a','u','l','t','V','a','l','u','e',0};
714 struct column *columns;
716 IWbemClassObject *param;
718 HRESULT hr = E_OUTOFMEMORY;
723 count = count_instances( iter );
724 if (!(columns = heap_alloc( count * sizeof(struct column) ))) return E_OUTOFMEMORY;
725 if (!(row = heap_alloc_zero( count * sizeof(LONGLONG) ))) goto error;
729 IEnumWbemClassObject_Next( iter, WBEM_INFINITE, 1, ¶m, &count );
732 hr = IWbemClassObject_Get( param, parameterW, 0, &val, NULL, NULL );
733 if (hr != S_OK) goto error;
734 columns[i].name = heap_strdupW( V_BSTR( &val ) );
735 VariantClear( &val );
737 hr = IWbemClassObject_Get( param, typeW, 0, &val, NULL, NULL );
738 if (hr != S_OK) goto error;
739 columns[i].type = V_UI4( &val );
741 hr = IWbemClassObject_Get( param, varianttypeW, 0, &val, NULL, NULL );
742 if (hr != S_OK) goto error;
743 columns[i].vartype = V_UI4( &val );
745 hr = IWbemClassObject_Get( param, defaultvalueW, 0, &val, NULL, NULL );
746 if (hr != S_OK) goto error;
747 if (V_UI4( &val )) set_default_value( columns[i].type, V_UI4( &val ), row + offset );
748 offset += get_type_size( columns[i].type );
750 IWbemClassObject_Release( param );
759 for (; i >= 0; i--) heap_free( (WCHAR *)columns[i].name );
760 heap_free( columns );
765 static HRESULT create_signature_table( IEnumWbemClassObject *iter, WCHAR *name )
769 struct column *columns;
773 hr = create_signature_columns_and_data( iter, &num_cols, &columns, &row );
774 if (hr != S_OK) return hr;
776 if (!(table = create_table( name, num_cols, columns, 1, row, NULL )))
778 free_columns( columns, num_cols );
780 return E_OUTOFMEMORY;
782 if (!add_table( table )) free_table( table ); /* already exists */
786 static WCHAR *build_signature_table_name( const WCHAR *class, const WCHAR *method, enum param_direction dir )
788 static const WCHAR fmtW[] = {'_','_','%','s','_','%','s','_','%','s',0};
789 static const WCHAR outW[] = {'O','U','T',0};
790 static const WCHAR inW[] = {'I','N',0};
791 UINT len = SIZEOF(fmtW) + SIZEOF(outW) + strlenW( class ) + strlenW( method );
794 if (!(ret = heap_alloc( len * sizeof(WCHAR) ))) return NULL;
795 sprintfW( ret, fmtW, class, method, dir == PARAM_IN ? inW : outW );
796 return struprW( ret );
799 HRESULT create_signature( const WCHAR *class, const WCHAR *method, enum param_direction dir,
800 IWbemClassObject **sig )
802 static const WCHAR selectW[] =
803 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
804 '_','_','P','A','R','A','M','E','T','E','R','S',' ','W','H','E','R','E',' ',
805 'C','l','a','s','s','=','\'','%','s','\'',' ','A','N','D',' ',
806 'M','e','t','h','o','d','=','\'','%','s','\'',' ','A','N','D',' ',
807 'D','i','r','e','c','t','i','o','n','%','s',0};
808 static const WCHAR geW[] = {'>','=','0',0};
809 static const WCHAR leW[] = {'<','=','0',0};
810 UINT len = SIZEOF(selectW) + SIZEOF(geW);
811 IEnumWbemClassObject *iter;
815 len += strlenW( class ) + strlenW( method );
816 if (!(query = heap_alloc( len * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
817 sprintfW( query, selectW, class, method, dir >= 0 ? geW : leW );
819 hr = exec_query( query, &iter );
821 if (hr != S_OK) return hr;
823 if (!(name = build_signature_table_name( class, method, dir )))
825 IEnumWbemClassObject_Release( iter );
826 return E_OUTOFMEMORY;
828 hr = create_signature_table( iter, name );
829 IEnumWbemClassObject_Release( iter );
835 return get_object( name, sig );
838 static HRESULT WINAPI class_object_GetMethod(
839 IWbemClassObject *iface,
842 IWbemClassObject **ppInSignature,
843 IWbemClassObject **ppOutSignature )
845 struct class_object *co = impl_from_IWbemClassObject( iface );
848 TRACE("%p, %s, %08x, %p, %p\n", iface, debugstr_w(wszName), lFlags, ppInSignature, ppOutSignature);
850 hr = create_signature( co->name, wszName, PARAM_IN, ppInSignature );
851 if (hr != S_OK || !ppOutSignature) return hr;
853 hr = create_signature( co->name, wszName, PARAM_OUT, ppOutSignature );
854 if (hr != S_OK) IWbemClassObject_Release( *ppInSignature );
858 static HRESULT WINAPI class_object_PutMethod(
859 IWbemClassObject *iface,
862 IWbemClassObject *pInSignature,
863 IWbemClassObject *pOutSignature )
865 FIXME("%p, %s, %08x, %p, %p\n", iface, debugstr_w(wszName), lFlags, pInSignature, pOutSignature);
869 static HRESULT WINAPI class_object_DeleteMethod(
870 IWbemClassObject *iface,
873 FIXME("%p, %s\n", iface, debugstr_w(wszName));
877 static HRESULT WINAPI class_object_BeginMethodEnumeration(
878 IWbemClassObject *iface,
881 struct class_object *co = impl_from_IWbemClassObject( iface );
883 TRACE("%p, %08x\n", iface, lEnumFlags);
885 if (lEnumFlags) FIXME("flags 0x%08x not supported\n", lEnumFlags);
889 WARN("not allowed on instance\n");
890 return WBEM_E_ILLEGAL_OPERATION;
892 co->index_method = 0;
896 static HRESULT WINAPI class_object_NextMethod(
897 IWbemClassObject *iface,
900 IWbemClassObject **ppInSignature,
901 IWbemClassObject **ppOutSignature)
903 struct class_object *co = impl_from_IWbemClassObject( iface );
907 TRACE("%p, %08x, %p, %p, %p\n", iface, lFlags, pstrName, ppInSignature, ppOutSignature);
909 if (!(method = get_method_name( co->name, co->index_method ))) return WBEM_S_NO_MORE_DATA;
911 hr = create_signature( co->name, method, PARAM_IN, ppInSignature );
914 SysFreeString( method );
917 hr = create_signature( co->name, method, PARAM_OUT, ppOutSignature );
920 SysFreeString( method );
921 IWbemClassObject_Release( *ppInSignature );
931 static HRESULT WINAPI class_object_EndMethodEnumeration(
932 IWbemClassObject *iface )
934 struct class_object *co = impl_from_IWbemClassObject( iface );
936 TRACE("%p\n", iface);
938 co->index_method = 0;
942 static HRESULT WINAPI class_object_GetMethodQualifierSet(
943 IWbemClassObject *iface,
945 IWbemQualifierSet **ppQualSet)
947 FIXME("%p, %s, %p\n", iface, debugstr_w(wszMethod), ppQualSet);
951 static HRESULT WINAPI class_object_GetMethodOrigin(
952 IWbemClassObject *iface,
953 LPCWSTR wszMethodName,
956 FIXME("%p, %s, %p\n", iface, debugstr_w(wszMethodName), pstrClassName);
960 static const IWbemClassObjectVtbl class_object_vtbl =
962 class_object_QueryInterface,
964 class_object_Release,
965 class_object_GetQualifierSet,
969 class_object_GetNames,
970 class_object_BeginEnumeration,
972 class_object_EndEnumeration,
973 class_object_GetPropertyQualifierSet,
975 class_object_GetObjectText,
976 class_object_SpawnDerivedClass,
977 class_object_SpawnInstance,
978 class_object_CompareTo,
979 class_object_GetPropertyOrigin,
980 class_object_InheritsFrom,
981 class_object_GetMethod,
982 class_object_PutMethod,
983 class_object_DeleteMethod,
984 class_object_BeginMethodEnumeration,
985 class_object_NextMethod,
986 class_object_EndMethodEnumeration,
987 class_object_GetMethodQualifierSet,
988 class_object_GetMethodOrigin
991 HRESULT create_class_object( const WCHAR *name, IEnumWbemClassObject *iter, UINT index,
992 struct record *record, IWbemClassObject **obj )
994 struct class_object *co;
996 TRACE("%s, %p\n", debugstr_w(name), obj);
998 co = heap_alloc( sizeof(*co) );
999 if (!co) return E_OUTOFMEMORY;
1001 co->IWbemClassObject_iface.lpVtbl = &class_object_vtbl;
1003 co->name = heap_strdupW( name );
1007 return E_OUTOFMEMORY;
1011 co->index_method = 0;
1012 co->index_property = 0;
1013 co->record = record;
1014 if (iter) IEnumWbemClassObject_AddRef( iter );
1016 *obj = &co->IWbemClassObject_iface;
1018 TRACE("returning iface %p\n", *obj);