/* FUNCTIONS *****************************************************************/
-VOID
-NTAPI
-AVrfPageHeapDllNotification(IN PLDR_DATA_TABLE_ENTRY LdrEntry)
-{
- /* Check if page heap dll notification is turned on */
- if (!(RtlpDphGlobalFlags & DPH_FLAG_DLL_NOTIFY))
- return;
-
- /* We don't support this flag currently */
- UNIMPLEMENTED;
-}
NTSTATUS
NTAPI
}
/* Check if Application Verifier was enabled */
- if (Peb->NtGlobalFlag & FLG_HEAP_ENABLE_TAIL_CHECK)
+ if (Peb->NtGlobalFlag & FLG_APPLICATION_VERIFIER)
{
- /* FIXME */
- DPRINT1("We don't support Application Verifier yet!\n");
+ AVrfDllLoadNotification(LdrEntry);
}
/* Just to be safe */
return Status;
}
-/* FIXME: This function is missing SxS support */
NTSTATUS
NTAPI
LdrpLoadImportModule(IN PWSTR DllPath OPTIONAL,
NTSTATUS Status;
PPEB Peb = RtlGetCurrentPeb();
PTEB Teb = NtCurrentTeb();
+ UNICODE_STRING RedirectedImpDescName;
+ BOOLEAN RedirectedDll;
DPRINT("LdrpLoadImportModule('%S' '%s' %p %p)\n", DllPath, ImportName, DataTableEntry, Existing);
+ RedirectedDll = FALSE;
+ RtlInitEmptyUnicodeString(&RedirectedImpDescName, NULL, 0);
+
/* Convert import descriptor name to unicode string */
ImpDescName = &Teb->StaticUnicodeString;
RtlInitAnsiString(&AnsiString, ImportName);
&LdrApiDefaultExtension);
}
+ /* Check if the SxS Assemblies specify another file */
+ Status = RtlDosApplyFileIsolationRedirection_Ustr(TRUE,
+ ImpDescName,
+ &LdrApiDefaultExtension,
+ NULL,
+ &RedirectedImpDescName,
+ &ImpDescName,
+ NULL,
+ NULL,
+ NULL);
+
+ /* Check success */
+ if (NT_SUCCESS(Status))
+ {
+ /* Let Ldrp know */
+ RedirectedDll = TRUE;
+ }
+ else if (Status != STATUS_SXS_KEY_NOT_FOUND)
+ {
+ /* Unrecoverable SxS failure */
+ DPRINT1("LDR: RtlDosApplyFileIsolationRedirection_Ustr failed with status %x for dll %wZ\n", Status, ImpDescName);
+ goto done;
+ }
+
/* Check if it's loaded */
if (LdrpCheckForLoadedDll(DllPath,
ImpDescName,
TRUE,
- FALSE,
+ RedirectedDll,
DataTableEntry))
{
/* It's already existing in the list */
*Existing = TRUE;
- return STATUS_SUCCESS;
+ Status = STATUS_SUCCESS;
+ goto done;
}
/* 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,
ImpDescName->Buffer,
NULL,
TRUE,
- FALSE,
+ RedirectedDll,
DataTableEntry);
-
- if (!NT_SUCCESS(Status)) return Status;
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("LDR: LdrpMapDll failed with status %x for dll %wZ\n", Status, ImpDescName);
+ goto done;
+ }
/* Walk its import descriptor table */
Status = LdrpWalkImportDescriptor(DllPath,
&(*DataTableEntry)->InInitializationOrderLinks);
}
+done:
+ RtlFreeUnicodeString(&RedirectedImpDescName);
+
return Status;
}
PIMAGE_IMPORT_BY_NAME AddressOfData;
PULONG NameTable;
PUSHORT OrdinalTable;
- LPSTR ImportName = NULL;
+ LPSTR ImportName = NULL, DotPosition;
USHORT Hint;
NTSTATUS Status;
ULONG_PTR HardErrorParameters[3];
/* Is this a static snap? */
if (Static)
{
+ RtlInitAnsiString(&TempString, DllName ? DllName : "Unknown");
/* Inform the debug log */
if (IsOrdinal)
- DPRINT1("Failed to snap ordinal 0x%x\n", OriginalOrdinal);
+ DPRINT1("Failed to snap ordinal %Z!0x%x\n", &TempString, OriginalOrdinal);
else
- DPRINT1("Failed to snap %s\n", ImportName);
+ DPRINT1("Failed to snap %Z!%s\n", &TempString, ImportName);
/* These are critical errors. Setup a string for the DLL name */
- RtlInitAnsiString(&TempString, DllName ? DllName : "Unknown");
RtlAnsiStringToUnicodeString(&HardErrorDllName, &TempString, TRUE);
/* Set it as the parameter */
{
/* Get the Import and Forwarder Names */
ImportName = (LPSTR)Thunk->u1.Function;
+
+ DotPosition = strchr(ImportName, '.');
+ ASSERT(DotPosition != NULL);
+ if (!DotPosition)
+ goto FailurePath;
+
ForwarderName.Buffer = ImportName;
- ForwarderName.Length = (USHORT)(strchr(ImportName, '.') - ImportName);
+ ForwarderName.Length = (USHORT)(DotPosition - ImportName);
ForwarderName.MaximumLength = ForwarderName.Length;
Status = RtlAnsiStringToUnicodeString(&TempUString,
&ForwarderName,
/* Make sure the conversion was OK */
if (NT_SUCCESS(Status))
{
- /* Load the forwarder, free the temp string */
- Status = LdrpLoadDll(FALSE,
+ WCHAR StringBuffer[MAX_PATH];
+ UNICODE_STRING StaticString, *RedirectedImportName;
+ BOOLEAN Redirected = FALSE;
+
+ RtlInitEmptyUnicodeString(&StaticString, StringBuffer, sizeof(StringBuffer));
+
+ /* Check if the SxS Assemblies specify another file */
+ Status = RtlDosApplyFileIsolationRedirection_Ustr(TRUE,
+ &TempUString,
+ &LdrApiDefaultExtension,
+ &StaticString,
+ NULL,
+ &RedirectedImportName,
+ NULL,
+ NULL,
+ NULL);
+ if (NT_SUCCESS(Status))
+ {
+ if (ShowSnaps)
+ {
+ DPRINT1("LDR: %Z got redirected to %wZ\n", &ForwarderName, RedirectedImportName);
+ }
+ /* Let Ldrp know */
+ Redirected = TRUE;
+ }
+ else
+ {
+ RedirectedImportName = &TempUString;
+ }
+
+ /* Load the forwarder */
+ Status = LdrpLoadDll(Redirected,
NULL,
NULL,
- &TempUString,
+ RedirectedImportName,
&ForwarderHandle,
FALSE);
+
RtlFreeUnicodeString(&TempUString);
}
{
/* Import by name */
ForwardName = &ForwarderName;
+ ForwardOrdinal = 0;
}
/* Get the pointer */