From: Dmitry Timoshkov dmitry@baikal.ru
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/wbemprox/builtin.c | 45 ++++++++++++++++++++++++++++++++++ dlls/wbemprox/tests/query.c | 48 +++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+)
diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c index 75f1475d11a..3c72ff4a480 100644 --- a/dlls/wbemprox/builtin.c +++ b/dlls/wbemprox/builtin.c @@ -298,6 +298,15 @@ static const struct column col_physicalmemory[] = { L"PartNumber", CIM_STRING }, { L"SerialNumber", CIM_STRING }, }; +static const struct column col_physicalmemoryarray[] = +{ + { L"Caption", CIM_STRING }, + { L"MaxCapacity", CIM_UINT32 }, + { L"MaxCapacityEx", CIM_UINT64 }, + { L"Model", CIM_STRING }, + { L"Name", CIM_STRING }, + { L"Status", CIM_STRING }, +}; static const struct column col_pnpentity[] = { { L"Caption", CIM_STRING|COL_FLAG_DYNAMIC }, @@ -792,6 +801,15 @@ struct record_physicalmemory const WCHAR *partnumber; const WCHAR *serial; }; +struct record_physicalmemoryarray +{ + const WCHAR *caption; + UINT32 max_capacity; + UINT64 max_capacity_ex; + const WCHAR *model; + const WCHAR *name; + const WCHAR *status; +}; struct record_pnpentity { const WCHAR *caption; @@ -3255,6 +3273,32 @@ static enum fill_status fill_physicalmemory( struct table *table, const struct e return status; }
+static enum fill_status fill_physicalmemoryarray( struct table *table, const struct expr *cond ) +{ + struct record_physicalmemoryarray *rec; + enum fill_status status = FILL_STATUS_UNFILTERED; + UINT row = 0; + UINT64 max_capacity; + + if (!resize_table( table, 1, sizeof(*rec) )) return FILL_STATUS_FAILED; + + max_capacity = get_total_physical_memory(); + + rec = (struct record_physicalmemoryarray *)table->data; + rec->caption = L"Physical Memory Array"; + rec->max_capacity = max_capacity > 0x400000 ? 0x400000 : max_capacity; + rec->max_capacity_ex = max_capacity; + rec->model = NULL; + rec->name = L"Physical Memory Array"; + rec->status = NULL; + if (!match_row( table, row, cond, &status )) free_row_values( table, row ); + else row++; + + TRACE("created %u rows\n", row); + table->num_rows = row; + return status; +} + static WCHAR *get_reg_value( HKEY key, const WCHAR *value ) { DWORD size, type; @@ -4477,6 +4521,7 @@ static struct table cimv2_builtin_classes[] = { L"Win32_PageFileUsage", C(col_pagefileusage), D(data_pagefileusage) }, { L"Win32_PhysicalMedia", C(col_physicalmedia), D(data_physicalmedia) }, { L"Win32_PhysicalMemory", C(col_physicalmemory), 0, 0, NULL, fill_physicalmemory }, + { L"Win32_PhysicalMemoryArray", C(col_physicalmemoryarray), 0, 0, NULL, fill_physicalmemoryarray }, { L"Win32_PnPEntity", C(col_pnpentity), 0, 0, NULL, fill_pnpentity }, { L"Win32_Printer", C(col_printer), 0, 0, NULL, fill_printer }, { L"Win32_Process", C(col_process), 0, 0, NULL, fill_process }, diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c index 07d1ca73622..9b5c15ef9fa 100644 --- a/dlls/wbemprox/tests/query.c +++ b/dlls/wbemprox/tests/query.c @@ -1727,6 +1727,53 @@ static void test_Win32_PhysicalMemory( IWbemServices *services ) SysFreeString( wql ); }
+static void test_Win32_PhysicalMemoryArray( IWbemServices *services ) +{ + BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_PhysicalMemoryArray" ); + IEnumWbemClassObject *result; + IWbemClassObject *obj; + CIMTYPE type; + VARIANT val; + DWORD count; + HRESULT hr; + + hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result ); + if (hr != S_OK) + { + win_skip( "Win32_PhysicalMemory not available\n" ); + return; + } + + for (;;) + { + hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count ); + if (hr != S_OK) break; + + check_property( obj, L"Caption", VT_BSTR, CIM_STRING ); + check_property( obj, L"MaxCapacity", VT_I4, CIM_UINT32 ); + check_property( obj, L"Model", VT_NULL, CIM_STRING ); + check_property( obj, L"Name", VT_BSTR, CIM_STRING ); + check_property( obj, L"Status", VT_NULL, CIM_STRING ); + + type = 0xdeadbeef; + VariantInit( &val ); + hr = IWbemClassObject_Get( obj, L"MaxCapacityEx", 0, &val, &type, NULL ); + ok( hr == S_OK || broken(hr == WBEM_E_NOT_FOUND) /* < win10 */, "got %#lx\n", hr ); + if (hr == S_OK) + { + ok( V_VT( &val ) == VT_BSTR, "unexpected variant type %#x\n", V_VT( &val ) ); + ok( type == CIM_UINT64, "unexpected type %#lx\n", type ); + VariantClear( &val ); + } + + IWbemClassObject_Release( obj ); + } + + IEnumWbemClassObject_Release( result ); + SysFreeString( query ); + SysFreeString( wql ); +} + static void test_Win32_IP4RouteTable( IWbemServices *services ) { BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_IP4RouteTable" ); @@ -2490,6 +2537,7 @@ START_TEST(query) test_Win32_OperatingSystem( services ); test_Win32_PageFileUsage( services ); test_Win32_PhysicalMemory( services ); + test_Win32_PhysicalMemoryArray( services ); test_Win32_PnPEntity( services ); test_Win32_Printer( services ); test_Win32_Process( services, FALSE );