From: Paul Gofman pgofman@codeweavers.com
--- dlls/wbemprox/class.c | 18 ++++++--- dlls/wbemprox/query.c | 13 ++++--- dlls/wbemprox/tests/query.c | 63 ++++++++++++++++++++++++++++++++ dlls/wbemprox/wbemprox_private.h | 3 ++ 4 files changed, 87 insertions(+), 10 deletions(-)
diff --git a/dlls/wbemprox/class.c b/dlls/wbemprox/class.c index ee215b1aced..19f8d79d51b 100644 --- a/dlls/wbemprox/class.c +++ b/dlls/wbemprox/class.c @@ -539,7 +539,7 @@ static HRESULT WINAPI class_object_Next( struct table *table = get_view_table( view, obj->index ); BSTR prop; HRESULT hr; - UINT i; + UINT i, view_idx_start;
TRACE( "%p, %#lx, %p, %p, %p, %p\n", iface, lFlags, strName, pVal, pType, plFlavor );
@@ -549,11 +549,19 @@ static HRESULT WINAPI class_object_Next( return WBEM_E_INVALID_PARAMETER; }
- for (i = obj->index_property; i < table->num_cols; i++) + view_idx_start = obj->record ? 0 : system_prop_count; + for (i = obj->index_property; i < table->num_cols + view_idx_start; i++) { - if (is_method( table, i )) continue; - if (!is_result_prop( view, table->columns[i].name )) continue; - if (!(prop = SysAllocString( table->columns[i].name ))) return E_OUTOFMEMORY; + if (i < view_idx_start) + { + if (!(prop = SysAllocString( system_props[i] ))) return E_OUTOFMEMORY; + } + else + { + if (is_method( table, i - view_idx_start )) continue; + if (!is_result_prop( view, table->columns[i - view_idx_start].name )) continue; + if (!(prop = SysAllocString( table->columns[i - view_idx_start].name ))) return E_OUTOFMEMORY; + } if (obj->record) { UINT index; diff --git a/dlls/wbemprox/query.c b/dlls/wbemprox/query.c index 9e080f9a03d..868a5fd9a71 100644 --- a/dlls/wbemprox/query.c +++ b/dlls/wbemprox/query.c @@ -815,6 +815,12 @@ static BOOL is_system_prop( const WCHAR *name ) return (name[0] == '_' && name[1] == '_'); }
+const WCHAR * const system_props[] = + { L"__GENUS", L"__CLASS", L"__RELPATH", L"__PROPERTY_COUNT", L"__DERIVATION", L"__SERVER", L"__NAMESPACE", + L"__PATH" }; + +unsigned int system_prop_count = ARRAY_SIZE(system_props); + static BSTR build_proplist( const struct table *table, UINT row, UINT count, UINT *len ) { UINT i, j, offset; @@ -1413,9 +1419,6 @@ HRESULT put_propval( const struct view *view, UINT index, const WCHAR *name, VAR
HRESULT get_properties( const struct view *view, UINT index, LONG flags, SAFEARRAY **props ) { - static const WCHAR * const system_props[] = - { L"__GENUS", L"__CLASS", L"__RELPATH", L"__PROPERTY_COUNT", L"__DERIVATION", L"__SERVER", L"__NAMESPACE", - L"__PATH" }; SAFEARRAY *sa; BSTR str; UINT i, table_index, result_index, count = 0; @@ -1426,7 +1429,7 @@ HRESULT get_properties( const struct view *view, UINT index, LONG flags, SAFEARR if ((hr = map_view_index( view, index, &table_index, &result_index )) != S_OK) return hr; table = view->table[table_index];
- if (!(flags & WBEM_FLAG_NONSYSTEM_ONLY)) count += ARRAY_SIZE(system_props); + if (!(flags & WBEM_FLAG_NONSYSTEM_ONLY)) count += system_prop_count; if (!(flags & WBEM_FLAG_SYSTEM_ONLY)) { for (i = 0; i < table->num_cols; i++) @@ -1439,7 +1442,7 @@ HRESULT get_properties( const struct view *view, UINT index, LONG flags, SAFEARR
if (!(flags & WBEM_FLAG_NONSYSTEM_ONLY)) { - for (j = 0; j < ARRAY_SIZE(system_props); j++) + for (j = 0; j < system_prop_count; j++) { str = SysAllocString( system_props[j] ); if (!str || SafeArrayPutElement( sa, &j, str ) != S_OK) diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c index 8fe5b502259..e49aa575611 100644 --- a/dlls/wbemprox/tests/query.c +++ b/dlls/wbemprox/tests/query.c @@ -216,6 +216,68 @@ static void test_like_query( IWbemServices *services ) }
+static void test_IWbemClassObject_Next( IWbemServices *services ) +{ + struct + { + const WCHAR *name; + BOOL found; + } + system_props[] = + { + {L"__GENUS"}, {L"__CLASS"}, {L"__RELPATH"}, {L"__PROPERTY_COUNT"}, {L"__DERIVATION"}, + {L"__SERVER"}, {L"__NAMESPACE"}, {L"__PATH"}, + }; + + BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_LogicalDisk" ); + BSTR name; + IEnumWbemClassObject *result; + IWbemClassObject *obj; + HRESULT hr; + unsigned int i, j; + DWORD count; + + hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result ); + if (hr != S_OK) + { + win_skip( "Win32_Volume not available\n" ); + return; + } + + hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count ); + ok( hr == S_OK, "got %#lx.\n", hr ); + + IWbemClassObject_BeginEnumeration(obj, 0); + hr = IWbemClassObject_Next( obj, WBEM_FLAG_SYSTEM_ONLY, &name, NULL, NULL, NULL ); + ok( hr == WBEM_E_INVALID_PARAMETER, "got %#lx.\n", hr ); + hr = IWbemClassObject_Next( obj, WBEM_FLAG_NONSYSTEM_ONLY, &name, NULL, NULL, NULL ); + ok( hr == WBEM_E_INVALID_PARAMETER, "got %#lx.\n", hr ); + + for (i = 0; !(hr = IWbemClassObject_Next( obj, 0, &name, NULL, NULL, NULL )); ++i) + { + ok( hr == S_OK, "got %#lx\n", hr ); + for (j = 0; j < ARRAY_SIZE(system_props); ++j) + { + if (!wcscmp(name, system_props[j].name)) + { + system_props[j].found = TRUE; + break; + } + } + SysFreeString( name ); + } + ok( hr == WBEM_S_NO_MORE_DATA, "got %#lx.\n", hr ); + IWbemClassObject_Release( obj ); + + for (i = 0; i < ARRAY_SIZE(system_props); ++i) + ok( system_props[i].found, "%s not found.\n", debugstr_w(system_props[i].name) ); + + IEnumWbemClassObject_Release( result ); + SysFreeString( query ); + SysFreeString( wql ); +} + + static void test_associators( IWbemServices *services ) { static const WCHAR *test[] = @@ -2649,6 +2711,7 @@ START_TEST(query) test_query_semisync( services ); test_select( services ); test_like_query( services ); + test_IWbemClassObject_Next( services );
/* classes */ test_SoftwareLicensingProduct( services ); diff --git a/dlls/wbemprox/wbemprox_private.h b/dlls/wbemprox/wbemprox_private.h index 632d448b8cd..b8d2cb56ad5 100644 --- a/dlls/wbemprox/wbemprox_private.h +++ b/dlls/wbemprox/wbemprox_private.h @@ -290,3 +290,6 @@ static inline BOOL is_digit(WCHAR c) { return '0' <= c && c <= '9'; } + +extern const WCHAR * const system_props[]; +extern unsigned int system_prop_count;