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
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
);
47 case DLL_WINE_PREATTACH
:
48 return FALSE
; /* prefer native version */
49 case DLL_PROCESS_ATTACH
:
50 DisableThreadLibraryCalls(instance
);
51 instance_dx8vb
= instance
;
59 IClassFactory IClassFactory_iface
;
62 HRESULT (*pfnCreateInstance
)(IUnknown
*unk_outer
, void **ppobj
);
65 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
67 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
70 struct object_creation_info
73 HRESULT (*pfnCreateInstance
)(IUnknown
*unk_outer
, void **ppobj
);
76 static const struct object_creation_info object_creation
[] =
81 static HRESULT WINAPI
classfactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppobj
)
83 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
85 if (IsEqualGUID(riid
, &IID_IUnknown
)
86 || IsEqualGUID(riid
, &IID_IClassFactory
))
88 IClassFactory_AddRef(iface
);
89 *ppobj
= &This
->IClassFactory_iface
;
93 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
97 static ULONG WINAPI
classfactory_AddRef(IClassFactory
*iface
)
99 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
100 return InterlockedIncrement(&This
->ref
);
103 static ULONG WINAPI
classfactory_Release(IClassFactory
*iface
)
105 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
106 ULONG ref
= InterlockedDecrement(&This
->ref
);
109 HeapFree(GetProcessHeap(), 0, This
);
114 static HRESULT WINAPI
classfactory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer_unk
, REFIID riid
, void **ppobj
)
116 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
120 TRACE("(%p)->(%p,%s,%p)\n", This
, outer_unk
, debugstr_guid(riid
), ppobj
);
123 hres
= This
->pfnCreateInstance(outer_unk
, (void **) &unk
);
126 hres
= IUnknown_QueryInterface(unk
, riid
, ppobj
);
127 IUnknown_Release(unk
);
132 static HRESULT WINAPI
classfactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
134 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
135 FIXME("(%p)->(%d), stub!\n", This
, dolock
);
139 static const IClassFactoryVtbl classfactory_Vtbl
=
141 classfactory_QueryInterface
,
143 classfactory_Release
,
144 classfactory_CreateInstance
,
145 classfactory_LockServer
148 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, void **ppv
)
151 IClassFactoryImpl
*factory
;
153 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
155 if (!IsEqualGUID(&IID_IClassFactory
, riid
)
156 && !IsEqualGUID( &IID_IUnknown
, riid
))
157 return E_NOINTERFACE
;
159 for (i
= 0; i
< ARRAY_SIZE(object_creation
); i
++)
161 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
165 if (i
== ARRAY_SIZE(object_creation
))
167 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
168 return CLASS_E_CLASSNOTAVAILABLE
;
171 factory
= HeapAlloc(GetProcessHeap(), 0, sizeof(*factory
));
173 return E_OUTOFMEMORY
;
175 factory
->IClassFactory_iface
.lpVtbl
= &classfactory_Vtbl
;
178 factory
->pfnCreateInstance
= object_creation
[i
].pfnCreateInstance
;
180 *ppv
= &factory
->IClassFactory_iface
;
184 HRESULT WINAPI
DllCanUnloadNow(void)
189 HRESULT WINAPI
DllRegisterServer(void)
191 return __wine_register_resources(instance_dx8vb
);
194 HRESULT WINAPI
DllUnregisterServer(void)
196 return __wine_unregister_resources(instance_dx8vb
);