user32: Don't paint new button styles instead of crashing.
[wine/multimedia.git] / dlls / mscoree / corruntimehost.c
blob831f6de87c8581a5d7b63858332427b536f97fea
1 /*
3 * Copyright 2008 Alistair Leslie-Hughes
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
20 #define COBJMACROS
22 #include <stdarg.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "winreg.h"
28 #include "ole2.h"
30 #include "cor.h"
31 #include "mscoree.h"
32 #include "metahost.h"
33 #include "mscoree_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL( mscoree );
39 struct RuntimeHost
41 const struct ICorRuntimeHostVtbl *lpVtbl;
42 const CLRRuntimeInfo *version;
43 const loaded_mono *mono;
44 LONG ref;
45 BOOL legacy; /* if True, this was created by create_corruntimehost, and Release frees it */
48 static inline RuntimeHost *impl_from_ICorRuntimeHost( ICorRuntimeHost *iface )
50 return (RuntimeHost *)((char*)iface - FIELD_OFFSET(RuntimeHost, lpVtbl));
53 /*** IUnknown methods ***/
54 static HRESULT WINAPI corruntimehost_QueryInterface(ICorRuntimeHost* iface,
55 REFIID riid,
56 void **ppvObject)
58 RuntimeHost *This = impl_from_ICorRuntimeHost( iface );
59 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
61 if ( IsEqualGUID( riid, &IID_ICorRuntimeHost ) ||
62 IsEqualGUID( riid, &IID_IUnknown ) )
64 *ppvObject = iface;
66 else
68 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
69 return E_NOINTERFACE;
72 ICorRuntimeHost_AddRef( iface );
74 return S_OK;
77 static ULONG WINAPI corruntimehost_AddRef(ICorRuntimeHost* iface)
79 RuntimeHost *This = impl_from_ICorRuntimeHost( iface );
80 return InterlockedIncrement( &This->ref );
83 static ULONG WINAPI corruntimehost_Release(ICorRuntimeHost* iface)
85 RuntimeHost *This = impl_from_ICorRuntimeHost( iface );
86 ULONG ref;
88 ref = InterlockedDecrement( &This->ref );
89 if ( ref == 0 && This->legacy )
91 RuntimeHost_Destroy(This);
94 return ref;
97 /*** ICorRuntimeHost methods ***/
98 static HRESULT WINAPI corruntimehost_CreateLogicalThreadState(
99 ICorRuntimeHost* iface)
101 FIXME("stub %p\n", iface);
102 return E_NOTIMPL;
105 static HRESULT WINAPI corruntimehost_DeleteLogicalThreadState(
106 ICorRuntimeHost* iface)
108 FIXME("stub %p\n", iface);
109 return E_NOTIMPL;
112 static HRESULT WINAPI corruntimehost_SwitchInLogicalThreadState(
113 ICorRuntimeHost* iface,
114 DWORD *fiberCookie)
116 FIXME("stub %p\n", iface);
117 return E_NOTIMPL;
120 static HRESULT WINAPI corruntimehost_SwitchOutLogicalThreadState(
121 ICorRuntimeHost* iface,
122 DWORD **fiberCookie)
124 FIXME("stub %p\n", iface);
125 return E_NOTIMPL;
128 static HRESULT WINAPI corruntimehost_LocksHeldByLogicalThread(
129 ICorRuntimeHost* iface,
130 DWORD *pCount)
132 FIXME("stub %p\n", iface);
133 return E_NOTIMPL;
136 static HRESULT WINAPI corruntimehost_MapFile(
137 ICorRuntimeHost* iface,
138 HANDLE hFile,
139 HMODULE *mapAddress)
141 FIXME("stub %p\n", iface);
142 return E_NOTIMPL;
145 static HRESULT WINAPI corruntimehost_GetConfiguration(
146 ICorRuntimeHost* iface,
147 ICorConfiguration **pConfiguration)
149 FIXME("stub %p\n", iface);
150 return E_NOTIMPL;
153 static HRESULT WINAPI corruntimehost_Start(
154 ICorRuntimeHost* iface)
156 FIXME("stub %p\n", iface);
157 return E_NOTIMPL;
160 static HRESULT WINAPI corruntimehost_Stop(
161 ICorRuntimeHost* iface)
163 FIXME("stub %p\n", iface);
164 return E_NOTIMPL;
167 static HRESULT WINAPI corruntimehost_CreateDomain(
168 ICorRuntimeHost* iface,
169 LPCWSTR friendlyName,
170 IUnknown *identityArray,
171 IUnknown **appDomain)
173 FIXME("stub %p\n", iface);
174 return E_NOTIMPL;
177 static HRESULT WINAPI corruntimehost_GetDefaultDomain(
178 ICorRuntimeHost* iface,
179 IUnknown **pAppDomain)
181 FIXME("stub %p\n", iface);
182 return E_NOTIMPL;
185 static HRESULT WINAPI corruntimehost_EnumDomains(
186 ICorRuntimeHost* iface,
187 HDOMAINENUM *hEnum)
189 FIXME("stub %p\n", iface);
190 return E_NOTIMPL;
193 static HRESULT WINAPI corruntimehost_NextDomain(
194 ICorRuntimeHost* iface,
195 HDOMAINENUM hEnum,
196 IUnknown **appDomain)
198 FIXME("stub %p\n", iface);
199 return E_NOTIMPL;
202 static HRESULT WINAPI corruntimehost_CloseEnum(
203 ICorRuntimeHost* iface,
204 HDOMAINENUM hEnum)
206 FIXME("stub %p\n", iface);
207 return E_NOTIMPL;
210 static HRESULT WINAPI corruntimehost_CreateDomainEx(
211 ICorRuntimeHost* iface,
212 LPCWSTR friendlyName,
213 IUnknown *setup,
214 IUnknown *evidence,
215 IUnknown **appDomain)
217 FIXME("stub %p\n", iface);
218 return E_NOTIMPL;
221 static HRESULT WINAPI corruntimehost_CreateDomainSetup(
222 ICorRuntimeHost* iface,
223 IUnknown **appDomainSetup)
225 FIXME("stub %p\n", iface);
226 return E_NOTIMPL;
229 static HRESULT WINAPI corruntimehost_CreateEvidence(
230 ICorRuntimeHost* iface,
231 IUnknown **evidence)
233 FIXME("stub %p\n", iface);
234 return E_NOTIMPL;
237 static HRESULT WINAPI corruntimehost_UnloadDomain(
238 ICorRuntimeHost* iface,
239 IUnknown *appDomain)
241 FIXME("stub %p\n", iface);
242 return E_NOTIMPL;
245 static HRESULT WINAPI corruntimehost_CurrentDomain(
246 ICorRuntimeHost* iface,
247 IUnknown **appDomain)
249 FIXME("stub %p\n", iface);
250 return E_NOTIMPL;
253 static const struct ICorRuntimeHostVtbl corruntimehost_vtbl =
255 corruntimehost_QueryInterface,
256 corruntimehost_AddRef,
257 corruntimehost_Release,
258 corruntimehost_CreateLogicalThreadState,
259 corruntimehost_DeleteLogicalThreadState,
260 corruntimehost_SwitchInLogicalThreadState,
261 corruntimehost_SwitchOutLogicalThreadState,
262 corruntimehost_LocksHeldByLogicalThread,
263 corruntimehost_MapFile,
264 corruntimehost_GetConfiguration,
265 corruntimehost_Start,
266 corruntimehost_Stop,
267 corruntimehost_CreateDomain,
268 corruntimehost_GetDefaultDomain,
269 corruntimehost_EnumDomains,
270 corruntimehost_NextDomain,
271 corruntimehost_CloseEnum,
272 corruntimehost_CreateDomainEx,
273 corruntimehost_CreateDomainSetup,
274 corruntimehost_CreateEvidence,
275 corruntimehost_UnloadDomain,
276 corruntimehost_CurrentDomain
279 HRESULT RuntimeHost_Construct(const CLRRuntimeInfo *runtime_version,
280 const loaded_mono *loaded_mono, RuntimeHost** result)
282 RuntimeHost *This;
284 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
285 if ( !This )
286 return E_OUTOFMEMORY;
288 This->lpVtbl = &corruntimehost_vtbl;
289 This->ref = 1;
290 This->version = runtime_version;
291 This->mono = loaded_mono;
292 This->legacy = FALSE;
294 *result = This;
296 return S_OK;
299 HRESULT RuntimeHost_GetInterface(RuntimeHost *This, REFCLSID clsid, REFIID riid, void **ppv)
301 IUnknown *unk;
303 if (IsEqualGUID(clsid, &CLSID_CorRuntimeHost))
304 unk = (IUnknown*)&This->lpVtbl;
305 else
306 unk = NULL;
308 if (unk)
309 return IUnknown_QueryInterface(unk, riid, ppv);
310 else
311 FIXME("not implemented for class %s\n", debugstr_guid(clsid));
313 return CLASS_E_CLASSNOTAVAILABLE;
316 HRESULT RuntimeHost_Destroy(RuntimeHost *This)
318 HeapFree( GetProcessHeap(), 0, This );
319 return S_OK;
322 IUnknown* create_corruntimehost(void)
324 RuntimeHost *This;
325 IUnknown *result;
327 if (FAILED(RuntimeHost_Construct(NULL, NULL, &This)))
328 return NULL;
330 This->legacy = TRUE;
332 if (FAILED(RuntimeHost_GetInterface(This, &CLSID_CorRuntimeHost, &IID_IUnknown, (void**)&result)))
334 RuntimeHost_Destroy(This);
335 return NULL;
338 FIXME("return iface %p\n", result);
340 return result;