DCOM: Local Server Marshaling Fix

Robert Shearman rob at codeweavers.com
Fri Jul 30 07:30:17 CDT 2004


Changelog:

Mike Hearn <mh at codeweavers.com>
Don't marshal IClassFactory into the local server pipe until we have connected, otherwise we might end up with stubs that are never used.


-------------- next part --------------
Index: wine/dlls/ole32/compobj.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/compobj.c,v
retrieving revision 1.99
diff -u -r1.99 compobj.c
--- wine/dlls/ole32/compobj.c	29 Jul 2004 02:43:48 -0000	1.99
+++ wine/dlls/ole32/compobj.c	30 Jul 2004 12:26:28 -0000
@@ -1061,41 +1061,10 @@
     ULONG		res;
 
     TRACE("Starting threader for %s.\n",debugstr_guid(&newClass->classIdentifier));
+
     strcpy(pipefn,PIPEPREF);
     WINE_StringFromCLSID(&newClass->classIdentifier,pipefn+strlen(PIPEPREF));
 
-    hres = IUnknown_QueryInterface(newClass->classObject,&IID_IClassFactory,(LPVOID*)&classfac);
-    if (hres) return hres;
-
-    hres = CreateStreamOnHGlobal(0,TRUE,&pStm);
-    if (hres) {
-	FIXME("Failed to create stream on hglobal.\n");
-	return hres;
-    }
-    hres = CoMarshalInterface(pStm,&IID_IClassFactory,(LPVOID)classfac,0,NULL,0);
-    if (hres) {
-	FIXME("CoMarshalInterface failed, %lx!\n",hres);
-	return hres;
-    }
-    hres = IStream_Stat(pStm,&ststg,0);
-    if (hres) return hres;
-
-    buflen = ststg.cbSize.u.LowPart;
-    buffer = HeapAlloc(GetProcessHeap(),0,buflen);
-    seekto.u.LowPart = 0;
-    seekto.u.HighPart = 0;
-    hres = IStream_Seek(pStm,seekto,SEEK_SET,&newpos);
-    if (hres) {
-	FIXME("IStream_Seek failed, %lx\n",hres);
-	return hres;
-    }
-    hres = IStream_Read(pStm,buffer,buflen,&res);
-    if (hres) {
-	FIXME("Stream Read failed, %lx\n",hres);
-	return hres;
-    }
-    IStream_Release(pStm);
-
     hPipe = CreateNamedPipeA( pipefn, PIPE_ACCESS_DUPLEX,
                PIPE_TYPE_BYTE|PIPE_WAIT, PIPE_UNLIMITED_INSTANCES,
                4096, 4096, NMPWAIT_USE_DEFAULT_WAIT, NULL );
@@ -1108,9 +1077,52 @@
             ERR("Failure during ConnectNamedPipe %lx, ABORT!\n",GetLastError());
             break;
         }
+
+        TRACE("marshalling IClassFactory to client\n");
+        
+        hres = IUnknown_QueryInterface(newClass->classObject,&IID_IClassFactory,(LPVOID*)&classfac);
+        if (hres) return hres;
+
+        hres = CreateStreamOnHGlobal(0,TRUE,&pStm);
+        if (hres) {
+            FIXME("Failed to create stream on hglobal.\n");
+            return hres;
+        }
+        hres = CoMarshalInterface(pStm,&IID_IClassFactory,(LPVOID)classfac,0,NULL,0);
+        if (hres) {
+            FIXME("CoMarshalInterface failed, %lx!\n",hres);
+            return hres;
+        }
+
+        DWORD rc = IUnknown_Release(classfac); /* is this right? */
+        TRACE("classfactory rc=%ld\n", rc);
+        
+        hres = IStream_Stat(pStm,&ststg,0);
+        if (hres) return hres;
+
+        buflen = ststg.cbSize.u.LowPart;
+        buffer = HeapAlloc(GetProcessHeap(),0,buflen);
+        seekto.u.LowPart = 0;
+        seekto.u.HighPart = 0;
+        hres = IStream_Seek(pStm,seekto,SEEK_SET,&newpos);
+        if (hres) {
+            FIXME("IStream_Seek failed, %lx\n",hres);
+            return hres;
+        }
+        
+        hres = IStream_Read(pStm,buffer,buflen,&res);
+        if (hres) {
+            FIXME("Stream Read failed, %lx\n",hres);
+            return hres;
+        }
+        
+        IStream_Release(pStm);
+
         WriteFile(hPipe,buffer,buflen,&res,NULL);
         FlushFileBuffers(hPipe);
         DisconnectNamedPipe(hPipe);
+
+        TRACE("done marshalling IClassFactory\n");
     }
     CloseHandle(hPipe);
     return 0;


More information about the wine-patches mailing list