ReactOS 0.4.15-dev-7131-ge4d03f4
filtermapper.c
Go to the documentation of this file.
1/*
2 * Filtermapper unit tests for Quartz
3 *
4 * Copyright (C) 2008 Alexander Dorofeyev
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#define COBJMACROS
22
23#include "wine/test.h"
24#include "winbase.h"
25#include "initguid.h"
26#include "dshow.h"
27#include "wine/winternl.h"
28
29#include "fil_data.h"
30
31DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
32
33/* Helper function, checks if filter with given name was enumerated. */
34static BOOL enum_find_filter(const WCHAR *wszFilterName, IEnumMoniker *pEnum)
35{
36 IMoniker *pMoniker = NULL;
37 BOOL found = FALSE;
38 ULONG nb;
39 HRESULT hr;
40 static const WCHAR wszFriendlyName[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
41
43 while(!found && IEnumMoniker_Next(pEnum, 1, &pMoniker, &nb) == S_OK)
44 {
45 IPropertyBag * pPropBagCat = NULL;
47
49
50 hr = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (LPVOID*)&pPropBagCat);
51 ok(SUCCEEDED(hr), "IMoniker_BindToStorage failed with %x\n", hr);
52
53 hr = IPropertyBag_Read(pPropBagCat, wszFriendlyName, &var, NULL);
54 ok(SUCCEEDED(hr), "IPropertyBag_Read failed with %x\n", hr);
55
56 if (!lstrcmpW(V_BSTR(&var), wszFilterName))
57 found = TRUE;
58
59 IPropertyBag_Release(pPropBagCat);
60 IMoniker_Release(pMoniker);
62 }
63
64 return found;
65}
66
68{
69 IEnumRegFilters *enum_reg;
70 IFilterMapper2 *pMapper = NULL;
71 IFilterMapper *mapper;
72 HRESULT hr;
73 REGFILTER2 rgf2;
74 REGFILTERPINS2 rgPins2[2];
75 REGPINTYPES rgPinType;
76 static const WCHAR wszFilterName1[] = {'T', 'e', 's', 't', 'f', 'i', 'l', 't', 'e', 'r', '1', 0 };
77 static const WCHAR wszFilterName2[] = {'T', 'e', 's', 't', 'f', 'i', 'l', 't', 'e', 'r', '2', 0 };
78 CLSID clsidFilter1;
79 CLSID clsidFilter2;
80 IEnumMoniker *pEnum = NULL;
81 BOOL found, registered = TRUE;
82 REGFILTER *regfilter;
84
85 ZeroMemory(&rgf2, sizeof(rgf2));
86
87 hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
88 &IID_IFilterMapper2, (LPVOID*)&pMapper);
89 ok(hr == S_OK, "CoCreateInstance failed with %x\n", hr);
90 if (FAILED(hr)) goto out;
91
92 hr = CoCreateGuid(&clsidFilter1);
93 ok(hr == S_OK, "CoCreateGuid failed with %x\n", hr);
94 hr = CoCreateGuid(&clsidFilter2);
95 ok(hr == S_OK, "CoCreateGuid failed with %x\n", hr);
96
97 /* Test that a test renderer filter is returned when enumerating filters with bRender=FALSE */
98 rgf2.dwVersion = 2;
99 rgf2.dwMerit = MERIT_UNLIKELY;
100 S2(U(rgf2)).cPins2 = 1;
101 S2(U(rgf2)).rgPins2 = rgPins2;
102
103 rgPins2[0].dwFlags = REG_PINFLAG_B_RENDERER;
104 rgPins2[0].cInstances = 1;
105 rgPins2[0].nMediaTypes = 1;
106 rgPins2[0].lpMediaType = &rgPinType;
107 rgPins2[0].nMediums = 0;
108 rgPins2[0].lpMedium = NULL;
109 rgPins2[0].clsPinCategory = NULL;
110
111 rgPinType.clsMajorType = &GUID_NULL;
112 rgPinType.clsMinorType = &GUID_NULL;
113
114 hr = IFilterMapper2_RegisterFilter(pMapper, &clsidFilter1, wszFilterName1, NULL,
115 &CLSID_LegacyAmFilterCategory, NULL, &rgf2);
116 if (hr == E_ACCESSDENIED)
117 {
118 registered = FALSE;
119 skip("Not authorized to register filters\n");
120 }
121 else
122 {
123 ok(hr == S_OK, "IFilterMapper2_RegisterFilter failed with %x\n", hr);
124
125 rgPins2[0].dwFlags = 0;
126
127 rgPins2[1].dwFlags = REG_PINFLAG_B_OUTPUT;
128 rgPins2[1].cInstances = 1;
129 rgPins2[1].nMediaTypes = 1;
130 rgPins2[1].lpMediaType = &rgPinType;
131 rgPins2[1].nMediums = 0;
132 rgPins2[1].lpMedium = NULL;
133 rgPins2[1].clsPinCategory = NULL;
134
135 S2(U(rgf2)).cPins2 = 2;
136
137 hr = IFilterMapper2_RegisterFilter(pMapper, &clsidFilter2, wszFilterName2, NULL,
138 &CLSID_LegacyAmFilterCategory, NULL, &rgf2);
139 ok(hr == S_OK, "IFilterMapper2_RegisterFilter failed with %x\n", hr);
140
141 hr = IFilterMapper2_EnumMatchingFilters(pMapper, &pEnum, 0, TRUE, MERIT_UNLIKELY, TRUE,
143 ok(hr == S_OK, "IFilterMapper2_EnumMatchingFilters failed with %x\n", hr);
144 if (SUCCEEDED(hr) && pEnum)
145 {
146 found = enum_find_filter(wszFilterName1, pEnum);
147 ok(found, "EnumMatchingFilters failed to return the test filter 1\n");
148 }
149
150 if (pEnum) IEnumMoniker_Release(pEnum);
151 pEnum = NULL;
152
153 hr = IFilterMapper2_EnumMatchingFilters(pMapper, &pEnum, 0, TRUE, MERIT_UNLIKELY, TRUE,
155 ok(hr == S_OK, "IFilterMapper2_EnumMatchingFilters failed with %x\n", hr);
156 if (SUCCEEDED(hr) && pEnum)
157 {
158 found = enum_find_filter(wszFilterName2, pEnum);
159 ok(found, "EnumMatchingFilters failed to return the test filter 2\n");
160 }
161
162 if (pEnum) IEnumMoniker_Release(pEnum);
163 pEnum = NULL;
164
165 /* Non renderer must not be returned with bRender=TRUE */
166
167 hr = IFilterMapper2_EnumMatchingFilters(pMapper, &pEnum, 0, TRUE, MERIT_UNLIKELY, TRUE,
168 0, NULL, NULL, &GUID_NULL, TRUE, FALSE, 0, NULL, NULL, &GUID_NULL);
169 ok(hr == S_OK, "IFilterMapper2_EnumMatchingFilters failed with %x\n", hr);
170
171 if (SUCCEEDED(hr) && pEnum)
172 {
173 found = enum_find_filter(wszFilterName1, pEnum);
174 ok(found, "EnumMatchingFilters failed to return the test filter 1\n");
175 }
176
177 hr = IFilterMapper2_QueryInterface(pMapper, &IID_IFilterMapper, (void **)&mapper);
178 ok(hr == S_OK, "QueryInterface(IFilterMapper) failed: %#x\n", hr);
179
180 found = FALSE;
181 hr = IFilterMapper_EnumMatchingFilters(mapper, &enum_reg, MERIT_UNLIKELY,
183 ok(hr == S_OK, "IFilterMapper_EnumMatchingFilters failed: %#x\n", hr);
184 while (!found && IEnumRegFilters_Next(enum_reg, 1, &regfilter, &count) == S_OK)
185 {
186 if (!lstrcmpW(regfilter->Name, wszFilterName1) && IsEqualGUID(&clsidFilter1, &regfilter->Clsid))
187 found = TRUE;
188 }
189 IEnumRegFilters_Release(enum_reg);
190 ok(found, "IFilterMapper didn't find filter\n");
191 }
192
193 if (pEnum) IEnumMoniker_Release(pEnum);
194 pEnum = NULL;
195
196 hr = IFilterMapper2_EnumMatchingFilters(pMapper, &pEnum, 0, TRUE, MERIT_UNLIKELY, TRUE,
197 0, NULL, NULL, &GUID_NULL, TRUE, FALSE, 0, NULL, NULL, &GUID_NULL);
198 ok(hr == S_OK, "IFilterMapper2_EnumMatchingFilters failed with %x\n", hr);
199
200 if (SUCCEEDED(hr) && pEnum)
201 {
202 found = enum_find_filter(wszFilterName2, pEnum);
203 ok(!found, "EnumMatchingFilters should not return the test filter 2\n");
204 }
205
206 if (registered)
207 {
208 hr = IFilterMapper2_UnregisterFilter(pMapper, &CLSID_LegacyAmFilterCategory, NULL,
209 &clsidFilter1);
210 ok(SUCCEEDED(hr), "IFilterMapper2_UnregisterFilter failed with %x\n", hr);
211
212 hr = IFilterMapper2_UnregisterFilter(pMapper, &CLSID_LegacyAmFilterCategory, NULL,
213 &clsidFilter2);
214 ok(SUCCEEDED(hr), "IFilterMapper2_UnregisterFilter failed with %x\n", hr);
215 }
216
217 out:
218
219 if (pEnum) IEnumMoniker_Release(pEnum);
220 if (pMapper) IFilterMapper2_Release(pMapper);
221}
222
224{
225 static const WCHAR testfilterW[] = {'T','e','s','t','f','i','l','t','e','r',0};
226 static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0};
227 static const WCHAR pinW[] = {'P','i','n','1',0};
228 IEnumRegFilters *enum_reg;
229 IEnumMoniker *enum_mon;
230 IFilterMapper2 *mapper2;
231 IFilterMapper *mapper;
232 REGFILTER *regfilter;
233 WCHAR clsidstring[40];
234 WCHAR key_name[50];
235 ULONG count;
236 CLSID clsid;
237 LRESULT ret;
238 HRESULT hr;
239 BOOL found;
240 HKEY hkey;
241
242 /* Register* functions need a filter class key to write pin and pin media
243 * type data to. Create a bogus class key for it. */
245 StringFromGUID2(&clsid, clsidstring, sizeof(clsidstring));
247 lstrcatW(key_name, clsidstring);
250 {
251 skip("Not authorized to register filters\n");
252 return;
253 }
254
255 /* Test if legacy filter registration scheme works (filter is added to HKCR\Filter). IFilterMapper_RegisterFilter
256 * registers in this way. Filters so registered must then be accessible through both IFilterMapper_EnumMatchingFilters
257 * and IFilterMapper2_EnumMatchingFilters. */
258 hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterMapper2, (void **)&mapper2);
259 ok(hr == S_OK, "CoCreateInstance failed with %x\n", hr);
260
261 hr = IFilterMapper2_QueryInterface(mapper2, &IID_IFilterMapper, (void **)&mapper);
262 ok(hr == S_OK, "IFilterMapper2_QueryInterface failed with %x\n", hr);
263
264 /* Set default value - this is interpreted as "friendly name" later. */
265 RegSetValueExW(hkey, NULL, 0, REG_SZ, (BYTE *)testfilterW, sizeof(testfilterW));
266 RegCloseKey(hkey);
267
268 hr = IFilterMapper_RegisterFilter(mapper, clsid, testfilterW, MERIT_UNLIKELY);
269 ok(hr == S_OK, "RegisterFilter failed: %#x\n", hr);
270
271 hr = IFilterMapper_RegisterPin(mapper, clsid, pinW, TRUE, FALSE, FALSE, FALSE, GUID_NULL, NULL);
272 ok(hr == S_OK, "RegisterPin failed: %#x\n", hr);
273
274 hr = IFilterMapper_RegisterPinType(mapper, clsid, pinW, GUID_NULL, GUID_NULL);
275 ok(hr == S_OK, "RegisterPinType failed: %#x\n", hr);
276
277 hr = IFilterMapper2_EnumMatchingFilters(mapper2, &enum_mon, 0, TRUE, MERIT_UNLIKELY, TRUE,
279 ok(hr == S_OK, "IFilterMapper2_EnumMatchingFilters failed: %x\n", hr);
280 ok(enum_find_filter(testfilterW, enum_mon), "IFilterMapper2 didn't find filter\n");
281 IEnumMoniker_Release(enum_mon);
282
283 found = FALSE;
284 hr = IFilterMapper_EnumMatchingFilters(mapper, &enum_reg, MERIT_UNLIKELY, TRUE, GUID_NULL, GUID_NULL,
286 ok(hr == S_OK, "IFilterMapper_EnumMatchingFilters failed with %x\n", hr);
287 while(!found && IEnumRegFilters_Next(enum_reg, 1, &regfilter, &count) == S_OK)
288 {
289 if (!lstrcmpW(regfilter->Name, testfilterW) && IsEqualGUID(&clsid, &regfilter->Clsid))
290 found = TRUE;
291 }
292 IEnumRegFilters_Release(enum_reg);
293 ok(found, "IFilterMapper didn't find filter\n");
294
295 hr = IFilterMapper_UnregisterFilter(mapper, clsid);
296 ok(hr == S_OK, "FilterMapper_UnregisterFilter failed with %x\n", hr);
297
298 hr = IFilterMapper2_EnumMatchingFilters(mapper2, &enum_mon, 0, TRUE, MERIT_UNLIKELY, TRUE,
300 ok(hr == S_OK, "IFilterMapper2_EnumMatchingFilters failed: %x\n", hr);
301 ok(!enum_find_filter(testfilterW, enum_mon), "IFilterMapper2 shouldn't find filter\n");
302 IEnumMoniker_Release(enum_mon);
303
304 found = FALSE;
305 hr = IFilterMapper_EnumMatchingFilters(mapper, &enum_reg, MERIT_UNLIKELY, TRUE, GUID_NULL, GUID_NULL,
307 ok(hr == S_OK, "IFilterMapper_EnumMatchingFilters failed with %x\n", hr);
308 while(!found && IEnumRegFilters_Next(enum_reg, 1, &regfilter, &count) == S_OK)
309 {
310 if (!lstrcmpW(regfilter->Name, testfilterW) && IsEqualGUID(&clsid, &regfilter->Clsid))
311 found = TRUE;
312 }
313 IEnumRegFilters_Release(enum_reg);
314 ok(!found, "IFilterMapper shouldn't find filter\n");
315
317 ok(!ret, "RegDeleteKeyA failed: %lu\n", ret);
318
319 hr = IFilterMapper_RegisterFilter(mapper, clsid, testfilterW, MERIT_UNLIKELY);
320 ok(hr == S_OK, "RegisterFilter failed: %#x\n", hr);
321
322 hr = IFilterMapper_UnregisterFilter(mapper, clsid);
323 ok(hr == S_OK, "FilterMapper_UnregisterFilter failed with %x\n", hr);
324
325 IFilterMapper_Release(mapper);
326 IFilterMapper2_Release(mapper2);
327}
328
330{
331 IUnknown_AddRef(iface);
332 return IUnknown_Release(iface);
333}
334
336{
337 IFilterGraph2* pgraph2 = NULL;
338 IFilterMapper2 *pMapper2 = NULL;
339 IFilterGraph *filtergraph = NULL;
340 HRESULT hr;
341 ULONG refcount;
342
343 hr = CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterGraph2, (LPVOID*)&pgraph2);
344 ok(hr == S_OK, "CoCreateInstance failed with %08x\n", hr);
345 if (!pgraph2) goto out;
346
347 hr = IFilterGraph2_QueryInterface(pgraph2, &IID_IFilterMapper2, (LPVOID*)&pMapper2);
348 ok(hr == S_OK, "IFilterGraph2_QueryInterface failed with %08x\n", hr);
349 if (!pMapper2) goto out;
350
351 refcount = getRefcount((IUnknown*)pgraph2);
352 ok(refcount == 2, "unexpected reference count: %u\n", refcount);
353 refcount = getRefcount((IUnknown*)pMapper2);
354 ok(refcount == 2, "unexpected reference count: %u\n", refcount);
355
356 IFilterMapper2_AddRef(pMapper2);
357 refcount = getRefcount((IUnknown*)pgraph2);
358 ok(refcount == 3, "unexpected reference count: %u\n", refcount);
359 refcount = getRefcount((IUnknown*)pMapper2);
360 ok(refcount == 3, "unexpected reference count: %u\n", refcount);
361 IFilterMapper2_Release(pMapper2);
362
363 hr = IFilterMapper2_QueryInterface(pMapper2, &IID_IFilterGraph, (LPVOID*)&filtergraph);
364 ok(hr == S_OK, "IFilterMapper2_QueryInterface failed with %08x\n", hr);
365 if (!filtergraph) goto out;
366
367 IFilterMapper2_Release(pMapper2);
368 pMapper2 = NULL;
369 IFilterGraph_Release(filtergraph);
370 filtergraph = NULL;
371
372 hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterMapper2, (LPVOID*)&pMapper2);
373 ok(hr == S_OK, "CoCreateInstance failed with %08x\n", hr);
374 if (!pMapper2) goto out;
375
376 hr = IFilterMapper2_QueryInterface(pMapper2, &IID_IFilterGraph, (LPVOID*)&filtergraph);
377 ok(hr == E_NOINTERFACE, "IFilterMapper2_QueryInterface unexpected result: %08x\n", hr);
378
379 out:
380
381 if (pMapper2) IFilterMapper2_Release(pMapper2);
382 if (filtergraph) IFilterGraph_Release(filtergraph);
383 if (pgraph2) IFilterGraph2_Release(pgraph2);
384}
385
387{
388 IFilterMapper2 *pMapper = NULL;
389 HRESULT hr;
390 REGFILTER2 rgf2;
391 REGFILTERPINS rgPins;
392 REGFILTERPINS2 rgPins2;
393 REGPINTYPES rgPinType;
394 static WCHAR wszPinName[] = {'P', 'i', 'n', 0 };
395 static const WCHAR wszFilterName1[] = {'T', 'e', 's', 't', 'f', 'i', 'l', 't', 'e', 'r', '1', 0 };
396 static const WCHAR wszFilterName2[] = {'T', 'e', 's', 't', 'f', 'i', 'l', 't', 'e', 'r', '2', 0 };
397 CLSID clsidFilter1;
398 CLSID clsidFilter2;
399
400 hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
401 &IID_IFilterMapper2, (LPVOID*)&pMapper);
402 ok(hr == S_OK, "CoCreateInstance failed with %x\n", hr);
403 if (FAILED(hr)) goto out;
404
405 hr = CoCreateGuid(&clsidFilter1);
406 ok(hr == S_OK, "CoCreateGuid failed with %x\n", hr);
407 hr = CoCreateGuid(&clsidFilter2);
408 ok(hr == S_OK, "CoCreateGuid failed with %x\n", hr);
409
410 rgPinType.clsMajorType = &GUID_NULL;
411 /* Make sure quartz accepts it without crashing */
412 rgPinType.clsMinorType = NULL;
413
414 /* Test with pin descript version 1 */
415 ZeroMemory(&rgf2, sizeof(rgf2));
416 rgf2.dwVersion = 1;
417 rgf2.dwMerit = MERIT_UNLIKELY;
418 S1(U(rgf2)).cPins = 1;
419 S1(U(rgf2)).rgPins = &rgPins;
420
421 rgPins.strName = wszPinName;
422 rgPins.bRendered = 1;
423 rgPins.bOutput = 0;
424 rgPins.bZero = 0;
425 rgPins.bMany = 0;
426 rgPins.clsConnectsToFilter = NULL;
427 rgPins.strConnectsToPin = NULL;
428 rgPins.nMediaTypes = 1;
429 rgPins.lpMediaType = &rgPinType;
430
431 hr = IFilterMapper2_RegisterFilter(pMapper, &clsidFilter1, wszFilterName1, NULL,
432 &CLSID_LegacyAmFilterCategory, NULL, &rgf2);
433 if (hr == E_ACCESSDENIED)
434 {
435 skip("Not authorized to register filters\n");
436 goto out;
437 }
438 ok(hr == S_OK, "IFilterMapper2_RegisterFilter failed with %x\n", hr);
439
440 hr = IFilterMapper2_UnregisterFilter(pMapper, &CLSID_LegacyAmFilterCategory, NULL, &clsidFilter1);
441 ok(hr == S_OK, "FilterMapper_UnregisterFilter failed with %x\n", hr);
442
443 /* Test with pin descript version 2 */
444 ZeroMemory(&rgf2, sizeof(rgf2));
445 rgf2.dwVersion = 2;
446 rgf2.dwMerit = MERIT_UNLIKELY;
447 S2(U(rgf2)).cPins2 = 1;
448 S2(U(rgf2)).rgPins2 = &rgPins2;
449
451 rgPins2.cInstances = 1;
452 rgPins2.nMediaTypes = 1;
453 rgPins2.lpMediaType = &rgPinType;
454 rgPins2.nMediums = 0;
455 rgPins2.lpMedium = NULL;
456 rgPins2.clsPinCategory = NULL;
457
458 hr = IFilterMapper2_RegisterFilter(pMapper, &clsidFilter2, wszFilterName2, NULL,
459 &CLSID_LegacyAmFilterCategory, NULL, &rgf2);
460 ok(hr == S_OK, "IFilterMapper2_RegisterFilter failed with %x\n", hr);
461
462 hr = IFilterMapper2_UnregisterFilter(pMapper, &CLSID_LegacyAmFilterCategory, NULL, &clsidFilter2);
463 ok(hr == S_OK, "FilterMapper_UnregisterFilter failed with %x\n", hr);
464
465 out:
466
467 if (pMapper) IFilterMapper2_Release(pMapper);
468}
469
470static void test_parse_filter_data(void)
471{
472 static const BYTE data_block[] = {
473 0x02,0x00,0x00,0x00,0xff,0xff,0x5f,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x70,0x69,0x33,
474 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
475 0x30,0x74,0x79,0x33,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x31,0x70,0x69,0x33,
476 0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
477 0x30,0x74,0x79,0x33,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x76,0x69,0x64,0x73,
478 0x00,0x00,0x10,0x00,0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
479 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
480
481 BYTE *prgbRegFilter2 = NULL;
482 REGFILTER2 *pRegFilter = NULL;
483 IFilterMapper2 *pMapper = NULL;
484 SAFEARRAYBOUND saBound;
485 SAFEARRAY *psa = NULL;
486 LPBYTE pbSAData = NULL;
487 HRESULT hr;
488
490
491 hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
492 &IID_IFilterMapper2, (LPVOID*)&pMapper);
493 ok((hr == S_OK || broken(hr != S_OK)), "CoCreateInstance failed with %x\n", hr);
494 if (FAILED(hr)) goto out;
495
496 hr = IFilterMapper2_QueryInterface(pMapper, &IID_IAMFilterData, (LPVOID*)&pData);
497 ok((hr == S_OK || broken(hr != S_OK)), "Unable to find IID_IAMFilterData interface\n");
498 if (FAILED(hr)) goto out;
499
500 saBound.lLbound = 0;
501 saBound.cElements = sizeof(data_block);
502 psa = SafeArrayCreate(VT_UI1, 1, &saBound);
503 ok(psa != NULL, "Unable to create safe array\n");
504 if (!psa) goto out;
505 hr = SafeArrayAccessData(psa, (LPVOID *)&pbSAData);
506 ok(hr == S_OK, "Unable to access array data\n");
507 if (FAILED(hr)) goto out;
508 memcpy(pbSAData, data_block, sizeof(data_block));
509
510 hr = IAMFilterData_ParseFilterData(pData, pbSAData, sizeof(data_block), &prgbRegFilter2);
511 /* We cannot do anything here. prgbRegFilter2 is very unstable */
512 /* Pre Vista, this is a stack pointer so anything that changes the stack invalidats it */
513 /* Post Vista, it is a static pointer in the data section of the module */
514 pRegFilter =((REGFILTER2**)prgbRegFilter2)[0];
515 ok (hr==S_OK,"Failed to Parse filter Data\n");
516
517 ok(IsBadReadPtr(prgbRegFilter2,sizeof(REGFILTER2*))==0,"Bad read pointer returned\n");
518 ok(IsBadReadPtr(pRegFilter,sizeof(REGFILTER2))==0,"Bad read pointer for FilterData\n");
519 ok(pRegFilter->dwMerit == 0x5fffff,"Incorrect merit returned\n");
520
521out:
522 CoTaskMemFree(pRegFilter);
523 if (psa)
524 {
527 }
528 if (pData)
529 IAMFilterData_Release(pData);
530 if (pMapper)
531 IFilterMapper2_Release(pMapper);
532}
533
534typedef struct IUnknownImpl
535{
537 int AddRef_called;
538 int Release_called;
540
542{
543 return CONTAINING_RECORD(iface, IUnknownImpl, IUnknown_iface);
544}
545
547{
548 ok(0, "QueryInterface should not be called for %s\n", wine_dbgstr_guid(riid));
549 return E_NOINTERFACE;
550}
551
553{
555 This->AddRef_called++;
556 return 2;
557}
558
560{
562 This->Release_called++;
563 return 1;
564}
565
566static CONST_VTBL IUnknownVtbl IUnknownImpl_Vtbl =
567{
571};
572
574{
575 HRESULT hr;
576 IUnknown *pmapper;
577 IUnknown *punk;
578 IUnknownImpl unk_outer = { { &IUnknownImpl_Vtbl }, 0, 0 };
579
580 hr = CoCreateInstance(&CLSID_FilterMapper2, &unk_outer.IUnknown_iface, CLSCTX_INPROC_SERVER,
581 &IID_IUnknown, (void **)&pmapper);
582 ok(hr == S_OK, "CoCreateInstance returned %x\n", hr);
583 ok(pmapper != &unk_outer.IUnknown_iface, "pmapper = %p, expected not %p\n", pmapper, &unk_outer.IUnknown_iface);
584
585 hr = IUnknown_QueryInterface(pmapper, &IID_IUnknown, (void **)&punk);
586 ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr);
587 ok(punk != &unk_outer.IUnknown_iface, "punk = %p, expected not %p\n", punk, &unk_outer.IUnknown_iface);
588 IUnknown_Release(punk);
589
590 ok(unk_outer.AddRef_called == 0, "IUnknownImpl_AddRef called %d times\n", unk_outer.AddRef_called);
591 ok(unk_outer.Release_called == 0, "IUnknownImpl_Release called %d times\n", unk_outer.Release_called);
592 unk_outer.AddRef_called = 0;
593 unk_outer.Release_called = 0;
594
595 hr = IUnknown_QueryInterface(pmapper, &IID_IFilterMapper, (void **)&punk);
596 ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr);
597 ok(punk != &unk_outer.IUnknown_iface, "punk = %p, expected not %p\n", punk, &unk_outer.IUnknown_iface);
598 IUnknown_Release(punk);
599
600 ok(unk_outer.AddRef_called == 1, "IUnknownImpl_AddRef called %d times\n", unk_outer.AddRef_called);
601 ok(unk_outer.Release_called == 1, "IUnknownImpl_Release called %d times\n", unk_outer.Release_called);
602 unk_outer.AddRef_called = 0;
603 unk_outer.Release_called = 0;
604
605 hr = IUnknown_QueryInterface(pmapper, &IID_IFilterMapper2, (void **)&punk);
606 ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr);
607 ok(punk != &unk_outer.IUnknown_iface, "punk = %p, expected not %p\n", punk, &unk_outer.IUnknown_iface);
608 IUnknown_Release(punk);
609
610 ok(unk_outer.AddRef_called == 1, "IUnknownImpl_AddRef called %d times\n", unk_outer.AddRef_called);
611 ok(unk_outer.Release_called == 1, "IUnknownImpl_Release called %d times\n", unk_outer.Release_called);
612 unk_outer.AddRef_called = 0;
613 unk_outer.Release_called = 0;
614
615 hr = IUnknown_QueryInterface(pmapper, &IID_IFilterMapper3, (void **)&punk);
616 ok(hr == S_OK, "IUnknown_QueryInterface returned %x\n", hr);
617 ok(punk != &unk_outer.IUnknown_iface, "punk = %p, expected not %p\n", punk, &unk_outer.IUnknown_iface);
618 IUnknown_Release(punk);
619
620 ok(unk_outer.AddRef_called == 1, "IUnknownImpl_AddRef called %d times\n", unk_outer.AddRef_called);
621 ok(unk_outer.Release_called == 1, "IUnknownImpl_Release called %d times\n", unk_outer.Release_called);
622
623 IUnknown_Release(pmapper);
624}
625
626START_TEST(filtermapper)
627{
629
636
638}
#define broken(x)
Definition: _sntprintf.h:21
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
REGPINTYPES
Definition: axextend.idl:192
@ REG_PINFLAG_B_RENDERER
Definition: axextend.idl:217
@ REG_PINFLAG_B_OUTPUT
Definition: axextend.idl:219
#define U(x)
Definition: wordpad.c:45
const GUID IID_IUnknown
#define RegCloseKey(hKey)
Definition: registry.h:49
static const WCHAR clsidW[]
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static const WCHAR wszFriendlyName[]
Definition: filtermapper.c:86
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4902
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1234
#define lstrcpyW
Definition: compat.h:749
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
@ VT_UI1
Definition: compat.h:2311
BOOL WINAPI IsBadReadPtr(IN LPCVOID lp, IN UINT_PTR ucb)
Definition: except.c:805
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI CoCreateGuid(GUID *pguid)
Definition: compobj.c:2206
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
HRESULT WINAPI SafeArrayAccessData(SAFEARRAY *psa, void **ppvData)
Definition: safearray.c:1137
HRESULT WINAPI SafeArrayUnaccessData(SAFEARRAY *psa)
Definition: safearray.c:1168
HRESULT WINAPI SafeArrayDestroy(SAFEARRAY *psa)
Definition: safearray.c:1347
SAFEARRAY *WINAPI SafeArrayCreate(VARTYPE vt, UINT cDims, SAFEARRAYBOUND *rgsabound)
Definition: safearray.c:600
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint GLuint GLsizei count
Definition: gl.h:1545
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define GUID_NULL
Definition: ks.h:106
#define REG_SZ
Definition: layer.c:22
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
const char * var
Definition: shader.c:5666
static BOOL enum_find_filter(const WCHAR *wszFilterName, IEnumMoniker *pEnum)
Definition: filtermapper.c:34
static void test_register_filter_with_null_clsMinorType(void)
Definition: filtermapper.c:386
static ULONG WINAPI IUnknownImpl_AddRef(IUnknown *iface)
Definition: filtermapper.c:552
static void test_aggregate_filter_mapper(void)
Definition: filtermapper.c:573
static void test_legacy_filter_registration(void)
Definition: filtermapper.c:223
static ULONG getRefcount(IUnknown *iface)
Definition: filtermapper.c:329
static HRESULT WINAPI IUnknownImpl_QueryInterface(IUnknown *iface, REFIID riid, LPVOID *ppv)
Definition: filtermapper.c:546
static void test_ifiltermapper_from_filtergraph(void)
Definition: filtermapper.c:335
static void test_parse_filter_data(void)
Definition: filtermapper.c:470
static CONST_VTBL IUnknownVtbl IUnknownImpl_Vtbl
Definition: filtermapper.c:566
struct IUnknownImpl IUnknownImpl
static ULONG WINAPI IUnknownImpl_Release(IUnknown *iface)
Definition: filtermapper.c:559
static void test_fm2_enummatchingfilters(void)
Definition: filtermapper.c:67
static IUnknownImpl * IUnknownImpl_from_iface(IUnknown *iface)
Definition: filtermapper.c:541
static SCRIPT_CACHE SCRIPT_ANALYSIS * psa
Definition: usp10.c:64
REFCLSID clsid
Definition: msctf.c:82
#define KEY_WRITE
Definition: nt_native.h:1031
#define CONST_VTBL
Definition: objbase.h:222
#define V_BSTR(A)
Definition: oleauto.h:226
const GUID IID_IPropertyBag
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
Definition: guiddef.h:68
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
static FILE * out
Definition: regtests2xml.c:44
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197
#define S2(x)
Definition: test.h:219
#define S1(x)
Definition: test.h:218
#define disable_success_count
Definition: test.h:181
HRESULT hr
Definition: shlfolder.c:183
IUnknown IUnknown_iface
Definition: filtergraph.c:2200
DWORD dwVersion
Definition: axextend.idl:236
DWORD dwMerit
Definition: axextend.idl:237
const CLSID * clsPinCategory
Definition: axextend.idl:231
const REGPINMEDIUM * lpMedium
Definition: axextend.idl:230
const REGPINTYPES * lpMediaType
Definition: axextend.idl:228
LPWSTR strName
Definition: axextend.idl:196
const CLSID * clsConnectsToFilter
Definition: axextend.idl:201
const REGPINTYPES * lpMediaType
Definition: axextend.idl:204
const WCHAR * strConnectsToPin
Definition: axextend.idl:202
UINT nMediaTypes
Definition: axextend.idl:203
CLSID Clsid
Definition: axextend.idl:81
LPWSTR Name
Definition: axextend.idl:82
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
unsigned char * LPBYTE
Definition: typedefs.h:53
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:568
int ret
#define ZeroMemory
Definition: winbase.h:1712
LONG_PTR LRESULT
Definition: windef.h:209
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364
#define E_ACCESSDENIED
Definition: winerror.h:2849
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193