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@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2020-10-22 21:25:49 +02:00 committed by Alexandre Julliard
parent 3f2ff588ba
commit b1ceb7853c
2 changed files with 61 additions and 23 deletions

View File

@ -1375,40 +1375,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++)
if (!(flags & WBEM_FLAG_NONSYSTEM_ONLY)) count += ARRAY_SIZE(system_props);
if (!(flags & WBEM_FLAG_SYSTEM_ONLY))
{
BOOL is_system;
if (is_method( table, i )) continue;
if (!is_result_prop( view, table->columns[i].name )) continue;
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;
str = SysAllocString( table->columns[i].name );
if (!str || SafeArrayPutElement( sa, &j, str ) != S_OK)
for (i = 0; i < table->num_cols; i++)
{
SysFreeString( str );
SafeArrayDestroy( sa );
return E_OUTOFMEMORY;
if (!is_method( table, i ) && is_result_prop( view, table->columns[i].name )) count++;
}
SysFreeString( str );
j++;
}
if (!(sa = SafeArrayCreateVector( VT_BSTR, 0, count ))) return E_OUTOFMEMORY;
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 );
j++;
}
}
*props = sa;
return S_OK;
}

View File

@ -460,6 +460,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;
@ -484,6 +486,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, L"GetOwner", 0, &sig_in, NULL );
ok( hr == S_OK, "failed to get GetOwner method %08x\n", hr );