ReactOS 0.4.17-dev-966-gf06eace
filtermapper.c File Reference
#include "wine/test.h"
#include "winbase.h"
#include "dshow.h"
#include "mediaobj.h"
#include "initguid.h"
#include "dmo.h"
#include "wine/fil_data.h"
Include dependency graph for filtermapper.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define check_interface(a, b, c)   check_interface_(__LINE__, a, b, c)
 

Functions

static IFilterMapper3 * create_mapper (void)
 
static ULONG get_refcount (void *iface)
 
static void check_interface_ (unsigned int line, void *iface_ptr, REFIID iid, BOOL supported)
 
static void test_interfaces (void)
 
static BOOL enum_find_filter (const WCHAR *wszFilterName, IEnumMoniker *pEnum)
 
static void test_fm2_enummatchingfilters (void)
 
static void test_legacy_filter_registration (void)
 
static void test_register_filter_with_null_clsMinorType (void)
 
static void test_parse_filter_data (void)
 
static HRESULT WINAPI outer_QueryInterface (IUnknown *iface, REFIID iid, void **out)
 
static ULONG WINAPI outer_AddRef (IUnknown *iface)
 
static ULONG WINAPI outer_Release (IUnknown *iface)
 
static void test_aggregation (void)
 
static void test_dmo (void)
 
 START_TEST (filtermapper)
 

Variables

static const GUID testclsid = {0x77777777}
 
static const GUID test_iid = {0x33333333}
 
static LONG outer_ref = 1
 
static const IUnknownVtbl outer_vtbl
 
static IUnknown test_outer = {&outer_vtbl}
 

Macro Definition Documentation

◆ check_interface

#define check_interface (   a,
  b,
  c 
)    check_interface_(__LINE__, a, b, c)

Definition at line 49 of file filtermapper.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file filtermapper.c.

Function Documentation

◆ check_interface_()

static void check_interface_ ( unsigned int  line,
void *  iface_ptr,
REFIID  iid,
BOOL  supported 
)
static

Definition at line 50 of file filtermapper.c.

51{
52 IUnknown *iface = iface_ptr;
54 IUnknown *unk;
55
56 expected_hr = supported ? S_OK : E_NOINTERFACE;
57
58 hr = IUnknown_QueryInterface(iface, iid, (void **)&unk);
59 ok_(__FILE__, line)(hr == expected_hr, "Got hr %#lx, expected %#lx.\n", hr, expected_hr);
60 if (SUCCEEDED(hr))
61 IUnknown_Release(unk);
62}
#define ok_(x1, x2)
Definition: atltest.h:61
HRESULT expected_hr
HRESULT hr
Definition: delayimp.cpp:582
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
Definition: parser.c:49
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ create_mapper()

static IFilterMapper3 * create_mapper ( void  )
static

Definition at line 33 of file filtermapper.c.

34{
35 IFilterMapper3 *ret;
36 HRESULT hr;
37 hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterMapper3, (void **)&ret);
38 ok(hr == S_OK, "Failed to create filter mapper, hr %#lx.\n", hr);
39 return ret;
40}
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
return ret
Definition: mutex.c:147

Referenced by test_dmo(), and test_interfaces().

◆ enum_find_filter()

static BOOL enum_find_filter ( const WCHAR *  wszFilterName,
IEnumMoniker *  pEnum 
)
static

Definition at line 80 of file filtermapper.c.

81{
82 IMoniker *pMoniker = NULL;
83 BOOL found = FALSE;
84 ULONG nb;
85 HRESULT hr;
86
87 while(!found && IEnumMoniker_Next(pEnum, 1, &pMoniker, &nb) == S_OK)
88 {
89 IPropertyBag * pPropBagCat = NULL;
91
93
94 hr = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (LPVOID*)&pPropBagCat);
95 ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
96
97 hr = IPropertyBag_Read(pPropBagCat, L"FriendlyName", &var, NULL);
98 ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
99
100 if (!wcscmp(V_BSTR(&var), wszFilterName))
101 found = TRUE;
102
103 IPropertyBag_Release(pPropBagCat);
104 IMoniker_Release(pMoniker);
106 }
107
108 return found;
109}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
const char * var
Definition: shader.c:5879
#define V_BSTR(A)
Definition: oleauto.h:226
const GUID IID_IPropertyBag
uint32_t ULONG
Definition: typedefs.h:59
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:626
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:547

Referenced by test_fm2_enummatchingfilters(), and test_legacy_filter_registration().

◆ get_refcount()

static ULONG get_refcount ( void *  iface)
static

Definition at line 42 of file filtermapper.c.

43{
44 IUnknown *unknown = iface;
45 IUnknown_AddRef(unknown);
46 return IUnknown_Release(unknown);
47}
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1674

Referenced by test_aggregation().

◆ outer_AddRef()

static ULONG WINAPI outer_AddRef ( IUnknown *  iface)
static

Definition at line 533 of file filtermapper.c.

534{
536}
#define InterlockedIncrement
Definition: armddk.h:53
static LONG outer_ref
Definition: filtermapper.c:518

◆ outer_QueryInterface()

static HRESULT WINAPI outer_QueryInterface ( IUnknown *  iface,
REFIID  iid,
void **  out 
)
static

Definition at line 520 of file filtermapper.c.

521{
522 if (IsEqualGUID(iid, &IID_IUnknown)
523 || IsEqualGUID(iid, &IID_IFilterMapper3)
524 || IsEqualGUID(iid, &test_iid))
525 {
526 *out = (IUnknown *)0xdeadbeef;
527 return S_OK;
528 }
529 ok(0, "unexpected call %s\n", wine_dbgstr_guid(iid));
530 return E_NOINTERFACE;
531}
const GUID IID_IUnknown
static const GUID test_iid
Definition: filtermapper.c:517
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:181
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

◆ outer_Release()

static ULONG WINAPI outer_Release ( IUnknown *  iface)
static

Definition at line 538 of file filtermapper.c.

539{
541}
#define InterlockedDecrement
Definition: armddk.h:52

◆ START_TEST()

START_TEST ( filtermapper  )

Definition at line 660 of file filtermapper.c.

661{
663
670 test_dmo();
671
673}
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:531
static void test_register_filter_with_null_clsMinorType(void)
Definition: filtermapper.c:371
static void test_aggregation(void)
Definition: filtermapper.c:552
static void test_dmo(void)
Definition: filtermapper.c:611
static void test_legacy_filter_registration(void)
Definition: filtermapper.c:268
static void test_interfaces(void)
Definition: filtermapper.c:64
static void test_parse_filter_data(void)
Definition: filtermapper.c:453
static void test_fm2_enummatchingfilters(void)
Definition: filtermapper.c:111

◆ test_aggregation()

static void test_aggregation ( void  )
static

Definition at line 552 of file filtermapper.c.

553{
554 IFilterMapper3 *mapper, *mapper2;
555 IUnknown *unk, *unk2;
556 HRESULT hr;
557 ULONG ref;
558
559 mapper = (IFilterMapper3 *)0xdeadbeef;
560 hr = CoCreateInstance(&CLSID_FilterMapper2, &test_outer, CLSCTX_INPROC_SERVER,
561 &IID_IFilterMapper3, (void **)&mapper);
562 ok(hr == E_NOINTERFACE, "Got hr %#lx.\n", hr);
563 ok(!mapper, "Got interface %p.\n", mapper);
564
565 hr = CoCreateInstance(&CLSID_FilterMapper2, &test_outer, CLSCTX_INPROC_SERVER,
566 &IID_IUnknown, (void **)&unk);
567 ok(hr == S_OK, "Got hr %#lx.\n", hr);
568 ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
569 ok(unk != &test_outer, "Returned IUnknown should not be outer IUnknown.\n");
570 ref = get_refcount(unk);
571 ok(ref == 1, "Got unexpected refcount %ld.\n", ref);
572
573 ref = IUnknown_AddRef(unk);
574 ok(ref == 2, "Got unexpected refcount %ld.\n", ref);
575 ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
576
577 ref = IUnknown_Release(unk);
578 ok(ref == 1, "Got unexpected refcount %ld.\n", ref);
579 ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
580
581 hr = IUnknown_QueryInterface(unk, &IID_IUnknown, (void **)&unk2);
582 ok(hr == S_OK, "Got hr %#lx.\n", hr);
583 ok(unk2 == unk, "Got unexpected IUnknown %p.\n", unk2);
584 IUnknown_Release(unk2);
585
586 hr = IUnknown_QueryInterface(unk, &IID_IFilterMapper3, (void **)&mapper);
587 ok(hr == S_OK, "Got hr %#lx.\n", hr);
588
589 hr = IFilterMapper3_QueryInterface(mapper, &IID_IUnknown, (void **)&unk2);
590 ok(hr == S_OK, "Got hr %#lx.\n", hr);
591 ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
592
593 hr = IFilterMapper3_QueryInterface(mapper, &IID_IFilterMapper3, (void **)&mapper2);
594 ok(hr == S_OK, "Got hr %#lx.\n", hr);
595 ok(mapper2 == (IFilterMapper3 *)0xdeadbeef, "Got unexpected IFilterMapper3 %p.\n", mapper2);
596
597 hr = IUnknown_QueryInterface(unk, &test_iid, (void **)&unk2);
598 ok(hr == E_NOINTERFACE, "Got hr %#lx.\n", hr);
599 ok(!unk2, "Got unexpected IUnknown %p.\n", unk2);
600
601 hr = IFilterMapper3_QueryInterface(mapper, &test_iid, (void **)&unk2);
602 ok(hr == S_OK, "Got hr %#lx.\n", hr);
603 ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
604
605 IFilterMapper3_Release(mapper);
606 ref = IUnknown_Release(unk);
607 ok(!ref, "Got unexpected refcount %ld.\n", ref);
608 ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
609}
static ULONG get_refcount(void *iface)
Definition: filtermapper.c:42
static IUnknown test_outer
Definition: filtermapper.c:550
Definition: send.c:48

Referenced by START_TEST().

◆ test_dmo()

static void test_dmo ( void  )
static

Definition at line 611 of file filtermapper.c.

612{
613 DMO_PARTIAL_MEDIATYPE mt = {MEDIATYPE_Audio, MEDIASUBTYPE_PCM};
614 IEnumMoniker *enumerator;
615 IFilterMapper3 *mapper;
617 WCHAR *name;
618 HRESULT hr;
619 BOOL found;
620 ULONG ref;
621
622 hr = DMORegister(L"dmo test", &testclsid, &DMOCATEGORY_AUDIO_DECODER, 0, 1, &mt, 1, &mt);
623 if (hr == E_FAIL)
624 {
625 skip("Not enough permissions to register DMOs.\n");
626 return;
627 }
628 ok(hr == S_OK, "Got hr %#lx.\n", hr);
629
630 mapper = create_mapper();
631
632 hr = IFilterMapper3_EnumMatchingFilters(mapper, &enumerator, 0, FALSE, 0,
633 FALSE, 0, NULL, NULL, NULL, FALSE, FALSE, 0, NULL, NULL, NULL);
634 ok(hr == S_OK, "Got hr %#lx.\n", hr);
635
636 found = FALSE;
637 while (IEnumMoniker_Next(enumerator, 1, &moniker, NULL) == S_OK)
638 {
639 hr = IMoniker_GetDisplayName(moniker, NULL, NULL, &name);
640 ok(hr == S_OK, "Got hr %#lx.\n", hr);
641
642 if (!wcscmp(name, L"@device:dmo:{77777777-0000-0000-0000-000000000000}{57F2DB8B-E6BB-4513-9D43-DCD2A6593125}"))
643 found = TRUE;
644
646 IMoniker_Release(moniker);
647 }
648 IEnumMoniker_Release(enumerator);
649 ok(found, "DMO should be enumerated.\n");
650
651 /* DMOs are enumerated by IFilterMapper in Windows 7 and higher. */
652
653 ref = IFilterMapper3_Release(mapper);
654 ok(!ref, "Got outstanding refcount %ld.\n", ref);
655
656 hr = DMOUnregister(&testclsid, &DMOCATEGORY_AUDIO_DECODER);
657 ok(hr == S_OK, "Got hr %#lx.\n", hr);
658}
#define skip(...)
Definition: atltest.h:64
#define E_FAIL
Definition: ddrawi.h:102
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
HRESULT WINAPI DMORegister(LPCWSTR szName, REFCLSID clsidDMO, REFGUID guidCategory, DWORD dwFlags, DWORD cInTypes, const DMO_PARTIAL_MEDIATYPE *pInTypes, DWORD cOutTypes, const DMO_PARTIAL_MEDIATYPE *pOutTypes)
Definition: dmoreg.c:126
HRESULT WINAPI DMOUnregister(REFCLSID dmo, REFGUID category)
Definition: dmoreg.c:231
static const GUID testclsid
Definition: filtermapper.c:31
static IFilterMapper3 * create_mapper(void)
Definition: filtermapper.c:33
short WCHAR
Definition: pedump.c:58
Definition: name.c:39

Referenced by START_TEST().

◆ test_fm2_enummatchingfilters()

static void test_fm2_enummatchingfilters ( void  )
static

Definition at line 111 of file filtermapper.c.

112{
113 IEnumRegFilters *enum_reg;
114 IFilterMapper2 *pMapper = NULL;
115 IFilterMapper *mapper;
116 HRESULT hr;
117 REGFILTER2 rgf2;
118 REGFILTERPINS2 rgPins2[2];
119 REGPINTYPES rgPinType;
120 CLSID clsidFilter1;
121 CLSID clsidFilter2;
122 IEnumMoniker *pEnum = NULL;
123 BOOL found, registered = TRUE;
124 REGFILTER *regfilter;
125 ULONG count, ref;
126
127 ZeroMemory(&rgf2, sizeof(rgf2));
128
129 hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
130 &IID_IFilterMapper2, (LPVOID*)&pMapper);
131 ok(hr == S_OK, "Got hr %#lx.\n", hr);
132 if (FAILED(hr)) goto out;
133
134 hr = CoCreateGuid(&clsidFilter1);
135 ok(hr == S_OK, "Got hr %#lx.\n", hr);
136 hr = CoCreateGuid(&clsidFilter2);
137 ok(hr == S_OK, "Got hr %#lx.\n", hr);
138
139 /* Test that a test renderer filter is returned when enumerating filters with bRender=FALSE */
140 rgf2.dwVersion = 2;
141 rgf2.dwMerit = MERIT_UNLIKELY;
142 rgf2.cPins2 = 1;
143 rgf2.rgPins2 = rgPins2;
144
145 rgPins2[0].dwFlags = REG_PINFLAG_B_RENDERER;
146 rgPins2[0].cInstances = 1;
147 rgPins2[0].nMediaTypes = 1;
148 rgPins2[0].lpMediaType = &rgPinType;
149 rgPins2[0].nMediums = 0;
150 rgPins2[0].lpMedium = NULL;
151 rgPins2[0].clsPinCategory = NULL;
152
153 rgPinType.clsMajorType = &GUID_NULL;
154 rgPinType.clsMinorType = &GUID_NULL;
155
156 hr = IFilterMapper2_RegisterFilter(pMapper, &clsidFilter1, L"Testfilter1", NULL,
157 &CLSID_LegacyAmFilterCategory, NULL, &rgf2);
158 if (hr == E_ACCESSDENIED)
159 {
160 registered = FALSE;
161 skip("Not authorized to register filters\n");
162 }
163 else
164 {
165 ok(hr == S_OK, "Got hr %#lx.\n", hr);
166
167 rgPins2[0].dwFlags = 0;
168
169 rgPins2[1].dwFlags = REG_PINFLAG_B_OUTPUT;
170 rgPins2[1].cInstances = 1;
171 rgPins2[1].nMediaTypes = 1;
172 rgPins2[1].lpMediaType = &rgPinType;
173 rgPins2[1].nMediums = 0;
174 rgPins2[1].lpMedium = NULL;
175 rgPins2[1].clsPinCategory = NULL;
176
177 rgf2.cPins2 = 2;
178
179 hr = IFilterMapper2_RegisterFilter(pMapper, &clsidFilter2, L"Testfilter2", NULL,
180 &CLSID_LegacyAmFilterCategory, NULL, &rgf2);
181 ok(hr == S_OK, "Got hr %#lx.\n", hr);
182
183 hr = IFilterMapper2_EnumMatchingFilters(pMapper, &pEnum, 0, TRUE, MERIT_UNLIKELY, TRUE,
185 ok(hr == S_OK, "Got hr %#lx.\n", hr);
186 if (SUCCEEDED(hr) && pEnum)
187 {
188 found = enum_find_filter(L"Testfilter1", pEnum);
189 ok(found, "EnumMatchingFilters failed to return the test filter 1\n");
190 }
191
192 if (pEnum) IEnumMoniker_Release(pEnum);
193 pEnum = NULL;
194
195 hr = IFilterMapper2_EnumMatchingFilters(pMapper, &pEnum, 0, TRUE, MERIT_UNLIKELY, TRUE,
197 ok(hr == S_OK, "Got hr %#lx.\n", hr);
198 if (SUCCEEDED(hr) && pEnum)
199 {
200 found = enum_find_filter(L"Testfilter2", pEnum);
201 ok(found, "EnumMatchingFilters failed to return the test filter 2\n");
202 }
203
204 if (pEnum) IEnumMoniker_Release(pEnum);
205 pEnum = NULL;
206
207 /* Non renderer must not be returned with bRender=TRUE */
208
209 hr = IFilterMapper2_EnumMatchingFilters(pMapper, &pEnum, 0, TRUE, MERIT_UNLIKELY, TRUE,
210 0, NULL, NULL, &GUID_NULL, TRUE, FALSE, 0, NULL, NULL, &GUID_NULL);
211 ok(hr == S_OK, "Got hr %#lx.\n", hr);
212
213 if (SUCCEEDED(hr) && pEnum)
214 {
215 found = enum_find_filter(L"Testfilter1", pEnum);
216 ok(found, "EnumMatchingFilters failed to return the test filter 1\n");
217 }
218
219 hr = IFilterMapper2_QueryInterface(pMapper, &IID_IFilterMapper, (void **)&mapper);
220 ok(hr == S_OK, "Got hr %#lx.\n", hr);
221
222 found = FALSE;
223 hr = IFilterMapper_EnumMatchingFilters(mapper, &enum_reg, MERIT_UNLIKELY,
225 ok(hr == S_OK, "Got hr %#lx.\n", hr);
226 while (!found && IEnumRegFilters_Next(enum_reg, 1, &regfilter, &count) == S_OK)
227 {
228 if (!wcscmp(regfilter->Name, L"Testfilter1") && IsEqualGUID(&clsidFilter1, &regfilter->Clsid))
229 found = TRUE;
230 }
231 IEnumRegFilters_Release(enum_reg);
232 ok(found, "IFilterMapper didn't find filter\n");
233
234 IFilterMapper_Release(mapper);
235 }
236
237 if (pEnum) IEnumMoniker_Release(pEnum);
238 pEnum = NULL;
239
240 hr = IFilterMapper2_EnumMatchingFilters(pMapper, &pEnum, 0, TRUE, MERIT_UNLIKELY, TRUE,
241 0, NULL, NULL, &GUID_NULL, TRUE, FALSE, 0, NULL, NULL, &GUID_NULL);
242 ok(hr == S_OK, "Got hr %#lx.\n", hr);
243
244 if (SUCCEEDED(hr) && pEnum)
245 {
246 found = enum_find_filter(L"Testfilter2", pEnum);
247 ok(!found, "EnumMatchingFilters should not return the test filter 2\n");
248 }
249
250 if (registered)
251 {
252 hr = IFilterMapper2_UnregisterFilter(pMapper, &CLSID_LegacyAmFilterCategory, NULL,
253 &clsidFilter1);
254 ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
255
256 hr = IFilterMapper2_UnregisterFilter(pMapper, &CLSID_LegacyAmFilterCategory, NULL,
257 &clsidFilter2);
258 ok(SUCCEEDED(hr), "Got hr %#lx.\n", hr);
259 }
260
261 out:
262
263 if (pEnum) IEnumMoniker_Release(pEnum);
264 ref = IFilterMapper2_Release(pMapper);
265 ok(!ref, "Got outstanding refcount %ld.\n", ref);
266}
REGPINTYPES
Definition: axextend.idl:194
@ REG_PINFLAG_B_RENDERER
Definition: axextend.idl:219
@ REG_PINFLAG_B_OUTPUT
Definition: axextend.idl:221
HRESULT WINAPI CoCreateGuid(GUID *guid)
Definition: combase.c:1016
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define FAILED(hr)
Definition: intsafe.h:51
#define GUID_NULL
Definition: ks.h:106
#define ZeroMemory
Definition: minwinbase.h:31
static BOOL enum_find_filter(const WCHAR *wszFilterName, IEnumMoniker *pEnum)
Definition: filtermapper.c:80
DWORD dwVersion
Definition: axextend.idl:238
DWORD dwMerit
Definition: axextend.idl:239
const REGFILTERPINS2 * rgPins2
Definition: axextend.idl:253
ULONG cPins2
Definition: axextend.idl:252
const CLSID * clsPinCategory
Definition: axextend.idl:233
const REGPINMEDIUM * lpMedium
Definition: axextend.idl:232
const REGPINTYPES * lpMediaType
Definition: axextend.idl:230
CLSID Clsid
Definition: axextend.idl:83
LPWSTR Name
Definition: axextend.idl:84
#define E_ACCESSDENIED
Definition: winerror.h:4116

Referenced by START_TEST().

◆ test_interfaces()

static void test_interfaces ( void  )
static

Definition at line 64 of file filtermapper.c.

65{
66 IFilterMapper3 *mapper = create_mapper();
67
68 check_interface(mapper, &IID_IAMFilterData, TRUE);
69 check_interface(mapper, &IID_IFilterMapper, TRUE);
70 check_interface(mapper, &IID_IFilterMapper2, TRUE);
71 check_interface(mapper, &IID_IFilterMapper3, TRUE);
73
74 check_interface(mapper, &IID_IFilterGraph, FALSE);
75
76 IFilterMapper3_Release(mapper);
77}
#define check_interface(a, b, c)
Definition: filtermapper.c:49

Referenced by START_TEST().

◆ test_legacy_filter_registration()

static void test_legacy_filter_registration ( void  )
static

Definition at line 268 of file filtermapper.c.

269{
270 IEnumRegFilters *enum_reg;
271 IEnumMoniker *enum_mon;
272 IFilterMapper2 *mapper2;
273 IFilterMapper *mapper;
274 REGFILTER *regfilter;
275 WCHAR clsidstring[40];
276 WCHAR key_name[50];
277 ULONG count;
278 CLSID clsid;
279 LRESULT ret;
280 HRESULT hr;
281 BOOL found;
282 HKEY hkey;
283
284 /* Register* functions need a filter class key to write pin and pin media
285 * type data to. Create a bogus class key for it. */
287 StringFromGUID2(&clsid, clsidstring, ARRAY_SIZE(clsidstring));
288 wcscpy(key_name, L"CLSID\\");
289 wcscat(key_name, clsidstring);
292 {
293 skip("Not authorized to register filters\n");
294 return;
295 }
296
297 /* Test if legacy filter registration scheme works (filter is added to HKCR\Filter). IFilterMapper_RegisterFilter
298 * registers in this way. Filters so registered must then be accessible through both IFilterMapper_EnumMatchingFilters
299 * and IFilterMapper2_EnumMatchingFilters. */
300 hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterMapper2, (void **)&mapper2);
301 ok(hr == S_OK, "Got hr %#lx.\n", hr);
302
303 hr = IFilterMapper2_QueryInterface(mapper2, &IID_IFilterMapper, (void **)&mapper);
304 ok(hr == S_OK, "Got hr %#lx.\n", hr);
305
306 /* Set default value - this is interpreted as "friendly name" later. */
307 RegSetValueExW(hkey, NULL, 0, REG_SZ, (const BYTE *)L"Testfilter", sizeof(L"Testfilter"));
308 RegCloseKey(hkey);
309
310 hr = IFilterMapper_RegisterFilter(mapper, clsid, L"Testfilter", MERIT_UNLIKELY);
311 ok(hr == S_OK, "Got hr %#lx.\n", hr);
312
313 hr = IFilterMapper_RegisterPin(mapper, clsid, L"Pin1", TRUE, FALSE, FALSE, FALSE, GUID_NULL, NULL);
314 ok(hr == S_OK, "Got hr %#lx.\n", hr);
315
316 hr = IFilterMapper_RegisterPinType(mapper, clsid, L"Pin1", GUID_NULL, GUID_NULL);
317 ok(hr == S_OK, "Got hr %#lx.\n", hr);
318
319 hr = IFilterMapper2_EnumMatchingFilters(mapper2, &enum_mon, 0, TRUE, MERIT_UNLIKELY, TRUE,
321 ok(hr == S_OK, "Got hr %#lx.\n", hr);
322 ok(enum_find_filter(L"Testfilter", enum_mon), "IFilterMapper2 didn't find filter\n");
323 IEnumMoniker_Release(enum_mon);
324
325 found = FALSE;
326 hr = IFilterMapper_EnumMatchingFilters(mapper, &enum_reg, MERIT_UNLIKELY, TRUE, GUID_NULL, GUID_NULL,
328 ok(hr == S_OK, "Got hr %#lx.\n", hr);
329 while(!found && IEnumRegFilters_Next(enum_reg, 1, &regfilter, &count) == S_OK)
330 {
331 if (!wcscmp(regfilter->Name, L"Testfilter") && IsEqualGUID(&clsid, &regfilter->Clsid))
332 found = TRUE;
333 }
334 IEnumRegFilters_Release(enum_reg);
335 ok(found, "IFilterMapper didn't find filter\n");
336
337 hr = IFilterMapper_UnregisterFilter(mapper, clsid);
338 ok(hr == S_OK, "Got hr %#lx.\n", hr);
339
340 hr = IFilterMapper2_EnumMatchingFilters(mapper2, &enum_mon, 0, TRUE, MERIT_UNLIKELY, TRUE,
342 ok(hr == S_OK, "Got hr %#lx.\n", hr);
343 ok(!enum_find_filter(L"Testfilter", enum_mon), "IFilterMapper2 shouldn't find filter\n");
344 IEnumMoniker_Release(enum_mon);
345
346 found = FALSE;
347 hr = IFilterMapper_EnumMatchingFilters(mapper, &enum_reg, MERIT_UNLIKELY, TRUE, GUID_NULL, GUID_NULL,
349 ok(hr == S_OK, "Got hr %#lx.\n", hr);
350 while(!found && IEnumRegFilters_Next(enum_reg, 1, &regfilter, &count) == S_OK)
351 {
352 if (!wcscmp(regfilter->Name, L"Testfilter") && IsEqualGUID(&clsid, &regfilter->Clsid))
353 found = TRUE;
354 }
355 IEnumRegFilters_Release(enum_reg);
356 ok(!found, "IFilterMapper shouldn't find filter\n");
357
359 ok(!ret, "RegDeleteKeyA failed: %Iu\n", ret);
360
361 hr = IFilterMapper_RegisterFilter(mapper, clsid, L"Testfilter", MERIT_UNLIKELY);
362 ok(hr == S_OK, "Got hr %#lx.\n", hr);
363
364 hr = IFilterMapper_UnregisterFilter(mapper, clsid);
365 ok(hr == S_OK, "Got hr %#lx.\n", hr);
366
367 IFilterMapper_Release(mapper);
368 IFilterMapper2_Release(mapper2);
369}
#define REG_SZ
Definition: layer.c:22
#define ARRAY_SIZE(A)
Definition: main.h:20
#define RegCloseKey(hKey)
Definition: registry.h:49
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:1096
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:4882
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
INT WINAPI StringFromGUID2(REFGUID guid, LPOLESTR str, INT cmax)
Definition: combase.c:1525
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
LONG_PTR LRESULT
Definition: minwindef.h:176
const CLSID * clsid
Definition: msctf.cpp:50
#define KEY_WRITE
Definition: nt_native.h:1034
wcscat
wcscpy
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ test_parse_filter_data()

static void test_parse_filter_data ( void  )
static

Definition at line 453 of file filtermapper.c.

454{
455 static const BYTE data_block[] = {
456 0x02,0x00,0x00,0x00,0xff,0xff,0x5f,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x70,0x69,0x33,
457 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
458 0x30,0x74,0x79,0x33,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x31,0x70,0x69,0x33,
459 0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
460 0x30,0x74,0x79,0x33,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x76,0x69,0x64,0x73,
461 0x00,0x00,0x10,0x00,0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
462 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
463
464 BYTE *prgbRegFilter2 = NULL;
465 REGFILTER2 *pRegFilter = NULL;
466 IFilterMapper2 *pMapper = NULL;
467 SAFEARRAYBOUND saBound;
468 SAFEARRAY *psa = NULL;
469 LPBYTE pbSAData = NULL;
470 HRESULT hr;
471
473
474 hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
475 &IID_IFilterMapper2, (LPVOID*)&pMapper);
476 ok((hr == S_OK || broken(hr != S_OK)), "Got hr %#lx.\n", hr);
477 if (FAILED(hr)) goto out;
478
479 hr = IFilterMapper2_QueryInterface(pMapper, &IID_IAMFilterData, (LPVOID*)&pData);
480 ok((hr == S_OK || broken(hr != S_OK)), "Unable to find IID_IAMFilterData interface\n");
481 if (FAILED(hr)) goto out;
482
483 saBound.lLbound = 0;
484 saBound.cElements = sizeof(data_block);
485 psa = SafeArrayCreate(VT_UI1, 1, &saBound);
486 ok(psa != NULL, "Unable to create safe array\n");
487 if (!psa) goto out;
488 hr = SafeArrayAccessData(psa, (LPVOID *)&pbSAData);
489 ok(hr == S_OK, "Unable to access array data\n");
490 if (FAILED(hr)) goto out;
491 memcpy(pbSAData, data_block, sizeof(data_block));
492
493 hr = IAMFilterData_ParseFilterData(pData, pbSAData, sizeof(data_block), &prgbRegFilter2);
494 /* We cannot do anything here. prgbRegFilter2 is very unstable */
495 /* Pre Vista, this is a stack pointer so anything that changes the stack invalidats it */
496 /* Post Vista, it is a static pointer in the data section of the module */
497 pRegFilter =((REGFILTER2**)prgbRegFilter2)[0];
498 ok (hr==S_OK,"Failed to Parse filter Data\n");
499
500 ok(IsBadReadPtr(prgbRegFilter2,sizeof(REGFILTER2*))==0,"Bad read pointer returned\n");
501 ok(IsBadReadPtr(pRegFilter,sizeof(REGFILTER2))==0,"Bad read pointer for FilterData\n");
502 ok(pRegFilter->dwMerit == 0x5fffff,"Incorrect merit returned\n");
503
504out:
505 CoTaskMemFree(pRegFilter);
506 if (psa)
507 {
509 SafeArrayDestroy(psa);
510 }
511 if (pData)
512 IAMFilterData_Release(pData);
513 if (pMapper)
514 IFilterMapper2_Release(pMapper);
515}
#define broken(x)
Definition: atltest.h:178
@ VT_UI1
Definition: compat.h:2311
BOOL WINAPI IsBadReadPtr(IN LPCVOID lp, IN UINT_PTR ucb)
Definition: except.c:805
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
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by START_TEST().

◆ test_register_filter_with_null_clsMinorType()

static void test_register_filter_with_null_clsMinorType ( void  )
static

Definition at line 371 of file filtermapper.c.

372{
373 static WCHAR wszPinName[] = L"Pin";
374 IFilterMapper2 *pMapper = NULL;
375 HRESULT hr;
376 REGFILTER2 rgf2;
377 REGFILTERPINS rgPins;
378 REGFILTERPINS2 rgPins2;
379 REGPINTYPES rgPinType;
380 CLSID clsidFilter1;
381 CLSID clsidFilter2;
382
383 hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
384 &IID_IFilterMapper2, (LPVOID*)&pMapper);
385 ok(hr == S_OK, "Got hr %#lx.\n", hr);
386 if (FAILED(hr)) goto out;
387
388 hr = CoCreateGuid(&clsidFilter1);
389 ok(hr == S_OK, "Got hr %#lx.\n", hr);
390 hr = CoCreateGuid(&clsidFilter2);
391 ok(hr == S_OK, "Got hr %#lx.\n", hr);
392
393 rgPinType.clsMajorType = &GUID_NULL;
394 /* Make sure quartz accepts it without crashing */
395 rgPinType.clsMinorType = NULL;
396
397 /* Test with pin descript version 1 */
398 ZeroMemory(&rgf2, sizeof(rgf2));
399 rgf2.dwVersion = 1;
400 rgf2.dwMerit = MERIT_UNLIKELY;
401 rgf2.cPins = 1;
402 rgf2.rgPins = &rgPins;
403
404 rgPins.strName = wszPinName;
405 rgPins.bRendered = 1;
406 rgPins.bOutput = 0;
407 rgPins.bZero = 0;
408 rgPins.bMany = 0;
409 rgPins.clsConnectsToFilter = NULL;
410 rgPins.strConnectsToPin = NULL;
411 rgPins.nMediaTypes = 1;
412 rgPins.lpMediaType = &rgPinType;
413
414 hr = IFilterMapper2_RegisterFilter(pMapper, &clsidFilter1, L"Testfilter1", NULL,
415 &CLSID_LegacyAmFilterCategory, NULL, &rgf2);
416 if (hr == E_ACCESSDENIED)
417 {
418 skip("Not authorized to register filters\n");
419 goto out;
420 }
421 ok(hr == S_OK, "Got hr %#lx.\n", hr);
422
423 hr = IFilterMapper2_UnregisterFilter(pMapper, &CLSID_LegacyAmFilterCategory, NULL, &clsidFilter1);
424 ok(hr == S_OK, "Got hr %#lx.\n", hr);
425
426 /* Test with pin descript version 2 */
427 ZeroMemory(&rgf2, sizeof(rgf2));
428 rgf2.dwVersion = 2;
429 rgf2.dwMerit = MERIT_UNLIKELY;
430 rgf2.cPins2 = 1;
431 rgf2.rgPins2 = &rgPins2;
432
434 rgPins2.cInstances = 1;
435 rgPins2.nMediaTypes = 1;
436 rgPins2.lpMediaType = &rgPinType;
437 rgPins2.nMediums = 0;
438 rgPins2.lpMedium = NULL;
439 rgPins2.clsPinCategory = NULL;
440
441 hr = IFilterMapper2_RegisterFilter(pMapper, &clsidFilter2, L"Testfilter2", NULL,
442 &CLSID_LegacyAmFilterCategory, NULL, &rgf2);
443 ok(hr == S_OK, "Got hr %#lx.\n", hr);
444
445 hr = IFilterMapper2_UnregisterFilter(pMapper, &CLSID_LegacyAmFilterCategory, NULL, &clsidFilter2);
446 ok(hr == S_OK, "Got hr %#lx.\n", hr);
447
448 out:
449
450 if (pMapper) IFilterMapper2_Release(pMapper);
451}
const REGFILTERPINS * rgPins
Definition: axextend.idl:246
ULONG cPins
Definition: axextend.idl:245
LPWSTR strName
Definition: axextend.idl:198
const CLSID * clsConnectsToFilter
Definition: axextend.idl:203
const REGPINTYPES * lpMediaType
Definition: axextend.idl:206
const WCHAR * strConnectsToPin
Definition: axextend.idl:204
UINT nMediaTypes
Definition: axextend.idl:205

Referenced by START_TEST().

Variable Documentation

◆ outer_ref

LONG outer_ref = 1
static

Definition at line 518 of file filtermapper.c.

Referenced by outer_AddRef(), outer_Release(), and test_aggregation().

◆ outer_vtbl

const IUnknownVtbl outer_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI outer_AddRef(IUnknown *iface)
Definition: filtermapper.c:533
static HRESULT WINAPI outer_QueryInterface(IUnknown *iface, REFIID iid, void **out)
Definition: filtermapper.c:520
static ULONG WINAPI outer_Release(IUnknown *iface)
Definition: filtermapper.c:538

Definition at line 543 of file filtermapper.c.

◆ test_iid

const GUID test_iid = {0x33333333}
static

Definition at line 517 of file filtermapper.c.

Referenced by outer_QueryInterface(), and test_aggregation().

◆ test_outer

IUnknown test_outer = {&outer_vtbl}
static

Definition at line 550 of file filtermapper.c.

Referenced by test_aggregation().

◆ testclsid

const GUID testclsid = {0x77777777}
static

Definition at line 31 of file filtermapper.c.

Referenced by test_dmo().