diff --git a/patches/kernel32-PE_Loader_Fixes/0001-server-All-fields-up-to-CheckSum-are-mandatory-regar.patch b/patches/kernel32-PE_Loader_Fixes/0001-server-All-fields-up-to-CheckSum-are-mandatory-regar.patch index 945ff350..cb656a88 100644 --- a/patches/kernel32-PE_Loader_Fixes/0001-server-All-fields-up-to-CheckSum-are-mandatory-regar.patch +++ b/patches/kernel32-PE_Loader_Fixes/0001-server-All-fields-up-to-CheckSum-are-mandatory-regar.patch @@ -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 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 diff --git a/patches/kernel32-PE_Loader_Fixes/definition b/patches/kernel32-PE_Loader_Fixes/definition index 7af156bb..afc660f9 100644 --- a/patches/kernel32-PE_Loader_Fixes/definition +++ b/patches/kernel32-PE_Loader_Fixes/definition @@ -1 +1,2 @@ Fixes: [42125] Various PE loader fixes for 8k demos +Fixes: [38176] Optical Circuit 4K demo crashes on startup diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 77fb91f0..d5f1e25f 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -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