Commit 337f3848 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

wbemprox: Implement Win32_Volume.

parent d423d76f
......@@ -482,6 +482,13 @@ static const struct column col_videocontroller[] =
{ L"VideoModeDescription", CIM_STRING|COL_FLAG_DYNAMIC },
{ L"VideoProcessor", CIM_STRING|COL_FLAG_DYNAMIC },
};
static const struct column col_volume[] =
{
{ L"DeviceId", CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
{ L"DriveLetter", CIM_STRING|COL_FLAG_DYNAMIC },
};
static const struct column col_winsat[] =
{
{ L"CPUScore", CIM_REAL32 },
......@@ -923,6 +930,13 @@ struct record_videocontroller
const WCHAR *videomodedescription;
const WCHAR *videoprocessor;
};
struct record_volume
{
const WCHAR *deviceid;
const WCHAR *driveletter;
};
struct record_winsat
{
FLOAT cpuscore;
......@@ -4180,6 +4194,60 @@ static enum fill_status fill_videocontroller( struct table *table, const struct
return status;
}
static WCHAR *get_volume_driveletter( const WCHAR *volume )
{
DWORD len = 0;
WCHAR *ret;
if (!GetVolumePathNamesForVolumeNameW( volume, NULL, 0, &len ) && GetLastError() != ERROR_MORE_DATA) return NULL;
if (!(ret = malloc( len * sizeof(WCHAR) ))) return NULL;
if (!GetVolumePathNamesForVolumeNameW( volume, ret, len, &len ) || !wcschr( ret, ':' ))
{
free( ret );
return NULL;
}
wcschr( ret, ':' )[1] = 0;
return ret;
}
static enum fill_status fill_volume( struct table *table, const struct expr *cond )
{
struct record_volume *rec;
enum fill_status status = FILL_STATUS_UNFILTERED;
UINT row = 0, offset = 0;
WCHAR path[MAX_PATH];
HANDLE handle;
if (!resize_table( table, 2, sizeof(*rec) )) return FILL_STATUS_FAILED;
handle = FindFirstVolumeW( path, ARRAY_SIZE(path) );
while (handle != INVALID_HANDLE_VALUE)
{
if (!resize_table( table, row + 1, sizeof(*rec) )) return FILL_STATUS_FAILED;
rec = (struct record_volume *)(table->data + offset);
rec->deviceid = wcsdup( path );
rec->driveletter = get_volume_driveletter( path );
if (!match_row( table, row, cond, &status )) free_row_values( table, row );
else
{
offset += sizeof(*rec);
row++;
}
if (!FindNextVolumeW( handle, path, ARRAY_SIZE(path) ))
{
FindVolumeClose( handle );
handle = INVALID_HANDLE_VALUE;
}
}
TRACE("created %u rows\n", row);
table->num_rows = row;
return status;
}
static WCHAR *get_sounddevice_pnpdeviceid( DXGI_ADAPTER_DESC *desc )
{
static const WCHAR fmtW[] = L"HDAUDIO\\FUNC_01&VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%04X\\0&DEADBEEF&0&DEAD";
......@@ -4262,6 +4330,7 @@ static struct table cimv2_builtin_classes[] =
{ L"Win32_SoundDevice", C(col_sounddevice), 0, 0, NULL, fill_sounddevice },
{ L"Win32_SystemEnclosure", C(col_systemenclosure), 0, 0, NULL, fill_systemenclosure },
{ L"Win32_VideoController", C(col_videocontroller), 0, 0, NULL, fill_videocontroller },
{ L"Win32_Volume", C(col_volume), 0, 0, NULL, fill_volume },
{ L"Win32_WinSAT", C(col_winsat), D(data_winsat) },
};
......
......@@ -1752,6 +1752,45 @@ static void test_Win32_VideoController( IWbemServices *services )
SysFreeString( wql );
}
static void test_Win32_Volume( IWbemServices *services )
{
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_Volume" );
IEnumWbemClassObject *result;
IWbemClassObject *obj;
HRESULT hr;
VARIANT val;
CIMTYPE type;
DWORD count;
hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result );
if (hr != S_OK)
{
win_skip( "Win32_Volume not available\n" );
return;
}
for (;;)
{
hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count );
if (hr != S_OK) break;
check_property( obj, L"DeviceID", VT_BSTR, CIM_STRING );
type = 0xdeadbeef;
memset( &val, 0, sizeof(val) );
hr = IWbemClassObject_Get( obj, L"DriveLetter", 0, &val, &type, NULL );
ok( hr == S_OK, "got %#lx\n", hr );
ok( V_VT( &val ) == VT_BSTR || V_VT( &val ) == VT_NULL, "unexpected variant type 0x%x\n", V_VT( &val ) );
ok( type == CIM_STRING, "unexpected type %#lx\n", type );
trace( "driveletter %s\n", wine_dbgstr_w(V_BSTR( &val )) );
VariantClear( &val );
}
IEnumWbemClassObject_Release( result );
SysFreeString( query );
SysFreeString( wql );
}
static void test_Win32_Printer( IWbemServices *services )
{
BSTR wql = SysAllocString( L"wql" ), query = SysAllocString( L"SELECT * FROM Win32_Printer" );
......@@ -2306,6 +2345,7 @@ START_TEST(query)
test_Win32_SoundDevice( services );
test_Win32_SystemEnclosure( services );
test_Win32_VideoController( services );
test_Win32_Volume( services );
test_Win32_WinSAT( services );
test_SystemRestore( services );
test_empty_namespace( locator );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment