Rebase against 5bd9d58016236da3142e030add2efbb2789fa2e4.

This commit is contained in:
Sebastian Lackner
2015-07-29 22:53:17 +02:00
parent 5ec4d6171e
commit 493ed4662c
14 changed files with 77 additions and 599 deletions

View File

@@ -1,39 +0,0 @@
From 85b9819021a4e4b8f31050f5e894eb36b56e8cba Mon Sep 17 00:00:00 2001
From: Martin Storsjo <martin@martin.st>
Date: Thu, 23 Jul 2015 10:36:06 +0300
Subject: ntdll: Handle partial image load config structs. (try 3)
Some DLLs have a struct that only is large enough to contain the fields
that are relevant. Don't require the full struct to be available;
only make sure that it is large enough to contain the SecurityCookie
field.
This fixes loading ucrtbase.dll (from the redistributable visual
studio 2015 c++ runtime), which requires the security cookie to be
initialized. The 32 bit version of this DLL had loadcfg_size == 64,
where offsetof(IMAGE_LOAD_CONFIG_DIRECTORY, SecurityCookie) == 60.
That is, SecurityCookie is the last field included in the struct in
that case.
This fixes loading ucrtbase.dll.
---
dlls/ntdll/virtual.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index ff947da..479ca79 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -1320,7 +1320,8 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz
loadcfg = RtlImageDirectoryEntryToData( (HMODULE)ptr, TRUE,
IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG, &loadcfg_size );
- if (loadcfg && loadcfg_size >= sizeof(*loadcfg))
+ if (loadcfg &&
+ loadcfg_size >= offsetof(IMAGE_LOAD_CONFIG_DIRECTORY, SecurityCookie) + sizeof(loadcfg->SecurityCookie))
set_security_cookie((ULONG_PTR *)loadcfg->SecurityCookie);
/* set the image protections */
--
2.4.5