mscoree: Add support for unmanaged classes in .NET Framework.

Signed-off-by: Esme Povirk <esme@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Esme Povirk 2022-02-01 15:56:22 -06:00 committed by Alexandre Julliard
parent 8184e86a67
commit 14d37f3fb3
1 changed files with 46 additions and 0 deletions

View File

@ -1747,6 +1747,52 @@ HRESULT create_monodata(REFCLSID clsid, LPVOID *ppObj)
res = RegOpenKeyExW(HKEY_CLASSES_ROOT, path, 0, KEY_READ, &key);
if (res != ERROR_FILE_NOT_FOUND)
{
res = RegOpenKeyExW( key, L"Server", 0, KEY_READ, &subkey );
if (res == ERROR_SUCCESS)
{
/* Not a managed class, just chain through LoadLibraryShim */
HMODULE module;
HRESULT (WINAPI *pDllGetClassObject)(REFCLSID,REFIID,LPVOID*);
IClassFactory *classfactory;
dwBufLen = ARRAY_SIZE( filename );
res = RegGetValueW( subkey, NULL, NULL, RRF_RT_REG_SZ, NULL, filename, &dwBufLen );
RegCloseKey( subkey );
if (res != ERROR_SUCCESS)
{
WARN("Can't read default value from Server subkey.\n");
hr = CLASS_E_CLASSNOTAVAILABLE;
goto cleanup;
}
hr = LoadLibraryShim( filename, L"v4.0.30319", NULL, &module);
if (FAILED(hr))
{
WARN("Can't load %s.\n", debugstr_w(filename));
goto cleanup;
}
pDllGetClassObject = (void*)GetProcAddress( module, "DllGetClassObject" );
if (!pDllGetClassObject)
{
WARN("Can't get DllGetClassObject from %s.\n", debugstr_w(filename));
hr = CLASS_E_CLASSNOTAVAILABLE;
goto cleanup;
}
hr = pDllGetClassObject( clsid, &IID_IClassFactory, (void**)&classfactory );
if (SUCCEEDED(hr))
{
hr = IClassFactory_CreateInstance( classfactory, NULL, &IID_IUnknown, ppObj );
IClassFactory_Release( classfactory );
}
goto cleanup;
}
res = RegGetValueW( key, NULL, L"Class", RRF_RT_REG_SZ, NULL, classname, &dwBufLen);
if(res != ERROR_SUCCESS)
{