[PATCH 14/27] [Kernel32]: ActCtx: now also doing manifests lookup in WinSxS directory

Eric Pouech eric.pouech at wanadoo.fr
Mon May 7 14:51:11 CDT 2007


From: Jacek Caban <jacek at codeweavers.com>


---

 dlls/kernel32/actctx.c |   70 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 70 insertions(+), 0 deletions(-)

diff --git a/dlls/kernel32/actctx.c b/dlls/kernel32/actctx.c
index d82e52c..82588fc 100644
--- a/dlls/kernel32/actctx.c
+++ b/dlls/kernel32/actctx.c
@@ -1127,6 +1127,74 @@ static DWORD get_manifest_in_file(struct actctx_loader* acl,
     return ret;
 }
 
+static BOOL lookup_winsxs(struct actctx_loader* acl,
+                          struct assembly_identity* ai)
+{
+    WCHAR                     path[MAX_PATH];
+    WCHAR                     sys_dir[MAX_PATH];
+    WCHAR                     sxs_file[MAX_PATH] = {0};
+    WIN32_FIND_DATAW          find_data;
+    struct assembly_identity  sxs_ai;
+    HANDLE                    find;
+    ULONG                     build, revision;
+    DWORD                     res;
+
+    static const WCHAR formatW[] =
+        {'%','s','\\','w','i','n','s','x','s','\\','m','a','n','i','f','e','s','t','s','\\',
+         'x','8','6','_','%','s','_','%','s','_','%','u','.','%','u','.','*','.','*','_',
+         '*', /* FIXME */
+         '.','m','a','n','i','f','e','s','t',0};
+    static const WCHAR winsxsW[] =
+        {'\\','w','i','n','s','x','s','\\','m','a','n','i','f','e','s','t','s','\\',0};
+
+    if (!ai->name || !ai->public_key) return FALSE;
+
+    if (!GetSystemWindowsDirectoryW(sys_dir, sizeof(sys_dir) / sizeof(WCHAR)))
+        return FALSE;
+
+    sprintfW(path, formatW, sys_dir, ai->name, ai->public_key, ai->version.major,
+             ai->version.minor);
+
+    TRACE("%s\n", debugstr_w(path));
+
+    build = ai->version.build;
+    revision = ai->version.revision;
+    memcpy(&sxs_ai, ai, sizeof(sxs_ai));
+
+    if ((find = FindFirstFileW(path, &find_data)) == INVALID_HANDLE_VALUE)
+        return FALSE;
+
+    do
+    {
+        WCHAR*   tmp;
+
+        tmp = find_data.cFileName + (strchrW(path, '*') - strrchrW(path, '\\') - 1);
+        build = atoiW(tmp);
+        if (build < sxs_ai.version.build) continue;
+
+        tmp = strchrW(tmp, '.')+1;
+        revision = atoiW(tmp);
+        if (build == sxs_ai.version.build && revision < sxs_ai.version.revision)
+            continue;
+
+        strcpyW(sxs_file, find_data.cFileName);
+        sxs_ai.version.build = build;
+        sxs_ai.version.revision = revision;
+    } while (FindNextFileW(find, &find_data));
+
+    FindClose(find);
+
+    if (!sxs_file[0]) return FALSE;
+
+    strcpyW(path, sys_dir);
+    strcatW(path, winsxsW);
+    strcatW(path, sxs_file);
+
+    res = get_manifest_in_file(acl, &sxs_ai, path, NULL, TRUE);
+
+    return res == ERROR_SUCCESS;
+}
+
 static BOOL lookup_assembly(struct actctx_loader* acl,
                             struct assembly_identity* ai)
 {
@@ -1136,6 +1204,8 @@ static BOOL lookup_assembly(struct actctx_loader* acl,
     WCHAR       tmp[MAX_PATH];
     unsigned    i;
 
+    if (lookup_winsxs(acl, ai)) return TRUE;
+
     /* FIXME: add support for language specific lookup */
     /* FIXME: should ensure we don't overflow the tmp array */
     strcpyW(tmp, acl->actctx->app.info);





More information about the wine-patches mailing list