msi/tests: Drop workarounds for Windows 2000.
[wine.git] / dlls / ddrawex / main.c
blob9fc6c2c2c79b7a852c85c29143d660528e60d602
1 /* DirectDrawEx
3 * Copyright 2006 Ulrich Czekalla
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/debug.h"
23 #define COBJMACROS
25 #include "winbase.h"
26 #include "wingdi.h"
27 #include "objbase.h"
28 #include "rpcproxy.h"
30 #include "ddraw.h"
32 #include "initguid.h"
33 #include "ddrawex_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(ddrawex);
37 static HINSTANCE instance;
39 struct ddrawex_class_factory
41 IClassFactory IClassFactory_iface;
42 LONG ref;
43 HRESULT (*pfnCreateInstance)(IUnknown *outer, REFIID iid, void **out);
46 static inline struct ddrawex_class_factory *impl_from_IClassFactory(IClassFactory *iface)
48 return CONTAINING_RECORD(iface, struct ddrawex_class_factory, IClassFactory_iface);
51 static HRESULT WINAPI ddrawex_class_factory_QueryInterface(IClassFactory *iface, REFIID riid, void **out)
53 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
55 if (IsEqualGUID(riid, &IID_IClassFactory)
56 || IsEqualGUID(riid, &IID_IUnknown))
58 IClassFactory_AddRef(iface);
59 *out = iface;
60 return S_OK;
63 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
65 *out = NULL;
66 return E_NOINTERFACE;
69 static ULONG WINAPI ddrawex_class_factory_AddRef(IClassFactory *iface)
71 struct ddrawex_class_factory *factory = impl_from_IClassFactory(iface);
72 ULONG refcount = InterlockedIncrement(&factory->ref);
74 TRACE("%p increasing refcount to %u.\n", iface, refcount);
76 return refcount;
79 static ULONG WINAPI ddrawex_class_factory_Release(IClassFactory *iface)
81 struct ddrawex_class_factory *factory = impl_from_IClassFactory(iface);
82 ULONG refcount = InterlockedDecrement(&factory->ref);
84 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
86 if (!refcount)
87 heap_free(factory);
89 return refcount;
92 static HRESULT WINAPI ddrawex_class_factory_CreateInstance(IClassFactory *iface,
93 IUnknown *outer_unknown, REFIID riid, void **out)
95 struct ddrawex_class_factory *factory = impl_from_IClassFactory(iface);
97 TRACE("iface %p, outer_unknown %p, riid %s, out %p.\n",
98 iface, outer_unknown, debugstr_guid(riid), out);
100 return factory->pfnCreateInstance(outer_unknown, riid, out);
103 static HRESULT WINAPI ddrawex_class_factory_LockServer(IClassFactory *iface, BOOL dolock)
105 FIXME("iface %p, dolock %#x stub!\n", iface, dolock);
107 return S_OK;
110 static const IClassFactoryVtbl ddrawex_class_factory_vtbl =
112 ddrawex_class_factory_QueryInterface,
113 ddrawex_class_factory_AddRef,
114 ddrawex_class_factory_Release,
115 ddrawex_class_factory_CreateInstance,
116 ddrawex_class_factory_LockServer,
119 struct ddrawex_factory
121 IDirectDrawFactory IDirectDrawFactory_iface;
122 LONG ref;
125 static inline struct ddrawex_factory *impl_from_IDirectDrawFactory(IDirectDrawFactory *iface)
127 return CONTAINING_RECORD(iface, struct ddrawex_factory, IDirectDrawFactory_iface);
130 static HRESULT WINAPI ddrawex_factory_QueryInterface(IDirectDrawFactory *iface, REFIID riid, void **out)
132 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
134 if (IsEqualGUID(riid, &IID_IDirectDrawFactory)
135 || IsEqualGUID(riid, &IID_IUnknown))
137 IDirectDrawFactory_AddRef(iface);
138 *out = iface;
139 return S_OK;
142 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
144 *out = NULL;
145 return E_NOINTERFACE;
148 static ULONG WINAPI ddrawex_factory_AddRef(IDirectDrawFactory *iface)
150 struct ddrawex_factory *factory = impl_from_IDirectDrawFactory(iface);
151 ULONG refcount = InterlockedIncrement(&factory->ref);
153 TRACE("%p increasing refcount to %u.\n", iface, refcount);
155 return refcount;
158 static ULONG WINAPI ddrawex_factory_Release(IDirectDrawFactory *iface)
160 struct ddrawex_factory *factory = impl_from_IDirectDrawFactory(iface);
161 ULONG refcount = InterlockedDecrement(&factory->ref);
163 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
165 if (!refcount)
166 heap_free(factory);
168 return refcount;
171 static HRESULT WINAPI ddrawex_factory_DirectDrawEnumerate(IDirectDrawFactory *iface,
172 LPDDENUMCALLBACKW cb, void *ctx)
174 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
176 return E_FAIL;
179 static const IDirectDrawFactoryVtbl ddrawex_factory_vtbl =
181 ddrawex_factory_QueryInterface,
182 ddrawex_factory_AddRef,
183 ddrawex_factory_Release,
184 ddrawex_factory_CreateDirectDraw,
185 ddrawex_factory_DirectDrawEnumerate,
188 static HRESULT ddrawex_factory_create(IUnknown *outer_unknown, REFIID riid, void **out)
190 struct ddrawex_factory *factory;
191 HRESULT hr;
193 TRACE("outer_unknown %p, riid %s, out %p.\n", outer_unknown, debugstr_guid(riid), out);
195 if (outer_unknown)
196 return CLASS_E_NOAGGREGATION;
198 if (!(factory = heap_alloc_zero(sizeof(*factory))))
199 return E_OUTOFMEMORY;
201 factory->IDirectDrawFactory_iface.lpVtbl = &ddrawex_factory_vtbl;
203 if (FAILED(hr = ddrawex_factory_QueryInterface(&factory->IDirectDrawFactory_iface, riid, out)))
204 heap_free(factory);
206 return hr;
209 /*******************************************************************************
210 * DllCanUnloadNow [DDRAWEX.@] Determines whether the DLL is in use.
212 HRESULT WINAPI DllCanUnloadNow(void)
214 return S_FALSE;
218 /*******************************************************************************
219 * DllGetClassObject [DDRAWEX.@]
221 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **out)
223 struct ddrawex_class_factory *factory;
225 TRACE("rclsid %s, riid %s, out %p.\n", debugstr_guid(rclsid), debugstr_guid(riid), out);
227 if (!IsEqualGUID( &IID_IClassFactory, riid)
228 && !IsEqualGUID( &IID_IUnknown, riid))
229 return E_NOINTERFACE;
231 if (!IsEqualGUID(&CLSID_DirectDrawFactory, rclsid))
233 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
234 return CLASS_E_CLASSNOTAVAILABLE;
237 if (!(factory = heap_alloc_zero(sizeof(*factory))))
238 return E_OUTOFMEMORY;
240 factory->IClassFactory_iface.lpVtbl = &ddrawex_class_factory_vtbl;
241 factory->ref = 1;
243 factory->pfnCreateInstance = ddrawex_factory_create;
245 *out = factory;
247 return S_OK;
251 /***********************************************************************
252 * DllMain
254 BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved)
256 switch (reason)
258 case DLL_PROCESS_ATTACH:
259 instance = inst;
260 DisableThreadLibraryCalls( inst );
261 break;
263 return TRUE;
266 /***********************************************************************
267 * DllRegisterServer (DDRAWEX.@)
269 HRESULT WINAPI DllRegisterServer(void)
271 return __wine_register_resources( instance );
274 /***********************************************************************
275 * DllUnregisterServer (DDRAWEX.@)
277 HRESULT WINAPI DllUnregisterServer(void)
279 return __wine_unregister_resources( instance );