3 * Copyright 2006 Ulrich Czekalla
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/debug.h"
36 #include "ddrawex_private.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(ddrawex
);
40 static HINSTANCE instance
;
42 /*******************************************************************************
43 * IDirectDrawClassFactory::QueryInterface
45 *******************************************************************************/
47 IDirectDrawClassFactoryImpl_QueryInterface(IClassFactory
*iface
,
51 IClassFactoryImpl
*This
= (IClassFactoryImpl
*) iface
;
53 TRACE("(%p)->(%s,%p)\n", This
, debugstr_guid(riid
), obj
);
55 if (IsEqualGUID(riid
, &IID_IUnknown
)
56 || IsEqualGUID(riid
, &IID_IClassFactory
))
58 IClassFactory_AddRef(iface
);
63 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),obj
);
67 /*******************************************************************************
68 * IDirectDrawClassFactory::AddRef
70 *******************************************************************************/
72 IDirectDrawClassFactoryImpl_AddRef(IClassFactory
*iface
)
74 IClassFactoryImpl
*This
= (IClassFactoryImpl
*) iface
;
75 ULONG ref
= InterlockedIncrement(&This
->ref
);
77 TRACE("(%p)->() incrementing from %d.\n", This
, ref
- 1);
82 /*******************************************************************************
83 * IDirectDrawClassFactory::Release
85 *******************************************************************************/
87 IDirectDrawClassFactoryImpl_Release(IClassFactory
*iface
)
89 IClassFactoryImpl
*This
= (IClassFactoryImpl
*) iface
;
90 ULONG ref
= InterlockedDecrement(&This
->ref
);
91 TRACE("(%p)->() decrementing from %d.\n", This
, ref
+1);
94 HeapFree(GetProcessHeap(), 0, This
);
100 /*******************************************************************************
101 * IDirectDrawClassFactory::CreateInstance
103 *******************************************************************************/
104 static HRESULT WINAPI
105 IDirectDrawClassFactoryImpl_CreateInstance(IClassFactory
*iface
,
110 IClassFactoryImpl
*This
= (IClassFactoryImpl
*) iface
;
112 TRACE("(%p)->(%p,%s,%p)\n",This
,UnkOuter
,debugstr_guid(riid
),obj
);
114 return This
->pfnCreateInstance(UnkOuter
, riid
, obj
);
117 /*******************************************************************************
118 * IDirectDrawClassFactory::LockServer
120 *******************************************************************************/
121 static HRESULT WINAPI
122 IDirectDrawClassFactoryImpl_LockServer(IClassFactory
*iface
,BOOL dolock
)
124 IClassFactoryImpl
*This
= (IClassFactoryImpl
*) iface
;
125 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
130 /*******************************************************************************
131 * The class factory VTable
132 *******************************************************************************/
133 static const IClassFactoryVtbl IClassFactory_Vtbl
=
135 IDirectDrawClassFactoryImpl_QueryInterface
,
136 IDirectDrawClassFactoryImpl_AddRef
,
137 IDirectDrawClassFactoryImpl_Release
,
138 IDirectDrawClassFactoryImpl_CreateInstance
,
139 IDirectDrawClassFactoryImpl_LockServer
143 /*******************************************************************************
144 * IDirectDrawFactory::QueryInterface
146 *******************************************************************************/
147 static HRESULT WINAPI
148 IDirectDrawFactoryImpl_QueryInterface(IDirectDrawFactory
*iface
,
152 IDirectDrawFactoryImpl
*This
= (IDirectDrawFactoryImpl
*) iface
;
154 TRACE("(%p)->(%s,%p)\n", This
, debugstr_guid(riid
), obj
);
156 if (IsEqualGUID(riid
, &IID_IUnknown
)
157 || IsEqualGUID(riid
, &IID_IDirectDrawFactory
))
159 IDirectDrawFactory_AddRef(iface
);
164 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),obj
);
165 return E_NOINTERFACE
;
168 /*******************************************************************************
169 * IDirectDrawFactory::AddRef
171 *******************************************************************************/
173 IDirectDrawFactoryImpl_AddRef(IDirectDrawFactory
*iface
)
175 IDirectDrawFactoryImpl
*This
= (IDirectDrawFactoryImpl
*) iface
;
176 ULONG ref
= InterlockedIncrement(&This
->ref
);
178 TRACE("(%p)->() incrementing from %d.\n", This
, ref
- 1);
183 /*******************************************************************************
184 * IDirectDrawFactory::Release
186 *******************************************************************************/
188 IDirectDrawFactoryImpl_Release(IDirectDrawFactory
*iface
)
190 IDirectDrawFactoryImpl
*This
= (IDirectDrawFactoryImpl
*) iface
;
191 ULONG ref
= InterlockedDecrement(&This
->ref
);
192 TRACE("(%p)->() decrementing from %d.\n", This
, ref
+1);
195 HeapFree(GetProcessHeap(), 0, This
);
200 /*******************************************************************************
201 * IDirectDrawFactoryImpl_DirectDrawEnumerate
202 *******************************************************************************/
203 static HRESULT WINAPI
204 IDirectDrawFactoryImpl_DirectDrawEnumerate(IDirectDrawFactory
* iface
,
205 LPDDENUMCALLBACKW lpCallback
,
213 /*******************************************************************************
214 * Direct Draw Factory VTable
215 *******************************************************************************/
216 static const IDirectDrawFactoryVtbl IDirectDrawFactory_Vtbl
=
218 IDirectDrawFactoryImpl_QueryInterface
,
219 IDirectDrawFactoryImpl_AddRef
,
220 IDirectDrawFactoryImpl_Release
,
221 IDirectDrawFactoryImpl_CreateDirectDraw
,
222 IDirectDrawFactoryImpl_DirectDrawEnumerate
,
225 /***********************************************************************
226 * CreateDirectDrawFactory
228 ***********************************************************************/
230 CreateDirectDrawFactory(IUnknown
* UnkOuter
, REFIID iid
, void **obj
)
233 IDirectDrawFactoryImpl
*This
= NULL
;
235 TRACE("(%p,%s,%p)\n", UnkOuter
, debugstr_guid(iid
), obj
);
237 if (UnkOuter
!= NULL
)
238 return CLASS_E_NOAGGREGATION
;
240 This
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectDrawFactoryImpl
));
244 ERR("Out of memory when creating DirectDraw\n");
245 return E_OUTOFMEMORY
;
248 This
->lpVtbl
= &IDirectDrawFactory_Vtbl
;
250 hr
= IDirectDrawFactory_QueryInterface((IDirectDrawFactory
*)This
, iid
, obj
);
253 HeapFree(GetProcessHeap(), 0, This
);
259 /*******************************************************************************
260 * DllCanUnloadNow [DDRAWEX.@] Determines whether the DLL is in use.
262 HRESULT WINAPI
DllCanUnloadNow(void)
268 /*******************************************************************************
269 * DllGetClassObject [DDRAWEX.@]
271 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
273 IClassFactoryImpl
*factory
;
275 TRACE("ddrawex (%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
277 if (!IsEqualGUID( &IID_IClassFactory
, riid
)
278 && !IsEqualGUID( &IID_IUnknown
, riid
))
279 return E_NOINTERFACE
;
281 if (!IsEqualGUID(&CLSID_DirectDrawFactory
, rclsid
))
283 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
284 return CLASS_E_CLASSNOTAVAILABLE
;
287 factory
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*factory
));
288 if (factory
== NULL
) return E_OUTOFMEMORY
;
290 factory
->lpVtbl
= &IClassFactory_Vtbl
;
293 factory
->pfnCreateInstance
= CreateDirectDrawFactory
;
301 /***********************************************************************
304 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD reason
, LPVOID lpv
)
308 case DLL_PROCESS_ATTACH
:
310 DisableThreadLibraryCalls( hInstDLL
);
316 /***********************************************************************
317 * DllRegisterServer (DDRAWEX.@)
319 HRESULT WINAPI
DllRegisterServer(void)
321 return __wine_register_resources( instance
, NULL
);
324 /***********************************************************************
325 * DllUnregisterServer (DDRAWEX.@)
327 HRESULT WINAPI
DllUnregisterServer(void)
329 return __wine_unregister_resources( instance
, NULL
);