Module: wine Branch: master Commit: c3e2407664de1455554c6c151919ed75e61c725b URL: http://source.winehq.org/git/wine.git/?a=commit;h=c3e2407664de1455554c6c1519...
Author: Aric Stewart aric@codeweavers.com Date: Mon Feb 6 11:02:43 2012 -0600
quartz: AMFilterData_ParseFilterData returns a pointer to a pointer to filter data.
---
.gitignore | 1 + dlls/dxdiagn/provider.c | 4 ++- dlls/quartz/filtermapper.c | 4 +- dlls/quartz/tests/Makefile.in | 2 + dlls/quartz/tests/fil_data.idl | 50 ++++++++++++++++++++++++++++ dlls/quartz/tests/filtermapper.c | 68 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 126 insertions(+), 3 deletions(-)
diff --git a/.gitignore b/.gitignore index b97d5b5..f0fcf66 100644 --- a/.gitignore +++ b/.gitignore @@ -114,6 +114,7 @@ dlls/qmgrprxy/qmgrprxy_p.c dlls/quartz/fil_data.h dlls/quartz/quartz_strmif.h dlls/quartz/quartz_strmif_p.c +dlls/quartz/tests/fil_data.h dlls/rpcrt4/epm.h dlls/rpcrt4/epm_c.c dlls/rpcrt4/tests/server.h diff --git a/dlls/dxdiagn/provider.c b/dlls/dxdiagn/provider.c index bb4ce08..db407b0 100644 --- a/dlls/dxdiagn/provider.c +++ b/dlls/dxdiagn/provider.c @@ -1323,6 +1323,7 @@ static HRESULT fill_filter_data_information(IDxDiagContainerImpl_Container *subc HRESULT hr; IFilterMapper2 *pFileMapper = NULL; IAMFilterData *pFilterData = NULL; + BYTE *ppRF = NULL; REGFILTER2 *pRF = NULL; WCHAR bufferW[10]; ULONG j; @@ -1338,9 +1339,10 @@ static HRESULT fill_filter_data_information(IDxDiagContainerImpl_Container *subc if (FAILED(hr)) goto cleanup;
- hr = IAMFilterData_ParseFilterData(pFilterData, pData, cb, (BYTE **)&pRF); + hr = IAMFilterData_ParseFilterData(pFilterData, pData, cb, (BYTE **)&ppRF); if (FAILED(hr)) goto cleanup; + pRF = ((REGFILTER2**)ppRF)[0];
snprintfW(bufferW, sizeof(bufferW)/sizeof(bufferW[0]), szVersionFormat, pRF->dwVersion); hr = add_bstr_property(subcont, szVersionW, bufferW); diff --git a/dlls/quartz/filtermapper.c b/dlls/quartz/filtermapper.c index 7d7599f..8950caa 100644 --- a/dlls/quartz/filtermapper.c +++ b/dlls/quartz/filtermapper.c @@ -1732,14 +1732,14 @@ static HRESULT WINAPI AMFilterData_ParseFilterData(IAMFilterData* iface, { FilterMapper3Impl *This = impl_from_IAMFilterData(iface); HRESULT hr = S_OK; - REGFILTER2 *prf2; + static REGFILTER2 *prf2;
TRACE("(%p/%p)->(%p, %d, %p)\n", This, iface, pData, cb, ppRegFilter2);
prf2 = CoTaskMemAlloc(sizeof(*prf2)); if (!prf2) return E_OUTOFMEMORY; - *ppRegFilter2 = (BYTE *)prf2; + *ppRegFilter2 = (BYTE *)&prf2;
hr = FM2_ReadFilterData(pData, prf2); if (FAILED(hr)) diff --git a/dlls/quartz/tests/Makefile.in b/dlls/quartz/tests/Makefile.in index 55528ab..ae5fbac 100644 --- a/dlls/quartz/tests/Makefile.in +++ b/dlls/quartz/tests/Makefile.in @@ -11,4 +11,6 @@ C_SRCS = \ referenceclock.c \ videorenderer.c
+IDL_H_SRCS = fil_data.idl + @MAKE_TEST_RULES@ diff --git a/dlls/quartz/tests/fil_data.idl b/dlls/quartz/tests/fil_data.idl new file mode 100644 index 0000000..93cdf1e --- /dev/null +++ b/dlls/quartz/tests/fil_data.idl @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2009 Vitaliy Margolen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +import "objidl.idl"; +import "strmif.idl"; +import "unknwn.idl"; + + +/***************************************************************************** + * IAMFilterData interface + * + * Notes: + * - This interface is deprecated and IFilterMapper2 should be used instead. + * - There is no full replacement for IAMFilterData::ParseFilterData short of manually + * parsing out the REGFILTER2 struct from the binary blob. + */ +[ + object, + uuid(97f7c4d4-547b-4a5f-8332-536430ad2e4d), + pointer_default(unique) +] +interface IAMFilterData : IUnknown +{ + typedef [unique] IAMFilterData *LPIAMFILTERDATA; + + HRESULT ParseFilterData( + [in] BYTE * rgbFilterData, + [in] ULONG cb, + [out] BYTE ** prgbRegFilter2); + + HRESULT CreateFilterData( + [in] REGFILTER2 * prf2, + [out] BYTE ** prgbFilterData, + [out] ULONG * pcb); +} diff --git a/dlls/quartz/tests/filtermapper.c b/dlls/quartz/tests/filtermapper.c index cd3ea17..2209af4 100644 --- a/dlls/quartz/tests/filtermapper.c +++ b/dlls/quartz/tests/filtermapper.c @@ -24,6 +24,9 @@ #include "winbase.h" #include "initguid.h" #include "dshow.h" +#include "winternl.h" + +#include "fil_data.h"
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
@@ -467,6 +470,70 @@ static void test_register_filter_with_null_clsMinorType(void) if (pMapper) IFilterMapper2_Release(pMapper); }
+static void test_parse_filter_data(void) +{ + static const BYTE data_block[] = { + 0x02,0x00,0x00,0x00,0xff,0xff,0x5f,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x70,0x69,0x33, + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x30,0x74,0x79,0x33,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x31,0x70,0x69,0x33, + 0x08,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x30,0x74,0x79,0x33,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x76,0x69,0x64,0x73, + 0x00,0x00,0x10,0x00,0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + + BYTE *prgbRegFilter2 = NULL; + REGFILTER2 *pRegFilter = NULL; + IFilterMapper2 *pMapper = NULL; + SAFEARRAYBOUND saBound; + SAFEARRAY *psa = NULL; + LPBYTE pbSAData = NULL; + HRESULT hr; + + IAMFilterData *pData = NULL; + + hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, + &IID_IFilterMapper2, (LPVOID*)&pMapper); + ok((hr == S_OK || broken(hr != S_OK)), "CoCreateInstance failed with %x\n", hr); + if (FAILED(hr)) goto out; + + hr = IFilterMapper2_QueryInterface(pMapper, &IID_IAMFilterData, (LPVOID*)&pData); + ok((hr == S_OK || broken(hr != S_OK)), "Unable to find IID_IAMFilterData interface\n"); + if (FAILED(hr)) goto out; + + saBound.lLbound = 0; + saBound.cElements = sizeof(data_block); + psa = SafeArrayCreate(VT_UI1, 1, &saBound); + ok(psa != NULL, "Unable to crate safe array\n"); + if (!psa) goto out; + hr = SafeArrayAccessData(psa, (LPVOID *)&pbSAData); + ok(hr == S_OK, "Unable to access array data\n"); + if (FAILED(hr)) goto out; + memcpy(pbSAData, data_block, sizeof(data_block)); + + hr = IAMFilterData_ParseFilterData(pData, pbSAData, sizeof(data_block), &prgbRegFilter2); + /* We cannot do anything here. prgbRegFilter2 is very unstable */ + /* Pre Vista, this is a stack pointer so anything that changes the stack invalidats it */ + /* Post Vista, it is a static pointer in the data section of the module */ + pRegFilter =((REGFILTER2**)prgbRegFilter2)[0]; + ok (hr==S_OK,"Failed to Parse filter Data\n"); + + ok(IsBadReadPtr(prgbRegFilter2,sizeof(REGFILTER2**))==0,"Bad read pointer returned\n"); + ok(IsBadReadPtr(pRegFilter,sizeof(REGFILTER2*))==0,"Bad read pointer for FilterData\n"); + ok(pRegFilter->dwMerit == 0x5fffff,"Incorrect merit returned\n"); + +out: + if (pRegFilter) + CoTaskMemFree(pRegFilter); + if (psa) + { + SafeArrayUnaccessData(psa); + SafeArrayDestroy(psa); + } + if (pData) + IAMFilterData_Release(pData); + if (pMapper) + IFilterMapper2_Release(pMapper); +}
START_TEST(filtermapper) { @@ -476,6 +543,7 @@ START_TEST(filtermapper) test_legacy_filter_registration(); test_ifiltermapper_from_filtergraph(); test_register_filter_with_null_clsMinorType(); + test_parse_filter_data();
CoUninitialize(); }