wbemprox: Implement Win32_PhysicalMemory.MemoryType.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2016-11-16 10:02:07 -06:00 committed by Alexandre Julliard
parent 710abd65bb
commit b05928aae0
2 changed files with 77 additions and 7 deletions

View File

@ -252,6 +252,8 @@ static const WCHAR prop_mediatypeW[] =
{'M','e','d','i','a','T','y','p','e',0}; {'M','e','d','i','a','T','y','p','e',0};
static const WCHAR prop_memberW[] = static const WCHAR prop_memberW[] =
{'M','e','m','b','e','r',0}; {'M','e','m','b','e','r',0};
static const WCHAR prop_memorytypeW[] =
{'M','e','m','o','r','y','T','y','p','e',0};
static const WCHAR prop_methodW[] = static const WCHAR prop_methodW[] =
{'M','e','t','h','o','d',0}; {'M','e','t','h','o','d',0};
static const WCHAR prop_modelW[] = static const WCHAR prop_modelW[] =
@ -540,7 +542,8 @@ static const struct column col_physicalmedia[] =
}; };
static const struct column col_physicalmemory[] = static const struct column col_physicalmemory[] =
{ {
{ prop_capacityW, CIM_UINT64 } { prop_capacityW, CIM_UINT64 },
{ prop_memorytypeW, CIM_UINT16, VT_I4 }
}; };
static const struct column col_printer[] = static const struct column col_printer[] =
{ {
@ -924,6 +927,7 @@ struct record_physicalmedia
struct record_physicalmemory struct record_physicalmemory
{ {
UINT64 capacity; UINT64 capacity;
UINT16 memorytype;
}; };
struct record_printer struct record_printer
{ {
@ -2304,6 +2308,7 @@ static enum fill_status fill_physicalmemory( struct table *table, const struct e
rec = (struct record_physicalmemory *)table->data; rec = (struct record_physicalmemory *)table->data;
rec->capacity = get_total_physical_memory(); rec->capacity = get_total_physical_memory();
rec->memorytype = 9; /* RAM */
if (!match_row( table, row, cond, &status )) free_row_values( table, row ); if (!match_row( table, row, cond, &status )) free_row_values( table, row );
else row++; else row++;

View File

@ -482,9 +482,11 @@ static void test_Win32_Process( IWbemServices *services )
static void test_Win32_ComputerSystem( IWbemServices *services ) static void test_Win32_ComputerSystem( IWbemServices *services )
{ {
static const WCHAR backslashW[] = {'\\',0};
static const WCHAR memorytypeW[] = {'M','e','m','o','r','y','T','y','p','e',0};
static const WCHAR modelW[] = {'M','o','d','e','l',0};
static const WCHAR nameW[] = {'N','a','m','e',0}; static const WCHAR nameW[] = {'N','a','m','e',0};
static const WCHAR usernameW[] = {'U','s','e','r','N','a','m','e',0}; static const WCHAR usernameW[] = {'U','s','e','r','N','a','m','e',0};
static const WCHAR backslashW[] = {'\\',0};
static const WCHAR queryW[] = static const WCHAR queryW[] =
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_', {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
'C','o','m','p','u','t','e','r','S','y','s','t','e','m',0}; 'C','o','m','p','u','t','e','r','S','y','s','t','e','m',0};
@ -524,6 +526,20 @@ static void test_Win32_ComputerSystem( IWbemServices *services )
hr = IEnumWbemClassObject_Next( result, 10000, 1, &service, &count ); hr = IEnumWbemClassObject_Next( result, 10000, 1, &service, &count );
ok( hr == S_OK, "got %08x\n", hr ); ok( hr == S_OK, "got %08x\n", hr );
type = 0xdeadbeef;
VariantInit( &value );
hr = IWbemClassObject_Get( service, memorytypeW, 0, &value, &type, NULL );
ok( hr == WBEM_E_NOT_FOUND, "got %08x\n", hr );
type = 0xdeadbeef;
VariantInit( &value );
hr = IWbemClassObject_Get( service, modelW, 0, &value, &type, NULL );
ok( hr == S_OK, "failed to get model %08x\n", hr );
ok( V_VT( &value ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &value ) );
ok( type == CIM_STRING, "unexpected type 0x%x\n", type );
trace( "model: %s\n", wine_dbgstr_w(V_BSTR( &value )) );
VariantClear( &value );
type = 0xdeadbeef; type = 0xdeadbeef;
VariantInit( &value ); VariantInit( &value );
hr = IWbemClassObject_Get( service, nameW, 0, &value, &type, NULL ); hr = IWbemClassObject_Get( service, nameW, 0, &value, &type, NULL );
@ -1206,7 +1222,7 @@ static void test_ComputerSystemProduct( IWbemServices *services )
'C','o','m','p','u','t','e','r','S','y','s','t','e','m','P','r','o','d','u','c','t',0}; 'C','o','m','p','u','t','e','r','S','y','s','t','e','m','P','r','o','d','u','c','t',0};
BSTR wql = SysAllocString( wqlW ), query = SysAllocString( queryW ); BSTR wql = SysAllocString( wqlW ), query = SysAllocString( queryW );
IEnumWbemClassObject *result; IEnumWbemClassObject *result;
IWbemClassObject *service; IWbemClassObject *obj;
VARIANT value; VARIANT value;
CIMTYPE type; CIMTYPE type;
HRESULT hr; HRESULT hr;
@ -1219,24 +1235,72 @@ static void test_ComputerSystemProduct( IWbemServices *services )
return; return;
} }
hr = IEnumWbemClassObject_Next( result, 10000, 1, &service, &count ); hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
ok( hr == S_OK, "got %08x\n", hr ); ok( hr == S_OK, "got %08x\n", hr );
type = 0xdeadbeef; type = 0xdeadbeef;
VariantInit( &value ); VariantInit( &value );
hr = IWbemClassObject_Get( service, uuidW, 0, &value, &type, NULL ); hr = IWbemClassObject_Get( obj, uuidW, 0, &value, &type, NULL );
ok( hr == S_OK, "failed to get computer name %08x\n", hr ); ok( hr == S_OK, "failed to get computer name %08x\n", hr );
ok( V_VT( &value ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &value ) ); ok( V_VT( &value ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &value ) );
ok( type == CIM_STRING, "unexpected type 0x%x\n", type ); ok( type == CIM_STRING, "unexpected type 0x%x\n", type );
trace( "uuid %s\n", wine_dbgstr_w(V_BSTR(&value)) ); trace( "uuid %s\n", wine_dbgstr_w(V_BSTR(&value)) );
VariantClear( &value ); VariantClear( &value );
IWbemClassObject_Release( service ); IWbemClassObject_Release( obj );
IEnumWbemClassObject_Release( result ); IEnumWbemClassObject_Release( result );
SysFreeString( query ); SysFreeString( query );
SysFreeString( wql ); SysFreeString( wql );
} }
static void test_PhysicalMemory( IWbemServices *services )
{
static const WCHAR capacityW[] = {'C','a','p','a','c','i','t','y',0};
static const WCHAR memorytypeW[] = {'M','e','m','o','r','y','T','y','p','e',0};
static const WCHAR queryW[] =
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_',
'P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
BSTR wql = SysAllocString( wqlW ), query = SysAllocString( queryW );
IEnumWbemClassObject *result;
IWbemClassObject *obj;
VARIANT val;
CIMTYPE type;
HRESULT hr;
DWORD count;
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
if (hr != S_OK)
{
win_skip( "Win32_PhysicalMemory not available\n" );
return;
}
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
ok( hr == S_OK, "got %08x\n", hr );
type = 0xdeadbeef;
VariantInit( &val );
hr = IWbemClassObject_Get( obj, capacityW, 0, &val, &type, NULL );
ok( hr == S_OK, "failed to get capacity %08x\n", hr );
ok( V_VT( &val ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &val ) );
ok( type == CIM_UINT64, "unexpected type 0x%x\n", type );
trace( "capacity %s\n", wine_dbgstr_w(V_BSTR( &val )) );
VariantClear( &val );
type = 0xdeadbeef;
VariantInit( &val );
hr = IWbemClassObject_Get( obj, memorytypeW, 0, &val, &type, NULL );
ok( hr == S_OK, "failed to get memory type %08x\n", hr );
ok( V_VT( &val ) == VT_I4, "unexpected variant type 0x%x\n", V_VT( &val ) );
ok( type == CIM_UINT16, "unexpected type 0x%x\n", type );
trace( "memorytype %u\n", V_I4( &val ) );
VariantClear( &val );
IWbemClassObject_Release( obj );
SysFreeString( query );
SysFreeString( wql );
}
START_TEST(query) START_TEST(query)
{ {
static const WCHAR cimv2W[] = {'R','O','O','T','\\','C','I','M','V','2',0}; static const WCHAR cimv2W[] = {'R','O','O','T','\\','C','I','M','V','2',0};
@ -1276,6 +1340,7 @@ START_TEST(query)
test_SystemSecurity( services ); test_SystemSecurity( services );
test_OperatingSystem( services ); test_OperatingSystem( services );
test_ComputerSystemProduct( services ); test_ComputerSystemProduct( services );
test_PhysicalMemory( services );
SysFreeString( path ); SysFreeString( path );
IWbemServices_Release( services ); IWbemServices_Release( services );