Skip to content

Commit f6cd52a

Browse files
committed
[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! svn path=/trunk/; revision=70646
1 parent 1d3fa0b commit f6cd52a

File tree

4 files changed

+68
-14
lines changed

4 files changed

+68
-14
lines changed

reactos/dll/ntdll/ldr/ldrpe.c

Lines changed: 64 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,8 @@ LdrpWalkImportDescriptor(IN LPWSTR DllPath OPTIONAL,
690690
PIMAGE_BOUND_IMPORT_DESCRIPTOR BoundEntry = NULL;
691691
PIMAGE_IMPORT_DESCRIPTOR ImportEntry;
692692
ULONG BoundSize, IatSize;
693-
DPRINT("LdrpWalkImportDescriptor('%S' %p)\n", DllPath, LdrEntry);
693+
694+
DPRINT("LdrpWalkImportDescriptor - BEGIN (%wZ %p '%S')\n", &LdrEntry->BaseDllName, LdrEntry, DllPath);
694695

695696
/* Set up the Act Ctx */
696697
RtlZeroMemory(&ActCtx, sizeof(ActCtx));
@@ -711,7 +712,7 @@ LdrpWalkImportDescriptor(IN LPWSTR DllPath OPTIONAL,
711712
Status2 != STATUS_RESOURCE_LANG_NOT_FOUND)
712713
{
713714
/* Some serious issue */
714-
Status = Status2;
715+
//Status = Status2; // FIXME: Ignore that error for now
715716
DbgPrintEx(DPFLTR_SXS_ID,
716717
DPFLTR_WARNING_LEVEL,
717718
"LDR: LdrpWalkImportDescriptor() failed to probe %wZ for its "
@@ -724,16 +725,20 @@ LdrpWalkImportDescriptor(IN LPWSTR DllPath OPTIONAL,
724725
if (!NT_SUCCESS(Status)) return Status;
725726

726727
/* Get the Active ActCtx */
727-
Status = RtlGetActiveActivationContext(&LdrEntry->EntryPointActivationContext);
728-
if (!NT_SUCCESS(Status))
728+
if (!LdrEntry->EntryPointActivationContext)
729729
{
730-
/* Exit */
731-
DbgPrintEx(DPFLTR_SXS_ID,
732-
DPFLTR_WARNING_LEVEL,
733-
"LDR: RtlGetActiveActivationContext() failed; ntstatus = "
734-
"0x%08lx\n",
735-
Status);
736-
return Status;
730+
Status = RtlGetActiveActivationContext(&LdrEntry->EntryPointActivationContext);
731+
732+
if (!NT_SUCCESS(Status))
733+
{
734+
/* Exit */
735+
DbgPrintEx(DPFLTR_SXS_ID,
736+
DPFLTR_WARNING_LEVEL,
737+
"LDR: RtlGetActiveActivationContext() failed; ntstatus = "
738+
"0x%08lx\n",
739+
Status);
740+
return Status;
741+
}
737742
}
738743

739744
/* Activate the ActCtx */
@@ -807,6 +812,8 @@ LdrpWalkImportDescriptor(IN LPWSTR DllPath OPTIONAL,
807812
/* Release the activation context */
808813
RtlDeactivateActivationContextUnsafeFast(&ActCtx);
809814

815+
DPRINT("LdrpWalkImportDescriptor - END (%wZ %p)\n", &LdrEntry->BaseDllName, LdrEntry);
816+
810817
/* Return status */
811818
return Status;
812819
}
@@ -826,7 +833,7 @@ LdrpLoadImportModule(IN PWSTR DllPath OPTIONAL,
826833
PPEB Peb = RtlGetCurrentPeb();
827834
PTEB Teb = NtCurrentTeb();
828835

829-
DPRINT("LdrpLoadImportModule('%S' '%s' %p %p %p)\n", DllPath, ImportName, DllBase, DataTableEntry, Existing);
836+
DPRINT("LdrpLoadImportModule('%s' %p %p %p '%S')\n", ImportName, DllBase, DataTableEntry, Existing, DllPath);
830837

831838
/* Convert import descriptor name to unicode string */
832839
ImpDescName = &Teb->StaticUnicodeString;
@@ -849,6 +856,51 @@ LdrpLoadImportModule(IN PWSTR DllPath OPTIONAL,
849856
/* We're loading it for the first time */
850857
*Existing = FALSE;
851858

859+
#if 0
860+
/* Load manifest */
861+
{
862+
ACTCTX_SECTION_KEYED_DATA data;
863+
NTSTATUS status;
864+
865+
//DPRINT1("find_actctx_dll for %S\n", fullname);
866+
//RtlInitUnicodeString(&nameW, libname);
867+
data.cbSize = sizeof(data);
868+
status = RtlFindActivationContextSectionString(
869+
FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX, NULL,
870+
ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION,
871+
ImpDescName,
872+
&data);
873+
//if (status != STATUS_SUCCESS) return status;
874+
DPRINT1("Status: 0x%08X\n", status);
875+
876+
if (NT_SUCCESS(status))
877+
{
878+
ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION *info;
879+
SIZE_T needed, size = 1024;
880+
881+
for (;;)
882+
{
883+
if (!(info = RtlAllocateHeap(RtlGetProcessHeap(), 0, size)))
884+
{
885+
status = STATUS_NO_MEMORY;
886+
goto done;
887+
}
888+
status = RtlQueryInformationActivationContext(0, data.hActCtx, &data.ulAssemblyRosterIndex,
889+
AssemblyDetailedInformationInActivationContext,
890+
info, size, &needed);
891+
if (status == STATUS_SUCCESS) break;
892+
if (status != STATUS_BUFFER_TOO_SMALL) goto done;
893+
RtlFreeHeap(RtlGetProcessHeap(), 0, info);
894+
size = needed;
895+
}
896+
897+
DPRINT("manifestpath === %S\n", info->lpAssemblyManifestPath);
898+
DPRINT("DirectoryName === %S\n", info->lpAssemblyDirectoryName);
899+
}
900+
}
901+
done:
902+
#endif
903+
852904
/* Map it */
853905
Status = LdrpMapDll(DllPath,
854906
NULL,

reactos/dll/ntdll/ldr/ldrutils.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,6 +2061,8 @@ LdrpCheckForLoadedDll(IN PWSTR DllPath,
20612061
}
20622062

20632063
/* FIXME: Warning, activation context missing */
2064+
DPRINT("Warning, activation context missing\n");
2065+
20642066
/* NOTE: From here on down, everything looks good */
20652067

20662068
/* Loop the module list */

reactos/dll/win32/kernel32/client/actctx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ BasepProbeForDllManifest(IN PVOID DllHandle,
157157
Info.Type = (ULONG)RT_MANIFEST;
158158
Info.Name = (ULONG)ISOLATIONAWARE_MANIFEST_RESOURCE_ID;
159159
Info.Language = 0;
160-
if (!(Status = LdrFindResource_U(DllHandle, &Info, 2, &Entry)))
160+
if (!(Status = LdrFindResource_U(DllHandle, &Info, 3, &Entry)))
161161
{
162162
/* Create the activation context */
163163
Context.cbSize = sizeof(Context);

reactos/lib/rtl/actctx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4694,7 +4694,7 @@ RtlCreateActivationContext(IN ULONG Flags,
46944694
HANDLE file = 0;
46954695
struct actctx_loader acl;
46964696

4697-
DPRINT("%p %08x\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0);
4697+
DPRINT("RtlCreateActivationContext %p %08x, Image Base: %p\n", pActCtx, pActCtx ? pActCtx->dwFlags : 0, ((ACTCTXW*)ActivationContextData)->hModule);
46984698

46994699
if (!pActCtx || pActCtx->cbSize < sizeof(*pActCtx) ||
47004700
(pActCtx->dwFlags & ~ACTCTX_FLAGS_ALL))

0 commit comments

Comments
 (0)