- 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!

svn path=/trunk/; revision=70646
This commit is contained in:
Aleksey Bragin 2016-01-27 15:02:28 +00:00
parent 1d3fa0bb12
commit f6cd52a04f
4 changed files with 68 additions and 14 deletions

View file

@ -690,7 +690,8 @@ LdrpWalkImportDescriptor(IN LPWSTR DllPath OPTIONAL,
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 @@ LdrpWalkImportDescriptor(IN LPWSTR DllPath OPTIONAL,
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 @@ LdrpWalkImportDescriptor(IN LPWSTR DllPath OPTIONAL,
if (!NT_SUCCESS(Status)) return Status;
/* Get the Active ActCtx */
Status = RtlGetActiveActivationContext(&LdrEntry->EntryPointActivationContext);
if (!NT_SUCCESS(Status))
if (!LdrEntry->EntryPointActivationContext)
{
/* Exit */
DbgPrintEx(DPFLTR_SXS_ID,
DPFLTR_WARNING_LEVEL,
"LDR: RtlGetActiveActivationContext() failed; ntstatus = "
"0x%08lx\n",
Status);
return Status;
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 */
@ -807,6 +812,8 @@ LdrpWalkImportDescriptor(IN LPWSTR DllPath OPTIONAL,
/* Release the activation context */
RtlDeactivateActivationContextUnsafeFast(&ActCtx);
DPRINT("LdrpWalkImportDescriptor - END (%wZ %p)\n", &LdrEntry->BaseDllName, LdrEntry);
/* Return status */
return Status;
}
@ -826,7 +833,7 @@ LdrpLoadImportModule(IN PWSTR DllPath OPTIONAL,
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;
@ -849,6 +856,51 @@ LdrpLoadImportModule(IN PWSTR DllPath OPTIONAL,
/* 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,
NULL,

View file

@ -2061,6 +2061,8 @@ lookinhash:
}
/* FIXME: Warning, activation context missing */
DPRINT("Warning, activation context missing\n");
/* NOTE: From here on down, everything looks good */
/* Loop the module list */

View file

@ -157,7 +157,7 @@ BasepProbeForDllManifest(IN PVOID DllHandle,
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);

View file

@ -4694,7 +4694,7 @@ RtlCreateActivationContext(IN ULONG Flags,
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))