From 4ed40feb2215f9273fc3264e3108b6dfe7d035f4 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Mon, 7 Dec 2009 03:34:25 +0000 Subject: [PATCH] [dll/ntdll] - LdrLoadDll: Create a module activation context for modules when loaded by LoadLibrary and friends. Fixes loading assemblies of modules when loaded from threads. - find_actctx_dll: Silence debugging. [dll/kernel32] - CreateRemoteThread: Do not try to activate the processes default activation context, as the processes default activation context is not created properly yet. Will be fixed in near future. Several application broken by recent SXS commit are now back to working, including Media Player Class 6.4.9 and Opera 9.64. OO 3.0 install no longer errors on loading ms runtime. svn path=/trunk/; revision=44450 --- reactos/dll/ntdll/ldr/actctx.c | 4 ++-- reactos/dll/ntdll/ldr/utils.c | 8 +++++++- reactos/dll/win32/kernel32/thread/thread.c | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/reactos/dll/ntdll/ldr/actctx.c b/reactos/dll/ntdll/ldr/actctx.c index 80e15ae8e91..c859e6bc7ce 100644 --- a/reactos/dll/ntdll/ldr/actctx.c +++ b/reactos/dll/ntdll/ldr/actctx.c @@ -66,8 +66,8 @@ NTSTATUS find_actctx_dll( LPCWSTR libname, WCHAR *fullname ) size = needed; } - DPRINT1("manafestpath === %S\n", info->lpAssemblyManifestPath); - DPRINT1("DirectoryName === %S\n", info->lpAssemblyDirectoryName); + DPRINT("manafestpath === %S\n", info->lpAssemblyManifestPath); + DPRINT("DirectoryName === %S\n", info->lpAssemblyDirectoryName); if (!info->lpAssemblyManifestPath || !info->lpAssemblyDirectoryName) { status = STATUS_SXS_KEY_NOT_FOUND; diff --git a/reactos/dll/ntdll/ldr/utils.c b/reactos/dll/ntdll/ldr/utils.c index 9426eeee82d..f1ce796ea72 100644 --- a/reactos/dll/ntdll/ldr/utils.c +++ b/reactos/dll/ntdll/ldr/utils.c @@ -838,7 +838,7 @@ LdrLoadDll (IN PWSTR SearchPath OPTIONAL, { NTSTATUS Status; PLDR_DATA_TABLE_ENTRY Module; - + ULONG_PTR cookie; PPEB Peb = NtCurrentPeb(); TRACE_LDR("LdrLoadDll, loading %wZ%s%S\n", @@ -851,12 +851,18 @@ LdrLoadDll (IN PWSTR SearchPath OPTIONAL, if (NT_SUCCESS(Status) && (!LoadFlags || 0 == (*LoadFlags & LOAD_LIBRARY_AS_DATAFILE))) { + if (!create_module_activation_context( Module )) + { + RtlActivateActivationContext(0, Module->EntryPointActivationContext, &cookie); + } + if (!(Module->Flags & LDRP_PROCESS_ATTACH_CALLED)) { RtlEnterCriticalSection(Peb->LoaderLock); Status = LdrpAttachProcess(); RtlLeaveCriticalSection(Peb->LoaderLock); } + if (Module->EntryPointActivationContext) RtlDeactivateActivationContext(0, cookie); } if ((!Module) && (NT_SUCCESS(Status))) diff --git a/reactos/dll/win32/kernel32/thread/thread.c b/reactos/dll/win32/kernel32/thread/thread.c index 5f4270e54d5..337934bba8c 100644 --- a/reactos/dll/win32/kernel32/thread/thread.c +++ b/reactos/dll/win32/kernel32/thread/thread.c @@ -17,6 +17,7 @@ /* FIXME: NDK */ #define HIGH_PRIORITY 31 +#define SXS_SUPPORT_FIXME /* FUNCTIONS *****************************************************************/ static @@ -164,8 +165,10 @@ CreateRemoteThread(HANDLE hProcess, PTEB Teb; PVOID ActivationContextStack; THREAD_BASIC_INFORMATION ThreadBasicInfo; +#ifndef SXS_SUPPORT_FIXME ACTIVATION_CONTEXT_BASIC_INFORMATION ActivationCtxInfo; ULONG_PTR Cookie; +#endif ULONG retLen; /* Get the TEB */ @@ -186,7 +189,7 @@ CreateRemoteThread(HANDLE hProcess, /* Save it */ Teb->ActivationContextStackPointer = ActivationContextStack; - +#ifndef SXS_SUPPORT_FIXME /* Query the Context */ Status = RtlQueryInformationActivationContext(1, 0, @@ -210,6 +213,7 @@ CreateRemoteThread(HANDLE hProcess, } else DPRINT1("RtlQueryInformationActivationContext failed %x\n", Status); +#endif } else DPRINT1("RtlAllocateActivationContextStack failed %x\n", Status);