mscoree: Attempt to load the assembly from the application directory (try 3)

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Tue Nov 19 21:59:45 CST 2013


Hi,
Moved back to create_monodata.
Uses the Assembly Key from the registry to find the Filename.


Changelog:
      mscoree:Attempt to load the assembly from the application directory


Best Regards
   Alistair Leslie-Hughes

-------------- next part --------------
>From b8f053a7f4f9447d6937fa2df7b85113aa48f9af Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Wed, 14 Aug 2013 15:59:53 +1000
Subject: [PATCH] Attempt to load the assembly from the application directory
To: wine-patches <wine-patches at winehq.org>

---
 dlls/mscoree/corruntimehost.c | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/dlls/mscoree/corruntimehost.c b/dlls/mscoree/corruntimehost.c
index 554f4c5..77206c1 100644
--- a/dlls/mscoree/corruntimehost.c
+++ b/dlls/mscoree/corruntimehost.c
@@ -1280,6 +1280,7 @@ HRESULT create_monodata(REFIID riid, LPVOID *ppObj )
     static const WCHAR wszFileSlash[] = {'f','i','l','e',':','/','/','/',0};
     static const WCHAR wszCLSIDSlash[] = {'C','L','S','I','D','\\',0};
     static const WCHAR wszInprocServer32[] = {'\\','I','n','p','r','o','c','S','e','r','v','e','r','3','2',0};
+    static const WCHAR wszDLL[] = {'.','d','l','l',0};
     WCHAR path[CHARS_IN_GUID + ARRAYSIZE(wszCLSIDSlash) + ARRAYSIZE(wszInprocServer32) - 1];
     MonoDomain *domain;
     MonoAssembly *assembly;
@@ -1328,6 +1329,8 @@ HRESULT create_monodata(REFIID riid, LPVOID *ppObj )
     }
     else
     {
+        WCHAR assemblyname[MAX_PATH + 8];
+
         hr = CLASS_E_CLASSNOTAVAILABLE;
         WARN("CodeBase value cannot be found, trying Assembly.\n");
         /* get the last subkey of InprocServer32 */
@@ -1343,16 +1346,36 @@ HRESULT create_monodata(REFIID riid, LPVOID *ppObj )
         if (res != ERROR_SUCCESS)
             goto cleanup;
         dwBufLen = MAX_PATH + 8;
-        res = RegGetValueW(subkey, NULL, wszAssembly, RRF_RT_REG_SZ, NULL, codebase, &dwBufLen);
+        res = RegGetValueW(subkey, NULL, wszAssembly, RRF_RT_REG_SZ, NULL, assemblyname, &dwBufLen);
         RegCloseKey(subkey);
         if (res != ERROR_SUCCESS)
             goto cleanup;
-        hr = get_file_from_strongname(codebase, filename, MAX_PATH);
+
+        hr = get_file_from_strongname(assemblyname, filename, MAX_PATH);
         if (!SUCCEEDED(hr))
-            goto cleanup;
+        {
+            /*
+             * The registry doesn't have a CodeBase entry and it's not in the GAC.
+             *
+             * Use the Assembly Key to retrieve the filename.
+             *    Assembly : REG_SZ : AssenblyName, Version=X.X.X.X, Culture=neutral, PublicKeyToken=null
+             */
+            WCHAR *ns;
+
+            WARN("Attempt to load from the application directory.\n");
+            GetModuleFileNameW(NULL, filename, MAX_PATH);
+            ns = strrchrW(filename, '\\');
+            *(ns+1) = '\0';
+
+            ns = strchrW(assemblyname, ',');
+            *(ns) = '\0';
+            strcatW(filename, assemblyname);
+            *(ns) = '.';
+            strcatW(filename, wszDLL);
+        }
     }
 
-    TRACE("codebase (%s)\n", debugstr_w(filename));
+    TRACE("filename (%s)\n", debugstr_w(filename));
 
     *ppObj = NULL;
 
-- 
1.8.3.2



More information about the wine-patches mailing list