2003-07-01 06:29:48 +02:00
|
|
|
/*
|
2010-12-03 09:38:08 +01:00
|
|
|
* IFilterMapper & IFilterMapper3 Implementations
|
2003-07-01 06:29:48 +02:00
|
|
|
*
|
|
|
|
* Copyright 2003 Robert Shearman
|
2004-03-02 00:32:04 +01:00
|
|
|
* Copyright 2004 Christian Costa
|
2003-07-01 06:29:48 +02:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-07-01 06:29:48 +02:00
|
|
|
*/
|
|
|
|
|
2003-07-02 02:36:18 +02:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2003-07-01 06:29:48 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
|
|
|
|
#include "quartz_private.h"
|
|
|
|
|
|
|
|
#include "ole2.h"
|
2003-09-03 02:16:28 +02:00
|
|
|
#include "olectl.h"
|
2003-07-01 06:29:48 +02:00
|
|
|
#include "strmif.h"
|
|
|
|
#include "uuids.h"
|
2011-09-06 00:40:28 +02:00
|
|
|
#include "initguid.h"
|
2018-06-26 16:05:33 +02:00
|
|
|
#include "wine/fil_data.h"
|
2003-07-01 06:29:48 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
|
|
|
|
|
2020-05-20 07:10:39 +02:00
|
|
|
struct enum_reg_filters
|
|
|
|
{
|
|
|
|
IEnumRegFilters IEnumRegFilters_iface;
|
|
|
|
LONG refcount;
|
|
|
|
|
|
|
|
unsigned int index, count;
|
|
|
|
REGFILTER *filters;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct enum_reg_filters *impl_from_IEnumRegFilters(IEnumRegFilters *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct enum_reg_filters, IEnumRegFilters_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI enum_reg_filters_QueryInterface(IEnumRegFilters *iface, REFIID iid, void **out)
|
|
|
|
{
|
|
|
|
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
|
|
|
|
|
|
|
|
if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IEnumRegFilters))
|
|
|
|
{
|
|
|
|
IEnumRegFilters_AddRef(iface);
|
|
|
|
*out = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
|
|
|
|
*out = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI enum_reg_filters_AddRef(IEnumRegFilters *iface)
|
|
|
|
{
|
|
|
|
struct enum_reg_filters *enumerator = impl_from_IEnumRegFilters(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&enumerator->refcount);
|
|
|
|
TRACE("%p increasing refcount to %u.\n", enumerator, refcount);
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI enum_reg_filters_Release(IEnumRegFilters *iface)
|
|
|
|
{
|
|
|
|
struct enum_reg_filters *enumerator = impl_from_IEnumRegFilters(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&enumerator->refcount);
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
TRACE("%p decreasing refcount to %u.\n", enumerator, refcount);
|
|
|
|
if (!refcount)
|
|
|
|
{
|
|
|
|
for (i = 0; i < enumerator->count; ++i)
|
|
|
|
free(enumerator->filters[i].Name);
|
|
|
|
free(enumerator->filters);
|
|
|
|
free(enumerator);
|
|
|
|
}
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI enum_reg_filters_Next(IEnumRegFilters *iface, ULONG count,
|
|
|
|
REGFILTER **filters, ULONG *ret_count)
|
|
|
|
{
|
|
|
|
struct enum_reg_filters *enumerator = impl_from_IEnumRegFilters(iface);
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
TRACE("iface %p, count %u, filters %p, ret_count %p.\n", iface, count, filters, ret_count);
|
|
|
|
|
|
|
|
for (i = 0; i < count && enumerator->index + i < enumerator->count; ++i)
|
|
|
|
{
|
|
|
|
REGFILTER *filter = &enumerator->filters[enumerator->index + i];
|
|
|
|
|
|
|
|
if (!(filters[i] = CoTaskMemAlloc(sizeof(REGFILTER) + (wcslen(filter->Name) + 1) * sizeof(WCHAR))))
|
|
|
|
{
|
|
|
|
while (i--)
|
|
|
|
CoTaskMemFree(filters[i]);
|
|
|
|
memset(filters, 0, count * sizeof(*filters));
|
|
|
|
*ret_count = 0;
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
filters[i]->Clsid = filter->Clsid;
|
|
|
|
filters[i]->Name = (WCHAR *)(filters[i] + 1);
|
|
|
|
wcscpy(filters[i]->Name, filter->Name);
|
|
|
|
}
|
|
|
|
|
|
|
|
enumerator->index += i;
|
|
|
|
if (ret_count)
|
|
|
|
*ret_count = i;
|
|
|
|
return i ? S_OK : S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI enum_reg_filters_Skip(IEnumRegFilters *iface, ULONG count)
|
|
|
|
{
|
|
|
|
TRACE("iface %p, count %u, unimplemented.\n", iface, count);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI enum_reg_filters_Reset(IEnumRegFilters *iface)
|
|
|
|
{
|
|
|
|
struct enum_reg_filters *enumerator = impl_from_IEnumRegFilters(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
enumerator->index = 0;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI enum_reg_filters_Clone(IEnumRegFilters *iface, IEnumRegFilters **out)
|
|
|
|
{
|
|
|
|
TRACE("iface %p, out %p, unimplemented.\n", iface, out);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IEnumRegFiltersVtbl enum_reg_filters_vtbl =
|
|
|
|
{
|
|
|
|
enum_reg_filters_QueryInterface,
|
|
|
|
enum_reg_filters_AddRef,
|
|
|
|
enum_reg_filters_Release,
|
|
|
|
enum_reg_filters_Next,
|
|
|
|
enum_reg_filters_Skip,
|
|
|
|
enum_reg_filters_Reset,
|
|
|
|
enum_reg_filters_Clone,
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT enum_reg_filters_create(REGFILTER *filters, unsigned int count, IEnumRegFilters **out)
|
|
|
|
{
|
|
|
|
struct enum_reg_filters *object;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
*out = NULL;
|
|
|
|
|
|
|
|
if (!(object = calloc(1, sizeof(*object))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (!(object->filters = malloc(count * sizeof(*object->filters))))
|
|
|
|
{
|
|
|
|
free(object);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
object->filters[i].Clsid = filters[i].Clsid;
|
|
|
|
if (!(object->filters[i].Name = wcsdup(filters[i].Name)))
|
|
|
|
{
|
|
|
|
while (i--)
|
|
|
|
free(object->filters[i].Name);
|
|
|
|
free(object->filters);
|
|
|
|
free(object);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
object->IEnumRegFilters_iface.lpVtbl = &enum_reg_filters_vtbl;
|
|
|
|
object->refcount = 1;
|
|
|
|
object->count = count;
|
|
|
|
|
|
|
|
TRACE("Created enumerator %p.\n", object);
|
|
|
|
*out = &object->IEnumRegFilters_iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2020-05-20 07:10:40 +02:00
|
|
|
struct enum_moniker
|
|
|
|
{
|
|
|
|
IEnumMoniker IEnumMoniker_iface;
|
|
|
|
LONG refcount;
|
|
|
|
|
|
|
|
unsigned int index, count;
|
|
|
|
IMoniker **filters;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct enum_moniker *impl_from_IEnumMoniker(IEnumMoniker *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct enum_moniker, IEnumMoniker_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI enum_moniker_QueryInterface(IEnumMoniker *iface, REFIID iid, void **out)
|
|
|
|
{
|
|
|
|
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
|
|
|
|
|
|
|
|
if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IEnumMoniker))
|
|
|
|
{
|
|
|
|
IEnumMoniker_AddRef(iface);
|
|
|
|
*out = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
|
|
|
|
*out = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI enum_moniker_AddRef(IEnumMoniker *iface)
|
|
|
|
{
|
|
|
|
struct enum_moniker *enumerator = impl_from_IEnumMoniker(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&enumerator->refcount);
|
|
|
|
TRACE("%p increasing refcount to %u.\n", enumerator, refcount);
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI enum_moniker_Release(IEnumMoniker *iface)
|
|
|
|
{
|
|
|
|
struct enum_moniker *enumerator = impl_from_IEnumMoniker(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&enumerator->refcount);
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
TRACE("%p decreasing refcount to %u.\n", enumerator, refcount);
|
|
|
|
if (!refcount)
|
|
|
|
{
|
|
|
|
for (i = 0; i < enumerator->count; ++i)
|
|
|
|
IMoniker_Release(enumerator->filters[i]);
|
|
|
|
free(enumerator->filters);
|
|
|
|
free(enumerator);
|
|
|
|
}
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI enum_moniker_Next(IEnumMoniker *iface, ULONG count,
|
|
|
|
IMoniker **filters, ULONG *ret_count)
|
|
|
|
{
|
|
|
|
struct enum_moniker *enumerator = impl_from_IEnumMoniker(iface);
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
TRACE("iface %p, count %u, filters %p, ret_count %p.\n", iface, count, filters, ret_count);
|
|
|
|
|
|
|
|
for (i = 0; i < count && enumerator->index + i < enumerator->count; ++i)
|
|
|
|
IMoniker_AddRef(filters[i] = enumerator->filters[enumerator->index + i]);
|
|
|
|
|
|
|
|
enumerator->index += i;
|
|
|
|
if (ret_count)
|
|
|
|
*ret_count = i;
|
|
|
|
return i ? S_OK : S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI enum_moniker_Skip(IEnumMoniker *iface, ULONG count)
|
|
|
|
{
|
|
|
|
struct enum_moniker *enumerator = impl_from_IEnumMoniker(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, count %u.\n", iface, count);
|
|
|
|
|
|
|
|
enumerator->index += count;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI enum_moniker_Reset(IEnumMoniker *iface)
|
|
|
|
{
|
|
|
|
struct enum_moniker *enumerator = impl_from_IEnumMoniker(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
enumerator->index = 0;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI enum_moniker_Clone(IEnumMoniker *iface, IEnumMoniker **out)
|
|
|
|
{
|
|
|
|
TRACE("iface %p, out %p, unimplemented.\n", iface, out);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IEnumMonikerVtbl enum_moniker_vtbl =
|
|
|
|
{
|
|
|
|
enum_moniker_QueryInterface,
|
|
|
|
enum_moniker_AddRef,
|
|
|
|
enum_moniker_Release,
|
|
|
|
enum_moniker_Next,
|
|
|
|
enum_moniker_Skip,
|
|
|
|
enum_moniker_Reset,
|
|
|
|
enum_moniker_Clone,
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT enum_moniker_create(IMoniker **filters, unsigned int count, IEnumMoniker **out)
|
|
|
|
{
|
|
|
|
struct enum_moniker *object;
|
|
|
|
|
|
|
|
*out = NULL;
|
|
|
|
|
|
|
|
if (!(object = calloc(1, sizeof(*object))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (!(object->filters = malloc(count * sizeof(*object->filters))))
|
|
|
|
{
|
|
|
|
free(object);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
memcpy(object->filters, filters, count * sizeof(*filters));
|
|
|
|
|
|
|
|
object->IEnumMoniker_iface.lpVtbl = &enum_moniker_vtbl;
|
|
|
|
object->refcount = 1;
|
|
|
|
object->count = count;
|
|
|
|
|
|
|
|
TRACE("Created enumerator %p.\n", object);
|
|
|
|
*out = &object->IEnumMoniker_iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-12-03 09:38:08 +01:00
|
|
|
typedef struct FilterMapper3Impl
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2012-07-02 00:57:23 +02:00
|
|
|
IUnknown IUnknown_inner;
|
2011-06-21 10:38:43 +02:00
|
|
|
IFilterMapper3 IFilterMapper3_iface;
|
|
|
|
IFilterMapper IFilterMapper_iface;
|
|
|
|
IAMFilterData IAMFilterData_iface;
|
2012-07-02 00:57:23 +02:00
|
|
|
IUnknown *outer_unk;
|
|
|
|
LONG ref;
|
2010-12-03 09:38:08 +01:00
|
|
|
} FilterMapper3Impl;
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2011-06-21 10:38:43 +02:00
|
|
|
static inline FilterMapper3Impl *impl_from_IFilterMapper3( IFilterMapper3 *iface )
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, FilterMapper3Impl, IFilterMapper3_iface);
|
|
|
|
}
|
|
|
|
|
2010-12-03 09:38:08 +01:00
|
|
|
static inline FilterMapper3Impl *impl_from_IFilterMapper( IFilterMapper *iface )
|
2005-07-27 17:14:18 +02:00
|
|
|
{
|
2011-06-21 10:38:43 +02:00
|
|
|
return CONTAINING_RECORD(iface, FilterMapper3Impl, IFilterMapper_iface);
|
2005-07-27 17:14:18 +02:00
|
|
|
}
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2010-12-03 09:38:08 +01:00
|
|
|
static inline FilterMapper3Impl *impl_from_IAMFilterData( IAMFilterData *iface )
|
2007-04-10 17:15:09 +02:00
|
|
|
{
|
2011-06-21 10:38:43 +02:00
|
|
|
return CONTAINING_RECORD(iface, FilterMapper3Impl, IAMFilterData_iface);
|
2007-04-10 17:15:09 +02:00
|
|
|
}
|
|
|
|
|
2012-07-02 00:57:23 +02:00
|
|
|
static inline FilterMapper3Impl *impl_from_IUnknown( IUnknown *iface )
|
2008-07-17 19:24:15 +02:00
|
|
|
{
|
2012-07-02 00:57:23 +02:00
|
|
|
return CONTAINING_RECORD(iface, FilterMapper3Impl, IUnknown_inner);
|
2008-07-17 19:24:15 +02:00
|
|
|
}
|
|
|
|
|
2003-07-01 06:29:48 +02:00
|
|
|
/* registry format for REGFILTER2 */
|
|
|
|
struct REG_RF
|
|
|
|
{
|
|
|
|
DWORD dwVersion;
|
|
|
|
DWORD dwMerit;
|
|
|
|
DWORD dwPins;
|
|
|
|
DWORD dwUnused;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct REG_RFP
|
|
|
|
{
|
|
|
|
BYTE signature[4]; /* e.g. "0pi3" */
|
|
|
|
DWORD dwFlags;
|
|
|
|
DWORD dwInstances;
|
|
|
|
DWORD dwMediaTypes;
|
|
|
|
DWORD dwMediums;
|
|
|
|
DWORD bCategory; /* is there a category clsid? */
|
|
|
|
/* optional: dwOffsetCategoryClsid */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct REG_TYPE
|
|
|
|
{
|
|
|
|
BYTE signature[4]; /* e.g. "0ty3" */
|
|
|
|
DWORD dwUnused;
|
|
|
|
DWORD dwOffsetMajor;
|
|
|
|
DWORD dwOffsetMinor;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MONIKER_MERIT
|
|
|
|
{
|
|
|
|
IMoniker * pMoniker;
|
|
|
|
DWORD dwMerit;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Vector
|
|
|
|
{
|
|
|
|
LPBYTE pData;
|
|
|
|
int capacity; /* in bytes */
|
|
|
|
int current; /* pointer to next free byte */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* returns the position it was added at */
|
2018-08-15 08:38:53 +02:00
|
|
|
static int add_data(struct Vector *v, const void *pData, int size)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
|
|
|
int index = v->current;
|
|
|
|
if (v->current + size > v->capacity)
|
|
|
|
{
|
2018-08-14 17:25:10 +02:00
|
|
|
int new_capacity = (v->capacity + size) * 2;
|
|
|
|
BYTE *new_data = CoTaskMemRealloc(v->pData, new_capacity);
|
|
|
|
if (!new_data) return -1;
|
|
|
|
v->capacity = new_capacity;
|
|
|
|
v->pData = new_data;
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
memcpy(v->pData + v->current, pData, size);
|
|
|
|
v->current += size;
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
2018-08-15 08:38:53 +02:00
|
|
|
static int find_data(const struct Vector *v, const void *pData, int size)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
|
|
|
int index;
|
|
|
|
for (index = 0; index < v->current; index++)
|
|
|
|
if (!memcmp(v->pData + index, pData, size))
|
|
|
|
return index;
|
|
|
|
/* not found */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void delete_vector(struct Vector * v)
|
|
|
|
{
|
2006-10-07 03:05:08 +02:00
|
|
|
CoTaskMemFree(v->pData);
|
2003-07-01 06:29:48 +02:00
|
|
|
v->current = 0;
|
|
|
|
v->capacity = 0;
|
|
|
|
}
|
|
|
|
|
2008-07-17 19:24:15 +02:00
|
|
|
/*** IUnknown (inner) methods ***/
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2012-07-02 00:57:23 +02:00
|
|
|
static HRESULT WINAPI Inner_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2012-07-02 00:57:23 +02:00
|
|
|
FilterMapper3Impl *This = impl_from_IUnknown(iface);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2012-07-02 00:57:23 +02:00
|
|
|
TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv);
|
2008-07-17 19:24:15 +02:00
|
|
|
|
2003-07-01 06:29:48 +02:00
|
|
|
*ppv = NULL;
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown))
|
2012-07-02 00:57:23 +02:00
|
|
|
*ppv = &This->IUnknown_inner;
|
|
|
|
else if (IsEqualIID(riid, &IID_IFilterMapper2) || IsEqualIID(riid, &IID_IFilterMapper3))
|
|
|
|
*ppv = &This->IFilterMapper3_iface;
|
2003-07-01 06:29:48 +02:00
|
|
|
else if (IsEqualIID(riid, &IID_IFilterMapper))
|
2011-06-21 10:38:43 +02:00
|
|
|
*ppv = &This->IFilterMapper_iface;
|
2007-04-10 17:15:09 +02:00
|
|
|
else if (IsEqualIID(riid, &IID_IAMFilterData))
|
2011-06-21 10:38:43 +02:00
|
|
|
*ppv = &This->IAMFilterData_iface;
|
2003-07-01 06:29:48 +02:00
|
|
|
|
|
|
|
if (*ppv != NULL)
|
|
|
|
{
|
|
|
|
IUnknown_AddRef((IUnknown *)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("No interface for %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2012-07-02 00:57:23 +02:00
|
|
|
static ULONG WINAPI Inner_AddRef(IUnknown *iface)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2012-07-02 00:57:23 +02:00
|
|
|
FilterMapper3Impl *This = impl_from_IUnknown(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2012-07-02 00:57:23 +02:00
|
|
|
TRACE("(%p)->(): new ref = %d\n", This, ref);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2012-07-02 00:57:23 +02:00
|
|
|
return ref;
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
2012-07-02 00:57:23 +02:00
|
|
|
static ULONG WINAPI Inner_Release(IUnknown *iface)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2012-07-02 00:57:23 +02:00
|
|
|
FilterMapper3Impl *This = impl_from_IUnknown(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2012-07-02 00:57:23 +02:00
|
|
|
TRACE("(%p)->(): new ref = %d\n", This, ref);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2012-07-02 00:57:23 +02:00
|
|
|
if (ref == 0)
|
2020-03-13 03:34:12 +01:00
|
|
|
{
|
2003-07-01 06:29:48 +02:00
|
|
|
CoTaskMemFree(This);
|
2012-07-02 00:57:23 +02:00
|
|
|
|
2020-03-13 03:34:12 +01:00
|
|
|
InterlockedDecrement(&object_locks);
|
|
|
|
}
|
|
|
|
|
2012-07-02 00:57:23 +02:00
|
|
|
return ref;
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
2008-07-17 19:24:15 +02:00
|
|
|
static const IUnknownVtbl IInner_VTable =
|
|
|
|
{
|
|
|
|
Inner_QueryInterface,
|
|
|
|
Inner_AddRef,
|
|
|
|
Inner_Release
|
|
|
|
};
|
|
|
|
|
2010-12-03 09:38:08 +01:00
|
|
|
static HRESULT WINAPI FilterMapper3_QueryInterface(IFilterMapper3 * iface, REFIID riid, LPVOID *ppv)
|
2008-07-17 19:24:15 +02:00
|
|
|
{
|
2011-06-21 10:38:43 +02:00
|
|
|
FilterMapper3Impl *This = impl_from_IFilterMapper3(iface);
|
2008-07-17 19:24:15 +02:00
|
|
|
|
2012-07-02 00:57:23 +02:00
|
|
|
return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
|
2008-07-17 19:24:15 +02:00
|
|
|
}
|
|
|
|
|
2010-12-03 09:38:08 +01:00
|
|
|
static ULONG WINAPI FilterMapper3_AddRef(IFilterMapper3 * iface)
|
2008-07-17 19:24:15 +02:00
|
|
|
{
|
2011-06-21 10:38:43 +02:00
|
|
|
FilterMapper3Impl *This = impl_from_IFilterMapper3(iface);
|
2008-07-17 19:24:15 +02:00
|
|
|
|
2012-07-02 00:57:23 +02:00
|
|
|
return IUnknown_AddRef(This->outer_unk);
|
2008-07-17 19:24:15 +02:00
|
|
|
}
|
|
|
|
|
2010-12-03 09:38:08 +01:00
|
|
|
static ULONG WINAPI FilterMapper3_Release(IFilterMapper3 * iface)
|
2008-07-17 19:24:15 +02:00
|
|
|
{
|
2011-06-21 10:38:43 +02:00
|
|
|
FilterMapper3Impl *This = impl_from_IFilterMapper3(iface);
|
2008-07-17 19:24:15 +02:00
|
|
|
|
2012-07-02 00:57:23 +02:00
|
|
|
return IUnknown_Release(This->outer_unk);
|
2008-07-17 19:24:15 +02:00
|
|
|
}
|
|
|
|
|
2010-12-03 09:38:08 +01:00
|
|
|
/*** IFilterMapper3 methods ***/
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:57 +01:00
|
|
|
static HRESULT WINAPI FilterMapper3_CreateCategory(IFilterMapper3 *iface,
|
|
|
|
REFCLSID category, DWORD merit, const WCHAR *description)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2020-01-22 07:08:57 +01:00
|
|
|
WCHAR guidstr[39], keypath[93];
|
|
|
|
HKEY key;
|
|
|
|
LONG ret;
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:57 +01:00
|
|
|
TRACE("iface %p, category %s, merit %#x, description %s.\n", iface,
|
|
|
|
debugstr_guid(category), merit, debugstr_w(description));
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:57 +01:00
|
|
|
StringFromGUID2(category, guidstr, ARRAY_SIZE(guidstr));
|
|
|
|
wcscpy(keypath, L"CLSID\\{da4e3da0-d07d-11d0-bd50-00a0c911ce86}\\Instance\\");
|
|
|
|
wcscat(keypath, guidstr);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:57 +01:00
|
|
|
if ((ret = RegCreateKeyExW(HKEY_CLASSES_ROOT, keypath, 0, NULL, 0, KEY_WRITE, NULL, &key, NULL)))
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:57 +01:00
|
|
|
if ((ret = RegSetValueExW(key, L"FriendlyName", 0, REG_SZ,
|
|
|
|
(const BYTE *)description, (wcslen(description) + 1) * sizeof(WCHAR))))
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2020-01-22 07:08:57 +01:00
|
|
|
RegCloseKey(key);
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
2020-01-22 07:08:57 +01:00
|
|
|
if ((ret = RegSetValueExW(key, L"CLSID", 0, REG_SZ, (const BYTE *)guidstr, sizeof(guidstr))))
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2020-01-22 07:08:57 +01:00
|
|
|
RegCloseKey(key);
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
2020-01-22 07:08:57 +01:00
|
|
|
if ((ret = RegSetValueExW(key, L"Merit", 0, REG_DWORD, (const BYTE *)&merit, sizeof(DWORD))))
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2020-01-22 07:08:57 +01:00
|
|
|
RegCloseKey(key);
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
2020-01-22 07:08:57 +01:00
|
|
|
RegCloseKey(key);
|
|
|
|
return S_OK;
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
2020-01-22 07:08:58 +01:00
|
|
|
static HRESULT WINAPI FilterMapper3_UnregisterFilter(IFilterMapper3 *iface,
|
|
|
|
const CLSID *category, const WCHAR *instance, REFCLSID clsid)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2020-01-22 07:08:58 +01:00
|
|
|
WCHAR keypath[93];
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:58 +01:00
|
|
|
TRACE("iface %p, category %s, instance %s, clsid %s.\n",
|
|
|
|
iface, debugstr_guid(category), debugstr_w(instance), debugstr_guid(clsid));
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:58 +01:00
|
|
|
if (!category)
|
|
|
|
category = &CLSID_LegacyAmFilterCategory;
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:58 +01:00
|
|
|
wcscpy(keypath, L"CLSID\\");
|
|
|
|
StringFromGUID2(category, keypath + wcslen(keypath), ARRAY_SIZE(keypath) - wcslen(keypath));
|
|
|
|
wcscat(keypath, L"\\Instance\\");
|
|
|
|
if (instance)
|
|
|
|
wcscat(keypath, instance);
|
|
|
|
else
|
|
|
|
StringFromGUID2(clsid, keypath + wcslen(keypath), ARRAY_SIZE(keypath) - wcslen(keypath));
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:58 +01:00
|
|
|
return HRESULT_FROM_WIN32(RegDeleteKeyW(HKEY_CLASSES_ROOT, keypath));
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
2007-04-10 17:15:09 +02:00
|
|
|
static HRESULT FM2_WriteFilterData(const REGFILTER2 * prf2, BYTE **ppData, ULONG *pcbData)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
|
|
|
int size = sizeof(struct REG_RF);
|
2004-09-22 04:46:38 +02:00
|
|
|
unsigned int i;
|
2003-07-01 06:29:48 +02:00
|
|
|
struct Vector mainStore = {NULL, 0, 0};
|
|
|
|
struct Vector clsidStore = {NULL, 0, 0};
|
|
|
|
struct REG_RF rrf;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
rrf.dwVersion = prf2->dwVersion;
|
|
|
|
rrf.dwMerit = prf2->dwMerit;
|
2012-05-12 16:14:07 +02:00
|
|
|
rrf.dwPins = prf2->u.s2.cPins2;
|
2003-07-01 06:29:48 +02:00
|
|
|
rrf.dwUnused = 0;
|
|
|
|
|
2018-08-15 08:38:53 +02:00
|
|
|
add_data(&mainStore, &rrf, sizeof(rrf));
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2012-05-12 16:14:07 +02:00
|
|
|
for (i = 0; i < prf2->u.s2.cPins2; i++)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
|
|
|
size += sizeof(struct REG_RFP);
|
2012-05-12 16:14:07 +02:00
|
|
|
if (prf2->u.s2.rgPins2[i].clsPinCategory)
|
2003-07-01 06:29:48 +02:00
|
|
|
size += sizeof(DWORD);
|
2012-05-12 16:14:07 +02:00
|
|
|
size += prf2->u.s2.rgPins2[i].nMediaTypes * sizeof(struct REG_TYPE);
|
|
|
|
size += prf2->u.s2.rgPins2[i].nMediums * sizeof(DWORD);
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
2012-05-12 16:14:07 +02:00
|
|
|
for (i = 0; i < prf2->u.s2.cPins2; i++)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
|
|
|
struct REG_RFP rrfp;
|
2012-05-12 16:14:07 +02:00
|
|
|
REGFILTERPINS2 rgPin2 = prf2->u.s2.rgPins2[i];
|
2004-09-22 04:46:38 +02:00
|
|
|
unsigned int j;
|
2003-07-01 06:29:48 +02:00
|
|
|
|
|
|
|
rrfp.signature[0] = '0';
|
|
|
|
rrfp.signature[1] = 'p';
|
|
|
|
rrfp.signature[2] = 'i';
|
|
|
|
rrfp.signature[3] = '3';
|
|
|
|
rrfp.signature[0] += i;
|
|
|
|
rrfp.dwFlags = rgPin2.dwFlags;
|
|
|
|
rrfp.dwInstances = rgPin2.cInstances;
|
|
|
|
rrfp.dwMediaTypes = rgPin2.nMediaTypes;
|
|
|
|
rrfp.dwMediums = rgPin2.nMediums;
|
|
|
|
rrfp.bCategory = rgPin2.clsPinCategory ? 1 : 0;
|
|
|
|
|
2018-08-15 08:38:53 +02:00
|
|
|
add_data(&mainStore, &rrfp, sizeof(rrfp));
|
2003-07-01 06:29:48 +02:00
|
|
|
if (rrfp.bCategory)
|
|
|
|
{
|
2018-08-15 08:38:53 +02:00
|
|
|
DWORD index = find_data(&clsidStore, rgPin2.clsPinCategory, sizeof(CLSID));
|
2003-07-01 06:29:48 +02:00
|
|
|
if (index == -1)
|
2018-08-15 08:38:53 +02:00
|
|
|
index = add_data(&clsidStore, rgPin2.clsPinCategory, sizeof(CLSID));
|
2003-07-01 06:29:48 +02:00
|
|
|
index += size;
|
|
|
|
|
2018-08-15 08:38:53 +02:00
|
|
|
add_data(&mainStore, &index, sizeof(index));
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < rgPin2.nMediaTypes; j++)
|
|
|
|
{
|
|
|
|
struct REG_TYPE rt;
|
2008-12-06 18:58:11 +01:00
|
|
|
const CLSID * clsMinorType = rgPin2.lpMediaType[j].clsMinorType ? rgPin2.lpMediaType[j].clsMinorType : &MEDIASUBTYPE_NULL;
|
2003-07-01 06:29:48 +02:00
|
|
|
rt.signature[0] = '0';
|
|
|
|
rt.signature[1] = 't';
|
|
|
|
rt.signature[2] = 'y';
|
|
|
|
rt.signature[3] = '3';
|
|
|
|
rt.signature[0] += j;
|
|
|
|
rt.dwUnused = 0;
|
2018-08-15 08:38:53 +02:00
|
|
|
rt.dwOffsetMajor = find_data(&clsidStore, rgPin2.lpMediaType[j].clsMajorType, sizeof(CLSID));
|
2003-07-01 06:29:48 +02:00
|
|
|
if (rt.dwOffsetMajor == -1)
|
2018-08-15 08:38:53 +02:00
|
|
|
rt.dwOffsetMajor = add_data(&clsidStore, rgPin2.lpMediaType[j].clsMajorType, sizeof(CLSID));
|
2003-07-01 06:29:48 +02:00
|
|
|
rt.dwOffsetMajor += size;
|
2018-08-15 08:38:53 +02:00
|
|
|
rt.dwOffsetMinor = find_data(&clsidStore, clsMinorType, sizeof(CLSID));
|
2003-07-01 06:29:48 +02:00
|
|
|
if (rt.dwOffsetMinor == -1)
|
2018-08-15 08:38:53 +02:00
|
|
|
rt.dwOffsetMinor = add_data(&clsidStore, clsMinorType, sizeof(CLSID));
|
2003-07-01 06:29:48 +02:00
|
|
|
rt.dwOffsetMinor += size;
|
|
|
|
|
2018-08-15 08:38:53 +02:00
|
|
|
add_data(&mainStore, &rt, sizeof(rt));
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < rgPin2.nMediums; j++)
|
|
|
|
{
|
2018-08-15 08:38:53 +02:00
|
|
|
DWORD index = find_data(&clsidStore, rgPin2.lpMedium + j, sizeof(REGPINMEDIUM));
|
2003-07-01 06:29:48 +02:00
|
|
|
if (index == -1)
|
2018-08-15 08:38:53 +02:00
|
|
|
index = add_data(&clsidStore, rgPin2.lpMedium + j, sizeof(REGPINMEDIUM));
|
2003-07-01 06:29:48 +02:00
|
|
|
index += size;
|
|
|
|
|
2018-08-15 08:38:53 +02:00
|
|
|
add_data(&mainStore, &index, sizeof(index));
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-10 17:15:09 +02:00
|
|
|
if (SUCCEEDED(hr))
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2007-04-10 17:15:09 +02:00
|
|
|
*pcbData = mainStore.current + clsidStore.current;
|
|
|
|
*ppData = CoTaskMemAlloc(*pcbData);
|
|
|
|
if (!*ppData)
|
|
|
|
hr = E_OUTOFMEMORY;
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2007-04-10 17:15:09 +02:00
|
|
|
memcpy(*ppData, mainStore.pData, mainStore.current);
|
|
|
|
memcpy((*ppData) + mainStore.current, clsidStore.pData, clsidStore.current);
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
delete_vector(&mainStore);
|
|
|
|
delete_vector(&clsidStore);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2007-04-10 17:15:09 +02:00
|
|
|
static HRESULT FM2_ReadFilterData(BYTE *pData, REGFILTER2 * prf2)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2007-04-10 17:15:09 +02:00
|
|
|
HRESULT hr = S_OK;
|
2003-07-01 06:29:48 +02:00
|
|
|
struct REG_RF * prrf;
|
|
|
|
LPBYTE pCurrent;
|
|
|
|
DWORD i;
|
|
|
|
REGFILTERPINS2 * rgPins2;
|
|
|
|
|
2007-04-10 17:15:09 +02:00
|
|
|
prrf = (struct REG_RF *)pData;
|
|
|
|
pCurrent = pData;
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2007-04-10 17:15:09 +02:00
|
|
|
if (prrf->dwVersion != 2)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2007-04-10 17:15:09 +02:00
|
|
|
FIXME("Filter registry version %d not supported\n", prrf->dwVersion);
|
|
|
|
ZeroMemory(prf2, sizeof(*prf2));
|
|
|
|
hr = E_FAIL;
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2006-10-12 20:57:23 +02:00
|
|
|
TRACE("version = %d, merit = %x, #pins = %d, unused = %x\n",
|
2003-07-01 06:29:48 +02:00
|
|
|
prrf->dwVersion, prrf->dwMerit, prrf->dwPins, prrf->dwUnused);
|
|
|
|
|
|
|
|
prf2->dwVersion = prrf->dwVersion;
|
|
|
|
prf2->dwMerit = prrf->dwMerit;
|
2012-05-12 16:14:07 +02:00
|
|
|
prf2->u.s2.cPins2 = prrf->dwPins;
|
2003-07-01 06:29:48 +02:00
|
|
|
rgPins2 = CoTaskMemAlloc(prrf->dwPins * sizeof(*rgPins2));
|
2012-05-12 16:14:07 +02:00
|
|
|
prf2->u.s2.rgPins2 = rgPins2;
|
2003-07-01 06:29:48 +02:00
|
|
|
pCurrent += sizeof(struct REG_RF);
|
|
|
|
|
|
|
|
for (i = 0; i < prrf->dwPins; i++)
|
|
|
|
{
|
|
|
|
struct REG_RFP * prrfp = (struct REG_RFP *)pCurrent;
|
|
|
|
REGPINTYPES * lpMediaType;
|
|
|
|
REGPINMEDIUM * lpMedium;
|
|
|
|
UINT j;
|
|
|
|
|
|
|
|
/* FIXME: check signature */
|
|
|
|
|
2005-09-07 13:31:17 +02:00
|
|
|
TRACE("\tsignature = %s\n", debugstr_an((const char*)prrfp->signature, 4));
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2006-10-12 20:57:23 +02:00
|
|
|
TRACE("\tpin[%d]: flags = %x, instances = %d, media types = %d, mediums = %d\n",
|
2003-07-01 06:29:48 +02:00
|
|
|
i, prrfp->dwFlags, prrfp->dwInstances, prrfp->dwMediaTypes, prrfp->dwMediums);
|
|
|
|
|
|
|
|
rgPins2[i].dwFlags = prrfp->dwFlags;
|
|
|
|
rgPins2[i].cInstances = prrfp->dwInstances;
|
|
|
|
rgPins2[i].nMediaTypes = prrfp->dwMediaTypes;
|
|
|
|
rgPins2[i].nMediums = prrfp->dwMediums;
|
|
|
|
pCurrent += sizeof(struct REG_RFP);
|
|
|
|
if (prrfp->bCategory)
|
|
|
|
{
|
|
|
|
CLSID * clsCat = CoTaskMemAlloc(sizeof(CLSID));
|
|
|
|
memcpy(clsCat, pData + *(DWORD*)(pCurrent), sizeof(CLSID));
|
|
|
|
pCurrent += sizeof(DWORD);
|
|
|
|
rgPins2[i].clsPinCategory = clsCat;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rgPins2[i].clsPinCategory = NULL;
|
|
|
|
|
|
|
|
if (rgPins2[i].nMediaTypes > 0)
|
|
|
|
lpMediaType = CoTaskMemAlloc(rgPins2[i].nMediaTypes * sizeof(*lpMediaType));
|
|
|
|
else
|
|
|
|
lpMediaType = NULL;
|
|
|
|
|
|
|
|
rgPins2[i].lpMediaType = lpMediaType;
|
|
|
|
|
|
|
|
for (j = 0; j < rgPins2[i].nMediaTypes; j++)
|
|
|
|
{
|
|
|
|
struct REG_TYPE * prt = (struct REG_TYPE *)pCurrent;
|
|
|
|
CLSID * clsMajor = CoTaskMemAlloc(sizeof(CLSID));
|
|
|
|
CLSID * clsMinor = CoTaskMemAlloc(sizeof(CLSID));
|
|
|
|
|
|
|
|
/* FIXME: check signature */
|
2005-09-07 13:31:17 +02:00
|
|
|
TRACE("\t\tsignature = %s\n", debugstr_an((const char*)prt->signature, 4));
|
2003-07-01 06:29:48 +02:00
|
|
|
|
|
|
|
memcpy(clsMajor, pData + prt->dwOffsetMajor, sizeof(CLSID));
|
|
|
|
memcpy(clsMinor, pData + prt->dwOffsetMinor, sizeof(CLSID));
|
|
|
|
|
|
|
|
lpMediaType[j].clsMajorType = clsMajor;
|
|
|
|
lpMediaType[j].clsMinorType = clsMinor;
|
|
|
|
|
|
|
|
pCurrent += sizeof(*prt);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rgPins2[i].nMediums > 0)
|
|
|
|
lpMedium = CoTaskMemAlloc(rgPins2[i].nMediums * sizeof(*lpMedium));
|
|
|
|
else
|
|
|
|
lpMedium = NULL;
|
|
|
|
|
|
|
|
rgPins2[i].lpMedium = lpMedium;
|
|
|
|
|
|
|
|
for (j = 0; j < rgPins2[i].nMediums; j++)
|
|
|
|
{
|
|
|
|
DWORD dwOffset = *(DWORD *)pCurrent;
|
|
|
|
|
|
|
|
memcpy(lpMedium + j, pData + dwOffset, sizeof(REGPINMEDIUM));
|
|
|
|
|
|
|
|
pCurrent += sizeof(dwOffset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void FM2_DeleteRegFilter(REGFILTER2 * prf2)
|
|
|
|
{
|
|
|
|
UINT i;
|
2012-05-12 16:14:07 +02:00
|
|
|
for (i = 0; i < prf2->u.s2.cPins2; i++)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
|
|
|
UINT j;
|
2016-07-08 10:10:14 +02:00
|
|
|
CoTaskMemFree((void*)prf2->u.s2.rgPins2[i].clsPinCategory);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2012-05-12 16:14:07 +02:00
|
|
|
for (j = 0; j < prf2->u.s2.rgPins2[i].nMediaTypes; j++)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2012-05-12 16:14:07 +02:00
|
|
|
CoTaskMemFree((LPVOID)prf2->u.s2.rgPins2[i].lpMediaType[j].clsMajorType);
|
|
|
|
CoTaskMemFree((LPVOID)prf2->u.s2.rgPins2[i].lpMediaType[j].clsMinorType);
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
2012-05-12 16:14:07 +02:00
|
|
|
CoTaskMemFree((LPVOID)prf2->u.s2.rgPins2[i].lpMediaType);
|
|
|
|
CoTaskMemFree((LPVOID)prf2->u.s2.rgPins2[i].lpMedium);
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
2012-05-12 16:14:07 +02:00
|
|
|
CoTaskMemFree((LPVOID)prf2->u.s2.rgPins2);
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
2020-01-22 07:08:59 +01:00
|
|
|
static HRESULT WINAPI FilterMapper3_RegisterFilter(IFilterMapper3 *iface,
|
|
|
|
REFCLSID clsid, const WCHAR *name, IMoniker **ret_moniker,
|
|
|
|
const CLSID *category, const WCHAR *instance, const REGFILTER2 *prf2)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2020-01-22 07:08:59 +01:00
|
|
|
WCHAR *display_name, clsid_string[39];
|
|
|
|
IParseDisplayName *parser;
|
|
|
|
IPropertyBag *prop_bag;
|
|
|
|
ULONG filter_data_len;
|
|
|
|
IMoniker *moniker;
|
|
|
|
BYTE *filter_data;
|
|
|
|
VARIANT var;
|
|
|
|
ULONG eaten;
|
2003-12-30 22:52:45 +01:00
|
|
|
HRESULT hr;
|
2020-01-22 07:08:59 +01:00
|
|
|
size_t len;
|
2004-09-20 23:44:01 +02:00
|
|
|
REGFILTER2 regfilter2;
|
|
|
|
REGFILTERPINS2* pregfp2 = NULL;
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:59 +01:00
|
|
|
TRACE("iface %p, clsid %s, name %s, ret_moniker %p, category %s, instance %s, prf2 %p.\n",
|
|
|
|
iface, debugstr_guid(clsid), debugstr_w(name), ret_moniker,
|
|
|
|
debugstr_guid(category), debugstr_w(instance), prf2);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2004-09-20 23:44:01 +02:00
|
|
|
if (prf2->dwVersion == 2)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2004-09-20 23:44:01 +02:00
|
|
|
regfilter2 = *prf2;
|
|
|
|
}
|
|
|
|
else if (prf2->dwVersion == 1)
|
|
|
|
{
|
|
|
|
ULONG i;
|
|
|
|
DWORD flags;
|
|
|
|
/* REGFILTER2 structure is converted from version 1 to 2. Tested on Win2k. */
|
|
|
|
regfilter2.dwVersion = 2;
|
|
|
|
regfilter2.dwMerit = prf2->dwMerit;
|
2012-05-12 16:14:07 +02:00
|
|
|
regfilter2.u.s2.cPins2 = prf2->u.s1.cPins;
|
|
|
|
pregfp2 = CoTaskMemAlloc(prf2->u.s1.cPins * sizeof(REGFILTERPINS2));
|
|
|
|
regfilter2.u.s2.rgPins2 = pregfp2;
|
|
|
|
for (i = 0; i < prf2->u.s1.cPins; i++)
|
2004-09-20 23:44:01 +02:00
|
|
|
{
|
|
|
|
flags = 0;
|
2012-05-12 16:14:07 +02:00
|
|
|
if (prf2->u.s1.rgPins[i].bRendered)
|
2004-09-20 23:44:01 +02:00
|
|
|
flags |= REG_PINFLAG_B_RENDERER;
|
2012-05-12 16:14:07 +02:00
|
|
|
if (prf2->u.s1.rgPins[i].bOutput)
|
2004-09-20 23:44:01 +02:00
|
|
|
flags |= REG_PINFLAG_B_OUTPUT;
|
2012-05-12 16:14:07 +02:00
|
|
|
if (prf2->u.s1.rgPins[i].bZero)
|
2004-09-20 23:44:01 +02:00
|
|
|
flags |= REG_PINFLAG_B_ZERO;
|
2012-05-12 16:14:07 +02:00
|
|
|
if (prf2->u.s1.rgPins[i].bMany)
|
2004-09-20 23:44:01 +02:00
|
|
|
flags |= REG_PINFLAG_B_MANY;
|
|
|
|
pregfp2[i].dwFlags = flags;
|
|
|
|
pregfp2[i].cInstances = 1;
|
2012-05-12 16:14:07 +02:00
|
|
|
pregfp2[i].nMediaTypes = prf2->u.s1.rgPins[i].nMediaTypes;
|
|
|
|
pregfp2[i].lpMediaType = prf2->u.s1.rgPins[i].lpMediaType;
|
2004-09-20 23:44:01 +02:00
|
|
|
pregfp2[i].nMediums = 0;
|
|
|
|
pregfp2[i].lpMedium = NULL;
|
|
|
|
pregfp2[i].clsPinCategory = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("dwVersion other that 1 or 2 not supported at the moment\n");
|
2003-07-01 06:29:48 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2020-01-22 07:08:59 +01:00
|
|
|
if (ret_moniker)
|
|
|
|
*ret_moniker = NULL;
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:59 +01:00
|
|
|
if (!category)
|
|
|
|
category = &CLSID_LegacyAmFilterCategory;
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:59 +01:00
|
|
|
StringFromGUID2(clsid, clsid_string, ARRAY_SIZE(clsid_string));
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:59 +01:00
|
|
|
len = 50 + (instance ? wcslen(instance) : 38) + 1;
|
|
|
|
if (!(display_name = malloc(len * sizeof(WCHAR))))
|
2003-07-01 06:29:48 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2020-01-22 07:08:59 +01:00
|
|
|
wcscpy(display_name, L"@device:sw:");
|
|
|
|
StringFromGUID2(category, display_name + wcslen(display_name), len - wcslen(display_name));
|
|
|
|
wcscat(display_name, L"\\");
|
|
|
|
wcscat(display_name, instance ? instance : clsid_string);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:59 +01:00
|
|
|
if (FAILED(hr = CoCreateInstance(&CLSID_CDeviceMoniker, NULL, CLSCTX_INPROC,
|
|
|
|
&IID_IParseDisplayName, (void **)&parser)))
|
|
|
|
return hr;
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:59 +01:00
|
|
|
if (FAILED(hr = IParseDisplayName_ParseDisplayName(parser, NULL, display_name, &eaten, &moniker)))
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2020-01-22 07:08:59 +01:00
|
|
|
ERR("Failed to parse display name, hr %#x.\n", hr);
|
|
|
|
IParseDisplayName_Release(parser);
|
|
|
|
return hr;
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
2020-01-22 07:08:59 +01:00
|
|
|
IParseDisplayName_Release(parser);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:59 +01:00
|
|
|
if (FAILED(hr = IMoniker_BindToStorage(moniker, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag)))
|
|
|
|
{
|
|
|
|
ERR("Failed to get property bag, hr %#x.\n", hr);
|
|
|
|
IMoniker_Release(moniker);
|
|
|
|
return hr;
|
|
|
|
}
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:59 +01:00
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
V_BSTR(&var) = SysAllocString(name);
|
|
|
|
if (FAILED(hr = IPropertyBag_Write(prop_bag, L"FriendlyName", &var)))
|
|
|
|
ERR("Failed to write friendly name, hr %#x.\n", hr);
|
|
|
|
VariantClear(&var);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:59 +01:00
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
V_BSTR(&var) = SysAllocString(clsid_string);
|
|
|
|
if (FAILED(hr = IPropertyBag_Write(prop_bag, L"CLSID", &var)))
|
|
|
|
ERR("Failed to write class ID, hr %#x.\n", hr);
|
|
|
|
VariantClear(&var);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:59 +01:00
|
|
|
if (SUCCEEDED(FM2_WriteFilterData(®filter2, &filter_data, &filter_data_len)))
|
2007-04-10 17:15:09 +02:00
|
|
|
{
|
2020-01-22 07:08:59 +01:00
|
|
|
V_VT(&var) = VT_ARRAY | VT_UI1;
|
|
|
|
if ((V_ARRAY(&var) = SafeArrayCreateVector(VT_UI1, 0, filter_data_len)))
|
2007-04-10 17:15:09 +02:00
|
|
|
{
|
2020-01-22 07:08:59 +01:00
|
|
|
memcpy(V_ARRAY(&var)->pvData, filter_data, filter_data_len);
|
|
|
|
if (FAILED(hr = IPropertyBag_Write(prop_bag, L"FilterData", &var)))
|
|
|
|
ERR("Failed to write filter data, hr %#x.\n", hr);
|
|
|
|
VariantClear(&var);
|
2007-04-10 17:15:09 +02:00
|
|
|
}
|
2020-01-22 07:08:59 +01:00
|
|
|
|
|
|
|
CoTaskMemFree(filter_data);
|
2007-04-10 17:15:09 +02:00
|
|
|
}
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:59 +01:00
|
|
|
IPropertyBag_Release(prop_bag);
|
|
|
|
free(display_name);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2020-01-22 07:08:59 +01:00
|
|
|
if (ret_moniker)
|
|
|
|
*ret_moniker = moniker;
|
|
|
|
else
|
|
|
|
IMoniker_Release(moniker);
|
2004-09-20 23:44:01 +02:00
|
|
|
|
2006-10-07 03:05:08 +02:00
|
|
|
CoTaskMemFree(pregfp2);
|
2003-12-30 22:52:45 +01:00
|
|
|
|
2020-01-22 07:08:59 +01:00
|
|
|
return S_OK;
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* internal helper function */
|
|
|
|
static BOOL MatchTypes(
|
|
|
|
BOOL bExactMatch,
|
|
|
|
DWORD nPinTypes,
|
|
|
|
const REGPINTYPES * pPinTypes,
|
|
|
|
DWORD nMatchTypes,
|
|
|
|
const GUID * pMatchTypes)
|
|
|
|
{
|
|
|
|
BOOL bMatch = FALSE;
|
|
|
|
DWORD j;
|
|
|
|
|
|
|
|
if ((nMatchTypes == 0) && (nPinTypes > 0))
|
|
|
|
bMatch = TRUE;
|
|
|
|
|
|
|
|
for (j = 0; j < nPinTypes; j++)
|
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
for (i = 0; i < nMatchTypes*2; i+=2)
|
|
|
|
{
|
|
|
|
if (((!bExactMatch && IsEqualGUID(pPinTypes[j].clsMajorType, &GUID_NULL)) || IsEqualGUID(&pMatchTypes[i], &GUID_NULL) || IsEqualGUID(pPinTypes[j].clsMajorType, &pMatchTypes[i])) &&
|
|
|
|
((!bExactMatch && IsEqualGUID(pPinTypes[j].clsMinorType, &GUID_NULL)) || IsEqualGUID(&pMatchTypes[i+1], &GUID_NULL) || IsEqualGUID(pPinTypes[j].clsMinorType, &pMatchTypes[i+1])))
|
|
|
|
{
|
|
|
|
bMatch = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bMatch;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* internal helper function for qsort of MONIKER_MERIT array */
|
2019-08-05 17:25:58 +02:00
|
|
|
static int __cdecl mm_compare(const void * left, const void * right)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2009-01-29 11:14:55 +01:00
|
|
|
const struct MONIKER_MERIT * mmLeft = left;
|
|
|
|
const struct MONIKER_MERIT * mmRight = right;
|
2003-07-01 06:29:48 +02:00
|
|
|
|
|
|
|
if (mmLeft->dwMerit == mmRight->dwMerit)
|
|
|
|
return 0;
|
|
|
|
if (mmLeft->dwMerit > mmRight->dwMerit)
|
|
|
|
return -1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NOTES:
|
|
|
|
* Exact match means whether or not to treat GUID_NULL's in filter data as wild cards
|
|
|
|
* (GUID_NULL's in input to function automatically treated as wild cards)
|
|
|
|
* Input/Output needed means match only on criteria if TRUE (with zero input types
|
|
|
|
* meaning match any input/output pin as long as one exists), otherwise match any
|
|
|
|
* filter that meets the rest of the requirements.
|
|
|
|
*/
|
2010-12-03 09:38:08 +01:00
|
|
|
static HRESULT WINAPI FilterMapper3_EnumMatchingFilters(
|
|
|
|
IFilterMapper3 * iface,
|
2003-07-01 06:29:48 +02:00
|
|
|
IEnumMoniker **ppEnum,
|
|
|
|
DWORD dwFlags,
|
|
|
|
BOOL bExactMatch,
|
|
|
|
DWORD dwMerit,
|
|
|
|
BOOL bInputNeeded,
|
|
|
|
DWORD cInputTypes,
|
|
|
|
const GUID *pInputTypes,
|
|
|
|
const REGPINMEDIUM *pMedIn,
|
|
|
|
const CLSID *pPinCategoryIn,
|
|
|
|
BOOL bRender,
|
|
|
|
BOOL bOutputNeeded,
|
|
|
|
DWORD cOutputTypes,
|
|
|
|
const GUID *pOutputTypes,
|
|
|
|
const REGPINMEDIUM *pMedOut,
|
|
|
|
const CLSID *pPinCategoryOut)
|
|
|
|
{
|
|
|
|
ICreateDevEnum * pCreateDevEnum;
|
|
|
|
IMoniker * pMonikerCat;
|
|
|
|
IEnumMoniker * pEnumCat;
|
|
|
|
HRESULT hr;
|
|
|
|
struct Vector monikers = {NULL, 0, 0};
|
|
|
|
|
2006-10-12 20:57:23 +02:00
|
|
|
TRACE("(%p, %x, %s, %x, %s, %d, %p, %p, %p, %s, %s, %p, %p, %p)\n",
|
2003-07-01 06:29:48 +02:00
|
|
|
ppEnum,
|
|
|
|
dwFlags,
|
|
|
|
bExactMatch ? "true" : "false",
|
|
|
|
dwMerit,
|
|
|
|
bInputNeeded ? "true" : "false",
|
|
|
|
cInputTypes,
|
|
|
|
pInputTypes,
|
|
|
|
pMedIn,
|
|
|
|
pPinCategoryIn,
|
|
|
|
bRender ? "true" : "false",
|
|
|
|
bOutputNeeded ? "true" : "false",
|
|
|
|
pOutputTypes,
|
|
|
|
pMedOut,
|
|
|
|
pPinCategoryOut);
|
|
|
|
|
|
|
|
if (dwFlags != 0)
|
|
|
|
{
|
2006-10-12 20:57:23 +02:00
|
|
|
FIXME("dwFlags = %x not implemented\n", dwFlags);
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
*ppEnum = NULL;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC, &IID_ICreateDevEnum, (LPVOID*)&pCreateDevEnum);
|
2007-06-03 12:51:52 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2007-06-03 12:51:52 +02:00
|
|
|
hr = ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum, &CLSID_ActiveMovieCategories, &pEnumCat, 0);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ICreateDevEnum_Release(pCreateDevEnum);
|
|
|
|
return hr;
|
|
|
|
}
|
2003-07-01 06:29:48 +02:00
|
|
|
|
|
|
|
while (IEnumMoniker_Next(pEnumCat, 1, &pMonikerCat, NULL) == S_OK)
|
|
|
|
{
|
|
|
|
IPropertyBag * pPropBagCat = NULL;
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hrSub; /* this is so that one buggy filter
|
|
|
|
doesn't make the whole lot fail */
|
|
|
|
|
|
|
|
VariantInit(&var);
|
|
|
|
|
|
|
|
hrSub = IMoniker_BindToStorage(pMonikerCat, NULL, NULL, &IID_IPropertyBag, (LPVOID*)&pPropBagCat);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hrSub))
|
2020-01-22 23:30:53 +01:00
|
|
|
hrSub = IPropertyBag_Read(pPropBagCat, L"Merit", &var, NULL);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2014-09-02 18:22:48 +02:00
|
|
|
if (SUCCEEDED(hrSub) && (V_UI4(&var) >= dwMerit))
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
|
|
|
CLSID clsidCat;
|
|
|
|
IEnumMoniker * pEnum;
|
|
|
|
IMoniker * pMoniker;
|
|
|
|
|
|
|
|
VariantClear(&var);
|
|
|
|
|
|
|
|
if (TRACE_ON(quartz))
|
|
|
|
{
|
|
|
|
VARIANT temp;
|
|
|
|
V_VT(&temp) = VT_EMPTY;
|
2020-01-22 23:30:53 +01:00
|
|
|
IPropertyBag_Read(pPropBagCat, L"FriendlyName", &temp, NULL);
|
2014-09-02 18:22:48 +02:00
|
|
|
TRACE("Considering category %s\n", debugstr_w(V_BSTR(&temp)));
|
2003-07-01 06:29:48 +02:00
|
|
|
VariantClear(&temp);
|
|
|
|
}
|
|
|
|
|
2020-01-22 23:30:53 +01:00
|
|
|
hrSub = IPropertyBag_Read(pPropBagCat, L"CLSID", &var, NULL);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
|
|
|
if (SUCCEEDED(hrSub))
|
2014-09-02 18:22:48 +02:00
|
|
|
hrSub = CLSIDFromString(V_BSTR(&var), &clsidCat);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
|
|
|
if (SUCCEEDED(hrSub))
|
|
|
|
hrSub = ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum, &clsidCat, &pEnum, 0);
|
|
|
|
|
2004-03-02 00:32:04 +01:00
|
|
|
if (hrSub == S_OK)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
|
|
|
while (IEnumMoniker_Next(pEnum, 1, &pMoniker, NULL) == S_OK)
|
|
|
|
{
|
|
|
|
IPropertyBag * pPropBag = NULL;
|
2007-04-10 17:15:09 +02:00
|
|
|
VARIANT var;
|
|
|
|
BYTE *pData = NULL;
|
2003-07-01 06:29:48 +02:00
|
|
|
REGFILTER2 rf2;
|
|
|
|
DWORD i;
|
|
|
|
BOOL bInputMatch = !bInputNeeded;
|
|
|
|
BOOL bOutputMatch = !bOutputNeeded;
|
|
|
|
|
|
|
|
ZeroMemory(&rf2, sizeof(rf2));
|
2007-04-10 17:15:09 +02:00
|
|
|
VariantInit(&var);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
|
|
|
hrSub = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (LPVOID*)&pPropBag);
|
|
|
|
|
2005-01-09 19:24:41 +01:00
|
|
|
if (TRACE_ON(quartz))
|
|
|
|
{
|
|
|
|
VARIANT temp;
|
|
|
|
V_VT(&temp) = VT_EMPTY;
|
2020-01-22 23:30:53 +01:00
|
|
|
IPropertyBag_Read(pPropBag, L"FriendlyName", &temp, NULL);
|
2014-09-02 18:22:48 +02:00
|
|
|
TRACE("Considering filter %s\n", debugstr_w(V_BSTR(&temp)));
|
2005-01-09 19:24:41 +01:00
|
|
|
VariantClear(&temp);
|
|
|
|
}
|
|
|
|
|
2003-07-01 06:29:48 +02:00
|
|
|
if (SUCCEEDED(hrSub))
|
2007-04-10 17:15:09 +02:00
|
|
|
{
|
2020-01-22 23:30:53 +01:00
|
|
|
hrSub = IPropertyBag_Read(pPropBag, L"FilterData", &var, NULL);
|
2007-04-10 17:15:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hrSub))
|
2014-09-02 18:22:48 +02:00
|
|
|
hrSub = SafeArrayAccessData(V_ARRAY(&var), (LPVOID*)&pData);
|
2007-04-10 17:15:09 +02:00
|
|
|
|
|
|
|
if (SUCCEEDED(hrSub))
|
|
|
|
hrSub = FM2_ReadFilterData(pData, &rf2);
|
|
|
|
|
|
|
|
if (pData)
|
2014-09-02 18:22:48 +02:00
|
|
|
SafeArrayUnaccessData(V_ARRAY(&var));
|
2007-04-10 17:15:09 +02:00
|
|
|
|
|
|
|
VariantClear(&var);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
|
|
|
/* Logic used for bInputMatch expression:
|
|
|
|
* There exists some pin such that bInputNeeded implies (pin is an input and
|
|
|
|
* (bRender implies pin has render flag) and major/minor types members of
|
|
|
|
* pInputTypes )
|
|
|
|
* bOutputMatch is similar, but without the "bRender implies ..." part
|
|
|
|
* and substituting variables names containing input for output
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* determine whether filter meets requirements */
|
|
|
|
if (SUCCEEDED(hrSub) && (rf2.dwMerit >= dwMerit))
|
|
|
|
{
|
2012-05-12 16:14:07 +02:00
|
|
|
for (i = 0; (i < rf2.u.s2.cPins2) && (!bInputMatch || !bOutputMatch); i++)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2012-05-12 16:14:07 +02:00
|
|
|
const REGFILTERPINS2 * rfp2 = rf2.u.s2.rgPins2 + i;
|
2003-07-01 06:29:48 +02:00
|
|
|
|
|
|
|
bInputMatch = bInputMatch || (!(rfp2->dwFlags & REG_PINFLAG_B_OUTPUT) &&
|
2008-06-29 14:07:08 +02:00
|
|
|
(!bRender || (rfp2->dwFlags & REG_PINFLAG_B_RENDERER)) &&
|
2003-07-01 06:29:48 +02:00
|
|
|
MatchTypes(bExactMatch, rfp2->nMediaTypes, rfp2->lpMediaType, cInputTypes, pInputTypes));
|
|
|
|
bOutputMatch = bOutputMatch || ((rfp2->dwFlags & REG_PINFLAG_B_OUTPUT) &&
|
|
|
|
MatchTypes(bExactMatch, rfp2->nMediaTypes, rfp2->lpMediaType, cOutputTypes, pOutputTypes));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bInputMatch && bOutputMatch)
|
|
|
|
{
|
|
|
|
struct MONIKER_MERIT mm = {pMoniker, rf2.dwMerit};
|
|
|
|
IMoniker_AddRef(pMoniker);
|
2018-08-15 08:38:53 +02:00
|
|
|
add_data(&monikers, &mm, sizeof(mm));
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FM2_DeleteRegFilter(&rf2);
|
|
|
|
if (pPropBag)
|
|
|
|
IPropertyBag_Release(pPropBag);
|
|
|
|
IMoniker_Release(pMoniker);
|
|
|
|
}
|
|
|
|
IEnumMoniker_Release(pEnum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VariantClear(&var);
|
|
|
|
if (pPropBagCat)
|
|
|
|
IPropertyBag_Release(pPropBagCat);
|
|
|
|
IMoniker_Release(pMonikerCat);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
IMoniker ** ppMoniker;
|
2004-09-22 04:46:38 +02:00
|
|
|
unsigned int i;
|
2003-07-01 06:29:48 +02:00
|
|
|
ULONG nMonikerCount = monikers.current / sizeof(struct MONIKER_MERIT);
|
|
|
|
|
|
|
|
/* sort the monikers in descending merit order */
|
|
|
|
qsort(monikers.pData, nMonikerCount,
|
|
|
|
sizeof(struct MONIKER_MERIT),
|
|
|
|
mm_compare);
|
|
|
|
|
|
|
|
/* construct an IEnumMoniker interface */
|
|
|
|
ppMoniker = CoTaskMemAlloc(nMonikerCount * sizeof(IMoniker *));
|
|
|
|
for (i = 0; i < nMonikerCount; i++)
|
|
|
|
{
|
|
|
|
/* no need to AddRef here as already AddRef'd above */
|
|
|
|
ppMoniker[i] = ((struct MONIKER_MERIT *)monikers.pData)[i].pMoniker;
|
|
|
|
}
|
2020-05-20 07:10:40 +02:00
|
|
|
hr = enum_moniker_create(ppMoniker, nMonikerCount, ppEnum);
|
2003-07-01 06:29:48 +02:00
|
|
|
CoTaskMemFree(ppMoniker);
|
|
|
|
}
|
|
|
|
|
|
|
|
delete_vector(&monikers);
|
|
|
|
IEnumMoniker_Release(pEnumCat);
|
|
|
|
ICreateDevEnum_Release(pCreateDevEnum);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2010-12-03 09:38:08 +01:00
|
|
|
static HRESULT WINAPI FilterMapper3_GetICreateDevEnum(IFilterMapper3 *iface, ICreateDevEnum **ppEnum)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p)\n", iface, ppEnum);
|
|
|
|
if (!ppEnum)
|
|
|
|
return E_POINTER;
|
|
|
|
return CoCreateInstance(&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC, &IID_ICreateDevEnum, (void**)ppEnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IFilterMapper3Vtbl fm3vtbl =
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
|
|
|
|
2010-12-03 09:38:08 +01:00
|
|
|
FilterMapper3_QueryInterface,
|
|
|
|
FilterMapper3_AddRef,
|
|
|
|
FilterMapper3_Release,
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2010-12-03 09:38:08 +01:00
|
|
|
FilterMapper3_CreateCategory,
|
|
|
|
FilterMapper3_UnregisterFilter,
|
|
|
|
FilterMapper3_RegisterFilter,
|
|
|
|
FilterMapper3_EnumMatchingFilters,
|
|
|
|
FilterMapper3_GetICreateDevEnum
|
2003-07-01 06:29:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
|
|
|
|
static HRESULT WINAPI FilterMapper_QueryInterface(IFilterMapper * iface, REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
2010-12-03 09:38:08 +01:00
|
|
|
FilterMapper3Impl *This = impl_from_IFilterMapper(iface);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv);
|
|
|
|
|
2011-06-21 10:38:43 +02:00
|
|
|
return FilterMapper3_QueryInterface(&This->IFilterMapper3_iface, riid, ppv);
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI FilterMapper_AddRef(IFilterMapper * iface)
|
|
|
|
{
|
2010-12-03 09:38:08 +01:00
|
|
|
FilterMapper3Impl *This = impl_from_IFilterMapper(iface);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2012-07-02 00:57:23 +02:00
|
|
|
return IUnknown_AddRef(This->outer_unk);
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI FilterMapper_Release(IFilterMapper * iface)
|
|
|
|
{
|
2010-12-03 09:38:08 +01:00
|
|
|
FilterMapper3Impl *This = impl_from_IFilterMapper(iface);
|
2003-07-01 06:29:48 +02:00
|
|
|
|
2012-07-02 00:57:23 +02:00
|
|
|
return IUnknown_Release(This->outer_unk);
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** IFilterMapper methods ***/
|
|
|
|
|
|
|
|
static HRESULT WINAPI FilterMapper_EnumMatchingFilters(
|
|
|
|
IFilterMapper * iface,
|
|
|
|
IEnumRegFilters **ppEnum,
|
|
|
|
DWORD dwMerit,
|
|
|
|
BOOL bInputNeeded,
|
|
|
|
CLSID clsInMaj,
|
|
|
|
CLSID clsInSub,
|
|
|
|
BOOL bRender,
|
|
|
|
BOOL bOutputNeeded,
|
|
|
|
CLSID clsOutMaj,
|
|
|
|
CLSID clsOutSub)
|
|
|
|
{
|
2010-12-03 09:38:08 +01:00
|
|
|
FilterMapper3Impl *This = impl_from_IFilterMapper(iface);
|
2004-03-02 00:32:04 +01:00
|
|
|
GUID InputType[2];
|
|
|
|
GUID OutputType[2];
|
|
|
|
IEnumMoniker* ppEnumMoniker;
|
|
|
|
IMoniker* IMon;
|
|
|
|
ULONG nb;
|
|
|
|
ULONG idx = 0, nb_mon = 0;
|
|
|
|
REGFILTER* regfilters;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2016-10-25 07:26:30 +02:00
|
|
|
TRACE("(%p/%p)->(%p, %x, %s, %s, %s, %s, %s, %s, %s)\n",
|
2016-04-28 07:12:56 +02:00
|
|
|
This,
|
|
|
|
iface,
|
2004-03-02 00:32:04 +01:00
|
|
|
ppEnum,
|
|
|
|
dwMerit,
|
|
|
|
bInputNeeded ? "true" : "false",
|
|
|
|
debugstr_guid(&clsInMaj),
|
|
|
|
debugstr_guid(&clsInSub),
|
|
|
|
bRender ? "true" : "false",
|
|
|
|
bOutputNeeded ? "true" : "false",
|
|
|
|
debugstr_guid(&clsOutMaj),
|
|
|
|
debugstr_guid(&clsOutSub));
|
|
|
|
|
|
|
|
InputType[0] = clsInMaj;
|
|
|
|
InputType[1] = clsInSub;
|
|
|
|
OutputType[0] = clsOutMaj;
|
|
|
|
OutputType[1] = clsOutSub;
|
|
|
|
|
2008-07-01 23:59:33 +02:00
|
|
|
*ppEnum = NULL;
|
|
|
|
|
2011-06-21 10:38:43 +02:00
|
|
|
hr = IFilterMapper3_EnumMatchingFilters(&This->IFilterMapper3_iface, &ppEnumMoniker, 0, TRUE,
|
|
|
|
dwMerit, bInputNeeded, 1, InputType, NULL, &GUID_NULL, bRender, bOutputNeeded, 1,
|
|
|
|
OutputType, NULL, &GUID_NULL);
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2008-10-08 01:33:43 +02:00
|
|
|
if (FAILED(hr))
|
2004-03-02 00:32:04 +01:00
|
|
|
return hr;
|
|
|
|
|
|
|
|
while(IEnumMoniker_Next(ppEnumMoniker, 1, &IMon, &nb) == S_OK)
|
|
|
|
{
|
|
|
|
IMoniker_Release(IMon);
|
|
|
|
nb_mon++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!nb_mon)
|
|
|
|
{
|
|
|
|
IEnumMoniker_Release(ppEnumMoniker);
|
2020-05-20 07:10:39 +02:00
|
|
|
return enum_reg_filters_create(NULL, 0, ppEnum);
|
2004-03-02 00:32:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
regfilters = CoTaskMemAlloc(nb_mon * sizeof(REGFILTER));
|
|
|
|
if (!regfilters)
|
|
|
|
{
|
|
|
|
IEnumMoniker_Release(ppEnumMoniker);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2008-07-01 23:59:33 +02:00
|
|
|
ZeroMemory(regfilters, nb_mon * sizeof(REGFILTER)); /* will prevent bad free of Name in case of error. */
|
2004-03-02 00:32:04 +01:00
|
|
|
|
|
|
|
IEnumMoniker_Reset(ppEnumMoniker);
|
|
|
|
while(IEnumMoniker_Next(ppEnumMoniker, 1, &IMon, &nb) == S_OK)
|
|
|
|
{
|
|
|
|
IPropertyBag * pPropBagCat = NULL;
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hrSub;
|
|
|
|
GUID clsid;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
VariantInit(&var);
|
|
|
|
|
|
|
|
hrSub = IMoniker_BindToStorage(IMon, NULL, NULL, &IID_IPropertyBag, (LPVOID*)&pPropBagCat);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hrSub))
|
2020-01-22 23:30:53 +01:00
|
|
|
hrSub = IPropertyBag_Read(pPropBagCat, L"CLSID", &var, NULL);
|
2004-03-02 00:32:04 +01:00
|
|
|
|
|
|
|
if (SUCCEEDED(hrSub))
|
2014-09-02 18:22:48 +02:00
|
|
|
hrSub = CLSIDFromString(V_BSTR(&var), &clsid);
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2008-06-29 14:07:24 +02:00
|
|
|
VariantClear(&var);
|
|
|
|
|
2004-03-02 00:32:04 +01:00
|
|
|
if (SUCCEEDED(hrSub))
|
2020-01-22 23:30:53 +01:00
|
|
|
hrSub = IPropertyBag_Read(pPropBagCat, L"FriendlyName", &var, NULL);
|
2004-03-02 00:32:04 +01:00
|
|
|
|
|
|
|
if (SUCCEEDED(hrSub))
|
|
|
|
{
|
2020-01-22 23:30:53 +01:00
|
|
|
len = (wcslen(V_BSTR(&var)) + 1) * sizeof(WCHAR);
|
2004-03-02 00:32:04 +01:00
|
|
|
if (!(regfilters[idx].Name = CoTaskMemAlloc(len*2)))
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2008-07-01 23:59:33 +02:00
|
|
|
if (SUCCEEDED(hrSub) && regfilters[idx].Name)
|
2004-03-02 00:32:04 +01:00
|
|
|
{
|
2014-09-02 18:22:48 +02:00
|
|
|
memcpy(regfilters[idx].Name, V_BSTR(&var), len);
|
2004-03-02 00:32:04 +01:00
|
|
|
regfilters[idx].Clsid = clsid;
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pPropBagCat)
|
|
|
|
IPropertyBag_Release(pPropBagCat);
|
|
|
|
IMoniker_Release(IMon);
|
2008-06-29 14:07:24 +02:00
|
|
|
VariantClear(&var);
|
2004-03-02 00:32:04 +01:00
|
|
|
}
|
|
|
|
|
2008-07-01 23:59:33 +02:00
|
|
|
if (SUCCEEDED(hr))
|
2004-03-02 00:32:04 +01:00
|
|
|
{
|
2020-05-20 07:10:39 +02:00
|
|
|
hr = enum_reg_filters_create(regfilters, idx, ppEnum);
|
2004-03-02 00:32:04 +01:00
|
|
|
}
|
|
|
|
|
2008-07-01 23:59:33 +02:00
|
|
|
for (idx = 0; idx < nb_mon; idx++)
|
|
|
|
CoTaskMemFree(regfilters[idx].Name);
|
2004-03-02 00:32:04 +01:00
|
|
|
CoTaskMemFree(regfilters);
|
|
|
|
IEnumMoniker_Release(ppEnumMoniker);
|
|
|
|
|
|
|
|
return hr;
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-22 07:09:00 +01:00
|
|
|
static HRESULT WINAPI FilterMapper_RegisterFilter(IFilterMapper * iface,
|
|
|
|
CLSID clsid, const WCHAR *name, DWORD merit)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2020-01-22 07:09:00 +01:00
|
|
|
WCHAR keypath[46], guidstr[39];
|
|
|
|
HKEY key;
|
|
|
|
LONG ret;
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 07:09:00 +01:00
|
|
|
TRACE("iface %p, clsid %s, name %s, merit %#x.\n",
|
|
|
|
iface, debugstr_guid(&clsid), debugstr_w(name), merit);
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 07:09:00 +01:00
|
|
|
StringFromGUID2(&clsid, guidstr, ARRAY_SIZE(guidstr));
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 07:09:00 +01:00
|
|
|
wcscpy(keypath, L"Filter\\");
|
|
|
|
wcscat(keypath, guidstr);
|
|
|
|
if ((ret = RegCreateKeyExW(HKEY_CLASSES_ROOT, keypath, 0, NULL, 0, KEY_WRITE, NULL, &key, NULL)))
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 07:09:00 +01:00
|
|
|
if ((ret = RegSetValueExW(key, NULL, 0, REG_SZ, (const BYTE *)name, (wcslen(name) + 1) * sizeof(WCHAR))))
|
|
|
|
ERR("Failed to set filter name, error %u.\n", ret);
|
|
|
|
RegCloseKey(key);
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 07:09:00 +01:00
|
|
|
wcscpy(keypath, L"CLSID\\");
|
|
|
|
wcscat(keypath, guidstr);
|
|
|
|
if (!(ret = RegCreateKeyExW(HKEY_CLASSES_ROOT, keypath, 0, NULL, 0, KEY_WRITE, NULL, &key, NULL)))
|
2004-03-02 00:32:04 +01:00
|
|
|
{
|
2020-01-22 07:09:00 +01:00
|
|
|
if ((ret = RegSetValueExW(key, L"Merit", 0, REG_DWORD, (const BYTE *)&merit, sizeof(DWORD))))
|
|
|
|
ERR("Failed to set merit, error %u.\n", ret);
|
|
|
|
RegCloseKey(key);
|
2004-03-02 00:32:04 +01:00
|
|
|
}
|
2020-01-22 07:09:00 +01:00
|
|
|
else
|
|
|
|
ERR("Failed to create CLSID key, error %u.\n", ret);
|
2008-07-01 23:59:27 +02:00
|
|
|
|
2020-01-22 07:09:00 +01:00
|
|
|
return S_OK;
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI FilterMapper_RegisterFilterInstance(IFilterMapper * iface, CLSID clsid, LPCWSTR szName, CLSID *MRId)
|
|
|
|
{
|
2004-03-02 00:32:04 +01:00
|
|
|
TRACE("(%p)->(%s, %s, %p)\n", iface, debugstr_guid(&clsid), debugstr_w(szName), MRId);
|
|
|
|
|
|
|
|
/* Not implemented in Windows (tested on Win2k) */
|
|
|
|
|
2003-07-01 06:29:48 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2020-01-22 23:30:49 +01:00
|
|
|
static HRESULT WINAPI FilterMapper_RegisterPin(IFilterMapper *iface, CLSID clsid,
|
|
|
|
const WCHAR *name, BOOL rendered, BOOL output, BOOL zero, BOOL many,
|
|
|
|
CLSID external_filter, const WCHAR *external_pin)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2020-01-22 23:30:49 +01:00
|
|
|
WCHAR keypath[6 + 38 + 1], *pin_keypath;
|
|
|
|
HKEY key, pin_key, type_key;
|
|
|
|
LONG ret;
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:49 +01:00
|
|
|
TRACE("iface %p, clsid %s, name %s, rendered %d, output %d, zero %d, "
|
|
|
|
"many %d, external_filter %s, external_pin %s.\n",
|
|
|
|
iface, debugstr_guid(&clsid), debugstr_w(name), rendered, output,
|
|
|
|
zero, many, debugstr_guid(&external_filter), debugstr_w(external_pin));
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:49 +01:00
|
|
|
wcscpy(keypath, L"CLSID\\");
|
|
|
|
StringFromGUID2(&clsid, keypath + wcslen(keypath), ARRAY_SIZE(keypath) - wcslen(keypath));
|
|
|
|
if ((ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, keypath, 0, KEY_WRITE, &key)))
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:49 +01:00
|
|
|
if (!(pin_keypath = malloc((5 + wcslen(name) + 1) * sizeof(WCHAR))))
|
2004-03-02 00:32:04 +01:00
|
|
|
{
|
2020-01-22 23:30:49 +01:00
|
|
|
RegCloseKey(key);
|
|
|
|
return E_OUTOFMEMORY;
|
2004-03-02 00:32:04 +01:00
|
|
|
}
|
2020-01-22 23:30:49 +01:00
|
|
|
wcscpy(pin_keypath, L"Pins\\");
|
|
|
|
wcscat(pin_keypath, name);
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:49 +01:00
|
|
|
if ((ret = RegCreateKeyExW(key, pin_keypath, 0, NULL, 0, KEY_WRITE, NULL, &pin_key, NULL)))
|
2004-03-02 00:32:04 +01:00
|
|
|
{
|
2020-01-22 23:30:49 +01:00
|
|
|
ERR("Failed to open pin key, error %u.\n", ret);
|
|
|
|
free(pin_keypath);
|
|
|
|
RegCloseKey(key);
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
2004-03-02 00:32:04 +01:00
|
|
|
}
|
2020-01-22 23:30:49 +01:00
|
|
|
free(pin_keypath);
|
|
|
|
|
|
|
|
if ((ret = RegSetValueExW(pin_key, L"AllowedMany", 0, REG_DWORD, (const BYTE *)&many, sizeof(DWORD))))
|
|
|
|
ERR("Failed to set AllowedMany value, error %u.\n", ret);
|
|
|
|
if ((ret = RegSetValueExW(pin_key, L"AllowedZero", 0, REG_DWORD, (const BYTE *)&zero, sizeof(DWORD))))
|
|
|
|
ERR("Failed to set AllowedZero value, error %u.\n", ret);
|
|
|
|
if ((ret = RegSetValueExW(pin_key, L"Direction", 0, REG_DWORD, (const BYTE *)&output, sizeof(DWORD))))
|
|
|
|
ERR("Failed to set Direction value, error %u.\n", ret);
|
|
|
|
if ((ret = RegSetValueExW(pin_key, L"IsRendered", 0, REG_DWORD, (const BYTE *)&rendered, sizeof(DWORD))))
|
|
|
|
ERR("Failed to set IsRendered value, error %u.\n", ret);
|
|
|
|
|
|
|
|
if (!(ret = RegCreateKeyExW(pin_key, L"Types", 0, NULL, 0, 0, NULL, &type_key, NULL)))
|
|
|
|
RegCloseKey(type_key);
|
|
|
|
else
|
|
|
|
ERR("Failed to create Types subkey, error %u.\n", ret);
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:49 +01:00
|
|
|
RegCloseKey(pin_key);
|
|
|
|
RegCloseKey(key);
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:49 +01:00
|
|
|
return S_OK;
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-22 23:30:50 +01:00
|
|
|
static HRESULT WINAPI FilterMapper_RegisterPinType(IFilterMapper *iface,
|
|
|
|
CLSID clsid, const WCHAR *pin, CLSID majortype, CLSID subtype)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2020-01-22 23:30:50 +01:00
|
|
|
WCHAR *keypath, type_keypath[38 + 1 + 38 + 1];
|
|
|
|
HKEY key, type_key;
|
|
|
|
size_t len;
|
|
|
|
LONG ret;
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:50 +01:00
|
|
|
TRACE("iface %p, clsid %s, pin %s, majortype %s, subtype %s.\n", iface,
|
|
|
|
debugstr_guid(&clsid), debugstr_w(pin), debugstr_guid(&majortype), debugstr_guid(&subtype));
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:50 +01:00
|
|
|
len = 6 + 38 + 6 + wcslen(pin) + 6 + 1;
|
|
|
|
if (!(keypath = malloc(len * sizeof(WCHAR))))
|
|
|
|
return E_OUTOFMEMORY;
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:50 +01:00
|
|
|
wcscpy(keypath, L"CLSID\\");
|
|
|
|
StringFromGUID2(&clsid, keypath + wcslen(keypath), len - wcslen(keypath));
|
|
|
|
wcscat(keypath, L"\\Pins\\");
|
|
|
|
wcscat(keypath, pin);
|
|
|
|
wcscat(keypath, L"\\Types");
|
|
|
|
if ((ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, keypath, 0, KEY_CREATE_SUB_KEY, &key)))
|
2004-03-02 00:32:04 +01:00
|
|
|
{
|
2020-01-22 23:30:50 +01:00
|
|
|
free(keypath);
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
2004-03-02 00:32:04 +01:00
|
|
|
}
|
2020-01-22 23:30:50 +01:00
|
|
|
free(keypath);
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:50 +01:00
|
|
|
StringFromGUID2(&majortype, type_keypath, ARRAY_SIZE(type_keypath));
|
|
|
|
wcscat(type_keypath, L"\\");
|
|
|
|
StringFromGUID2(&subtype, type_keypath + wcslen(type_keypath), ARRAY_SIZE(type_keypath) - wcslen(type_keypath));
|
|
|
|
if (!(ret = RegCreateKeyExW(key, type_keypath, 0, NULL, 0, 0, NULL, &type_key, NULL)))
|
|
|
|
RegCloseKey(type_key);
|
|
|
|
else
|
|
|
|
ERR("Failed to create type key, error %u.\n", ret);
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:50 +01:00
|
|
|
RegCloseKey(key);
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
2020-01-22 23:30:51 +01:00
|
|
|
static HRESULT WINAPI FilterMapper_UnregisterFilter(IFilterMapper *iface, CLSID clsid)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2020-01-22 23:30:51 +01:00
|
|
|
WCHAR guidstr[39], keypath[6 + 38 + 1];
|
|
|
|
LONG ret;
|
|
|
|
HKEY key;
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:51 +01:00
|
|
|
TRACE("iface %p, clsid %s.\n", iface, debugstr_guid(&clsid));
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:51 +01:00
|
|
|
StringFromGUID2(&clsid, guidstr, ARRAY_SIZE(guidstr));
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:51 +01:00
|
|
|
if ((ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, L"Filter", 0, 0, &key)))
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
|
|
|
if ((ret = RegDeleteKeyW(key, guidstr)))
|
|
|
|
ERR("Failed to delete filter key, error %u.\n", ret);
|
|
|
|
RegCloseKey(key);
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:51 +01:00
|
|
|
wcscpy(keypath, L"CLSID\\");
|
|
|
|
wcscat(keypath, guidstr);
|
|
|
|
if (!(ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, keypath, 0, KEY_WRITE, &key)))
|
2004-03-02 00:32:04 +01:00
|
|
|
{
|
2020-01-22 23:30:51 +01:00
|
|
|
if ((ret = RegDeleteValueW(key, L"Merit")))
|
|
|
|
ERR("Failed to delete Merit value, error %u.\n", ret);
|
|
|
|
if ((ret = RegDeleteTreeW(key, L"Pins")))
|
|
|
|
ERR("Failed to delete Pins key, error %u.\n", ret);
|
|
|
|
RegCloseKey(key);
|
2004-03-02 00:32:04 +01:00
|
|
|
}
|
2020-01-22 23:30:51 +01:00
|
|
|
else
|
|
|
|
ERR("Failed to open CLSID key, error %u.\n", ret);
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:51 +01:00
|
|
|
return S_OK;
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI FilterMapper_UnregisterFilterInstance(IFilterMapper * iface, CLSID MRId)
|
|
|
|
{
|
2004-03-02 00:32:04 +01:00
|
|
|
TRACE("(%p)->(%s)\n", iface, debugstr_guid(&MRId));
|
|
|
|
|
|
|
|
/* Not implemented in Windows (tested on Win2k) */
|
|
|
|
|
2003-07-01 06:29:48 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2020-01-22 23:30:52 +01:00
|
|
|
static HRESULT WINAPI FilterMapper_UnregisterPin(IFilterMapper * iface, CLSID clsid, const WCHAR *name)
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
2020-01-22 23:30:52 +01:00
|
|
|
WCHAR keypath[6 + 38 + 5 + 1];
|
|
|
|
LONG ret;
|
|
|
|
HKEY key;
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:52 +01:00
|
|
|
TRACE("iface %p, clsid %s, name %s.\n", iface, debugstr_guid(&clsid), debugstr_w(name));
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:52 +01:00
|
|
|
if (!name)
|
2004-03-02 00:32:04 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2020-01-22 23:30:52 +01:00
|
|
|
wcscpy(keypath, L"CLSID\\");
|
|
|
|
StringFromGUID2(&clsid, keypath + wcslen(keypath), ARRAY_SIZE(keypath) - wcslen(keypath));
|
|
|
|
wcscat(keypath, L"\\Pins");
|
|
|
|
if ((ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, keypath, 0, 0, &key)))
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:52 +01:00
|
|
|
if ((ret = RegDeleteTreeW(key, name)))
|
|
|
|
ERR("Failed to delete subkey, error %u.\n", ret);
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:52 +01:00
|
|
|
RegCloseKey(key);
|
2004-03-02 00:32:04 +01:00
|
|
|
|
2020-01-22 23:30:52 +01:00
|
|
|
return S_OK;
|
2003-07-01 06:29:48 +02:00
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IFilterMapperVtbl fmvtbl =
|
2003-07-01 06:29:48 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
FilterMapper_QueryInterface,
|
|
|
|
FilterMapper_AddRef,
|
|
|
|
FilterMapper_Release,
|
|
|
|
|
|
|
|
FilterMapper_RegisterFilter,
|
|
|
|
FilterMapper_RegisterFilterInstance,
|
|
|
|
FilterMapper_RegisterPin,
|
|
|
|
FilterMapper_RegisterPinType,
|
|
|
|
FilterMapper_UnregisterFilter,
|
|
|
|
FilterMapper_UnregisterFilterInstance,
|
|
|
|
FilterMapper_UnregisterPin,
|
|
|
|
FilterMapper_EnumMatchingFilters
|
|
|
|
};
|
2007-04-10 17:15:09 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI AMFilterData_QueryInterface(IAMFilterData * iface, REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
2010-12-03 09:38:08 +01:00
|
|
|
FilterMapper3Impl *This = impl_from_IAMFilterData(iface);
|
2007-04-10 17:15:09 +02:00
|
|
|
|
2012-07-02 00:57:23 +02:00
|
|
|
return IUnknown_QueryInterface(This->outer_unk, riid, ppv);
|
2007-04-10 17:15:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AMFilterData_AddRef(IAMFilterData * iface)
|
|
|
|
{
|
2010-12-03 09:38:08 +01:00
|
|
|
FilterMapper3Impl *This = impl_from_IAMFilterData(iface);
|
2007-04-10 17:15:09 +02:00
|
|
|
|
2012-07-02 00:57:23 +02:00
|
|
|
return IUnknown_AddRef(This->outer_unk);
|
2007-04-10 17:15:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AMFilterData_Release(IAMFilterData * iface)
|
|
|
|
{
|
2010-12-03 09:38:08 +01:00
|
|
|
FilterMapper3Impl *This = impl_from_IAMFilterData(iface);
|
2007-04-10 17:15:09 +02:00
|
|
|
|
2012-07-02 00:57:23 +02:00
|
|
|
return IUnknown_Release(This->outer_unk);
|
2007-04-10 17:15:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** IAMFilterData methods ***/
|
|
|
|
static HRESULT WINAPI AMFilterData_ParseFilterData(IAMFilterData* iface,
|
|
|
|
BYTE *pData, ULONG cb,
|
|
|
|
BYTE **ppRegFilter2)
|
|
|
|
{
|
2010-12-03 09:38:08 +01:00
|
|
|
FilterMapper3Impl *This = impl_from_IAMFilterData(iface);
|
2007-04-10 17:15:09 +02:00
|
|
|
HRESULT hr = S_OK;
|
2012-02-06 18:02:43 +01:00
|
|
|
static REGFILTER2 *prf2;
|
2007-04-10 17:15:09 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p, %d, %p)\n", This, iface, pData, cb, ppRegFilter2);
|
|
|
|
|
|
|
|
prf2 = CoTaskMemAlloc(sizeof(*prf2));
|
|
|
|
if (!prf2)
|
|
|
|
return E_OUTOFMEMORY;
|
2012-02-06 18:02:43 +01:00
|
|
|
*ppRegFilter2 = (BYTE *)&prf2;
|
2007-04-10 17:15:09 +02:00
|
|
|
|
|
|
|
hr = FM2_ReadFilterData(pData, prf2);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
CoTaskMemFree(prf2);
|
|
|
|
*ppRegFilter2 = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AMFilterData_CreateFilterData(IAMFilterData* iface,
|
|
|
|
REGFILTER2 *prf2,
|
|
|
|
BYTE **pRegFilterData,
|
|
|
|
ULONG *pcb)
|
|
|
|
{
|
2010-12-03 09:38:08 +01:00
|
|
|
FilterMapper3Impl *This = impl_from_IAMFilterData(iface);
|
2007-04-10 17:15:09 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p, %p, %p)\n", This, iface, prf2, pRegFilterData, pcb);
|
|
|
|
|
|
|
|
return FM2_WriteFilterData(prf2, pRegFilterData, pcb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IAMFilterDataVtbl AMFilterDataVtbl = {
|
|
|
|
AMFilterData_QueryInterface,
|
|
|
|
AMFilterData_AddRef,
|
|
|
|
AMFilterData_Release,
|
|
|
|
AMFilterData_ParseFilterData,
|
|
|
|
AMFilterData_CreateFilterData
|
|
|
|
};
|
2012-07-02 00:58:29 +02:00
|
|
|
|
2020-03-12 03:10:10 +01:00
|
|
|
HRESULT filter_mapper_create(IUnknown *pUnkOuter, IUnknown **out)
|
2012-07-02 00:58:29 +02:00
|
|
|
{
|
|
|
|
FilterMapper3Impl * pFM2impl;
|
|
|
|
|
|
|
|
pFM2impl = CoTaskMemAlloc(sizeof(*pFM2impl));
|
|
|
|
if (!pFM2impl)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
pFM2impl->IUnknown_inner.lpVtbl = &IInner_VTable;
|
|
|
|
pFM2impl->IFilterMapper3_iface.lpVtbl = &fm3vtbl;
|
|
|
|
pFM2impl->IFilterMapper_iface.lpVtbl = &fmvtbl;
|
|
|
|
pFM2impl->IAMFilterData_iface.lpVtbl = &AMFilterDataVtbl;
|
|
|
|
pFM2impl->ref = 1;
|
|
|
|
|
|
|
|
if (pUnkOuter)
|
|
|
|
pFM2impl->outer_unk = pUnkOuter;
|
|
|
|
else
|
|
|
|
pFM2impl->outer_unk = &pFM2impl->IUnknown_inner;
|
|
|
|
|
2020-03-12 03:10:10 +01:00
|
|
|
TRACE("Created filter mapper %p.\n", pFM2impl);
|
|
|
|
*out = &pFM2impl->IUnknown_inner;
|
2012-07-02 00:58:29 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|