Updated kernel32-PE_Loader_Fixes patchset

Thanks Paul.
This commit is contained in:
Alistair Leslie-Hughes 2019-06-20 09:10:25 +10:00
parent 11194ea339
commit ed630b8146
3 changed files with 19 additions and 10 deletions

View File

@ -1,27 +1,34 @@
From 144568af9042e8a4924d7f8c25d74c64665905a1 Mon Sep 17 00:00:00 2001
From 111ddb813a63598861536541896711c07491ea03 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Mon, 2 Jan 2017 15:34:21 +0800
Subject: [PATCH] server: All fields up to CheckSum are mandatory regardless of
SizeOfOptionalHeader value.
---
server/mapping.c | 10 ++++++++++
1 file changed, 10 insertions(+)
server/mapping.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/server/mapping.c b/server/mapping.c
index 2fba0231e3d..7680f88c59b 100644
index 0728fdc14f..77de48f57f 100644
--- a/server/mapping.c
+++ b/server/mapping.c
@@ -669,6 +669,8 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
@@ -592,11 +592,12 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
mz_size = size;
pos = mz.dos.e_lfanew;
+ /* zero out header in the case it's not present or partial */
+ /* zero out Optional header in the case it's not present or partial */
+ memset( &nt, 0, sizeof(nt) );
+
size = pread( unix_fd, &nt, sizeof(nt), pos );
if (size < sizeof(nt.Signature) + sizeof(nt.FileHeader)) return STATUS_INVALID_IMAGE_PROTECT;
/* zero out Optional header in the case it's not present or partial */
@@ -686,6 +688,10 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
- /* zero out Optional header in the case it's not present or partial */
- size = min( size, sizeof(nt.Signature) + sizeof(nt.FileHeader) + nt.FileHeader.SizeOfOptionalHeader );
- if (size < sizeof(nt)) memset( (char *)&nt + size, 0, sizeof(nt) - size );
+
if (nt.Signature != IMAGE_NT_SIGNATURE)
{
IMAGE_OS2_HEADER *os2 = (IMAGE_OS2_HEADER *)&nt;
@@ -609,6 +610,10 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
switch (nt.opt.hdr32.Magic)
{
case IMAGE_NT_OPTIONAL_HDR32_MAGIC:
@ -32,7 +39,7 @@ index 2fba0231e3d..7680f88c59b 100644
switch (nt.FileHeader.Machine)
{
case IMAGE_FILE_MACHINE_I386:
@@ -731,6 +737,10 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
@@ -654,6 +659,10 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
break;
case IMAGE_NT_OPTIONAL_HDR64_MAGIC:
@ -44,5 +51,5 @@ index 2fba0231e3d..7680f88c59b 100644
switch (nt.FileHeader.Machine)
{
--
2.17.1
2.21.0

View File

@ -1 +1,2 @@
Fixes: [42125] Various PE loader fixes for 8k demos
Fixes: [38176] Optical Circuit 4K demo crashes on startup

View File

@ -4142,6 +4142,7 @@ fi
# |
# | This patchset fixes the following Wine bugs:
# | * [#42125] Various PE loader fixes for 8k demos
# | * [#38176] Optical Circuit 4K demo crashes on startup
# |
# | Modified files:
# | * dlls/kernel32/process.c, dlls/kernel32/tests/loader.c, dlls/ntdll/virtual.c, server/mapping.c