From: Zebediah Figura Subject: [PATCH v5] compobj.dll16: Implement CoGetClassObject16(). Message-Id: <1487367137-8038-1-git-send-email-z.figura12@gmail.com> Date: Fri, 17 Feb 2017 15:32:17 -0600 Fixes https://bugs.winehq.org/show_bug.cgi?id=41209 Signed-off-by: Zebediah Figura --- dlls/compobj.dll16/compobj.c | 71 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 4 deletions(-) diff --git a/dlls/compobj.dll16/compobj.c b/dlls/compobj.dll16/compobj.c index b934a06..0e30541 100644 --- a/dlls/compobj.dll16/compobj.c +++ b/dlls/compobj.dll16/compobj.c @@ -715,14 +715,77 @@ 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)); + 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); + + HMODULE16 dll; + FARPROC16 DllGetClassObject; + + SEGPTR seg_rclsid = MapLS(rclsid); + SEGPTR seg_riid = MapLS(riid); + SEGPTR seg_ppv = MapLS(ppv); + WORD args[6]; + DWORD dwRet; + + 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; + } + + dll = LoadLibrary16(dllpath); + if (!dll) + { + ERR("couldn't load in-process dll %s\n", debugstr_a(dllpath)); + return E_ACCESSDENIED; /* FIXME: or should this be CO_E_DLLNOTFOUND? */ + } + + DllGetClassObject = GetProcAddress16(dll, "DllGetClassObject"); + if (!DllGetClassObject) + { + ERR("couldn't find function DllGetClassObject in %s\n", debugstr_a(dllpath)); + FreeLibrary16(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