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
33 #include "mscoree_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL( mscoree );
41 const struct ICorRuntimeHostVtbl *lpVtbl;
42 const CLRRuntimeInfo *version;
43 const loaded_mono *mono;
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,
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 ) )
68 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
72 ICorRuntimeHost_AddRef( iface );
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 );
88 ref = InterlockedDecrement( &This->ref );
89 if ( ref == 0 && This->legacy )
91 RuntimeHost_Destroy(This);
97 /*** ICorRuntimeHost methods ***/
98 static HRESULT WINAPI corruntimehost_CreateLogicalThreadState(
99 ICorRuntimeHost* iface)
101 FIXME("stub %p\n", iface);
105 static HRESULT WINAPI corruntimehost_DeleteLogicalThreadState(
106 ICorRuntimeHost* iface)
108 FIXME("stub %p\n", iface);
112 static HRESULT WINAPI corruntimehost_SwitchInLogicalThreadState(
113 ICorRuntimeHost* iface,
116 FIXME("stub %p\n", iface);
120 static HRESULT WINAPI corruntimehost_SwitchOutLogicalThreadState(
121 ICorRuntimeHost* iface,
124 FIXME("stub %p\n", iface);
128 static HRESULT WINAPI corruntimehost_LocksHeldByLogicalThread(
129 ICorRuntimeHost* iface,
132 FIXME("stub %p\n", iface);
136 static HRESULT WINAPI corruntimehost_MapFile(
137 ICorRuntimeHost* iface,
141 FIXME("stub %p\n", iface);
145 static HRESULT WINAPI corruntimehost_GetConfiguration(
146 ICorRuntimeHost* iface,
147 ICorConfiguration **pConfiguration)
149 FIXME("stub %p\n", iface);
153 static HRESULT WINAPI corruntimehost_Start(
154 ICorRuntimeHost* iface)
156 FIXME("stub %p\n", iface);
160 static HRESULT WINAPI corruntimehost_Stop(
161 ICorRuntimeHost* iface)
163 FIXME("stub %p\n", iface);
167 static HRESULT WINAPI corruntimehost_CreateDomain(
168 ICorRuntimeHost* iface,
169 LPCWSTR friendlyName,
170 IUnknown *identityArray,
171 IUnknown **appDomain)
173 FIXME("stub %p\n", iface);
177 static HRESULT WINAPI corruntimehost_GetDefaultDomain(
178 ICorRuntimeHost* iface,
179 IUnknown **pAppDomain)
181 FIXME("stub %p\n", iface);
185 static HRESULT WINAPI corruntimehost_EnumDomains(
186 ICorRuntimeHost* iface,
189 FIXME("stub %p\n", iface);
193 static HRESULT WINAPI corruntimehost_NextDomain(
194 ICorRuntimeHost* iface,
196 IUnknown **appDomain)
198 FIXME("stub %p\n", iface);
202 static HRESULT WINAPI corruntimehost_CloseEnum(
203 ICorRuntimeHost* iface,
206 FIXME("stub %p\n", iface);
210 static HRESULT WINAPI corruntimehost_CreateDomainEx(
211 ICorRuntimeHost* iface,
212 LPCWSTR friendlyName,
215 IUnknown **appDomain)
217 FIXME("stub %p\n", iface);
221 static HRESULT WINAPI corruntimehost_CreateDomainSetup(
222 ICorRuntimeHost* iface,
223 IUnknown **appDomainSetup)
225 FIXME("stub %p\n", iface);
229 static HRESULT WINAPI corruntimehost_CreateEvidence(
230 ICorRuntimeHost* iface,
233 FIXME("stub %p\n", iface);
237 static HRESULT WINAPI corruntimehost_UnloadDomain(
238 ICorRuntimeHost* iface,
241 FIXME("stub %p\n", iface);
245 static HRESULT WINAPI corruntimehost_CurrentDomain(
246 ICorRuntimeHost* iface,
247 IUnknown **appDomain)
249 FIXME("stub %p\n", iface);
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,
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)
284 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
286 return E_OUTOFMEMORY;
288 This->lpVtbl = &corruntimehost_vtbl;
290 This->version = runtime_version;
291 This->mono = loaded_mono;
292 This->legacy = FALSE;
299 HRESULT RuntimeHost_GetInterface(RuntimeHost *This, REFCLSID clsid, REFIID riid, void **ppv)
303 if (IsEqualGUID(clsid, &CLSID_CorRuntimeHost))
304 unk = (IUnknown*)&This->lpVtbl;
309 return IUnknown_QueryInterface(unk, riid, ppv);
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 );
322 IUnknown* create_corruntimehost(void)
327 if (FAILED(RuntimeHost_Construct(NULL, NULL, &This)))
332 if (FAILED(RuntimeHost_GetInterface(This, &CLSID_CorRuntimeHost, &IID_IUnknown, (void**)&result)))
334 RuntimeHost_Destroy(This);
338 FIXME("return iface %p\n", result);