ReactOS  0.4.14-dev-297-g23e575c
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__
32 static 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) {
43  case DLL_PROCESS_ATTACH:
44  devenum_instance = hinstDLL;
45  DisableThreadLibraryCalls(hinstDLL);
46  break;
47  }
48  return TRUE;
49 }
50 
52 {
55 };
56 
57 static inline struct class_factory *impl_from_IClassFactory( IClassFactory *iface )
58 {
59  return CONTAINING_RECORD( iface, struct class_factory, IClassFactory_iface );
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 {
93  struct class_factory *This = impl_from_IClassFactory( iface );
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 
113 static 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 
203  CoUninitialize();
204 
205  return res;
206 }
207 
208 /***********************************************************************
209  * DllUnregisterServer (DEVENUM.@)
210  */
212 {
213  FIXME("stub!\n");
215 }
216 
217 #ifdef __REACTOS__
218 
219 typedef HRESULT (WINAPI *DllRegisterServer_func)(void);
220 
221 /* calls DllRegisterServer() for the Quartz DLL */
222 static 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
static HINSTANCE devenum_instance
Definition: devenum_main.c:29
#define HRESULT
Definition: msvc.h:9
static void DEVENUM_UnlockModule(void)
#define REFIID
Definition: guiddef.h:118
#define TRUE
Definition: types.h:120
#define E_NOINTERFACE
Definition: winerror.h:2364
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
rwlock_t lock
Definition: tcpcore.h:1163
DECLSPEC_HIDDEN LONG dll_refs
Definition: devenum_main.c:28
HRESULT hr
Definition: shlfolder.c:183
HRESULT __wine_register_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:98
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
Definition: devenum_main.c:84
#define REFCLSID
Definition: guiddef.h:117
WINE_DEFAULT_DEBUG_CHANNEL(devenum)
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
Definition: devenum_main.c:38
#define WARN(fmt,...)
Definition: debug.h:111
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
HRESULT WINAPI DllRegisterServer(void)
Definition: devenum_main.c:153
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
static struct class_factory device_moniker_cf
Definition: devenum_main.c:122
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID iid, void **obj)
Definition: devenum_main.c:90
#define MERIT_DO_NOT_USE
Definition: precomp.h:18
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
Definition: devenum_main.c:78
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **obj)
Definition: devenum_main.c:127
#define FIXME(fmt,...)
Definition: debug.h:110
static struct class_factory * impl_from_IClassFactory(IClassFactory *iface)
Definition: devenum_main.c:57
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
static void DEVENUM_LockModule(void)
#define debugstr_guid
Definition: kernel32.h:35
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static struct class_factory create_devenum_cf
Definition: devenum_main.c:121
IUnknown * obj
Definition: devenum_main.c:54
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI DllCanUnloadNow(void)
Definition: devenum_main.c:145
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
ICreateDevEnum DEVENUM_CreateDevEnum
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:8
IParseDisplayName DEVENUM_ParseDisplayName
unsigned long DWORD
Definition: ntddk_ex.h:95
REFCLSID clsid
Definition: msctf.c:82
HRESULT __wine_unregister_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:110
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
DWORD LPVOID fImpLoad
Definition: misc.cpp:155
#define DECLSPEC_HIDDEN
Definition: precomp.h:8
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL lock)
Definition: devenum_main.c:104
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
static const IClassFactoryVtbl ClassFactory_vtbl
Definition: devenum_main.c:113
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID iid, void **obj)
Definition: devenum_main.c:62
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
GLuint res
Definition: glext.h:9613
unsigned int ULONG
Definition: retypes.h:1
IClassFactory IClassFactory_iface
Definition: devenum_main.c:53
#define GetProcAddress(x, y)
Definition: compat.h:410
HRESULT WINAPI DllUnregisterServer(void)
Definition: devenum_main.c:211
#define E_POINTER
Definition: winerror.h:2365
const GUID IID_IClassFactory
#define SUCCEEDED(hr)
Definition: intsafe.h:57