Author: fireball Date: Wed Jan 27 15:02:28 2016 New Revision: 70646
URL: http://svn.reactos.org/svn/reactos?rev=70646&view=rev Log: [LDR] - Fix a typo in kernel32's manifest prober routine - Don't RtlGetActiveActivationContext if it's already existing - Improve actctx and ldr debug prints - This fixes numerous LDR bugs, such as the famous bug with MSVCR90 CORE-7313, .NET installation issues CORE-7489 and, hopefully, many other. Thank you very much for putting your trust in me!
Modified: trunk/reactos/dll/ntdll/ldr/ldrpe.c trunk/reactos/dll/ntdll/ldr/ldrutils.c trunk/reactos/dll/win32/kernel32/client/actctx.c trunk/reactos/lib/rtl/actctx.c
Modified: trunk/reactos/dll/ntdll/ldr/ldrpe.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ldr/ldrpe.c?rev=7... ============================================================================== --- trunk/reactos/dll/ntdll/ldr/ldrpe.c [iso-8859-1] (original) +++ trunk/reactos/dll/ntdll/ldr/ldrpe.c [iso-8859-1] Wed Jan 27 15:02:28 2016 @@ -690,7 +690,8 @@ PIMAGE_BOUND_IMPORT_DESCRIPTOR BoundEntry = NULL; PIMAGE_IMPORT_DESCRIPTOR ImportEntry; ULONG BoundSize, IatSize; - DPRINT("LdrpWalkImportDescriptor('%S' %p)\n", DllPath, LdrEntry); + + DPRINT("LdrpWalkImportDescriptor - BEGIN (%wZ %p '%S')\n", &LdrEntry->BaseDllName, LdrEntry, DllPath);
/* Set up the Act Ctx */ RtlZeroMemory(&ActCtx, sizeof(ActCtx)); @@ -711,7 +712,7 @@ Status2 != STATUS_RESOURCE_LANG_NOT_FOUND) { /* Some serious issue */ - Status = Status2; + //Status = Status2; // FIXME: Ignore that error for now DbgPrintEx(DPFLTR_SXS_ID, DPFLTR_WARNING_LEVEL, "LDR: LdrpWalkImportDescriptor() failed to probe %wZ for its " @@ -724,16 +725,20 @@ if (!NT_SUCCESS(Status)) return Status;
/* Get the Active ActCtx */ - Status = RtlGetActiveActivationContext(&LdrEntry->EntryPointActivationContext); - if (!NT_SUCCESS(Status)) - { - /* Exit */ - DbgPrintEx(DPFLTR_SXS_ID, - DPFLTR_WARNING_LEVEL, - "LDR: RtlGetActiveActivationContext() failed; ntstatus = " - "0x%08lx\n", - Status); - return Status; + if (!LdrEntry->EntryPointActivationContext) + { + Status = RtlGetActiveActivationContext(&LdrEntry->EntryPointActivationContext); + + if (!NT_SUCCESS(Status)) + { + /* Exit */ + DbgPrintEx(DPFLTR_SXS_ID, + DPFLTR_WARNING_LEVEL, + "LDR: RtlGetActiveActivationContext() failed; ntstatus = " + "0x%08lx\n", + Status); + return Status; + } }
/* Activate the ActCtx */ @@ -806,6 +811,8 @@
/* Release the activation context */ RtlDeactivateActivationContextUnsafeFast(&ActCtx); + + DPRINT("LdrpWalkImportDescriptor - END (%wZ %p)\n", &LdrEntry->BaseDllName, LdrEntry);
/* Return status */ return Status; @@ -826,7 +833,7 @@ PPEB Peb = RtlGetCurrentPeb(); PTEB Teb = NtCurrentTeb();
- DPRINT("LdrpLoadImportModule('%S' '%s' %p %p %p)\n", DllPath, ImportName, DllBase, DataTableEntry, Existing); + DPRINT("LdrpLoadImportModule('%s' %p %p %p '%S')\n", ImportName, DllBase, DataTableEntry, Existing, DllPath);
/* Convert import descriptor name to unicode string */ ImpDescName = &Teb->StaticUnicodeString; @@ -848,6 +855,51 @@
/* We're loading it for the first time */ *Existing = FALSE; + +#if 0 + /* Load manifest */ + { + ACTCTX_SECTION_KEYED_DATA data; + NTSTATUS status; + + //DPRINT1("find_actctx_dll for %S\n", fullname); + //RtlInitUnicodeString(&nameW, libname); + data.cbSize = sizeof(data); + status = RtlFindActivationContextSectionString( + FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL, + ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION, + ImpDescName, + &data); + //if (status != STATUS_SUCCESS) return status; + DPRINT1("Status: 0x%08X\n", status); + + if (NT_SUCCESS(status)) + { + ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION *info; + SIZE_T needed, size = 1024; + + for (;;) + { + if (!(info = RtlAllocateHeap(RtlGetProcessHeap(), 0, size))) + { + status = STATUS_NO_MEMORY; + goto done; + } + status = RtlQueryInformationActivationContext(0, data.hActCtx, &data.ulAssemblyRosterIndex, + AssemblyDetailedInformationInActivationContext, + info, size, &needed); + if (status == STATUS_SUCCESS) break; + if (status != STATUS_BUFFER_TOO_SMALL) goto done; + RtlFreeHeap(RtlGetProcessHeap(), 0, info); + size = needed; + } + + DPRINT("manifestpath === %S\n", info->lpAssemblyManifestPath); + DPRINT("DirectoryName === %S\n", info->lpAssemblyDirectoryName); + } + } +done: +#endif
/* Map it */ Status = LdrpMapDll(DllPath,
Modified: trunk/reactos/dll/ntdll/ldr/ldrutils.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/ldr/ldrutils.c?re... ============================================================================== --- trunk/reactos/dll/ntdll/ldr/ldrutils.c [iso-8859-1] (original) +++ trunk/reactos/dll/ntdll/ldr/ldrutils.c [iso-8859-1] Wed Jan 27 15:02:28 2016 @@ -2061,6 +2061,8 @@ }
/* FIXME: Warning, activation context missing */ + DPRINT("Warning, activation context missing\n"); + /* NOTE: From here on down, everything looks good */
/* Loop the module list */
Modified: trunk/reactos/dll/win32/kernel32/client/actctx.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/a... ============================================================================== --- trunk/reactos/dll/win32/kernel32/client/actctx.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/actctx.c [iso-8859-1] Wed Jan 27 15:02:28 2016 @@ -157,7 +157,7 @@ Info.Type = (ULONG)RT_MANIFEST; Info.Name = (ULONG)ISOLATIONAWARE_MANIFEST_RESOURCE_ID; Info.Language = 0; - if (!(Status = LdrFindResource_U(DllHandle, &Info, 2, &Entry))) + if (!(Status = LdrFindResource_U(DllHandle, &Info, 3, &Entry))) { /* Create the activation context */ Context.cbSize = sizeof(Context);
Modified: trunk/reactos/lib/rtl/actctx.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/actctx.c?rev=70646&... ============================================================================== --- trunk/reactos/lib/rtl/actctx.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/actctx.c [iso-8859-1] Wed Jan 27 15:02:28 2016 @@ -4694,7 +4694,7 @@ HANDLE file = 0; struct actctx_loader acl;
- DPRINT("%p %08x\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0); + DPRINT("RtlCreateActivationContext %p %08x, Image Base: %p\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0, ((ACTCTXW*)ActivationContextData)->hModule);
if (!pActCtx || pActCtx->cbSize < sizeof(*pActCtx) || (pActCtx->dwFlags & ~ACTCTX_FLAGS_ALL))