2010-01-17 14:10:32 +01:00
|
|
|
/*
|
2010-03-20 15:24:53 +01:00
|
|
|
* Copyright 2010 Maarten Lankhorst for CodeWeavers
|
2010-01-17 14:10:32 +01:00
|
|
|
*
|
|
|
|
* 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 NONAMELESSUNION
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#ifdef STANDALONE
|
|
|
|
#include "initguid.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "unknwn.h"
|
|
|
|
#include "uuids.h"
|
|
|
|
#include "mmdeviceapi.h"
|
2010-04-22 22:59:58 +02:00
|
|
|
#include "devpkey.h"
|
2010-01-17 14:10:32 +01:00
|
|
|
|
2015-05-01 20:11:12 +02:00
|
|
|
static BOOL (WINAPI *pIsWow64Process)(HANDLE, BOOL *);
|
|
|
|
|
|
|
|
static const WCHAR software_renderW[] =
|
|
|
|
{ 'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s','\\',
|
|
|
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
|
|
|
'M','M','D','e','v','i','c','e','s','\\',
|
|
|
|
'A','u','d','i','o','\\',
|
|
|
|
'R','e','n','d','e','r',0 };
|
|
|
|
static const WCHAR propertiesW[] = {'P','r','o','p','e','r','t','i','e','s',0};
|
|
|
|
|
|
|
|
|
2010-01-17 14:10:32 +01:00
|
|
|
static void test_propertystore(IPropertyStore *store)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
2010-04-22 22:59:58 +02:00
|
|
|
PROPVARIANT pv;
|
|
|
|
char temp[128];
|
|
|
|
temp[sizeof(temp)-1] = 0;
|
2010-01-17 14:10:32 +01:00
|
|
|
|
2010-04-22 22:59:58 +02:00
|
|
|
pv.vt = VT_EMPTY;
|
2010-01-17 14:10:32 +01:00
|
|
|
hr = IPropertyStore_GetValue(store, &PKEY_AudioEndpoint_GUID, &pv);
|
|
|
|
ok(hr == S_OK, "Failed with %08x\n", hr);
|
2010-04-22 22:59:58 +02:00
|
|
|
ok(pv.vt == VT_LPWSTR, "Value should be %i, is %i\n", VT_LPWSTR, pv.vt);
|
|
|
|
if (hr == S_OK && pv.vt == VT_LPWSTR)
|
2010-01-17 14:10:32 +01:00
|
|
|
{
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, pv.u.pwszVal, -1, temp, sizeof(temp)-1, NULL, NULL);
|
|
|
|
trace("guid: %s\n", temp);
|
|
|
|
CoTaskMemFree(pv.u.pwszVal);
|
|
|
|
}
|
2010-04-22 22:59:58 +02:00
|
|
|
|
|
|
|
pv.vt = VT_EMPTY;
|
|
|
|
hr = IPropertyStore_GetValue(store, (const PROPERTYKEY*)&DEVPKEY_DeviceInterface_FriendlyName, &pv);
|
|
|
|
ok(hr == S_OK, "Failed with %08x\n", hr);
|
|
|
|
ok(pv.vt == VT_EMPTY, "Key should not be found\n");
|
|
|
|
|
|
|
|
pv.vt = VT_EMPTY;
|
|
|
|
hr = IPropertyStore_GetValue(store, (const PROPERTYKEY*)&DEVPKEY_DeviceInterface_Enabled, &pv);
|
2011-02-09 01:06:14 +01:00
|
|
|
ok(hr == S_OK, "Failed with %08x\n", hr);
|
2010-04-22 22:59:58 +02:00
|
|
|
ok(pv.vt == VT_EMPTY, "Key should not be found\n");
|
|
|
|
|
|
|
|
pv.vt = VT_EMPTY;
|
|
|
|
hr = IPropertyStore_GetValue(store, (const PROPERTYKEY*)&DEVPKEY_DeviceInterface_ClassGuid, &pv);
|
2011-02-09 01:06:14 +01:00
|
|
|
ok(hr == S_OK, "Failed with %08x\n", hr);
|
2010-04-22 22:59:58 +02:00
|
|
|
ok(pv.vt == VT_EMPTY, "Key should not be found\n");
|
2010-01-17 14:10:32 +01:00
|
|
|
}
|
|
|
|
|
2012-04-05 21:16:40 +02:00
|
|
|
static void test_deviceinterface(IPropertyStore *store)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
PROPVARIANT pv;
|
|
|
|
|
|
|
|
static const PROPERTYKEY deviceinterface_key = {
|
|
|
|
{0x233164c8, 0x1b2c, 0x4c7d, {0xbc, 0x68, 0xb6, 0x71, 0x68, 0x7a, 0x25, 0x67}}, 1
|
|
|
|
};
|
|
|
|
|
|
|
|
pv.vt = VT_EMPTY;
|
|
|
|
hr = IPropertyStore_GetValue(store, &deviceinterface_key, &pv);
|
|
|
|
ok(hr == S_OK, "GetValue failed: %08x\n", hr);
|
|
|
|
ok(pv.vt == VT_LPWSTR, "Got wrong variant type: 0x%x\n", pv.vt);
|
|
|
|
trace("device interface: %s\n", wine_dbgstr_w(pv.u.pwszVal));
|
|
|
|
CoTaskMemFree(pv.u.pwszVal);
|
|
|
|
}
|
|
|
|
|
2013-09-29 23:26:35 +02:00
|
|
|
static void test_getat(IPropertyStore *store)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD propcount;
|
|
|
|
DWORD prop;
|
|
|
|
PROPERTYKEY pkey;
|
|
|
|
BOOL found_name = FALSE;
|
|
|
|
BOOL found_desc = FALSE;
|
|
|
|
char temp[128];
|
|
|
|
temp[sizeof(temp)-1] = 0;
|
|
|
|
|
|
|
|
hr = IPropertyStore_GetCount(store, &propcount);
|
|
|
|
|
|
|
|
ok(hr == S_OK, "Failed with %08x\n", hr);
|
|
|
|
ok(propcount > 0, "Propcount %d should be greather than zero\n", propcount);
|
|
|
|
|
|
|
|
for (prop = 0; prop < propcount; prop++) {
|
|
|
|
hr = IPropertyStore_GetAt(store, prop, &pkey);
|
|
|
|
ok(hr == S_OK, "Failed with %08x\n", hr);
|
|
|
|
if (IsEqualPropertyKey(pkey, DEVPKEY_Device_FriendlyName))
|
|
|
|
found_name = TRUE;
|
|
|
|
if (IsEqualPropertyKey(pkey, DEVPKEY_Device_DeviceDesc))
|
|
|
|
found_desc = TRUE;
|
|
|
|
}
|
2013-10-17 14:00:17 +02:00
|
|
|
ok(found_name || broken(!found_name), "DEVPKEY_Device_FriendlyName not found\n");
|
2013-09-29 23:26:35 +02:00
|
|
|
ok(found_desc == TRUE, "DEVPKEY_Device_DeviceDesc not found\n");
|
|
|
|
}
|
|
|
|
|
2015-05-01 20:11:12 +02:00
|
|
|
static void test_setvalue_on_wow64(IPropertyStore *store)
|
|
|
|
{
|
|
|
|
PROPVARIANT pv;
|
|
|
|
HRESULT hr;
|
|
|
|
LONG ret;
|
|
|
|
WCHAR *guidW;
|
|
|
|
HKEY root, props, devkey;
|
|
|
|
DWORD type, regval, size;
|
|
|
|
|
|
|
|
static const PROPERTYKEY PKEY_Bogus = {
|
|
|
|
{0x1da5d803, 0xd492, 0x4edd, {0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x00}}, 0x7f
|
|
|
|
};
|
|
|
|
static const WCHAR bogusW[] = {'{','1','D','A','5','D','8','0','3','-','D','4','9','2','-','4','E','D','D','-','8','C','2','3','-','E','0','C','0','F','F','E','E','7','F','0','0','}',',','1','2','7',0};
|
|
|
|
|
|
|
|
PropVariantInit(&pv);
|
|
|
|
|
|
|
|
pv.vt = VT_EMPTY;
|
|
|
|
hr = IPropertyStore_GetValue(store, &PKEY_AudioEndpoint_GUID, &pv);
|
|
|
|
ok(hr == S_OK, "Failed to get Endpoint GUID: %08x\n", hr);
|
|
|
|
|
|
|
|
guidW = pv.u.pwszVal;
|
|
|
|
|
|
|
|
pv.vt = VT_UI4;
|
|
|
|
pv.u.ulVal = 0xAB;
|
|
|
|
|
|
|
|
hr = IPropertyStore_SetValue(store, &PKEY_Bogus, &pv);
|
|
|
|
ok(hr == S_OK || hr == E_ACCESSDENIED, "SetValue failed: %08x\n", hr);
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
win_skip("Missing permission to write to registry\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pv.u.ulVal = 0x00;
|
|
|
|
|
|
|
|
hr = IPropertyStore_GetValue(store, &PKEY_Bogus, &pv);
|
|
|
|
ok(hr == S_OK, "GetValue failed: %08x\n", hr);
|
|
|
|
ok(pv.u.ulVal == 0xAB, "Got wrong value: 0x%x\n", pv.u.ulVal);
|
|
|
|
|
|
|
|
/* should find the key in 64-bit view */
|
|
|
|
ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE, software_renderW, 0, KEY_READ|KEY_WOW64_64KEY, &root);
|
|
|
|
ok(ret == ERROR_SUCCESS, "Couldn't open mmdevices Render key: %u\n", ret);
|
|
|
|
|
|
|
|
ret = RegOpenKeyExW(root, guidW, 0, KEY_READ|KEY_WOW64_64KEY, &devkey);
|
|
|
|
ok(ret == ERROR_SUCCESS, "Couldn't open mmdevice guid key: %u\n", ret);
|
|
|
|
|
|
|
|
ret = RegOpenKeyExW(devkey, propertiesW, 0, KEY_READ|KEY_WOW64_64KEY, &props);
|
|
|
|
ok(ret == ERROR_SUCCESS, "Couldn't open mmdevice property key: %u\n", ret);
|
|
|
|
|
|
|
|
/* Note: the registry key exists even without calling IPropStore::Commit */
|
|
|
|
size = sizeof(regval);
|
2016-04-20 11:52:11 +02:00
|
|
|
ret = RegQueryValueExW(props, bogusW, NULL, &type, (LPBYTE)®val, &size);
|
2015-05-01 20:11:12 +02:00
|
|
|
ok(ret == ERROR_SUCCESS, "Couldn't get bogus propertykey value: %u\n", ret);
|
|
|
|
ok(type == REG_DWORD, "Got wrong value type: %u\n", type);
|
|
|
|
ok(regval == 0xAB, "Got wrong value: 0x%x\n", regval);
|
|
|
|
|
|
|
|
RegCloseKey(props);
|
|
|
|
RegCloseKey(devkey);
|
|
|
|
RegCloseKey(root);
|
|
|
|
|
|
|
|
CoTaskMemFree(guidW);
|
|
|
|
|
|
|
|
/* should NOT find the key in 32-bit view */
|
|
|
|
ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE, software_renderW, 0, KEY_READ, &root);
|
|
|
|
ok(ret == ERROR_FILE_NOT_FOUND, "Wrong error when opening mmdevices Render key: %u\n", ret);
|
|
|
|
}
|
|
|
|
|
2010-01-17 14:10:32 +01:00
|
|
|
START_TEST(propstore)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IMMDeviceEnumerator *mme = NULL;
|
|
|
|
IMMDevice *dev = NULL;
|
|
|
|
IPropertyStore *store;
|
2015-05-01 20:11:12 +02:00
|
|
|
BOOL is_wow64 = FALSE;
|
|
|
|
HMODULE hk32 = GetModuleHandleA("kernel32.dll");
|
|
|
|
|
|
|
|
pIsWow64Process = (void *)GetProcAddress(hk32, "IsWow64Process");
|
|
|
|
|
|
|
|
if (pIsWow64Process)
|
|
|
|
pIsWow64Process(GetCurrentProcess(), &is_wow64);
|
2010-01-17 14:10:32 +01:00
|
|
|
|
|
|
|
CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
|
|
|
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&mme);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
skip("mmdevapi not available: 0x%08x\n", hr);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(mme, eRender, eMultimedia, &dev);
|
|
|
|
ok(hr == S_OK || hr == E_NOTFOUND, "GetDefaultAudioEndpoint failed: 0x%08x\n", hr);
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
if (hr == E_NOTFOUND)
|
|
|
|
skip("No sound card available\n");
|
|
|
|
else
|
|
|
|
skip("GetDefaultAudioEndpoint returns 0x%08x\n", hr);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
store = NULL;
|
|
|
|
hr = IMMDevice_OpenPropertyStore(dev, 3, &store);
|
2010-04-06 14:26:23 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Wrong hr returned: %08x\n", hr);
|
2010-01-17 14:10:32 +01:00
|
|
|
if (hr != S_OK)
|
|
|
|
/* It seems on windows returning with E_INVALIDARG doesn't
|
|
|
|
* set store to NULL, so just don't set store to non-null
|
|
|
|
* before calling this function
|
|
|
|
*/
|
|
|
|
ok(!store, "Store set to non-NULL on failure: %p/%08x\n", store, hr);
|
|
|
|
else if (store)
|
|
|
|
IPropertyStore_Release(store);
|
|
|
|
hr = IMMDevice_OpenPropertyStore(dev, STGM_READ, NULL);
|
2010-04-06 14:26:23 +02:00
|
|
|
ok(hr == E_POINTER, "Wrong hr returned: %08x\n", hr);
|
2010-01-17 14:10:32 +01:00
|
|
|
|
|
|
|
store = NULL;
|
2015-05-01 20:11:12 +02:00
|
|
|
hr = IMMDevice_OpenPropertyStore(dev, STGM_READWRITE, &store);
|
|
|
|
if(hr == E_ACCESSDENIED)
|
|
|
|
hr = IMMDevice_OpenPropertyStore(dev, STGM_READ, &store);
|
2010-04-06 14:26:23 +02:00
|
|
|
ok(hr == S_OK, "Opening valid store returned %08x\n", hr);
|
2010-01-17 14:10:32 +01:00
|
|
|
if (store)
|
|
|
|
{
|
|
|
|
test_propertystore(store);
|
2012-04-05 21:16:40 +02:00
|
|
|
test_deviceinterface(store);
|
2013-09-29 23:26:35 +02:00
|
|
|
test_getat(store);
|
2015-05-01 20:11:12 +02:00
|
|
|
if (is_wow64)
|
|
|
|
test_setvalue_on_wow64(store);
|
2010-01-17 14:10:32 +01:00
|
|
|
IPropertyStore_Release(store);
|
|
|
|
}
|
|
|
|
IMMDevice_Release(dev);
|
|
|
|
cleanup:
|
|
|
|
if (mme)
|
2012-08-15 11:45:03 +02:00
|
|
|
IMMDeviceEnumerator_Release(mme);
|
2010-01-17 14:10:32 +01:00
|
|
|
CoUninitialize();
|
|
|
|
}
|