CoGetClassObject: for CLSCTX_LOCAL_SERVER at least look up the server

in the registry, even though we don't yet execute it.
This commit is contained in:
Bill Medland 2002-01-18 18:09:37 +00:00 committed by Alexandre Julliard
parent fcb8e0d77a
commit 43471ddf0b
1 changed files with 65 additions and 46 deletions

View File

@ -1225,6 +1225,11 @@ end:
/*********************************************************************** /***********************************************************************
* CoGetClassObject [COMPOBJ.7] * CoGetClassObject [COMPOBJ.7]
* CoGetClassObject [OLE32.16] * CoGetClassObject [OLE32.16]
*
* FIXME. If request allows of several options and there is a failure
* with one (other than not being registered) do we try the
* others or return failure? (E.g. inprocess is registered but
* the DLL is not found but the server version works)
*/ */
HRESULT WINAPI CoGetClassObject( HRESULT WINAPI CoGetClassObject(
REFCLSID rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo, REFCLSID rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo,
@ -1233,12 +1238,14 @@ HRESULT WINAPI CoGetClassObject(
LPUNKNOWN regClassObject; LPUNKNOWN regClassObject;
HRESULT hres = E_UNEXPECTED; HRESULT hres = E_UNEXPECTED;
char xclsid[80]; char xclsid[80];
WCHAR dllName[MAX_PATH+1]; WCHAR ProviderName[MAX_PATH+1];
DWORD dllNameLen = sizeof(dllName); DWORD ProviderNameLen = sizeof(ProviderName);
HINSTANCE hLibrary; HINSTANCE hLibrary;
typedef HRESULT CALLBACK (*DllGetClassObjectFunc)(REFCLSID clsid, typedef HRESULT CALLBACK (*DllGetClassObjectFunc)(REFCLSID clsid,
REFIID iid, LPVOID *ppv); REFIID iid, LPVOID *ppv);
DllGetClassObjectFunc DllGetClassObject; DllGetClassObjectFunc DllGetClassObject;
HKEY key;
char buf[200];
WINE_StringFromCLSID((LPCLSID)rclsid,xclsid); WINE_StringFromCLSID((LPCLSID)rclsid,xclsid);
@ -1273,57 +1280,69 @@ HRESULT WINAPI CoGetClassObject(
return hres; return hres;
} }
/* out of process and remote servers not supported yet */ /* Then try for in-process */
if ( ((CLSCTX_LOCAL_SERVER|CLSCTX_REMOTE_SERVER) & dwClsContext) if ((CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER) & dwClsContext)
&& !((CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER) & dwClsContext) {
){ memset(ProviderName,0,sizeof(ProviderName));
FIXME("%s %s not supported!\n",
(dwClsContext&CLSCTX_LOCAL_SERVER)?"CLSCTX_LOCAL_SERVER":"",
(dwClsContext&CLSCTX_REMOTE_SERVER)?"CLSCTX_REMOTE_SERVER":""
);
return E_ACCESSDENIED;
}
if ((CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER) & dwClsContext) {
HKEY key;
char buf[200];
sprintf(buf,"CLSID\\%s\\InprocServer32",xclsid); sprintf(buf,"CLSID\\%s\\InprocServer32",xclsid);
hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key); if (((hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key)) != ERROR_SUCCESS) ||
((hres = RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)ProviderName,&ProviderNameLen)),
if (hres != ERROR_SUCCESS) { RegCloseKey (key),
return REGDB_E_CLASSNOTREG; hres != ERROR_SUCCESS))
{
hres = REGDB_E_CLASSNOTREG;
}
/* Don't ask me. MSDN says that CoGetClassObject does NOT call CoLoadLibrary */
else if ((hLibrary = CoLoadLibrary(ProviderName, TRUE)) == 0)
{
FIXME("couldn't load InprocServer32 dll %s\n", debugstr_w(ProviderName));
hres = E_ACCESSDENIED; /* or should this be CO_E_DLLNOTFOUND? */
} }
else if (!(DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject")))
memset(dllName,0,sizeof(dllName)); {
hres= RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)dllName,&dllNameLen);
if (hres)
return REGDB_E_CLASSNOTREG; /* FIXME: check retval */
RegCloseKey(key);
TRACE("found InprocServer32 dll %s\n", debugstr_w(dllName));
/* open dll, call DllGetClassObject */
hLibrary = CoLoadLibrary(dllName, TRUE);
if (hLibrary == 0) {
FIXME("couldn't load InprocServer32 dll %s\n", debugstr_w(dllName));
return E_ACCESSDENIED; /* or should this be CO_E_DLLNOTFOUND? */
}
DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject");
if (!DllGetClassObject) {
/* not sure if this should be called here CoFreeLibrary(hLibrary);*/ /* not sure if this should be called here CoFreeLibrary(hLibrary);*/
FIXME("couldn't find function DllGetClassObject in %s\n", debugstr_w(dllName)); FIXME("couldn't find function DllGetClassObject in %s\n", debugstr_w(ProviderName));
return E_ACCESSDENIED; hres = E_ACCESSDENIED;
} }
else
/* {
* Ask the DLL for its class object. (there was a note here about class /* Ask the DLL for its class object. (there was a note here about
* factories but this is good. * class factories but this is good.
*/ */
return DllGetClassObject(rclsid, iid, ppv); return DllGetClassObject(rclsid, iid, ppv);
}
} }
/* Finally try out of process */
/* out of process and remote servers not supported yet */
if (CLSCTX_LOCAL_SERVER & dwClsContext)
{
memset(ProviderName,0,sizeof(ProviderName));
sprintf(buf,"CLSID\\%s\\LocalServer32",xclsid);
if (((hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key)) != ERROR_SUCCESS) ||
((hres = RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)ProviderName,&ProviderNameLen)),
RegCloseKey (key),
hres != ERROR_SUCCESS))
{
hres = REGDB_E_CLASSNOTREG;
}
else
{
/* CO_E_APPNOTFOUND if no exe */
FIXME("CLSCTX_LOCAL_SERVER %s registered but not yet supported!\n",debugstr_w(ProviderName));
hres = E_ACCESSDENIED;
}
}
if (CLSCTX_REMOTE_SERVER & dwClsContext)
{
FIXME ("CLSCTX_REMOTE_SERVER not supported\n");
hres = E_ACCESSDENIED;
}
return hres; return hres;
} }
/*********************************************************************** /***********************************************************************
* CoResumeClassObjects (OLE32.173) * CoResumeClassObjects (OLE32.173)
* *