Rebase against 9e26bc811656ad8eb901bffa5528b9ce25d44bc3.

This commit is contained in:
Zebediah Figura 2020-05-15 17:29:14 -05:00
parent cc185de9ef
commit 68f3e40ff7
8 changed files with 14 additions and 287 deletions

View File

@ -1,55 +0,0 @@
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 | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/server/mapping.c b/server/mapping.c
index 0728fdc14f..77de48f57f 100644
--- a/server/mapping.c
+++ b/server/mapping.c
@@ -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 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 */
- 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:
+ /* All fields up to CheckSum are mandatory regardless of SizeOfOptionalHeader value */
+ size = max( nt.FileHeader.SizeOfOptionalHeader, offsetof(IMAGE_OPTIONAL_HEADER32, CheckSum) );
+ if (size < sizeof(nt.opt.hdr32)) memset( (char *)&nt.opt.hdr32 + size, 0, sizeof(nt.opt.hdr32) - size );
+
switch (nt.FileHeader.Machine)
{
case IMAGE_FILE_MACHINE_I386:
@@ -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:
+ /* All fields up to CheckSum are mandatory regardless of SizeOfOptionalHeader value */
+ size = max( nt.FileHeader.SizeOfOptionalHeader, offsetof(IMAGE_OPTIONAL_HEADER64, CheckSum) );
+ if (size < sizeof(nt.opt.hdr64)) memset( (char *)&nt.opt.hdr64 + size, 0, sizeof(nt.opt.hdr64) - size );
+
if (!(cpu_mask & CPU_64BIT_MASK)) return STATUS_INVALID_IMAGE_WIN_64;
switch (nt.FileHeader.Machine)
{
--
2.21.0

View File

@ -1,28 +0,0 @@
From 446c35154c24406aa69522971bc31fb72bf854dc Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Mon, 2 Jan 2017 15:35:41 +0800
Subject: ntdll: If PE image size is larger than the backed file size then
treat file as removable.
---
dlls/ntdll/virtual.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index c64a31de045..ab72a9f9db5 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -1375,6 +1375,10 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, char *ba
/* unaligned sections, this happens for native subsystem binaries */
/* in that case Windows simply maps in the whole file */
+ /* if the image size is larger than the backed file size we can't mmap it */
+ if (total_size > ROUND_SIZE( 0, st.st_size ))
+ removable = TRUE;
+
if (map_file_into_view( view, fd, 0, total_size, 0, VPROT_COMMITTED | VPROT_READ | VPROT_WRITECOPY,
removable ) != STATUS_SUCCESS) goto error;
--
2.14.1

View File

@ -1,38 +0,0 @@
From 3f4b08acc72791d1c9bb244c39f0721b8da180de Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Mon, 2 Jan 2017 15:38:48 +0800
Subject: kernel32: On process entry store PEB address in %ebx.
8k demo custom PE loader depends on this.
---
dlls/kernel32/process.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index fdf272f61b0..231844b80a7 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -1073,12 +1073,19 @@ __ASM_GLOBAL_FUNC( call_process_entry,
__ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
"movl %esp,%ebp\n\t"
__ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
+ "pushl %ebx\n\t"
+ __ASM_CFI(".cfi_rel_offset %ebx,-4\n\t")
+ "subl $12,%esp\n\t"
"pushl 4(%ebp)\n\t" /* deliberately mis-align the stack by 8, Doom 3 needs this */
"pushl 4(%ebp)\n\t" /* Driller expects readable address at this offset */
"pushl 4(%ebp)\n\t"
"pushl 8(%ebp)\n\t"
+ "movl 8(%ebp),%ebx\n\t"
"call *12(%ebp)\n\t"
- "leave\n\t"
+ "leal -4(%ebp),%esp\n\t"
+ "popl %ebx\n\t"
+ __ASM_CFI(".cfi_same_value %ebx\n\t")
+ "popl %ebp\n\t"
__ASM_CFI(".cfi_def_cfa %esp,4\n\t")
__ASM_CFI(".cfi_same_value %ebp\n\t")
"ret" )
--
2.11.0

View File

@ -1,113 +0,0 @@
From 9b16cb2d6cd6a9e12819ea88e71d679ef5bbdc10 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Mon, 2 Jan 2017 15:50:01 +0800
Subject: [PATCH] kernel32/tests: Add a PE test image that resembles format of
some of 8k demos.
---
dlls/kernel32/tests/loader.c | 40 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c
index 25d3bf5..5efa0d6 100644
--- a/dlls/kernel32/tests/loader.c
+++ b/dlls/kernel32/tests/loader.c
@@ -193,7 +193,7 @@ static DWORD create_test_dll( const IMAGE_DOS_HEADER *dos_header, UINT dos_size,
{
SetLastError(0xdeadbeef);
ret = WriteFile(hfile, &nt_header->OptionalHeader,
- min(nt_header->FileHeader.SizeOfOptionalHeader, sizeof(IMAGE_OPTIONAL_HEADER)),
+ sizeof(IMAGE_OPTIONAL_HEADER),
&dummy, NULL);
ok(ret, "WriteFile error %d\n", GetLastError());
if (nt_header->FileHeader.SizeOfOptionalHeader > sizeof(IMAGE_OPTIONAL_HEADER))
@@ -209,6 +209,8 @@ static DWORD create_test_dll( const IMAGE_DOS_HEADER *dos_header, UINT dos_size,
assert(nt_header->FileHeader.NumberOfSections <= 1);
if (nt_header->FileHeader.NumberOfSections)
{
+ SetFilePointer(hfile, dos_size + sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER) + nt_header->FileHeader.SizeOfOptionalHeader, NULL, FILE_BEGIN);
+
section.SizeOfRawData = 10;
if (nt_header->OptionalHeader.SectionAlignment >= page_size)
@@ -233,6 +235,17 @@ static DWORD create_test_dll( const IMAGE_DOS_HEADER *dos_header, UINT dos_size,
ret = WriteFile(hfile, section_data, sizeof(section_data), &dummy, NULL);
ok(ret, "WriteFile error %d\n", GetLastError());
}
+
+ /* Minimal PE image that Windows7+ is able to load: 268 bytes */
+ size = GetFileSize(hfile, NULL);
+ if (size < 268)
+ {
+ file_align = 268 - size;
+ SetLastError(0xdeadbeef);
+ ret = WriteFile(hfile, filler, file_align, &dummy, NULL);
+ ok(ret, "WriteFile error %d\n", GetLastError());
+ }
+
size = GetFileSize(hfile, NULL);
CloseHandle(hfile);
return size;
@@ -382,7 +395,8 @@ static BOOL query_image_section( int id, const char *dll_name, const IMAGE_NT_HE
ok( image.LoaderFlags == (cor_header != NULL), "%u: LoaderFlags wrong %08x\n", id, image.LoaderFlags );
ok( image.ImageFileSize == file_size || broken(!image.ImageFileSize), /* winxpsp1 */
"%u: ImageFileSize wrong %08x / %08x\n", id, image.ImageFileSize, file_size );
- ok( image.CheckSum == nt_header->OptionalHeader.CheckSum, "%u: CheckSum wrong %08x / %08x\n", id,
+ ok( image.CheckSum == nt_header->OptionalHeader.CheckSum || broken(truncated),
+ "%u: CheckSum wrong %08x / %08x\n", id,
image.CheckSum, nt_header->OptionalHeader.CheckSum );
if (nt_header->OptionalHeader.SizeOfCode || nt_header->OptionalHeader.AddressOfEntryPoint)
@@ -605,6 +619,7 @@ static void test_Loader(void)
/* Mandatory are all fields up to SizeOfHeaders, everything else
* is really optional (at least that's true for XP).
*/
+#if 0 /* 32-bit Windows 8 crashes inside of LoadLibrary */
{ sizeof(dos_header),
1, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum), 0x200, 0x200,
sizeof(dos_header) + sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER) + FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum) + sizeof(IMAGE_SECTION_HEADER) + 0x10,
@@ -612,6 +627,7 @@ static void test_Loader(void)
{ ERROR_SUCCESS, ERROR_BAD_EXE_FORMAT, ERROR_INVALID_ADDRESS,
ERROR_NOACCESS }
},
+#endif
{ sizeof(dos_header),
0, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum), 0x200, 0x200,
0xd0, /* beyond of the end of file */
@@ -680,6 +696,14 @@ static void test_Loader(void)
0x40, /* minimal image size that Windows7 accepts */
0,
{ ERROR_SUCCESS }
+ },
+ /* the following data mimics the PE image which 8k demos have */
+ { 0x04,
+ 0, 0x08,
+ 0x04 /* also serves as e_lfanew in the truncated MZ header */, 0x04,
+ 0x200000,
+ 0x40,
+ { ERROR_SUCCESS }
}
};
int i;
@@ -886,6 +910,18 @@ static void test_Loader(void)
ok(ret, "FreeLibrary error %d\n", GetLastError());
}
+ SetLastError(0xdeadbeef);
+ ret = DeleteFileA(dll_name);
+ ok(ret, "DeleteFile error %d\n", GetLastError());
+
+ nt_header.OptionalHeader.AddressOfEntryPoint = 0x12345678;
+ file_size = create_test_dll( &dos_header, td[i].size_of_dos_header, &nt_header, dll_name );
+ if (!file_size)
+ {
+ ok(0, "could not create %s\n", dll_name);
+ break;
+ }
+
query_image_section( i, dll_name, &nt_header, NULL );
}
else
--
1.9.1

View File

@ -1 +0,0 @@
Fixes: [42125] Various PE loader fixes for 8k demos

View File

@ -52,7 +52,7 @@ usage()
# Get the upstream commit sha
upstream_commit()
{
echo "893080e4df5a45929320ebb88b8668eea316476c"
echo "9e26bc811656ad8eb901bffa5528b9ce25d44bc3"
}
# Show version information
@ -150,7 +150,6 @@ patch_enable_all ()
enable_kernel32_FindFirstFile="$1"
enable_kernel32_Job_Tests="$1"
enable_kernel32_K32GetPerformanceInfo="$1"
enable_kernel32_PE_Loader_Fixes="$1"
enable_kernel32_Processor_Group="$1"
enable_kernel32_SetProcessDEPPolicy="$1"
enable_krnl386_exe16_GDT_LDT_Emulation="$1"
@ -554,9 +553,6 @@ patch_enable ()
kernel32-K32GetPerformanceInfo)
enable_kernel32_K32GetPerformanceInfo="$2"
;;
kernel32-PE_Loader_Fixes)
enable_kernel32_PE_Loader_Fixes="$2"
;;
kernel32-Processor_Group)
enable_kernel32_Processor_Group="$2"
;;
@ -1550,13 +1546,6 @@ if test "$enable_wineboot_ProxySettings" -eq 1; then
enable_wineboot_drivers_etc_Stubs=1
fi
if test "$enable_windowscodecs_TIFF_Support" -eq 1; then
if test "$enable_windowscodecs_GIF_Encoder" -gt 1; then
abort "Patchset windowscodecs-GIF_Encoder disabled, but windowscodecs-TIFF_Support depends on that."
fi
enable_windowscodecs_GIF_Encoder=1
fi
if test "$enable_uxtheme_GTK_Theming" -eq 1; then
if test "$enable_uxtheme_CloseThemeClass" -gt 1; then
abort "Patchset uxtheme-CloseThemeClass disabled, but uxtheme-GTK_Theming depends on that."
@ -4039,27 +4028,6 @@ if test "$enable_kernel32_Job_Tests" -eq 1; then
) >> "$patchlist"
fi
# Patchset kernel32-PE_Loader_Fixes
# |
# | This patchset fixes the following Wine bugs:
# | * [#42125] Various PE loader fixes for 8k demos
# |
# | Modified files:
# | * dlls/kernel32/process.c, dlls/kernel32/tests/loader.c, dlls/ntdll/virtual.c, server/mapping.c
# |
if test "$enable_kernel32_PE_Loader_Fixes" -eq 1; then
patch_apply kernel32-PE_Loader_Fixes/0001-server-All-fields-up-to-CheckSum-are-mandatory-regar.patch
patch_apply kernel32-PE_Loader_Fixes/0002-ntdll-If-PE-image-size-is-larger-than-the-backed-fil.patch
patch_apply kernel32-PE_Loader_Fixes/0003-kernel32-On-process-entry-store-PEB-address-in-ebx.patch
patch_apply kernel32-PE_Loader_Fixes/0005-kernel32-tests-Add-a-PE-test-image-that-resembles-fo.patch
(
printf '%s\n' '+ { "Dmitry Timoshkov", "server: All fields up to CheckSum are mandatory regardless of SizeOfOptionalHeader value.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "ntdll: If PE image size is larger than the backed file size then treat file as removable.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "kernel32: On process entry store PEB address in %ebx.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "kernel32/tests: Add a PE test image that resembles format of some of 8k demos.", 1 },';
) >> "$patchlist"
fi
# Patchset kernel32-Processor_Group
# |
# | This patchset has the following (direct or indirect) dependencies:
@ -6178,9 +6146,6 @@ fi
# Patchset windowscodecs-TIFF_Support
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * windowscodecs-GIF_Encoder
# |
# | Modified files:
# | * dlls/gdiplus/image.c, dlls/gdiplus/tests/image.c, dlls/windowscodecs/metadatahandler.c
# |

View File

@ -1,4 +1,4 @@
From 6ae64bdf13f10acc9a9fb4c4f7d06d1fb0c6b161 Mon Sep 17 00:00:00 2001
From 9d32cc45f4c3ce2ddbc92d74198053631003153a Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Fri, 16 Dec 2016 18:09:55 +0800
Subject: [PATCH] gdiplus: Add support for more image color formats.
@ -8,23 +8,22 @@ Subject: [PATCH] gdiplus: Add support for more image color formats.
1 file changed, 5 insertions(+)
diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index 8bd723f031..9601a57d67 100644
index cafe69d8f43..4b696cd0481 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -61,8 +61,13 @@ static const struct
{ &GUID_WICPixelFormat16bppBGR555, PixelFormat16bppRGB555, WICBitmapPaletteTypeFixedHalftone256 },
{ &GUID_WICPixelFormat24bppBGR, PixelFormat24bppRGB, WICBitmapPaletteTypeFixedHalftone256 },
{ &GUID_WICPixelFormat32bppBGR, PixelFormat32bppRGB, WICBitmapPaletteTypeFixedHalftone256 },
+ { &GUID_WICPixelFormat48bppRGB, PixelFormat48bppRGB, WICBitmapPaletteTypeFixedHalftone256 },
{ &GUID_WICPixelFormat32bppBGRA, PixelFormat32bppARGB, WICBitmapPaletteTypeFixedHalftone256 },
{ &GUID_WICPixelFormat32bppPBGRA, PixelFormat32bppPARGB, WICBitmapPaletteTypeFixedHalftone256 },
+ { &GUID_WICPixelFormat32bppCMYK, PixelFormat32bppCMYK, WICBitmapPaletteTypeFixedHalftone256 },
+ { &GUID_WICPixelFormat32bppGrayFloat, PixelFormat32bppARGB, WICBitmapPaletteTypeFixedGray256 },
+ { &GUID_WICPixelFormat64bppCMYK, PixelFormat48bppRGB, WICBitmapPaletteTypeFixedHalftone256 },
+ { &GUID_WICPixelFormat64bppRGBA, PixelFormat48bppRGB, WICBitmapPaletteTypeFixedHalftone256 },
@@ -62,7 +62,12 @@ static const struct
{ &GUID_WICPixelFormat24bppBGR, PixelFormat24bppRGB, 0 },
{ &GUID_WICPixelFormat32bppBGR, PixelFormat32bppRGB, 0 },
{ &GUID_WICPixelFormat32bppBGRA, PixelFormat32bppARGB, 0 },
+ { &GUID_WICPixelFormat32bppCMYK, PixelFormat32bppCMYK, 0 },
+ { &GUID_WICPixelFormat32bppGrayFloat, PixelFormat32bppARGB, 0 },
{ &GUID_WICPixelFormat32bppPBGRA, PixelFormat32bppPARGB, 0 },
+ { &GUID_WICPixelFormat48bppRGB, PixelFormat48bppRGB, 0 },
+ { &GUID_WICPixelFormat64bppCMYK, PixelFormat48bppRGB, 0 },
+ { &GUID_WICPixelFormat64bppRGBA, PixelFormat48bppRGB, 0 },
{ NULL }
};
--
2.19.1
2.26.2

View File

@ -1,3 +1 @@
Fixes: Improve TIFF support in windowscodecs.dll
Depends: windowscodecs-GIF_Encoder