[PATCH 2/5] mscoree: Add support for unmanaged classes in .NET Framework.
Esme Povirk
esme at codeweavers.com
Tue Feb 1 15:56:22 CST 2022
Signed-off-by: Esme Povirk <esme at codeweavers.com>
---
dlls/mscoree/corruntimehost.c | 46 +++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/dlls/mscoree/corruntimehost.c b/dlls/mscoree/corruntimehost.c
index 923680a931e..3b23ce33e40 100644
--- a/dlls/mscoree/corruntimehost.c
+++ b/dlls/mscoree/corruntimehost.c
@@ -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)
{
--
2.30.2
More information about the wine-devel
mailing list