2003-07-01 06:30:30 +02:00
|
|
|
/*
|
|
|
|
* IEnumMoniker implementation for DEVENUM.dll
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Robert Shearman
|
|
|
|
*
|
|
|
|
* 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:30:30 +02:00
|
|
|
*
|
|
|
|
* NOTES ON THIS FILE:
|
|
|
|
* - Implements IEnumMoniker interface which enumerates through moniker
|
|
|
|
* objects created from HKEY_CLASSES/CLSID/{DEVICE_CLSID}/Instance
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "devenum_private.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(devenum);
|
|
|
|
|
2012-04-03 00:16:52 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
IEnumMoniker IEnumMoniker_iface;
|
2018-03-07 03:57:10 +01:00
|
|
|
CLSID class;
|
2012-04-03 00:16:52 +02:00
|
|
|
LONG ref;
|
2018-06-25 00:20:30 +02:00
|
|
|
IEnumDMO *dmo_enum;
|
2018-03-07 03:57:08 +01:00
|
|
|
HKEY sw_key;
|
|
|
|
DWORD sw_index;
|
|
|
|
HKEY cm_key;
|
|
|
|
DWORD cm_index;
|
2012-04-03 00:16:52 +02:00
|
|
|
} EnumMonikerImpl;
|
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
static inline struct moniker *impl_from_IPropertyBag(IPropertyBag *iface)
|
2010-12-04 22:13:13 +01:00
|
|
|
{
|
2020-04-14 07:16:04 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct moniker, IPropertyBag_iface);
|
2010-12-04 22:13:13 +01:00
|
|
|
}
|
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
static HRESULT WINAPI property_bag_QueryInterface(IPropertyBag *iface, REFIID iid, void **out)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-14 07:16:04 +02:00
|
|
|
struct moniker *moniker = impl_from_IPropertyBag(iface);
|
2008-12-07 11:38:12 +01:00
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
TRACE("moniker %p, iid %s, out %p.\n", moniker, debugstr_guid(iid), out);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
if (!out)
|
|
|
|
return E_POINTER;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IPropertyBag))
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-14 07:16:04 +02:00
|
|
|
*out = iface;
|
2012-04-03 00:19:59 +02:00
|
|
|
IPropertyBag_AddRef(iface);
|
2003-07-01 06:30:30 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
|
|
|
|
*out = NULL;
|
2003-07-01 06:30:30 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static ULONG WINAPI property_bag_AddRef(IPropertyBag *iface)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-14 07:16:04 +02:00
|
|
|
struct moniker *moniker = impl_from_IPropertyBag(iface);
|
|
|
|
return IMoniker_AddRef(&moniker->IMoniker_iface);
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static ULONG WINAPI property_bag_Release(IPropertyBag *iface)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-14 07:16:04 +02:00
|
|
|
struct moniker *moniker = impl_from_IPropertyBag(iface);
|
|
|
|
return IMoniker_Release(&moniker->IMoniker_iface);
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI property_bag_Read(IPropertyBag *iface,
|
2020-04-14 07:16:04 +02:00
|
|
|
const WCHAR *name, VARIANT *var, IErrorLog *errorlog)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-14 07:16:04 +02:00
|
|
|
struct moniker *moniker = impl_from_IPropertyBag(iface);
|
|
|
|
WCHAR dmo_name[80];
|
|
|
|
DWORD size, type;
|
|
|
|
HKEY parent, key;
|
|
|
|
WCHAR path[78];
|
|
|
|
void *data;
|
|
|
|
HRESULT hr;
|
|
|
|
LONG ret;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
TRACE("moniker %p, name %s, var %p, errorlog %p.\n", moniker, debugstr_w(name), var, errorlog);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
if (!name || !var)
|
2003-07-01 06:30:30 +02:00
|
|
|
return E_POINTER;
|
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
if (moniker->type == DEVICE_DMO)
|
2018-06-25 00:20:29 +02:00
|
|
|
{
|
2020-04-14 07:16:04 +02:00
|
|
|
if (!wcscmp(name, L"FriendlyName"))
|
2018-06-25 00:20:29 +02:00
|
|
|
{
|
2020-04-14 07:16:04 +02:00
|
|
|
if (SUCCEEDED(hr = DMOGetName(&moniker->clsid, dmo_name)))
|
2018-06-25 00:20:29 +02:00
|
|
|
{
|
2020-04-14 07:16:04 +02:00
|
|
|
V_VT(var) = VT_BSTR;
|
|
|
|
V_BSTR(var) = SysAllocString(dmo_name);
|
2018-06-25 00:20:29 +02:00
|
|
|
}
|
2020-04-14 07:16:04 +02:00
|
|
|
return hr;
|
2018-06-25 00:20:29 +02:00
|
|
|
}
|
|
|
|
return HRESULT_FROM_WIN32(ERROR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
if (moniker->type == DEVICE_FILTER)
|
2018-03-07 03:57:11 +01:00
|
|
|
{
|
2020-04-14 07:16:04 +02:00
|
|
|
wcscpy(path, L"CLSID\\");
|
|
|
|
if (moniker->has_class)
|
|
|
|
{
|
|
|
|
StringFromGUID2(&moniker->class, path + wcslen(path), CHARS_IN_GUID);
|
|
|
|
wcscat(path, L"\\Instance");
|
|
|
|
}
|
|
|
|
if ((ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, path, 0, 0, &parent)))
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
2018-03-07 03:57:11 +01:00
|
|
|
}
|
2020-04-14 07:16:04 +02:00
|
|
|
else if (moniker->type == DEVICE_CODEC)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-14 07:16:04 +02:00
|
|
|
wcscpy(path, L"Software\\Microsoft\\ActiveMovie\\devenum\\");
|
|
|
|
if (moniker->has_class)
|
|
|
|
StringFromGUID2(&moniker->class, path + wcslen(path), CHARS_IN_GUID);
|
|
|
|
if ((ret = RegOpenKeyExW(HKEY_CURRENT_USER, path, 0, 0, &parent)))
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
2003-08-05 21:19:21 +02:00
|
|
|
}
|
2020-04-14 07:16:04 +02:00
|
|
|
ret = RegOpenKeyExW(parent, moniker->name, 0, KEY_READ, &key);
|
|
|
|
RegCloseKey(parent);
|
|
|
|
if (ret)
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
2003-08-05 21:19:21 +02:00
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
if ((ret = RegQueryValueExW(key, name, NULL, NULL, NULL, &size)))
|
2003-08-05 21:19:21 +02:00
|
|
|
{
|
2020-04-14 07:16:04 +02:00
|
|
|
RegCloseKey(key);
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
|
|
|
}
|
2003-08-05 21:19:21 +02:00
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
data = malloc(size);
|
|
|
|
if ((ret = RegQueryValueExW(key, name, NULL, &type, data, &size)))
|
|
|
|
{
|
|
|
|
RegCloseKey(key);
|
|
|
|
free(data);
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
|
|
|
}
|
|
|
|
RegCloseKey(key);
|
2003-08-05 21:19:21 +02:00
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case REG_SZ:
|
|
|
|
if (V_VT(var) == VT_EMPTY)
|
|
|
|
V_VT(var) = VT_BSTR;
|
|
|
|
if (V_VT(var) != VT_BSTR)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-14 07:16:04 +02:00
|
|
|
WARN("Invalid type %s.\n", debugstr_vt(V_VT(var)));
|
|
|
|
return E_INVALIDARG;
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
2020-04-14 07:16:04 +02:00
|
|
|
V_BSTR(var) = SysAllocStringLen(data, size / sizeof(WCHAR) - 1);
|
|
|
|
free(data);
|
|
|
|
return S_OK;
|
|
|
|
case REG_DWORD:
|
|
|
|
if (V_VT(var) == VT_EMPTY)
|
|
|
|
V_VT(var) = VT_I4;
|
|
|
|
if (V_VT(var) != VT_I4)
|
|
|
|
{
|
|
|
|
WARN("Invalid type %s.\n", debugstr_vt(V_VT(var)));
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
V_I4(var) = *(DWORD *)data;
|
|
|
|
free(data);
|
|
|
|
return S_OK;
|
|
|
|
case REG_BINARY:
|
|
|
|
{
|
|
|
|
SAFEARRAYBOUND bound = {.cElements = size};
|
|
|
|
void *array_data;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
if (V_VT(var) == VT_EMPTY)
|
|
|
|
V_VT(var) = VT_ARRAY | VT_UI1;
|
|
|
|
if (V_VT(var) != (VT_ARRAY | VT_UI1))
|
|
|
|
{
|
|
|
|
WARN("Invalid type %s.\n", debugstr_vt(V_VT(var)));
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
2003-08-05 21:19:21 +02:00
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
if (!(V_ARRAY(var) = SafeArrayCreate(VT_UI1, 1, &bound)))
|
|
|
|
{
|
|
|
|
free(data);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2018-03-07 03:57:11 +01:00
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
SafeArrayAccessData(V_ARRAY(var), &array_data);
|
|
|
|
memcpy(array_data, data, size);
|
|
|
|
SafeArrayUnaccessData(V_ARRAY(var));
|
|
|
|
free(data);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled type %#x.\n", type);
|
|
|
|
free(data);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
static HRESULT WINAPI property_bag_Write(IPropertyBag *iface, const WCHAR *name, VARIANT *var)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-14 07:16:04 +02:00
|
|
|
struct moniker *moniker = impl_from_IPropertyBag(iface);
|
|
|
|
HKEY parent, key;
|
|
|
|
WCHAR path[78];
|
|
|
|
LONG ret;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
TRACE("moniker %p, name %s, var %s.\n", moniker, debugstr_w(name), debugstr_variant(var));
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
if (moniker->type == DEVICE_DMO)
|
2018-06-25 00:20:29 +02:00
|
|
|
return E_ACCESSDENIED;
|
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
if (moniker->type == DEVICE_FILTER)
|
|
|
|
{
|
|
|
|
wcscpy(path, L"CLSID\\");
|
|
|
|
if (moniker->has_class)
|
|
|
|
{
|
|
|
|
StringFromGUID2(&moniker->class, path + wcslen(path), CHARS_IN_GUID);
|
|
|
|
wcscat(path, L"\\Instance");
|
|
|
|
}
|
|
|
|
if ((ret = RegCreateKeyExW(HKEY_CLASSES_ROOT, path, 0, NULL, 0, 0, NULL, &parent, NULL)))
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
|
|
|
}
|
|
|
|
else if (moniker->type == DEVICE_CODEC)
|
|
|
|
{
|
|
|
|
wcscpy(path, L"Software\\Microsoft\\ActiveMovie\\devenum\\");
|
|
|
|
if (moniker->has_class)
|
|
|
|
StringFromGUID2(&moniker->class, path + wcslen(path), CHARS_IN_GUID);
|
|
|
|
if ((ret = RegCreateKeyExW(HKEY_CURRENT_USER, path, 0, NULL, 0, 0, NULL, &parent, NULL)))
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
|
|
|
}
|
|
|
|
ret = RegCreateKeyExW(parent, moniker->name, 0, NULL, 0, KEY_WRITE, NULL, &key, NULL);
|
|
|
|
RegCloseKey(parent);
|
|
|
|
if (ret)
|
|
|
|
return HRESULT_FROM_WIN32(ret);
|
|
|
|
|
|
|
|
switch (V_VT(var))
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
|
|
|
case VT_BSTR:
|
2020-04-14 07:16:04 +02:00
|
|
|
ret = RegSetValueExW(key, name, 0, REG_SZ, (BYTE *)V_BSTR(var),
|
|
|
|
(wcslen(V_BSTR(var)) + 1) * sizeof(WCHAR));
|
2003-07-01 06:30:30 +02:00
|
|
|
break;
|
|
|
|
case VT_I4:
|
2020-04-14 07:16:04 +02:00
|
|
|
ret = RegSetValueExW(key, name, 0, REG_DWORD, (BYTE *)&V_I4(var), sizeof(DWORD));
|
2003-07-01 06:30:30 +02:00
|
|
|
break;
|
|
|
|
case VT_ARRAY | VT_UI1:
|
|
|
|
{
|
2020-04-14 07:16:04 +02:00
|
|
|
LONG lbound, ubound;
|
|
|
|
void *array_data;
|
|
|
|
SafeArrayGetLBound(V_ARRAY(var), 1, &lbound);
|
|
|
|
SafeArrayGetUBound(V_ARRAY(var), 1, &ubound);
|
|
|
|
SafeArrayAccessData(V_ARRAY(var), &array_data);
|
|
|
|
ret = RegSetValueExW(key, name, 0, REG_BINARY, array_data, ubound - lbound + 1);
|
|
|
|
SafeArrayUnaccessData(V_ARRAY(var));
|
2003-07-01 06:30:30 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2020-04-14 07:16:04 +02:00
|
|
|
WARN("Unhandled type %s.\n", debugstr_vt(V_VT(var)));
|
2020-04-15 05:22:48 +02:00
|
|
|
return E_INVALIDARG;
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
RegCloseKey(key);
|
|
|
|
return S_OK;
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2005-05-30 12:01:08 +02:00
|
|
|
static const IPropertyBagVtbl IPropertyBag_Vtbl =
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-11 17:49:40 +02:00
|
|
|
property_bag_QueryInterface,
|
|
|
|
property_bag_AddRef,
|
|
|
|
property_bag_Release,
|
|
|
|
property_bag_Read,
|
|
|
|
property_bag_Write,
|
2003-07-01 06:30:30 +02:00
|
|
|
};
|
|
|
|
|
2020-04-11 17:49:41 +02:00
|
|
|
static inline struct moniker *impl_from_IMoniker(IMoniker *iface)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-11 17:49:41 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct moniker, IMoniker_iface);
|
2012-04-03 00:18:39 +02:00
|
|
|
}
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
|
2012-04-03 00:18:39 +02:00
|
|
|
{
|
|
|
|
TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2012-04-03 00:18:39 +02:00
|
|
|
if (!ppv)
|
|
|
|
return E_POINTER;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IPersist) ||
|
|
|
|
IsEqualGUID(riid, &IID_IPersistStream) ||
|
|
|
|
IsEqualGUID(riid, &IID_IMoniker))
|
|
|
|
{
|
2012-04-03 00:18:39 +02:00
|
|
|
*ppv = iface;
|
|
|
|
IMoniker_AddRef(iface);
|
2003-07-01 06:30:30 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-01-11 23:47:51 +01:00
|
|
|
FIXME("- no interface IID: %s\n", debugstr_guid(riid));
|
2012-04-03 00:18:39 +02:00
|
|
|
*ppv = NULL;
|
2003-07-01 06:30:30 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static ULONG WINAPI moniker_AddRef(IMoniker *iface)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-11 17:49:41 +02:00
|
|
|
struct moniker *This = impl_from_IMoniker(iface);
|
2012-04-03 00:18:39 +02:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2012-04-03 00:18:39 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static ULONG WINAPI moniker_Release(IMoniker *iface)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-11 17:49:41 +02:00
|
|
|
struct moniker *This = impl_from_IMoniker(iface);
|
2012-04-03 00:18:39 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
if (ref == 0) {
|
2020-04-29 17:01:21 +02:00
|
|
|
free(This->name);
|
2020-04-11 17:49:42 +02:00
|
|
|
free(This);
|
2004-12-07 15:37:11 +01:00
|
|
|
DEVENUM_UnlockModule();
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_GetClassID(IMoniker *iface, CLSID *pClassID)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-11 17:49:41 +02:00
|
|
|
struct moniker *This = impl_from_IMoniker(iface);
|
2012-04-03 00:18:39 +02:00
|
|
|
|
2017-03-10 11:26:53 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, pClassID);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
if (pClassID == NULL)
|
2017-03-10 11:26:53 +01:00
|
|
|
return E_INVALIDARG;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2017-03-10 11:26:53 +01:00
|
|
|
*pClassID = CLSID_CDeviceMoniker;
|
|
|
|
|
|
|
|
return S_OK;
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_IsDirty(IMoniker *iface)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2008-12-07 11:38:12 +01:00
|
|
|
FIXME("(%p)->(): stub\n", iface);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_Load(IMoniker *iface, IStream *pStm)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2008-12-07 11:38:12 +01:00
|
|
|
FIXME("(%p)->(%p): stub\n", iface, pStm);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2008-12-07 11:38:12 +01:00
|
|
|
FIXME("(%p)->(%p, %s): stub\n", iface, pStm, fClearDirty ? "true" : "false");
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
return STG_E_CANTSAVE;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2008-12-07 11:38:12 +01:00
|
|
|
FIXME("(%p)->(%p): stub\n", iface, pcbSize);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
ZeroMemory(pcbSize, sizeof(*pcbSize));
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2020-04-16 21:46:04 +02:00
|
|
|
static HRESULT WINAPI moniker_BindToObject(IMoniker *iface, IBindCtx *bind_ctx,
|
|
|
|
IMoniker *left, REFIID iid, void **out)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-16 21:46:04 +02:00
|
|
|
struct moniker *moniker = impl_from_IMoniker(iface);
|
|
|
|
IPersistPropertyBag *persist_bag;
|
|
|
|
IUnknown *unk;
|
|
|
|
CLSID clsid;
|
2003-07-01 06:30:30 +02:00
|
|
|
VARIANT var;
|
2020-04-16 21:46:04 +02:00
|
|
|
HRESULT hr;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2020-04-16 21:46:04 +02:00
|
|
|
TRACE("moniker %p, bind_ctx %p, left %p, iid %s, out %p.\n",
|
|
|
|
moniker, bind_ctx, left, debugstr_guid(iid), out);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2020-04-16 21:46:04 +02:00
|
|
|
if (!out)
|
2018-04-28 19:30:09 +02:00
|
|
|
return E_POINTER;
|
|
|
|
|
2020-04-16 21:46:04 +02:00
|
|
|
*out = NULL;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2020-04-16 21:46:06 +02:00
|
|
|
if (moniker->type == DEVICE_DMO)
|
|
|
|
{
|
|
|
|
IDMOWrapperFilter *wrapper;
|
|
|
|
|
|
|
|
if (FAILED(hr = CoCreateInstance(&CLSID_DMOWrapperFilter, NULL,
|
|
|
|
CLSCTX_INPROC_SERVER, &IID_IDMOWrapperFilter, (void **)&wrapper)))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr = IDMOWrapperFilter_Init(wrapper, &moniker->clsid, &moniker->class)))
|
|
|
|
{
|
|
|
|
hr = IDMOWrapperFilter_QueryInterface(wrapper, iid, out);
|
|
|
|
}
|
|
|
|
IDMOWrapperFilter_Release(wrapper);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
VariantInit(&var);
|
2020-04-16 21:46:04 +02:00
|
|
|
V_VT(&var) = VT_BSTR;
|
2020-04-16 21:46:05 +02:00
|
|
|
if (FAILED(hr = IPropertyBag_Read(&moniker->IPropertyBag_iface, L"CLSID", &var, NULL)))
|
2020-04-16 21:46:04 +02:00
|
|
|
return hr;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2020-04-16 21:46:04 +02:00
|
|
|
hr = CLSIDFromString(V_BSTR(&var), &clsid);
|
|
|
|
VariantClear(&var);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2020-04-16 21:46:04 +02:00
|
|
|
if (FAILED(hr = CoCreateInstance(&clsid, NULL, CLSCTX_ALL, &IID_IUnknown, (void **)&unk)))
|
|
|
|
return hr;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2020-04-16 21:46:04 +02:00
|
|
|
if (SUCCEEDED(IUnknown_QueryInterface(unk, &IID_IPersistPropertyBag, (void **)&persist_bag)))
|
|
|
|
{
|
2020-04-16 21:46:05 +02:00
|
|
|
hr = IPersistPropertyBag_Load(persist_bag, &moniker->IPropertyBag_iface, NULL);
|
2020-04-16 21:46:04 +02:00
|
|
|
IPersistPropertyBag_Release(persist_bag);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = IUnknown_QueryInterface(unk, iid, out);
|
|
|
|
|
|
|
|
IUnknown_Release(unk);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2020-04-16 21:46:04 +02:00
|
|
|
return hr;
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_BindToStorage(IMoniker *iface, IBindCtx *pbc,
|
2020-04-14 07:16:04 +02:00
|
|
|
IMoniker *pmkToLeft, REFIID riid, void **out)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-14 07:16:04 +02:00
|
|
|
struct moniker *moniker = impl_from_IMoniker(iface);
|
2012-04-03 00:18:39 +02:00
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
TRACE("moniker %p, left %p, iid %s, out %p.\n", moniker, pmkToLeft, debugstr_guid(riid), out);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2020-04-14 07:16:04 +02:00
|
|
|
*out = NULL;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2012-06-16 19:36:24 +02:00
|
|
|
if (pmkToLeft)
|
2003-07-01 06:30:30 +02:00
|
|
|
return MK_E_NOSTORAGE;
|
|
|
|
|
2012-06-16 19:36:24 +02:00
|
|
|
if (pbc != NULL)
|
|
|
|
{
|
|
|
|
static DWORD reported;
|
|
|
|
if (!reported)
|
|
|
|
{
|
|
|
|
FIXME("ignoring IBindCtx %p\n", pbc);
|
|
|
|
reported++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-01 06:30:30 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_IPropertyBag))
|
|
|
|
{
|
2020-04-14 07:16:04 +02:00
|
|
|
*out = &moniker->IPropertyBag_iface;
|
|
|
|
IPropertyBag_AddRef(&moniker->IPropertyBag_iface);
|
|
|
|
return S_OK;
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return MK_E_NOSTORAGE;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_Reduce(IMoniker *iface, IBindCtx *pbc,
|
2012-04-03 00:18:39 +02:00
|
|
|
DWORD dwReduceHowFar, IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2008-12-07 11:38:12 +01:00
|
|
|
TRACE("(%p)->(%p, %d, %p, %p)\n", iface, pbc, dwReduceHowFar, ppmkToLeft, ppmkReduced);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
if (ppmkToLeft)
|
|
|
|
*ppmkToLeft = NULL;
|
|
|
|
*ppmkReduced = iface;
|
|
|
|
|
|
|
|
return MK_S_REDUCED_TO_SELF;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_ComposeWith(IMoniker *iface, IMoniker *pmkRight,
|
2012-04-03 00:18:39 +02:00
|
|
|
BOOL fOnlyIfNotGeneric, IMoniker **ppmkComposite)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2008-12-07 11:38:12 +01:00
|
|
|
FIXME("(%p)->(%p, %s, %p): stub\n", iface, pmkRight, fOnlyIfNotGeneric ? "true" : "false", ppmkComposite);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
/* FIXME: use CreateGenericComposite? */
|
|
|
|
*ppmkComposite = NULL;
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_Enum(IMoniker *iface, BOOL fForward,
|
2012-04-03 00:18:39 +02:00
|
|
|
IEnumMoniker **ppenumMoniker)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2008-12-07 11:38:12 +01:00
|
|
|
FIXME("(%p)->(%s, %p): stub\n", iface, fForward ? "true" : "false", ppenumMoniker);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
*ppenumMoniker = NULL;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2017-03-27 17:41:23 +02:00
|
|
|
CLSID clsid;
|
|
|
|
LPOLESTR this_name, other_name;
|
|
|
|
IBindCtx *bind;
|
|
|
|
HRESULT res;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2017-03-27 17:41:23 +02:00
|
|
|
TRACE("(%p)->(%p)\n", iface, pmkOtherMoniker);
|
|
|
|
|
|
|
|
if (!pmkOtherMoniker)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
IMoniker_GetClassID(pmkOtherMoniker, &clsid);
|
|
|
|
if (!IsEqualCLSID(&clsid, &CLSID_CDeviceMoniker))
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
res = CreateBindCtx(0, &bind);
|
|
|
|
if (FAILED(res))
|
|
|
|
return res;
|
|
|
|
|
|
|
|
res = S_FALSE;
|
|
|
|
if (SUCCEEDED(IMoniker_GetDisplayName(iface, bind, NULL, &this_name)) &&
|
|
|
|
SUCCEEDED(IMoniker_GetDisplayName(pmkOtherMoniker, bind, NULL, &other_name)))
|
|
|
|
{
|
|
|
|
int result = lstrcmpiW(this_name, other_name);
|
|
|
|
CoTaskMemFree(this_name);
|
|
|
|
CoTaskMemFree(other_name);
|
|
|
|
if (!result)
|
|
|
|
res = S_OK;
|
|
|
|
}
|
|
|
|
IBindCtx_Release(bind);
|
|
|
|
return res;
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_Hash(IMoniker *iface, DWORD *pdwHash)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2008-12-07 11:38:12 +01:00
|
|
|
TRACE("(%p)->(%p)\n", iface, pdwHash);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
*pdwHash = 0;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_IsRunning(IMoniker *iface, IBindCtx *pbc,
|
2012-04-03 00:18:39 +02:00
|
|
|
IMoniker *pmkToLeft, IMoniker *pmkNewlyRunning)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2008-12-07 11:38:12 +01:00
|
|
|
FIXME("(%p)->(%p, %p, %p): stub\n", iface, pbc, pmkToLeft, pmkNewlyRunning);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc,
|
2012-04-03 00:18:39 +02:00
|
|
|
IMoniker *pmkToLeft, FILETIME *pFileTime)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2008-12-07 11:38:12 +01:00
|
|
|
TRACE("(%p)->(%p, %p, %p)\n", iface, pbc, pmkToLeft, pFileTime);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
pFileTime->dwLowDateTime = 0xFFFFFFFF;
|
|
|
|
pFileTime->dwHighDateTime = 0x7FFFFFFF;
|
|
|
|
|
|
|
|
return MK_E_UNAVAILABLE;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_Inverse(IMoniker *iface, IMoniker **ppmk)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2008-12-07 11:38:12 +01:00
|
|
|
TRACE("(%p)->(%p)\n", iface, ppmk);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
*ppmk = NULL;
|
|
|
|
|
|
|
|
return MK_E_NOINVERSE;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_CommonPrefixWith(IMoniker *iface,
|
2012-04-03 00:18:39 +02:00
|
|
|
IMoniker *pmkOtherMoniker, IMoniker **ppmkPrefix)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2008-12-07 11:38:12 +01:00
|
|
|
TRACE("(%p)->(%p, %p)\n", iface, pmkOtherMoniker, ppmkPrefix);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
*ppmkPrefix = NULL;
|
|
|
|
|
|
|
|
return MK_E_NOPREFIX;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_RelativePathTo(IMoniker *iface, IMoniker *pmkOther,
|
2012-04-03 00:18:39 +02:00
|
|
|
IMoniker **ppmkRelPath)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2008-12-07 11:38:12 +01:00
|
|
|
TRACE("(%p)->(%p, %p)\n", iface, pmkOther, ppmkRelPath);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
*ppmkRelPath = pmkOther;
|
|
|
|
|
|
|
|
return MK_S_HIM;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc,
|
2012-04-03 00:18:39 +02:00
|
|
|
IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-11 17:49:41 +02:00
|
|
|
struct moniker *This = impl_from_IMoniker(iface);
|
2018-03-07 03:57:10 +01:00
|
|
|
WCHAR *buffer;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2008-12-07 11:38:12 +01:00
|
|
|
TRACE("(%p)->(%p, %p, %p)\n", iface, pbc, pmkToLeft, ppszDisplayName);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
*ppszDisplayName = NULL;
|
|
|
|
|
2018-06-25 00:20:29 +02:00
|
|
|
if (This->type == DEVICE_DMO)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2019-05-31 08:49:22 +02:00
|
|
|
buffer = CoTaskMemAlloc((lstrlenW(deviceW) + lstrlenW(dmoW)
|
2018-06-25 00:20:29 +02:00
|
|
|
+ 2 * CHARS_IN_GUID + 1) * sizeof(WCHAR));
|
|
|
|
if (!buffer) return E_OUTOFMEMORY;
|
|
|
|
|
2019-05-31 08:49:22 +02:00
|
|
|
lstrcpyW(buffer, deviceW);
|
|
|
|
lstrcatW(buffer, dmoW);
|
|
|
|
StringFromGUID2(&This->clsid, buffer + lstrlenW(buffer), CHARS_IN_GUID);
|
|
|
|
StringFromGUID2(&This->class, buffer + lstrlenW(buffer), CHARS_IN_GUID);
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
2018-06-25 00:20:29 +02:00
|
|
|
else
|
|
|
|
{
|
2019-05-31 08:49:22 +02:00
|
|
|
buffer = CoTaskMemAlloc((lstrlenW(deviceW) + 3 + (This->has_class ? CHARS_IN_GUID : 0)
|
|
|
|
+ lstrlenW(This->name) + 1) * sizeof(WCHAR));
|
2018-06-25 00:20:29 +02:00
|
|
|
if (!buffer) return E_OUTOFMEMORY;
|
|
|
|
|
2019-05-31 08:49:22 +02:00
|
|
|
lstrcpyW(buffer, deviceW);
|
2018-06-25 00:20:29 +02:00
|
|
|
if (This->type == DEVICE_FILTER)
|
2019-05-31 08:49:22 +02:00
|
|
|
lstrcatW(buffer, swW);
|
2018-06-25 00:20:29 +02:00
|
|
|
else if (This->type == DEVICE_CODEC)
|
2019-05-31 08:49:22 +02:00
|
|
|
lstrcatW(buffer, cmW);
|
2018-06-25 00:20:29 +02:00
|
|
|
|
|
|
|
if (This->has_class)
|
|
|
|
{
|
2019-05-31 08:49:22 +02:00
|
|
|
StringFromGUID2(&This->class, buffer + lstrlenW(buffer), CHARS_IN_GUID);
|
|
|
|
lstrcatW(buffer, backslashW);
|
2018-06-25 00:20:29 +02:00
|
|
|
}
|
2019-05-31 08:49:22 +02:00
|
|
|
lstrcatW(buffer, This->name);
|
2018-06-25 00:20:29 +02:00
|
|
|
}
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2018-03-07 03:57:10 +01:00
|
|
|
*ppszDisplayName = buffer;
|
|
|
|
return S_OK;
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc,
|
2012-04-03 00:18:39 +02:00
|
|
|
IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2008-12-07 11:38:12 +01:00
|
|
|
FIXME("(%p)->(%p, %p, %s, %p, %p)\n", iface, pbc, pmkToLeft, debugstr_w(pszDisplayName), pchEaten, ppmkOut);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
*pchEaten = 0;
|
|
|
|
*ppmkOut = NULL;
|
|
|
|
|
|
|
|
return MK_E_SYNTAX;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI moniker_IsSystemMoniker(IMoniker *iface, DWORD *pdwMksys)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2008-12-07 11:38:12 +01:00
|
|
|
TRACE("(%p)->(%p)\n", iface, pdwMksys);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2005-05-30 12:01:08 +02:00
|
|
|
static const IMonikerVtbl IMoniker_Vtbl =
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-11 17:49:40 +02:00
|
|
|
moniker_QueryInterface,
|
|
|
|
moniker_AddRef,
|
|
|
|
moniker_Release,
|
|
|
|
moniker_GetClassID,
|
|
|
|
moniker_IsDirty,
|
|
|
|
moniker_Load,
|
|
|
|
moniker_Save,
|
|
|
|
moniker_GetSizeMax,
|
|
|
|
moniker_BindToObject,
|
|
|
|
moniker_BindToStorage,
|
|
|
|
moniker_Reduce,
|
|
|
|
moniker_ComposeWith,
|
|
|
|
moniker_Enum,
|
|
|
|
moniker_IsEqual,
|
|
|
|
moniker_Hash,
|
|
|
|
moniker_IsRunning,
|
|
|
|
moniker_GetTimeOfLastChange,
|
|
|
|
moniker_Inverse,
|
|
|
|
moniker_CommonPrefixWith,
|
|
|
|
moniker_RelativePathTo,
|
|
|
|
moniker_GetDisplayName,
|
|
|
|
moniker_ParseDisplayName,
|
|
|
|
moniker_IsSystemMoniker,
|
2003-07-01 06:30:30 +02:00
|
|
|
};
|
|
|
|
|
2020-04-11 17:49:43 +02:00
|
|
|
struct moniker *filter_moniker_create(const GUID *class, const WCHAR *name)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-11 17:49:42 +02:00
|
|
|
struct moniker *object;
|
2020-04-11 17:49:41 +02:00
|
|
|
|
2020-04-11 17:49:42 +02:00
|
|
|
if (!(object = calloc(1, sizeof(*object))))
|
2003-07-01 06:30:30 +02:00
|
|
|
return NULL;
|
|
|
|
|
2020-04-11 17:49:42 +02:00
|
|
|
object->IMoniker_iface.lpVtbl = &IMoniker_Vtbl;
|
2020-04-14 07:16:04 +02:00
|
|
|
object->IPropertyBag_iface.lpVtbl = &IPropertyBag_Vtbl;
|
2020-04-11 17:49:42 +02:00
|
|
|
object->ref = 1;
|
2020-04-11 17:49:43 +02:00
|
|
|
object->type = DEVICE_FILTER;
|
|
|
|
if (class)
|
|
|
|
object->class = *class;
|
|
|
|
object->has_class = !!class;
|
|
|
|
object->name = wcsdup(name);
|
|
|
|
|
|
|
|
DEVENUM_LockModule();
|
|
|
|
|
|
|
|
return object;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct moniker *codec_moniker_create(const GUID *class, const WCHAR *name)
|
|
|
|
{
|
|
|
|
struct moniker *object;
|
|
|
|
|
|
|
|
if (!(object = calloc(1, sizeof(*object))))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
object->IMoniker_iface.lpVtbl = &IMoniker_Vtbl;
|
2020-04-14 07:16:04 +02:00
|
|
|
object->IPropertyBag_iface.lpVtbl = &IPropertyBag_Vtbl;
|
2020-04-11 17:49:43 +02:00
|
|
|
object->ref = 1;
|
|
|
|
object->type = DEVICE_CODEC;
|
|
|
|
if (class)
|
|
|
|
object->class = *class;
|
|
|
|
object->has_class = !!class;
|
|
|
|
object->name = wcsdup(name);
|
|
|
|
|
|
|
|
DEVENUM_LockModule();
|
|
|
|
|
|
|
|
return object;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct moniker *dmo_moniker_create(const GUID class, const GUID clsid)
|
|
|
|
{
|
|
|
|
struct moniker *object;
|
|
|
|
|
|
|
|
if (!(object = calloc(1, sizeof(*object))))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
object->IMoniker_iface.lpVtbl = &IMoniker_Vtbl;
|
2020-04-14 07:16:04 +02:00
|
|
|
object->IPropertyBag_iface.lpVtbl = &IPropertyBag_Vtbl;
|
2020-04-11 17:49:43 +02:00
|
|
|
object->ref = 1;
|
|
|
|
object->type = DEVICE_DMO;
|
|
|
|
object->class = class;
|
|
|
|
object->clsid = clsid;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2004-12-07 15:37:11 +01:00
|
|
|
DEVENUM_LockModule();
|
|
|
|
|
2020-04-11 17:49:42 +02:00
|
|
|
return object;
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2012-04-03 00:16:52 +02:00
|
|
|
static inline EnumMonikerImpl *impl_from_IEnumMoniker(IEnumMoniker *iface)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2012-04-03 00:16:52 +02:00
|
|
|
return CONTAINING_RECORD(iface, EnumMonikerImpl, IEnumMoniker_iface);
|
|
|
|
}
|
2008-12-07 11:38:12 +01:00
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI enum_moniker_QueryInterface(IEnumMoniker *iface, REFIID riid, void **ppv)
|
2012-04-03 00:16:52 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2012-04-03 00:16:52 +02:00
|
|
|
if (!ppv)
|
|
|
|
return E_POINTER;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IEnumMoniker))
|
|
|
|
{
|
2012-04-03 00:16:52 +02:00
|
|
|
*ppv = iface;
|
|
|
|
IEnumMoniker_AddRef(iface);
|
2003-07-01 06:30:30 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-01-11 23:47:51 +01:00
|
|
|
FIXME("- no interface IID: %s\n", debugstr_guid(riid));
|
2012-04-03 00:16:52 +02:00
|
|
|
*ppv = NULL;
|
2003-07-01 06:30:30 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static ULONG WINAPI enum_moniker_AddRef(IEnumMoniker *iface)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2012-04-03 00:16:52 +02:00
|
|
|
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
|
2005-01-09 19:24:41 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2012-04-03 00:16:52 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2005-01-09 19:24:41 +01:00
|
|
|
return ref;
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static ULONG WINAPI enum_moniker_Release(IEnumMoniker *iface)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2012-04-03 00:16:52 +02:00
|
|
|
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
|
2005-01-09 19:24:41 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2012-04-03 00:16:52 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2005-01-09 19:24:41 +01:00
|
|
|
if (!ref)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2018-06-25 00:20:30 +02:00
|
|
|
IEnumDMO_Release(This->dmo_enum);
|
2018-03-07 03:57:08 +01:00
|
|
|
RegCloseKey(This->sw_key);
|
|
|
|
RegCloseKey(This->cm_key);
|
2003-07-01 06:30:30 +02:00
|
|
|
CoTaskMemFree(This);
|
2004-12-07 15:37:11 +01:00
|
|
|
DEVENUM_UnlockModule();
|
2003-07-01 06:30:30 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2005-01-09 19:24:41 +01:00
|
|
|
return ref;
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI enum_moniker_Next(IEnumMoniker *iface, ULONG celt, IMoniker **rgelt,
|
2012-04-03 00:16:52 +02:00
|
|
|
ULONG *pceltFetched)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2012-04-03 00:16:52 +02:00
|
|
|
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
|
2003-07-01 06:30:30 +02:00
|
|
|
WCHAR buffer[MAX_PATH + 1];
|
2020-04-11 17:49:43 +02:00
|
|
|
struct moniker *moniker;
|
2003-07-01 06:30:30 +02:00
|
|
|
LONG res;
|
|
|
|
ULONG fetched = 0;
|
2018-06-25 00:20:30 +02:00
|
|
|
HRESULT hr;
|
2020-04-11 17:49:43 +02:00
|
|
|
GUID clsid;
|
2018-03-07 03:57:08 +01:00
|
|
|
HKEY hkey;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2006-10-08 18:58:22 +02:00
|
|
|
TRACE("(%p)->(%d, %p, %p)\n", iface, celt, rgelt, pceltFetched);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
while (fetched < celt)
|
|
|
|
{
|
2018-06-25 00:20:30 +02:00
|
|
|
/* FIXME: try PNP devices first */
|
|
|
|
|
|
|
|
/* try DMOs */
|
2019-02-24 20:46:35 +01:00
|
|
|
if ((hr = IEnumDMO_Next(This->dmo_enum, 1, &clsid, NULL, NULL)) == S_OK)
|
2018-06-25 00:20:30 +02:00
|
|
|
{
|
2020-04-11 17:49:43 +02:00
|
|
|
moniker = dmo_moniker_create(This->class, clsid);
|
2018-06-25 00:20:30 +02:00
|
|
|
}
|
2018-03-07 03:57:08 +01:00
|
|
|
/* try DirectShow filters */
|
2018-08-04 22:45:40 +02:00
|
|
|
else if (!(res = RegEnumKeyW(This->sw_key, This->sw_index, buffer, ARRAY_SIZE(buffer))))
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2018-03-07 03:57:08 +01:00
|
|
|
This->sw_index++;
|
|
|
|
if ((res = RegOpenKeyExW(This->sw_key, buffer, 0, KEY_QUERY_VALUE, &hkey)))
|
|
|
|
break;
|
2018-03-07 03:57:10 +01:00
|
|
|
|
2020-04-11 17:49:43 +02:00
|
|
|
moniker = filter_moniker_create(&This->class, buffer);
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
2018-03-07 03:57:08 +01:00
|
|
|
/* then try codecs */
|
2018-08-04 22:45:40 +02:00
|
|
|
else if (!(res = RegEnumKeyW(This->cm_key, This->cm_index, buffer, ARRAY_SIZE(buffer))))
|
2018-03-07 03:57:08 +01:00
|
|
|
{
|
|
|
|
This->cm_index++;
|
|
|
|
|
|
|
|
if ((res = RegOpenKeyExW(This->cm_key, buffer, 0, KEY_QUERY_VALUE, &hkey)))
|
|
|
|
break;
|
2018-03-07 03:57:10 +01:00
|
|
|
|
2020-04-11 17:49:43 +02:00
|
|
|
moniker = codec_moniker_create(&This->class, buffer);
|
2018-03-07 03:57:08 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
|
2020-04-11 17:49:43 +02:00
|
|
|
if (!moniker)
|
|
|
|
return E_OUTOFMEMORY;
|
2018-03-07 03:57:08 +01:00
|
|
|
|
2020-04-11 17:49:43 +02:00
|
|
|
rgelt[fetched++] = &moniker->IMoniker_iface;
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2006-10-08 18:58:22 +02:00
|
|
|
TRACE("-- fetched %d\n", fetched);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
if (pceltFetched)
|
|
|
|
*pceltFetched = fetched;
|
|
|
|
|
|
|
|
if (fetched != celt)
|
|
|
|
return S_FALSE;
|
|
|
|
else
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI enum_moniker_Skip(IEnumMoniker *iface, ULONG celt)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2012-04-03 00:16:52 +02:00
|
|
|
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2006-10-08 18:58:22 +02:00
|
|
|
TRACE("(%p)->(%d)\n", iface, celt);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2018-03-07 03:57:08 +01:00
|
|
|
while (celt--)
|
2008-01-05 00:05:34 +01:00
|
|
|
{
|
2018-06-25 00:20:30 +02:00
|
|
|
/* FIXME: try PNP devices first */
|
2008-01-05 00:05:34 +01:00
|
|
|
|
2018-06-25 00:20:30 +02:00
|
|
|
/* try DMOs */
|
|
|
|
if (IEnumDMO_Skip(This->dmo_enum, 1) == S_OK)
|
|
|
|
;
|
2018-03-07 03:57:08 +01:00
|
|
|
/* try DirectShow filters */
|
2018-06-25 00:20:30 +02:00
|
|
|
else if (RegEnumKeyW(This->sw_key, This->sw_index, NULL, 0) != ERROR_NO_MORE_ITEMS)
|
2018-03-07 03:57:08 +01:00
|
|
|
{
|
|
|
|
This->sw_index++;
|
|
|
|
}
|
|
|
|
/* then try codecs */
|
|
|
|
else if (RegEnumKeyW(This->cm_key, This->cm_index, NULL, 0) != ERROR_NO_MORE_ITEMS)
|
|
|
|
{
|
|
|
|
This->cm_index++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI enum_moniker_Reset(IEnumMoniker *iface)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2012-04-03 00:16:52 +02:00
|
|
|
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2005-01-09 19:24:41 +01:00
|
|
|
TRACE("(%p)->()\n", iface);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2018-06-25 00:20:30 +02:00
|
|
|
IEnumDMO_Reset(This->dmo_enum);
|
2018-03-07 03:57:08 +01:00
|
|
|
This->sw_index = 0;
|
|
|
|
This->cm_index = 0;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI enum_moniker_Clone(IEnumMoniker *iface, IEnumMoniker **ppenum)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2005-01-09 19:24:41 +01:00
|
|
|
FIXME("(%p)->(%p): stub\n", iface, ppenum);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* IEnumMoniker_Vtbl
|
|
|
|
*/
|
2005-05-30 12:01:08 +02:00
|
|
|
static const IEnumMonikerVtbl IEnumMoniker_Vtbl =
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2020-04-11 17:49:40 +02:00
|
|
|
enum_moniker_QueryInterface,
|
|
|
|
enum_moniker_AddRef,
|
|
|
|
enum_moniker_Release,
|
|
|
|
enum_moniker_Next,
|
|
|
|
enum_moniker_Skip,
|
|
|
|
enum_moniker_Reset,
|
|
|
|
enum_moniker_Clone,
|
2003-07-01 06:30:30 +02:00
|
|
|
};
|
2004-12-07 15:37:11 +01:00
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
HRESULT enum_moniker_create(REFCLSID class, IEnumMoniker **ppEnumMoniker)
|
2004-12-07 15:37:11 +01:00
|
|
|
{
|
|
|
|
EnumMonikerImpl * pEnumMoniker = CoTaskMemAlloc(sizeof(EnumMonikerImpl));
|
2018-03-07 03:57:08 +01:00
|
|
|
WCHAR buffer[78];
|
2018-06-25 00:20:30 +02:00
|
|
|
HRESULT hr;
|
2018-03-07 03:57:08 +01:00
|
|
|
|
2004-12-07 15:37:11 +01:00
|
|
|
if (!pEnumMoniker)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2012-04-03 00:16:52 +02:00
|
|
|
pEnumMoniker->IEnumMoniker_iface.lpVtbl = &IEnumMoniker_Vtbl;
|
2004-12-07 15:37:11 +01:00
|
|
|
pEnumMoniker->ref = 1;
|
2018-03-07 03:57:08 +01:00
|
|
|
pEnumMoniker->sw_index = 0;
|
|
|
|
pEnumMoniker->cm_index = 0;
|
2018-03-07 03:57:10 +01:00
|
|
|
pEnumMoniker->class = *class;
|
2004-12-07 15:37:11 +01:00
|
|
|
|
2019-05-31 08:49:22 +02:00
|
|
|
lstrcpyW(buffer, clsidW);
|
|
|
|
lstrcatW(buffer, backslashW);
|
|
|
|
StringFromGUID2(class, buffer + lstrlenW(buffer), CHARS_IN_GUID);
|
|
|
|
lstrcatW(buffer, instanceW);
|
2018-03-07 03:57:08 +01:00
|
|
|
if (RegOpenKeyExW(HKEY_CLASSES_ROOT, buffer, 0, KEY_ENUMERATE_SUB_KEYS, &pEnumMoniker->sw_key))
|
|
|
|
pEnumMoniker->sw_key = NULL;
|
2004-12-07 15:37:11 +01:00
|
|
|
|
2019-05-31 08:49:22 +02:00
|
|
|
lstrcpyW(buffer, wszActiveMovieKey);
|
|
|
|
StringFromGUID2(class, buffer + lstrlenW(buffer), CHARS_IN_GUID);
|
2018-03-07 03:57:08 +01:00
|
|
|
if (RegOpenKeyExW(HKEY_CURRENT_USER, buffer, 0, KEY_ENUMERATE_SUB_KEYS, &pEnumMoniker->cm_key))
|
|
|
|
pEnumMoniker->cm_key = NULL;
|
2014-01-08 14:12:11 +01:00
|
|
|
|
2018-06-25 00:20:30 +02:00
|
|
|
hr = DMOEnum(class, 0, 0, NULL, 0, NULL, &pEnumMoniker->dmo_enum);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IEnumMoniker_Release(&pEnumMoniker->IEnumMoniker_iface);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-03-07 03:57:08 +01:00
|
|
|
*ppEnumMoniker = &pEnumMoniker->IEnumMoniker_iface;
|
2014-01-08 14:12:11 +01:00
|
|
|
|
2004-12-07 15:37:11 +01:00
|
|
|
DEVENUM_LockModule();
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|