Sync with trunk (r48008)
[reactos.git] / dll / win32 / rpcrt4 / cpsf.c
index ac1eccf..d2efa01 100644 (file)
@@ -240,7 +240,16 @@ HRESULT WINAPI NdrDllRegisterProxy(HMODULE hDll,
   DWORD len;
 
   TRACE("(%p,%p,%s)\n", hDll, pProxyFileList, debugstr_guid(pclsid));
-  format_clsid( clsid, pclsid );
+
+  //if (!hDll) return E_HANDLE;
+  if (!pProxyFileList || !*pProxyFileList) return E_NOINTERFACE;
+
+  if (pclsid)
+      format_clsid( clsid, pclsid );
+  else if ((*pProxyFileList)->TableSize > 0)
+      format_clsid( clsid,(*pProxyFileList)->pStubVtblList[0]->header.piid);
+  else
+      return E_NOINTERFACE;
 
   /* register interfaces to point to clsid */
   while (*pProxyFileList) {
@@ -297,8 +306,15 @@ HRESULT WINAPI NdrDllUnregisterProxy(HMODULE hDll,
   static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0};
   static const WCHAR interfaceW[] = {'I','n','t','e','r','f','a','c','e','\\',0};
   WCHAR keyname[50];
+  WCHAR clsid[39];
 
   TRACE("(%p,%p,%s)\n", hDll, pProxyFileList, debugstr_guid(pclsid));
+  if (pclsid)
+      format_clsid( clsid, pclsid );
+  else if ((*pProxyFileList)->TableSize > 0)
+      format_clsid( clsid,(*pProxyFileList)->pStubVtblList[0]->header.piid);
+  else
+      return E_NOINTERFACE;
 
   /* unregister interfaces */
   while (*pProxyFileList) {
@@ -318,7 +334,7 @@ HRESULT WINAPI NdrDllUnregisterProxy(HMODULE hDll,
 
   /* unregister clsid */
   strcpyW( keyname, clsidW );
-  format_clsid( keyname + strlenW(keyname), pclsid );
+  strcatW( keyname, clsid );
   RegDeleteTreeW(HKEY_CLASSES_ROOT, keyname);
 
   return S_OK;