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
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(dx8vb
);
40 static HINSTANCE instance_dx8vb
;
42 BOOL WINAPI
DllMain(HINSTANCE instance
, DWORD reason
, LPVOID reserved
)
44 TRACE("(0x%p, %d, %p)\n", instance
, reason
, reserved
);
48 case DLL_WINE_PREATTACH
:
49 return FALSE
; /* prefer native version */
50 case DLL_PROCESS_ATTACH
:
51 DisableThreadLibraryCalls(instance
);
52 instance_dx8vb
= instance
;
60 IClassFactory IClassFactory_iface
;
63 HRESULT (*pfnCreateInstance
)(IUnknown
*unk_outer
, void **ppobj
);
66 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
68 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
71 struct object_creation_info
74 HRESULT (*pfnCreateInstance
)(IUnknown
*unk_outer
, void **ppobj
);
77 static const struct object_creation_info object_creation
[] =
82 static HRESULT WINAPI
classfactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppobj
)
84 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
86 if (IsEqualGUID(riid
, &IID_IUnknown
)
87 || IsEqualGUID(riid
, &IID_IClassFactory
))
89 IClassFactory_AddRef(iface
);
90 *ppobj
= &This
->IClassFactory_iface
;
94 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
98 static ULONG WINAPI
classfactory_AddRef(IClassFactory
*iface
)
100 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
101 return InterlockedIncrement(&This
->ref
);
104 static ULONG WINAPI
classfactory_Release(IClassFactory
*iface
)
106 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
107 ULONG ref
= InterlockedDecrement(&This
->ref
);
110 HeapFree(GetProcessHeap(), 0, This
);
115 static HRESULT WINAPI
classfactory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer_unk
, REFIID riid
, void **ppobj
)
117 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
121 TRACE("(%p)->(%p,%s,%p)\n", This
, outer_unk
, debugstr_guid(riid
), ppobj
);
124 hres
= This
->pfnCreateInstance(outer_unk
, (void **) &unk
);
127 hres
= IUnknown_QueryInterface(unk
, riid
, ppobj
);
128 IUnknown_Release(unk
);
133 static HRESULT WINAPI
classfactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
135 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
136 FIXME("(%p)->(%d), stub!\n", This
, dolock
);
140 static const IClassFactoryVtbl classfactory_Vtbl
=
142 classfactory_QueryInterface
,
144 classfactory_Release
,
145 classfactory_CreateInstance
,
146 classfactory_LockServer
149 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, void **ppv
)
152 IClassFactoryImpl
*factory
;
154 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
156 if (!IsEqualGUID(&IID_IClassFactory
, riid
)
157 && !IsEqualGUID( &IID_IUnknown
, riid
))
158 return E_NOINTERFACE
;
160 for (i
= 0; i
< ARRAY_SIZE(object_creation
); i
++)
162 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
166 if (i
== ARRAY_SIZE(object_creation
))
168 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
169 return CLASS_E_CLASSNOTAVAILABLE
;
172 factory
= HeapAlloc(GetProcessHeap(), 0, sizeof(*factory
));
174 return E_OUTOFMEMORY
;
176 factory
->IClassFactory_iface
.lpVtbl
= &classfactory_Vtbl
;
179 factory
->pfnCreateInstance
= object_creation
[i
].pfnCreateInstance
;
181 *ppv
= &factory
->IClassFactory_iface
;
185 HRESULT WINAPI
DllCanUnloadNow(void)
190 HRESULT WINAPI
DllRegisterServer(void)
192 return __wine_register_resources(instance_dx8vb
);
195 HRESULT WINAPI
DllUnregisterServer(void)
197 return __wine_unregister_resources(instance_dx8vb
);