wined3d: Pass a texture and sub-resource index to wined3d_volume_download_data().
[wine.git] / dlls / mscoree / metahost.c
blob30b9739e70b99b81cca6f0e1d748a1ace629dbdc
1 /*
2 * ICLRMetaHost - discovery and management of available .NET runtimes
4 * Copyright 2010 Vincent Povirk for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdio.h>
22 #include <stdarg.h>
23 #include <assert.h>
25 #define COBJMACROS
27 #include "wine/unicode.h"
28 #include "wine/library.h"
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winreg.h"
32 #include "ole2.h"
34 #include "corerror.h"
35 #include "cor.h"
36 #include "mscoree.h"
37 #include "corhdr.h"
38 #include "cordebug.h"
39 #include "metahost.h"
40 #include "fusion.h"
41 #include "wine/list.h"
42 #include "mscoree_private.h"
44 #include "wine/debug.h"
46 WINE_DEFAULT_DEBUG_CHANNEL( mscoree );
48 static const struct ICLRRuntimeInfoVtbl CLRRuntimeInfoVtbl;
50 #define NUM_RUNTIMES 4
52 static struct CLRRuntimeInfo runtimes[NUM_RUNTIMES] = {
53 {{&CLRRuntimeInfoVtbl}, 1, 0, 3705, 0},
54 {{&CLRRuntimeInfoVtbl}, 1, 1, 4322, 0},
55 {{&CLRRuntimeInfoVtbl}, 2, 0, 50727, 0},
56 {{&CLRRuntimeInfoVtbl}, 4, 0, 30319, 0}
59 static CRITICAL_SECTION runtime_list_cs;
60 static CRITICAL_SECTION_DEBUG runtime_list_cs_debug =
62 0, 0, &runtime_list_cs,
63 { &runtime_list_cs_debug.ProcessLocksList,
64 &runtime_list_cs_debug.ProcessLocksList },
65 0, 0, { (DWORD_PTR)(__FILE__ ": runtime_list_cs") }
67 static CRITICAL_SECTION runtime_list_cs = { &runtime_list_cs_debug, -1, 0, 0, 0, 0 };
69 static HMODULE mono_handle;
71 BOOL is_mono_started;
72 static BOOL is_mono_shutdown;
74 MonoImage* (CDECL *mono_assembly_get_image)(MonoAssembly *assembly);
75 MonoAssembly* (CDECL *mono_assembly_load_from)(MonoImage *image, const char *fname, MonoImageOpenStatus *status);
76 MonoAssembly* (CDECL *mono_assembly_open)(const char *filename, MonoImageOpenStatus *status);
77 MonoClass* (CDECL *mono_class_from_mono_type)(MonoType *type);
78 MonoClass* (CDECL *mono_class_from_name)(MonoImage *image, const char* name_space, const char *name);
79 MonoMethod* (CDECL *mono_class_get_method_from_name)(MonoClass *klass, const char *name, int param_count);
80 static void (CDECL *mono_config_parse)(const char *filename);
81 MonoAssembly* (CDECL *mono_domain_assembly_open)(MonoDomain *domain, const char *name);
82 MonoDomain* (CDECL *mono_domain_get)(void);
83 MonoDomain* (CDECL *mono_domain_get_by_id)(int id);
84 BOOL (CDECL *mono_domain_set)(MonoDomain *domain,BOOL force);
85 void (CDECL *mono_domain_set_config)(MonoDomain *domain,const char *base_dir,const char *config_file_name);
86 static void (CDECL *mono_free)(void *);
87 static MonoImage* (CDECL *mono_image_open)(const char *fname, MonoImageOpenStatus *status);
88 MonoImage* (CDECL *mono_image_open_from_module_handle)(HMODULE module_handle, char* fname, UINT has_entry_point, MonoImageOpenStatus* status);
89 static void (CDECL *mono_install_assembly_preload_hook)(MonoAssemblyPreLoadFunc func, void *user_data);
90 int (CDECL *mono_jit_exec)(MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[]);
91 MonoDomain* (CDECL *mono_jit_init_version)(const char *domain_name, const char *runtime_version);
92 static int (CDECL *mono_jit_set_trace_options)(const char* options);
93 void* (CDECL *mono_marshal_get_vtfixup_ftnptr)(MonoImage *image, DWORD token, WORD type);
94 MonoDomain* (CDECL *mono_object_get_domain)(MonoObject *obj);
95 MonoMethod* (CDECL *mono_object_get_virtual_method)(MonoObject *obj, MonoMethod *method);
96 MonoObject* (CDECL *mono_object_new)(MonoDomain *domain, MonoClass *klass);
97 void* (CDECL *mono_object_unbox)(MonoObject *obj);
98 static void (CDECL *mono_profiler_install)(MonoProfiler *prof, MonoProfileFunc shutdown_callback);
99 MonoType* (CDECL *mono_reflection_type_from_name)(char *name, MonoImage *image);
100 MonoObject* (CDECL *mono_runtime_invoke)(MonoMethod *method, void *obj, void **params, MonoObject **exc);
101 void (CDECL *mono_runtime_object_init)(MonoObject *this_obj);
102 void (CDECL *mono_runtime_quit)(void);
103 static void (CDECL *mono_set_crash_chaining)(BOOL chain_signals);
104 static void (CDECL *mono_set_dirs)(const char *assembly_dir, const char *config_dir);
105 static void (CDECL *mono_set_verbose_level)(DWORD level);
106 MonoString* (CDECL *mono_string_new)(MonoDomain *domain, const char *str);
107 static char* (CDECL *mono_stringify_assembly_name)(MonoAssemblyName *aname);
108 MonoThread* (CDECL *mono_thread_attach)(MonoDomain *domain);
109 void (CDECL *mono_thread_manage)(void);
110 void (CDECL *mono_trace_set_assembly)(MonoAssembly *assembly);
111 void (CDECL *mono_trace_set_print_handler)(MonoPrintCallback callback);
112 void (CDECL *mono_trace_set_printerr_handler)(MonoPrintCallback callback);
114 static BOOL get_mono_path(LPWSTR path);
116 static BOOL find_mono_dll(LPCWSTR path, LPWSTR dll_path);
118 static MonoAssembly* CDECL mono_assembly_preload_hook_fn(MonoAssemblyName *aname, char **assemblies_path, void *user_data);
120 static void CDECL mono_shutdown_callback_fn(MonoProfiler *prof);
122 static void CDECL mono_print_handler_fn(const char *string, INT is_stdout);
124 static MonoImage* CDECL image_open_module_handle_dummy(HMODULE module_handle,
125 char* fname, UINT has_entry_point, MonoImageOpenStatus* status)
127 return mono_image_open(fname, status);
130 static void CDECL set_crash_chaining_dummy(BOOL crash_chaining)
134 static void CDECL set_print_handler_dummy(MonoPrintCallback callback)
138 static HRESULT load_mono(LPCWSTR mono_path)
140 static const WCHAR lib[] = {'\\','l','i','b',0};
141 static const WCHAR etc[] = {'\\','e','t','c',0};
142 WCHAR mono_dll_path[MAX_PATH+16];
143 WCHAR mono_lib_path[MAX_PATH+4], mono_etc_path[MAX_PATH+4];
144 char mono_lib_path_a[MAX_PATH], mono_etc_path_a[MAX_PATH];
145 int trace_size;
146 char trace_setting[256];
147 int verbose_size;
148 char verbose_setting[256];
150 if (is_mono_shutdown)
152 ERR("Cannot load Mono after it has been shut down.\n");
153 return E_FAIL;
156 if (!mono_handle)
158 strcpyW(mono_lib_path, mono_path);
159 strcatW(mono_lib_path, lib);
160 WideCharToMultiByte(CP_UTF8, 0, mono_lib_path, -1, mono_lib_path_a, MAX_PATH, NULL, NULL);
162 strcpyW(mono_etc_path, mono_path);
163 strcatW(mono_etc_path, etc);
164 WideCharToMultiByte(CP_UTF8, 0, mono_etc_path, -1, mono_etc_path_a, MAX_PATH, NULL, NULL);
166 if (!find_mono_dll(mono_path, mono_dll_path)) goto fail;
168 mono_handle = LoadLibraryW(mono_dll_path);
170 if (!mono_handle) goto fail;
172 #define LOAD_MONO_FUNCTION(x) do { \
173 x = (void*)GetProcAddress(mono_handle, #x); \
174 if (!x) { \
175 goto fail; \
177 } while (0);
179 LOAD_MONO_FUNCTION(mono_assembly_get_image);
180 LOAD_MONO_FUNCTION(mono_assembly_load_from);
181 LOAD_MONO_FUNCTION(mono_assembly_open);
182 LOAD_MONO_FUNCTION(mono_config_parse);
183 LOAD_MONO_FUNCTION(mono_class_from_mono_type);
184 LOAD_MONO_FUNCTION(mono_class_from_name);
185 LOAD_MONO_FUNCTION(mono_class_get_method_from_name);
186 LOAD_MONO_FUNCTION(mono_domain_assembly_open);
187 LOAD_MONO_FUNCTION(mono_domain_get);
188 LOAD_MONO_FUNCTION(mono_domain_get_by_id);
189 LOAD_MONO_FUNCTION(mono_domain_set);
190 LOAD_MONO_FUNCTION(mono_domain_set_config);
191 LOAD_MONO_FUNCTION(mono_free);
192 LOAD_MONO_FUNCTION(mono_image_open);
193 LOAD_MONO_FUNCTION(mono_install_assembly_preload_hook);
194 LOAD_MONO_FUNCTION(mono_jit_exec);
195 LOAD_MONO_FUNCTION(mono_jit_init_version);
196 LOAD_MONO_FUNCTION(mono_jit_set_trace_options);
197 LOAD_MONO_FUNCTION(mono_marshal_get_vtfixup_ftnptr);
198 LOAD_MONO_FUNCTION(mono_object_get_domain);
199 LOAD_MONO_FUNCTION(mono_object_get_virtual_method);
200 LOAD_MONO_FUNCTION(mono_object_new);
201 LOAD_MONO_FUNCTION(mono_object_unbox);
202 LOAD_MONO_FUNCTION(mono_profiler_install);
203 LOAD_MONO_FUNCTION(mono_reflection_type_from_name);
204 LOAD_MONO_FUNCTION(mono_runtime_invoke);
205 LOAD_MONO_FUNCTION(mono_runtime_object_init);
206 LOAD_MONO_FUNCTION(mono_runtime_quit);
207 LOAD_MONO_FUNCTION(mono_set_dirs);
208 LOAD_MONO_FUNCTION(mono_set_verbose_level);
209 LOAD_MONO_FUNCTION(mono_stringify_assembly_name);
210 LOAD_MONO_FUNCTION(mono_string_new);
211 LOAD_MONO_FUNCTION(mono_thread_attach);
212 LOAD_MONO_FUNCTION(mono_thread_manage);
213 LOAD_MONO_FUNCTION(mono_trace_set_assembly);
215 #undef LOAD_MONO_FUNCTION
217 #define LOAD_OPT_MONO_FUNCTION(x, default) do { \
218 x = (void*)GetProcAddress(mono_handle, #x); \
219 if (!x) { \
220 x = default; \
222 } while (0);
224 LOAD_OPT_MONO_FUNCTION(mono_image_open_from_module_handle, image_open_module_handle_dummy);
225 LOAD_OPT_MONO_FUNCTION(mono_set_crash_chaining, set_crash_chaining_dummy);
226 LOAD_OPT_MONO_FUNCTION(mono_trace_set_print_handler, set_print_handler_dummy);
227 LOAD_OPT_MONO_FUNCTION(mono_trace_set_printerr_handler, set_print_handler_dummy);
229 #undef LOAD_OPT_MONO_FUNCTION
231 mono_profiler_install(NULL, mono_shutdown_callback_fn);
233 mono_set_crash_chaining(TRUE);
235 mono_trace_set_print_handler(mono_print_handler_fn);
236 mono_trace_set_printerr_handler(mono_print_handler_fn);
238 mono_set_dirs(mono_lib_path_a, mono_etc_path_a);
240 mono_config_parse(NULL);
242 mono_install_assembly_preload_hook(mono_assembly_preload_hook_fn, NULL);
244 trace_size = GetEnvironmentVariableA("WINE_MONO_TRACE", trace_setting, sizeof(trace_setting));
246 if (trace_size)
248 mono_jit_set_trace_options(trace_setting);
251 verbose_size = GetEnvironmentVariableA("WINE_MONO_VERBOSE", verbose_setting, sizeof(verbose_setting));
253 if (verbose_size)
255 mono_set_verbose_level(verbose_setting[0] - '0');
259 return S_OK;
261 fail:
262 ERR("Could not load Mono into this process\n");
263 FreeLibrary(mono_handle);
264 mono_handle = NULL;
265 return E_FAIL;
268 static void CDECL mono_shutdown_callback_fn(MonoProfiler *prof)
270 is_mono_shutdown = TRUE;
273 static void CDECL mono_print_handler_fn(const char *string, INT is_stdout)
275 const char *p;
276 for (; *string; string = p)
278 if ((p = strstr(string, "\n"))) p++;
279 else p = string + strlen(string);
280 wine_dbg_printf("%.*s", (int)(p - string), string);
284 static HRESULT CLRRuntimeInfo_GetRuntimeHost(CLRRuntimeInfo *This, RuntimeHost **result)
286 HRESULT hr = S_OK;
287 WCHAR mono_path[MAX_PATH];
289 if (This->loaded_runtime)
291 *result = This->loaded_runtime;
292 return hr;
295 if (!get_mono_path(mono_path))
297 ERR("Wine Mono is not installed\n");
298 return CLR_E_SHIM_RUNTIME;
301 EnterCriticalSection(&runtime_list_cs);
303 hr = load_mono(mono_path);
305 if (SUCCEEDED(hr))
306 hr = RuntimeHost_Construct(This, &This->loaded_runtime);
308 LeaveCriticalSection(&runtime_list_cs);
310 if (SUCCEEDED(hr))
311 *result = This->loaded_runtime;
313 return hr;
316 void expect_no_runtimes(void)
318 if (mono_handle && is_mono_started && !is_mono_shutdown)
320 ERR("Process exited with a Mono runtime loaded.\n");
321 return;
325 static inline CLRRuntimeInfo *impl_from_ICLRRuntimeInfo(ICLRRuntimeInfo *iface)
327 return CONTAINING_RECORD(iface, CLRRuntimeInfo, ICLRRuntimeInfo_iface);
330 static HRESULT WINAPI CLRRuntimeInfo_QueryInterface(ICLRRuntimeInfo* iface,
331 REFIID riid,
332 void **ppvObject)
334 TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject);
336 if ( IsEqualGUID( riid, &IID_ICLRRuntimeInfo ) ||
337 IsEqualGUID( riid, &IID_IUnknown ) )
339 *ppvObject = iface;
341 else
343 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
344 return E_NOINTERFACE;
347 ICLRRuntimeInfo_AddRef( iface );
349 return S_OK;
352 static ULONG WINAPI CLRRuntimeInfo_AddRef(ICLRRuntimeInfo* iface)
354 return 2;
357 static ULONG WINAPI CLRRuntimeInfo_Release(ICLRRuntimeInfo* iface)
359 return 1;
362 static HRESULT WINAPI CLRRuntimeInfo_GetVersionString(ICLRRuntimeInfo* iface,
363 LPWSTR pwzBuffer, DWORD *pcchBuffer)
365 struct CLRRuntimeInfo *This = impl_from_ICLRRuntimeInfo(iface);
366 DWORD buffer_size = *pcchBuffer;
367 HRESULT hr = S_OK;
368 char version[11];
369 DWORD size;
371 TRACE("%p %p %p\n", iface, pwzBuffer, pcchBuffer);
373 size = snprintf(version, sizeof(version), "v%u.%u.%u", This->major, This->minor, This->build);
375 assert(size <= sizeof(version));
377 *pcchBuffer = MultiByteToWideChar(CP_UTF8, 0, version, -1, NULL, 0);
379 if (pwzBuffer)
381 if (buffer_size >= *pcchBuffer)
382 MultiByteToWideChar(CP_UTF8, 0, version, -1, pwzBuffer, buffer_size);
383 else
384 hr = E_NOT_SUFFICIENT_BUFFER;
387 return hr;
390 static BOOL get_install_root(LPWSTR install_dir)
392 const WCHAR dotnet_key[] = {'S','O','F','T','W','A','R','E','\\','M','i','c','r','o','s','o','f','t','\\','.','N','E','T','F','r','a','m','e','w','o','r','k','\\',0};
393 const WCHAR install_root[] = {'I','n','s','t','a','l','l','R','o','o','t',0};
395 DWORD len;
396 HKEY key;
398 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, dotnet_key, 0, KEY_READ, &key))
399 return FALSE;
401 len = MAX_PATH;
402 if (RegQueryValueExW(key, install_root, 0, NULL, (LPBYTE)install_dir, &len))
404 RegCloseKey(key);
405 return FALSE;
407 RegCloseKey(key);
409 return TRUE;
412 static HRESULT WINAPI CLRRuntimeInfo_GetRuntimeDirectory(ICLRRuntimeInfo* iface,
413 LPWSTR pwzBuffer, DWORD *pcchBuffer)
415 static const WCHAR slash[] = {'\\',0};
416 DWORD buffer_size = *pcchBuffer;
417 WCHAR system_dir[MAX_PATH];
418 WCHAR version[MAX_PATH];
419 DWORD version_size, size;
420 HRESULT hr = S_OK;
422 TRACE("%p %p %p\n", iface, pwzBuffer, pcchBuffer);
424 if (!get_install_root(system_dir))
426 ERR("error reading registry key for installroot\n");
427 return E_FAIL;
429 else
431 version_size = MAX_PATH;
432 ICLRRuntimeInfo_GetVersionString(iface, version, &version_size);
433 lstrcatW(system_dir, version);
434 lstrcatW(system_dir, slash);
435 size = lstrlenW(system_dir) + 1;
438 *pcchBuffer = size;
440 if (pwzBuffer)
442 if (buffer_size >= size)
443 strcpyW(pwzBuffer, system_dir);
444 else
445 hr = E_NOT_SUFFICIENT_BUFFER;
448 return hr;
451 static HRESULT WINAPI CLRRuntimeInfo_IsLoaded(ICLRRuntimeInfo* iface,
452 HANDLE hndProcess, BOOL *pbLoaded)
454 FIXME("%p %p %p\n", iface, hndProcess, pbLoaded);
456 return E_NOTIMPL;
459 static HRESULT WINAPI CLRRuntimeInfo_LoadErrorString(ICLRRuntimeInfo* iface,
460 UINT iResourceID, LPWSTR pwzBuffer, DWORD *pcchBuffer, LONG iLocaleid)
462 FIXME("%p %u %p %p %x\n", iface, iResourceID, pwzBuffer, pcchBuffer, iLocaleid);
464 return E_NOTIMPL;
467 static HRESULT WINAPI CLRRuntimeInfo_LoadLibrary(ICLRRuntimeInfo* iface,
468 LPCWSTR pwzDllName, HMODULE *phndModule)
470 WCHAR version[MAX_PATH];
471 HRESULT hr;
472 DWORD cchBuffer;
474 TRACE("%p %s %p\n", iface, debugstr_w(pwzDllName), phndModule);
476 cchBuffer = MAX_PATH;
477 hr = ICLRRuntimeInfo_GetVersionString(iface, version, &cchBuffer);
478 if (FAILED(hr)) return hr;
480 return LoadLibraryShim(pwzDllName, version, NULL, phndModule);
483 static HRESULT WINAPI CLRRuntimeInfo_GetProcAddress(ICLRRuntimeInfo* iface,
484 LPCSTR pszProcName, LPVOID *ppProc)
486 FIXME("%p %s %p\n", iface, debugstr_a(pszProcName), ppProc);
488 return E_NOTIMPL;
491 static HRESULT WINAPI CLRRuntimeInfo_GetInterface(ICLRRuntimeInfo* iface,
492 REFCLSID rclsid, REFIID riid, LPVOID *ppUnk)
494 struct CLRRuntimeInfo *This = impl_from_ICLRRuntimeInfo(iface);
495 RuntimeHost *host;
496 HRESULT hr;
498 TRACE("%p %s %s %p\n", iface, debugstr_guid(rclsid), debugstr_guid(riid), ppUnk);
500 hr = CLRRuntimeInfo_GetRuntimeHost(This, &host);
502 if (SUCCEEDED(hr))
503 hr = RuntimeHost_GetInterface(host, rclsid, riid, ppUnk);
505 return hr;
508 static HRESULT WINAPI CLRRuntimeInfo_IsLoadable(ICLRRuntimeInfo* iface,
509 BOOL *pbLoadable)
511 FIXME("%p %p\n", iface, pbLoadable);
513 return E_NOTIMPL;
516 static HRESULT WINAPI CLRRuntimeInfo_SetDefaultStartupFlags(ICLRRuntimeInfo* iface,
517 DWORD dwStartupFlags, LPCWSTR pwzHostConfigFile)
519 FIXME("%p %x %s\n", iface, dwStartupFlags, debugstr_w(pwzHostConfigFile));
521 return E_NOTIMPL;
524 static HRESULT WINAPI CLRRuntimeInfo_GetDefaultStartupFlags(ICLRRuntimeInfo* iface,
525 DWORD *pdwStartupFlags, LPWSTR pwzHostConfigFile, DWORD *pcchHostConfigFile)
527 FIXME("%p %p %p %p\n", iface, pdwStartupFlags, pwzHostConfigFile, pcchHostConfigFile);
529 return E_NOTIMPL;
532 static HRESULT WINAPI CLRRuntimeInfo_BindAsLegacyV2Runtime(ICLRRuntimeInfo* iface)
534 FIXME("%p\n", iface);
536 return E_NOTIMPL;
539 static HRESULT WINAPI CLRRuntimeInfo_IsStarted(ICLRRuntimeInfo* iface,
540 BOOL *pbStarted, DWORD *pdwStartupFlags)
542 FIXME("%p %p %p\n", iface, pbStarted, pdwStartupFlags);
544 return E_NOTIMPL;
547 static const struct ICLRRuntimeInfoVtbl CLRRuntimeInfoVtbl = {
548 CLRRuntimeInfo_QueryInterface,
549 CLRRuntimeInfo_AddRef,
550 CLRRuntimeInfo_Release,
551 CLRRuntimeInfo_GetVersionString,
552 CLRRuntimeInfo_GetRuntimeDirectory,
553 CLRRuntimeInfo_IsLoaded,
554 CLRRuntimeInfo_LoadErrorString,
555 CLRRuntimeInfo_LoadLibrary,
556 CLRRuntimeInfo_GetProcAddress,
557 CLRRuntimeInfo_GetInterface,
558 CLRRuntimeInfo_IsLoadable,
559 CLRRuntimeInfo_SetDefaultStartupFlags,
560 CLRRuntimeInfo_GetDefaultStartupFlags,
561 CLRRuntimeInfo_BindAsLegacyV2Runtime,
562 CLRRuntimeInfo_IsStarted
565 HRESULT ICLRRuntimeInfo_GetRuntimeHost(ICLRRuntimeInfo *iface, RuntimeHost **result)
567 struct CLRRuntimeInfo *This = impl_from_ICLRRuntimeInfo(iface);
569 assert(This->ICLRRuntimeInfo_iface.lpVtbl == &CLRRuntimeInfoVtbl);
571 return CLRRuntimeInfo_GetRuntimeHost(This, result);
574 #ifdef __i386__
575 static const WCHAR libmono2_arch_dll[] = {'\\','b','i','n','\\','l','i','b','m','o','n','o','-','2','.','0','-','x','8','6','.','d','l','l',0};
576 #elif defined(__x86_64__)
577 static const WCHAR libmono2_arch_dll[] = {'\\','b','i','n','\\','l','i','b','m','o','n','o','-','2','.','0','-','x','8','6','_','6','4','.','d','l','l',0};
578 #else
579 static const WCHAR libmono2_arch_dll[] = {'\\','b','i','n','\\','l','i','b','m','o','n','o','-','2','.','0','.','d','l','l',0};
580 #endif
582 static BOOL find_mono_dll(LPCWSTR path, LPWSTR dll_path)
584 static const WCHAR mono2_dll[] = {'\\','b','i','n','\\','m','o','n','o','-','2','.','0','.','d','l','l',0};
585 static const WCHAR libmono2_dll[] = {'\\','b','i','n','\\','l','i','b','m','o','n','o','-','2','.','0','.','d','l','l',0};
586 DWORD attributes=INVALID_FILE_ATTRIBUTES;
588 strcpyW(dll_path, path);
589 strcatW(dll_path, libmono2_arch_dll);
590 attributes = GetFileAttributesW(dll_path);
592 if (attributes == INVALID_FILE_ATTRIBUTES)
594 strcpyW(dll_path, path);
595 strcatW(dll_path, mono2_dll);
596 attributes = GetFileAttributesW(dll_path);
599 if (attributes == INVALID_FILE_ATTRIBUTES)
601 strcpyW(dll_path, path);
602 strcatW(dll_path, libmono2_dll);
603 attributes = GetFileAttributesW(dll_path);
606 return (attributes != INVALID_FILE_ATTRIBUTES);
609 static BOOL get_mono_path(LPWSTR path)
611 static const WCHAR subdir_mono[] = {'\\','m','o','n','o','\\','m','o','n','o','-','2','.','0', 0};
612 WCHAR base_path[MAX_PATH], mono_dll_path[MAX_PATH];
614 /* c:\windows\mono\mono-2.0 */
615 GetWindowsDirectoryW(base_path, MAX_PATH);
616 strcatW(base_path, subdir_mono);
618 if (find_mono_dll(base_path, mono_dll_path))
620 strcpyW(path, base_path);
621 return TRUE;
624 return FALSE;
627 struct InstalledRuntimeEnum
629 IEnumUnknown IEnumUnknown_iface;
630 LONG ref;
631 ULONG pos;
634 static const struct IEnumUnknownVtbl InstalledRuntimeEnum_Vtbl;
636 static inline struct InstalledRuntimeEnum *impl_from_IEnumUnknown(IEnumUnknown *iface)
638 return CONTAINING_RECORD(iface, struct InstalledRuntimeEnum, IEnumUnknown_iface);
641 static HRESULT WINAPI InstalledRuntimeEnum_QueryInterface(IEnumUnknown* iface, REFIID riid,
642 void **ppvObject)
644 TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject);
646 if ( IsEqualGUID( riid, &IID_IEnumUnknown ) ||
647 IsEqualGUID( riid, &IID_IUnknown ) )
649 *ppvObject = iface;
651 else
653 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
654 return E_NOINTERFACE;
657 IEnumUnknown_AddRef( iface );
659 return S_OK;
662 static ULONG WINAPI InstalledRuntimeEnum_AddRef(IEnumUnknown* iface)
664 struct InstalledRuntimeEnum *This = impl_from_IEnumUnknown(iface);
665 ULONG ref = InterlockedIncrement(&This->ref);
667 TRACE("(%p) refcount=%u\n", iface, ref);
669 return ref;
672 static ULONG WINAPI InstalledRuntimeEnum_Release(IEnumUnknown* iface)
674 struct InstalledRuntimeEnum *This = impl_from_IEnumUnknown(iface);
675 ULONG ref = InterlockedDecrement(&This->ref);
677 TRACE("(%p) refcount=%u\n", iface, ref);
679 if (ref == 0)
681 HeapFree(GetProcessHeap(), 0, This);
684 return ref;
687 static HRESULT WINAPI InstalledRuntimeEnum_Next(IEnumUnknown *iface, ULONG celt,
688 IUnknown **rgelt, ULONG *pceltFetched)
690 struct InstalledRuntimeEnum *This = impl_from_IEnumUnknown(iface);
691 ULONG num_fetched = 0;
692 HRESULT hr=S_OK;
693 IUnknown *item;
695 TRACE("(%p,%u,%p,%p)\n", iface, celt, rgelt, pceltFetched);
697 while (num_fetched < celt)
699 if (This->pos >= NUM_RUNTIMES)
701 hr = S_FALSE;
702 break;
704 item = (IUnknown*)&runtimes[This->pos].ICLRRuntimeInfo_iface;
705 IUnknown_AddRef(item);
706 rgelt[num_fetched] = item;
707 num_fetched++;
708 This->pos++;
711 if (pceltFetched)
712 *pceltFetched = num_fetched;
714 return hr;
717 static HRESULT WINAPI InstalledRuntimeEnum_Skip(IEnumUnknown *iface, ULONG celt)
719 struct InstalledRuntimeEnum *This = impl_from_IEnumUnknown(iface);
720 ULONG num_fetched = 0;
721 HRESULT hr=S_OK;
723 TRACE("(%p,%u)\n", iface, celt);
725 while (num_fetched < celt)
727 if (This->pos >= NUM_RUNTIMES)
729 hr = S_FALSE;
730 break;
732 num_fetched++;
733 This->pos++;
736 return hr;
739 static HRESULT WINAPI InstalledRuntimeEnum_Reset(IEnumUnknown *iface)
741 struct InstalledRuntimeEnum *This = impl_from_IEnumUnknown(iface);
743 TRACE("(%p)\n", iface);
745 This->pos = 0;
747 return S_OK;
750 static HRESULT WINAPI InstalledRuntimeEnum_Clone(IEnumUnknown *iface, IEnumUnknown **ppenum)
752 struct InstalledRuntimeEnum *This = impl_from_IEnumUnknown(iface);
753 struct InstalledRuntimeEnum *new_enum;
755 TRACE("(%p)\n", iface);
757 new_enum = HeapAlloc(GetProcessHeap(), 0, sizeof(*new_enum));
758 if (!new_enum)
759 return E_OUTOFMEMORY;
761 new_enum->IEnumUnknown_iface.lpVtbl = &InstalledRuntimeEnum_Vtbl;
762 new_enum->ref = 1;
763 new_enum->pos = This->pos;
765 *ppenum = &new_enum->IEnumUnknown_iface;
767 return S_OK;
770 static const struct IEnumUnknownVtbl InstalledRuntimeEnum_Vtbl = {
771 InstalledRuntimeEnum_QueryInterface,
772 InstalledRuntimeEnum_AddRef,
773 InstalledRuntimeEnum_Release,
774 InstalledRuntimeEnum_Next,
775 InstalledRuntimeEnum_Skip,
776 InstalledRuntimeEnum_Reset,
777 InstalledRuntimeEnum_Clone
780 struct CLRMetaHost
782 ICLRMetaHost ICLRMetaHost_iface;
784 RuntimeLoadedCallbackFnPtr callback;
787 static struct CLRMetaHost GlobalCLRMetaHost;
789 static HRESULT WINAPI CLRMetaHost_QueryInterface(ICLRMetaHost* iface,
790 REFIID riid,
791 void **ppvObject)
793 TRACE("%s %p\n", debugstr_guid(riid), ppvObject);
795 if ( IsEqualGUID( riid, &IID_ICLRMetaHost ) ||
796 IsEqualGUID( riid, &IID_IUnknown ) )
798 *ppvObject = iface;
800 else
802 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
803 return E_NOINTERFACE;
806 ICLRMetaHost_AddRef( iface );
808 return S_OK;
811 static ULONG WINAPI CLRMetaHost_AddRef(ICLRMetaHost* iface)
813 return 2;
816 static ULONG WINAPI CLRMetaHost_Release(ICLRMetaHost* iface)
818 return 1;
821 static BOOL parse_runtime_version(LPCWSTR version, DWORD *major, DWORD *minor, DWORD *build)
823 *major = 0;
824 *minor = 0;
825 *build = 0;
827 if (version[0] == 'v' || version[0] == 'V')
829 version++;
830 if (!isdigit(*version))
831 return FALSE;
833 while (isdigit(*version))
834 *major = *major * 10 + (*version++ - '0');
836 if (*version == 0)
837 return TRUE;
839 if (*version++ != '.' || !isdigit(*version))
840 return FALSE;
842 while (isdigit(*version))
843 *minor = *minor * 10 + (*version++ - '0');
845 if (*version == 0)
846 return TRUE;
848 if (*version++ != '.' || !isdigit(*version))
849 return FALSE;
851 while (isdigit(*version))
852 *build = *build * 10 + (*version++ - '0');
854 return *version == 0;
856 else
857 return FALSE;
860 static HRESULT get_runtime(LPCWSTR pwzVersion, BOOL allow_short,
861 REFIID iid, LPVOID *ppRuntime)
863 int i;
864 DWORD major, minor, build;
866 if (!pwzVersion)
867 return E_POINTER;
869 if (!parse_runtime_version(pwzVersion, &major, &minor, &build))
871 ERR("Cannot parse %s\n", debugstr_w(pwzVersion));
872 return CLR_E_SHIM_RUNTIME;
875 for (i=0; i<NUM_RUNTIMES; i++)
877 if (runtimes[i].major == major && runtimes[i].minor == minor &&
878 (runtimes[i].build == build || (allow_short && major >= 4 && build == 0)))
880 return ICLRRuntimeInfo_QueryInterface(&runtimes[i].ICLRRuntimeInfo_iface, iid,
881 ppRuntime);
885 FIXME("Unrecognized version %s\n", debugstr_w(pwzVersion));
886 return CLR_E_SHIM_RUNTIME;
889 HRESULT WINAPI CLRMetaHost_GetRuntime(ICLRMetaHost* iface,
890 LPCWSTR pwzVersion, REFIID iid, LPVOID *ppRuntime)
892 TRACE("%s %s %p\n", debugstr_w(pwzVersion), debugstr_guid(iid), ppRuntime);
894 return get_runtime(pwzVersion, FALSE, iid, ppRuntime);
897 HRESULT WINAPI CLRMetaHost_GetVersionFromFile(ICLRMetaHost* iface,
898 LPCWSTR pwzFilePath, LPWSTR pwzBuffer, DWORD *pcchBuffer)
900 ASSEMBLY *assembly;
901 HRESULT hr;
902 LPSTR version;
903 ULONG buffer_size=*pcchBuffer;
905 TRACE("%s %p %p\n", debugstr_w(pwzFilePath), pwzBuffer, pcchBuffer);
907 hr = assembly_create(&assembly, pwzFilePath);
909 if (SUCCEEDED(hr))
911 hr = assembly_get_runtime_version(assembly, &version);
913 if (SUCCEEDED(hr))
915 *pcchBuffer = MultiByteToWideChar(CP_UTF8, 0, version, -1, NULL, 0);
917 if (pwzBuffer)
919 if (buffer_size >= *pcchBuffer)
920 MultiByteToWideChar(CP_UTF8, 0, version, -1, pwzBuffer, buffer_size);
921 else
922 hr = E_NOT_SUFFICIENT_BUFFER;
926 assembly_release(assembly);
929 return hr;
932 static HRESULT WINAPI CLRMetaHost_EnumerateInstalledRuntimes(ICLRMetaHost* iface,
933 IEnumUnknown **ppEnumerator)
935 struct InstalledRuntimeEnum *new_enum;
937 TRACE("%p\n", ppEnumerator);
939 new_enum = HeapAlloc(GetProcessHeap(), 0, sizeof(*new_enum));
940 if (!new_enum)
941 return E_OUTOFMEMORY;
943 new_enum->IEnumUnknown_iface.lpVtbl = &InstalledRuntimeEnum_Vtbl;
944 new_enum->ref = 1;
945 new_enum->pos = 0;
947 *ppEnumerator = &new_enum->IEnumUnknown_iface;
949 return S_OK;
952 static HRESULT WINAPI CLRMetaHost_EnumerateLoadedRuntimes(ICLRMetaHost* iface,
953 HANDLE hndProcess, IEnumUnknown **ppEnumerator)
955 FIXME("%p %p\n", hndProcess, ppEnumerator);
957 return E_NOTIMPL;
960 static HRESULT WINAPI CLRMetaHost_RequestRuntimeLoadedNotification(ICLRMetaHost* iface,
961 RuntimeLoadedCallbackFnPtr pCallbackFunction)
963 TRACE("%p\n", pCallbackFunction);
965 if(!pCallbackFunction)
966 return E_POINTER;
968 WARN("Callback currently will not be called.\n");
970 GlobalCLRMetaHost.callback = pCallbackFunction;
972 return S_OK;
975 static HRESULT WINAPI CLRMetaHost_QueryLegacyV2RuntimeBinding(ICLRMetaHost* iface,
976 REFIID riid, LPVOID *ppUnk)
978 FIXME("%s %p\n", debugstr_guid(riid), ppUnk);
980 return E_NOTIMPL;
983 HRESULT WINAPI CLRMetaHost_ExitProcess(ICLRMetaHost* iface, INT32 iExitCode)
985 TRACE("%i\n", iExitCode);
987 EnterCriticalSection(&runtime_list_cs);
989 if (is_mono_started && !is_mono_shutdown)
991 /* search for a runtime and call System.Environment.Exit() */
992 int i;
994 for (i=0; i<NUM_RUNTIMES; i++)
995 if (runtimes[i].loaded_runtime)
996 RuntimeHost_ExitProcess(runtimes[i].loaded_runtime, iExitCode);
999 ExitProcess(iExitCode);
1002 static const struct ICLRMetaHostVtbl CLRMetaHost_vtbl =
1004 CLRMetaHost_QueryInterface,
1005 CLRMetaHost_AddRef,
1006 CLRMetaHost_Release,
1007 CLRMetaHost_GetRuntime,
1008 CLRMetaHost_GetVersionFromFile,
1009 CLRMetaHost_EnumerateInstalledRuntimes,
1010 CLRMetaHost_EnumerateLoadedRuntimes,
1011 CLRMetaHost_RequestRuntimeLoadedNotification,
1012 CLRMetaHost_QueryLegacyV2RuntimeBinding,
1013 CLRMetaHost_ExitProcess
1016 static struct CLRMetaHost GlobalCLRMetaHost = {
1017 { &CLRMetaHost_vtbl }
1020 HRESULT CLRMetaHost_CreateInstance(REFIID riid, void **ppobj)
1022 return ICLRMetaHost_QueryInterface(&GlobalCLRMetaHost.ICLRMetaHost_iface, riid, ppobj);
1025 struct CLRMetaHostPolicy
1027 ICLRMetaHostPolicy ICLRMetaHostPolicy_iface;
1030 static struct CLRMetaHostPolicy GlobalCLRMetaHostPolicy;
1032 static HRESULT WINAPI metahostpolicy_QueryInterface(ICLRMetaHostPolicy *iface, REFIID riid, void **obj)
1034 TRACE("%s %p\n", debugstr_guid(riid), obj);
1036 if ( IsEqualGUID( riid, &IID_ICLRMetaHostPolicy ) ||
1037 IsEqualGUID( riid, &IID_IUnknown ) )
1039 ICLRMetaHostPolicy_AddRef( iface );
1040 *obj = iface;
1041 return S_OK;
1044 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
1046 *obj = NULL;
1047 return E_NOINTERFACE;
1050 static ULONG WINAPI metahostpolicy_AddRef(ICLRMetaHostPolicy *iface)
1052 return 2;
1055 static ULONG WINAPI metahostpolicy_Release(ICLRMetaHostPolicy *iface)
1057 return 1;
1060 static HRESULT WINAPI metahostpolicy_GetRequestedRuntime(ICLRMetaHostPolicy *iface, METAHOST_POLICY_FLAGS dwPolicyFlags,
1061 LPCWSTR pwzBinary, IStream *pCfgStream, LPWSTR pwzVersion, DWORD *pcchVersion,
1062 LPWSTR pwzImageVersion, DWORD *pcchImageVersion, DWORD *pdwConfigFlags, REFIID riid,
1063 LPVOID *ppRuntime)
1065 ICLRRuntimeInfo *result;
1066 HRESULT hr;
1067 WCHAR filename[MAX_PATH];
1068 const WCHAR *path = NULL;
1069 int flags = 0;
1071 TRACE("%d %p %p %p %p %p %p %p %s %p\n", dwPolicyFlags, pwzBinary, pCfgStream,
1072 pwzVersion, pcchVersion, pwzImageVersion, pcchImageVersion, pdwConfigFlags,
1073 debugstr_guid(riid), ppRuntime);
1075 if (pCfgStream)
1076 FIXME("ignoring config file stream\n");
1078 if (pdwConfigFlags)
1079 FIXME("ignoring config flags\n");
1081 if(dwPolicyFlags & METAHOST_POLICY_USE_PROCESS_IMAGE_PATH)
1083 GetModuleFileNameW(0, filename, MAX_PATH);
1084 path = filename;
1086 else if(pwzBinary)
1088 path = pwzBinary;
1091 if(dwPolicyFlags & METAHOST_POLICY_APPLY_UPGRADE_POLICY)
1092 flags |= RUNTIME_INFO_UPGRADE_VERSION;
1094 hr = get_runtime_info(path, pwzImageVersion, NULL, 0, flags, FALSE, &result);
1095 if (SUCCEEDED(hr))
1097 if (pwzImageVersion)
1099 /* Ignoring errors on purpose */
1100 ICLRRuntimeInfo_GetVersionString(result, pwzImageVersion, pcchImageVersion);
1103 hr = ICLRRuntimeInfo_QueryInterface(result, riid, ppRuntime);
1105 ICLRRuntimeInfo_Release(result);
1108 TRACE("<- 0x%08x\n", hr);
1110 return hr;
1113 static const struct ICLRMetaHostPolicyVtbl CLRMetaHostPolicy_vtbl =
1115 metahostpolicy_QueryInterface,
1116 metahostpolicy_AddRef,
1117 metahostpolicy_Release,
1118 metahostpolicy_GetRequestedRuntime
1121 static struct CLRMetaHostPolicy GlobalCLRMetaHostPolicy = {
1122 { &CLRMetaHostPolicy_vtbl }
1125 HRESULT CLRMetaHostPolicy_CreateInstance(REFIID riid, void **ppobj)
1127 return ICLRMetaHostPolicy_QueryInterface(&GlobalCLRMetaHostPolicy.ICLRMetaHostPolicy_iface, riid, ppobj);
1130 HRESULT get_file_from_strongname(WCHAR* stringnameW, WCHAR* assemblies_path, int path_length)
1132 HRESULT hr=S_OK;
1133 IAssemblyCache *asmcache;
1134 ASSEMBLY_INFO info;
1135 static const WCHAR fusiondll[] = {'f','u','s','i','o','n',0};
1136 HMODULE hfusion=NULL;
1137 static HRESULT (WINAPI *pCreateAssemblyCache)(IAssemblyCache**,DWORD);
1139 if (!pCreateAssemblyCache)
1141 hr = LoadLibraryShim(fusiondll, NULL, NULL, &hfusion);
1143 if (SUCCEEDED(hr))
1145 pCreateAssemblyCache = (void*)GetProcAddress(hfusion, "CreateAssemblyCache");
1146 if (!pCreateAssemblyCache)
1147 hr = E_FAIL;
1151 if (SUCCEEDED(hr))
1152 hr = pCreateAssemblyCache(&asmcache, 0);
1154 if (SUCCEEDED(hr))
1156 info.cbAssemblyInfo = sizeof(info);
1157 info.pszCurrentAssemblyPathBuf = assemblies_path;
1158 info.cchBuf = path_length;
1159 assemblies_path[0] = 0;
1161 hr = IAssemblyCache_QueryAssemblyInfo(asmcache, 0, stringnameW, &info);
1163 IAssemblyCache_Release(asmcache);
1166 return hr;
1169 static MonoAssembly* CDECL mono_assembly_preload_hook_fn(MonoAssemblyName *aname, char **assemblies_path, void *user_data)
1171 HRESULT hr;
1172 MonoAssembly *result=NULL;
1173 char *stringname=NULL;
1174 LPWSTR stringnameW;
1175 int stringnameW_size;
1176 WCHAR path[MAX_PATH];
1177 char *pathA;
1178 MonoImageOpenStatus stat;
1180 stringname = mono_stringify_assembly_name(aname);
1182 TRACE("%s\n", debugstr_a(stringname));
1184 if (!stringname) return NULL;
1186 /* FIXME: We should search the given paths before the GAC. */
1188 stringnameW_size = MultiByteToWideChar(CP_UTF8, 0, stringname, -1, NULL, 0);
1190 stringnameW = HeapAlloc(GetProcessHeap(), 0, stringnameW_size * sizeof(WCHAR));
1191 if (stringnameW)
1193 MultiByteToWideChar(CP_UTF8, 0, stringname, -1, stringnameW, stringnameW_size);
1195 hr = get_file_from_strongname(stringnameW, path, MAX_PATH);
1197 HeapFree(GetProcessHeap(), 0, stringnameW);
1199 else
1200 hr = E_OUTOFMEMORY;
1202 if (SUCCEEDED(hr))
1204 TRACE("found: %s\n", debugstr_w(path));
1206 pathA = WtoA(path);
1208 if (pathA)
1210 result = mono_assembly_open(pathA, &stat);
1212 if (!result)
1213 ERR("Failed to load %s, status=%u\n", debugstr_w(path), stat);
1215 HeapFree(GetProcessHeap(), 0, pathA);
1219 mono_free(stringname);
1221 return result;
1224 HRESULT get_runtime_info(LPCWSTR exefile, LPCWSTR version, LPCWSTR config_file,
1225 DWORD startup_flags, DWORD runtimeinfo_flags, BOOL legacy, ICLRRuntimeInfo **result)
1227 static const WCHAR dotconfig[] = {'.','c','o','n','f','i','g',0};
1228 static const DWORD supported_startup_flags = 0;
1229 static const DWORD supported_runtime_flags = RUNTIME_INFO_UPGRADE_VERSION;
1230 int i;
1231 WCHAR local_version[MAX_PATH];
1232 ULONG local_version_size = MAX_PATH;
1233 WCHAR local_config_file[MAX_PATH];
1234 HRESULT hr;
1235 parsed_config_file parsed_config;
1237 if (startup_flags & ~supported_startup_flags)
1238 FIXME("unsupported startup flags %x\n", startup_flags & ~supported_startup_flags);
1240 if (runtimeinfo_flags & ~supported_runtime_flags)
1241 FIXME("unsupported runtimeinfo flags %x\n", runtimeinfo_flags & ~supported_runtime_flags);
1243 if (exefile && !exefile[0])
1244 exefile = NULL;
1246 if (exefile && !config_file)
1248 strcpyW(local_config_file, exefile);
1249 strcatW(local_config_file, dotconfig);
1251 config_file = local_config_file;
1254 if (config_file)
1256 BOOL found = FALSE;
1257 hr = parse_config_file(config_file, &parsed_config);
1259 if (SUCCEEDED(hr))
1261 supported_runtime *entry;
1262 LIST_FOR_EACH_ENTRY(entry, &parsed_config.supported_runtimes, supported_runtime, entry)
1264 hr = get_runtime(entry->version, TRUE, &IID_ICLRRuntimeInfo, (void**)result);
1265 if (SUCCEEDED(hr))
1267 found = TRUE;
1268 break;
1272 else
1274 WARN("failed to parse config file %s, hr=%x\n", debugstr_w(config_file), hr);
1277 free_parsed_config_file(&parsed_config);
1279 if (found)
1280 return S_OK;
1283 if (exefile && !version)
1285 hr = CLRMetaHost_GetVersionFromFile(0, exefile, local_version, &local_version_size);
1287 version = local_version;
1289 if (FAILED(hr)) return hr;
1292 if (version)
1294 hr = CLRMetaHost_GetRuntime(0, version, &IID_ICLRRuntimeInfo, (void**)result);
1295 if(SUCCEEDED(hr))
1296 return hr;
1299 if (runtimeinfo_flags & RUNTIME_INFO_UPGRADE_VERSION)
1301 DWORD major, minor, build;
1303 if (version && !parse_runtime_version(version, &major, &minor, &build))
1305 ERR("Cannot parse %s\n", debugstr_w(version));
1306 return CLR_E_SHIM_RUNTIME;
1309 if (legacy)
1310 i = 3;
1311 else
1312 i = NUM_RUNTIMES;
1314 while (i--)
1316 /* Must be greater or equal to the version passed in. */
1317 if (!version || ((runtimes[i].major >= major && runtimes[i].minor >= minor && runtimes[i].build >= build) ||
1318 (runtimes[i].major >= major && runtimes[i].minor > minor) ||
1319 (runtimes[i].major > major)))
1321 return ICLRRuntimeInfo_QueryInterface(&runtimes[i].ICLRRuntimeInfo_iface,
1322 &IID_ICLRRuntimeInfo, (void **)result);
1326 return CLR_E_SHIM_RUNTIME;
1329 return CLR_E_SHIM_RUNTIME;