ReactOS 0.4.16-dev-297-gc569aee
filtermapper.c File Reference
#include "wine/test.h"
#include "winbase.h"
#include "initguid.h"
#include "dshow.h"
#include "wine/winternl.h"
#include "fil_data.h"
Include dependency graph for filtermapper.c:

Go to the source code of this file.

Classes

struct  IUnknownImpl
 

Macros

#define COBJMACROS
 

Typedefs

typedef struct IUnknownImpl IUnknownImpl
 

Functions

 DEFINE_GUID (GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
 
static BOOL enum_find_filter (const WCHAR *wszFilterName, IEnumMoniker *pEnum)
 
static void test_fm2_enummatchingfilters (void)
 
static void test_legacy_filter_registration (void)
 
static ULONG getRefcount (IUnknown *iface)
 
static void test_ifiltermapper_from_filtergraph (void)
 
static void test_register_filter_with_null_clsMinorType (void)
 
static void test_parse_filter_data (void)
 
static IUnknownImplIUnknownImpl_from_iface (IUnknown *iface)
 
static HRESULT WINAPI IUnknownImpl_QueryInterface (IUnknown *iface, REFIID riid, LPVOID *ppv)
 
static ULONG WINAPI IUnknownImpl_AddRef (IUnknown *iface)
 
static ULONG WINAPI IUnknownImpl_Release (IUnknown *iface)
 
static void test_aggregate_filter_mapper (void)
 
 START_TEST (filtermapper)
 

Variables

static CONST_VTBL IUnknownVtbl IUnknownImpl_Vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file filtermapper.c.

Typedef Documentation

◆ IUnknownImpl

Function Documentation

◆ DEFINE_GUID()

DEFINE_GUID ( GUID_NULL  ,
,
,
,
,
,
,
,
,
,
,
 
)

◆ enum_find_filter()

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

Definition at line 34 of file filtermapper.c.

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}
#define ok(value,...)
Definition: atltest.h:57
#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
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4243
unsigned int BOOL
Definition: ntddk_ex.h:94
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
const char * var
Definition: shader.c:5666
#define V_BSTR(A)
Definition: oleauto.h:226
const GUID IID_IPropertyBag
#define disable_success_count
Definition: test.h:184
HRESULT hr
Definition: shlfolder.c:183
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
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by test_fm2_enummatchingfilters(), and test_legacy_filter_registration().

◆ getRefcount()

static ULONG getRefcount ( IUnknown iface)
static

Definition at line 329 of file filtermapper.c.

330{
331 IUnknown_AddRef(iface);
332 return IUnknown_Release(iface);
333}

Referenced by test_ifiltermapper_from_filtergraph().

◆ IUnknownImpl_AddRef()

static ULONG WINAPI IUnknownImpl_AddRef ( IUnknown iface)
static

Definition at line 552 of file filtermapper.c.

553{
555 This->AddRef_called++;
556 return 2;
557}
static IUnknownImpl * IUnknownImpl_from_iface(IUnknown *iface)
Definition: filtermapper.c:541

◆ IUnknownImpl_from_iface()

static IUnknownImpl * IUnknownImpl_from_iface ( IUnknown iface)
static

Definition at line 541 of file filtermapper.c.

542{
543 return CONTAINING_RECORD(iface, IUnknownImpl, IUnknown_iface);
544}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by IUnknownImpl_AddRef(), and IUnknownImpl_Release().

◆ IUnknownImpl_QueryInterface()

static HRESULT WINAPI IUnknownImpl_QueryInterface ( IUnknown iface,
REFIID  riid,
LPVOID ppv 
)
static

Definition at line 546 of file filtermapper.c.

547{
548 ok(0, "QueryInterface should not be called for %s\n", wine_dbgstr_guid(riid));
549 return E_NOINTERFACE;
550}
REFIID riid
Definition: atlbase.h:39
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ IUnknownImpl_Release()

static ULONG WINAPI IUnknownImpl_Release ( IUnknown iface)
static

Definition at line 559 of file filtermapper.c.

560{
562 This->Release_called++;
563 return 1;
564}

◆ START_TEST()

START_TEST ( filtermapper  )

Definition at line 626 of file filtermapper.c.

627{
629
636
638}
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
static void test_register_filter_with_null_clsMinorType(void)
Definition: filtermapper.c:386
static void test_aggregate_filter_mapper(void)
Definition: filtermapper.c:573
static void test_legacy_filter_registration(void)
Definition: filtermapper.c:223
static void test_ifiltermapper_from_filtergraph(void)
Definition: filtermapper.c:335
static void test_parse_filter_data(void)
Definition: filtermapper.c:470
static void test_fm2_enummatchingfilters(void)
Definition: filtermapper.c:67

◆ test_aggregate_filter_mapper()

static void test_aggregate_filter_mapper ( void  )
static

Definition at line 573 of file filtermapper.c.

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}
const GUID IID_IUnknown
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
static CONST_VTBL IUnknownVtbl IUnknownImpl_Vtbl
Definition: filtermapper.c:566
IUnknown IUnknown_iface
Definition: filtergraph.c:2200

Referenced by START_TEST().

◆ test_fm2_enummatchingfilters()

static void test_fm2_enummatchingfilters ( void  )
static

Definition at line 67 of file filtermapper.c.

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}
#define skip(...)
Definition: atltest.h:64
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
HRESULT WINAPI CoCreateGuid(GUID *pguid)
Definition: compobj.c:2206
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define FAILED(hr)
Definition: intsafe.h:51
#define GUID_NULL
Definition: ks.h:106
static BOOL enum_find_filter(const WCHAR *wszFilterName, IEnumMoniker *pEnum)
Definition: filtermapper.c:34
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
static FILE * out
Definition: regtests2xml.c:44
#define S2(x)
Definition: test.h:222
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
CLSID Clsid
Definition: axextend.idl:81
LPWSTR Name
Definition: axextend.idl:82
#define ZeroMemory
Definition: winbase.h:1737
#define E_ACCESSDENIED
Definition: winerror.h:2849

Referenced by START_TEST().

◆ test_ifiltermapper_from_filtergraph()

static void test_ifiltermapper_from_filtergraph ( void  )
static

Definition at line 335 of file filtermapper.c.

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}
static ULONG getRefcount(IUnknown *iface)
Definition: filtermapper.c:329

Referenced by START_TEST().

◆ test_legacy_filter_registration()

static void test_legacy_filter_registration ( void  )
static

Definition at line 223 of file filtermapper.c.

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}
#define RegCloseKey(hKey)
Definition: registry.h:49
static const WCHAR clsidW[]
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
#define lstrcpyW
Definition: compat.h:749
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
#define REG_SZ
Definition: layer.c:22
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
REFCLSID clsid
Definition: msctf.c:82
#define KEY_WRITE
Definition: nt_native.h:1031
int ret
LONG_PTR LRESULT
Definition: windef.h:209
#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 470 of file filtermapper.c.

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}
#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
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static SCRIPT_CACHE SCRIPT_ANALYSIS * psa
Definition: usp10.c:64
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 386 of file filtermapper.c.

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}
#define S1(x)
Definition: test.h:221
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

Referenced by START_TEST().

Variable Documentation

◆ IUnknownImpl_Vtbl

CONST_VTBL IUnknownVtbl IUnknownImpl_Vtbl
static
Initial value:
=
{
}
static ULONG WINAPI IUnknownImpl_AddRef(IUnknown *iface)
Definition: filtermapper.c:552
static HRESULT WINAPI IUnknownImpl_QueryInterface(IUnknown *iface, REFIID riid, LPVOID *ppv)
Definition: filtermapper.c:546
static ULONG WINAPI IUnknownImpl_Release(IUnknown *iface)
Definition: filtermapper.c:559

Definition at line 566 of file filtermapper.c.

Referenced by test_aggregate_filter_mapper().