For all DLLs with defined DllMain and which do not require
[wine/wine-kai.git] / dlls / quartz / main.c
blob68e63b7ec3f7be8da8fdfb4d00dc23e0de112233
1 /* DirectShow Base Functions (QUARTZ.DLL)
3 * Copyright 2002 Lionel Ulmer
5 * This file contains the (internal) driver registration functions,
6 * driver enumeration APIs and DirectDraw creation functions.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "config.h"
24 #include "wine/debug.h"
26 #include "quartz_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
30 static DWORD dll_ref = 0;
32 /* For the moment, do nothing here. */
33 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
35 switch(fdwReason) {
36 case DLL_PROCESS_ATTACH:
37 DisableThreadLibraryCalls(hInstDLL);
38 break;
39 case DLL_PROCESS_DETACH:
40 break;
42 return TRUE;
45 /******************************************************************************
46 * DirectShow ClassFactory
48 typedef struct {
49 IClassFactory ITF_IClassFactory;
51 DWORD ref;
52 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
53 } IClassFactoryImpl;
55 struct object_creation_info
57 const CLSID *clsid;
58 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
61 static const struct object_creation_info object_creation[] =
63 { &CLSID_FilterGraph, FILTERGRAPH_create },
66 static HRESULT WINAPI
67 DSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
69 ICOM_THIS(IClassFactoryImpl,iface);
71 if (IsEqualGUID(riid, &IID_IUnknown)
72 || IsEqualGUID(riid, &IID_IClassFactory))
74 IClassFactory_AddRef(iface);
75 *ppobj = This;
76 return S_OK;
79 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
80 return E_NOINTERFACE;
83 static ULONG WINAPI DSCF_AddRef(LPCLASSFACTORY iface) {
84 ICOM_THIS(IClassFactoryImpl,iface);
85 return ++(This->ref);
88 static ULONG WINAPI DSCF_Release(LPCLASSFACTORY iface) {
89 ICOM_THIS(IClassFactoryImpl,iface);
91 ULONG ref = --This->ref;
93 if (ref == 0)
94 HeapFree(GetProcessHeap(), 0, This);
96 return ref;
100 static HRESULT WINAPI DSCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
101 REFIID riid, LPVOID *ppobj) {
102 ICOM_THIS(IClassFactoryImpl,iface);
103 HRESULT hres;
104 LPUNKNOWN punk;
106 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
108 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
109 if (FAILED(hres)) {
110 *ppobj = NULL;
111 return hres;
113 hres = IUnknown_QueryInterface(punk, riid, ppobj);
114 if (FAILED(hres)) {
115 *ppobj = NULL;
116 return hres;
118 IUnknown_Release(punk);
119 return hres;
122 static HRESULT WINAPI DSCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
123 ICOM_THIS(IClassFactoryImpl,iface);
124 FIXME("(%p)->(%d),stub!\n",This,dolock);
125 return S_OK;
128 static ICOM_VTABLE(IClassFactory) DSCF_Vtbl =
130 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
131 DSCF_QueryInterface,
132 DSCF_AddRef,
133 DSCF_Release,
134 DSCF_CreateInstance,
135 DSCF_LockServer
138 /*******************************************************************************
139 * DllGetClassObject [QUARTZ.@]
140 * Retrieves class object from a DLL object
142 * NOTES
143 * Docs say returns STDAPI
145 * PARAMS
146 * rclsid [I] CLSID for the class object
147 * riid [I] Reference to identifier of interface for class object
148 * ppv [O] Address of variable to receive interface pointer for riid
150 * RETURNS
151 * Success: S_OK
152 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
153 * E_UNEXPECTED
155 DWORD WINAPI QUARTZ_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
157 int i;
158 IClassFactoryImpl *factory;
160 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
162 if ( !IsEqualGUID( &IID_IClassFactory, riid )
163 && ! IsEqualGUID( &IID_IUnknown, riid) )
164 return E_NOINTERFACE;
166 for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
168 if (IsEqualGUID(object_creation[i].clsid, rclsid))
169 break;
172 if (i == sizeof(object_creation)/sizeof(object_creation[0]))
174 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
175 return CLASS_E_CLASSNOTAVAILABLE;
178 factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
179 if (factory == NULL) return E_OUTOFMEMORY;
181 factory->ITF_IClassFactory.lpVtbl = &DSCF_Vtbl;
182 factory->ref = 1;
184 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
186 *ppv = &(factory->ITF_IClassFactory);
187 return S_OK;
190 /***********************************************************************
191 * DllRegisterServer (QUARTZ.@)
193 HRESULT WINAPI QUARTZ_DllRegisterServer()
195 FIXME("(): stub\n");
196 return 0;
199 /***********************************************************************
200 * DllCanUnloadNow (QUARTZ.@)
202 HRESULT WINAPI QUARTZ_DllCanUnloadNow()
204 return dll_ref != 0 ? S_FALSE : S_OK;