RPC Merge (B_PL5)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




From Jürgen Schmied's RPC patches.
Minor changes may exist between this and the original 
patch but it's intended to be basically the same stuff.

LICENSE: X11

CHANGELOG:

* dlls/rpcrt4: rpcrt4.spec, cpsf.c (new), Makefile.in,
  rpcrt4_main.c: Ove Kaaven <ovek@transgaming.com>
- NdrDllCanUnloadNow, NdrDllGetClassObject,
  NdrDllRegisterProxy, NdrDllUnregisterProxy,
  CStdPSFactory methods.

-- 
gmt

"If ye love wealth better than liberty, the tranquility
of servitude better than the animating contest of freedom,
go home from us in peace. We ask not your counsels or your
arms. Crouch down and lick the hands, which feed you. May
your chains set lightly upon you, and may posterity forget
that ye were our countrymen." 

-Samuel Adams
--- dlls/rpcrt4/Makefile.in.B_PL4	2002-10-10 00:32:41.000000000 -0500
+++ dlls/rpcrt4/Makefile.in	2002-10-10 01:10:13.000000000 -0500
@@ -4,7 +4,8 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = rpcrt4.dll
-IMPORTS   = kernel32 ntdll
+IMPORTS   = kernel32 ntdll advapi32
+EXTRALIBS = $(LIBUUID)
 
 LDDLLFLAGS = @LDDLLFLAGS@
 SYMBOLFILE = $(MODULE).tmp.o
@@ -12,6 +13,7 @@
 C_SRCS = \
 	cproxy.c \
 	cstub.c \
+	cpsf.c \
 	rpc_binding.c \
 	rpc_message.c \
 	ndr_stubless.c \
--- dlls/rpcrt4/rpcrt4.spec.B_PL4	2002-10-10 01:29:45.000000000 -0500
+++ dlls/rpcrt4/rpcrt4.spec	2002-10-10 01:30:02.000000000 -0500
@@ -17,11 +17,6 @@
 @ stub MqGetContext # win9x
 @ stub MqRegisterQueue # win9x
 
-@ stdcall NdrDllCanUnloadNow(ptr) NdrDllCanUnloadNow
-@ stdcall NdrDllGetClassObject(ptr ptr ptr ptr ptr ptr) NdrDllGetClassObject
-@ stdcall NdrDllRegisterProxy(long ptr ptr) NdrDllRegisterProxy
-@ stub NdrDllUnregisterProxy
-
 @ stub RpcAbortAsyncCall
 @ stub RpcAsyncAbortCall
 @ stub RpcAsyncCancelCall
@@ -199,6 +194,11 @@
 @ stdcall IUnknown_AddRef_Proxy(ptr) IUnknown_AddRef_Proxy
 @ stdcall IUnknown_Release_Proxy(ptr) IUnknown_Release_Proxy
 
+@ stdcall NdrDllCanUnloadNow(ptr) NdrDllCanUnloadNow
+@ stdcall NdrDllGetClassObject(ptr ptr ptr ptr ptr ptr) NdrDllGetClassObject
+@ stdcall NdrDllRegisterProxy(long ptr ptr) NdrDllRegisterProxy
+@ stdcall NdrDllUnregisterProxy(long ptr ptr) NdrDllUnregisterProxy
+
 @ stub NdrAllocate
 @ stub NdrAsyncClientCall
 @ stub NdrAsyncServerCall
--- dlls/rpcrt4/rpcrt4_main.c.B_PL4	2002-10-10 01:58:29.000000000 -0500
+++ dlls/rpcrt4/rpcrt4_main.c	2002-10-10 02:00:03.000000000 -0500
@@ -591,19 +591,6 @@
 }
 
 /***********************************************************************
- *		NdrDllRegisterProxy (RPCRT4.@)
- */
-HRESULT WINAPI NdrDllRegisterProxy(
-  HMODULE hDll,          /* [in] */
-  const ProxyFileInfo **pProxyFileList, /* [in] */
-  const CLSID *pclsid    /* [in] */
-)
-{
-  FIXME("(%x,%p,%s), stub!\n",hDll,pProxyFileList,debugstr_guid(pclsid));
-  return S_OK;
-}
-
-/***********************************************************************
  *		RpcServerUseProtseqEpA (RPCRT4.@)
  */
 
@@ -732,29 +719,6 @@
 }
 
 /***********************************************************************
- *		NdrDllCanUnloadNow (RPCRT4.@)
- */
-HRESULT WINAPI NdrDllCanUnloadNow(CStdPSFactoryBuffer *pPSFactoryBuffer)
-{
-    FIXME("%p\n",pPSFactoryBuffer);
-    return FALSE;
-}
-
-/***********************************************************************
- *		NdrDllGetClassObject (RPCRT4.@)
- */
-HRESULT WINAPI NdrDllGetClassObject(
-    REFCLSID rclsid, REFIID riid , LPVOID *ppv,
-    const ProxyFileInfo **   pProxyFileList,
-    const CLSID *            pclsid,
-    CStdPSFactoryBuffer *    pPSFactoryBuffer)
-{
-    if(ppv)
-        *ppv = NULL;
-    return RPC_S_UNKNOWN_IF;
-}
-
-/***********************************************************************
  *              DllRegisterServer (RPCRT4.@)
  */
 
--- /dev/null	1969-12-31 18:00:00.000000000 -0600
+++ dlls/rpcrt4/cpsf.c	2002-10-10 02:09:01.000000000 -0500
@@ -0,0 +1,240 @@
+/*
+ * COM proxy/stub factory (CStdPSFactory) implementation
+ *
+ * Copyright 2001 Ove Kåven, TransGaming Technologies
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+#include "winreg.h"
+
+#include "wine/obj_base.h"
+#include "wine/obj_channel.h"
+
+#include "rpcproxy.h"
+
+#include "wine/debug.h"
+
+#include "cpsf.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(ole);
+
+static BOOL FindProxyInfo(const ProxyFileInfo **pProxyFileList, REFIID riid, const ProxyFileInfo **pProxyInfo, int *pIndex)
+{
+  while (*pProxyFileList) {
+    if ((*pProxyFileList)->pIIDLookupRtn(riid, pIndex)) {
+      *pProxyInfo = *pProxyFileList;
+      TRACE("found: ProxyInfo %p Index %d\n", *pProxyInfo, *pIndex);
+      return TRUE;
+    }
+    pProxyFileList++;
+  }
+  TRACE("not found\n");
+  return FALSE;
+}
+
+static HRESULT WINAPI CStdPSFactory_QueryInterface(LPPSFACTORYBUFFER iface,
+                                                  REFIID riid,
+                                                  LPVOID *obj)
+{
+  ICOM_THIS(CStdPSFactoryBuffer,iface);
+  TRACE("(%p)->QueryInterface(%s,%p)\n",iface,debugstr_guid(riid),obj);
+  if (IsEqualGUID(&IID_IUnknown,riid) ||
+      IsEqualGUID(&IID_IPSFactoryBuffer,riid)) {
+    *obj = This;
+    This->RefCount++;
+    return S_OK;
+  }
+  return E_NOINTERFACE;
+}
+
+static ULONG WINAPI CStdPSFactory_AddRef(LPPSFACTORYBUFFER iface)
+{
+  ICOM_THIS(CStdPSFactoryBuffer,iface);
+  TRACE("(%p)->AddRef()\n",iface);
+  return ++(This->RefCount);
+}
+
+static ULONG WINAPI CStdPSFactory_Release(LPPSFACTORYBUFFER iface)
+{
+  ICOM_THIS(CStdPSFactoryBuffer,iface);
+  TRACE("(%p)->Release()\n",iface);
+  return --(This->RefCount);
+}
+
+static HRESULT WINAPI CStdPSFactory_CreateProxy(LPPSFACTORYBUFFER iface,
+                                               LPUNKNOWN pUnkOuter,
+                                               REFIID riid,
+                                               LPRPCPROXYBUFFER *ppProxy,
+                                               LPVOID *ppv)
+{
+  ICOM_THIS(CStdPSFactoryBuffer,iface);
+  const ProxyFileInfo *ProxyInfo;
+  int Index;
+  TRACE("(%p)->CreateProxy(%p,%s,%p,%p)\n",iface,pUnkOuter,
+       debugstr_guid(riid),ppProxy,ppv);
+  if (!FindProxyInfo(This->pProxyFileList,riid,&ProxyInfo,&Index))
+    return E_NOINTERFACE;
+  return StdProxy_Construct(riid, pUnkOuter, ProxyInfo->pProxyVtblList[Index],
+                           ProxyInfo->pStubVtblList[Index], iface, ppProxy, ppv);
+}
+
+static HRESULT WINAPI CStdPSFactory_CreateStub(LPPSFACTORYBUFFER iface,
+                                              REFIID riid,
+                                              LPUNKNOWN pUnkServer,
+                                              LPRPCSTUBBUFFER *ppStub)
+{
+  ICOM_THIS(CStdPSFactoryBuffer,iface);
+  const ProxyFileInfo *ProxyInfo;
+  int Index;
+  TRACE("(%p)->CreateStub(%s,%p,%p)\n",iface,debugstr_guid(riid),
+       pUnkServer,ppStub);
+  if (!FindProxyInfo(This->pProxyFileList,riid,&ProxyInfo,&Index))
+    return E_NOINTERFACE;
+  return CStdStubBuffer_Construct(riid, pUnkServer, ProxyInfo->pStubVtblList[Index], iface, ppStub);
+}
+
+static ICOM_VTABLE(IPSFactoryBuffer) CStdPSFactory_Vtbl =
+{
+  ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+  CStdPSFactory_QueryInterface,
+  CStdPSFactory_AddRef,
+  CStdPSFactory_Release,
+  CStdPSFactory_CreateProxy,
+  CStdPSFactory_CreateStub
+};
+
+/***********************************************************************
+ *           NdrDllGetClassObject [RPCRT4.@]
+ */
+HRESULT WINAPI NdrDllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv,
+                                   const ProxyFileInfo **pProxyFileList,
+                                   const CLSID *pclsid,
+                                   CStdPSFactoryBuffer *pPSFactoryBuffer)
+{
+  *ppv = NULL;
+  if (!pPSFactoryBuffer->lpVtbl) {
+    pPSFactoryBuffer->lpVtbl = &CStdPSFactory_Vtbl;
+    pPSFactoryBuffer->RefCount = 0;
+    pPSFactoryBuffer->pProxyFileList = pProxyFileList;
+  }
+  if (IsEqualGUID(rclsid, pclsid))
+    return IPSFactoryBuffer_QueryInterface((LPPSFACTORYBUFFER)pPSFactoryBuffer, iid, ppv);
+  return CLASS_E_CLASSNOTAVAILABLE;
+}
+
+/***********************************************************************
+ *           NdrDllCanUnloadNow [RPCRT4.@]
+ */
+HRESULT WINAPI NdrDllCanUnloadNow(CStdPSFactoryBuffer *pPSFactoryBuffer)
+{
+  return !(pPSFactoryBuffer->RefCount);
+}
+
+/***********************************************************************
+ *           NdrDllRegisterProxy [RPCRT4.@]
+ */
+HRESULT WINAPI NdrDllRegisterProxy(HMODULE hDll,
+                                  const ProxyFileInfo **pProxyFileList,
+                                  const CLSID *pclsid)
+{
+  LPSTR clsid;
+  char keyname[120], module[120];
+  HKEY key, subkey;
+
+  TRACE("(%x,%p,%s)\n", hDll, pProxyFileList, debugstr_guid(pclsid));
+  UuidToStringA((UUID*)pclsid, &clsid);
+
+  /* register interfaces to point to clsid */
+  while (*pProxyFileList) {
+    unsigned u;
+    for (u=0; u<(*pProxyFileList)->TableSize; u++) {
+      CInterfaceProxyVtbl *proxy = (*pProxyFileList)->pProxyVtblList[u];
+      PCInterfaceName name = (*pProxyFileList)->pNamesArray[u];
+      LPSTR iid;
+
+      TRACE("registering %s %s => %s\n", name, debugstr_guid(proxy->header.piid), clsid);
+
+      UuidToStringA((UUID*)proxy->header.piid, &iid);
+      snprintf(keyname, sizeof(keyname), "Interface\\%s", iid);
+      RpcStringFreeA(&iid);
+      if (RegCreateKeyExA(HKEY_CLASSES_ROOT, keyname, 0, NULL, 0,
+                          KEY_WRITE, NULL, &key, NULL) == ERROR_SUCCESS) {
+        if (name)
+          RegSetValueExA(key, NULL, 0, REG_SZ, name, strlen(name));
+        if (RegCreateKeyExA(key, "ProxyStubClsid32", 0, NULL, 0,
+                            KEY_WRITE, NULL, &subkey, NULL) == ERROR_SUCCESS) {
+          RegSetValueExA(subkey, NULL, 0, REG_SZ, clsid, strlen(clsid));
+          RegCloseKey(subkey);
+        }
+        RegCloseKey(key);
+      }
+    }
+    pProxyFileList++;
+  }
+
+  /* register clsid to point to module */
+  snprintf(keyname, sizeof(keyname), "CLSID\\%s", clsid);
+  GetModuleFileNameA(hDll, module, sizeof(module));
+  TRACE("registering %s => %s\n", clsid, module);
+  if (RegCreateKeyExA(HKEY_CLASSES_ROOT, keyname, 0, NULL, 0,
+                      KEY_WRITE, NULL, &key, NULL) == ERROR_SUCCESS) {
+     if (RegCreateKeyExA(key, "InProcServer32", 0, NULL, 0,
+                         KEY_WRITE, NULL, &subkey, NULL) == ERROR_SUCCESS) {
+       RegSetValueExA(subkey, NULL, 0, REG_SZ, module, strlen(module));
+       RegCloseKey(subkey);
+     }
+     RegCloseKey(key);
+  }
+
+  /* done */
+  RpcStringFreeA(&clsid);
+  return S_OK;
+}
+
+/***********************************************************************
+ *           NdrDllUnregisterProxy [RPCRT4.@]
+ */
+HRESULT WINAPI NdrDllUnregisterProxy(HMODULE hDll,
+                                    const ProxyFileInfo **pProxyFileList,
+                                    const CLSID *pclsid)
+{
+  LPSTR clsid;
+  char keyname[120], module[120];
+
+  TRACE("(%x,%p,%s)\n", hDll, pProxyFileList, debugstr_guid(pclsid));
+  UuidToStringA((UUID*)pclsid, &clsid);
+
+  /* unregister interfaces */
+  while (*pProxyFileList) {
+    unsigned u;
+    for (u=0; u<(*pProxyFileList)->TableSize; u++) {
+      CInterfaceProxyVtbl *proxy = (*pProxyFileList)->pProxyVtblList[u];
+      PCInterfaceName name = (*pProxyFileList)->pNamesArray[u];
+      LPSTR iid;
+
+      TRACE("unregistering %s %s <= %s\n", name, debugstr_guid(proxy->header.piid), clsid);
+
+      UuidToStringA((UUID*)proxy->header.piid, &iid);
+      snprintf(keyname, sizeof(keyname), "Interface\\%s", iid);
+      RpcStringFreeA(&iid);
+      RegDeleteKeyA(HKEY_CLASSES_ROOT, keyname);
+    }
+    pProxyFileList++;
+  }
+
+  /* unregister clsid */
+  snprintf(keyname, sizeof(keyname), "CLSID\\%s", clsid);
+  GetModuleFileNameA(hDll, module, sizeof(module));
+  TRACE("unregistering %s <= %s\n", clsid, module);
+  RegDeleteKeyA(HKEY_CLASSES_ROOT, keyname);
+
+  /* done */
+  RpcStringFreeA(&clsid);
+  return S_OK;
+}
+

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux