(CoGetClassObject) one missing CALLBACK, extremely simplified clsid
lookup (Registry is case insensitive).
This commit is contained in:
parent
42e68a6aab
commit
6188232436
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue