From 4018697078975825bb256508127584b1c575ced9 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Fri, 1 Oct 2010 15:37:25 -0500 Subject: [PATCH 05/20] mscoree: Use the .NET 4 interfaces to implement CorBindToRuntimeEx. --- dlls/mscoree/corruntimehost.c | 27 --------------------------- dlls/mscoree/mscoree_main.c | 20 ++++++++++++++------ dlls/mscoree/mscoree_private.h | 2 -- 3 files changed, 14 insertions(+), 35 deletions(-) diff --git a/dlls/mscoree/corruntimehost.c b/dlls/mscoree/corruntimehost.c index 831f6de..1e9cc7f 100644 --- a/dlls/mscoree/corruntimehost.c +++ b/dlls/mscoree/corruntimehost.c @@ -42,7 +42,6 @@ struct RuntimeHost const CLRRuntimeInfo *version; const loaded_mono *mono; LONG ref; - BOOL legacy; /* if True, this was created by create_corruntimehost, and Release frees it */ }; static inline RuntimeHost *impl_from_ICorRuntimeHost( ICorRuntimeHost *iface ) @@ -86,10 +85,6 @@ static ULONG WINAPI corruntimehost_Release(ICorRuntimeHost* iface) ULONG ref; ref = InterlockedDecrement( &This->ref ); - if ( ref == 0 && This->legacy ) - { - RuntimeHost_Destroy(This); - } return ref; } @@ -289,7 +284,6 @@ HRESULT RuntimeHost_Construct(const CLRRuntimeInfo *runtime_version, This->ref = 1; This->version = runtime_version; This->mono = loaded_mono; - This->legacy = FALSE; *result = This; @@ -318,24 +312,3 @@ HRESULT RuntimeHost_Destroy(RuntimeHost *This) HeapFree( GetProcessHeap(), 0, This ); return S_OK; } - -IUnknown* create_corruntimehost(void) -{ - RuntimeHost *This; - IUnknown *result; - - if (FAILED(RuntimeHost_Construct(NULL, NULL, &This))) - return NULL; - - This->legacy = TRUE; - - if (FAILED(RuntimeHost_GetInterface(This, &CLSID_CorRuntimeHost, &IID_IUnknown, (void**)&result))) - { - RuntimeHost_Destroy(This); - return NULL; - } - - FIXME("return iface %p\n", result); - - return result; -} diff --git a/dlls/mscoree/mscoree_main.c b/dlls/mscoree/mscoree_main.c index cb55d63..6a16354 100644 --- a/dlls/mscoree/mscoree_main.c +++ b/dlls/mscoree/mscoree_main.c @@ -574,16 +574,24 @@ HRESULT WINAPI LoadStringRC(UINT resId, LPWSTR pBuffer, int iBufLen, int bQuiet) HRESULT WINAPI CorBindToRuntimeEx(LPWSTR szVersion, LPWSTR szBuildFlavor, DWORD nflags, REFCLSID rslsid, REFIID riid, LPVOID *ppv) { - FIXME("%s %s %d %s %s %p\n", debugstr_w(szVersion), debugstr_w(szBuildFlavor), nflags, debugstr_guid( rslsid ), + HRESULT ret; + ICLRRuntimeInfo *info; + + TRACE("%s %s %d %s %s %p\n", debugstr_w(szVersion), debugstr_w(szBuildFlavor), nflags, debugstr_guid( rslsid ), debugstr_guid( riid ), ppv); - if(IsEqualGUID( riid, &IID_ICorRuntimeHost )) + *ppv = NULL; + + ret = get_runtime_info(NULL, szVersion, NULL, nflags, 0, TRUE, &info); + + if (SUCCEEDED(ret)) { - *ppv = create_corruntimehost(); - return S_OK; + ret = ICLRRuntimeInfo_GetInterface(info, rslsid, riid, ppv); + + ICLRRuntimeInfo_Release(info); } - *ppv = NULL; - return E_NOTIMPL; + + return ret; } HRESULT WINAPI CorBindToCurrentRuntime(LPCWSTR filename, REFCLSID rclsid, REFIID riid, LPVOID *ppv) diff --git a/dlls/mscoree/mscoree_private.h b/dlls/mscoree/mscoree_private.h index 6273b82..7114d9e 100644 --- a/dlls/mscoree/mscoree_private.h +++ b/dlls/mscoree/mscoree_private.h @@ -20,8 +20,6 @@ #ifndef __MSCOREE_PRIVATE__ #define __MSCOREE_PRIVATE__ -extern IUnknown* create_corruntimehost(void); - extern HRESULT CLRMetaHost_CreateInstance(REFIID riid, void **ppobj); typedef struct tagASSEMBLY ASSEMBLY; -- 1.7.1