d3d11: Use wined3d_device_context_draw().
[wine.git] / dlls / dx8vb / main.c
blob4784c84e20392f2a36ff77c1c30931f24a04ec6a
1 /*
2 * Copyright 2017 Fabian Maurer
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
22 #include <stdarg.h>
23 #include <string.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "winreg.h"
30 #include "ole2.h"
31 #include "rpcproxy.h"
33 #include "unknwn.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(dx8vb);
39 static HINSTANCE instance_dx8vb;
41 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
43 TRACE("(0x%p, %d, %p)\n", instance, reason, reserved);
45 switch (reason)
47 case DLL_PROCESS_ATTACH:
48 DisableThreadLibraryCalls(instance);
49 instance_dx8vb = instance;
50 break;
53 return TRUE;
56 typedef struct {
57 IClassFactory IClassFactory_iface;
59 LONG ref;
60 HRESULT (*pfnCreateInstance)(IUnknown *unk_outer, void **ppobj);
61 } IClassFactoryImpl;
63 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
65 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
68 struct object_creation_info
70 const CLSID *clsid;
71 HRESULT (*pfnCreateInstance)(IUnknown *unk_outer, void **ppobj);
74 static const struct object_creation_info object_creation[] =
76 { &GUID_NULL, 0 },
79 static HRESULT WINAPI classfactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
81 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
83 if (IsEqualGUID(riid, &IID_IUnknown)
84 || IsEqualGUID(riid, &IID_IClassFactory))
86 IClassFactory_AddRef(iface);
87 *ppobj = &This->IClassFactory_iface;
88 return S_OK;
91 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
92 return E_NOINTERFACE;
95 static ULONG WINAPI classfactory_AddRef(IClassFactory *iface)
97 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
98 return InterlockedIncrement(&This->ref);
101 static ULONG WINAPI classfactory_Release(IClassFactory *iface)
103 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
104 ULONG ref = InterlockedDecrement(&This->ref);
106 if (ref == 0)
107 HeapFree(GetProcessHeap(), 0, This);
109 return ref;
112 static HRESULT WINAPI classfactory_CreateInstance(IClassFactory *iface, IUnknown *outer_unk, REFIID riid, void **ppobj)
114 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
115 HRESULT hres;
116 IUnknown *unk;
118 TRACE("(%p)->(%p,%s,%p)\n", This, outer_unk, debugstr_guid(riid), ppobj);
120 *ppobj = NULL;
121 hres = This->pfnCreateInstance(outer_unk, (void **) &unk);
122 if (SUCCEEDED(hres))
124 hres = IUnknown_QueryInterface(unk, riid, ppobj);
125 IUnknown_Release(unk);
127 return hres;
130 static HRESULT WINAPI classfactory_LockServer(IClassFactory *iface, BOOL dolock)
132 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
133 FIXME("(%p)->(%d), stub!\n", This, dolock);
134 return S_OK;
137 static const IClassFactoryVtbl classfactory_Vtbl =
139 classfactory_QueryInterface,
140 classfactory_AddRef,
141 classfactory_Release,
142 classfactory_CreateInstance,
143 classfactory_LockServer
146 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv)
148 unsigned int i;
149 IClassFactoryImpl *factory;
151 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
153 if (!IsEqualGUID(&IID_IClassFactory, riid)
154 && !IsEqualGUID( &IID_IUnknown, riid))
155 return E_NOINTERFACE;
157 for (i = 0; i < ARRAY_SIZE(object_creation); i++)
159 if (IsEqualGUID(object_creation[i].clsid, rclsid))
160 break;
163 if (i == ARRAY_SIZE(object_creation))
165 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
166 return CLASS_E_CLASSNOTAVAILABLE;
169 factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
170 if (factory == NULL)
171 return E_OUTOFMEMORY;
173 factory->IClassFactory_iface.lpVtbl = &classfactory_Vtbl;
174 factory->ref = 1;
176 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
178 *ppv = &factory->IClassFactory_iface;
179 return S_OK;
182 HRESULT WINAPI DllCanUnloadNow(void)
184 return S_FALSE;
187 HRESULT WINAPI DllRegisterServer(void)
189 return __wine_register_resources(instance_dx8vb);
192 HRESULT WINAPI DllUnregisterServer(void)
194 return __wine_unregister_resources(instance_dx8vb);