2003-07-01 06:30:30 +02:00
|
|
|
/*
|
2018-06-26 16:05:29 +02:00
|
|
|
* Device Enumeration
|
2003-07-01 06:30:30 +02:00
|
|
|
*
|
|
|
|
* Copyright (C) 2002 John K. Hohm
|
|
|
|
* 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
|
|
|
*/
|
|
|
|
|
|
|
|
#include "devenum_private.h"
|
2010-12-07 14:44:19 +01:00
|
|
|
#include "rpcproxy.h"
|
2003-01-02 18:55:45 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(devenum);
|
|
|
|
|
2011-05-13 16:43:26 +02:00
|
|
|
DECLSPEC_HIDDEN LONG dll_refs;
|
2018-06-26 16:05:31 +02:00
|
|
|
static HINSTANCE devenum_instance;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllEntryPoint
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
|
|
|
|
{
|
2006-10-08 18:58:22 +02:00
|
|
|
TRACE("%p 0x%x %p\n", hinstDLL, fdwReason, fImpLoad);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
switch(fdwReason) {
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2018-06-26 16:05:31 +02:00
|
|
|
devenum_instance = hinstDLL;
|
2003-07-01 06:30:30 +02:00
|
|
|
DisableThreadLibraryCalls(hinstDLL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-06-26 16:05:30 +02:00
|
|
|
struct class_factory
|
|
|
|
{
|
|
|
|
IClassFactory IClassFactory_iface;
|
|
|
|
IUnknown *obj;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct class_factory *impl_from_IClassFactory( IClassFactory *iface )
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD( iface, struct class_factory, IClassFactory_iface );
|
|
|
|
}
|
|
|
|
|
2018-06-26 16:05:29 +02:00
|
|
|
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID iid, void **obj)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %s, %p)\n", iface, debugstr_guid(iid), obj);
|
|
|
|
|
|
|
|
if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IClassFactory))
|
|
|
|
{
|
|
|
|
IClassFactory_AddRef(iface);
|
|
|
|
*obj = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
WARN("no interface for %s\n", debugstr_guid(iid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
|
|
|
|
{
|
|
|
|
DEVENUM_LockModule();
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
|
|
|
|
{
|
|
|
|
DEVENUM_UnlockModule();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface,
|
|
|
|
IUnknown *outer, REFIID iid, void **obj)
|
|
|
|
{
|
2018-06-26 16:05:30 +02:00
|
|
|
struct class_factory *This = impl_from_IClassFactory( iface );
|
|
|
|
|
2018-06-26 16:05:29 +02:00
|
|
|
TRACE("(%p, %s, %p)\n", outer, debugstr_guid(iid), obj);
|
|
|
|
|
|
|
|
if (!obj) return E_POINTER;
|
|
|
|
|
|
|
|
if (outer) return CLASS_E_NOAGGREGATION;
|
|
|
|
|
2018-06-26 16:05:30 +02:00
|
|
|
return IUnknown_QueryInterface(This->obj, iid, obj);
|
2018-06-26 16:05:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL lock)
|
|
|
|
{
|
|
|
|
if (lock)
|
|
|
|
DEVENUM_LockModule();
|
|
|
|
else
|
|
|
|
DEVENUM_UnlockModule();
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IClassFactoryVtbl ClassFactory_vtbl = {
|
|
|
|
ClassFactory_QueryInterface,
|
|
|
|
ClassFactory_AddRef,
|
|
|
|
ClassFactory_Release,
|
|
|
|
ClassFactory_CreateInstance,
|
|
|
|
ClassFactory_LockServer
|
|
|
|
};
|
|
|
|
|
2018-06-26 16:05:30 +02:00
|
|
|
static struct class_factory create_devenum_cf = { { &ClassFactory_vtbl }, (IUnknown *)&DEVENUM_CreateDevEnum };
|
|
|
|
static struct class_factory device_moniker_cf = { { &ClassFactory_vtbl }, (IUnknown *)&DEVENUM_ParseDisplayName };
|
2018-06-26 16:05:29 +02:00
|
|
|
|
2003-07-01 06:30:30 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* DllGetClassObject (DEVENUM.@)
|
|
|
|
*/
|
2018-06-26 16:05:30 +02:00
|
|
|
HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **obj)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2018-06-26 16:05:30 +02:00
|
|
|
TRACE("(%s, %s, %p)\n", debugstr_guid(clsid), debugstr_guid(iid), obj);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2018-06-26 16:05:30 +02:00
|
|
|
*obj = NULL;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2018-06-26 16:05:30 +02:00
|
|
|
if (IsEqualGUID(clsid, &CLSID_SystemDeviceEnum))
|
|
|
|
return IClassFactory_QueryInterface(&create_devenum_cf.IClassFactory_iface, iid, obj);
|
|
|
|
else if (IsEqualGUID(clsid, &CLSID_CDeviceMoniker))
|
|
|
|
return IClassFactory_QueryInterface(&device_moniker_cf.IClassFactory_iface, iid, obj);
|
2004-12-07 15:37:11 +01:00
|
|
|
|
2018-06-26 16:05:30 +02:00
|
|
|
FIXME("class %s not available\n", debugstr_guid(clsid));
|
2003-07-01 06:30:30 +02:00
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllCanUnloadNow (DEVENUM.@)
|
|
|
|
*/
|
2005-05-17 16:41:37 +02:00
|
|
|
HRESULT WINAPI DllCanUnloadNow(void)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2004-12-07 15:37:11 +01:00
|
|
|
return dll_refs != 0 ? S_FALSE : S_OK;
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllRegisterServer (DEVENUM.@)
|
|
|
|
*/
|
2005-05-17 16:41:37 +02:00
|
|
|
HRESULT WINAPI DllRegisterServer(void)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
|
|
|
HRESULT res;
|
|
|
|
IFilterMapper2 * pMapper = NULL;
|
2003-12-30 22:52:45 +01:00
|
|
|
LPVOID mapvptr;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
2018-06-26 16:05:31 +02:00
|
|
|
res = __wine_register_resources( devenum_instance );
|
2015-01-14 11:11:21 +01:00
|
|
|
if (FAILED(res))
|
|
|
|
return res;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
res = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC,
|
2003-07-22 05:14:25 +02:00
|
|
|
&IID_IFilterMapper2, &mapvptr);
|
2003-12-30 22:52:45 +01:00
|
|
|
if (SUCCEEDED(res))
|
|
|
|
{
|
|
|
|
static const WCHAR friendlyvidcap[] = {'V','i','d','e','o',' ','C','a','p','t','u','r','e',' ','S','o','u','r','c','e','s',0};
|
|
|
|
static const WCHAR friendlydshow[] = {'D','i','r','e','c','t','S','h','o','w',' ','F','i','l','t','e','r','s',0};
|
|
|
|
static const WCHAR friendlyvidcomp[] = {'V','i','d','e','o',' ','C','o','m','p','r','e','s','s','o','r','s',0};
|
|
|
|
static const WCHAR friendlyaudcap[] = {'A','u','d','i','o',' ','C','a','p','t','u','r','e',' ','S','o','u','r','c','e','s',0};
|
|
|
|
static const WCHAR friendlyaudcomp[] = {'A','u','d','i','o',' ','C','o','m','p','r','e','s','s','o','r','s',0};
|
|
|
|
static const WCHAR friendlyaudrend[] = {'A','u','d','i','o',' ','R','e','n','d','e','r','e','r','s',0};
|
|
|
|
static const WCHAR friendlymidirend[] = {'M','i','d','i',' ','R','e','n','d','e','r','e','r','s',0};
|
|
|
|
static const WCHAR friendlyextrend[] = {'E','x','t','e','r','n','a','l',' ','R','e','n','d','e','r','e','r','s',0};
|
|
|
|
static const WCHAR friendlydevctrl[] = {'D','e','v','i','c','e',' ','C','o','n','t','r','o','l',' ','F','i','l','t','e','r','s',0};
|
|
|
|
|
2009-01-13 10:57:39 +01:00
|
|
|
pMapper = mapvptr;
|
2003-12-30 22:52:45 +01:00
|
|
|
|
|
|
|
IFilterMapper2_CreateCategory(pMapper, &CLSID_VideoInputDeviceCategory, MERIT_DO_NOT_USE, friendlyvidcap);
|
|
|
|
IFilterMapper2_CreateCategory(pMapper, &CLSID_LegacyAmFilterCategory, MERIT_NORMAL, friendlydshow);
|
|
|
|
IFilterMapper2_CreateCategory(pMapper, &CLSID_VideoCompressorCategory, MERIT_DO_NOT_USE, friendlyvidcomp);
|
|
|
|
IFilterMapper2_CreateCategory(pMapper, &CLSID_AudioInputDeviceCategory, MERIT_DO_NOT_USE, friendlyaudcap);
|
|
|
|
IFilterMapper2_CreateCategory(pMapper, &CLSID_AudioCompressorCategory, MERIT_DO_NOT_USE, friendlyaudcomp);
|
|
|
|
IFilterMapper2_CreateCategory(pMapper, &CLSID_AudioRendererCategory, MERIT_NORMAL, friendlyaudrend);
|
|
|
|
IFilterMapper2_CreateCategory(pMapper, &CLSID_MidiRendererCategory, MERIT_NORMAL, friendlymidirend);
|
|
|
|
IFilterMapper2_CreateCategory(pMapper, &CLSID_TransmitCategory, MERIT_DO_NOT_USE, friendlyextrend);
|
|
|
|
IFilterMapper2_CreateCategory(pMapper, &CLSID_DeviceControlCategory, MERIT_DO_NOT_USE, friendlydevctrl);
|
|
|
|
|
|
|
|
IFilterMapper2_Release(pMapper);
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2003-01-02 18:55:45 +01:00
|
|
|
/***********************************************************************
|
2003-07-01 06:30:30 +02:00
|
|
|
* DllUnregisterServer (DEVENUM.@)
|
2003-01-02 18:55:45 +01:00
|
|
|
*/
|
2005-05-17 16:41:37 +02:00
|
|
|
HRESULT WINAPI DllUnregisterServer(void)
|
2003-01-02 18:55:45 +01:00
|
|
|
{
|
2010-12-07 14:44:19 +01:00
|
|
|
FIXME("stub!\n");
|
2018-06-26 16:05:31 +02:00
|
|
|
return __wine_unregister_resources( devenum_instance );
|
2003-01-02 18:55:45 +01:00
|
|
|
}
|