Hans Leidekker : wbemprox: Also return system properties from IWbemClassObject::GetNames.
Alexandre Julliard
julliard at winehq.org
Tue Mar 23 15:07:42 CDT 2021
Module: wine
Branch: oldstable
Commit: 8f18677406cf17b41cadf2af4ce73b7c89128023
URL: https://source.winehq.org/git/wine.git/?a=commit;h=8f18677406cf17b41cadf2af4ce73b7c89128023
Author: Hans Leidekker <hans at codeweavers.com>
Date: Thu Oct 22 21:25:49 2020 +0200
wbemprox: Also return system properties from IWbemClassObject::GetNames.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50038
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit b1ceb7853cf0d7abe99fd917e65a22507795f7de)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/wbemprox/query.c | 61 ++++++++++++++++++++++++++++++---------------
dlls/wbemprox/tests/query.c | 17 +++++++++++++
2 files changed, 58 insertions(+), 20 deletions(-)
diff --git a/dlls/wbemprox/query.c b/dlls/wbemprox/query.c
index f46dcd922f9..7778d12b759 100644
--- a/dlls/wbemprox/query.c
+++ b/dlls/wbemprox/query.c
@@ -1397,40 +1397,61 @@ 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"__SERVER", L"__NAMESPACE", L"__PATH" };
SAFEARRAY *sa;
BSTR str;
- UINT i, table_index, result_index, num_props;
+ UINT i, table_index, result_index, count = 0;
struct table *table;
HRESULT hr;
- LONG j;
+ LONG j = 0;
if ((hr = map_view_index( view, index, &table_index, &result_index )) != S_OK) return hr;
-
- num_props = count_result_properties( view, table_index );
- if (!(sa = SafeArrayCreateVector( VT_BSTR, 0, num_props ))) return E_OUTOFMEMORY;
-
table = view->table[table_index];
- for (i = 0, j = 0; i < table->num_cols; i++)
- {
- BOOL is_system;
- if (is_method( table, i )) continue;
- if (!is_result_prop( view, table->columns[i].name )) continue;
+ if (!(flags & WBEM_FLAG_NONSYSTEM_ONLY)) count += ARRAY_SIZE(system_props);
+ if (!(flags & WBEM_FLAG_SYSTEM_ONLY))
+ {
+ for (i = 0; i < table->num_cols; i++)
+ {
+ if (!is_method( table, i ) && is_result_prop( view, table->columns[i].name )) count++;
+ }
+ }
- is_system = is_system_prop( table->columns[i].name );
- if ((flags & WBEM_FLAG_NONSYSTEM_ONLY) && is_system) continue;
- else if ((flags & WBEM_FLAG_SYSTEM_ONLY) && !is_system) continue;
+ if (!(sa = SafeArrayCreateVector( VT_BSTR, 0, count ))) return E_OUTOFMEMORY;
- str = SysAllocString( table->columns[i].name );
- if (!str || SafeArrayPutElement( sa, &j, str ) != S_OK)
+ if (!(flags & WBEM_FLAG_NONSYSTEM_ONLY))
+ {
+ for (j = 0; j < ARRAY_SIZE(system_props); j++)
+ {
+ str = SysAllocString( system_props[j] );
+ if (!str || SafeArrayPutElement( sa, &j, str ) != S_OK)
+ {
+ SysFreeString( str );
+ SafeArrayDestroy( sa );
+ return E_OUTOFMEMORY;
+ }
+ SysFreeString( str );
+ }
+ }
+ if (!(flags & WBEM_FLAG_SYSTEM_ONLY))
+ {
+ for (i = 0; i < table->num_cols; i++)
{
+ if (is_method( table, i ) || !is_result_prop( view, table->columns[i].name )) continue;
+
+ str = SysAllocString( table->columns[i].name );
+ if (!str || SafeArrayPutElement( sa, &j, str ) != S_OK)
+ {
+ SysFreeString( str );
+ SafeArrayDestroy( sa );
+ return E_OUTOFMEMORY;
+ }
SysFreeString( str );
- SafeArrayDestroy( sa );
- return E_OUTOFMEMORY;
+ j++;
}
- SysFreeString( str );
- j++;
}
+
*props = sa;
return S_OK;
}
diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c
index 31cf93b4ac9..b254837afd2 100644
--- a/dlls/wbemprox/tests/query.c
+++ b/dlls/wbemprox/tests/query.c
@@ -494,6 +494,8 @@ static void test_Win32_Process( IWbemServices *services, BOOL use_full_path )
IWbemClassObject *process, *sig_in, *out;
IWbemQualifierSet *qualifiers;
VARIANT retval, val;
+ SAFEARRAY *names;
+ LONG bound, i;
DWORD full_path_len = 0;
LONG flavor;
CIMTYPE type;
@@ -518,6 +520,21 @@ static void test_Win32_Process( IWbemServices *services, BOOL use_full_path )
win_skip( "Win32_Process not available\n" );
return;
}
+ names = NULL;
+ hr = IWbemClassObject_GetNames( process, NULL, 0, NULL, &names );
+ ok( hr == S_OK, "got %08x\n", hr );
+ ok( names != NULL, "names not set\n" );
+ hr = SafeArrayGetUBound( names, 1, &bound );
+ ok( hr == S_OK, "got %08x\n", hr );
+ for (i = 0; i <= bound; i++)
+ {
+ BSTR str;
+ hr = SafeArrayGetElement( names, &i, &str );
+ ok( hr == S_OK, "%d: got %08x\n", i, hr );
+ SysFreeString( str );
+ }
+ SafeArrayDestroy( names );
+
sig_in = (void*)0xdeadbeef;
hr = IWbemClassObject_GetMethod( process, getownerW, 0, &sig_in, NULL );
ok( hr == S_OK, "failed to get GetOwner method %08x\n", hr );
More information about the wine-cvs
mailing list