From 45a24b8d9855cad6ad07c146c281fa788e40eb9c Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Fri, 1 Oct 2010 14:11:09 -0500 Subject: [PATCH 03/20] mscoree: Use the new Mono runtime search code in GetRequestedRuntimeInfo. --- dlls/mscoree/assembly.c | 1 + dlls/mscoree/corruntimehost.c | 1 + dlls/mscoree/metahost.c | 48 ++++++++++++++++++++++++++++++++++++++++ dlls/mscoree/mscoree_main.c | 35 ++++++++++++++--------------- dlls/mscoree/mscoree_private.h | 3 ++ 5 files changed, 70 insertions(+), 18 deletions(-) diff --git a/dlls/mscoree/assembly.c b/dlls/mscoree/assembly.c index b4b72d4..04e5d23 100644 --- a/dlls/mscoree/assembly.c +++ b/dlls/mscoree/assembly.c @@ -28,6 +28,7 @@ #include "dbghelp.h" #include "ole2.h" #include "corhdr.h" +#include "metahost.h" #include "mscoree_private.h" #include "wine/debug.h" diff --git a/dlls/mscoree/corruntimehost.c b/dlls/mscoree/corruntimehost.c index ee0ad44..831f6de 100644 --- a/dlls/mscoree/corruntimehost.c +++ b/dlls/mscoree/corruntimehost.c @@ -29,6 +29,7 @@ #include "cor.h" #include "mscoree.h" +#include "metahost.h" #include "mscoree_private.h" #include "wine/debug.h" diff --git a/dlls/mscoree/metahost.c b/dlls/mscoree/metahost.c index bf62f3c..57fce37 100644 --- a/dlls/mscoree/metahost.c +++ b/dlls/mscoree/metahost.c @@ -899,3 +899,51 @@ extern HRESULT CLRMetaHost_CreateInstance(REFIID riid, void **ppobj) { return ICLRMetaHost_QueryInterface((ICLRMetaHost*)&GlobalCLRMetaHost, riid, ppobj); } + +HRESULT get_runtime_info(LPCWSTR exefile, LPCWSTR version, LPCWSTR config_file, + DWORD startup_flags, DWORD runtimeinfo_flags, BOOL legacy, ICLRRuntimeInfo **result) +{ + static const DWORD supported_startup_flags = 0; + static const DWORD supported_runtime_flags = RUNTIME_INFO_UPGRADE_VERSION; + int i; + + if (exefile) + FIXME("ignoring exe filename %s\n", debugstr_w(exefile)); + + if (config_file) + FIXME("ignoring config filename %s\n", debugstr_w(config_file)); + + if (startup_flags & ~supported_startup_flags) + FIXME("unsupported startup flags %x\n", startup_flags & ~supported_startup_flags); + + if (runtimeinfo_flags & ~supported_runtime_flags) + FIXME("unsupported runtimeinfo flags %x\n", runtimeinfo_flags & ~supported_runtime_flags); + + if (version) + { + return CLRMetaHost_GetRuntime(0, version, &IID_ICLRRuntimeInfo, (void**)result); + } + + if (runtimeinfo_flags & RUNTIME_INFO_UPGRADE_VERSION) + { + find_runtimes(); + + if (legacy) + i = 2; + else + i = NUM_RUNTIMES; + + while (i--) + { + if (runtimes[i].mono_abi_version) + return IUnknown_QueryInterface((IUnknown*)&runtimes[i], + &IID_ICLRRuntimeInfo, (void**)result); + } + + ERR("No %s.NET runtime installed\n", legacy ? "legacy " : ""); + + return CLR_E_SHIM_RUNTIME; + } + + return CLR_E_SHIM_RUNTIME; +} diff --git a/dlls/mscoree/mscoree_main.c b/dlls/mscoree/mscoree_main.c index fe7c35b..a57d766 100644 --- a/dlls/mscoree/mscoree_main.c +++ b/dlls/mscoree/mscoree_main.c @@ -21,6 +21,7 @@ #include +#define COBJMACROS #include "wine/unicode.h" #include "wine/library.h" #include "windef.h" @@ -516,35 +517,33 @@ HRESULT WINAPI GetRequestedRuntimeInfo(LPCWSTR pExe, LPCWSTR pwszVersion, LPCWST LPWSTR pVersion, DWORD cchBuffer, DWORD *dwlength) { HRESULT ret; - DWORD ver_len, dir_len; - WCHAR dirW[MAX_PATH], verW[MAX_PATH]; + ICLRRuntimeInfo *info; + DWORD length_dummy; - FIXME("(%s, %s, %s, 0x%08x, 0x%08x, %p, 0x%08x, %p, %p, 0x%08x, %p) semi-stub\n", debugstr_w(pExe), + TRACE("(%s, %s, %s, 0x%08x, 0x%08x, %p, 0x%08x, %p, %p, 0x%08x, %p)\n", debugstr_w(pExe), debugstr_w(pwszVersion), debugstr_w(pConfigurationFile), startupFlags, runtimeInfoFlags, pDirectory, dwDirectory, dwDirectoryLength, pVersion, cchBuffer, dwlength); - if (!pwszVersion && !(runtimeInfoFlags & RUNTIME_INFO_UPGRADE_VERSION)) - return CLR_E_SHIM_RUNTIME; + if (!dwDirectoryLength) dwDirectoryLength = &length_dummy; - ret = GetCORSystemDirectory(dirW, dwDirectory, &dir_len); + if (!dwlength) dwlength = &length_dummy; - if (ret == S_OK) - { - if (dwDirectoryLength) - *dwDirectoryLength = dir_len; - if (pDirectory) - lstrcpyW(pDirectory, dirW); + ret = get_runtime_info(pExe, pwszVersion, pConfigurationFile, startupFlags, runtimeInfoFlags, TRUE, &info); - ret = GetCORVersion(verW, cchBuffer, &ver_len); + if (SUCCEEDED(ret)) + { + *dwlength = cchBuffer; + ret = ICLRRuntimeInfo_GetVersionString(info, pVersion, dwlength); - if (ret == S_OK) + if (SUCCEEDED(ret)) { - if (dwlength) - *dwlength = ver_len; - if (pVersion) - lstrcpyW(pVersion, verW); + *dwDirectoryLength = dwDirectory; + ret = ICLRRuntimeInfo_GetRuntimeDirectory(info, pDirectory, dwDirectoryLength); } + + ICLRRuntimeInfo_Release(info); } + return ret; } diff --git a/dlls/mscoree/mscoree_private.h b/dlls/mscoree/mscoree_private.h index 8604c81..6273b82 100644 --- a/dlls/mscoree/mscoree_private.h +++ b/dlls/mscoree/mscoree_private.h @@ -45,6 +45,9 @@ typedef struct CLRRuntimeInfo struct RuntimeHost *loaded_runtime; } CLRRuntimeInfo; +extern HRESULT get_runtime_info(LPCWSTR exefile, LPCWSTR version, LPCWSTR config_file, + DWORD startup_flags, DWORD runtimeinfo_flags, BOOL legacy, ICLRRuntimeInfo **result); + /* Mono 2.6 embedding */ typedef struct _MonoDomain MonoDomain; typedef struct _MonoAssembly MonoAssembly; -- 1.7.1