kernel32: Add a couple of weird PE images
Dmitry Timoshkov
dmitry at codeweavers.com
Wed Dec 13 11:00:05 CST 2006
Hello,
Changelog:
kernel32: Add a couple of weird PE images.
---
dlls/kernel32/tests/loader.c | 36 +++++++++++++++++++++++++++++++++++-
1 files changed, 35 insertions(+), 1 deletions(-)
diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c
index 7ae70f3..3a87481 100644
--- a/dlls/kernel32/tests/loader.c
+++ b/dlls/kernel32/tests/loader.c
@@ -100,6 +100,17 @@ static IMAGE_SECTION_HEADER section =
IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ, /* Characteristics */
};
+static BOOL is_power_of_two(DWORD alignment)
+{
+ if (!alignment) return FALSE;
+
+ while (!(alignment & 1))
+ {
+ alignment >>= 1;
+ }
+ return alignment == 1;
+}
+
START_TEST(loader)
{
static const struct test_data
@@ -186,6 +197,12 @@ START_TEST(loader)
ERROR_SUCCESS
},
{ &dos_header, sizeof(dos_header),
+ 0, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum), 0x300, 0x300,
+ 1,
+ 0,
+ ERROR_BAD_EXE_FORMAT /* alignment is not power of 2 */
+ },
+ { &dos_header, sizeof(dos_header),
0, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum), 4, 4,
1,
0,
@@ -210,6 +227,14 @@ START_TEST(loader)
0x200,
ERROR_SUCCESS
},
+ /* Minimal PE image that XP is able to load: 92 bytes */
+ { &dos_header, 0x04,
+ 0, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum),
+ 0x04 /* also serves as e_lfanew in the truncated MZ header */, 0x04,
+ 1,
+ 0,
+ ERROR_SUCCESS
+ }
};
static const char filler[0x1000];
static const char section_data[0x10] = "section data";
@@ -412,7 +437,16 @@ todo_wine {
ok(FreeLibrary(hlib), "FreeLibrary error %d\n", GetLastError());
}
else
- { /* LoadLibrary has failed */
+ { /* LoadLibrary is expected to fail */
+ if (nt_header.OptionalHeader.FileAlignment &&
+ (!is_power_of_two(nt_header.OptionalHeader.SectionAlignment) ||
+ !is_power_of_two(nt_header.OptionalHeader.FileAlignment)))
+ {
+ todo_wine ok(!hlib, "%d: LoadLibrary should fail\n", i);
+ FreeLibrary(hlib);
+ continue;
+ }
+
ok(!hlib, "%d: LoadLibrary should fail\n", i);
if (GetLastError() == ERROR_GEN_FAILURE) /* Win9x, broken behaviour */
--
1.4.4.2
More information about the wine-patches
mailing list