From 61882324362ea9b23aaabb6d7e4a4dd9900e1be3 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Sat, 14 Nov 1998 16:46:26 +0000 Subject: [PATCH] (CoGetClassObject) one missing CALLBACK, extremely simplified clsid lookup (Registry is case insensitive). --- ole/compobj.c | 65 ++++++++++++--------------------------------------- 1 file changed, 15 insertions(+), 50 deletions(-) diff --git a/ole/compobj.c b/ole/compobj.c index 2538372f66a..2d1e140e320 100644 --- a/ole/compobj.c +++ b/ole/compobj.c @@ -728,18 +728,14 @@ HRESULT WINAPI CoGetClassObject(REFCLSID rclsid, DWORD dwClsContext, { char xclsid[50],xiid[50]; HRESULT hres = E_UNEXPECTED; + char dllName[MAX_PATH+1]; - LONG dllNameLen = MAX_PATH+1; + LONG dllNameLen = sizeof(dllName); HINSTANCE32 hLibrary; - typedef HRESULT (*DllGetClassObjectFunc)(REFCLSID clsid, + typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid, REFIID iid, LPVOID *ppv); DllGetClassObjectFunc DllGetClassObject; - HKEY CLSIDkey; - char buf[MAX_PATH + 1]; - int i; - int found; - WINE_StringFromCLSID((LPCLSID)rclsid,xclsid); WINE_StringFromCLSID((LPCLSID)iid,xiid); TRACE(ole,"\n\tCLSID:\t%s,\n\tIID:\t%s\n",xclsid,xiid); @@ -751,72 +747,41 @@ HRESULT WINAPI CoGetClassObject(REFCLSID rclsid, DWORD dwClsContext, } if ((CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER) & dwClsContext) { + HKEY CLSIDkey,key; /* lookup CLSID in registry key HKCR/CLSID */ hres = RegOpenKeyEx32A(HKEY_CLASSES_ROOT, "CLSID", 0, - KEY_ENUMERATE_SUB_KEYS, &CLSIDkey); + KEY_READ, &CLSIDkey); - if (hres != ERROR_SUCCESS) { - return REGDB_E_READREGDB; - } - - /* search all the subkeys for a match to xclsid */ - found=FALSE; - for (i=0; i<100000; i++) { - - char clsidKeyPath[MAX_PATH + 1]; - HKEY key; - LONG res; - - res = RegEnumKey32A(CLSIDkey, i, buf, MAX_PATH); - if (res == ERROR_NO_MORE_ITEMS) - break; - if (res != ERROR_SUCCESS) - continue; - - sprintf(clsidKeyPath, "CLSID\\%s", buf); - - if (lstrcmpi32A(buf, xclsid) != 0) - continue; - - res = RegOpenKeyEx32A(HKEY_CLASSES_ROOT, clsidKeyPath, 0, - KEY_QUERY_VALUE, &key); - if (res != ERROR_SUCCESS) { + if (hres != ERROR_SUCCESS) return REGDB_E_READREGDB; + hres = RegOpenKeyEx32A(HKEY_CLASSES_ROOT,xclsid,0,KEY_QUERY_VALUE, + &key); + if (hres != ERROR_SUCCESS) { + RegCloseKey(CLSIDkey); + return REGDB_E_CLASSNOTREG; } hres = RegQueryValue32A(key, "InprocServer32", dllName, &dllNameLen); - if (res != ERROR_SUCCESS) { + RegCloseKey(key); + RegCloseKey(CLSIDkey); + if (hres != ERROR_SUCCESS) return REGDB_E_READREGDB; - } TRACE(ole,"found InprocServer32 dll %s\n", dllName); - found = TRUE; - break; - } - if (!found) { - return REGDB_E_CLASSNOTREG; - } - - /* open dll, call DllGetClassFactory */ hLibrary = CoLoadLibrary(dllName, TRUE); - - if (hLibrary == 0) { TRACE(ole,"couldn't load InprocServer32 dll %s\n", dllName); return E_ACCESSDENIED; /* or should this be CO_E_DLLNOTFOUND? */ } - DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress32(hLibrary, "DllGetClassObject"); - if (DllGetClassObject == NULL) { + if (!DllGetClassObject) { /* not sure if this should be called here CoFreeLibrary(hLibrary);*/ TRACE(ole,"couldn't find function DllGetClassObject in %s\n", dllName); return E_ACCESSDENIED; } - return DllGetClassObject(rclsid, iid, ppv); } - return hres; }