[PATCH 1/2] kernel32/tests: Align SizeOfHeaders to FileAlignment

Brendan McGrath brendan at redmandi.com
Thu Nov 29 03:09:12 CST 2018


According to:
https://docs.microsoft.com/en-us/windows/desktop/debug/pe-format#optional-header-windows-specific-fields-image-only

SizeOfHeaders: The combined size of an MS-DOS stub, PE header, and section headers rounded up to a multiple of FileAlignment.

This change also fixes two kernel loader tests currently failing under 64bit.

Signed-off-by: Brendan McGrath <brendan at redmandi.com>
---
This patch set fixes three of the four failing 64bit kernel32 loader tests.

The remaining test that fails is due to the clr header being version 2.4 and wine only offering
64bit support for clr header version 2.5 and above. I couldn't find any documentation
to state why that is so I've left the test as failing.

 dlls/kernel32/tests/loader.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c
index 01c7cfa8a911..aaaa39f601d4 100644
--- a/dlls/kernel32/tests/loader.c
+++ b/dlls/kernel32/tests/loader.c
@@ -1097,7 +1097,7 @@ static void test_Loader(void)
         nt64.OptionalHeader.MajorOperatingSystemVersion = 4;
         nt64.OptionalHeader.MajorImageVersion = 1;
         nt64.OptionalHeader.MajorSubsystemVersion = 4;
-        nt64.OptionalHeader.SizeOfHeaders = sizeof(dos_header) + sizeof(nt64) + sizeof(IMAGE_SECTION_HEADER);
+        nt64.OptionalHeader.SizeOfHeaders = ALIGN_SIZE(sizeof(dos_header) + sizeof(nt64) + sizeof(IMAGE_SECTION_HEADER), nt64.OptionalHeader.FileAlignment);
         nt64.OptionalHeader.SizeOfImage = nt64.OptionalHeader.SizeOfHeaders + 0x1000;
         nt64.OptionalHeader.Subsystem = IMAGE_SUBSYSTEM_WINDOWS_CUI;
         nt64.OptionalHeader.SizeOfStackReserve = 0x321000;
@@ -1212,7 +1212,7 @@ static void test_Loader(void)
         nt32.OptionalHeader.MajorOperatingSystemVersion = 4;
         nt32.OptionalHeader.MajorImageVersion = 1;
         nt32.OptionalHeader.MajorSubsystemVersion = 4;
-        nt32.OptionalHeader.SizeOfHeaders = sizeof(dos_header) + sizeof(nt32) + sizeof(IMAGE_SECTION_HEADER);
+        nt32.OptionalHeader.SizeOfHeaders = ALIGN_SIZE(sizeof(dos_header) + sizeof(nt32) + sizeof(IMAGE_SECTION_HEADER), nt32.OptionalHeader.FileAlignment);
         nt32.OptionalHeader.SizeOfImage = nt32.OptionalHeader.SizeOfHeaders + 0x1000;
         nt32.OptionalHeader.Subsystem = IMAGE_SUBSYSTEM_WINDOWS_CUI;
         nt32.OptionalHeader.SizeOfStackReserve = 0x321000;
-- 
2.17.1




More information about the wine-devel mailing list