ReactOS 0.4.15-dev-7842-g558ab78
propstore.c File Reference
#include "wine/test.h"
#include "unknwn.h"
#include "uuids.h"
#include "mmdeviceapi.h"
#include "devpkey.h"
Include dependency graph for propstore.c:

Go to the source code of this file.

Macros

#define NONAMELESSUNION
 
#define COBJMACROS
 

Functions

static BOOL (WINAPI *pIsWow64Process)(HANDLE
 
static void test_propertystore (IPropertyStore *store)
 
static void test_deviceinterface (IPropertyStore *store)
 
static void test_getat (IPropertyStore *store)
 
static void test_setvalue_on_wow64 (IPropertyStore *store)
 
 START_TEST (propstore)
 

Variables

static BOOL *static const WCHAR software_renderW []
 
static const WCHAR propertiesW [] = {'P','r','o','p','e','r','t','i','e','s',0}
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 22 of file propstore.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 19 of file propstore.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pIsWow64Process)
static

◆ START_TEST()

START_TEST ( propstore  )

Definition at line 196 of file propstore.c.

197{
198 HRESULT hr;
200 IMMDevice *dev = NULL;
201 IPropertyStore *store;
203 HMODULE hk32 = GetModuleHandleA("kernel32.dll");
204
205 pIsWow64Process = (void *)GetProcAddress(hk32, "IsWow64Process");
206
207 if (pIsWow64Process)
208 pIsWow64Process(GetCurrentProcess(), &is_wow64);
209
211 hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&mme);
212 if (FAILED(hr))
213 {
214 skip("mmdevapi not available: 0x%08x\n", hr);
215 goto cleanup;
216 }
217
218 hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(mme, eRender, eMultimedia, &dev);
219 ok(hr == S_OK || hr == E_NOTFOUND, "GetDefaultAudioEndpoint failed: 0x%08x\n", hr);
220 if (hr != S_OK)
221 {
222 if (hr == E_NOTFOUND)
223 skip("No sound card available\n");
224 else
225 skip("GetDefaultAudioEndpoint returns 0x%08x\n", hr);
226 goto cleanup;
227 }
228 store = NULL;
229 hr = IMMDevice_OpenPropertyStore(dev, 3, &store);
230 ok(hr == E_INVALIDARG, "Wrong hr returned: %08x\n", hr);
231 if (hr != S_OK)
232 /* It seems on windows returning with E_INVALIDARG doesn't
233 * set store to NULL, so just don't set store to non-null
234 * before calling this function
235 */
236 ok(!store, "Store set to non-NULL on failure: %p/%08x\n", store, hr);
237 else if (store)
238 IPropertyStore_Release(store);
239 hr = IMMDevice_OpenPropertyStore(dev, STGM_READ, NULL);
240 ok(hr == E_POINTER, "Wrong hr returned: %08x\n", hr);
241
242 store = NULL;
243 hr = IMMDevice_OpenPropertyStore(dev, STGM_READWRITE, &store);
244 if(hr == E_ACCESSDENIED)
245 hr = IMMDevice_OpenPropertyStore(dev, STGM_READ, &store);
246 ok(hr == S_OK, "Opening valid store returned %08x\n", hr);
247 if (store)
248 {
249 test_propertystore(store);
251 test_getat(store);
252 if (is_wow64)
254 IPropertyStore_Release(store);
255 }
256 IMMDevice_Release(dev);
257cleanup:
258 if (mme)
259 IMMDeviceEnumerator_Release(mme);
261}
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define E_INVALIDARG
Definition: ddrawi.h:101
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define GetProcAddress(x, y)
Definition: compat.h:753
#define GetCurrentProcess()
Definition: compat.h:759
static void cleanup(void)
Definition: main.c:1335
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
BOOL is_wow64
Definition: msi.c:54
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
unsigned int BOOL
Definition: ntddk_ex.h:94
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
@ eRender
Definition: mmdeviceapi.idl:63
@ eMultimedia
Definition: mmdeviceapi.idl:72
static void test_setvalue_on_wow64(IPropertyStore *store)
Definition: propstore.c:129
static void test_getat(IPropertyStore *store)
Definition: propstore.c:100
static void test_deviceinterface(IPropertyStore *store)
Definition: propstore.c:83
static IMMDeviceEnumerator * mme
Definition: render.c:63
static void test_propertystore(void)
Definition: propstore.c:306
#define STGM_READWRITE
Definition: objbase.h:919
@ COINIT_MULTITHREADED
Definition: objbase.h:279
#define STGM_READ
Definition: objbase.h:917
HRESULT hr
Definition: shlfolder.c:183
#define E_ACCESSDENIED
Definition: winerror.h:2849
#define E_POINTER
Definition: winerror.h:2365

◆ test_deviceinterface()

static void test_deviceinterface ( IPropertyStore store)
static

Definition at line 83 of file propstore.c.

84{
85 HRESULT hr;
86 PROPVARIANT pv;
87
88 static const PROPERTYKEY deviceinterface_key = {
89 {0x233164c8, 0x1b2c, 0x4c7d, {0xbc, 0x68, 0xb6, 0x71, 0x68, 0x7a, 0x25, 0x67}}, 1
90 };
91
92 pv.vt = VT_EMPTY;
93 hr = IPropertyStore_GetValue(store, &deviceinterface_key, &pv);
94 ok(hr == S_OK, "GetValue failed: %08x\n", hr);
95 ok(pv.vt == VT_LPWSTR, "Got wrong variant type: 0x%x\n", pv.vt);
96 trace("device interface: %s\n", wine_dbgstr_w(pv.u.pwszVal));
98}
#define trace
Definition: atltest.h:70
@ VT_LPWSTR
Definition: compat.h:2325
@ VT_EMPTY
Definition: compat.h:2295
HRESULT WINAPI PropVariantClear(PROPVARIANT *pvar)
Definition: ole2.c:2968
#define wine_dbgstr_w
Definition: kernel32.h:34

Referenced by START_TEST().

◆ test_getat()

static void test_getat ( IPropertyStore store)
static

Definition at line 100 of file propstore.c.

101{
102 HRESULT hr;
103 DWORD propcount;
104 DWORD prop;
105 PROPERTYKEY pkey;
106 BOOL found_name = FALSE;
107 BOOL found_desc = FALSE;
108 char temp[128];
109 temp[sizeof(temp)-1] = 0;
110
111 hr = IPropertyStore_GetCount(store, &propcount);
112
113 ok(hr == S_OK, "Failed with %08x\n", hr);
114 ok(propcount > 0, "Propcount %d should be greater than zero\n", propcount);
115
116 for (prop = 0; prop < propcount; prop++) {
117 hr = IPropertyStore_GetAt(store, prop, &pkey);
118 ok(hr == S_OK, "Failed with %08x\n", hr);
119 if (IsEqualPropertyKey(pkey, DEVPKEY_Device_FriendlyName))
120 found_name = TRUE;
121 if (IsEqualPropertyKey(pkey, DEVPKEY_Device_DeviceDesc))
122 found_desc = TRUE;
123 }
124 ok(found_name ||
125 broken(!found_name) /* vista */, "DEVPKEY_Device_FriendlyName not found\n");
126 ok(found_desc, "DEVPKEY_Device_DeviceDesc not found\n");
127}
#define broken(x)
Definition: _sntprintf.h:21
#define TRUE
Definition: types.h:120
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IsEqualPropertyKey(a, b)
Definition: propkeydef.h:52
static calc_node_t temp
Definition: rpn_ieee.c:38

Referenced by START_TEST().

◆ test_propertystore()

static void test_propertystore ( IPropertyStore store)
static

Definition at line 46 of file propstore.c.

47{
48 HRESULT hr;
49 PROPVARIANT pv;
50 char temp[128];
51 temp[sizeof(temp)-1] = 0;
52
53 pv.vt = VT_EMPTY;
54 hr = IPropertyStore_GetValue(store, &PKEY_AudioEndpoint_GUID, &pv);
55 ok(hr == S_OK, "Failed with %08x\n", hr);
56 ok(pv.vt == VT_LPWSTR, "Value should be %i, is %i\n", VT_LPWSTR, pv.vt);
57 if (hr == S_OK && pv.vt == VT_LPWSTR)
58 {
59 WideCharToMultiByte(CP_ACP, 0, pv.u.pwszVal, -1, temp, sizeof(temp)-1, NULL, NULL);
60 trace("guid: %s\n", temp);
62 }
63
64 pv.vt = VT_EMPTY;
65 hr = IPropertyStore_GetValue(store, (const PROPERTYKEY*)&DEVPKEY_DeviceInterface_FriendlyName, &pv);
66 ok(hr == S_OK, "Failed with %08x\n", hr);
67 ok(pv.vt == VT_LPWSTR && pv.u.pwszVal, "FriendlyName value had wrong type: 0x%x or was NULL\n", pv.vt);
69
70 pv.vt = VT_EMPTY;
71 hr = IPropertyStore_GetValue(store, (const PROPERTYKEY*)&DEVPKEY_DeviceInterface_Enabled, &pv);
72 ok(hr == S_OK, "Failed with %08x\n", hr);
73 ok(pv.vt == VT_EMPTY, "Key should not be found\n");
75
76 pv.vt = VT_EMPTY;
77 hr = IPropertyStore_GetValue(store, (const PROPERTYKEY*)&DEVPKEY_DeviceInterface_ClassGuid, &pv);
78 ok(hr == S_OK, "Failed with %08x\n", hr);
79 ok(pv.vt == VT_EMPTY, "Key should not be found\n");
81}
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111

◆ test_setvalue_on_wow64()

static void test_setvalue_on_wow64 ( IPropertyStore store)
static

Definition at line 129 of file propstore.c.

130{
131 PROPVARIANT pv;
132 HRESULT hr;
133 LONG ret;
134 WCHAR *guidW;
135 HKEY root, props, devkey;
136 DWORD type, regval, size;
137
138 static const PROPERTYKEY PKEY_Bogus = {
139 {0x1da5d803, 0xd492, 0x4edd, {0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x00}}, 0x7f
140 };
141 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};
142
143 PropVariantInit(&pv);
144
145 pv.vt = VT_EMPTY;
146 hr = IPropertyStore_GetValue(store, &PKEY_AudioEndpoint_GUID, &pv);
147 ok(hr == S_OK, "Failed to get Endpoint GUID: %08x\n", hr);
148
149 guidW = pv.u.pwszVal;
150
151 pv.vt = VT_UI4;
152 pv.u.ulVal = 0xAB;
153
154 hr = IPropertyStore_SetValue(store, &PKEY_Bogus, &pv);
155 ok(hr == S_OK || hr == E_ACCESSDENIED, "SetValue failed: %08x\n", hr);
156 if (hr != S_OK)
157 {
158 win_skip("Missing permission to write to registry\n");
159 return;
160 }
161
162 pv.u.ulVal = 0x00;
163
164 hr = IPropertyStore_GetValue(store, &PKEY_Bogus, &pv);
165 ok(hr == S_OK, "GetValue failed: %08x\n", hr);
166 ok(pv.u.ulVal == 0xAB, "Got wrong value: 0x%x\n", pv.u.ulVal);
167
168 /* should find the key in 64-bit view */
170 ok(ret == ERROR_SUCCESS, "Couldn't open mmdevices Render key: %u\n", ret);
171
172 ret = RegOpenKeyExW(root, guidW, 0, KEY_READ|KEY_WOW64_64KEY, &devkey);
173 ok(ret == ERROR_SUCCESS, "Couldn't open mmdevice guid key: %u\n", ret);
174
176 ok(ret == ERROR_SUCCESS, "Couldn't open mmdevice property key: %u\n", ret);
177
178 /* Note: the registry key exists even without calling IPropStore::Commit */
179 size = sizeof(regval);
180 ret = RegQueryValueExW(props, bogusW, NULL, &type, (LPBYTE)&regval, &size);
181 ok(ret == ERROR_SUCCESS, "Couldn't get bogus propertykey value: %u\n", ret);
182 ok(type == REG_DWORD, "Got wrong value type: %u\n", type);
183 ok(regval == 0xAB, "Got wrong value: 0x%x\n", regval);
184
186 RegCloseKey(devkey);
188
189 CoTaskMemFree(guidW);
190
191 /* should NOT find the key in 32-bit view */
193 ok(ret == ERROR_FILE_NOT_FOUND, "Wrong error when opening mmdevices Render key: %u\n", ret);
194}
#define RegCloseKey(hKey)
Definition: registry.h:49
struct _root root
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
@ VT_UI4
Definition: compat.h:2313
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static BOOL *static const WCHAR software_renderW[]
Definition: propstore.c:35
static const WCHAR propertiesW[]
Definition: propstore.c:43
#define KEY_READ
Definition: nt_native.h:1023
long LONG
Definition: pedump.c:60
#define REG_DWORD
Definition: sdbapi.c:596
#define win_skip
Definition: test.h:160
unsigned char * LPBYTE
Definition: typedefs.h:53
static const WCHAR props[]
Definition: wbemdisp.c:288
int ret
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

Variable Documentation

◆ propertiesW

const WCHAR propertiesW[] = {'P','r','o','p','e','r','t','i','e','s',0}
static

Definition at line 43 of file propstore.c.

Referenced by test_setvalue_on_wow64().

◆ software_renderW

BOOL* static const WCHAR software_renderW[]
static
Initial value:
=
{ '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 }

Definition at line 35 of file propstore.c.

Referenced by test_setvalue_on_wow64().