ReactOS 0.4.15-dev-7788-g1ad9096
devenum_main.c
Go to the documentation of this file.
1/*
2 * Device Enumeration
3 *
4 * Copyright (C) 2002 John K. Hohm
5 * Copyright (C) 2002 Robert Shearman
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22#include "devenum_private.h"
23#include "rpcproxy.h"
24#include "wine/debug.h"
25
27
30
31#ifdef __REACTOS__
32static void DEVENUM_RegisterQuartz(void);
33#endif
34
35/***********************************************************************
36 * DllEntryPoint
37 */
39{
40 TRACE("%p 0x%x %p\n", hinstDLL, fdwReason, fImpLoad);
41
42 switch(fdwReason) {
44 devenum_instance = hinstDLL;
46 break;
47 }
48 return TRUE;
49}
50
52{
55};
56
58{
60}
61
63{
64 TRACE("(%p, %s, %p)\n", iface, debugstr_guid(iid), obj);
65
67 {
68 IClassFactory_AddRef(iface);
69 *obj = iface;
70 return S_OK;
71 }
72
73 *obj = NULL;
74 WARN("no interface for %s\n", debugstr_guid(iid));
75 return E_NOINTERFACE;
76}
77
79{
81 return 2;
82}
83
85{
87 return 1;
88}
89
91 IUnknown *outer, REFIID iid, void **obj)
92{
94
95 TRACE("(%p, %s, %p)\n", outer, debugstr_guid(iid), obj);
96
97 if (!obj) return E_POINTER;
98
99 if (outer) return CLASS_E_NOAGGREGATION;
100
101 return IUnknown_QueryInterface(This->obj, iid, obj);
102}
103
105{
106 if (lock)
108 else
110 return S_OK;
111}
112
113static const IClassFactoryVtbl ClassFactory_vtbl = {
119};
120
123
124/***********************************************************************
125 * DllGetClassObject (DEVENUM.@)
126 */
128{
129 TRACE("(%s, %s, %p)\n", debugstr_guid(clsid), debugstr_guid(iid), obj);
130
131 *obj = NULL;
132
133 if (IsEqualGUID(clsid, &CLSID_SystemDeviceEnum))
134 return IClassFactory_QueryInterface(&create_devenum_cf.IClassFactory_iface, iid, obj);
135 else if (IsEqualGUID(clsid, &CLSID_CDeviceMoniker))
136 return IClassFactory_QueryInterface(&device_moniker_cf.IClassFactory_iface, iid, obj);
137
138 FIXME("class %s not available\n", debugstr_guid(clsid));
140}
141
142/***********************************************************************
143 * DllCanUnloadNow (DEVENUM.@)
144 */
146{
147 return dll_refs != 0 ? S_FALSE : S_OK;
148}
149
150/***********************************************************************
151 * DllRegisterServer (DEVENUM.@)
152 */
154{
155 HRESULT res;
156 IFilterMapper2 * pMapper = NULL;
157 LPVOID mapvptr;
158
159 TRACE("\n");
160
162 if (FAILED(res))
163 return res;
164
165#ifdef __REACTOS__
166 /* Quartz is needed for IFilterMapper2 */
167 DEVENUM_RegisterQuartz();
168#endif
169
170/*** ActiveMovieFilter Categories ***/
171
173
174 res = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC,
175 &IID_IFilterMapper2, &mapvptr);
176 if (SUCCEEDED(res))
177 {
178 static const WCHAR friendlyvidcap[] = {'V','i','d','e','o',' ','C','a','p','t','u','r','e',' ','S','o','u','r','c','e','s',0};
179 static const WCHAR friendlydshow[] = {'D','i','r','e','c','t','S','h','o','w',' ','F','i','l','t','e','r','s',0};
180 static const WCHAR friendlyvidcomp[] = {'V','i','d','e','o',' ','C','o','m','p','r','e','s','s','o','r','s',0};
181 static const WCHAR friendlyaudcap[] = {'A','u','d','i','o',' ','C','a','p','t','u','r','e',' ','S','o','u','r','c','e','s',0};
182 static const WCHAR friendlyaudcomp[] = {'A','u','d','i','o',' ','C','o','m','p','r','e','s','s','o','r','s',0};
183 static const WCHAR friendlyaudrend[] = {'A','u','d','i','o',' ','R','e','n','d','e','r','e','r','s',0};
184 static const WCHAR friendlymidirend[] = {'M','i','d','i',' ','R','e','n','d','e','r','e','r','s',0};
185 static const WCHAR friendlyextrend[] = {'E','x','t','e','r','n','a','l',' ','R','e','n','d','e','r','e','r','s',0};
186 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};
187
188 pMapper = mapvptr;
189
190 IFilterMapper2_CreateCategory(pMapper, &CLSID_VideoInputDeviceCategory, MERIT_DO_NOT_USE, friendlyvidcap);
191 IFilterMapper2_CreateCategory(pMapper, &CLSID_LegacyAmFilterCategory, MERIT_NORMAL, friendlydshow);
192 IFilterMapper2_CreateCategory(pMapper, &CLSID_VideoCompressorCategory, MERIT_DO_NOT_USE, friendlyvidcomp);
193 IFilterMapper2_CreateCategory(pMapper, &CLSID_AudioInputDeviceCategory, MERIT_DO_NOT_USE, friendlyaudcap);
194 IFilterMapper2_CreateCategory(pMapper, &CLSID_AudioCompressorCategory, MERIT_DO_NOT_USE, friendlyaudcomp);
195 IFilterMapper2_CreateCategory(pMapper, &CLSID_AudioRendererCategory, MERIT_NORMAL, friendlyaudrend);
196 IFilterMapper2_CreateCategory(pMapper, &CLSID_MidiRendererCategory, MERIT_NORMAL, friendlymidirend);
197 IFilterMapper2_CreateCategory(pMapper, &CLSID_TransmitCategory, MERIT_DO_NOT_USE, friendlyextrend);
198 IFilterMapper2_CreateCategory(pMapper, &CLSID_DeviceControlCategory, MERIT_DO_NOT_USE, friendlydevctrl);
199
200 IFilterMapper2_Release(pMapper);
201 }
202
204
205 return res;
206}
207
208/***********************************************************************
209 * DllUnregisterServer (DEVENUM.@)
210 */
212{
213 FIXME("stub!\n");
215}
216
217#ifdef __REACTOS__
218
219typedef HRESULT (WINAPI *DllRegisterServer_func)(void);
220
221/* calls DllRegisterServer() for the Quartz DLL */
222static void DEVENUM_RegisterQuartz(void)
223{
224 HANDLE hDLL = LoadLibraryA("quartz.dll");
225 DllRegisterServer_func pDllRegisterServer = NULL;
226 if (hDLL)
227 pDllRegisterServer = (DllRegisterServer_func)GetProcAddress(hDLL, "DllRegisterServer");
228 if (pDllRegisterServer)
229 {
230 HRESULT hr = pDllRegisterServer();
231 if (FAILED(hr))
232 ERR("Failed to register Quartz. Error was 0x%x)\n", hr);
233 }
234}
235
236#endif
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
DWORD LPVOID fImpLoad
Definition: misc.cpp:155
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define FIXME(fmt,...)
Definition: debug.h:111
#define WARN(fmt,...)
Definition: debug.h:112
#define ERR(fmt,...)
Definition: debug.h:110
ICreateDevEnum DEVENUM_CreateDevEnum
static HINSTANCE devenum_instance
Definition: devenum_main.c:29
HRESULT WINAPI DllRegisterServer(void)
Definition: devenum_main.c:153
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
Definition: devenum_main.c:38
static const IClassFactoryVtbl ClassFactory_vtbl
Definition: devenum_main.c:113
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
Definition: devenum_main.c:84
HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **obj)
Definition: devenum_main.c:127
static struct class_factory create_devenum_cf
Definition: devenum_main.c:121
HRESULT WINAPI DllUnregisterServer(void)
Definition: devenum_main.c:211
static struct class_factory device_moniker_cf
Definition: devenum_main.c:122
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
Definition: devenum_main.c:78
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL lock)
Definition: devenum_main.c:104
HRESULT WINAPI DllCanUnloadNow(void)
Definition: devenum_main.c:145
static struct class_factory * impl_from_IClassFactory(IClassFactory *iface)
Definition: devenum_main.c:57
DECLSPEC_HIDDEN LONG dll_refs
Definition: devenum_main.c:28
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID iid, void **obj)
Definition: devenum_main.c:62
static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID iid, void **obj)
Definition: devenum_main.c:90
static void DEVENUM_UnlockModule(void)
static void DEVENUM_LockModule(void)
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define DECLSPEC_HIDDEN
Definition: precomp.h:8
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define GetProcAddress(x, y)
Definition: compat.h:753
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define MERIT_DO_NOT_USE
Definition: precomp.h:18
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_guid
Definition: kernel32.h:35
REFCLSID clsid
Definition: msctf.c:82
IParseDisplayName DEVENUM_ParseDisplayName
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
HRESULT __wine_unregister_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:110
HRESULT __wine_register_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:98
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
IUnknown * obj
Definition: devenum_main.c:54
IClassFactory IClassFactory_iface
Definition: devenum_main.c:53
rwlock_t lock
Definition: tcpcore.h:0
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define E_NOINTERFACE
Definition: winerror.h:2364
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
#define E_POINTER
Definition: winerror.h:2365
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
__wchar_t WCHAR
Definition: xmlstorage.h:180