2012-06-18 09:32:22 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Hans Leidekker for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "windows.h"
|
|
|
|
#include "ocidl.h"
|
2014-08-04 23:29:16 +02:00
|
|
|
#include "sddl.h"
|
2012-06-18 09:32:22 +02:00
|
|
|
#include "initguid.h"
|
|
|
|
#include "objidl.h"
|
|
|
|
#include "wbemcli.h"
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
static HRESULT exec_query( IWbemServices *services, const WCHAR *str, IEnumWbemClassObject **result )
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IWbemClassObject *obj;
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( str );
|
2012-06-18 09:32:22 +02:00
|
|
|
LONG flags = WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_FORWARD_ONLY;
|
|
|
|
ULONG count;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, flags, NULL, result );
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
trace("%s\n", wine_dbgstr_w(str));
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
VARIANT var;
|
2019-08-28 14:14:29 +02:00
|
|
|
IWbemQualifierSet *qualifiers;
|
|
|
|
SAFEARRAY *names;
|
2012-06-18 09:32:22 +02:00
|
|
|
|
2014-03-21 19:01:09 +01:00
|
|
|
IEnumWbemClassObject_Next( *result, 10000, 1, &obj, &count );
|
2012-06-18 09:32:22 +02:00
|
|
|
if (!count) break;
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
if (IWbemClassObject_Get( obj, L"Caption", 0, &var, NULL, NULL ) == WBEM_S_NO_ERROR)
|
2012-06-18 09:32:22 +02:00
|
|
|
{
|
|
|
|
trace("caption: %s\n", wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
VariantClear( &var );
|
|
|
|
}
|
2020-02-25 11:39:53 +01:00
|
|
|
if (IWbemClassObject_Get( obj, L"Description", 0, &var, NULL, NULL ) == WBEM_S_NO_ERROR)
|
2012-06-18 09:32:22 +02:00
|
|
|
{
|
|
|
|
trace("description: %s\n", wine_dbgstr_w(V_BSTR(&var)));
|
|
|
|
VariantClear( &var );
|
|
|
|
}
|
2019-08-28 14:14:29 +02:00
|
|
|
|
|
|
|
hr = IWbemClassObject_GetQualifierSet( obj, &qualifiers );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2019-08-28 14:14:29 +02:00
|
|
|
|
|
|
|
hr = IWbemQualifierSet_GetNames( qualifiers, 0, &names );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2019-08-28 14:14:29 +02:00
|
|
|
|
|
|
|
SafeArrayDestroy( names );
|
|
|
|
IWbemQualifierSet_Release( qualifiers );
|
2012-06-18 09:32:22 +02:00
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SysFreeString( wql );
|
|
|
|
SysFreeString( query );
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2012-10-12 14:26:58 +02:00
|
|
|
static void test_select( IWbemServices *services )
|
2012-06-18 09:32:22 +02:00
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
static const WCHAR *test[] =
|
|
|
|
{
|
|
|
|
L"SELECT HOTFIXID FROM Win32_QuickFixEngineering",
|
|
|
|
L"SELECT * FROM Win32_BIOS",
|
|
|
|
L"SELECT * FROM Win32_LogicalDisk WHERE \"NTFS\" = FileSystem",
|
|
|
|
L"SELECT a FROM b",
|
|
|
|
L"SELECT a FROM Win32_Bios",
|
|
|
|
L"SELECT Description FROM Win32_Bios",
|
|
|
|
L"SELECT * FROM Win32_Process WHERE Caption LIKE '%%REGEDIT%'",
|
|
|
|
L"SELECT * FROM Win32_DiskDrive WHERE DeviceID=\"\\\\\\\\.\\\\PHYSICALDRIVE0\"",
|
|
|
|
L"SELECT\na\rFROM\tb",
|
|
|
|
L"SELECT * FROM Win32_Process WHERE Caption LIKE \"%firefox.exe\"",
|
|
|
|
L"SELECT * FROM Win32_VideoController where availability = '3'",
|
|
|
|
L"SELECT * FROM Win3_BIOS WHERE NAME <> NULL",
|
|
|
|
L"SELECT * FROM Win32_BIOS WHERE NULL = NAME",
|
|
|
|
L"SELECT * FROM Win32_LogicalDiskToPartition",
|
|
|
|
L"SELECT * FROM Win32_DiskDriveToDiskPartition",
|
|
|
|
};
|
2012-06-18 09:32:22 +02:00
|
|
|
HRESULT hr;
|
|
|
|
IEnumWbemClassObject *result;
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" );
|
|
|
|
BSTR sql = SysAllocString( L"SQL" );
|
|
|
|
BSTR query = SysAllocString( L"SELECT * FROM Win32_BIOS" );
|
2012-06-18 09:32:22 +02:00
|
|
|
UINT i;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, NULL, NULL, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == WBEM_E_INVALID_PARAMETER, "query failed %#lx\n", hr );
|
2012-06-18 09:32:22 +02:00
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, NULL, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == WBEM_E_INVALID_PARAMETER, "query failed %#lx\n", hr );
|
2012-06-18 09:32:22 +02:00
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, NULL, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == WBEM_E_INVALID_PARAMETER, "query failed %#lx\n", hr );
|
2012-06-18 09:32:22 +02:00
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, sql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == WBEM_E_INVALID_QUERY_TYPE, "query failed %#lx\n", hr );
|
2012-06-18 09:32:22 +02:00
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, sql, NULL, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == WBEM_E_INVALID_PARAMETER, "query failed %#lx\n", hr );
|
2012-06-18 09:32:22 +02:00
|
|
|
|
2013-01-18 10:22:49 +01:00
|
|
|
SysFreeString( query );
|
2020-02-25 11:39:53 +01:00
|
|
|
query = SysAllocString( L"" );
|
2013-01-18 10:22:49 +01:00
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == WBEM_E_INVALID_PARAMETER, "query failed %#lx\n", hr );
|
2013-01-18 10:22:49 +01:00
|
|
|
|
2018-05-30 21:15:33 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE( test ); i++)
|
2012-06-18 09:32:22 +02:00
|
|
|
{
|
|
|
|
hr = exec_query( services, test[i], &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "query %u failed: %#lx\n", i, hr );
|
2012-06-18 09:32:22 +02:00
|
|
|
if (result) IEnumWbemClassObject_Release( result );
|
|
|
|
}
|
|
|
|
|
|
|
|
SysFreeString( wql );
|
|
|
|
SysFreeString( sql );
|
|
|
|
SysFreeString( query );
|
|
|
|
}
|
|
|
|
|
2016-04-18 11:04:49 +02:00
|
|
|
static void test_associators( IWbemServices *services )
|
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
static const WCHAR *test[] =
|
|
|
|
{
|
|
|
|
L"ASSOCIATORS OF{Win32_LogicalDisk.DeviceID=\"C:\"}",
|
|
|
|
L"ASSOCIATORS OF {Win32_LogicalDisk.DeviceID=\"C:\"} WHERE AssocClass=Win32_LogicalDiskToPartition",
|
|
|
|
L"ASSOCIATORS OF {Win32_LogicalDisk.DeviceID}",
|
|
|
|
L"ASSOCIATORS OF {Win32_DiskDrive.DeviceID='\\\\.\\PHYSICALDRIVE0'}",
|
|
|
|
L"ASSOCIATORS OF {Win32_LogicalDisk.DeviceID=\"C:\"} WHERE AssocClass=Win32_LogicalDiskToPartition ClassDefsOnly",
|
|
|
|
L"ASSOCIATORS OF {Win32_LogicalDisk.DeviceID=\"C:\"} WHERE ClassDefsOnly",
|
|
|
|
L"ASSOCIATORS OF {Win32_LogicalDisk.DeviceID=\"C:\"} WHERE ClassDefsOnly AssocClass = Win32_LogicalDiskToPartition",
|
|
|
|
};
|
2016-04-18 11:04:49 +02:00
|
|
|
HRESULT hr;
|
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
UINT i;
|
|
|
|
|
2018-05-30 21:15:33 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE( test ); i++)
|
2016-04-18 11:04:49 +02:00
|
|
|
{
|
|
|
|
hr = exec_query( services, test[i], &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "query %u failed: %#lx\n", i, hr );
|
2016-04-18 11:04:49 +02:00
|
|
|
if (result) IEnumWbemClassObject_Release( result );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-28 11:35:07 +02:00
|
|
|
static void test_IEnumWbemClassObject_Next( IWbemServices *services )
|
|
|
|
{
|
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_IP4RouteTable" );
|
|
|
|
IWbemClassObject **obj, *obj1;
|
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
DWORD count, num_objects = 0;
|
|
|
|
HRESULT hr;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2020-07-28 11:35:07 +02:00
|
|
|
|
|
|
|
count = 2;
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, NULL, &count );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == WBEM_E_INVALID_PARAMETER, "got %#lx\n", hr );
|
|
|
|
ok( count == 2, "expected 0, got %lu\n", count );
|
2020-07-28 11:35:07 +02:00
|
|
|
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj1, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == WBEM_E_INVALID_PARAMETER, "got %#lx\n", hr );
|
2020-07-28 11:35:07 +02:00
|
|
|
|
|
|
|
count = 2;
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 0, &obj1, &count );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
|
|
|
ok( count == 0, "expected 0, got %lu\n", count );
|
2020-07-28 11:35:07 +02:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj1, &count );
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
num_objects++;
|
|
|
|
IWbemClassObject_Release(obj1);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IEnumWbemClassObject_Reset( result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2020-07-28 11:35:07 +02:00
|
|
|
|
2022-01-31 14:49:43 +01:00
|
|
|
obj = malloc( num_objects * sizeof( IWbemClassObject * ) );
|
2020-07-28 11:35:07 +02:00
|
|
|
|
|
|
|
count = 0;
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, num_objects, obj, &count );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
|
|
|
ok( count == num_objects, "expected %lu, got %lu\n", num_objects, count );
|
2020-07-28 11:35:07 +02:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
IWbemClassObject_Release( obj[i] );
|
|
|
|
|
|
|
|
hr = IEnumWbemClassObject_Reset( result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2020-07-28 11:35:07 +02:00
|
|
|
|
|
|
|
count = 0;
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, num_objects + 1, obj, &count );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_FALSE, "got %#lx\n", hr );
|
|
|
|
ok( count == num_objects, "expected %lu, got %lu\n", num_objects, count );
|
2020-07-28 11:35:07 +02:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
IWbemClassObject_Release( obj[i] );
|
|
|
|
|
2022-01-31 14:49:43 +01:00
|
|
|
free( obj );
|
2020-07-28 11:35:07 +02:00
|
|
|
|
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2019-09-19 19:33:29 +02:00
|
|
|
static void _check_property( ULONG line, IWbemClassObject *obj, const WCHAR *prop, VARTYPE vartype, CIMTYPE cimtype )
|
|
|
|
{
|
|
|
|
CIMTYPE type = 0xdeadbeef;
|
|
|
|
VARIANT val;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
VariantInit( &val );
|
|
|
|
hr = IWbemClassObject_Get( obj, prop, 0, &val, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "%lu: failed to get description %#lx\n", line, hr );
|
|
|
|
ok( V_VT( &val ) == vartype, "%lu: unexpected variant type 0x%x\n", line, V_VT(&val) );
|
|
|
|
ok( type == cimtype, "%lu: unexpected type %#lx\n", line, type );
|
2019-09-19 19:33:29 +02:00
|
|
|
switch (V_VT(&val))
|
|
|
|
{
|
|
|
|
case VT_BSTR:
|
|
|
|
trace( "%s: %s\n", wine_dbgstr_w(prop), wine_dbgstr_w(V_BSTR(&val)) );
|
|
|
|
break;
|
|
|
|
case VT_I2:
|
|
|
|
trace( "%s: %d\n", wine_dbgstr_w(prop), V_I2(&val) );
|
|
|
|
break;
|
|
|
|
case VT_I4:
|
2022-02-14 12:14:59 +01:00
|
|
|
trace( "%s: %ld\n", wine_dbgstr_w(prop), V_I4(&val) );
|
2019-09-19 19:33:29 +02:00
|
|
|
break;
|
|
|
|
case VT_R4:
|
|
|
|
trace( "%s: %f\n", wine_dbgstr_w(prop), V_R4(&val) );
|
|
|
|
break;
|
2021-01-21 12:36:40 +01:00
|
|
|
case VT_BOOL:
|
|
|
|
trace( "%s: %d\n", wine_dbgstr_w(prop), V_BOOL(&val) );
|
|
|
|
break;
|
2019-09-19 19:33:29 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
VariantClear( &val );
|
|
|
|
}
|
|
|
|
#define check_property(a,b,c,d) _check_property(__LINE__,a,b,c,d)
|
|
|
|
|
2012-10-17 11:08:40 +02:00
|
|
|
static void test_Win32_Service( IWbemServices *services )
|
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR class = SysAllocString( L"Win32_Service.Name=\"Spooler\"" ), empty = SysAllocString( L"" ), method;
|
2012-10-17 11:08:40 +02:00
|
|
|
IWbemClassObject *service, *out;
|
2020-08-11 12:01:47 +02:00
|
|
|
VARIANT state, retval, classvar;
|
2012-10-17 11:08:40 +02:00
|
|
|
CIMTYPE type;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IWbemServices_GetObject( services, class, 0, NULL, &service, NULL );
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
win_skip( "Win32_Service not available\n" );
|
2020-08-10 02:30:09 +02:00
|
|
|
SysFreeString( empty );
|
|
|
|
SysFreeString( class );
|
|
|
|
return;
|
2012-10-17 11:08:40 +02:00
|
|
|
}
|
2019-09-19 19:33:29 +02:00
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( service, L"ProcessID", VT_I4, CIM_UINT32 );
|
2012-10-17 11:08:40 +02:00
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &state );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( service, L"State", 0, &state, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get service state %#lx\n", hr );
|
2012-10-17 11:08:40 +02:00
|
|
|
ok( V_VT( &state ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &state ) );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( type == CIM_STRING, "unexpected type %#lx\n", type );
|
2012-10-17 11:08:40 +02:00
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
if (!lstrcmpW( V_BSTR( &state ), L"Stopped" ))
|
2012-10-17 11:08:40 +02:00
|
|
|
{
|
|
|
|
out = NULL;
|
2020-02-25 11:39:53 +01:00
|
|
|
method = SysAllocString( L"StartService" );
|
2012-10-17 11:08:40 +02:00
|
|
|
hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, NULL, &out, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to execute method %#lx\n", hr );
|
2012-10-17 11:08:40 +02:00
|
|
|
SysFreeString( method );
|
|
|
|
|
|
|
|
VariantInit( &retval );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( out, L"ReturnValue", 0, &retval, NULL, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get return value %#lx\n", hr );
|
|
|
|
ok( !V_I4( &retval ), "unexpected error %lu\n", V_UI4( &retval ) );
|
2012-10-17 11:08:40 +02:00
|
|
|
IWbemClassObject_Release( out );
|
|
|
|
}
|
|
|
|
out = NULL;
|
2020-02-25 11:39:53 +01:00
|
|
|
method = SysAllocString( L"PauseService" );
|
2012-10-17 11:08:40 +02:00
|
|
|
hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, NULL, &out, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to execute method %#lx\n", hr );
|
2012-10-17 11:08:40 +02:00
|
|
|
SysFreeString( method );
|
|
|
|
|
|
|
|
VariantInit( &retval );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( out, L"ReturnValue", 0, &retval, NULL, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get return value %#lx\n", hr );
|
2012-10-17 11:08:40 +02:00
|
|
|
ok( V_I4( &retval ), "unexpected success\n" );
|
|
|
|
IWbemClassObject_Release( out );
|
|
|
|
|
|
|
|
out = NULL;
|
2020-02-25 11:39:53 +01:00
|
|
|
method = SysAllocString( L"ResumeService" );
|
2012-10-17 11:08:40 +02:00
|
|
|
hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, NULL, &out, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to execute method %#lx\n", hr );
|
2012-10-17 11:08:40 +02:00
|
|
|
SysFreeString( method );
|
|
|
|
|
|
|
|
VariantInit( &retval );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( out, L"ReturnValue", 0, &retval, NULL, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get return value %#lx\n", hr );
|
2012-10-17 11:08:40 +02:00
|
|
|
ok( V_I4( &retval ), "unexpected success\n" );
|
|
|
|
IWbemClassObject_Release( out );
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
if (!lstrcmpW( V_BSTR( &state ), L"Stopped" ))
|
2012-10-17 11:08:40 +02:00
|
|
|
{
|
|
|
|
out = NULL;
|
2020-02-25 11:39:53 +01:00
|
|
|
method = SysAllocString( L"StopService" );
|
2012-10-17 11:08:40 +02:00
|
|
|
hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, NULL, &out, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to execute method %#lx\n", hr );
|
2012-10-17 11:08:40 +02:00
|
|
|
SysFreeString( method );
|
|
|
|
|
|
|
|
VariantInit( &retval );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( out, L"ReturnValue", 0, &retval, NULL, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get return value %#lx\n", hr );
|
|
|
|
ok( !V_I4( &retval ), "unexpected error %lu\n", V_UI4( &retval ) );
|
2012-10-17 11:08:40 +02:00
|
|
|
IWbemClassObject_Release( out );
|
|
|
|
}
|
|
|
|
VariantClear( &state );
|
|
|
|
IWbemClassObject_Release( service );
|
2013-01-28 15:56:40 +01:00
|
|
|
|
|
|
|
service = NULL;
|
|
|
|
hr = IWbemServices_GetObject( services, NULL, 0, NULL, &service, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2020-08-11 12:01:46 +02:00
|
|
|
ok( !!service, "expected non-NULL service\n" );
|
2020-08-11 12:01:47 +02:00
|
|
|
|
|
|
|
VariantInit(&classvar);
|
|
|
|
V_VT(&classvar) = VT_BSTR;
|
|
|
|
V_BSTR(&classvar) = SysAllocString(L"MyClass");
|
|
|
|
hr = IWbemClassObject_Put(service, L"__CLASS", 0, &classvar, 0);
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2020-08-11 12:01:47 +02:00
|
|
|
VariantClear(&classvar);
|
2020-08-11 12:01:46 +02:00
|
|
|
IWbemClassObject_Release( service );
|
2013-01-28 15:56:40 +01:00
|
|
|
|
|
|
|
service = NULL;
|
|
|
|
hr = IWbemServices_GetObject( services, empty, 0, NULL, &service, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2020-08-11 12:01:46 +02:00
|
|
|
ok( !!service, "expected non-NULL service\n" );
|
|
|
|
IWbemClassObject_Release( service );
|
2013-01-28 15:56:40 +01:00
|
|
|
|
|
|
|
SysFreeString( empty );
|
2012-10-17 11:08:40 +02:00
|
|
|
SysFreeString( class );
|
2020-08-10 02:30:09 +02:00
|
|
|
|
|
|
|
class = SysAllocString( L"Win32_Service.Name=\"nonexistent\"" );
|
2020-08-11 12:01:46 +02:00
|
|
|
service = (IWbemClassObject *)0xdeadbeef;
|
2020-08-10 02:30:09 +02:00
|
|
|
hr = IWbemServices_GetObject( services, class, 0, NULL, &service, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == WBEM_E_NOT_FOUND, "got %#lx\n", hr );
|
2020-08-11 12:01:46 +02:00
|
|
|
ok( service == NULL, "expected NULL service, got %p\n", service );
|
2020-08-10 02:30:09 +02:00
|
|
|
SysFreeString( class );
|
2012-10-17 11:08:40 +02:00
|
|
|
}
|
|
|
|
|
2015-10-07 14:20:18 +02:00
|
|
|
static void test_Win32_Bios( IWbemServices *services )
|
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_BIOS" );
|
2015-10-07 14:20:18 +02:00
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
CIMTYPE type;
|
|
|
|
ULONG count;
|
|
|
|
VARIANT val;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "IWbemServices_ExecQuery failed %#lx\n", hr );
|
2015-10-07 14:20:18 +02:00
|
|
|
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "IEnumWbemClassObject_Next failed %#lx\n", hr );
|
2015-10-07 14:20:18 +02:00
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"Description", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"IdentificationCode", VT_NULL, CIM_STRING );
|
|
|
|
check_property( obj, L"Manufacturer", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"Name", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"ReleaseDate", VT_BSTR, CIM_DATETIME );
|
2015-10-07 14:20:18 +02:00
|
|
|
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &val );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( obj, L"SerialNumber", 0, &val, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get serial number %#lx\n", hr );
|
2015-10-07 14:20:18 +02:00
|
|
|
ok( V_VT( &val ) == VT_BSTR || V_VT( &val ) == VT_NULL /* Testbot VMs */,
|
|
|
|
"unexpected variant type 0x%x\n", V_VT( &val ) );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( type == CIM_STRING, "unexpected type %#lx\n", type );
|
2015-10-07 14:20:18 +02:00
|
|
|
VariantClear( &val );
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"SMBIOSBIOSVersion", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"SMBIOSMajorVersion", VT_I4, CIM_UINT16 );
|
|
|
|
check_property( obj, L"SMBIOSMinorVersion", VT_I4, CIM_UINT16 );
|
|
|
|
check_property( obj, L"Version", VT_BSTR, CIM_STRING );
|
2015-10-07 14:20:18 +02:00
|
|
|
|
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2019-08-28 14:14:25 +02:00
|
|
|
static void test_Win32_Baseboard( IWbemServices *services )
|
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_Baseboard" );
|
2019-08-28 14:14:25 +02:00
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
CIMTYPE type;
|
|
|
|
ULONG count;
|
|
|
|
VARIANT val;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "IWbemServices_ExecQuery failed %#lx\n", hr );
|
2019-08-28 14:14:25 +02:00
|
|
|
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
win_skip( "Win32_Baseboard not available\n" );
|
|
|
|
return;
|
|
|
|
}
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "IEnumWbemClassObject_Next failed %#lx\n", hr );
|
2019-08-28 14:14:25 +02:00
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"Manufacturer", VT_BSTR, CIM_STRING );
|
2019-08-28 14:14:25 +02:00
|
|
|
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &val );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( obj, L"Model", 0, &val, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get model %#lx\n", hr );
|
2019-08-28 14:14:25 +02:00
|
|
|
ok( V_VT( &val ) == VT_BSTR || V_VT( &val ) == VT_NULL, "unexpected variant type 0x%x\n", V_VT( &val ) );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( type == CIM_STRING, "unexpected type %#lx\n", type );
|
2019-08-28 14:14:25 +02:00
|
|
|
trace( "model: %s\n", wine_dbgstr_w(V_BSTR(&val)) );
|
|
|
|
VariantClear( &val );
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"Name", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"Product", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"Tag", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"Version", VT_BSTR, CIM_STRING );
|
2019-08-28 14:14:25 +02:00
|
|
|
|
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2021-05-18 09:49:45 +02:00
|
|
|
static void test_Win32_Process_created_process(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-10-15 19:59:21 +02:00
|
|
|
static void test_Win32_Process( IWbemServices *services, BOOL use_full_path )
|
2013-01-11 17:22:14 +01:00
|
|
|
{
|
2013-01-25 17:34:00 +01:00
|
|
|
static const LONG expected_flavor = WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE |
|
|
|
|
WBEM_FLAVOR_NOT_OVERRIDABLE |
|
|
|
|
WBEM_FLAVOR_ORIGIN_PROPAGATED;
|
2020-02-25 11:39:53 +01:00
|
|
|
WCHAR full_path[MAX_COMPUTERNAME_LENGTH + ARRAY_SIZE( L"\\\\%s\\ROOT\\CIMV2:" )];
|
2013-01-11 17:22:14 +01:00
|
|
|
BSTR class, method;
|
2021-05-18 09:49:45 +02:00
|
|
|
IWbemClassObject *process, *sig_in, *sig_out, *out, *params;
|
|
|
|
WCHAR cmdlineW[MAX_PATH + 64 + 1];
|
2013-01-25 17:34:00 +01:00
|
|
|
IWbemQualifierSet *qualifiers;
|
2019-04-24 12:58:12 +02:00
|
|
|
VARIANT retval, val;
|
2020-10-22 21:25:49 +02:00
|
|
|
SAFEARRAY *names;
|
|
|
|
LONG bound, i;
|
2018-10-15 19:59:21 +02:00
|
|
|
DWORD full_path_len = 0;
|
2021-05-18 09:49:45 +02:00
|
|
|
ULONG refcount;
|
2013-01-25 17:34:00 +01:00
|
|
|
LONG flavor;
|
2013-01-11 17:22:14 +01:00
|
|
|
CIMTYPE type;
|
|
|
|
HRESULT hr;
|
2021-05-18 09:49:45 +02:00
|
|
|
DWORD ret;
|
|
|
|
HANDLE h;
|
2013-01-11 17:22:14 +01:00
|
|
|
|
2018-10-15 19:59:21 +02:00
|
|
|
if (use_full_path)
|
|
|
|
{
|
|
|
|
WCHAR server[MAX_COMPUTERNAME_LENGTH+1];
|
|
|
|
|
|
|
|
full_path_len = ARRAY_SIZE(server);
|
|
|
|
ok( GetComputerNameW(server, &full_path_len), "GetComputerName failed\n" );
|
2020-02-25 11:39:53 +01:00
|
|
|
full_path_len = wsprintfW( full_path, L"\\\\%s\\ROOT\\CIMV2:", server );
|
2018-10-15 19:59:21 +02:00
|
|
|
}
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
class = SysAllocStringLen( NULL, full_path_len + ARRAY_SIZE( L"Win32_Process" ) );
|
2018-10-15 19:59:21 +02:00
|
|
|
memcpy( class, full_path, full_path_len * sizeof(WCHAR) );
|
2020-02-25 11:39:53 +01:00
|
|
|
memcpy( class + full_path_len, L"Win32_Process", sizeof(L"Win32_Process") );
|
2013-01-11 17:22:14 +01:00
|
|
|
hr = IWbemServices_GetObject( services, class, 0, NULL, &process, NULL );
|
|
|
|
SysFreeString( class );
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
win_skip( "Win32_Process not available\n" );
|
|
|
|
return;
|
|
|
|
}
|
2020-10-22 21:25:49 +02:00
|
|
|
names = NULL;
|
|
|
|
hr = IWbemClassObject_GetNames( process, NULL, 0, NULL, &names );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2020-10-22 21:25:49 +02:00
|
|
|
ok( names != NULL, "names not set\n" );
|
|
|
|
hr = SafeArrayGetUBound( names, 1, &bound );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2020-10-22 21:25:49 +02:00
|
|
|
for (i = 0; i <= bound; i++)
|
|
|
|
{
|
|
|
|
BSTR str;
|
|
|
|
hr = SafeArrayGetElement( names, &i, &str );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "%ld: got %#lx\n", i, hr );
|
2020-10-22 21:25:49 +02:00
|
|
|
SysFreeString( str );
|
|
|
|
}
|
|
|
|
SafeArrayDestroy( names );
|
|
|
|
|
2021-05-18 09:49:44 +02:00
|
|
|
sig_in = (void *)0xdeadbeef;
|
|
|
|
sig_out = (void *)0xdeadbeef;
|
|
|
|
hr = IWbemClassObject_GetMethod( process, L"unknown", 0, &sig_in, &sig_out );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == WBEM_E_NOT_FOUND, "Got unexpected hr %#lx\n", hr );
|
2021-05-18 09:49:44 +02:00
|
|
|
ok( !sig_in, "Got unexpected sig_in %p.\n", sig_in );
|
|
|
|
ok( !sig_out, "Got unexpected sig_out %p.\n", sig_out );
|
|
|
|
|
2021-05-18 09:49:45 +02:00
|
|
|
sig_in = (void *)0xdeadbeef;
|
|
|
|
sig_out = (void *)0xdeadbeef;
|
|
|
|
hr = IWbemClassObject_GetMethod( process, L"Create", 0, &sig_in, &sig_out );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "Got unexpected hr %#lx\n", hr );
|
2021-05-18 09:49:45 +02:00
|
|
|
ok( !!sig_in, "Got unexpected sig_in %p.\n", sig_in );
|
|
|
|
ok( !!sig_out, "Got unexpected sig_out %p.\n", sig_out );
|
|
|
|
|
|
|
|
hr = IWbemClassObject_SpawnInstance( sig_in, 0, ¶ms );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2021-05-18 09:49:45 +02:00
|
|
|
|
|
|
|
out = NULL;
|
|
|
|
class = SysAllocString( L"Win32_Process" );
|
|
|
|
method = SysAllocString( L"Create" );
|
|
|
|
hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, params, &out, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to execute method %#lx\n", hr );
|
2021-05-18 09:49:45 +02:00
|
|
|
SysFreeString( method );
|
|
|
|
SysFreeString( class );
|
|
|
|
|
|
|
|
VariantInit( &retval );
|
|
|
|
hr = IWbemClassObject_Get( out, L"ReturnValue", 0, &retval, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get return value %#lx\n", hr );
|
2021-05-18 09:49:45 +02:00
|
|
|
ok( V_VT( &retval ) == VT_I4, "unexpected variant type 0x%x\n", V_VT( &retval ) );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( V_I4( &retval ) == 21, "unexpected error %ld\n", V_I4( &retval ) );
|
2021-05-18 09:49:45 +02:00
|
|
|
|
|
|
|
IWbemClassObject_Release( out );
|
|
|
|
|
|
|
|
V_VT( &val ) = VT_BSTR;
|
|
|
|
V_BSTR( &val ) = SysAllocString( L"unknown" );
|
|
|
|
hr = IWbemClassObject_Put( params, L"CommandLine", 0, &val, 0 );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2021-05-18 09:49:45 +02:00
|
|
|
VariantClear( &val );
|
|
|
|
|
|
|
|
out = NULL;
|
|
|
|
class = SysAllocString( L"Win32_Process" );
|
|
|
|
method = SysAllocString( L"Create" );
|
|
|
|
hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, params, &out, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to execute method %#lx\n", hr );
|
2021-05-18 09:49:45 +02:00
|
|
|
SysFreeString( method );
|
|
|
|
SysFreeString( class );
|
|
|
|
|
|
|
|
VariantInit( &retval );
|
|
|
|
hr = IWbemClassObject_Get( out, L"ReturnValue", 0, &retval, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get return value %#lx\n", hr );
|
2021-05-18 09:49:45 +02:00
|
|
|
ok( V_VT( &retval ) == VT_I4, "unexpected variant type 0x%x\n", V_VT( &retval ) );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( V_I4( &retval ) == 9, "unexpected error %ld\n", V_I4( &retval ) );
|
2021-05-18 09:49:45 +02:00
|
|
|
|
|
|
|
VariantInit( &retval );
|
|
|
|
V_VT( &retval ) = VT_I4;
|
|
|
|
hr = IWbemClassObject_Get( out, L"ProcessId", 0, &retval, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get return value %#lx\n", hr );
|
|
|
|
todo_wine ok( V_VT( &retval ) == VT_NULL && type == CIM_UINT32, "unexpected variant type %#x, type %lu\n",
|
2021-05-18 09:49:45 +02:00
|
|
|
V_VT( &retval ), type );
|
|
|
|
|
|
|
|
IWbemClassObject_Release( out );
|
|
|
|
|
|
|
|
ret = GetModuleFileNameW( NULL, cmdlineW, MAX_PATH + 1 );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( ret < MAX_PATH + 1, "got unexpected ret %lu\n", ret );
|
2021-05-18 09:49:45 +02:00
|
|
|
lstrcatW( cmdlineW, L" query created_process");
|
|
|
|
V_VT( &val ) = VT_BSTR;
|
|
|
|
V_BSTR( &val ) = SysAllocString( cmdlineW );
|
|
|
|
hr = IWbemClassObject_Put( params, L"CommandLine", 0, &val, 0 );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2021-05-18 09:49:45 +02:00
|
|
|
VariantClear( &val );
|
|
|
|
|
|
|
|
out = NULL;
|
|
|
|
class = SysAllocString( L"Win32_Process" );
|
|
|
|
method = SysAllocString( L"Create" );
|
|
|
|
hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, params, &out, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to execute method %#lx\n", hr );
|
2021-05-18 09:49:45 +02:00
|
|
|
SysFreeString( method );
|
|
|
|
SysFreeString( class );
|
|
|
|
|
|
|
|
VariantInit( &retval );
|
|
|
|
hr = IWbemClassObject_Get( out, L"ReturnValue", 0, &retval, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get return value %#lx\n", hr );
|
2021-05-18 09:49:45 +02:00
|
|
|
ok( V_VT( &retval ) == VT_I4, "unexpected variant type 0x%x\n", V_VT( &retval ) );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( !V_I4( &retval ), "unexpected error %ld\n", V_I4( &retval ) );
|
2021-05-18 09:49:45 +02:00
|
|
|
|
|
|
|
VariantInit( &retval );
|
|
|
|
V_VT( &retval ) = VT_I4;
|
|
|
|
hr = IWbemClassObject_Get( out, L"ProcessId", 0, &retval, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get return value %#lx\n", hr );
|
|
|
|
ok( V_VT( &retval ) == VT_I4 && type == CIM_UINT32, "unexpected variant type %#x, type %lu\n",
|
2021-05-18 09:49:45 +02:00
|
|
|
V_VT( &retval ), type );
|
|
|
|
ok( !!V_UI4( &retval ), "unexpected zero pid\n" );
|
|
|
|
|
|
|
|
IWbemClassObject_Release( out );
|
|
|
|
|
|
|
|
h = OpenProcess( SYNCHRONIZE, FALSE, V_UI4( &retval ));
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( !!h, "failed to open process %#lx\n", V_UI4( &retval ));
|
2021-05-18 09:49:45 +02:00
|
|
|
|
|
|
|
ret = WaitForSingleObject( h, INFINITE );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( ret == WAIT_OBJECT_0, "got unexpected ret %lu, GetLastError() %lu\n", ret, GetLastError() );
|
2021-05-18 09:49:45 +02:00
|
|
|
CloseHandle( h );
|
|
|
|
|
|
|
|
refcount = IWbemClassObject_Release( params );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( !refcount, "got unexpected refcount %lu\n", refcount );
|
2021-05-18 09:49:45 +02:00
|
|
|
|
|
|
|
refcount = IWbemClassObject_Release( sig_in );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( !refcount, "got unexpected refcount %lu\n", refcount );
|
2021-05-18 09:49:45 +02:00
|
|
|
refcount = IWbemClassObject_Release( sig_out );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( !refcount, "got unexpected refcount %lu\n", refcount );
|
2021-05-18 09:49:45 +02:00
|
|
|
|
2018-10-17 08:47:20 +02:00
|
|
|
sig_in = (void*)0xdeadbeef;
|
2021-05-18 09:49:44 +02:00
|
|
|
hr = IWbemClassObject_GetMethod( process, L"getowner", 0, &sig_in, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get GetOwner method %#lx\n", hr );
|
2018-10-17 08:47:20 +02:00
|
|
|
ok( !sig_in, "sig_in != NULL\n");
|
2015-04-22 11:28:20 +02:00
|
|
|
IWbemClassObject_Release( process );
|
2013-01-11 17:22:14 +01:00
|
|
|
|
|
|
|
out = NULL;
|
2020-02-25 11:39:53 +01:00
|
|
|
method = SysAllocString( L"GetOwner" );
|
|
|
|
class = SysAllocStringLen( NULL, full_path_len + ARRAY_SIZE( L"Win32_Process.Handle=\"%u\"" ) + 10 );
|
2018-10-15 19:59:21 +02:00
|
|
|
memcpy( class, full_path, full_path_len * sizeof(WCHAR) );
|
2020-02-25 11:39:53 +01:00
|
|
|
wsprintfW( class + full_path_len, L"Win32_Process.Handle=\"%u\"", GetCurrentProcessId() );
|
2013-01-11 17:22:14 +01:00
|
|
|
hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, NULL, &out, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to execute method %#lx\n", hr );
|
2013-01-11 17:22:14 +01:00
|
|
|
SysFreeString( method );
|
|
|
|
SysFreeString( class );
|
|
|
|
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &retval );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( out, L"ReturnValue", 0, &retval, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get return value %#lx\n", hr );
|
2013-01-11 17:22:14 +01:00
|
|
|
ok( V_VT( &retval ) == VT_I4, "unexpected variant type 0x%x\n", V_VT( &retval ) );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( !V_I4( &retval ), "unexpected error %ld\n", V_I4( &retval ) );
|
|
|
|
ok( type == CIM_UINT32, "unexpected type %#lx\n", type );
|
2013-01-11 17:22:14 +01:00
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( out, L"User", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( out, L"Domain", VT_BSTR, CIM_STRING );
|
2013-01-11 17:22:14 +01:00
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_GetPropertyQualifierSet( out, L"User", &qualifiers );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get qualifier set %#lx\n", hr );
|
2013-01-25 17:34:00 +01:00
|
|
|
|
|
|
|
flavor = -1;
|
|
|
|
V_I4(&val) = -1;
|
|
|
|
V_VT(&val) = VT_ERROR;
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemQualifierSet_Get( qualifiers, L"ID", 0, &val, &flavor );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
|
|
|
ok( flavor == expected_flavor, "got %ld\n", flavor );
|
|
|
|
ok( V_VT(&val) == VT_I4, "got %#x\n", V_VT(&val) );
|
|
|
|
ok( V_I4(&val) == 0, "got %ld\n", V_I4(&val) );
|
2013-01-25 17:34:00 +01:00
|
|
|
VariantClear( &val );
|
|
|
|
|
|
|
|
IWbemQualifierSet_Release( qualifiers );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_GetPropertyQualifierSet( out, L"Domain", &qualifiers );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get qualifier set %#lx\n", hr );
|
2013-01-25 17:34:00 +01:00
|
|
|
|
|
|
|
flavor = -1;
|
|
|
|
V_I4(&val) = -1;
|
|
|
|
V_VT(&val) = VT_ERROR;
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemQualifierSet_Get( qualifiers, L"ID", 0, &val, &flavor );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
|
|
|
ok( flavor == expected_flavor, "got %ld\n", flavor );
|
|
|
|
ok( V_VT(&val) == VT_I4, "got %#x\n", V_VT(&val) );
|
|
|
|
ok( V_I4(&val) == 1, "got %ld\n", V_I4(&val) );
|
2013-01-25 17:34:00 +01:00
|
|
|
VariantClear( &val );
|
|
|
|
|
|
|
|
IWbemQualifierSet_Release( qualifiers );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_GetPropertyQualifierSet( out, L"ReturnValue", &qualifiers );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get qualifier set %#lx\n", hr );
|
2013-01-25 17:34:00 +01:00
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemQualifierSet_Get( qualifiers, L"ID", 0, &val, &flavor );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == WBEM_E_NOT_FOUND, "got %#lx\n", hr );
|
2013-01-25 17:34:00 +01:00
|
|
|
|
|
|
|
IWbemQualifierSet_Release( qualifiers );
|
2013-01-11 17:22:14 +01:00
|
|
|
IWbemClassObject_Release( out );
|
|
|
|
}
|
|
|
|
|
2015-02-22 21:17:46 +01:00
|
|
|
static void test_Win32_ComputerSystem( IWbemServices *services )
|
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_ComputerSystem" );
|
2015-02-22 21:17:46 +01:00
|
|
|
IEnumWbemClassObject *result;
|
2019-01-25 10:44:14 +01:00
|
|
|
IWbemClassObject *obj;
|
2015-02-22 21:17:46 +01:00
|
|
|
VARIANT value;
|
|
|
|
CIMTYPE type;
|
|
|
|
HRESULT hr;
|
|
|
|
WCHAR compname[MAX_COMPUTERNAME_LENGTH + 1];
|
2015-02-22 22:23:12 +01:00
|
|
|
WCHAR username[128];
|
2015-02-22 21:17:46 +01:00
|
|
|
DWORD len, count;
|
|
|
|
|
2018-05-30 21:15:33 +02:00
|
|
|
len = ARRAY_SIZE( compname );
|
2015-02-22 21:17:46 +01:00
|
|
|
if (!GetComputerNameW( compname, &len ))
|
|
|
|
compname[0] = 0;
|
|
|
|
|
2015-02-22 22:23:12 +01:00
|
|
|
lstrcpyW( username, compname );
|
2020-02-25 11:39:53 +01:00
|
|
|
lstrcatW( username, L"\\" );
|
2018-05-30 21:15:33 +02:00
|
|
|
len = ARRAY_SIZE( username ) - lstrlenW( username );
|
2015-02-22 22:23:12 +01:00
|
|
|
if (!GetUserNameW( username + lstrlenW( username ), &len ))
|
|
|
|
username[0] = 0;
|
|
|
|
|
|
|
|
if (!compname[0] || !username[0])
|
2015-02-22 21:17:46 +01:00
|
|
|
{
|
2015-02-22 22:23:12 +01:00
|
|
|
skip( "Failed to get user or computer name\n" );
|
2015-04-17 07:58:06 +02:00
|
|
|
goto out;
|
2015-02-22 21:17:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
win_skip( "Win32_ComputerSystem not available\n" );
|
2015-04-17 07:58:06 +02:00
|
|
|
goto out;
|
2015-02-22 21:17:46 +01:00
|
|
|
}
|
|
|
|
|
2019-01-25 10:44:14 +01:00
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2015-02-22 21:17:46 +01:00
|
|
|
|
2016-11-16 17:02:07 +01:00
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &value );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( obj, L"MemoryType", 0, &value, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == WBEM_E_NOT_FOUND, "got %#lx\n", hr );
|
2016-11-16 17:02:07 +01:00
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"Model", VT_BSTR, CIM_STRING );
|
2016-11-16 17:02:07 +01:00
|
|
|
|
2015-02-22 21:17:46 +01:00
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &value );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( obj, L"Name", 0, &value, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get computer name %#lx\n", hr );
|
2015-02-22 21:17:46 +01:00
|
|
|
ok( V_VT( &value ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &value ) );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( type == CIM_STRING, "unexpected type %#lx\n", type );
|
2015-02-22 21:17:46 +01:00
|
|
|
ok( !lstrcmpiW( V_BSTR( &value ), compname ), "got %s, expected %s\n", wine_dbgstr_w(V_BSTR(&value)), wine_dbgstr_w(compname) );
|
|
|
|
VariantClear( &value );
|
|
|
|
|
2015-02-22 22:23:12 +01:00
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &value );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( obj, L"NumberOfLogicalProcessors", 0, &value, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK || broken(hr == WBEM_E_NOT_FOUND) /* win2k3 */, "got %#lx\n", hr );
|
2019-01-25 10:44:14 +01:00
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( V_VT( &value ) == VT_I4, "unexpected variant type %#x\n", V_VT( &value ) );
|
|
|
|
ok( type == CIM_UINT32, "unexpected type %#lx\n", type );
|
|
|
|
trace( "numlogicalprocessors %ld\n", V_I4( &value ) );
|
2019-01-25 10:44:14 +01:00
|
|
|
}
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"NumberOfProcessors", VT_I4, CIM_UINT32 );
|
2022-04-28 12:43:24 +02:00
|
|
|
check_property( obj, L"SystemType", VT_BSTR, CIM_STRING );
|
2019-01-25 10:44:14 +01:00
|
|
|
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &value );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( obj, L"UserName", 0, &value, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get computer name %#lx\n", hr );
|
2015-02-22 22:23:12 +01:00
|
|
|
ok( V_VT( &value ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &value ) );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( type == CIM_STRING, "unexpected type %#lx\n", type );
|
2015-02-22 22:23:12 +01:00
|
|
|
ok( !lstrcmpiW( V_BSTR( &value ), username ), "got %s, expected %s\n", wine_dbgstr_w(V_BSTR(&value)), wine_dbgstr_w(username) );
|
|
|
|
VariantClear( &value );
|
|
|
|
|
2019-01-25 10:44:14 +01:00
|
|
|
IWbemClassObject_Release( obj );
|
2015-02-22 21:17:46 +01:00
|
|
|
IEnumWbemClassObject_Release( result );
|
2015-04-17 07:58:06 +02:00
|
|
|
out:
|
2015-02-22 21:17:46 +01:00
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2015-05-22 07:55:14 +02:00
|
|
|
static void test_Win32_SystemEnclosure( IWbemServices *services )
|
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_SystemEnclosure" );
|
2015-05-22 07:55:14 +02:00
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
CIMTYPE type;
|
|
|
|
ULONG count;
|
|
|
|
VARIANT val;
|
|
|
|
DWORD *data;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "IWbemServices_ExecQuery failed %#lx\n", hr );
|
2015-05-22 07:55:14 +02:00
|
|
|
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "IEnumWbemClassObject_Next failed %#lx\n", hr );
|
2015-05-22 07:55:14 +02:00
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"Caption", VT_BSTR, CIM_STRING );
|
2015-05-22 07:55:14 +02:00
|
|
|
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &val );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( obj, L"ChassisTypes", 0, &val, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get chassis types %#lx\n", hr );
|
|
|
|
ok( V_VT( &val ) == (VT_I4|VT_ARRAY), "unexpected variant type %#x\n", V_VT( &val ) );
|
|
|
|
ok( type == (CIM_UINT16|CIM_FLAG_ARRAY), "unexpected type %#lx\n", type );
|
2015-05-22 07:55:14 +02:00
|
|
|
hr = SafeArrayAccessData( V_ARRAY( &val ), (void **)&data );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "SafeArrayAccessData failed %#lx\n", hr );
|
2015-05-22 07:55:14 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
LONG i, lower, upper;
|
|
|
|
|
|
|
|
hr = SafeArrayGetLBound( V_ARRAY( &val ), 1, &lower );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "SafeArrayGetLBound failed %#lx\n", hr );
|
2015-05-22 07:55:14 +02:00
|
|
|
hr = SafeArrayGetUBound( V_ARRAY( &val ), 1, &upper );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "SafeArrayGetUBound failed %#lx\n", hr );
|
2015-04-16 21:46:13 +02:00
|
|
|
if (V_VT( &val ) == (VT_I4|VT_ARRAY))
|
|
|
|
{
|
|
|
|
for (i = 0; i < upper - lower + 1; i++)
|
2022-02-14 12:14:59 +01:00
|
|
|
trace( "chassis type: %lu\n", data[i] );
|
2015-04-16 21:46:13 +02:00
|
|
|
}
|
2015-05-22 07:55:14 +02:00
|
|
|
hr = SafeArrayUnaccessData( V_ARRAY( &val ) );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "SafeArrayUnaccessData failed %#lx\n", hr );
|
2015-05-22 07:55:14 +02:00
|
|
|
}
|
|
|
|
VariantClear( &val );
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"Description", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"LockPresent", VT_BOOL, CIM_BOOLEAN );
|
|
|
|
check_property( obj, L"Manufacturer", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"Name", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"Tag", VT_BSTR, CIM_STRING );
|
2015-05-22 07:55:14 +02:00
|
|
|
|
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2012-10-12 14:26:58 +02:00
|
|
|
static void test_StdRegProv( IWbemServices *services )
|
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR class = SysAllocString( L"StdRegProv" ), method, name;
|
2018-10-09 15:25:02 +02:00
|
|
|
IWbemClassObject *reg, *sig_in, *sig_out, *in, *out;
|
2019-10-04 21:58:41 +02:00
|
|
|
VARIANT defkey, subkey, retval, valuename;
|
2012-10-12 14:26:58 +02:00
|
|
|
CIMTYPE type;
|
|
|
|
HRESULT hr;
|
2018-09-28 10:58:40 +02:00
|
|
|
LONG res;
|
2012-10-12 14:26:58 +02:00
|
|
|
|
|
|
|
hr = IWbemServices_GetObject( services, class, 0, NULL, ®, NULL );
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
win_skip( "StdRegProv not available\n" );
|
|
|
|
return;
|
|
|
|
}
|
2018-10-09 15:25:02 +02:00
|
|
|
|
|
|
|
hr = IWbemClassObject_BeginMethodEnumeration( reg, 0 );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2018-10-09 15:25:02 +02:00
|
|
|
|
|
|
|
while (IWbemClassObject_NextMethod( reg, 0, &name, &sig_in, &sig_out ) == S_OK)
|
|
|
|
{
|
|
|
|
SysFreeString( name );
|
|
|
|
IWbemClassObject_Release( sig_in );
|
|
|
|
IWbemClassObject_Release( sig_out );
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IWbemClassObject_EndMethodEnumeration( reg );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2018-10-09 15:25:02 +02:00
|
|
|
|
|
|
|
hr = IWbemClassObject_BeginEnumeration( reg, 0 );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2018-10-09 15:25:02 +02:00
|
|
|
|
|
|
|
while (IWbemClassObject_Next( reg, 0, &name, NULL, NULL, NULL ) == S_OK)
|
|
|
|
SysFreeString( name );
|
|
|
|
|
|
|
|
hr = IWbemClassObject_EndEnumeration( reg );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2018-10-09 15:25:02 +02:00
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_GetMethod( reg, L"CreateKey", 0, &sig_in, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get CreateKey method %#lx\n", hr );
|
2018-09-28 10:58:40 +02:00
|
|
|
|
|
|
|
hr = IWbemClassObject_SpawnInstance( sig_in, 0, &in );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to spawn instance %#lx\n", hr );
|
2018-09-28 10:58:40 +02:00
|
|
|
|
2021-02-26 08:22:14 +01:00
|
|
|
hr = IWbemClassObject_BeginEnumeration( in, 0 );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to start enumeration %#lx\n", hr );
|
2021-02-26 08:22:14 +01:00
|
|
|
|
|
|
|
hr = IWbemClassObject_Next( in, 0, &name, NULL, NULL, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2021-02-26 08:22:14 +01:00
|
|
|
SysFreeString( name );
|
|
|
|
|
|
|
|
hr = IWbemClassObject_EndEnumeration( in );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to end enumeration %#lx\n", hr );
|
2021-02-26 08:22:14 +01:00
|
|
|
|
2018-09-28 10:58:40 +02:00
|
|
|
V_VT( &defkey ) = VT_I4;
|
|
|
|
V_I4( &defkey ) = 0x80000001;
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Put( in, L"hDefKey", 0, &defkey, 0 );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to set root %#lx\n", hr );
|
2018-09-28 10:58:40 +02:00
|
|
|
|
|
|
|
V_VT( &subkey ) = VT_BSTR;
|
2020-02-25 11:39:53 +01:00
|
|
|
V_BSTR( &subkey ) = SysAllocString( L"Software\\StdRegProvTest" );
|
|
|
|
hr = IWbemClassObject_Put( in, L"sSubKeyName", 0, &subkey, 0 );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to set subkey %#lx\n", hr );
|
2018-09-28 10:58:40 +02:00
|
|
|
|
|
|
|
out = NULL;
|
2020-02-25 11:39:53 +01:00
|
|
|
method = SysAllocString( L"CreateKey" );
|
2018-09-28 10:58:40 +02:00
|
|
|
hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, in, &out, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to execute method %#lx\n", hr );
|
2018-09-28 10:58:40 +02:00
|
|
|
SysFreeString( method );
|
|
|
|
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &retval );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( out, L"ReturnValue", 0, &retval, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get return value %#lx\n", hr );
|
|
|
|
ok( V_VT( &retval ) == VT_I4, "unexpected variant type %#x\n", V_VT( &retval ) );
|
|
|
|
ok( !V_I4( &retval ), "unexpected error %ld\n", V_UI4( &retval ) );
|
|
|
|
ok( type == CIM_UINT32, "unexpected type %#lx\n", type );
|
2018-09-28 10:58:40 +02:00
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
res = RegDeleteKeyW( HKEY_CURRENT_USER, L"Software\\StdRegProvTest" );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( !res, "got %ld\n", res );
|
2018-09-28 10:58:40 +02:00
|
|
|
|
|
|
|
VariantClear( &subkey );
|
|
|
|
IWbemClassObject_Release( in );
|
|
|
|
IWbemClassObject_Release( out );
|
|
|
|
IWbemClassObject_Release( sig_in );
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_GetMethod( reg, L"EnumKey", 0, &sig_in, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get EnumKey method %#lx\n", hr );
|
2012-10-12 14:26:58 +02:00
|
|
|
|
|
|
|
hr = IWbemClassObject_SpawnInstance( sig_in, 0, &in );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to spawn instance %#lx\n", hr );
|
2012-10-12 14:26:58 +02:00
|
|
|
|
|
|
|
V_VT( &defkey ) = VT_I4;
|
|
|
|
V_I4( &defkey ) = 0x80000002;
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Put( in, L"hDefKey", 0, &defkey, 0 );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to set root %#lx\n", hr );
|
2012-10-12 14:26:58 +02:00
|
|
|
|
|
|
|
V_VT( &subkey ) = VT_BSTR;
|
2020-02-25 11:39:53 +01:00
|
|
|
V_BSTR( &subkey ) = SysAllocString( L"Software\\microsoft\\Windows\\CurrentVersion" );
|
|
|
|
hr = IWbemClassObject_Put( in, L"sSubKeyName", 0, &subkey, 0 );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to set subkey %#lx\n", hr );
|
2012-10-12 14:26:58 +02:00
|
|
|
|
|
|
|
out = NULL;
|
2020-02-25 11:39:53 +01:00
|
|
|
method = SysAllocString( L"EnumKey" );
|
2012-10-12 14:26:58 +02:00
|
|
|
hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, in, &out, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to execute method %#lx\n", hr );
|
2012-10-12 14:26:58 +02:00
|
|
|
SysFreeString( method );
|
|
|
|
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &retval );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( out, L"ReturnValue", 0, &retval, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get return value %#lx\n", hr );
|
2012-10-12 14:26:58 +02:00
|
|
|
ok( V_VT( &retval ) == VT_I4, "unexpected variant type 0x%x\n", V_VT( &retval ) );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( !V_I4( &retval ), "unexpected error %lu\n", V_UI4( &retval ) );
|
|
|
|
ok( type == CIM_UINT32, "unexpected type %#lx\n", type );
|
2012-10-12 14:26:58 +02:00
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( out, L"sNames", VT_BSTR|VT_ARRAY, CIM_STRING|CIM_FLAG_ARRAY );
|
2012-10-12 14:26:58 +02:00
|
|
|
|
|
|
|
VariantClear( &subkey );
|
|
|
|
IWbemClassObject_Release( in );
|
|
|
|
IWbemClassObject_Release( out );
|
|
|
|
IWbemClassObject_Release( sig_in );
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_GetMethod( reg, L"EnumValues", 0, &sig_in, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get EnumValues method %#lx\n", hr );
|
2012-10-12 14:26:58 +02:00
|
|
|
|
|
|
|
hr = IWbemClassObject_SpawnInstance( sig_in, 0, &in );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to spawn instance %#lx\n", hr );
|
2012-10-12 14:26:58 +02:00
|
|
|
|
|
|
|
V_VT( &defkey ) = VT_I4;
|
|
|
|
V_I4( &defkey ) = 0x80000002;
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Put( in, L"hDefKey", 0, &defkey, 0 );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to set root %#lx\n", hr );
|
2012-10-12 14:26:58 +02:00
|
|
|
|
|
|
|
V_VT( &subkey ) = VT_BSTR;
|
2020-02-25 11:39:53 +01:00
|
|
|
V_BSTR( &subkey ) = SysAllocString( L"Software\\microsoft\\Windows\\CurrentVersion" );
|
|
|
|
hr = IWbemClassObject_Put( in, L"sSubKeyName", 0, &subkey, 0 );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to set subkey %#lx\n", hr );
|
2012-10-12 14:26:58 +02:00
|
|
|
|
|
|
|
out = NULL;
|
2020-02-25 11:39:53 +01:00
|
|
|
method = SysAllocString( L"EnumValues" );
|
2012-10-12 14:26:58 +02:00
|
|
|
hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, in, &out, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to execute method %#lx\n", hr );
|
2012-10-12 14:26:58 +02:00
|
|
|
SysFreeString( method );
|
|
|
|
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &retval );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( out, L"ReturnValue", 0, &retval, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get return value %#lx\n", hr );
|
|
|
|
ok( V_VT( &retval ) == VT_I4, "unexpected variant type %#x\n", V_VT( &retval ) );
|
|
|
|
ok( !V_I4( &retval ), "unexpected error %ld\n", V_I4( &retval ) );
|
|
|
|
ok( type == CIM_UINT32, "unexpected type %#lx\n", type );
|
2012-10-12 14:26:58 +02:00
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( out, L"sNames", VT_BSTR|VT_ARRAY, CIM_STRING|CIM_FLAG_ARRAY );
|
|
|
|
check_property( out, L"Types", VT_I4|VT_ARRAY, CIM_SINT32|CIM_FLAG_ARRAY );
|
2012-10-12 14:26:58 +02:00
|
|
|
|
|
|
|
VariantClear( &subkey );
|
|
|
|
IWbemClassObject_Release( in );
|
|
|
|
IWbemClassObject_Release( out );
|
|
|
|
IWbemClassObject_Release( sig_in );
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_GetMethod( reg, L"GetStringValue", 0, &sig_in, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get GetStringValue method %#lx\n", hr );
|
2012-10-15 10:46:09 +02:00
|
|
|
|
|
|
|
hr = IWbemClassObject_SpawnInstance( sig_in, 0, &in );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to spawn instance %#lx\n", hr );
|
2012-10-15 10:46:09 +02:00
|
|
|
|
|
|
|
V_VT( &defkey ) = VT_I4;
|
|
|
|
V_I4( &defkey ) = 0x80000002;
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Put( in, L"hDefKey", 0, &defkey, 0 );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to set root %#lx\n", hr );
|
2012-10-15 10:46:09 +02:00
|
|
|
|
|
|
|
V_VT( &subkey ) = VT_BSTR;
|
2020-02-25 11:39:53 +01:00
|
|
|
V_BSTR( &subkey ) = SysAllocString( L"Software\\microsoft\\Windows\\CurrentVersion" );
|
|
|
|
hr = IWbemClassObject_Put( in, L"sSubKeyName", 0, &subkey, 0 );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to set subkey %#lx\n", hr );
|
2012-10-15 10:46:09 +02:00
|
|
|
|
|
|
|
V_VT( &valuename ) = VT_BSTR;
|
2020-02-25 11:39:53 +01:00
|
|
|
V_BSTR( &valuename ) = SysAllocString( L"ProgramFilesDir" );
|
|
|
|
hr = IWbemClassObject_Put( in, L"sValueName", 0, &valuename, 0 );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to set value name %#lx\n", hr );
|
2012-10-15 10:46:09 +02:00
|
|
|
|
|
|
|
out = NULL;
|
2020-02-25 11:39:53 +01:00
|
|
|
method = SysAllocString( L"GetStringValue" );
|
2012-10-15 10:46:09 +02:00
|
|
|
hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, in, &out, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to execute method %#lx\n", hr );
|
2012-10-15 10:46:09 +02:00
|
|
|
SysFreeString( method );
|
|
|
|
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &retval );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( out, L"ReturnValue", 0, &retval, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get return value %#lx\n", hr );
|
|
|
|
ok( V_VT( &retval ) == VT_I4, "unexpected variant type %#x\n", V_VT( &retval ) );
|
|
|
|
ok( !V_I4( &retval ), "unexpected error %ld\n", V_I4( &retval ) );
|
|
|
|
ok( type == CIM_UINT32, "unexpected type %#lx\n", type );
|
2012-10-15 10:46:09 +02:00
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( out, L"sValue", VT_BSTR, CIM_STRING );
|
2012-10-15 10:46:09 +02:00
|
|
|
|
|
|
|
VariantClear( &valuename );
|
|
|
|
VariantClear( &subkey );
|
|
|
|
IWbemClassObject_Release( in );
|
|
|
|
IWbemClassObject_Release( out );
|
|
|
|
IWbemClassObject_Release( sig_in );
|
|
|
|
|
2012-10-12 14:26:58 +02:00
|
|
|
IWbemClassObject_Release( reg );
|
|
|
|
SysFreeString( class );
|
|
|
|
}
|
|
|
|
|
2013-05-14 14:01:50 +02:00
|
|
|
static HRESULT WINAPI sink_QueryInterface(
|
|
|
|
IWbemObjectSink *iface, REFIID riid, void **ppv )
|
|
|
|
{
|
|
|
|
*ppv = NULL;
|
|
|
|
if (IsEqualGUID( &IID_IUnknown, riid ) || IsEqualGUID( &IID_IWbemObjectSink, riid ))
|
|
|
|
{
|
|
|
|
*ppv = iface;
|
|
|
|
IWbemObjectSink_AddRef( iface );
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG sink_refs;
|
|
|
|
|
|
|
|
static ULONG WINAPI sink_AddRef(
|
|
|
|
IWbemObjectSink *iface )
|
|
|
|
{
|
|
|
|
return ++sink_refs;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI sink_Release(
|
|
|
|
IWbemObjectSink *iface )
|
|
|
|
{
|
|
|
|
return --sink_refs;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI sink_Indicate(
|
|
|
|
IWbemObjectSink *iface, LONG count, IWbemClassObject **objects )
|
|
|
|
{
|
2022-02-14 12:14:59 +01:00
|
|
|
trace( "Indicate: %ld, %p\n", count, objects );
|
2013-05-14 14:01:50 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI sink_SetStatus(
|
|
|
|
IWbemObjectSink *iface, LONG flags, HRESULT hresult, BSTR str_param, IWbemClassObject *obj_param )
|
|
|
|
{
|
2022-02-14 12:14:59 +01:00
|
|
|
trace( "SetStatus: %#lx, %#lx, %s, %p\n", flags, hresult, wine_dbgstr_w(str_param), obj_param );
|
2013-05-14 14:01:50 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IWbemObjectSinkVtbl sink_vtbl =
|
|
|
|
{
|
|
|
|
sink_QueryInterface,
|
|
|
|
sink_AddRef,
|
|
|
|
sink_Release,
|
|
|
|
sink_Indicate,
|
|
|
|
sink_SetStatus
|
|
|
|
};
|
|
|
|
|
|
|
|
static IWbemObjectSink sink = { &sink_vtbl };
|
|
|
|
|
|
|
|
static void test_notification_query_async( IWbemServices *services )
|
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_DeviceChangeEvent" );
|
2013-05-16 12:04:03 +02:00
|
|
|
ULONG prev_sink_refs;
|
2013-05-14 14:01:50 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2013-05-16 12:04:03 +02:00
|
|
|
hr = IWbemServices_ExecNotificationQueryAsync( services, wql, query, 0, NULL, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == WBEM_E_INVALID_PARAMETER, "got %#lx\n", hr );
|
2013-05-16 12:04:03 +02:00
|
|
|
|
|
|
|
prev_sink_refs = sink_refs;
|
2013-05-14 14:01:50 +02:00
|
|
|
hr = IWbemServices_ExecNotificationQueryAsync( services, wql, query, 0, NULL, &sink );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK || broken(hr == WBEM_E_NOT_FOUND), "got %#lx\n", hr );
|
|
|
|
ok( sink_refs > prev_sink_refs || broken(!sink_refs), "got %lu refs\n", sink_refs );
|
2013-05-16 12:04:03 +02:00
|
|
|
|
|
|
|
hr = IWbemServices_CancelAsyncCall( services, &sink );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK || broken(hr == WBEM_E_NOT_FOUND), "got %#lx\n", hr );
|
2013-05-16 12:04:03 +02:00
|
|
|
|
|
|
|
SysFreeString( wql );
|
|
|
|
SysFreeString( query );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_query_async( IWbemServices *services )
|
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_Process" );
|
2013-05-16 12:04:03 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQueryAsync( services, wql, query, 0, NULL, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == WBEM_E_INVALID_PARAMETER, "got %#lx\n", hr );
|
2013-05-16 12:04:03 +02:00
|
|
|
|
|
|
|
hr = IWbemServices_ExecQueryAsync( services, wql, query, 0, NULL, &sink );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK || broken(hr == WBEM_E_NOT_FOUND), "got %#lx\n", hr );
|
2013-05-16 12:04:03 +02:00
|
|
|
|
|
|
|
hr = IWbemServices_CancelAsyncCall( services, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == WBEM_E_INVALID_PARAMETER, "got %#lx\n", hr );
|
2013-05-14 14:01:50 +02:00
|
|
|
|
|
|
|
hr = IWbemServices_CancelAsyncCall( services, &sink );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2013-05-14 14:01:50 +02:00
|
|
|
|
|
|
|
SysFreeString( wql );
|
|
|
|
SysFreeString( query );
|
|
|
|
}
|
|
|
|
|
2019-02-15 18:04:52 +01:00
|
|
|
static void test_query_semisync( IWbemServices *services )
|
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_Dummy" );
|
2019-02-15 18:04:52 +01:00
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
ULONG count;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_FORWARD_ONLY,
|
|
|
|
NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2019-02-15 18:04:52 +01:00
|
|
|
|
|
|
|
count = 1;
|
|
|
|
obj = (void *)0xdeadbeef;
|
|
|
|
hr = IEnumWbemClassObject_Next( result, -1, 1, &obj, &count );
|
2022-01-29 00:37:00 +01:00
|
|
|
todo_wine
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == WBEM_E_INVALID_CLASS, "unexpected hr %#lx\n", hr );
|
|
|
|
ok( count == 0, "unexpected count %lu\n", count );
|
|
|
|
ok( obj == (void *)0xdeadbeef, "got object %p\n", obj );
|
2019-02-15 18:04:52 +01:00
|
|
|
|
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
|
|
|
|
SysFreeString( wql );
|
|
|
|
SysFreeString( query );
|
|
|
|
}
|
|
|
|
|
2014-03-31 11:25:54 +02:00
|
|
|
static void test_GetNames( IWbemServices *services )
|
2014-03-24 11:42:00 +01:00
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_OperatingSystem" );
|
2014-03-24 11:42:00 +01:00
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2014-03-24 11:42:00 +01:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
SAFEARRAY *names;
|
|
|
|
ULONG count;
|
|
|
|
VARIANT val;
|
|
|
|
|
|
|
|
IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
|
|
|
if (!count) break;
|
|
|
|
|
2020-08-10 12:09:10 +02:00
|
|
|
hr = IWbemClassObject_GetNames( obj, NULL, 0, NULL, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == WBEM_E_INVALID_PARAMETER, "got %#lx\n", hr );
|
2020-08-10 12:09:10 +02:00
|
|
|
|
|
|
|
hr = IWbemClassObject_GetNames( obj, NULL, 0, NULL, &names );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2020-08-10 12:09:10 +02:00
|
|
|
SafeArrayDestroy( names );
|
|
|
|
|
|
|
|
hr = IWbemClassObject_GetNames( obj, NULL, WBEM_FLAG_ALWAYS, NULL, &names );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2020-08-10 12:09:10 +02:00
|
|
|
SafeArrayDestroy( names );
|
|
|
|
|
|
|
|
hr = IWbemClassObject_GetNames( obj, NULL, WBEM_FLAG_ALWAYS | WBEM_MASK_CONDITION_ORIGIN, NULL, &names );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2020-08-10 12:09:10 +02:00
|
|
|
SafeArrayDestroy( names );
|
|
|
|
|
2014-03-24 11:42:00 +01:00
|
|
|
VariantInit( &val );
|
|
|
|
hr = IWbemClassObject_GetNames( obj, NULL, WBEM_FLAG_NONSYSTEM_ONLY, &val, &names );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2014-03-24 11:42:00 +01:00
|
|
|
|
|
|
|
SafeArrayDestroy( names );
|
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
}
|
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2014-08-04 23:29:16 +02:00
|
|
|
static void test_SystemSecurity( IWbemServices *services )
|
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR class = SysAllocString( L"__SystemSecurity" ), method;
|
2014-08-04 23:29:16 +02:00
|
|
|
IWbemClassObject *reg, *out;
|
|
|
|
VARIANT retval, var_sd;
|
|
|
|
void *data;
|
|
|
|
SECURITY_DESCRIPTOR_RELATIVE *sd;
|
|
|
|
CIMTYPE type;
|
|
|
|
HRESULT hr;
|
|
|
|
BYTE sid_admin_buffer[SECURITY_MAX_SID_SIZE];
|
|
|
|
SID *sid_admin = (SID*)sid_admin_buffer;
|
|
|
|
DWORD sid_size;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
hr = IWbemServices_GetObject( services, class, 0, NULL, ®, NULL );
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
win_skip( "__SystemSecurity not available\n" );
|
|
|
|
return;
|
|
|
|
}
|
2017-10-02 20:35:05 +02:00
|
|
|
IWbemClassObject_Release( reg );
|
2014-08-04 23:29:16 +02:00
|
|
|
|
|
|
|
sid_size = sizeof(sid_admin_buffer);
|
|
|
|
ret = CreateWellKnownSid( WinBuiltinAdministratorsSid, NULL, sid_admin, &sid_size );
|
|
|
|
ok( ret, "CreateWellKnownSid failed\n" );
|
|
|
|
|
|
|
|
out = NULL;
|
2020-02-25 11:39:53 +01:00
|
|
|
method = SysAllocString( L"GetSD" );
|
2014-08-04 23:29:16 +02:00
|
|
|
hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, NULL, &out, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK || hr == WBEM_E_ACCESS_DENIED, "failed to execute method %#lx\n", hr );
|
2014-08-04 23:29:16 +02:00
|
|
|
SysFreeString( method );
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &retval );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( out, L"ReturnValue", 0, &retval, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get return value %#lx\n", hr );
|
|
|
|
ok( V_VT( &retval ) == VT_I4, "unexpected variant type %#x\n", V_VT( &retval ) );
|
|
|
|
ok( !V_I4( &retval ), "unexpected error %lu\n", V_UI4( &retval ) );
|
|
|
|
ok( type == CIM_UINT32, "unexpected type %#lx\n", type );
|
2014-08-04 23:29:16 +02:00
|
|
|
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &var_sd );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( out, L"SD", 0, &var_sd, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get names %#lx\n", hr );
|
|
|
|
ok( V_VT( &var_sd ) == (VT_UI1|VT_ARRAY), "unexpected variant type %#x\n", V_VT( &var_sd ) );
|
|
|
|
ok( type == (CIM_UINT8|CIM_FLAG_ARRAY), "unexpected type %#lx\n", type );
|
2014-08-04 23:29:16 +02:00
|
|
|
|
|
|
|
hr = SafeArrayAccessData( V_ARRAY( &var_sd ), &data );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "SafeArrayAccessData failed %#lx\n", hr );
|
2014-08-04 23:29:16 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
sd = data;
|
|
|
|
|
|
|
|
ok( (sd->Control & SE_SELF_RELATIVE) == SE_SELF_RELATIVE, "relative flag unset\n" );
|
|
|
|
ok( sd->Owner != 0, "no owner SID\n");
|
|
|
|
ok( sd->Group != 0, "no owner SID\n");
|
|
|
|
ok( EqualSid( (PSID)((LPBYTE)sd + sd->Owner), sid_admin ), "unexpected owner SID\n" );
|
|
|
|
ok( EqualSid( (PSID)((LPBYTE)sd + sd->Group), sid_admin ), "unexpected group SID\n" );
|
|
|
|
|
|
|
|
hr = SafeArrayUnaccessData( V_ARRAY( &var_sd ) );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "SafeArrayUnaccessData failed %#lx\n", hr );
|
2014-08-04 23:29:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VariantClear( &var_sd );
|
|
|
|
IWbemClassObject_Release( out );
|
|
|
|
}
|
|
|
|
else if (hr == WBEM_E_ACCESS_DENIED)
|
|
|
|
win_skip( "insufficient privs to test __SystemSecurity\n" );
|
|
|
|
|
|
|
|
SysFreeString( class );
|
|
|
|
}
|
|
|
|
|
2021-01-21 12:36:39 +01:00
|
|
|
static void test_Win32_NetworkAdapter( IWbemServices *services )
|
|
|
|
{
|
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_NetworkAdapter" );
|
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD count;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2021-01-21 12:36:39 +01:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
2021-01-21 12:36:42 +01:00
|
|
|
VARIANT val;
|
|
|
|
CIMTYPE type;
|
|
|
|
|
2021-01-21 12:36:39 +01:00
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
|
2021-01-21 12:36:42 +01:00
|
|
|
check_property( obj, L"Description", VT_BSTR, CIM_STRING );
|
2021-01-21 12:36:39 +01:00
|
|
|
check_property( obj, L"DeviceID", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"Index", VT_I4, CIM_UINT32 );
|
2021-01-21 12:36:40 +01:00
|
|
|
check_property( obj, L"Name", VT_BSTR, CIM_STRING );
|
2021-01-21 12:36:42 +01:00
|
|
|
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &val );
|
|
|
|
hr = IWbemClassObject_Get( obj, L"ServiceName", 0, &val, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get service name %#lx\n", hr );
|
2021-01-21 12:36:42 +01:00
|
|
|
ok( V_VT( &val ) == VT_BSTR || broken(V_VT( &val ) == VT_NULL) /* win2k8 */,
|
|
|
|
"unexpected variant type 0x%x\n", V_VT( &val ) );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( type == CIM_STRING, "unexpected type %#lx\n", type );
|
2021-01-21 12:36:42 +01:00
|
|
|
VariantClear( &val );
|
|
|
|
|
2021-01-21 12:36:40 +01:00
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
SysFreeString( query );
|
2021-01-21 12:36:41 +01:00
|
|
|
|
|
|
|
query = SysAllocString( L"SELECT * FROM Win32_NetworkAdapter WHERE PNPDeviceID LIKE \"PCI\\\\%\"" );
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2021-01-21 12:36:41 +01:00
|
|
|
SysFreeString( query );
|
|
|
|
|
|
|
|
query = SysAllocString( L"SELECT * FROM Win32_NetworkAdapter WHERE PNPDeviceID LIKE \"PCI\\%\"" );
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
todo_wine ok( hr == WBEM_E_INVALID_QUERY, "got %#lx\n", hr );
|
2021-01-21 12:36:41 +01:00
|
|
|
SysFreeString( query );
|
2021-01-21 12:36:40 +01:00
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_Win32_NetworkAdapterConfiguration( IWbemServices *services )
|
|
|
|
{
|
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_NetworkAdapterConfiguration" );
|
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemClassObject *obj;
|
2021-11-08 23:26:14 +01:00
|
|
|
CIMTYPE type;
|
2021-01-21 12:36:40 +01:00
|
|
|
HRESULT hr;
|
|
|
|
DWORD count;
|
2021-11-08 23:26:14 +01:00
|
|
|
VARIANT val;
|
2021-01-21 12:36:40 +01:00
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2021-01-21 12:36:40 +01:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
|
|
|
|
check_property( obj, L"Description", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"Index", VT_I4, CIM_UINT32 );
|
|
|
|
check_property( obj, L"IPEnabled", VT_BOOL, CIM_BOOLEAN );
|
2021-11-08 23:26:14 +01:00
|
|
|
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &val );
|
|
|
|
hr = IWbemClassObject_Get( obj, L"DNSDomain", 0, &val, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2021-11-08 23:26:14 +01:00
|
|
|
ok( V_VT( &val ) == VT_BSTR || V_VT( &val ) == VT_NULL, "unexpected variant type 0x%x\n", V_VT( &val ) );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( type == CIM_STRING, "unexpected type %#lx\n", type );
|
2021-11-08 23:26:14 +01:00
|
|
|
trace( "DNSDomain %s\n", wine_dbgstr_w(V_BSTR( &val )) );
|
|
|
|
VariantClear( &val );
|
|
|
|
|
2021-01-21 12:36:39 +01:00
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2018-03-02 11:54:58 +01:00
|
|
|
static void test_Win32_OperatingSystem( IWbemServices *services )
|
2016-10-05 09:46:28 +02:00
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_OperatingSystem" );
|
2016-10-05 09:46:28 +02:00
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
CIMTYPE type;
|
|
|
|
ULONG count;
|
|
|
|
VARIANT val;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "IWbemServices_ExecQuery failed %#lx\n", hr );
|
2016-10-05 09:46:28 +02:00
|
|
|
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "IEnumWbemClassObject_Next failed %#lx\n", hr );
|
2016-10-05 09:46:28 +02:00
|
|
|
|
2018-10-09 15:25:02 +02:00
|
|
|
hr = IWbemClassObject_BeginEnumeration( obj, 0 );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2018-10-09 15:25:02 +02:00
|
|
|
|
2018-10-09 15:25:03 +02:00
|
|
|
while (IWbemClassObject_Next( obj, 0, NULL, NULL, NULL, NULL ) == S_OK) {}
|
|
|
|
|
2018-10-09 15:25:02 +02:00
|
|
|
hr = IWbemClassObject_EndEnumeration( obj );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2018-10-09 15:25:02 +02:00
|
|
|
|
2022-04-28 12:43:22 +02:00
|
|
|
check_property( obj, L"BootDevice", VT_BSTR, CIM_STRING );
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"BuildNumber", VT_BSTR, CIM_STRING );
|
2022-04-28 12:43:19 +02:00
|
|
|
check_property( obj, L"BuildType", VT_BSTR, CIM_STRING );
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"Caption", VT_BSTR, CIM_STRING );
|
2016-10-05 09:46:28 +02:00
|
|
|
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &val );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( obj, L"CSDVersion", 0, &val, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get csdversion %#lx\n", hr );
|
2016-10-05 09:46:28 +02:00
|
|
|
ok( V_VT( &val ) == VT_BSTR || V_VT( &val ) == VT_NULL, "unexpected variant type 0x%x\n", V_VT( &val ) );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( type == CIM_STRING, "unexpected type %#lx\n", type );
|
2016-10-05 09:46:28 +02:00
|
|
|
trace( "csdversion: %s\n", wine_dbgstr_w(V_BSTR( &val )) );
|
|
|
|
VariantClear( &val );
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"FreePhysicalMemory", VT_BSTR, CIM_UINT64 );
|
2022-04-28 12:43:25 +02:00
|
|
|
check_property( obj, L"FreeVirtualMemory", VT_BSTR, CIM_UINT64 );
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"Name", VT_BSTR, CIM_STRING );
|
2016-10-05 09:46:28 +02:00
|
|
|
|
2019-03-25 10:06:05 +01:00
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &val );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( obj, L"OperatingSystemSKU", 0, &val, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK || broken(hr == WBEM_E_NOT_FOUND) /* winxp */, "failed to get operatingsystemsku %#lx\n", hr );
|
2019-03-25 10:06:05 +01:00
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
ok( V_VT( &val ) == VT_I4, "unexpected variant type 0x%x\n", V_VT( &val ) );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( type == CIM_UINT32, "unexpected type %#lx\n", type );
|
|
|
|
trace( "operatingsystemsku: %#lx\n", V_I4( &val ) );
|
2019-03-25 10:06:05 +01:00
|
|
|
VariantClear( &val );
|
|
|
|
}
|
|
|
|
|
2016-10-05 09:46:28 +02:00
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &val );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( obj, L"OSProductSuite", 0, &val, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get osproductsuite %#lx\n", hr );
|
2016-10-05 09:46:28 +02:00
|
|
|
ok( V_VT( &val ) == VT_I4 || broken(V_VT( &val ) == VT_NULL) /* winxp */, "unexpected variant type 0x%x\n", V_VT( &val ) );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( type == CIM_UINT32, "unexpected type %#lx\n", type );
|
|
|
|
trace( "osproductsuite: %ld (%#lx)\n", V_I4( &val ), V_I4( &val ) );
|
2016-10-05 09:46:28 +02:00
|
|
|
VariantClear( &val );
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"CSName", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"CurrentTimeZone", VT_I2, CIM_SINT16 );
|
|
|
|
check_property( obj, L"Manufacturer", VT_BSTR, CIM_STRING );
|
2022-04-28 12:43:21 +02:00
|
|
|
check_property( obj, L"Organization", VT_BSTR, CIM_STRING );
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"OSType", VT_I4, CIM_UINT16 );
|
2021-03-14 21:22:51 +01:00
|
|
|
check_property( obj, L"ProductType", VT_I4, CIM_UINT32 );
|
2022-04-28 12:43:20 +02:00
|
|
|
check_property( obj, L"RegisteredUser", VT_BSTR, CIM_STRING );
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"ServicePackMajorVersion", VT_I4, CIM_UINT16 );
|
|
|
|
check_property( obj, L"ServicePackMinorVersion", VT_I4, CIM_UINT16 );
|
|
|
|
check_property( obj, L"SuiteMask", VT_I4, CIM_UINT32 );
|
|
|
|
check_property( obj, L"Version", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"TotalVisibleMemorySize", VT_BSTR, CIM_UINT64 );
|
|
|
|
check_property( obj, L"TotalVirtualMemorySize", VT_BSTR, CIM_UINT64 );
|
2021-10-15 10:41:28 +02:00
|
|
|
check_property( obj, L"Status", VT_BSTR, CIM_STRING );
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"SystemDrive", VT_BSTR, CIM_STRING );
|
2022-04-28 12:43:23 +02:00
|
|
|
check_property( obj, L"WindowsDirectory", VT_BSTR, CIM_STRING );
|
2019-04-24 12:58:11 +02:00
|
|
|
|
2016-10-05 09:46:28 +02:00
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2018-03-02 11:54:58 +01:00
|
|
|
static void test_Win32_ComputerSystemProduct( IWbemServices *services )
|
2016-10-24 10:04:21 +02:00
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_ComputerSystemProduct" );
|
2016-10-24 10:04:21 +02:00
|
|
|
IEnumWbemClassObject *result;
|
2016-11-16 17:02:07 +01:00
|
|
|
IWbemClassObject *obj;
|
2016-10-24 10:04:21 +02:00
|
|
|
HRESULT hr;
|
|
|
|
DWORD count;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
win_skip( "Win32_ComputerSystemProduct not available\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-11-16 17:02:07 +01:00
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2016-10-24 10:04:21 +02:00
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"IdentifyingNumber", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"Name", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"SKUNumber", VT_NULL, CIM_STRING );
|
|
|
|
check_property( obj, L"UUID", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"Vendor", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"Version", VT_BSTR, CIM_STRING );
|
2018-02-05 16:08:15 +01:00
|
|
|
|
2016-11-16 17:02:07 +01:00
|
|
|
IWbemClassObject_Release( obj );
|
2016-10-24 10:04:21 +02:00
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2022-04-24 23:41:10 +02:00
|
|
|
static void test_Win32_PageFileUsage( IWbemServices *services )
|
|
|
|
{
|
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_PageFileUsage" );
|
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD count;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
|
|
|
ok( hr == S_OK , "got %#lx\n", hr );
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
|
|
|
|
check_property( obj, L"Name", VT_BSTR, CIM_STRING );
|
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2018-03-02 11:54:58 +01:00
|
|
|
static void test_Win32_PhysicalMemory( IWbemServices *services )
|
2016-11-16 17:02:07 +01:00
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_PhysicalMemory" );
|
2016-11-16 17:02:07 +01:00
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemClassObject *obj;
|
2020-07-17 17:33:10 +02:00
|
|
|
CIMTYPE type;
|
|
|
|
VARIANT val;
|
2016-11-16 17:02:07 +01:00
|
|
|
DWORD count;
|
2020-07-17 17:33:10 +02:00
|
|
|
HRESULT hr;
|
2016-11-16 17:02:07 +01:00
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
win_skip( "Win32_PhysicalMemory not available\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-17 17:33:10 +02:00
|
|
|
for (;;)
|
2018-08-06 18:11:01 +02:00
|
|
|
{
|
2020-07-17 17:33:10 +02:00
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
|
2020-07-07 09:54:22 +02:00
|
|
|
check_property( obj, L"BankLabel", VT_BSTR, CIM_STRING );
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"Capacity", VT_BSTR, CIM_UINT64 );
|
2020-07-07 09:54:22 +02:00
|
|
|
check_property( obj, L"Caption", VT_BSTR, CIM_STRING );
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"DeviceLocator", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"FormFactor", VT_I4, CIM_UINT16 );
|
|
|
|
check_property( obj, L"MemoryType", VT_I4, CIM_UINT16 );
|
2020-07-17 17:33:10 +02:00
|
|
|
|
2020-07-17 17:33:11 +02:00
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &val );
|
|
|
|
hr = IWbemClassObject_Get( obj, L"ConfiguredClockSpeed", 0, &val, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK || broken(hr == WBEM_E_NOT_FOUND) /* < win10 */, "got %#lx\n", hr );
|
2020-07-17 17:33:11 +02:00
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( V_VT( &val ) == VT_I4, "unexpected variant type %#x\n", V_VT( &val ) );
|
|
|
|
ok( type == CIM_UINT32, "unexpected type %#lx\n", type );
|
|
|
|
trace( "ConfiguredClockSpeed %ld\n", V_I4( &val ) );
|
2020-07-17 17:33:11 +02:00
|
|
|
}
|
|
|
|
|
2020-07-17 17:33:10 +02:00
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &val );
|
|
|
|
hr = IWbemClassObject_Get( obj, L"PartNumber", 0, &val, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
|
|
|
ok( V_VT( &val ) == VT_BSTR || V_VT( &val ) == VT_NULL, "unexpected variant type %#x\n", V_VT( &val ) );
|
|
|
|
ok( type == CIM_STRING, "unexpected type %#lx\n", type );
|
2020-07-17 17:33:10 +02:00
|
|
|
trace( "PartNumber %s\n", wine_dbgstr_w(V_BSTR( &val )) );
|
|
|
|
VariantClear( &val );
|
|
|
|
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &val );
|
|
|
|
hr = IWbemClassObject_Get( obj, L"SerialNumber", 0, &val, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
|
|
|
ok( V_VT( &val ) == VT_BSTR || V_VT( &val ) == VT_NULL, "unexpected variant type %#x\n", V_VT( &val ) );
|
|
|
|
ok( type == CIM_STRING, "unexpected type %#lx\n", type );
|
2020-07-17 17:33:10 +02:00
|
|
|
trace( "SerialNumber %s\n", wine_dbgstr_w(V_BSTR( &val )) );
|
|
|
|
VariantClear( &val );
|
|
|
|
|
2018-08-06 18:11:01 +02:00
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
}
|
2020-07-17 17:33:10 +02:00
|
|
|
|
2017-10-02 20:35:05 +02:00
|
|
|
IEnumWbemClassObject_Release( result );
|
2016-11-16 17:02:07 +01:00
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2018-03-02 11:54:58 +01:00
|
|
|
static void test_Win32_IP4RouteTable( IWbemServices *services )
|
2017-02-01 14:18:50 +01:00
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_IP4RouteTable" );
|
2017-02-01 14:18:50 +01:00
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD count;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
win_skip( "Win32_IP4RouteTable not available\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"Destination", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"InterfaceIndex", VT_I4, CIM_SINT32 );
|
|
|
|
check_property( obj, L"NextHop", VT_BSTR, CIM_STRING );
|
2017-02-01 14:18:50 +01:00
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
}
|
|
|
|
|
2019-01-14 20:15:43 +01:00
|
|
|
IEnumWbemClassObject_Release( result );
|
2017-02-01 14:18:50 +01:00
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2018-02-05 16:08:17 +01:00
|
|
|
static void test_Win32_Processor( IWbemServices *services )
|
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_Processor" );
|
2018-02-05 16:08:17 +01:00
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
VARIANT val;
|
|
|
|
CIMTYPE type;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD count;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2018-02-05 16:08:17 +01:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"Architecture", VT_I4, CIM_UINT16 );
|
|
|
|
check_property( obj, L"Caption", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"CpuStatus", VT_I4, CIM_UINT16 );
|
|
|
|
check_property( obj, L"Family", VT_I4, CIM_UINT16 );
|
|
|
|
check_property( obj, L"Level", VT_I4, CIM_UINT16 );
|
|
|
|
check_property( obj, L"Manufacturer", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"Name", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"ProcessorId", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"Revision", VT_I4, CIM_UINT16 );
|
|
|
|
check_property( obj, L"Version", VT_BSTR, CIM_STRING );
|
2018-02-05 16:08:17 +01:00
|
|
|
|
2019-01-25 10:44:14 +01:00
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &val );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( obj, L"NumberOfLogicalProcessors", 0, &val, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK || broken(hr == WBEM_E_NOT_FOUND) /* win2k3 */, "got %#lx\n", hr );
|
2019-01-25 10:44:14 +01:00
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( V_VT( &val ) == VT_I4, "unexpected variant type %#x\n", V_VT( &val ) );
|
|
|
|
ok( type == CIM_UINT32, "unexpected type %#lx\n", type );
|
|
|
|
trace( "numlogicalprocessors %ld\n", V_I4( &val ) );
|
2019-01-25 10:44:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &val );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( obj, L"NumberOfCores", 0, &val, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK || broken(hr == WBEM_E_NOT_FOUND) /* win2k3 */, "got %#lx\n", hr );
|
2019-01-25 10:44:14 +01:00
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( V_VT( &val ) == VT_I4, "unexpected variant type %#x\n", V_VT( &val ) );
|
|
|
|
ok( type == CIM_UINT32, "unexpected type %#lx\n", type );
|
|
|
|
trace( "numcores %ld\n", V_I4( &val ) );
|
2019-01-25 10:44:14 +01:00
|
|
|
}
|
|
|
|
|
2018-02-05 16:08:17 +01:00
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
}
|
|
|
|
|
2019-01-14 20:15:43 +01:00
|
|
|
IEnumWbemClassObject_Release( result );
|
2018-02-05 16:08:17 +01:00
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2018-03-01 17:20:40 +01:00
|
|
|
static void test_Win32_VideoController( IWbemServices *services )
|
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_VideoController" );
|
2018-03-01 17:20:40 +01:00
|
|
|
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_VideoController not available\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
|
2020-09-30 12:37:39 +02:00
|
|
|
check_property( obj, L"__CLASS", VT_BSTR, CIM_STRING );
|
2021-10-13 12:48:44 +02:00
|
|
|
check_property( obj, L"__DERIVATION", VT_BSTR | VT_ARRAY, CIM_STRING | CIM_FLAG_ARRAY );
|
2020-09-30 12:37:39 +02:00
|
|
|
check_property( obj, L"__GENUS", VT_I4, CIM_SINT32 );
|
|
|
|
check_property( obj, L"__NAMESPACE", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"__PATH", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"__PROPERTY_COUNT", VT_I4, CIM_SINT32 );
|
|
|
|
check_property( obj, L"__RELPATH", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"__SERVER", VT_BSTR, CIM_STRING );
|
2020-04-20 10:38:11 +02:00
|
|
|
check_property( obj, L"AdapterCompatibility", VT_BSTR, CIM_STRING );
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"Availability", VT_I4, CIM_UINT16 );
|
|
|
|
check_property( obj, L"ConfigManagerErrorCode", VT_I4, CIM_UINT32 );
|
|
|
|
check_property( obj, L"DriverDate", VT_BSTR, CIM_DATETIME );
|
2018-03-01 17:20:40 +01:00
|
|
|
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &val );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( obj, L"InstalledDisplayDrivers", 0, &val, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2018-03-01 17:20:40 +01:00
|
|
|
ok( V_VT( &val ) == VT_BSTR || V_VT( &val ) == VT_NULL, "unexpected variant type 0x%x\n", V_VT( &val ) );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( type == CIM_STRING, "unexpected type %#lx\n", type );
|
2018-03-01 17:20:40 +01:00
|
|
|
trace( "installeddisplaydrivers %s\n", wine_dbgstr_w(V_BSTR( &val )) );
|
|
|
|
VariantClear( &val );
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"Status", VT_BSTR, CIM_STRING );
|
2018-03-01 17:20:40 +01:00
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
}
|
|
|
|
|
2020-09-30 12:37:39 +02:00
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
SysFreeString( query );
|
|
|
|
|
|
|
|
query = SysAllocString( L"SELECT AdapterRAM FROM Win32_VideoController" );
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
win_skip( "Win32_VideoController not available\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
check_property( obj, L"__CLASS", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"__GENUS", VT_I4, CIM_SINT32 );
|
|
|
|
check_property( obj, L"__NAMESPACE", VT_NULL, CIM_STRING );
|
|
|
|
check_property( obj, L"__PATH", VT_NULL, CIM_STRING );
|
|
|
|
check_property( obj, L"__PROPERTY_COUNT", VT_I4, CIM_SINT32 );
|
|
|
|
check_property( obj, L"__RELPATH", VT_NULL, CIM_STRING );
|
|
|
|
check_property( obj, L"__SERVER", VT_NULL, CIM_STRING );
|
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
}
|
|
|
|
|
2019-01-14 20:15:43 +01:00
|
|
|
IEnumWbemClassObject_Release( result );
|
2018-03-01 17:20:40 +01:00
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2018-03-02 11:55:00 +01:00
|
|
|
static void test_Win32_Printer( IWbemServices *services )
|
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_Printer" );
|
2018-03-02 11:55:00 +01:00
|
|
|
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_Printer not available\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"Attributes", VT_I4, CIM_UINT32 );
|
|
|
|
check_property( obj, L"DeviceId", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"HorizontalResolution", VT_I4, CIM_UINT32 );
|
2018-03-02 11:55:00 +01:00
|
|
|
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
memset( &val, 0, sizeof(val) );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( obj, L"Location", 0, &val, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2018-03-02 11:55:00 +01:00
|
|
|
ok( V_VT( &val ) == VT_BSTR || V_VT( &val ) == VT_NULL, "unexpected variant type 0x%x\n", V_VT( &val ) );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( type == CIM_STRING, "unexpected type %#lx\n", type );
|
2018-03-02 11:55:00 +01:00
|
|
|
trace( "location %s\n", wine_dbgstr_w(V_BSTR( &val )) );
|
|
|
|
VariantClear( &val );
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"PortName", VT_BSTR, CIM_STRING );
|
2018-03-02 11:55:00 +01:00
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
}
|
|
|
|
|
2019-01-14 20:15:43 +01:00
|
|
|
IEnumWbemClassObject_Release( result );
|
2018-03-02 11:55:00 +01:00
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2018-08-06 18:11:15 +02:00
|
|
|
static void test_Win32_PnPEntity( IWbemServices *services )
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IEnumWbemClassObject *enm;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
VARIANT val;
|
|
|
|
CIMTYPE type;
|
|
|
|
ULONG count, i;
|
|
|
|
BSTR bstr;
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
bstr = SysAllocString( L"Win32_PnPEntity" );
|
2018-08-06 18:11:15 +02:00
|
|
|
hr = IWbemServices_CreateInstanceEnum( services, bstr, 0, NULL, &enm );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2018-08-06 18:11:15 +02:00
|
|
|
SysFreeString( bstr );
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
bstr = SysAllocString( L"DeviceId" );
|
2018-08-06 18:11:15 +02:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
hr = IEnumWbemClassObject_Next( enm, 1000, 1, &obj, &count );
|
|
|
|
ok( (count == 1 && (hr == WBEM_S_FALSE || hr == WBEM_S_NO_ERROR)) ||
|
|
|
|
(count == 0 && (hr == WBEM_S_FALSE || hr == WBEM_S_TIMEDOUT)),
|
2022-02-14 12:14:59 +01:00
|
|
|
"got %#lx with %lu objects returned\n", hr, count );
|
2018-08-06 18:11:15 +02:00
|
|
|
|
|
|
|
if (count == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
hr = IWbemClassObject_Get( obj, bstr, 0, &val, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2018-08-06 18:11:15 +02:00
|
|
|
|
|
|
|
if (SUCCEEDED( hr ))
|
|
|
|
{
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( V_VT( &val ) == VT_BSTR, "unexpected variant type %#x\n", V_VT( &val ) );
|
|
|
|
ok( type == CIM_STRING, "unexpected type %#lx\n", type );
|
2018-08-06 18:11:15 +02:00
|
|
|
VariantClear( &val );
|
|
|
|
}
|
|
|
|
}
|
2019-10-04 21:58:40 +02:00
|
|
|
IWbemClassObject_Release( obj );
|
2018-08-06 18:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SysFreeString( bstr );
|
|
|
|
IEnumWbemClassObject_Release( enm );
|
|
|
|
}
|
|
|
|
|
2019-09-17 13:41:45 +02:00
|
|
|
static void test_Win32_WinSAT( IWbemServices *services )
|
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_WinSAT" );
|
2019-09-17 13:41:45 +02:00
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD count;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK || broken(hr == WBEM_E_INVALID_CLASS) /* win2k8 */, "got %#lx\n", hr );
|
2019-09-17 13:41:45 +02:00
|
|
|
if (hr == WBEM_E_INVALID_CLASS)
|
|
|
|
{
|
|
|
|
win_skip( "class not found\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"CPUScore", VT_R4, CIM_REAL32 );
|
|
|
|
check_property( obj, L"D3DScore", VT_R4, CIM_REAL32 );
|
|
|
|
check_property( obj, L"DiskScore", VT_R4, CIM_REAL32 );
|
|
|
|
check_property( obj, L"GraphicsScore", VT_R4, CIM_REAL32 );
|
|
|
|
check_property( obj, L"MemoryScore", VT_R4, CIM_REAL32 );
|
|
|
|
check_property( obj, L"WinSATAssessmentState", VT_I4, CIM_UINT32 );
|
|
|
|
check_property( obj, L"WinSPRLevel", VT_R4, CIM_REAL32 );
|
2019-09-17 13:41:45 +02:00
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2022-01-19 12:43:07 +01:00
|
|
|
static void test_SoftwareLicensingProduct( IWbemServices *services )
|
|
|
|
{
|
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM SoftwareLicensingProduct" );
|
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD count;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK , "got %#lx\n", hr );
|
2022-01-19 12:43:07 +01:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
check_property( obj, L"LicenseIsAddon", VT_BOOL, CIM_BOOLEAN );
|
|
|
|
check_property( obj, L"LicenseStatus", VT_I4, CIM_UINT32 );
|
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2020-02-25 11:39:52 +01:00
|
|
|
static void test_Win32_DesktopMonitor( IWbemServices *services )
|
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_DesktopMonitor" );
|
2020-02-25 11:39:52 +01:00
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD count;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2020-02-25 11:39:52 +01:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
|
|
|
|
check_property( obj, L"Name", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"PixelsPerXlogicalInch", VT_I4, CIM_UINT32 );
|
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2020-05-26 10:18:43 +02:00
|
|
|
static void test_Win32_DiskDrive( IWbemServices *services )
|
|
|
|
{
|
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_DiskDrive" );
|
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD count;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2020-05-26 10:18:43 +02:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
|
|
|
|
check_property( obj, L"DeviceID", VT_BSTR, CIM_STRING );
|
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2019-09-20 13:37:15 +02:00
|
|
|
static void test_Win32_DisplayControllerConfiguration( IWbemServices *services )
|
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" );
|
|
|
|
BSTR query = SysAllocString( L"SELECT * FROM Win32_DisplayControllerConfiguration" );
|
2019-09-20 13:37:15 +02:00
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD count;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2019-09-20 13:37:15 +02:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"BitsPerPixel", VT_I4, CIM_UINT32 );
|
|
|
|
check_property( obj, L"Caption", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"HorizontalResolution", VT_I4, CIM_UINT32 );
|
|
|
|
check_property( obj, L"Name", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"VerticalResolution", VT_I4, CIM_UINT32 );
|
2019-09-20 13:37:15 +02:00
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2019-09-30 17:12:58 +02:00
|
|
|
static void test_Win32_QuickFixEngineering( IWbemServices *services )
|
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_QuickFixEngineering" );
|
2019-09-30 17:12:58 +02:00
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD count, total = 0;
|
|
|
|
VARIANT caption;
|
|
|
|
CIMTYPE type;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2019-09-30 17:12:58 +02:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
VariantInit( &caption );
|
2020-02-25 11:39:53 +01:00
|
|
|
hr = IWbemClassObject_Get( obj, L"Caption", 0, &caption, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get caption %#lx\n", hr );
|
2019-09-30 17:12:58 +02:00
|
|
|
ok( V_VT( &caption ) == VT_BSTR || V_VT( &caption ) == VT_NULL /* winxp */,
|
2022-02-14 12:14:59 +01:00
|
|
|
"unexpected variant type %#x\n", V_VT( &caption ) );
|
|
|
|
ok( type == CIM_STRING, "unexpected type %#lx\n", type );
|
2019-09-30 17:12:58 +02:00
|
|
|
|
2020-02-25 11:39:53 +01:00
|
|
|
check_property( obj, L"HotFixID", VT_BSTR, CIM_STRING );
|
2019-09-30 17:12:58 +02:00
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
if (total++ >= 10) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2020-07-08 12:26:02 +02:00
|
|
|
static void test_Win32_SoundDevice( IWbemServices *services )
|
|
|
|
{
|
|
|
|
BSTR wql = SysAllocString( L"wql" );
|
|
|
|
BSTR query = SysAllocString( L"SELECT * FROM Win32_SoundDevice" );
|
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD count;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2020-07-08 12:26:02 +02:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
|
|
|
|
if (hr != S_OK) break;
|
|
|
|
|
2020-10-29 13:15:49 +01:00
|
|
|
check_property( obj, L"DeviceID", VT_BSTR, CIM_STRING );
|
|
|
|
check_property( obj, L"Manufacturer", VT_BSTR, CIM_STRING );
|
2020-07-08 12:26:02 +02:00
|
|
|
check_property( obj, L"Name", VT_BSTR, CIM_STRING );
|
2020-10-29 13:15:49 +01:00
|
|
|
check_property( obj, L"PNPDeviceID", VT_BSTR, CIM_STRING );
|
2020-07-08 12:26:02 +02:00
|
|
|
check_property( obj, L"ProductName", VT_BSTR, CIM_STRING );
|
2020-10-29 13:15:49 +01:00
|
|
|
check_property( obj, L"Status", VT_BSTR, CIM_STRING );
|
2020-07-08 12:26:02 +02:00
|
|
|
check_property( obj, L"StatusInfo", VT_I4, CIM_UINT16 );
|
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2020-12-18 13:51:26 +01:00
|
|
|
static void test_SystemRestore( IWbemServices *services )
|
|
|
|
{
|
|
|
|
WCHAR path[MAX_PATH];
|
|
|
|
BSTR class, method;
|
|
|
|
IWbemClassObject *service, *sig_in, *in, *out;
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
class = SysAllocString( L"SystemRestore" );
|
|
|
|
hr = IWbemServices_GetObject( services, class, 0, NULL, &service, NULL );
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
2021-01-20 11:15:57 +01:00
|
|
|
win_skip( "SystemRestore not available\n" );
|
2020-12-18 13:51:26 +01:00
|
|
|
SysFreeString( class );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
check_property( service, L"CreationTime", VT_NULL, CIM_STRING );
|
|
|
|
check_property( service, L"Description", VT_NULL, CIM_STRING );
|
2021-01-20 11:15:57 +01:00
|
|
|
if (0) /* FIXME */
|
|
|
|
{
|
2020-12-18 13:51:26 +01:00
|
|
|
check_property( service, L"EventType", VT_NULL, CIM_UINT32 );
|
|
|
|
check_property( service, L"RestorePointType", VT_NULL, CIM_UINT32 );
|
|
|
|
check_property( service, L"SequenceNumber", VT_NULL, CIM_UINT32 );
|
2021-01-20 11:15:57 +01:00
|
|
|
}
|
2020-12-18 13:51:26 +01:00
|
|
|
|
|
|
|
method = SysAllocString( L"Enable" );
|
|
|
|
sig_in = NULL;
|
|
|
|
hr = IWbemClassObject_GetMethod( service, method, 0, &sig_in, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get Enable method %#lx\n", hr );
|
2020-12-18 13:51:26 +01:00
|
|
|
|
|
|
|
hr = IWbemClassObject_SpawnInstance( sig_in, 0, &in );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to spawn instance %#lx\n", hr );
|
2020-12-18 13:51:26 +01:00
|
|
|
|
|
|
|
GetWindowsDirectoryW(path, ARRAY_SIZE(path));
|
|
|
|
path[3] = 0; /* otherwise XP fails */
|
|
|
|
V_VT( &var ) = VT_BSTR;
|
|
|
|
V_BSTR( &var ) = SysAllocString( path );
|
|
|
|
hr = IWbemClassObject_Put( in, L"Drive", 0, &var, 0 );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to set Drive %#lx\n", hr );
|
2020-12-18 13:51:26 +01:00
|
|
|
SysFreeString( V_BSTR( &var ) );
|
|
|
|
|
|
|
|
out = NULL;
|
|
|
|
hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, in, &out, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK || hr == WBEM_E_ACCESS_DENIED, "failed to execute method %#lx\n", hr );
|
2021-01-20 11:15:58 +01:00
|
|
|
if (hr == S_OK)
|
2020-12-18 13:51:26 +01:00
|
|
|
{
|
|
|
|
VariantInit( &var );
|
|
|
|
hr = IWbemClassObject_Get( out, L"ReturnValue", 0, &var, NULL, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get return value %#lx\n", hr );
|
|
|
|
ok( V_I4( &var ) == ERROR_SUCCESS, "unexpected error %ld\n", V_UI4( &var ) );
|
2020-12-18 13:51:26 +01:00
|
|
|
|
|
|
|
IWbemClassObject_Release( out );
|
|
|
|
}
|
|
|
|
else if (hr == WBEM_E_ACCESS_DENIED)
|
|
|
|
win_skip( "insufficient privs to test SystemRestore\n" );
|
|
|
|
|
|
|
|
IWbemClassObject_Release( in );
|
|
|
|
IWbemClassObject_Release( sig_in );
|
|
|
|
IWbemClassObject_Release( service );
|
|
|
|
SysFreeString( method );
|
|
|
|
SysFreeString( class );
|
|
|
|
}
|
|
|
|
|
2021-02-09 10:12:54 +01:00
|
|
|
static void test_Win32_LogicalDisk( IWbemServices *services )
|
|
|
|
{
|
|
|
|
BSTR wql = SysAllocString( L"wql" );
|
|
|
|
BSTR query = SysAllocString( L"SELECT * FROM Win32_LogicalDisk" );
|
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD count;
|
|
|
|
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2021-02-09 10:12:54 +01:00
|
|
|
|
|
|
|
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"Name", VT_BSTR, CIM_STRING );
|
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumWbemClassObject_Release( result );
|
|
|
|
SysFreeString( query );
|
|
|
|
SysFreeString( wql );
|
|
|
|
}
|
|
|
|
|
2021-09-13 16:13:28 +02:00
|
|
|
static void test_empty_namespace( IWbemLocator *locator )
|
|
|
|
{
|
|
|
|
BSTR path = SysAllocString( L"ROOT" );
|
|
|
|
BSTR wql = SysAllocString( L"wql" );
|
|
|
|
IEnumWbemClassObject *result;
|
|
|
|
IWbemServices *services;
|
|
|
|
BSTR query;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IWbemLocator_ConnectServer( locator, path, NULL, NULL, NULL, 0, NULL, NULL, &services );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get IWbemServices interface %#lx\n", hr );
|
2021-09-13 16:13:28 +02:00
|
|
|
|
|
|
|
query = SysAllocString( L"SELECT * FROM __ASSOCIATORS" );
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == WBEM_E_INVALID_CLASS, "Query failed: %#lx\n", hr );
|
2021-09-13 16:13:28 +02:00
|
|
|
SysFreeString( query );
|
|
|
|
|
|
|
|
query = SysAllocString( L"SELECT * FROM Win32_OperatingSystem" );
|
|
|
|
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == WBEM_E_INVALID_CLASS, "got %#lx\n", hr );
|
2021-09-13 16:13:28 +02:00
|
|
|
SysFreeString( query );
|
|
|
|
|
|
|
|
SysFreeString( wql );
|
|
|
|
SysFreeString( path );
|
|
|
|
IWbemServices_Release( services );
|
|
|
|
}
|
|
|
|
|
2021-12-03 14:20:25 +01:00
|
|
|
static void test_MSSMBios_RawSMBiosTables( IWbemLocator *locator )
|
|
|
|
{
|
|
|
|
BSTR path = SysAllocString( L"ROOT\\WMI" );
|
|
|
|
BSTR bios = SysAllocString( L"MSSMBios_RawSMBiosTables" );
|
|
|
|
IWbemServices *services;
|
|
|
|
IEnumWbemClassObject *iter;
|
|
|
|
IWbemClassObject *obj;
|
|
|
|
VARIANT val;
|
|
|
|
CIMTYPE type;
|
|
|
|
ULONG count;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IWbemLocator_ConnectServer( locator, path, NULL, NULL, NULL, 0, NULL, NULL, &services );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get IWbemServices interface %#lx\n", hr );
|
2021-12-03 14:20:25 +01:00
|
|
|
|
|
|
|
hr = IWbemServices_CreateInstanceEnum( services, bios, 0, NULL, &iter );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2021-12-03 14:20:25 +01:00
|
|
|
|
|
|
|
hr = IEnumWbemClassObject_Next( iter, WBEM_INFINITE, 1, &obj, &count );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
2021-12-03 14:20:25 +01:00
|
|
|
|
|
|
|
type = 0;
|
|
|
|
VariantInit( &val );
|
|
|
|
hr = IWbemClassObject_Get( obj, L"SMBiosData", 0, &val, &type, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "got %#lx\n", hr );
|
|
|
|
todo_wine ok( V_VT( &val ) == (VT_UI1 | VT_ARRAY), "got %#x\n", V_VT(&val) );
|
|
|
|
ok( type == (CIM_UINT8 | CIM_FLAG_ARRAY), "got %#lx\n", type );
|
2021-12-03 14:20:25 +01:00
|
|
|
|
|
|
|
IWbemClassObject_Release( obj );
|
|
|
|
IEnumWbemClassObject_Release( iter );
|
|
|
|
IWbemServices_Release( services );
|
|
|
|
SysFreeString( path );
|
|
|
|
SysFreeString( bios );
|
|
|
|
}
|
|
|
|
|
2012-06-18 09:32:22 +02:00
|
|
|
START_TEST(query)
|
|
|
|
{
|
2020-02-25 11:39:53 +01:00
|
|
|
BSTR path = SysAllocString( L"ROOT\\CIMV2" );
|
2012-10-12 14:26:58 +02:00
|
|
|
IWbemLocator *locator;
|
|
|
|
IWbemServices *services;
|
2020-08-31 21:01:25 +02:00
|
|
|
DWORD authn_svc;
|
2021-05-18 09:49:45 +02:00
|
|
|
char **argv;
|
2012-10-12 14:26:58 +02:00
|
|
|
HRESULT hr;
|
2021-05-18 09:49:45 +02:00
|
|
|
int argc;
|
|
|
|
|
|
|
|
argc = winetest_get_mainargs( &argv );
|
|
|
|
if (argc >= 3)
|
|
|
|
{
|
|
|
|
if (!strcmp( argv[2], "created_process" ))
|
|
|
|
test_Win32_Process_created_process();
|
|
|
|
return;
|
|
|
|
}
|
2012-10-12 14:26:58 +02:00
|
|
|
|
2012-06-18 09:32:22 +02:00
|
|
|
CoInitialize( NULL );
|
|
|
|
CoInitializeSecurity( NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT,
|
|
|
|
RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL );
|
2012-10-12 14:26:58 +02:00
|
|
|
hr = CoCreateInstance( &CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER, &IID_IWbemLocator,
|
|
|
|
(void **)&locator );
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
win_skip("can't create instance of WbemLocator\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
hr = IWbemLocator_ConnectServer( locator, path, NULL, NULL, NULL, 0, NULL, NULL, &services );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get IWbemServices interface %#lx\n", hr );
|
2012-10-12 14:26:58 +02:00
|
|
|
|
2020-08-31 21:01:25 +02:00
|
|
|
hr = CoQueryProxyBlanket( (IUnknown *)services, NULL, NULL, NULL, NULL, NULL, NULL, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to query proxy blanket %#lx\n", hr );
|
2020-08-31 21:01:25 +02:00
|
|
|
|
|
|
|
hr = CoQueryProxyBlanket( (IUnknown *)services, &authn_svc, NULL, NULL, NULL, NULL, NULL, NULL );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to query proxy blanket %#lx\n", hr );
|
2020-08-31 21:01:25 +02:00
|
|
|
|
2012-10-12 14:26:58 +02:00
|
|
|
hr = CoSetProxyBlanket( (IUnknown *)services, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL,
|
|
|
|
RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to set proxy blanket %#lx\n", hr );
|
2012-10-12 14:26:58 +02:00
|
|
|
|
2019-08-28 14:14:25 +02:00
|
|
|
test_GetNames( services );
|
2020-07-28 11:35:07 +02:00
|
|
|
test_IEnumWbemClassObject_Next( services );
|
2016-04-18 11:04:49 +02:00
|
|
|
test_associators( services );
|
2013-05-14 14:01:50 +02:00
|
|
|
test_notification_query_async( services );
|
2013-05-16 12:04:03 +02:00
|
|
|
test_query_async( services );
|
2019-02-15 18:04:52 +01:00
|
|
|
test_query_semisync( services );
|
2019-08-28 14:14:25 +02:00
|
|
|
test_select( services );
|
|
|
|
|
|
|
|
/* classes */
|
2022-01-19 12:43:07 +01:00
|
|
|
test_SoftwareLicensingProduct( services );
|
2019-08-28 14:14:25 +02:00
|
|
|
test_StdRegProv( services );
|
2014-08-04 23:29:16 +02:00
|
|
|
test_SystemSecurity( services );
|
2019-08-28 14:14:25 +02:00
|
|
|
test_Win32_Baseboard( services );
|
|
|
|
test_Win32_ComputerSystem( services );
|
2018-03-02 11:54:58 +01:00
|
|
|
test_Win32_ComputerSystemProduct( services );
|
2019-08-28 14:14:25 +02:00
|
|
|
test_Win32_Bios( services );
|
2020-02-25 11:39:52 +01:00
|
|
|
test_Win32_DesktopMonitor( services );
|
2020-05-26 10:18:43 +02:00
|
|
|
test_Win32_DiskDrive( services );
|
2019-09-20 13:37:15 +02:00
|
|
|
test_Win32_DisplayControllerConfiguration( services );
|
2018-03-02 11:54:58 +01:00
|
|
|
test_Win32_IP4RouteTable( services );
|
2021-02-09 10:12:54 +01:00
|
|
|
test_Win32_LogicalDisk( services );
|
2021-01-21 12:36:39 +01:00
|
|
|
test_Win32_NetworkAdapter( services );
|
2021-01-21 12:36:40 +01:00
|
|
|
test_Win32_NetworkAdapterConfiguration( services );
|
2019-08-28 14:14:25 +02:00
|
|
|
test_Win32_OperatingSystem( services );
|
2022-04-24 23:41:10 +02:00
|
|
|
test_Win32_PageFileUsage( services );
|
2019-08-28 14:14:25 +02:00
|
|
|
test_Win32_PhysicalMemory( services );
|
|
|
|
test_Win32_PnPEntity( services );
|
|
|
|
test_Win32_Printer( services );
|
|
|
|
test_Win32_Process( services, FALSE );
|
|
|
|
test_Win32_Process( services, TRUE );
|
2018-02-05 16:08:17 +01:00
|
|
|
test_Win32_Processor( services );
|
2019-09-30 17:12:58 +02:00
|
|
|
test_Win32_QuickFixEngineering( services );
|
2019-08-28 14:14:25 +02:00
|
|
|
test_Win32_Service( services );
|
2020-07-08 12:26:02 +02:00
|
|
|
test_Win32_SoundDevice( services );
|
2019-08-28 14:14:25 +02:00
|
|
|
test_Win32_SystemEnclosure( services );
|
2018-03-01 17:20:40 +01:00
|
|
|
test_Win32_VideoController( services );
|
2019-09-17 13:41:45 +02:00
|
|
|
test_Win32_WinSAT( services );
|
2020-12-18 13:51:26 +01:00
|
|
|
test_SystemRestore( services );
|
2021-09-13 16:13:28 +02:00
|
|
|
test_empty_namespace( locator );
|
2021-12-03 14:20:25 +01:00
|
|
|
test_MSSMBios_RawSMBiosTables( locator );
|
2012-10-12 14:26:58 +02:00
|
|
|
|
2020-12-18 13:51:19 +01:00
|
|
|
SysFreeString( path );
|
|
|
|
IWbemServices_Release( services );
|
|
|
|
|
|
|
|
/* Some tests need other connection point */
|
|
|
|
path = SysAllocString( L"ROOT\\DEFAULT" );
|
|
|
|
hr = IWbemLocator_ConnectServer( locator, path, NULL, NULL, NULL, 0, NULL, NULL, &services );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to get IWbemServices interface %#lx\n", hr );
|
2020-12-18 13:51:19 +01:00
|
|
|
hr = CoSetProxyBlanket( (IUnknown *)services, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL,
|
|
|
|
RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE );
|
2022-02-14 12:14:59 +01:00
|
|
|
ok( hr == S_OK, "failed to set proxy blanket %#lx\n", hr );
|
2020-12-18 13:51:19 +01:00
|
|
|
|
|
|
|
test_StdRegProv( services );
|
2020-12-18 13:51:26 +01:00
|
|
|
test_SystemRestore( services );
|
2020-12-18 13:51:19 +01:00
|
|
|
|
2012-10-12 14:26:58 +02:00
|
|
|
SysFreeString( path );
|
|
|
|
IWbemServices_Release( services );
|
|
|
|
IWbemLocator_Release( locator );
|
2012-06-18 09:32:22 +02:00
|
|
|
CoUninitialize();
|
|
|
|
}
|