From 270f725526ebe3bde8458b8eee44b2ea63cee3f6 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 25 Jul 2007 16:48:40 +0200 Subject: [PATCH] ntdll: Create the process activation context at initialization time. --- dlls/ntdll/actctx.c | 17 +++++++++++++++++ dlls/ntdll/loader.c | 1 + dlls/ntdll/ntdll_misc.h | 1 + 3 files changed, 19 insertions(+) diff --git a/dlls/ntdll/actctx.c b/dlls/ntdll/actctx.c index 1e2e101cf8d..2f2e28b0f30 100644 --- a/dlls/ntdll/actctx.c +++ b/dlls/ntdll/actctx.c @@ -227,6 +227,8 @@ struct actctx_loader static const WCHAR dotManifestW[] = {'.','m','a','n','i','f','e','s','t',0}; +static ACTIVATION_CONTEXT system_actctx = { ACTCTX_MAGIC, 1 }; +static ACTIVATION_CONTEXT *process_actctx = &system_actctx; static WCHAR *strdupW(const WCHAR* str) { @@ -1827,6 +1829,21 @@ static NTSTATUS parse_depend_manifests(struct actctx_loader* acl) return status; } +/* initialize the activation context for the current process */ +void actctx_init(void) +{ + ACTCTXW ctx; + HANDLE handle; + + ctx.cbSize = sizeof(ctx); + ctx.lpSource = NULL; + ctx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID | ACTCTX_FLAG_HMODULE_VALID; + ctx.hModule = NtCurrentTeb()->Peb->ImageBaseAddress; + ctx.lpResourceName = (LPCWSTR)CREATEPROCESS_MANIFEST_RESOURCE_ID; + + if (!RtlCreateActivationContext( &handle, &ctx )) process_actctx = check_actctx(handle); +} + /*********************************************************************** * RtlCreateActivationContext (NTDLL.@) diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index ca06e8931ac..207d39156ee 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -2166,6 +2166,7 @@ void WINAPI LdrInitializeThunk( ULONG unknown1, ULONG unknown2, ULONG unknown3, RtlEnterCriticalSection( &loader_section ); + actctx_init(); load_path = NtCurrentTeb()->Peb->ProcessParameters->DllPath.Buffer; if ((status = fixup_imports( wm, load_path )) != STATUS_SUCCESS) goto error; if ((status = alloc_process_tls()) != STATUS_SUCCESS) goto error; diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index 8f41ff87e31..05df50796e8 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -49,6 +49,7 @@ extern size_t get_signal_stack_total_size(void); extern void version_init( const WCHAR *appname ); extern void debug_init(void); extern HANDLE thread_init(void); +extern void actctx_init(void); extern void virtual_init(void); extern void virtual_init_threading(void);