From 8343aed4c299b691d76b2c6f3554cd98b6ee2ffd Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Wed, 30 Apr 2014 10:19:30 +0200 Subject: [PATCH] wbemprox: Return selected properties only from IWbemClassObject::Next. --- dlls/wbemprox/class.c | 29 ++++++++++++++++++----------- dlls/wbemprox/query.c | 4 ++-- dlls/wbemprox/table.c | 25 ------------------------- dlls/wbemprox/wbemprox_private.h | 3 ++- 4 files changed, 22 insertions(+), 39 deletions(-) diff --git a/dlls/wbemprox/class.c b/dlls/wbemprox/class.c index 5a9e2e405b3..afb9f8c1deb 100644 --- a/dlls/wbemprox/class.c +++ b/dlls/wbemprox/class.c @@ -511,23 +511,30 @@ static HRESULT WINAPI class_object_Next( CIMTYPE *pType, LONG *plFlavor ) { - struct class_object *co = impl_from_IWbemClassObject( iface ); - struct enum_class_object *ec = impl_from_IEnumWbemClassObject( co->iter ); - struct view *view = ec->query->view; - BSTR property; + struct class_object *obj = impl_from_IWbemClassObject( iface ); + struct enum_class_object *iter = impl_from_IEnumWbemClassObject( obj->iter ); + struct view *view = iter->query->view; + BSTR prop; HRESULT hr; + UINT i; TRACE("%p, %08x, %p, %p, %p, %p\n", iface, lFlags, strName, pVal, pType, plFlavor); - if (!(property = get_property_name( co->name, co->index_property ))) return WBEM_S_NO_MORE_DATA; - if ((hr = get_propval( view, co->index, property, pVal, pType, plFlavor ) != S_OK)) + for (i = obj->index_property; i < view->table->num_cols; i++) { - SysFreeString( property ); - return hr; + if (is_method( view->table, i )) continue; + if (!is_selected_prop( view, view->table->columns[i].name )) continue; + if (!(prop = SysAllocString( view->table->columns[i].name ))) return E_OUTOFMEMORY; + if ((hr = get_propval( view, obj->index, prop, pVal, pType, plFlavor )) != S_OK) + { + SysFreeString( prop ); + return hr; + } + obj->index_property = i + 1; + *strName = prop; + return S_OK; } - *strName = property; - co->index_property++; - return S_OK; + return WBEM_S_NO_MORE_DATA; } static HRESULT WINAPI class_object_EndEnumeration( diff --git a/dlls/wbemprox/query.c b/dlls/wbemprox/query.c index e4c4fcda446..c97b52b8d1c 100644 --- a/dlls/wbemprox/query.c +++ b/dlls/wbemprox/query.c @@ -424,7 +424,7 @@ done: return hr; } -static BOOL is_selected_prop( const struct view *view, const WCHAR *name ) +BOOL is_selected_prop( const struct view *view, const WCHAR *name ) { const struct property *prop = view->proplist; @@ -563,7 +563,7 @@ done: return ret; } -static inline BOOL is_method( const struct table *table, UINT column ) +BOOL is_method( const struct table *table, UINT column ) { return table->columns[column].type & COL_FLAG_METHOD; } diff --git a/dlls/wbemprox/table.c b/dlls/wbemprox/table.c index bbd3f5ebf5b..7a5b1c18012 100644 --- a/dlls/wbemprox/table.c +++ b/dlls/wbemprox/table.c @@ -406,28 +406,3 @@ BSTR get_method_name( const WCHAR *class, UINT index ) release_table( table ); return NULL; } - -BSTR get_property_name( const WCHAR *class, UINT index ) -{ - struct table *table; - UINT i, count = 0; - BSTR ret; - - if (!(table = grab_table( class ))) return NULL; - - for (i = 0; i < table->num_cols; i++) - { - if (!(table->columns[i].type & COL_FLAG_METHOD)) - { - if (index == count) - { - ret = SysAllocString( table->columns[i].name ); - release_table( table ); - return ret; - } - count++; - } - } - release_table( table ); - return NULL; -} diff --git a/dlls/wbemprox/wbemprox_private.h b/dlls/wbemprox/wbemprox_private.h index c047ac14b3d..0eeb0c75f00 100644 --- a/dlls/wbemprox/wbemprox_private.h +++ b/dlls/wbemprox/wbemprox_private.h @@ -192,6 +192,7 @@ HRESULT get_column_index( const struct table *, const WCHAR *, UINT * ) DECLSPEC HRESULT get_value( const struct table *, UINT, UINT, LONGLONG * ) DECLSPEC_HIDDEN; BSTR get_value_bstr( const struct table *, UINT, UINT ) DECLSPEC_HIDDEN; HRESULT set_value( const struct table *, UINT, UINT, LONGLONG, CIMTYPE ) DECLSPEC_HIDDEN; +BOOL is_method( const struct table *, UINT ) DECLSPEC_HIDDEN; HRESULT get_method( const struct table *, const WCHAR *, class_method ** ) DECLSPEC_HIDDEN; HRESULT get_propval( const struct view *, UINT, const WCHAR *, VARIANT *, CIMTYPE *, LONG * ) DECLSPEC_HIDDEN; @@ -200,10 +201,10 @@ HRESULT to_longlong( VARIANT *, LONGLONG *, CIMTYPE * ) DECLSPEC_HIDDEN; SAFEARRAY *to_safearray( const struct array *, CIMTYPE ) DECLSPEC_HIDDEN; VARTYPE to_vartype( CIMTYPE ) DECLSPEC_HIDDEN; void destroy_array( struct array *, CIMTYPE ) DECLSPEC_HIDDEN; +BOOL is_selected_prop( const struct view *, const WCHAR * ) DECLSPEC_HIDDEN; HRESULT get_properties( const struct view *, LONG, SAFEARRAY ** ) DECLSPEC_HIDDEN; HRESULT get_object( const WCHAR *, IWbemClassObject ** ) DECLSPEC_HIDDEN; BSTR get_method_name( const WCHAR *, UINT ) DECLSPEC_HIDDEN; -BSTR get_property_name( const WCHAR *, UINT ) DECLSPEC_HIDDEN; void set_variant( VARTYPE, LONGLONG, void *, VARIANT * ) DECLSPEC_HIDDEN; HRESULT create_signature( const WCHAR *, const WCHAR *, enum param_direction, IWbemClassObject ** ) DECLSPEC_HIDDEN;