[PATCH 06/27] [Kernel32]: ActCtx: added ability to store assembly
id:s and to look them
Eric Pouech
eric.pouech at wanadoo.fr
Mon May 7 14:50:15 CDT 2007
up afterwards
---
dlls/kernel32/actctx.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 88 insertions(+), 1 deletions(-)
diff --git a/dlls/kernel32/actctx.c b/dlls/kernel32/actctx.c
index 1dbb9d7..89fada1 100644
--- a/dlls/kernel32/actctx.c
+++ b/dlls/kernel32/actctx.c
@@ -136,6 +136,22 @@ 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->dependencies = HeapReAlloc(GetProcessHeap(), 0, acl->dependencies,
+ (acl->num_dependencies + 1) * sizeof(acl->dependencies[0]));
+ else
+ 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, (void*)ai->name);
@@ -324,6 +340,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.@)
*
@@ -404,9 +485,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