[PATCH 04/11] [Kernel32]: ActCtx: added ability to store assembly id:s and to look them

Eric Pouech eric.pouech at wanadoo.fr
Wed May 9 15:07:48 CDT 2007


up afterwards
---

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

diff --git a/dlls/kernel32/actctx.c b/dlls/kernel32/actctx.c
index 36e65c2..033bb4b 100644
--- a/dlls/kernel32/actctx.c
+++ b/dlls/kernel32/actctx.c
@@ -147,6 +147,31 @@ static struct assembly* add_assembly(struct actctx* actctx, enum assembly_type a
     return assembly;
 }
 
+static BOOL add_dependent_assembly_id(struct actctx_loader* acl,
+                                      struct assembly_identity* ai)
+{
+    /* FIXME: should check that the passed ai isn't already in the list */
+    if (acl->num_dependencies == acl->allocated_dependencies)
+    {
+        if (acl->allocated_dependencies)
+        {
+            acl->allocated_dependencies *= 2;
+            acl->dependencies = HeapReAlloc(GetProcessHeap(), 0, acl->dependencies,
+                                            acl->allocated_dependencies * sizeof(acl->dependencies[0]));
+        }
+        else
+        {
+            acl->allocated_dependencies = 1;
+            acl->dependencies = HeapAlloc(GetProcessHeap(), 0,
+                                          sizeof(acl->dependencies[0]));
+        }
+    }
+    if (!acl->dependencies) return FALSE;
+    acl->dependencies[acl->num_dependencies++] = *ai;
+
+    return TRUE;
+}
+
 static void free_assembly_identity(struct assembly_identity *ai)
 {
     HeapFree(GetProcessHeap(), 0, ai->name);
@@ -334,6 +359,71 @@ static DWORD get_manifest_in_file(struct actctx_loader* acl,
     return ret;
 }
 
+static BOOL lookup_assembly(struct actctx_loader* acl,
+                            struct assembly_identity* ai)
+{
+    const WCHAR slashW[] = {'\\','\0'};
+    const WCHAR dotDllW[] = {'.','d','l','l','\0'};
+    LPWSTR      ptr;
+    WCHAR       tmp[MAX_PATH];
+    unsigned    i;
+
+    /* FIXME: add support for language specific lookup */
+    /* FIXME: should ensure we don't overflow the tmp array */
+    strcpyW(tmp, acl->actctx->app.info);
+    strcatW(tmp, slashW);
+    /* lookup in appdir\name.dll
+     *           appdir\name.manifest
+     *           appdir\name\name.dll
+     *           appdir\name\name.manifest
+     */
+    for (i = 0; i < 2; i++)
+    {
+        strcatW(tmp, ai->name);
+        ptr = tmp + lstrlenW(tmp);
+        strcpyW(ptr, dotDllW);
+        if (GetFileAttributesW(tmp) != INVALID_FILE_ATTRIBUTES)
+        {
+            FIXME("Unsupported yet (lookup of assembly manifest in .DLL)\n");
+        }
+        strcpyW(ptr, dotManifestW);
+        if (GetFileAttributesW(tmp) != INVALID_FILE_ATTRIBUTES)
+        {
+            return get_manifest_in_file(acl, ai, tmp, NULL, TRUE) == ERROR_SUCCESS;
+        }
+        if (i == 0) strcpyW(ptr, slashW);
+    }
+    return FALSE;
+}
+
+static void free_depend_manifests(struct actctx_loader* acl)
+{
+    unsigned    i;
+    for (i = 0; i < acl->num_dependencies; i++)
+    {
+        free_assembly_identity(&acl->dependencies[i]);
+    }
+    HeapFree(GetProcessHeap(), 0, acl->dependencies);
+    acl->dependencies = NULL;
+}
+
+static DWORD parse_depend_manifests(struct actctx_loader* acl)
+{
+    DWORD       ret = ERROR_SUCCESS;
+    unsigned    i;
+
+    for (i = 0; i < acl->num_dependencies; i++)
+    {
+        if (!lookup_assembly(acl, &acl->dependencies[i]))
+        {
+            WARN("Could not find assembly\n");
+            ret = ERROR_SXS_CANT_GEN_ACTCTX;
+        }
+    }
+    /* FIXME should now iterate through all refs */
+    return ret;
+}
+
 /***********************************************************************
  * CreateActCtxW (KERNEL32.@)
  *
@@ -416,9 +506,15 @@ HANDLE WINAPI CreateActCtxW(PCACTCTXW pActCtx)
 
     if (ret == ERROR_SUCCESS)
     {
-        return (HANDLE)actctx;
+        ret = parse_depend_manifests(&acl);
+        if (ret == ERROR_SUCCESS)
+        {
+            free_depend_manifests(&acl);
+            return (HANDLE)actctx;
+        }
     }
 
+    free_depend_manifests(&acl);
     ReleaseActCtx((HANDLE)actctx);
     SetLastError(ret);
     return INVALID_HANDLE_VALUE;





More information about the wine-patches mailing list