Vincent Povirk : mscoree: Implement ICorRuntimeHost_GetDefaultDomain.

Alexandre Julliard julliard at winehq.org
Fri May 20 12:44:29 CDT 2011


Module: wine
Branch: master
Commit: 6bd0887225fc05d8139e747a8581ea3a7ccc52fa
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6bd0887225fc05d8139e747a8581ea3a7ccc52fa

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Thu May 19 14:08:12 2011 -0500

mscoree: Implement ICorRuntimeHost_GetDefaultDomain.

---

 dlls/mscoree/corruntimehost.c |   79 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 77 insertions(+), 2 deletions(-)

diff --git a/dlls/mscoree/corruntimehost.c b/dlls/mscoree/corruntimehost.c
index 231295d..607537c 100644
--- a/dlls/mscoree/corruntimehost.c
+++ b/dlls/mscoree/corruntimehost.c
@@ -39,6 +39,10 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL( mscoree );
 
+#include "initguid.h"
+
+DEFINE_GUID(IID__AppDomain, 0x05f696dc,0x2b29,0x3663,0xad,0x8b,0xc4,0x38,0x9c,0xf2,0xa7,0x13);
+
 struct RuntimeHost
 {
     const struct ICorRuntimeHostVtbl *lpVtbl;
@@ -142,6 +146,65 @@ static void RuntimeHost_DeleteDomain(RuntimeHost *This, MonoDomain *domain)
     LeaveCriticalSection(&This->lock);
 }
 
+static HRESULT RuntimeHost_GetIUnknownForDomain(RuntimeHost *This, MonoDomain *domain, IUnknown **punk)
+{
+    HRESULT hr;
+    void *args[0];
+    MonoAssembly *assembly;
+    MonoImage *image;
+    MonoClass *klass;
+    MonoMethod *method;
+    MonoObject *appdomain_object;
+    IUnknown *unk;
+
+    assembly = This->mono->mono_domain_assembly_open(domain, "mscorlib");
+    if (!assembly)
+    {
+        ERR("Cannot load mscorlib\n");
+        return E_FAIL;
+    }
+
+    image = This->mono->mono_assembly_get_image(assembly);
+    if (!image)
+    {
+        ERR("Couldn't get assembly image\n");
+        return E_FAIL;
+    }
+
+    klass = This->mono->mono_class_from_name(image, "System", "AppDomain");
+    if (!klass)
+    {
+        ERR("Couldn't get class from image\n");
+        return E_FAIL;
+    }
+
+    method = This->mono->mono_class_get_method_from_name(klass, "get_CurrentDomain", 0);
+    if (!method)
+    {
+        ERR("Couldn't get method from class\n");
+        return E_FAIL;
+    }
+
+    args[0] = NULL;
+    appdomain_object = This->mono->mono_runtime_invoke(method, NULL, args, NULL);
+    if (!appdomain_object)
+    {
+        ERR("Couldn't get result pointer\n");
+        return E_FAIL;
+    }
+
+    hr = RuntimeHost_GetIUnknownForObject(This, appdomain_object, &unk);
+
+    if (SUCCEEDED(hr))
+    {
+        hr = IUnknown_QueryInterface(unk, &IID__AppDomain, (void**)punk);
+
+        IUnknown_Release(unk);
+    }
+
+    return hr;
+}
+
 static inline RuntimeHost *impl_from_ICLRRuntimeHost( ICLRRuntimeHost *iface )
 {
     return (RuntimeHost *)((char*)iface - FIELD_OFFSET(RuntimeHost, lpCLRHostVtbl));
@@ -277,8 +340,20 @@ static HRESULT WINAPI corruntimehost_GetDefaultDomain(
     ICorRuntimeHost* iface,
     IUnknown **pAppDomain)
 {
-    FIXME("stub %p\n", iface);
-    return E_NOTIMPL;
+    RuntimeHost *This = impl_from_ICorRuntimeHost( iface );
+    HRESULT hr;
+    MonoDomain *domain;
+
+    TRACE("(%p)\n", iface);
+
+    hr = RuntimeHost_GetDefaultDomain(This, &domain);
+
+    if (SUCCEEDED(hr))
+    {
+        hr = RuntimeHost_GetIUnknownForDomain(This, domain, pAppDomain);
+    }
+
+    return hr;
 }
 
 static HRESULT WINAPI corruntimehost_EnumDomains(




More information about the wine-cvs mailing list