https://git.reactos.org/?p=reactos.git;a=commitdiff;h=27cc4c6a08e1c0dda3f87…
commit 27cc4c6a08e1c0dda3f874a68244ee6b0541f4b4
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Thu Feb 7 20:57:04 2019 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Fri Feb 8 21:24:01 2019 +0100
[LDR] Check forwarded imports against the manifest before trying to load them
CORE-15729
---
dll/ntdll/ldr/ldrpe.c | 37 ++++++++++++++++++++++++++++++++++---
1 file changed, 34 insertions(+), 3 deletions(-)
diff --git a/dll/ntdll/ldr/ldrpe.c b/dll/ntdll/ldr/ldrpe.c
index 1f7fa312366..ecba954687b 100644
--- a/dll/ntdll/ldr/ldrpe.c
+++ b/dll/ntdll/ldr/ldrpe.c
@@ -1133,13 +1133,44 @@ FailurePath:
/* 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);
}