From d36c8e9d0cdbc1f1b43c5438f6492c9c67a1ec24 Mon Sep 17 00:00:00 2001
From: Bill Medland <medbi01@accpac.com>
Date: Wed, 29 May 2002 19:20:32 +0000
Subject: [PATCH] Ensure that an out-of-process COM object is started only
 once. Allow out-of-process COM objects if request is for
 in-or-out-of-process.

---
 dlls/ole32/compobj.c | 38 ++++----------------------------------
 dlls/ole32/rpc.c     |  4 ++--
 2 files changed, 6 insertions(+), 36 deletions(-)

diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c
index 693999a289f..dc716ace643 100644
--- a/dlls/ole32/compobj.c
+++ b/dlls/ole32/compobj.c
@@ -1315,8 +1315,6 @@ HRESULT WINAPI CoGetClassObject(
     typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid,
 			     REFIID iid, LPVOID *ppv);
     DllGetClassObjectFunc DllGetClassObject;
-    HKEY key;
-    char buf[200];
 
     WINE_StringFromCLSID((LPCLSID)rclsid,xclsid);
 
@@ -1351,20 +1349,6 @@ HRESULT WINAPI CoGetClassObject(
       return hres;
     }
 
-    if (((CLSCTX_LOCAL_SERVER) & dwClsContext)
-        && !((CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER) & dwClsContext))
-	return create_marshalled_proxy(rclsid,iid,ppv);
-
-  
-
-    /* remote servers not supported yet */
-    if (     ((CLSCTX_REMOTE_SERVER) & dwClsContext)
-        && !((CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER) & dwClsContext)
-    ){
-        FIXME("CLSCTX_REMOTE_SERVER not supported!\n");
-	return E_NOINTERFACE;
-    }
-
     if ((CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER) & dwClsContext) {
         HKEY key;
 	char buf[200];
@@ -1400,31 +1384,17 @@ HRESULT WINAPI CoGetClassObject(
     }
     
 
-    /* Finally try out of process */
-    /* out of process and remote servers not supported yet */
+    /* Next try out of process */
     if (CLSCTX_LOCAL_SERVER & dwClsContext)
     {
-	memset(ProviderName,0,sizeof(ProviderName));
-	sprintf(buf,"CLSID\\%s\\LocalServer32",xclsid);
-        if (((hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key)) != ERROR_SUCCESS) ||
-            ((hres = RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)ProviderName,&ProviderNameLen)),
-             RegCloseKey (key),
-             hres != ERROR_SUCCESS))
-        {
-            hres = REGDB_E_CLASSNOTREG;
-        }
-        else
-        {
-            /* CO_E_APPNOTFOUND if no exe */
-            FIXME("CLSCTX_LOCAL_SERVER %s registered but not yet supported!\n",debugstr_w(ProviderName));
-            hres = E_ACCESSDENIED;
-	}
+        return create_marshalled_proxy(rclsid,iid,ppv);
     }
 
+    /* Finally try remote */
     if (CLSCTX_REMOTE_SERVER & dwClsContext)
     {
         FIXME ("CLSCTX_REMOTE_SERVER not supported\n");
-        hres = E_ACCESSDENIED;
+        hres = E_NOINTERFACE;
     }
 
     return hres;
diff --git a/dlls/ole32/rpc.c b/dlls/ole32/rpc.c
index 5411e6c93de..2eeafbcdd3b 100644
--- a/dlls/ole32/rpc.c
+++ b/dlls/ole32/rpc.c
@@ -479,13 +479,13 @@ create_server(REFCLSID rclsid) {
   hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key);
 
   if (hres != ERROR_SUCCESS)
-      return REGDB_E_CLASSNOTREG;
+      return REGDB_E_READREGDB; /* Probably */
 
   memset(dllName,0,sizeof(dllName));
   hres= RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)dllName,&dllNameLen);
+  RegCloseKey(key);
   if (hres)
 	  return REGDB_E_CLASSNOTREG; /* FIXME: check retval */
-  RegCloseKey(key);
   memset(&sinfo,0,sizeof(sinfo));
   sinfo.cb = sizeof(sinfo);
   if (!CreateProcessW(NULL,dllName,NULL,NULL,FALSE,0,NULL,NULL,&sinfo,&pinfo))
-- 
GitLab