/* * SetupRegisterFilter through IFilterMapper2 */ static HRESULT SetupRegisterFilter2(const AMOVIESETUP_FILTER * const pSetup, IFilterMapper2 * pIFM2, BOOL bRegister) { HRESULT hr; if (NULL == pSetup) return S_FALSE; /* unregister filter */ hr = IFilterMapper2_UnregisterFilter(pIFM2, 0, 0, pSetup->clsID); if (bRegister) { REGFILTER2 rf2; rf2.dwVersion = 1; rf2.dwMerit = pSetup->dwMerit; rf2.u.s.cPins = pSetup->nPins; rf2.u.s.rgPins = pSetup->lpPin; /* register filter */ hr = IFilterMapper2_RegisterFilter(pIFM2, pSetup->clsID, pSetup->strName, 0, 0, NULL, &rf2); } else { /* filter not found is ignored here, but there is no #define for 0x80070002 */ if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) hr = NOERROR; } return hr; }
HRESULT WINAPI AMovieSetupRegisterFilter2(const AMOVIESETUP_FILTER *pFilter, IFilterMapper2 *pIFM2, BOOL bRegister) { if (!pFilter) return S_OK; if (bRegister) { { REGFILTER2 rf2; rf2.dwVersion = 1; rf2.dwMerit = pFilter->merit; rf2.u.s1.cPins = pFilter->pins; rf2.u.s1.rgPins = pFilter->pPin; return IFilterMapper2_RegisterFilter(pIFM2, pFilter->clsid, pFilter->name, NULL, &CLSID_LegacyAmFilterCategory, NULL, &rf2); } } else return IFilterMapper2_UnregisterFilter(pIFM2, &CLSID_LegacyAmFilterCategory, NULL, pFilter->clsid); }
/********************************************************************** * DEVENUM_CreateSpecialCategories (INTERNAL) * * Creates the keys in the registry for the dynamic categories */ static HRESULT DEVENUM_CreateSpecialCategories(void) { HRESULT res; WCHAR szDSoundNameFormat[MAX_PATH + 1]; WCHAR szDSoundName[MAX_PATH + 1]; DWORD iDefaultDevice = -1; UINT numDevs; IFilterMapper2 * pMapper = NULL; REGFILTER2 rf2; REGFILTERPINS2 rfp2; WCHAR path[MAX_PATH]; HKEY basekey; if (DEVENUM_populate_handle) return S_OK; DEVENUM_populate_handle = CreateEventW(NULL, TRUE, FALSE, DEVENUM_populate_handle_nameW); if (GetLastError() == ERROR_ALREADY_EXISTS) { /* Webcams can take some time to scan if the driver is badly written and it enables them, * so have a 10 s timeout here */ if (WaitForSingleObject(DEVENUM_populate_handle, 10000) == WAIT_TIMEOUT) WARN("Waiting for object timed out\n"); TRACE("No need to rescan\n"); return S_OK; } TRACE("Scanning for devices\n"); /* Since devices can change between session, for example because you just plugged in a webcam * or switched from pulseaudio to alsa, delete all old devices first */ if (SUCCEEDED(DEVENUM_GetCategoryKey(&CLSID_AudioRendererCategory, &basekey, path, MAX_PATH))) RegDeleteTreeW(basekey, path); if (SUCCEEDED(DEVENUM_GetCategoryKey(&CLSID_AudioInputDeviceCategory, &basekey, path, MAX_PATH))) RegDeleteTreeW(basekey, path); if (SUCCEEDED(DEVENUM_GetCategoryKey(&CLSID_VideoInputDeviceCategory, &basekey, path, MAX_PATH))) RegDeleteTreeW(basekey, path); if (SUCCEEDED(DEVENUM_GetCategoryKey(&CLSID_MidiRendererCategory, &basekey, path, MAX_PATH))) RegDeleteTreeW(basekey, path); rf2.dwVersion = 2; rf2.dwMerit = MERIT_PREFERRED; rf2.u.s1.cPins2 = 1; rf2.u.s1.rgPins2 = &rfp2; rfp2.cInstances = 1; rfp2.nMediums = 0; rfp2.lpMedium = NULL; rfp2.clsPinCategory = &IID_NULL; if (!LoadStringW(DEVENUM_hInstance, IDS_DEVENUM_DS, szDSoundNameFormat, sizeof(szDSoundNameFormat)/sizeof(szDSoundNameFormat[0])-1)) { ERR("Couldn't get string resource (GetLastError() is %d)\n", GetLastError()); return HRESULT_FROM_WIN32(GetLastError()); } res = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC, &IID_IFilterMapper2, (void **) &pMapper); /* * Fill in info for devices */ if (SUCCEEDED(res)) { UINT i; WAVEOUTCAPSW wocaps; WAVEINCAPSW wicaps; MIDIOUTCAPSW mocaps; REGPINTYPES * pTypes; numDevs = waveOutGetNumDevs(); res = DEVENUM_CreateAMCategoryKey(&CLSID_AudioRendererCategory); if (FAILED(res)) /* can't register any devices in this category */ numDevs = 0; rfp2.dwFlags = REG_PINFLAG_B_RENDERER; for (i = 0; i < numDevs; i++) { if (waveOutGetDevCapsW(i, &wocaps, sizeof(WAVEOUTCAPSW)) == MMSYSERR_NOERROR) { IMoniker * pMoniker = NULL; rfp2.nMediaTypes = 1; pTypes = CoTaskMemAlloc(rfp2.nMediaTypes * sizeof(REGPINTYPES)); if (!pTypes) { IFilterMapper2_Release(pMapper); return E_OUTOFMEMORY; } /* FIXME: Native devenum seems to register a lot more types for * DSound than we do. Not sure what purpose they serve */ pTypes[0].clsMajorType = &MEDIATYPE_Audio; pTypes[0].clsMinorType = &MEDIASUBTYPE_PCM; rfp2.lpMediaType = pTypes; res = IFilterMapper2_RegisterFilter(pMapper, &CLSID_AudioRender, wocaps.szPname, &pMoniker, &CLSID_AudioRendererCategory, wocaps.szPname, &rf2); /* FIXME: do additional stuff with IMoniker here, depending on what RegisterFilter does */ if (pMoniker) { IMoniker_Release(pMoniker); pMoniker = NULL; } wsprintfW(szDSoundName, szDSoundNameFormat, wocaps.szPname); res = IFilterMapper2_RegisterFilter(pMapper, &CLSID_DSoundRender, szDSoundName, &pMoniker, &CLSID_AudioRendererCategory, szDSoundName, &rf2); /* FIXME: do additional stuff with IMoniker here, depending on what RegisterFilter does */ if (pMoniker) IMoniker_Release(pMoniker); if (i == iDefaultDevice) { FIXME("Default device\n"); } CoTaskMemFree(pTypes); } } numDevs = waveInGetNumDevs(); res = DEVENUM_CreateAMCategoryKey(&CLSID_AudioInputDeviceCategory); if (FAILED(res)) /* can't register any devices in this category */ numDevs = 0; rfp2.dwFlags = REG_PINFLAG_B_OUTPUT; for (i = 0; i < numDevs; i++) { if (waveInGetDevCapsW(i, &wicaps, sizeof(WAVEINCAPSW)) == MMSYSERR_NOERROR) { IMoniker * pMoniker = NULL; rfp2.nMediaTypes = 1; pTypes = CoTaskMemAlloc(rfp2.nMediaTypes * sizeof(REGPINTYPES)); if (!pTypes) { IFilterMapper2_Release(pMapper); return E_OUTOFMEMORY; } /* FIXME: Not sure if these are correct */ pTypes[0].clsMajorType = &MEDIATYPE_Audio; pTypes[0].clsMinorType = &MEDIASUBTYPE_PCM; rfp2.lpMediaType = pTypes; res = IFilterMapper2_RegisterFilter(pMapper, &CLSID_AudioRecord, wicaps.szPname, &pMoniker, &CLSID_AudioInputDeviceCategory, wicaps.szPname, &rf2); /* FIXME: do additional stuff with IMoniker here, depending on what RegisterFilter does */ if (pMoniker) IMoniker_Release(pMoniker); CoTaskMemFree(pTypes); } } numDevs = midiOutGetNumDevs(); res = DEVENUM_CreateAMCategoryKey(&CLSID_MidiRendererCategory); if (FAILED(res)) /* can't register any devices in this category */ numDevs = 0; rfp2.dwFlags = REG_PINFLAG_B_RENDERER; for (i = 0; i < numDevs; i++) { if (midiOutGetDevCapsW(i, &mocaps, sizeof(MIDIOUTCAPSW)) == MMSYSERR_NOERROR) { IMoniker * pMoniker = NULL; rfp2.nMediaTypes = 1; pTypes = CoTaskMemAlloc(rfp2.nMediaTypes * sizeof(REGPINTYPES)); if (!pTypes) { IFilterMapper2_Release(pMapper); return E_OUTOFMEMORY; } /* FIXME: Not sure if these are correct */ pTypes[0].clsMajorType = &MEDIATYPE_Midi; pTypes[0].clsMinorType = &MEDIASUBTYPE_None; rfp2.lpMediaType = pTypes; res = IFilterMapper2_RegisterFilter(pMapper, &CLSID_AVIMIDIRender, mocaps.szPname, &pMoniker, &CLSID_MidiRendererCategory, mocaps.szPname, &rf2); /* FIXME: do additional stuff with IMoniker here, depending on what RegisterFilter does */ /* Native version sets MidiOutId */ if (pMoniker) IMoniker_Release(pMoniker); if (i == iDefaultDevice) { FIXME("Default device\n"); } CoTaskMemFree(pTypes); } } res = DEVENUM_CreateAMCategoryKey(&CLSID_VideoInputDeviceCategory); if (SUCCEEDED(res)) for (i = 0; i < 10; i++) { WCHAR szDeviceName[32], szDeviceVersion[32], szDevicePath[10]; if (capGetDriverDescriptionW ((WORD) i, szDeviceName, sizeof(szDeviceName)/sizeof(WCHAR), szDeviceVersion, sizeof(szDeviceVersion)/sizeof(WCHAR))) { IMoniker * pMoniker = NULL; IPropertyBag * pPropBag = NULL; WCHAR dprintf[] = { 'v','i','d','e','o','%','d',0 }; snprintfW(szDevicePath, sizeof(szDevicePath)/sizeof(WCHAR), dprintf, i); /* The above code prevents 1 device with a different ID overwriting another */ rfp2.nMediaTypes = 1; pTypes = CoTaskMemAlloc(rfp2.nMediaTypes * sizeof(REGPINTYPES)); if (!pTypes) { IFilterMapper2_Release(pMapper); return E_OUTOFMEMORY; } pTypes[0].clsMajorType = &MEDIATYPE_Video; pTypes[0].clsMinorType = &MEDIASUBTYPE_None; rfp2.lpMediaType = pTypes; res = IFilterMapper2_RegisterFilter(pMapper, &CLSID_VfwCapture, szDeviceName, &pMoniker, &CLSID_VideoInputDeviceCategory, szDevicePath, &rf2); if (pMoniker) { OLECHAR wszVfwIndex[] = { 'V','F','W','I','n','d','e','x',0 }; VARIANT var; V_VT(&var) = VT_I4; V_UNION(&var, ulVal) = i; res = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (LPVOID)&pPropBag); if (SUCCEEDED(res)) res = IPropertyBag_Write(pPropBag, wszVfwIndex, &var); IMoniker_Release(pMoniker); } if (i == iDefaultDevice) FIXME("Default device\n"); CoTaskMemFree(pTypes); } } } if (pMapper) IFilterMapper2_Release(pMapper); SetEvent(DEVENUM_populate_handle); return res; }
static HRESULT DEVENUM_RegisterLegacyAmFilters(void) { HKEY hkeyFilter = NULL; DWORD dwFilterSubkeys, i; LONG lRet; IFilterMapper2 *pMapper = NULL; HRESULT hr; hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC, &IID_IFilterMapper2, (void **) &pMapper); if (SUCCEEDED(hr)) { lRet = RegOpenKeyExW(HKEY_CLASSES_ROOT, wszFilterKeyName, 0, KEY_READ, &hkeyFilter); hr = HRESULT_FROM_WIN32(lRet); } if (SUCCEEDED(hr)) { lRet = RegQueryInfoKeyW(hkeyFilter, NULL, NULL, NULL, &dwFilterSubkeys, NULL, NULL, NULL, NULL, NULL, NULL, NULL); hr = HRESULT_FROM_WIN32(lRet); } if (SUCCEEDED(hr)) { for (i = 0; i < dwFilterSubkeys; i++) { WCHAR wszFilterSubkeyName[64]; DWORD cName = sizeof(wszFilterSubkeyName) / sizeof(WCHAR); HKEY hkeyCategoryBaseKey; WCHAR wszRegKey[MAX_PATH]; HKEY hkeyInstance = NULL; if (RegEnumKeyExW(hkeyFilter, i, wszFilterSubkeyName, &cName, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) continue; hr = DEVENUM_GetCategoryKey(&CLSID_LegacyAmFilterCategory, &hkeyCategoryBaseKey, wszRegKey, MAX_PATH); if (FAILED(hr)) continue; strcatW(wszRegKey, wszRegSeparator); strcatW(wszRegKey, wszFilterSubkeyName); if (RegOpenKeyExW(HKEY_CLASSES_ROOT, wszRegKey, 0, KEY_READ, &hkeyInstance) == ERROR_SUCCESS) { RegCloseKey(hkeyInstance); } else { /* Filter is registered the IFilterMapper(1)-way in HKCR\Filter. Needs to be added to * legacy am filter category. */ HKEY hkeyFilterClass = NULL; REGFILTER2 rgf2; CLSID clsidFilter; WCHAR wszFilterName[MAX_PATH]; DWORD Type; DWORD cbData; HRESULT res; IMoniker *pMoniker = NULL; TRACE("Registering %s\n", debugstr_w(wszFilterSubkeyName)); strcpyW(wszRegKey, clsid_keyname); strcatW(wszRegKey, wszRegSeparator); strcatW(wszRegKey, wszFilterSubkeyName); if (RegOpenKeyExW(HKEY_CLASSES_ROOT, wszRegKey, 0, KEY_READ, &hkeyFilterClass) != ERROR_SUCCESS) continue; rgf2.dwVersion = 1; rgf2.dwMerit = 0; rgf2.u.s.cPins = 0; rgf2.u.s.rgPins = NULL; cbData = sizeof(wszFilterName); if (RegQueryValueExW(hkeyFilterClass, NULL, NULL, &Type, (LPBYTE)wszFilterName, &cbData) != ERROR_SUCCESS || Type != REG_SZ) goto cleanup; cbData = sizeof(rgf2.dwMerit); if (RegQueryValueExW(hkeyFilterClass, wszMeritName, NULL, &Type, (LPBYTE)&rgf2.dwMerit, &cbData) != ERROR_SUCCESS || Type != REG_DWORD) goto cleanup; DEVENUM_ReadPins(hkeyFilterClass, &rgf2); res = CLSIDFromString(wszFilterSubkeyName, &clsidFilter); if (FAILED(res)) goto cleanup; IFilterMapper2_RegisterFilter(pMapper, &clsidFilter, wszFilterName, &pMoniker, NULL, NULL, &rgf2); if (pMoniker) IMoniker_Release(pMoniker); cleanup: if (hkeyFilterClass) RegCloseKey(hkeyFilterClass); if (rgf2.u.s.rgPins) { UINT iPin; for (iPin = 0; iPin < rgf2.u.s.cPins; iPin++) { CoTaskMemFree(rgf2.u.s.rgPins[iPin].strName); if (rgf2.u.s.rgPins[iPin].lpMediaType) { UINT iType; for (iType = 0; iType < rgf2.u.s.rgPins[iPin].nMediaTypes; iType++) { CoTaskMemFree((void*)rgf2.u.s.rgPins[iPin].lpMediaType[iType].clsMajorType); CoTaskMemFree((void*)rgf2.u.s.rgPins[iPin].lpMediaType[iType].clsMinorType); } CoTaskMemFree((void*)rgf2.u.s.rgPins[iPin].lpMediaType); } } CoTaskMemFree((void*)rgf2.u.s.rgPins); } } } } if (hkeyFilter) RegCloseKey(hkeyFilter); if (pMapper) IFilterMapper2_Release(pMapper); return S_OK; }
/*********************************************************************** * register_filters */ static HRESULT register_filters(struct regsvr_filter const *list) { HRESULT hr; IFilterMapper2* pFM2 = NULL; CoInitialize(NULL); hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterMapper2, (LPVOID*)&pFM2); if (SUCCEEDED(hr)) { for (; SUCCEEDED(hr) && list->clsid; ++list) { REGFILTER2 rf2; REGFILTERPINS2* prfp2; int i; for (i = 0; list->pins[i].flags != 0xFFFFFFFF; i++) ; rf2.dwVersion = 2; rf2.dwMerit = list->merit; rf2.u.s2.cPins2 = i; rf2.u.s2.rgPins2 = prfp2 = CoTaskMemAlloc(i*sizeof(REGFILTERPINS2)); if (!prfp2) { hr = E_OUTOFMEMORY; break; } for (i = 0; list->pins[i].flags != 0xFFFFFFFF; i++) { REGPINTYPES* lpMediatype; CLSID* lpClsid; int j, nbmt; for (nbmt = 0; list->pins[i].mediatypes[nbmt].majortype; nbmt++) ; /* Allocate a single buffer for regpintypes struct and clsids */ lpMediatype = CoTaskMemAlloc(nbmt*(sizeof(REGPINTYPES) + 2*sizeof(CLSID))); if (!lpMediatype) { hr = E_OUTOFMEMORY; break; } lpClsid = (CLSID*) (lpMediatype + nbmt); for (j = 0; j < nbmt; j++) { (lpMediatype + j)->clsMajorType = lpClsid + j*2; memcpy(lpClsid + j*2, list->pins[i].mediatypes[j].majortype, sizeof(CLSID)); (lpMediatype + j)->clsMinorType = lpClsid + j*2 + 1; if (list->pins[i].mediatypes[j].subtype) memcpy(lpClsid + j*2 + 1, list->pins[i].mediatypes[j].subtype, sizeof(CLSID)); else { /* Subtype are often a combination of major type + fourcc/tag */ memcpy(lpClsid + j*2 + 1, list->pins[i].mediatypes[j].majortype, sizeof(CLSID)); *(DWORD*)(lpClsid + j*2 + 1) = list->pins[i].mediatypes[j].fourcc; } } prfp2[i].dwFlags = list->pins[i].flags; prfp2[i].cInstances = 0; prfp2[i].nMediaTypes = j; prfp2[i].lpMediaType = lpMediatype; prfp2[i].nMediums = 0; prfp2[i].lpMedium = NULL; prfp2[i].clsPinCategory = NULL; } if (FAILED(hr)) { ERR("failed to register with hresult 0x%x\n", hr); CoTaskMemFree(prfp2); break; } hr = IFilterMapper2_RegisterFilter(pFM2, list->clsid, list->name, NULL, list->category, NULL, &rf2); while (i) { CoTaskMemFree((REGPINTYPES*)prfp2[i-1].lpMediaType); i--; } CoTaskMemFree(prfp2); } } if (pFM2) IFilterMapper2_Release(pFM2); CoUninitialize(); return hr; }
static void test_fm2_enummatchingfilters(void) { IFilterMapper2 *pMapper = NULL; HRESULT hr; REGFILTER2 rgf2; REGFILTERPINS2 rgPins2[2]; REGPINTYPES rgPinType; static const WCHAR wszFilterName1[] = {'T', 'e', 's', 't', 'f', 'i', 'l', 't', 'e', 'r', '1', 0 }; static const WCHAR wszFilterName2[] = {'T', 'e', 's', 't', 'f', 'i', 'l', 't', 'e', 'r', '2', 0 }; CLSID clsidFilter1; CLSID clsidFilter2; IEnumMoniker *pEnum = NULL; BOOL found, registered = TRUE; ZeroMemory(&rgf2, sizeof(rgf2)); hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterMapper2, (LPVOID*)&pMapper); ok(hr == S_OK, "CoCreateInstance failed with %x\n", hr); if (FAILED(hr)) goto out; hr = CoCreateGuid(&clsidFilter1); ok(hr == S_OK, "CoCreateGuid failed with %x\n", hr); hr = CoCreateGuid(&clsidFilter2); ok(hr == S_OK, "CoCreateGuid failed with %x\n", hr); /* Test that a test renderer filter is returned when enumerating filters with bRender=FALSE */ rgf2.dwVersion = 2; rgf2.dwMerit = MERIT_UNLIKELY; S2(U(rgf2)).cPins2 = 1; S2(U(rgf2)).rgPins2 = rgPins2; rgPins2[0].dwFlags = REG_PINFLAG_B_RENDERER; rgPins2[0].cInstances = 1; rgPins2[0].nMediaTypes = 1; rgPins2[0].lpMediaType = &rgPinType; rgPins2[0].nMediums = 0; rgPins2[0].lpMedium = NULL; rgPins2[0].clsPinCategory = NULL; rgPinType.clsMajorType = &GUID_NULL; rgPinType.clsMinorType = &GUID_NULL; hr = IFilterMapper2_RegisterFilter(pMapper, &clsidFilter1, wszFilterName1, NULL, &CLSID_LegacyAmFilterCategory, NULL, &rgf2); if (hr == E_ACCESSDENIED) { registered = FALSE; skip("Not authorized to register filters\n"); } else { ok(hr == S_OK, "IFilterMapper2_RegisterFilter failed with %x\n", hr); rgPins2[0].dwFlags = 0; rgPins2[1].dwFlags = REG_PINFLAG_B_OUTPUT; rgPins2[1].cInstances = 1; rgPins2[1].nMediaTypes = 1; rgPins2[1].lpMediaType = &rgPinType; rgPins2[1].nMediums = 0; rgPins2[1].lpMedium = NULL; rgPins2[1].clsPinCategory = NULL; S2(U(rgf2)).cPins2 = 2; hr = IFilterMapper2_RegisterFilter(pMapper, &clsidFilter2, wszFilterName2, NULL, &CLSID_LegacyAmFilterCategory, NULL, &rgf2); ok(hr == S_OK, "IFilterMapper2_RegisterFilter failed with %x\n", hr); hr = IFilterMapper2_EnumMatchingFilters(pMapper, &pEnum, 0, TRUE, MERIT_UNLIKELY, TRUE, 0, NULL, NULL, &GUID_NULL, FALSE, FALSE, 0, NULL, NULL, &GUID_NULL); ok(hr == S_OK, "IFilterMapper2_EnumMatchingFilters failed with %x\n", hr); if (SUCCEEDED(hr) && pEnum) { found = enum_find_filter(wszFilterName1, pEnum); ok(found, "EnumMatchingFilters failed to return the test filter 1\n"); } if (pEnum) IEnumMoniker_Release(pEnum); pEnum = NULL; hr = IFilterMapper2_EnumMatchingFilters(pMapper, &pEnum, 0, TRUE, MERIT_UNLIKELY, TRUE, 0, NULL, NULL, &GUID_NULL, FALSE, FALSE, 0, NULL, NULL, &GUID_NULL); ok(hr == S_OK, "IFilterMapper2_EnumMatchingFilters failed with %x\n", hr); if (SUCCEEDED(hr) && pEnum) { found = enum_find_filter(wszFilterName2, pEnum); ok(found, "EnumMatchingFilters failed to return the test filter 2\n"); } if (pEnum) IEnumMoniker_Release(pEnum); pEnum = NULL; /* Non renderer must not be returned with bRender=TRUE */ hr = IFilterMapper2_EnumMatchingFilters(pMapper, &pEnum, 0, TRUE, MERIT_UNLIKELY, TRUE, 0, NULL, NULL, &GUID_NULL, TRUE, FALSE, 0, NULL, NULL, &GUID_NULL); ok(hr == S_OK, "IFilterMapper2_EnumMatchingFilters failed with %x\n", hr); if (SUCCEEDED(hr) && pEnum) { found = enum_find_filter(wszFilterName1, pEnum); ok(found, "EnumMatchingFilters failed to return the test filter 1\n"); } } if (pEnum) IEnumMoniker_Release(pEnum); pEnum = NULL; hr = IFilterMapper2_EnumMatchingFilters(pMapper, &pEnum, 0, TRUE, MERIT_UNLIKELY, TRUE, 0, NULL, NULL, &GUID_NULL, TRUE, FALSE, 0, NULL, NULL, &GUID_NULL); ok(hr == S_OK, "IFilterMapper2_EnumMatchingFilters failed with %x\n", hr); if (SUCCEEDED(hr) && pEnum) { found = enum_find_filter(wszFilterName2, pEnum); ok(!found, "EnumMatchingFilters should not return the test filter 2\n"); } if (registered) { hr = IFilterMapper2_UnregisterFilter(pMapper, &CLSID_LegacyAmFilterCategory, NULL, &clsidFilter1); ok(SUCCEEDED(hr), "IFilterMapper2_UnregisterFilter failed with %x\n", hr); hr = IFilterMapper2_UnregisterFilter(pMapper, &CLSID_LegacyAmFilterCategory, NULL, &clsidFilter2); ok(SUCCEEDED(hr), "IFilterMapper2_UnregisterFilter failed with %x\n", hr); } out: if (pEnum) IEnumMoniker_Release(pEnum); if (pMapper) IFilterMapper2_Release(pMapper); }
static void test_register_filter_with_null_clsMinorType(void) { IFilterMapper2 *pMapper = NULL; HRESULT hr; REGFILTER2 rgf2; REGFILTERPINS rgPins; REGFILTERPINS2 rgPins2; REGPINTYPES rgPinType; static WCHAR wszPinName[] = {'P', 'i', 'n', 0 }; static const WCHAR wszFilterName1[] = {'T', 'e', 's', 't', 'f', 'i', 'l', 't', 'e', 'r', '1', 0 }; static const WCHAR wszFilterName2[] = {'T', 'e', 's', 't', 'f', 'i', 'l', 't', 'e', 'r', '2', 0 }; CLSID clsidFilter1; CLSID clsidFilter2; hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterMapper2, (LPVOID*)&pMapper); ok(hr == S_OK, "CoCreateInstance failed with %x\n", hr); if (FAILED(hr)) goto out; hr = CoCreateGuid(&clsidFilter1); ok(hr == S_OK, "CoCreateGuid failed with %x\n", hr); hr = CoCreateGuid(&clsidFilter2); ok(hr == S_OK, "CoCreateGuid failed with %x\n", hr); rgPinType.clsMajorType = &GUID_NULL; /* Make sure quartz accepts it without crashing */ rgPinType.clsMinorType = NULL; /* Test with pin descript version 1 */ ZeroMemory(&rgf2, sizeof(rgf2)); rgf2.dwVersion = 1; rgf2.dwMerit = MERIT_UNLIKELY; S1(U(rgf2)).cPins = 1; S1(U(rgf2)).rgPins = &rgPins; rgPins.strName = wszPinName; rgPins.bRendered = 1; rgPins.bOutput = 0; rgPins.bZero = 0; rgPins.bMany = 0; rgPins.clsConnectsToFilter = NULL; rgPins.strConnectsToPin = NULL; rgPins.nMediaTypes = 1; rgPins.lpMediaType = &rgPinType; hr = IFilterMapper2_RegisterFilter(pMapper, &clsidFilter1, wszFilterName1, NULL, &CLSID_LegacyAmFilterCategory, NULL, &rgf2); if (hr == E_ACCESSDENIED) { skip("Not authorized to register filters\n"); goto out; } ok(hr == S_OK, "IFilterMapper2_RegisterFilter failed with %x\n", hr); hr = IFilterMapper2_UnregisterFilter(pMapper, &CLSID_LegacyAmFilterCategory, NULL, &clsidFilter1); ok(hr == S_OK, "FilterMapper_UnregisterFilter failed with %x\n", hr); /* Test with pin descript version 2 */ ZeroMemory(&rgf2, sizeof(rgf2)); rgf2.dwVersion = 2; rgf2.dwMerit = MERIT_UNLIKELY; S2(U(rgf2)).cPins2 = 1; S2(U(rgf2)).rgPins2 = &rgPins2; rgPins2.dwFlags = REG_PINFLAG_B_RENDERER; rgPins2.cInstances = 1; rgPins2.nMediaTypes = 1; rgPins2.lpMediaType = &rgPinType; rgPins2.nMediums = 0; rgPins2.lpMedium = NULL; rgPins2.clsPinCategory = NULL; hr = IFilterMapper2_RegisterFilter(pMapper, &clsidFilter2, wszFilterName2, NULL, &CLSID_LegacyAmFilterCategory, NULL, &rgf2); ok(hr == S_OK, "IFilterMapper2_RegisterFilter failed with %x\n", hr); hr = IFilterMapper2_UnregisterFilter(pMapper, &CLSID_LegacyAmFilterCategory, NULL, &clsidFilter2); ok(hr == S_OK, "FilterMapper_UnregisterFilter failed with %x\n", hr); out: if (pMapper) IFilterMapper2_Release(pMapper); }