kernel32/tests: Add error codes for XP/Win2003 Wow64.
This commit is contained in:
parent
8532d06602
commit
e114f85345
|
@ -127,55 +127,54 @@ static void test_Loader(void)
|
|||
WORD number_of_sections, size_of_optional_header;
|
||||
DWORD section_alignment, file_alignment;
|
||||
DWORD size_of_image, size_of_headers;
|
||||
DWORD error; /* 0 means LoadLibrary should succeed */
|
||||
DWORD alt_error; /* alternate error */
|
||||
DWORD errors[4]; /* 0 means LoadLibrary should succeed */
|
||||
} td[] =
|
||||
{
|
||||
{ &dos_header, sizeof(dos_header),
|
||||
1, 0, 0, 0, 0, 0,
|
||||
ERROR_BAD_EXE_FORMAT
|
||||
{ ERROR_BAD_EXE_FORMAT }
|
||||
},
|
||||
{ &dos_header, sizeof(dos_header),
|
||||
1, sizeof(IMAGE_OPTIONAL_HEADER), 0x1000, 0x1000,
|
||||
sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER) + 0xe00,
|
||||
sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER),
|
||||
ERROR_BAD_EXE_FORMAT /* XP doesn't like too small image size */
|
||||
{ ERROR_BAD_EXE_FORMAT } /* XP doesn't like too small image size */
|
||||
},
|
||||
{ &dos_header, sizeof(dos_header),
|
||||
1, sizeof(IMAGE_OPTIONAL_HEADER), 0x1000, 0x1000,
|
||||
sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER) + 0x1000,
|
||||
sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER),
|
||||
ERROR_SUCCESS
|
||||
{ ERROR_SUCCESS }
|
||||
},
|
||||
{ &dos_header, sizeof(dos_header),
|
||||
1, sizeof(IMAGE_OPTIONAL_HEADER), 0x1000, 0x1000,
|
||||
0x1f00,
|
||||
0x1000,
|
||||
ERROR_SUCCESS
|
||||
{ ERROR_SUCCESS }
|
||||
},
|
||||
{ &dos_header, sizeof(dos_header),
|
||||
1, sizeof(IMAGE_OPTIONAL_HEADER), 0x200, 0x200,
|
||||
sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER) + 0x200,
|
||||
sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER),
|
||||
ERROR_SUCCESS, ERROR_INVALID_ADDRESS /* vista is more strict */
|
||||
{ ERROR_SUCCESS, ERROR_INVALID_ADDRESS } /* vista is more strict */
|
||||
},
|
||||
{ &dos_header, sizeof(dos_header),
|
||||
1, sizeof(IMAGE_OPTIONAL_HEADER), 0x200, 0x1000,
|
||||
sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER) + 0x1000,
|
||||
sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER),
|
||||
ERROR_BAD_EXE_FORMAT /* XP doesn't like alignments */
|
||||
{ ERROR_BAD_EXE_FORMAT } /* XP doesn't like alignments */
|
||||
},
|
||||
{ &dos_header, sizeof(dos_header),
|
||||
1, sizeof(IMAGE_OPTIONAL_HEADER), 0x1000, 0x200,
|
||||
sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER) + 0x1000,
|
||||
sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER),
|
||||
ERROR_SUCCESS
|
||||
{ ERROR_SUCCESS }
|
||||
},
|
||||
{ &dos_header, sizeof(dos_header),
|
||||
1, sizeof(IMAGE_OPTIONAL_HEADER), 0x1000, 0x200,
|
||||
sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER) + 0x1000,
|
||||
0x200,
|
||||
ERROR_SUCCESS
|
||||
{ ERROR_SUCCESS }
|
||||
},
|
||||
/* Mandatory are all fields up to SizeOfHeaders, everything else
|
||||
* is really optional (at least that's true for XP).
|
||||
|
@ -184,58 +183,59 @@ static void test_Loader(void)
|
|||
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,
|
||||
sizeof(dos_header) + sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER) + FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum) + sizeof(IMAGE_SECTION_HEADER),
|
||||
ERROR_SUCCESS, ERROR_BAD_EXE_FORMAT /* vista is more strict */
|
||||
{ ERROR_SUCCESS, ERROR_BAD_EXE_FORMAT, ERROR_INVALID_ADDRESS,
|
||||
ERROR_NOACCESS }
|
||||
},
|
||||
{ &dos_header, sizeof(dos_header),
|
||||
0, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum), 0x200, 0x200,
|
||||
0xd0, /* beyond of the end of file */
|
||||
0xc0, /* beyond of the end of file */
|
||||
ERROR_SUCCESS, ERROR_BAD_EXE_FORMAT /* vista is more strict */
|
||||
{ ERROR_SUCCESS, ERROR_BAD_EXE_FORMAT } /* vista is more strict */
|
||||
},
|
||||
{ &dos_header, sizeof(dos_header),
|
||||
0, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum), 0x200, 0x200,
|
||||
0x1000,
|
||||
0,
|
||||
ERROR_SUCCESS, ERROR_BAD_EXE_FORMAT /* vista is more strict */
|
||||
{ ERROR_SUCCESS, ERROR_BAD_EXE_FORMAT } /* vista is more strict */
|
||||
},
|
||||
{ &dos_header, sizeof(dos_header),
|
||||
0, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum), 0x200, 0x200,
|
||||
1,
|
||||
0,
|
||||
ERROR_SUCCESS, ERROR_BAD_EXE_FORMAT /* vista is more strict */
|
||||
{ ERROR_SUCCESS, ERROR_BAD_EXE_FORMAT } /* vista is more strict */
|
||||
},
|
||||
#if 0 /* not power of 2 alignments need more test cases */
|
||||
{ &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 */
|
||||
{ ERROR_BAD_EXE_FORMAT } /* alignment is not power of 2 */
|
||||
},
|
||||
#endif
|
||||
{ &dos_header, sizeof(dos_header),
|
||||
0, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum), 4, 4,
|
||||
1,
|
||||
0,
|
||||
ERROR_SUCCESS, ERROR_BAD_EXE_FORMAT /* vista is more strict */
|
||||
{ ERROR_SUCCESS, ERROR_BAD_EXE_FORMAT } /* vista is more strict */
|
||||
},
|
||||
{ &dos_header, sizeof(dos_header),
|
||||
0, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum), 1, 1,
|
||||
1,
|
||||
0,
|
||||
ERROR_SUCCESS, ERROR_BAD_EXE_FORMAT /* vista is more strict */
|
||||
{ ERROR_SUCCESS, ERROR_BAD_EXE_FORMAT } /* vista is more strict */
|
||||
},
|
||||
{ &dos_header, sizeof(dos_header),
|
||||
0, FIELD_OFFSET(IMAGE_OPTIONAL_HEADER, CheckSum), 0x200, 0x200,
|
||||
0,
|
||||
0,
|
||||
ERROR_BAD_EXE_FORMAT /* image size == 0 -> failure */
|
||||
{ ERROR_BAD_EXE_FORMAT } /* image size == 0 -> failure */
|
||||
},
|
||||
/* the following data mimics the PE image which upack creates */
|
||||
{ &dos_header, 0x10,
|
||||
1, 0x148, 0x1000, 0x200,
|
||||
sizeof(dos_header) + sizeof(nt_header) + sizeof(IMAGE_SECTION_HEADER) + 0x1000,
|
||||
0x200,
|
||||
ERROR_SUCCESS
|
||||
{ ERROR_SUCCESS }
|
||||
},
|
||||
/* Minimal PE image that XP is able to load: 92 bytes */
|
||||
{ &dos_header, 0x04,
|
||||
|
@ -243,7 +243,7 @@ static void test_Loader(void)
|
|||
0x04 /* also serves as e_lfanew in the truncated MZ header */, 0x04,
|
||||
1,
|
||||
0,
|
||||
ERROR_SUCCESS, ERROR_BAD_EXE_FORMAT /* vista is more strict */
|
||||
{ ERROR_SUCCESS, ERROR_BAD_EXE_FORMAT } /* vista is more strict */
|
||||
}
|
||||
};
|
||||
static const char filler[0x1000];
|
||||
|
@ -255,6 +255,8 @@ static void test_Loader(void)
|
|||
SYSTEM_INFO si;
|
||||
char temp_path[MAX_PATH];
|
||||
char dll_name[MAX_PATH];
|
||||
SIZE_T size;
|
||||
BOOL ret;
|
||||
|
||||
GetSystemInfo(&si);
|
||||
trace("system page size 0x%04x\n", si.dwPageSize);
|
||||
|
@ -343,10 +345,11 @@ static void test_Loader(void)
|
|||
{
|
||||
MEMORY_BASIC_INFORMATION info;
|
||||
|
||||
ok( td[i].error == ERROR_SUCCESS, "%d: should have failed\n", i );
|
||||
ok( td[i].errors[0] == ERROR_SUCCESS, "%d: should have failed\n", i );
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ok(VirtualQuery(hlib, &info, sizeof(info)) == sizeof(info),
|
||||
size = VirtualQuery(hlib, &info, sizeof(info));
|
||||
ok(size == sizeof(info),
|
||||
"%d: VirtualQuery error %d\n", i, GetLastError());
|
||||
ok(info.BaseAddress == hlib, "%d: %p != %p\n", i, info.BaseAddress, hlib);
|
||||
ok(info.AllocationBase == hlib, "%d: %p != %p\n", i, info.AllocationBase, hlib);
|
||||
|
@ -361,7 +364,8 @@ static void test_Loader(void)
|
|||
ok(info.Type == SEC_IMAGE, "%d: %x != SEC_IMAGE\n", i, info.Type);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ok(VirtualQuery((char *)hlib + info.RegionSize, &info, sizeof(info)) == sizeof(info),
|
||||
size = VirtualQuery((char *)hlib + info.RegionSize, &info, sizeof(info));
|
||||
ok(size == sizeof(info),
|
||||
"%d: VirtualQuery error %d\n", i, GetLastError());
|
||||
if (nt_header.OptionalHeader.SectionAlignment == si.dwPageSize ||
|
||||
nt_header.OptionalHeader.SectionAlignment == nt_header.OptionalHeader.FileAlignment)
|
||||
|
@ -402,7 +406,8 @@ static void test_Loader(void)
|
|||
if (nt_header.FileHeader.NumberOfSections)
|
||||
{
|
||||
SetLastError(0xdeadbeef);
|
||||
ok(VirtualQuery((char *)hlib + section.VirtualAddress, &info, sizeof(info)) == sizeof(info),
|
||||
size = VirtualQuery((char *)hlib + section.VirtualAddress, &info, sizeof(info));
|
||||
ok(size == sizeof(info),
|
||||
"%d: VirtualQuery error %d\n", i, GetLastError());
|
||||
if (nt_header.OptionalHeader.SectionAlignment < si.dwPageSize)
|
||||
{
|
||||
|
@ -446,14 +451,16 @@ static void test_Loader(void)
|
|||
ok(hlib_as_data_file == hlib, "hlib_as_file and hlib are different\n");
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ok(FreeLibrary(hlib), "FreeLibrary error %d\n", GetLastError());
|
||||
ret = FreeLibrary(hlib);
|
||||
ok(ret, "FreeLibrary error %d\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
hlib = GetModuleHandle(dll_name);
|
||||
ok(hlib != 0, "GetModuleHandle error %u\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ok(FreeLibrary(hlib_as_data_file), "FreeLibrary error %d\n", GetLastError());
|
||||
ret = FreeLibrary(hlib_as_data_file);
|
||||
ok(ret, "FreeLibrary error %d\n", GetLastError());
|
||||
|
||||
hlib = GetModuleHandle(dll_name);
|
||||
ok(!hlib, "GetModuleHandle should fail\n");
|
||||
|
@ -467,11 +474,13 @@ static void test_Loader(void)
|
|||
ok(!hlib, "GetModuleHandle should fail\n");
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ok(FreeLibrary(hlib_as_data_file), "FreeLibrary error %d\n", GetLastError());
|
||||
ret = FreeLibrary(hlib_as_data_file);
|
||||
ok(ret, "FreeLibrary error %d\n", GetLastError());
|
||||
}
|
||||
else
|
||||
{
|
||||
ok(td[i].error || td[i].alt_error, "%d: LoadLibrary should succeed\n", i);
|
||||
BOOL error_match;
|
||||
int error_index;
|
||||
|
||||
if (GetLastError() == ERROR_GEN_FAILURE) /* Win9x, broken behaviour */
|
||||
{
|
||||
|
@ -480,9 +489,14 @@ static void test_Loader(void)
|
|||
return;
|
||||
}
|
||||
|
||||
ok(td[i].error == GetLastError() || td[i].alt_error == GetLastError(),
|
||||
"%d: expected error %d or %d, got %d\n",
|
||||
i, td[i].error, td[i].alt_error, GetLastError());
|
||||
error_match = FALSE;
|
||||
for (error_index = 0;
|
||||
! error_match && error_index < sizeof(td[i].errors) / sizeof(DWORD);
|
||||
error_index++)
|
||||
{
|
||||
error_match = td[i].errors[error_index] == GetLastError();
|
||||
}
|
||||
ok(error_match, "%d: unexpected error %d\n", i, GetLastError());
|
||||
}
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
|
|
Loading…
Reference in New Issue