[v3 2/5] compobj.dll16: Implement CoGetClassObject16().

Zebediah Figura z.figura12 at gmail.com
Thu Feb 9 11:56:18 CST 2017


Fixes https://bugs.winehq.org/show_bug.cgi?id=41209

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/compobj.dll16/compobj.c | 70 +++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 66 insertions(+), 4 deletions(-)

diff --git a/dlls/compobj.dll16/compobj.c b/dlls/compobj.dll16/compobj.c
index a1acf35..92cb00f 100644
--- a/dlls/compobj.dll16/compobj.c
+++ b/dlls/compobj.dll16/compobj.c
@@ -814,14 +814,76 @@ HRESULT WINAPI CoFileTimeNow16( FILETIME *lpFileTime )
  */
 HRESULT WINAPI CoGetClassObject16(
     REFCLSID rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo,
-    REFIID iid, LPVOID *ppv)
+    REFIID riid, LPVOID *ppv)
 {
-    FIXME(", stub!\n\tCLSID:\t%s,\n\tIID:\t%s\n", debugstr_guid(rclsid), debugstr_guid(iid));
+    HRESULT hres = E_UNEXPECTED;
 
+    TRACE("CLSID: %s,IID: %s\n", debugstr_guid(rclsid), debugstr_guid(riid));
+
+    *ppv = NULL;
+ 
     if (pServerInfo) {
-	FIXME("\tpServerInfo: name=%s\n",debugstr_w(pServerInfo->pwszName));
-	FIXME("\t\tpAuthInfo=%p\n",pServerInfo->pAuthInfo);
+        FIXME("pServerInfo->name=%s pAuthInfo=%p\n",
+              debugstr_w(pServerInfo->pwszName), pServerInfo->pAuthInfo);
+    }
+
+    if (CLSCTX_INPROC_SERVER & dwClsContext)
+    {
+        char idstr[CHARS_IN_GUID];
+        char buf_key[CHARS_IN_GUID+19], dllpath[MAX_PATH+1];
+        LONG dllpath_len = sizeof(dllpath);
+        
+        struct open_dll *dll;
+        FARPROC16 DllGetClassObject;
+        
+        SEGPTR seg_rclsid = MapLS(rclsid);
+        SEGPTR seg_riid   = MapLS(riid);
+        SEGPTR seg_ppv    = MapLS(ppv);
+        WORD args[6];
+        DWORD dwRet;
+
+        hres = StringFromGUID216(rclsid, idstr, CHARS_IN_GUID);
+        sprintf(buf_key, "CLSID\\%s\\InprocServer", idstr);
+        if (RegQueryValueA(HKEY_CLASSES_ROOT, buf_key, dllpath, &dllpath_len))
+        {
+            ERR("class %s not registered\n", debugstr_guid(rclsid));
+            return REGDB_E_CLASSNOTREG;
+        }
+
+        hres = dll_list_add(dllpath, &dll);
+        if (FAILED(hres))
+            return hres;
+
+        DllGetClassObject = GetProcAddress16(dll->library, "DllGetClassObject");
+        if (!DllGetClassObject)
+        {
+            ERR("couldn't find function DllGetClassObject in %s\n", debugstr_a(dll->library_name));
+            dll_list_free(dll);
+            return CO_E_DLLNOTFOUND;
+        }
+
+        TRACE("calling DllGetClassObject %p\n", DllGetClassObject);
+        args[5] = SELECTOROF(seg_rclsid);
+        args[4] = OFFSETOF(seg_rclsid);
+        args[3] = SELECTOROF(seg_riid);
+        args[2] = OFFSETOF(seg_riid);
+        args[1] = SELECTOROF(seg_ppv);
+        args[0] = OFFSETOF(seg_ppv);
+        WOWCallback16Ex((DWORD) DllGetClassObject, WCB16_PASCAL, sizeof(args), args, &dwRet);
+        if (dwRet != S_OK)
+        {
+            ERR("DllGetClassObject returned error 0x%08x\n", dwRet);
+            return dwRet;
+        }
+
+        UnMapLS(seg_rclsid);
+        UnMapLS(seg_riid);
+        UnMapLS(seg_ppv);
+
+        return S_OK;
     }
+
+    FIXME("semi-stub\n");
     return E_NOTIMPL;
 }
 
-- 
2.7.4




More information about the wine-patches mailing list