Commit b1ceb785 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

wbemprox: Also return system properties from IWbemClassObject::GetNames.

parent 3f2ff588
......@@ -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++)
{
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;
}
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment