Vincent Povirk : mscoree: Implement ICLRMetaHost_GetRuntime.
Alexandre Julliard
julliard at winehq.org
Wed Oct 13 11:43:06 CDT 2010
Module: wine
Branch: master
Commit: a7bda5c2b55fc3efd46db2e0f50128c01e98fde1
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a7bda5c2b55fc3efd46db2e0f50128c01e98fde1
Author: Vincent Povirk <vincent at codeweavers.com>
Date: Tue Sep 28 17:53:14 2010 -0500
mscoree: Implement ICLRMetaHost_GetRuntime.
---
dlls/mscoree/corruntimehost.c | 2 +
dlls/mscoree/metahost.c | 78 +++++++++++++++++++++++++++++++++++++---
dlls/mscoree/tests/metahost.c | 10 ++++--
3 files changed, 81 insertions(+), 9 deletions(-)
diff --git a/dlls/mscoree/corruntimehost.c b/dlls/mscoree/corruntimehost.c
index 794f1c8..ee0ad44 100644
--- a/dlls/mscoree/corruntimehost.c
+++ b/dlls/mscoree/corruntimehost.c
@@ -290,6 +290,8 @@ HRESULT RuntimeHost_Construct(const CLRRuntimeInfo *runtime_version,
This->mono = loaded_mono;
This->legacy = FALSE;
+ *result = This;
+
return S_OK;
}
diff --git a/dlls/mscoree/metahost.c b/dlls/mscoree/metahost.c
index f32afed..0939eb3 100644
--- a/dlls/mscoree/metahost.c
+++ b/dlls/mscoree/metahost.c
@@ -31,6 +31,7 @@
#include "winreg.h"
#include "ole2.h"
+#include "corerror.h"
#include "mscoree.h"
#include "metahost.h"
#include "mscoree_private.h"
@@ -86,15 +87,11 @@ static HRESULT CLRRuntimeInfo_GetRuntimeHost(CLRRuntimeInfo *This, RuntimeHost *
EnterCriticalSection(&runtime_list_cs);
- if (!This->loaded_runtime)
- goto end;
-
hr = load_mono(This, &ploaded_mono);
if (SUCCEEDED(hr))
hr = RuntimeHost_Construct(This, ploaded_mono, &This->loaded_runtime);
-end:
LeaveCriticalSection(&runtime_list_cs);
if (SUCCEEDED(hr))
@@ -662,12 +659,81 @@ static ULONG WINAPI CLRMetaHost_Release(ICLRMetaHost* iface)
return 1;
}
+static BOOL parse_runtime_version(LPCWSTR version, DWORD *major, DWORD *minor, DWORD *build)
+{
+ *major = 0;
+ *minor = 0;
+ *build = 0;
+
+ if (version[0] == 'v')
+ {
+ version++;
+ if (!isdigit(*version))
+ return FALSE;
+
+ while (isdigit(*version))
+ *major = *major * 10 + (*version++ - '0');
+
+ if (*version == 0)
+ return TRUE;
+
+ if (*version++ != '.' || !isdigit(*version))
+ return FALSE;
+
+ while (isdigit(*version))
+ *minor = *minor * 10 + (*version++ - '0');
+
+ if (*version == 0)
+ return TRUE;
+
+ if (*version++ != '.' || !isdigit(*version))
+ return FALSE;
+
+ while (isdigit(*version))
+ *build = *build * 10 + (*version++ - '0');
+
+ return *version == 0;
+ }
+ else
+ return FALSE;
+}
+
static HRESULT WINAPI CLRMetaHost_GetRuntime(ICLRMetaHost* iface,
LPCWSTR pwzVersion, REFIID iid, LPVOID *ppRuntime)
{
- FIXME("%s %s %p\n", debugstr_w(pwzVersion), debugstr_guid(iid), ppRuntime);
+ int i;
+ DWORD major, minor, build;
- return E_NOTIMPL;
+ TRACE("%s %s %p\n", debugstr_w(pwzVersion), debugstr_guid(iid), ppRuntime);
+
+ if (!pwzVersion)
+ return E_POINTER;
+
+ if (!parse_runtime_version(pwzVersion, &major, &minor, &build))
+ {
+ ERR("Cannot parse %s\n", debugstr_w(pwzVersion));
+ return CLR_E_SHIM_RUNTIME;
+ }
+
+ find_runtimes();
+
+ for (i=0; i<NUM_RUNTIMES; i++)
+ {
+ if (runtimes[i].major == major && runtimes[i].minor == minor &&
+ runtimes[i].build == build)
+ {
+ if (runtimes[i].mono_abi_version)
+ return IUnknown_QueryInterface((IUnknown*)&runtimes[i], iid, ppRuntime);
+ else
+ {
+ ERR("Mono is missing %s runtime\n", debugstr_w(pwzVersion));
+ return CLR_E_SHIM_RUNTIME;
+ }
+ }
+ }
+
+ FIXME("Unrecognized version %s\n", debugstr_w(pwzVersion));
+ return CLR_E_SHIM_RUNTIME;
}
static HRESULT WINAPI CLRMetaHost_GetVersionFromFile(ICLRMetaHost* iface,
diff --git a/dlls/mscoree/tests/metahost.c b/dlls/mscoree/tests/metahost.c
index 75f1220..bf9e383 100644
--- a/dlls/mscoree/tests/metahost.c
+++ b/dlls/mscoree/tests/metahost.c
@@ -118,10 +118,14 @@ void test_getruntime(void)
WCHAR buf[MAX_PATH];
hr = ICLRMetaHost_GetRuntime(metahost, NULL, &IID_ICLRRuntimeInfo, (void**)&info);
- todo_wine ok(hr == E_POINTER, "GetVersion failed, hr=%x\n", hr);
+ ok(hr == E_POINTER, "GetVersion failed, hr=%x\n", hr);
hr = ICLRMetaHost_GetRuntime(metahost, twodotzero, &IID_ICLRRuntimeInfo, (void**)&info);
- todo_wine ok(hr == S_OK, "GetVersion failed, hr=%x\n", hr);
+ if (hr == CLR_E_SHIM_RUNTIME)
+ /* FIXME: Get Mono properly packaged so we can fail here. */
+ todo_wine ok(hr == S_OK, "GetVersion failed, hr=%x\n", hr);
+ else
+ ok(hr == S_OK, "GetVersion failed, hr=%x\n", hr);
if (hr != S_OK) return;
count = MAX_PATH;
@@ -134,7 +138,7 @@ void test_getruntime(void)
/* Versions must match exactly. */
hr = ICLRMetaHost_GetRuntime(metahost, twodotzerodotzero, &IID_ICLRRuntimeInfo, (void**)&info);
- todo_wine ok(hr == CLR_E_SHIM_RUNTIME, "GetVersion failed, hr=%x\n", hr);
+ ok(hr == CLR_E_SHIM_RUNTIME, "GetVersion failed, hr=%x\n", hr);
}
START_TEST(metahost)
More information about the wine-cvs
mailing list