Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/kernel32/tests/virtual.c | 47 ------------------- dlls/ntdll/tests/Makefile.in | 3 +- dlls/ntdll/tests/virtual.c | 88 +++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 48 deletions(-) create mode 100644 dlls/ntdll/tests/virtual.c
diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index 474955630fd..0b718606d0e 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -52,8 +52,6 @@ static ULONG (WINAPI *pRtlRemoveVectoredExceptionHandler)(PVOID); static BOOL (WINAPI *pGetProcessDEPPolicy)(HANDLE, LPDWORD, PBOOL); static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL); static NTSTATUS (WINAPI *pNtProtectVirtualMemory)(HANDLE, PVOID *, SIZE_T *, ULONG, ULONG *); -static NTSTATUS (WINAPI *pNtAllocateVirtualMemory)(HANDLE, PVOID *, ULONG, SIZE_T *, ULONG, ULONG); -static NTSTATUS (WINAPI *pNtFreeVirtualMemory)(HANDLE, PVOID *, SIZE_T *, ULONG);
/* ############################### */
@@ -230,8 +228,6 @@ static void test_VirtualAlloc(void) void *addr1, *addr2; DWORD old_prot; MEMORY_BASIC_INFORMATION info; - NTSTATUS status; - SIZE_T size;
SetLastError(0xdeadbeef); addr1 = VirtualAlloc(0, 0, MEM_RESERVE, PAGE_NOACCESS); @@ -440,53 +436,12 @@ static void test_VirtualAlloc(void) addr2 = VirtualAlloc(addr1, 0x1000, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); ok(addr2 == addr1, "VirtualAlloc returned %p, expected %p\n", addr2, addr1);
- /* allocation conflicts because of 64k align */ - size = 0x1000; - addr2 = (char *)addr1 + 0x1000; - status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 0, &size, - MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); - ok(status == STATUS_CONFLICTING_ADDRESSES, "NtAllocateVirtualMemory returned %08x\n", status); - - /* it should conflict, even when zero_bits is explicitly set */ - size = 0x1000; - addr2 = (char *)addr1 + 0x1000; - status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 12, &size, - MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); - todo_wine - ok(status == STATUS_CONFLICTING_ADDRESSES, "NtAllocateVirtualMemory returned %08x\n", status); - if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n"); - - /* 21 zero bits is valid */ - size = 0x1000; - addr2 = NULL; - status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 21, &size, - MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); - ok(status == STATUS_SUCCESS || status == STATUS_NO_MEMORY, - "NtAllocateVirtualMemory returned %08x\n", status); - if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n"); - - /* 22 zero bits is invalid */ - size = 0x1000; - addr2 = NULL; - status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 22, &size, - MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); - ok(status == STATUS_INVALID_PARAMETER_3, "NtAllocateVirtualMemory returned %08x\n", status); - if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n"); - /* AT_ROUND_TO_PAGE flag is not supported for VirtualAlloc */ SetLastError(0xdeadbeef); addr2 = VirtualAlloc(addr1, 0x1000, MEM_RESERVE | MEM_COMMIT | AT_ROUND_TO_PAGE, PAGE_EXECUTE_READWRITE); ok(!addr2, "VirtualAlloc unexpectedly succeeded\n"); ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %d, expected ERROR_INVALID_PARAMETER\n", GetLastError());
- /* AT_ROUND_TO_PAGE flag is not supported for NtAllocateVirtualMemory */ - size = 0x1000; - addr2 = (char *)addr1 + 0x1000; - status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 0, &size, MEM_RESERVE | - MEM_COMMIT | AT_ROUND_TO_PAGE, PAGE_EXECUTE_READWRITE); - todo_wine - ok(status == STATUS_INVALID_PARAMETER_5, "NtAllocateVirtualMemory returned %08x\n", status); - ok(VirtualFree(addr1, 0, MEM_RELEASE), "VirtualFree failed\n"); }
@@ -4436,8 +4391,6 @@ START_TEST(virtual) pRtlAddVectoredExceptionHandler = (void *)GetProcAddress( hntdll, "RtlAddVectoredExceptionHandler" ); pRtlRemoveVectoredExceptionHandler = (void *)GetProcAddress( hntdll, "RtlRemoveVectoredExceptionHandler" ); pNtProtectVirtualMemory = (void *)GetProcAddress( hntdll, "NtProtectVirtualMemory" ); - pNtAllocateVirtualMemory = (void *)GetProcAddress( hntdll, "NtAllocateVirtualMemory" ); - pNtFreeVirtualMemory = (void *)GetProcAddress( hntdll, "NtFreeVirtualMemory" );
GetSystemInfo(&si); trace("system page size %#x\n", si.dwPageSize); diff --git a/dlls/ntdll/tests/Makefile.in b/dlls/ntdll/tests/Makefile.in index 5c70f3f01a0..ed15c51339f 100644 --- a/dlls/ntdll/tests/Makefile.in +++ b/dlls/ntdll/tests/Makefile.in @@ -22,4 +22,5 @@ C_SRCS = \ rtlstr.c \ string.c \ threadpool.c \ - time.c + time.c \ + virtual.c diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c new file mode 100644 index 00000000000..63300ac9460 --- /dev/null +++ b/dlls/ntdll/tests/virtual.c @@ -0,0 +1,88 @@ +#include <stdio.h> + +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winbase.h" +#include "winnt.h" +#include "winternl.h" +#include "winerror.h" +#include "winuser.h" +#include "excpt.h" +#include "wine/test.h" + +static NTSTATUS (WINAPI *pNtAllocateVirtualMemory)(HANDLE, PVOID *, ULONG, SIZE_T *, ULONG, ULONG); +static NTSTATUS (WINAPI *pNtFreeVirtualMemory)(HANDLE, PVOID *, SIZE_T *, ULONG); + +static void test_AllocateVirtualMemory(void) +{ + void *addr1, *addr2; + NTSTATUS status; + SIZE_T size; + + /* simple allocation should success */ + size = 0x1000; + addr1 = NULL; + status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr1, 0, &size, + MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); + ok(status == STATUS_SUCCESS, "NtAllocateVirtualMemory returned %08x\n", status); + + /* allocation conflicts because of 64k align */ + size = 0x1000; + addr2 = (char *)addr1 + 0x1000; + status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 0, &size, + MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); + ok(status == STATUS_CONFLICTING_ADDRESSES, "NtAllocateVirtualMemory returned %08x\n", status); + + /* it should conflict, even when zero_bits is explicitly set */ + size = 0x1000; + addr2 = (char *)addr1 + 0x1000; + status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 12, &size, + MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); + todo_wine + ok(status == STATUS_CONFLICTING_ADDRESSES, "NtAllocateVirtualMemory returned %08x\n", status); + if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n"); + + /* 21 zero bits is valid */ + size = 0x1000; + addr2 = NULL; + status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 21, &size, + MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); + ok(status == STATUS_SUCCESS || status == STATUS_NO_MEMORY, + "NtAllocateVirtualMemory returned %08x\n", status); + if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n"); + + /* 22 zero bits is invalid */ + size = 0x1000; + addr2 = NULL; + status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 22, &size, + MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); + ok(status == STATUS_INVALID_PARAMETER_3, "NtAllocateVirtualMemory returned %08x\n", status); + if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n"); + + /* AT_ROUND_TO_PAGE flag is not supported for NtAllocateVirtualMemory */ + size = 0x1000; + addr2 = (char *)addr1 + 0x1000; + status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 0, &size, MEM_RESERVE | + MEM_COMMIT | AT_ROUND_TO_PAGE, PAGE_EXECUTE_READWRITE); + todo_wine + ok(status == STATUS_INVALID_PARAMETER_5, "NtAllocateVirtualMemory returned %08x\n", status); + + ok(VirtualFree(addr1, 0, MEM_RELEASE), "VirtualFree failed\n"); +} + +START_TEST(virtual) +{ + SYSTEM_INFO si; + HMODULE hntdll; + + hntdll = GetModuleHandleA("ntdll.dll"); + + pNtAllocateVirtualMemory = (void *)GetProcAddress( hntdll, "NtAllocateVirtualMemory" ); + pNtFreeVirtualMemory = (void *)GetProcAddress( hntdll, "NtFreeVirtualMemory" ); + + GetSystemInfo(&si); + trace("system page size %#x\n", si.dwPageSize); + + test_AllocateVirtualMemory(); +}
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntdll/tests/virtual.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index 63300ac9460..f572a116eb9 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -48,7 +48,8 @@ static void test_AllocateVirtualMemory(void) addr2 = NULL; status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 21, &size, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); - ok(status == STATUS_SUCCESS || status == STATUS_NO_MEMORY, + ok((status == STATUS_SUCCESS || status == STATUS_NO_MEMORY) || + broken(status == STATUS_INVALID_PARAMETER) /* w1064v1809 */, "NtAllocateVirtualMemory returned %08x\n", status); if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n");
@@ -57,7 +58,9 @@ static void test_AllocateVirtualMemory(void) addr2 = NULL; status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 22, &size, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); - ok(status == STATUS_INVALID_PARAMETER_3, "NtAllocateVirtualMemory returned %08x\n", status); + ok(status == STATUS_INVALID_PARAMETER_3 || + broken(status == STATUS_INVALID_PARAMETER) /* w1064v1809 */, + "NtAllocateVirtualMemory returned %08x\n", status); if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n");
/* AT_ROUND_TO_PAGE flag is not supported for NtAllocateVirtualMemory */ @@ -66,7 +69,9 @@ static void test_AllocateVirtualMemory(void) status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 0, &size, MEM_RESERVE | MEM_COMMIT | AT_ROUND_TO_PAGE, PAGE_EXECUTE_READWRITE); todo_wine - ok(status == STATUS_INVALID_PARAMETER_5, "NtAllocateVirtualMemory returned %08x\n", status); + ok(status == STATUS_INVALID_PARAMETER_5 || + broken(status == STATUS_INVALID_PARAMETER) /* w1064v1809 */, + "NtAllocateVirtualMemory returned %08x\n", status);
ok(VirtualFree(addr1, 0, MEM_RELEASE), "VirtualFree failed\n"); }
On Wed, May 29, 2019 at 03:13:08PM +0200, Rémi Bernon wrote:
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
dlls/ntdll/tests/virtual.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index 63300ac9460..f572a116eb9 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -48,7 +48,8 @@ static void test_AllocateVirtualMemory(void) addr2 = NULL; status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 21, &size, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- ok(status == STATUS_SUCCESS || status == STATUS_NO_MEMORY,
- ok((status == STATUS_SUCCESS || status == STATUS_NO_MEMORY) ||
broken(status == STATUS_INVALID_PARAMETER) /* w1064v1809 */,
See my comment about this never succeeding under Windows. Also, I'm not sure that this is really broken. So just accepting STATUS_INVALID_PARAMETER as well as STATUS_NO_MEMORY is fine.
"NtAllocateVirtualMemory returned %08x\n", status); if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n");
@@ -57,7 +58,9 @@ static void test_AllocateVirtualMemory(void) addr2 = NULL; status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 22, &size, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- ok(status == STATUS_INVALID_PARAMETER_3, "NtAllocateVirtualMemory returned %08x\n", status);
- ok(status == STATUS_INVALID_PARAMETER_3 ||
broken(status == STATUS_INVALID_PARAMETER) /* w1064v1809 */,
"NtAllocateVirtualMemory returned %08x\n", status);
Again, I wouldn't describe this as broken behaviour.
if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n"); /* AT_ROUND_TO_PAGE flag is not supported for NtAllocateVirtualMemory */
@@ -66,7 +69,9 @@ static void test_AllocateVirtualMemory(void) status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 0, &size, MEM_RESERVE | MEM_COMMIT | AT_ROUND_TO_PAGE, PAGE_EXECUTE_READWRITE); todo_wine
- ok(status == STATUS_INVALID_PARAMETER_5, "NtAllocateVirtualMemory returned %08x\n", status);
- ok(status == STATUS_INVALID_PARAMETER_5 ||
broken(status == STATUS_INVALID_PARAMETER) /* w1064v1809 */,
"NtAllocateVirtualMemory returned %08x\n", status);
And again.
Huw.
On Thu, 2019-05-30 at 13:21 +0100, Huw Davies wrote:
On Wed, May 29, 2019 at 03:13:08PM +0200, Rémi Bernon wrote:
if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0,
MEM_RELEASE), "VirtualFree failed\n");
/* AT_ROUND_TO_PAGE flag is not supported for
NtAllocateVirtualMemory */ @@ -66,7 +69,9 @@ static void test_AllocateVirtualMemory(void) status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 0, &size, MEM_RESERVE | MEM_COMMIT | AT_ROUND_TO_PAGE, PAGE_EXECUTE_READWRITE); todo_wine
- ok(status == STATUS_INVALID_PARAMETER_5,
"NtAllocateVirtualMemory returned %08x\n", status);
- ok(status == STATUS_INVALID_PARAMETER_5 ||
broken(status == STATUS_INVALID_PARAMETER) /* w1064v1809
*/,
"NtAllocateVirtualMemory returned %08x\n", status);
And again.
Huw.
Here Wine returns STATUS_INVALID_PARAMETER, like w1064v1809, but not like previous Windows version, therefore the todo_wine. Should we detect the emulated windows version to be sure the returned status is consistent with it, or can the todo_wine be dropped?
Rémi.
On Fri, May 31, 2019 at 11:11:46AM +0200, Rémi Bernon wrote:
On Thu, 2019-05-30 at 13:21 +0100, Huw Davies wrote:
On Wed, May 29, 2019 at 03:13:08PM +0200, Rémi Bernon wrote:
if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0,
MEM_RELEASE), "VirtualFree failed\n");
/* AT_ROUND_TO_PAGE flag is not supported for
NtAllocateVirtualMemory */ @@ -66,7 +69,9 @@ static void test_AllocateVirtualMemory(void) status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 0, &size, MEM_RESERVE | MEM_COMMIT | AT_ROUND_TO_PAGE, PAGE_EXECUTE_READWRITE); todo_wine
- ok(status == STATUS_INVALID_PARAMETER_5,
"NtAllocateVirtualMemory returned %08x\n", status);
- ok(status == STATUS_INVALID_PARAMETER_5 ||
broken(status == STATUS_INVALID_PARAMETER) /* w1064v1809
*/,
"NtAllocateVirtualMemory returned %08x\n", status);
And again.
Huw.
Here Wine returns STATUS_INVALID_PARAMETER, like w1064v1809, but not like previous Windows version, therefore the todo_wine. Should we detect the emulated windows version to be sure the returned status is consistent with it, or can the todo_wine be dropped?
So they've 'fixed' Windows to behave like Wine - cool! ;-)
Yes, in that case just accept STATUS_INVALID_PARAMETER as well and remove the todo_wine.
Huw.
Memory allocated with NtAllocateVirtualMemory should be freed with NtFreeVirtualMemory, for consistency.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntdll/tests/virtual.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index f572a116eb9..ddee3eb5625 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -41,7 +41,12 @@ static void test_AllocateVirtualMemory(void) MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); todo_wine ok(status == STATUS_CONFLICTING_ADDRESSES, "NtAllocateVirtualMemory returned %08x\n", status); - if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n"); + if (status == STATUS_SUCCESS) + { + size = 0; + status = pNtFreeVirtualMemory(GetCurrentProcess(), &addr2, &size, MEM_RELEASE); + ok(status == STATUS_SUCCESS, "pNtFreeVirtualMemory return %08x, addr2: %p\n", status, addr2); + }
/* 21 zero bits is valid */ size = 0x1000; @@ -51,7 +56,12 @@ static void test_AllocateVirtualMemory(void) ok((status == STATUS_SUCCESS || status == STATUS_NO_MEMORY) || broken(status == STATUS_INVALID_PARAMETER) /* w1064v1809 */, "NtAllocateVirtualMemory returned %08x\n", status); - if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n"); + if (status == STATUS_SUCCESS) + { + size = 0; + status = pNtFreeVirtualMemory(GetCurrentProcess(), &addr2, &size, MEM_RELEASE); + ok(status == STATUS_SUCCESS, "pNtFreeVirtualMemory return %08x, addr2: %p\n", status, addr2); + }
/* 22 zero bits is invalid */ size = 0x1000; @@ -61,7 +71,12 @@ static void test_AllocateVirtualMemory(void) ok(status == STATUS_INVALID_PARAMETER_3 || broken(status == STATUS_INVALID_PARAMETER) /* w1064v1809 */, "NtAllocateVirtualMemory returned %08x\n", status); - if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n"); + if (status == STATUS_SUCCESS) + { + size = 0; + status = pNtFreeVirtualMemory(GetCurrentProcess(), &addr2, &size, MEM_RELEASE); + ok(status == STATUS_SUCCESS, "pNtFreeVirtualMemory return %08x, addr2: %p\n", status, addr2); + }
/* AT_ROUND_TO_PAGE flag is not supported for NtAllocateVirtualMemory */ size = 0x1000;
The zero_bits parameter doesn't behave as expected, and some 64bit code use it to allocate memory in the lower 32bit address space.
The expected full behaviour is:
* zero_bits == 0: no constraint on address range * 0 < zero_bits <= 15: returned address should have as many upper bits set to 0, starting at bit 31. In 64bit mode, upper 32bits should all be 0 as well. * 15 < zero_bits <= 31: unsure, but probably same as zero_bits == 15. * zero_bits > 31: (64bit/WoW64 only) zero_bits behaves as a bitmask, as if it was set to the number of leading 0 in the bitmask, works in the whole 64bit range.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntdll/tests/virtual.c | 63 ++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 6 deletions(-)
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index ddee3eb5625..c74d61c5bff 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -13,12 +13,15 @@
static NTSTATUS (WINAPI *pNtAllocateVirtualMemory)(HANDLE, PVOID *, ULONG, SIZE_T *, ULONG, ULONG); static NTSTATUS (WINAPI *pNtFreeVirtualMemory)(HANDLE, PVOID *, SIZE_T *, ULONG); +static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
static void test_AllocateVirtualMemory(void) { void *addr1, *addr2; NTSTATUS status; SIZE_T size; + ULONG zero_bits; + BOOL is_wow64;
/* simple allocation should success */ size = 0x1000; @@ -48,14 +51,15 @@ static void test_AllocateVirtualMemory(void) ok(status == STATUS_SUCCESS, "pNtFreeVirtualMemory return %08x, addr2: %p\n", status, addr2); }
- /* 21 zero bits is valid */ + /* 1 zero bits should zero 63-31 upper bits */ size = 0x1000; addr2 = NULL; - status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 21, &size, - MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); - ok((status == STATUS_SUCCESS || status == STATUS_NO_MEMORY) || - broken(status == STATUS_INVALID_PARAMETER) /* w1064v1809 */, - "NtAllocateVirtualMemory returned %08x\n", status); + zero_bits = 1; + status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 1, &size, + MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); + ok(((status == STATUS_SUCCESS || status == STATUS_NO_MEMORY) && ((UINT_PTR)addr2 >> (32 - zero_bits)) == 0) || + broken(status == STATUS_INVALID_PARAMETER_3) /* winxp */, + "NtAllocateVirtualMemory returned %08x, addr2: %p\n", status, addr2); if (status == STATUS_SUCCESS) { size = 0; @@ -63,6 +67,25 @@ static void test_AllocateVirtualMemory(void) ok(status == STATUS_SUCCESS, "pNtFreeVirtualMemory return %08x, addr2: %p\n", status, addr2); }
+ for (zero_bits = 2; zero_bits <= 21; zero_bits++) + { + size = 0x1000; + addr2 = NULL; + status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, zero_bits, &size, + MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); + todo_wine_if(zero_bits >= 12 || ((UINT_PTR)addr2 >> (32 - zero_bits))) + ok(((status == STATUS_SUCCESS || status == STATUS_NO_MEMORY) && ((UINT_PTR)addr2 >> (32 - zero_bits)) == 0) || + broken(zero_bits == 20 && status == STATUS_CONFLICTING_ADDRESSES) /* w1064v1809 */ || + broken(zero_bits == 21 && status == STATUS_INVALID_PARAMETER) /* w1064v1809 */, + "NtAllocateVirtualMemory with %d zero_bits returned %08x, addr2: %p\n", zero_bits, status, addr2); + if (status == STATUS_SUCCESS) + { + size = 0; + status = pNtFreeVirtualMemory(GetCurrentProcess(), &addr2, &size, MEM_RELEASE); + ok(status == STATUS_SUCCESS, "pNtFreeVirtualMemory return %08x, addr2: %p\n", status, addr2); + } + } + /* 22 zero bits is invalid */ size = 0x1000; addr2 = NULL; @@ -78,6 +101,31 @@ static void test_AllocateVirtualMemory(void) ok(status == STATUS_SUCCESS, "pNtFreeVirtualMemory return %08x, addr2: %p\n", status, addr2); }
+ /* zero bits > 31 should be considered as bitmask on 64bit and WoW64 */ + size = 0x1000; + addr2 = NULL; + zero_bits = 0x1fffffff; + status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, zero_bits, &size, + MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); + + if (sizeof(void *) == sizeof(int) && (!pIsWow64Process || + !pIsWow64Process( GetCurrentProcess(), &is_wow64 ) || !is_wow64)) + { + ok(status == STATUS_INVALID_PARAMETER_3, "NtAllocateVirtualMemory returned %08x\n", status); + } + else + { + todo_wine + ok((status == STATUS_SUCCESS || status == STATUS_NO_MEMORY) && ((UINT_PTR)addr2 & ~zero_bits) == 0, + "NtAllocateVirtualMemory returned %08x, addr2: %p\n", status, addr2); + if (status == STATUS_SUCCESS) + { + size = 0; + status = pNtFreeVirtualMemory(GetCurrentProcess(), &addr2, &size, MEM_RELEASE); + ok(status == STATUS_SUCCESS, "pNtFreeVirtualMemory return %08x, addr2: %p\n", status, addr2); + } + } + /* AT_ROUND_TO_PAGE flag is not supported for NtAllocateVirtualMemory */ size = 0x1000; addr2 = (char *)addr1 + 0x1000; @@ -95,11 +143,14 @@ START_TEST(virtual) { SYSTEM_INFO si; HMODULE hntdll; + HMODULE hkernel32;
hntdll = GetModuleHandleA("ntdll.dll"); + hkernel32 = GetModuleHandleA("kernel32.dll");
pNtAllocateVirtualMemory = (void *)GetProcAddress( hntdll, "NtAllocateVirtualMemory" ); pNtFreeVirtualMemory = (void *)GetProcAddress( hntdll, "NtFreeVirtualMemory" ); + pIsWow64Process = (void *)GetProcAddress( hkernel32, "IsWow64Process" );
GetSystemInfo(&si); trace("system page size %#x\n", si.dwPageSize);
NtAllocateVirtualMemory was called for its zero_bits parameter, used as an alignment value. But it is not, so call VirtualAlloc instead.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/commdlg.dll16/filedlg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/commdlg.dll16/filedlg.c b/dlls/commdlg.dll16/filedlg.c index 5b72bfab100..050cddb0dd5 100644 --- a/dlls/commdlg.dll16/filedlg.c +++ b/dlls/commdlg.dll16/filedlg.c @@ -509,8 +509,7 @@ static LPOFNHOOKPROC alloc_hook( LPOFNHOOKPROC16 hook16 ) SIZE_T size = 0x1000; unsigned int i;
- if (!hooks && NtAllocateVirtualMemory( GetCurrentProcess(), (void **)&hooks, 12, &size, - MEM_COMMIT, PAGE_EXECUTE_READWRITE )) + if (!hooks && !(hooks = VirtualAlloc( NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE ))) return NULL;
for (i = 0; i < count; i++)
This parameter was misinterpreted as an alignment parameter for the lower bits of the allocated memory region, although it is a constraint on the higher bits.
Add a new internal ntdll virtual_alloc_aligned function that has a separate alignment parameter which is now used instead of the zero_bits parameter.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntdll/directory.c | 4 ++-- dlls/ntdll/heap.c | 5 ++--- dlls/ntdll/ntdll_misc.h | 2 ++ dlls/ntdll/signal_arm.c | 12 ++++++------ dlls/ntdll/signal_arm64.c | 16 ++++++++-------- dlls/ntdll/signal_i386.c | 16 ++++++++-------- dlls/ntdll/signal_powerpc.c | 12 ++++++------ dlls/ntdll/signal_x86_64.c | 16 ++++++++-------- dlls/ntdll/tests/virtual.c | 3 ++- dlls/ntdll/thread.c | 3 +-- dlls/ntdll/virtual.c | 33 ++++++++++++++++++++++++++------- 11 files changed, 71 insertions(+), 51 deletions(-)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c index bbdbbe9781f..6605999b824 100644 --- a/dlls/ntdll/directory.c +++ b/dlls/ntdll/directory.c @@ -1603,14 +1603,14 @@ static KERNEL_DIRENT *start_vfat_ioctl( int fd ) SIZE_T size = 2 * sizeof(*de) + page_size; void *addr = NULL;
- if (NtAllocateVirtualMemory( GetCurrentProcess(), &addr, 1, &size, MEM_RESERVE, PAGE_READWRITE )) + if (virtual_alloc_aligned( &addr, 0, &size, MEM_RESERVE, PAGE_READWRITE, 1 )) return NULL; /* commit only the size needed for the dir entries */ /* this leaves an extra unaccessible page, which should make the kernel */ /* fail with -EFAULT before it stomps all over our memory */ de = addr; size = 2 * sizeof(*de); - NtAllocateVirtualMemory( GetCurrentProcess(), &addr, 1, &size, MEM_COMMIT, PAGE_READWRITE ); + virtual_alloc_aligned( &addr, 0, &size, MEM_COMMIT, PAGE_READWRITE, 1 ); }
/* set d_reclen to 65535 to work around an AFS kernel bug */ diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index cccaaee1d45..2d2caf551e3 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -726,8 +726,7 @@ static void *allocate_large_block( HEAP *heap, DWORD flags, SIZE_T size ) LPVOID address = NULL;
if (block_size < size) return NULL; /* overflow */ - if (NtAllocateVirtualMemory( NtCurrentProcess(), &address, 5, - &block_size, MEM_COMMIT, get_protection_type( flags ) )) + if (virtual_alloc_aligned( &address, 0, &block_size, MEM_COMMIT, get_protection_type( flags ), 5 )) { WARN("Could not allocate block for %08lx bytes\n", size ); return NULL; @@ -1521,7 +1520,7 @@ void heap_set_debug_flags( HANDLE handle ) void *ptr = NULL; SIZE_T size = MAX_FREE_PENDING * sizeof(*heap->pending_free);
- if (!NtAllocateVirtualMemory( NtCurrentProcess(), &ptr, 4, &size, MEM_COMMIT, PAGE_READWRITE )) + if (!virtual_alloc_aligned( &ptr, 0, &size, MEM_COMMIT, PAGE_READWRITE, 4 )) { heap->pending_free = ptr; heap->pending_pos = 0; diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index 2d83f541bd5..ae0e6b5742c 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -168,6 +168,8 @@ extern NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, ANSI_S UINT disposition ) DECLSPEC_HIDDEN;
/* virtual memory */ +extern NTSTATUS virtual_alloc_aligned( PVOID *ret, ULONG zero_bits, SIZE_T *size_ptr, + ULONG type, ULONG protect, ULONG alignment ); extern NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG zero_bits, SIZE_T commit_size, const LARGE_INTEGER *offset_ptr, SIZE_T *size_ptr, ULONG protect, pe_image_info_t *image_info ) DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/signal_arm.c b/dlls/ntdll/signal_arm.c index e01c8ce2193..cf7f2d13160 100644 --- a/dlls/ntdll/signal_arm.c +++ b/dlls/ntdll/signal_arm.c @@ -967,22 +967,22 @@ int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh) */ NTSTATUS signal_alloc_thread( TEB **teb ) { - static size_t sigstack_zero_bits; + static size_t sigstack_alignment; SIZE_T size; NTSTATUS status;
- if (!sigstack_zero_bits) + if (!sigstack_alignment) { size_t min_size = page_size; /* find the first power of two not smaller than min_size */ - while ((1u << sigstack_zero_bits) < min_size) sigstack_zero_bits++; + while ((1u << sigstack_alignment) < min_size) sigstack_alignment++; assert( sizeof(TEB) <= min_size ); }
- size = 1 << sigstack_zero_bits; + size = 1 << sigstack_alignment; *teb = NULL; - if (!(status = NtAllocateVirtualMemory( NtCurrentProcess(), (void **)teb, sigstack_zero_bits, - &size, MEM_COMMIT | MEM_TOP_DOWN, PAGE_READWRITE ))) + if (!(status = virtual_alloc_aligned( (void **)teb, 0, &size, MEM_COMMIT | MEM_TOP_DOWN, + PAGE_READWRITE, sigstack_alignment ))) { (*teb)->Tib.Self = &(*teb)->Tib; (*teb)->Tib.ExceptionList = (void *)~0UL; diff --git a/dlls/ntdll/signal_arm64.c b/dlls/ntdll/signal_arm64.c index 94520c95ced..d2d43b34bc1 100644 --- a/dlls/ntdll/signal_arm64.c +++ b/dlls/ntdll/signal_arm64.c @@ -871,24 +871,24 @@ int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh) */ NTSTATUS signal_alloc_thread( TEB **teb ) { - static size_t sigstack_zero_bits; + static size_t sigstack_alignment; SIZE_T size; NTSTATUS status;
- if (!sigstack_zero_bits) + if (!sigstack_alignment) { size_t min_size = teb_size + max( MINSIGSTKSZ, 8192 ); /* find the first power of two not smaller than min_size */ - sigstack_zero_bits = 12; - while ((1u << sigstack_zero_bits) < min_size) sigstack_zero_bits++; - signal_stack_size = (1 << sigstack_zero_bits) - teb_size; + sigstack_alignment = 12; + while ((1u << sigstack_alignment) < min_size) sigstack_alignment++; + signal_stack_size = (1 << sigstack_alignment) - teb_size; assert( sizeof(TEB) <= teb_size ); }
- size = 1 << sigstack_zero_bits; + size = 1 << sigstack_alignment; *teb = NULL; - if (!(status = NtAllocateVirtualMemory( NtCurrentProcess(), (void **)teb, sigstack_zero_bits, - &size, MEM_COMMIT | MEM_TOP_DOWN, PAGE_READWRITE ))) + if (!(status = virtual_alloc_aligned( (void **)teb, 0, &size, MEM_COMMIT | MEM_TOP_DOWN, + PAGE_READWRITE, sigstack_alignment ))) { (*teb)->Tib.Self = &(*teb)->Tib; (*teb)->Tib.ExceptionList = (void *)~0UL; diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c index b4e88d125f1..b2925062bf7 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -2312,25 +2312,25 @@ static void ldt_unlock(void) */ NTSTATUS signal_alloc_thread( TEB **teb ) { - static size_t sigstack_zero_bits; + static size_t sigstack_alignment; struct x86_thread_data *thread_data; SIZE_T size; void *addr = NULL; NTSTATUS status;
- if (!sigstack_zero_bits) + if (!sigstack_alignment) { size_t min_size = teb_size + max( MINSIGSTKSZ, 8192 ); /* find the first power of two not smaller than min_size */ - sigstack_zero_bits = 12; - while ((1u << sigstack_zero_bits) < min_size) sigstack_zero_bits++; - signal_stack_mask = (1 << sigstack_zero_bits) - 1; - signal_stack_size = (1 << sigstack_zero_bits) - teb_size; + sigstack_alignment = 12; + while ((1u << sigstack_alignment) < min_size) sigstack_alignment++; + signal_stack_mask = (1 << sigstack_alignment) - 1; + signal_stack_size = (1 << sigstack_alignment) - teb_size; }
size = signal_stack_mask + 1; - if (!(status = NtAllocateVirtualMemory( NtCurrentProcess(), &addr, sigstack_zero_bits, - &size, MEM_COMMIT | MEM_TOP_DOWN, PAGE_READWRITE ))) + if (!(status = virtual_alloc_aligned( &addr, 0, &size, MEM_COMMIT | MEM_TOP_DOWN, + PAGE_READWRITE, sigstack_alignment ))) { *teb = addr; (*teb)->Tib.Self = &(*teb)->Tib; diff --git a/dlls/ntdll/signal_powerpc.c b/dlls/ntdll/signal_powerpc.c index 86398d8f54f..f23265445df 100644 --- a/dlls/ntdll/signal_powerpc.c +++ b/dlls/ntdll/signal_powerpc.c @@ -1018,22 +1018,22 @@ int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh) */ NTSTATUS signal_alloc_thread( TEB **teb ) { - static size_t sigstack_zero_bits; + static size_t sigstack_alignment; SIZE_T size; NTSTATUS status;
- if (!sigstack_zero_bits) + if (!sigstack_alignment) { size_t min_size = page_size; /* this is just for the TEB, we don't use a signal stack yet */ /* find the first power of two not smaller than min_size */ - while ((1u << sigstack_zero_bits) < min_size) sigstack_zero_bits++; + while ((1u << sigstack_alignment) < min_size) sigstack_alignment++; assert( sizeof(TEB) <= min_size ); }
- size = 1 << sigstack_zero_bits; + size = 1 << sigstack_alignment; *teb = NULL; - if (!(status = NtAllocateVirtualMemory( NtCurrentProcess(), (void **)teb, sigstack_zero_bits, - &size, MEM_COMMIT | MEM_TOP_DOWN, PAGE_READWRITE ))) + if (!(status = virtual_alloc_aligned( (void **)teb, 0, &size, MEM_COMMIT | MEM_TOP_DOWN, + PAGE_READWRITE, sigstack_alignment ))) { (*teb)->Tib.Self = &(*teb)->Tib; (*teb)->Tib.ExceptionList = (void *)~0UL; diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c index c2151f78c63..e56534068ff 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c @@ -3263,24 +3263,24 @@ int CDECL __wine_set_signal_handler(unsigned int sig, wine_signal_handler wsh) */ NTSTATUS signal_alloc_thread( TEB **teb ) { - static size_t sigstack_zero_bits; + static size_t sigstack_alignment; SIZE_T size; NTSTATUS status;
- if (!sigstack_zero_bits) + if (!sigstack_alignment) { size_t min_size = teb_size + max( MINSIGSTKSZ, 8192 ); /* find the first power of two not smaller than min_size */ - sigstack_zero_bits = 12; - while ((1u << sigstack_zero_bits) < min_size) sigstack_zero_bits++; - signal_stack_size = (1 << sigstack_zero_bits) - teb_size; + sigstack_alignment = 12; + while ((1u << sigstack_alignment) < min_size) sigstack_alignment++; + signal_stack_size = (1 << sigstack_alignment) - teb_size; assert( sizeof(TEB) <= teb_size ); }
- size = 1 << sigstack_zero_bits; + size = 1 << sigstack_alignment; *teb = NULL; - if (!(status = NtAllocateVirtualMemory( NtCurrentProcess(), (void **)teb, sigstack_zero_bits, - &size, MEM_COMMIT | MEM_TOP_DOWN, PAGE_READWRITE ))) + if (!(status = virtual_alloc_aligned( (void **)teb, 0, &size, MEM_COMMIT | MEM_TOP_DOWN, + PAGE_READWRITE, sigstack_alignment ))) { (*teb)->Tib.Self = &(*teb)->Tib; (*teb)->Tib.ExceptionList = (void *)~0UL; diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index c74d61c5bff..7bad8f00a78 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -57,6 +57,7 @@ static void test_AllocateVirtualMemory(void) zero_bits = 1; status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 1, &size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); + todo_wine ok(((status == STATUS_SUCCESS || status == STATUS_NO_MEMORY) && ((UINT_PTR)addr2 >> (32 - zero_bits)) == 0) || broken(status == STATUS_INVALID_PARAMETER_3) /* winxp */, "NtAllocateVirtualMemory returned %08x, addr2: %p\n", status, addr2); @@ -73,7 +74,7 @@ static void test_AllocateVirtualMemory(void) addr2 = NULL; status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, zero_bits, &size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); - todo_wine_if(zero_bits >= 12 || ((UINT_PTR)addr2 >> (32 - zero_bits))) + todo_wine ok(((status == STATUS_SUCCESS || status == STATUS_NO_MEMORY) && ((UINT_PTR)addr2 >> (32 - zero_bits)) == 0) || broken(zero_bits == 20 && status == STATUS_CONFLICTING_ADDRESSES) /* w1064v1809 */ || broken(zero_bits == 21 && status == STATUS_INVALID_PARAMETER) /* w1064v1809 */, diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c index 46de839400d..96aa6be7f2c 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -184,8 +184,7 @@ void thread_init(void)
addr = NULL; size = sizeof(*peb); - NtAllocateVirtualMemory( NtCurrentProcess(), &addr, 1, &size, - MEM_COMMIT | MEM_TOP_DOWN, PAGE_READWRITE ); + virtual_alloc_aligned( &addr, 0, &size, MEM_COMMIT | MEM_TOP_DOWN, PAGE_READWRITE, 1 ); peb = addr;
peb->FastPebLock = &peb_lock; diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index 78973a8cda4..a3ed96ff77f 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -2461,19 +2461,17 @@ void virtual_set_large_address_space(void) NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_bits, SIZE_T *size_ptr, ULONG type, ULONG protect ) { - void *base; - unsigned int vprot; SIZE_T size = *size_ptr; - SIZE_T mask = get_mask( zero_bits ); NTSTATUS status = STATUS_SUCCESS; - BOOL is_dos_memory = FALSE; - struct file_view *view; - sigset_t sigset;
TRACE("%p %p %08lx %x %08x\n", process, *ret, size, type, protect );
if (!size) return STATUS_INVALID_PARAMETER; - if (!mask) return STATUS_INVALID_PARAMETER_3; + if (zero_bits) + { + FIXME("Unimplemented zero_bits handling\n"); + return STATUS_INVALID_PARAMETER_3; + }
if (process != NtCurrentProcess()) { @@ -2499,6 +2497,27 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_ return result.virtual_alloc.status; }
+ return virtual_alloc_aligned( ret, zero_bits, size_ptr, type, protect, 0 ); +} + + +/*********************************************************************** + * virtual_alloc_aligned (NTDLL.@) + * + * Same as NtAllocateVirtualMemory but with an alignment parameter + */ +NTSTATUS virtual_alloc_aligned( PVOID *ret, ULONG zero_bits, SIZE_T *size_ptr, + ULONG type, ULONG protect, ULONG alignment ) +{ + void *base; + unsigned int vprot; + SIZE_T size = *size_ptr; + SIZE_T mask = get_mask( alignment ); + NTSTATUS status = STATUS_SUCCESS; + BOOL is_dos_memory = FALSE; + struct file_view *view; + sigset_t sigset; + /* Round parameters to a page boundary */
if (is_beyond_limit( 0, size, working_set_limit )) return STATUS_WORKING_SET_LIMIT_RANGE;
Implement the correct zero_bits behavior for this single case: * Limit the search in reserved areas to the lower 2G range, * Pass the MAP_32BIT flag to mmap as a fallback.
LuaJIT <= v2.0.5 for example, when running in 64bit, allocates its memory in the lower 2GB memory region by using the zero_bits parameter.
This will fix this particular scenario, while trying to minimize the changes on all the other cases.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/ntdll/tests/virtual.c | 1 - dlls/ntdll/virtual.c | 35 +++++++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index 7bad8f00a78..1e54185770a 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -57,7 +57,6 @@ static void test_AllocateVirtualMemory(void) zero_bits = 1; status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 1, &size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); - todo_wine ok(((status == STATUS_SUCCESS || status == STATUS_NO_MEMORY) && ((UINT_PTR)addr2 >> (32 - zero_bits)) == 0) || broken(status == STATUS_INVALID_PARAMETER_3) /* winxp */, "NtAllocateVirtualMemory returned %08x, addr2: %p\n", status, addr2); diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index a3ed96ff77f..84c9ec97ed3 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -1083,7 +1083,7 @@ static NTSTATUS map_fixed_area( void *base, size_t size, unsigned int vprot ) * The csVirtual section must be held by caller. */ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, size_t mask, - int top_down, unsigned int vprot ) + int top_down, unsigned int vprot, size_t zero_bits ) { void *ptr; NTSTATUS status; @@ -1100,11 +1100,26 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size, { size_t view_size = size + mask + 1; struct alloc_area alloc; + int flags = 0;
alloc.size = size; alloc.mask = mask; alloc.top_down = top_down; alloc.limit = user_space_limit; + +#if defined(__x86_64__) && defined(MAP_32BIT) + /* HACK: only works for zero_bits == 1, this is a simple workaround + * for some 64bit code that tries to allocate memory in the lower + * 2GB segment using zero_bits parameter. + */ + assert(zero_bits <= 1); + if (zero_bits == 1) + { + alloc.limit = (void*)(((~(UINT_PTR)0) >> (32 + zero_bits)) & ~0xffff); + flags = MAP_32BIT; + } +#endif + if (wine_mmap_enum_reserved_areas( alloc_reserved_area_callback, &alloc, top_down )) { ptr = alloc.result; @@ -1116,7 +1131,7 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
for (;;) { - if ((ptr = wine_anon_mmap( NULL, view_size, VIRTUAL_GetUnixProt(vprot), 0 )) == (void *)-1) + if ((ptr = wine_anon_mmap( NULL, view_size, VIRTUAL_GetUnixProt(vprot), flags )) == (void *)-1) { if (errno == ENOMEM) return STATUS_NO_MEMORY; return STATUS_INVALID_PARAMETER; @@ -1284,7 +1299,7 @@ static NTSTATUS allocate_dos_memory( struct file_view **view, unsigned int vprot if (addr != low_64k) { if (addr != (void *)-1) munmap( addr, dosmem_size - 0x10000 ); - return map_view( view, NULL, dosmem_size, 0xffff, 0, vprot ); + return map_view( view, NULL, dosmem_size, 0xffff, 0, vprot, 0 ); } }
@@ -1388,11 +1403,11 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, SIZE_T m
if (base >= (char *)address_space_start) /* make sure the DOS area remains free */ status = map_view( &view, base, total_size, mask, FALSE, SEC_IMAGE | SEC_FILE | - VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY ); + VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY, 0 );
if (status != STATUS_SUCCESS) status = map_view( &view, NULL, total_size, mask, FALSE, SEC_IMAGE | SEC_FILE | - VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY ); + VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY, 0 );
if (status != STATUS_SUCCESS) goto error;
@@ -1713,7 +1728,7 @@ NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG zero_bits, S get_vprot_flags( protect, &vprot, sec_flags & SEC_IMAGE ); vprot |= sec_flags; if (!(sec_flags & SEC_RESERVE)) vprot |= VPROT_COMMITTED; - res = map_view( &view, *addr_ptr, size, mask, FALSE, vprot ); + res = map_view( &view, *addr_ptr, size, mask, FALSE, vprot, 0 ); if (res) { server_leave_uninterrupted_section( &csVirtual, &sigset ); @@ -1946,7 +1961,7 @@ NTSTATUS virtual_alloc_thread_stack( TEB *teb, SIZE_T reserve_size, SIZE_T commi server_enter_uninterrupted_section( &csVirtual, &sigset );
if ((status = map_view( &view, NULL, size + extra_size, 0xffff, 0, - VPROT_READ | VPROT_WRITE | VPROT_COMMITTED )) != STATUS_SUCCESS) + VPROT_READ | VPROT_WRITE | VPROT_COMMITTED, 0 )) != STATUS_SUCCESS) goto done;
#ifdef VALGRIND_STACK_REGISTER @@ -2467,7 +2482,11 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_ TRACE("%p %p %08lx %x %08x\n", process, *ret, size, type, protect );
if (!size) return STATUS_INVALID_PARAMETER; +#if defined(__x86_64__) && !defined(MAP_32BIT) if (zero_bits) +#else + if (zero_bits > 1) +#endif { FIXME("Unimplemented zero_bits handling\n"); return STATUS_INVALID_PARAMETER_3; @@ -2569,7 +2588,7 @@ NTSTATUS virtual_alloc_aligned( PVOID *ret, ULONG zero_bits, SIZE_T *size_ptr,
if (vprot & VPROT_WRITECOPY) status = STATUS_INVALID_PAGE_PROTECTION; else if (is_dos_memory) status = allocate_dos_memory( &view, vprot ); - else status = map_view( &view, base, size, mask, type & MEM_TOP_DOWN, vprot ); + else status = map_view( &view, base, size, mask, type & MEM_TOP_DOWN, vprot, zero_bits );
if (status == STATUS_SUCCESS) base = view->base; }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=53011
Your paranoid android.
=== wvistau64 (32 bit report) ===
kernel32: virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 0, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2850: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2864: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2989: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3007: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3088: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3112: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 1, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022
=== wvistau64_zh_CN (32 bit report) ===
kernel32: virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 0, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2850: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2864: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2989: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3007: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3088: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3112: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 1, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022
=== wvistau64_fr (32 bit report) ===
kernel32: virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 0, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2850: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2864: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2989: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3007: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3088: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3112: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 1, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022
=== wvistau64_he (32 bit report) ===
kernel32: virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 0, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2850: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2864: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2989: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3007: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3088: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3112: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 1, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022
=== w2008s64 (32 bit report) ===
kernel32: virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 0, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2850: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2864: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2989: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3007: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3088: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3112: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 1, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022
=== w7u (32 bit report) ===
kernel32: virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 0, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 1, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022
=== w7pro64 (32 bit report) ===
kernel32: virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 0, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2850: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2864: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2989: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3007: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3088: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3112: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 1, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022
=== w8 (32 bit report) ===
kernel32: virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 0, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2850: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2864: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2989: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3007: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3088: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3112: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 1, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022
=== w8adm (32 bit report) ===
kernel32: virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 0, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2850: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2864: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2989: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3007: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3088: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3112: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 1, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022
=== w864 (32 bit report) ===
kernel32: virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 0, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2850: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2864: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2989: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3007: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3088: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3112: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 1, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022
=== w1064v1507 (32 bit report) ===
kernel32: virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 0, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2850: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2864: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2989: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3007: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3088: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3112: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 1, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022
=== w1064v1809 (32 bit report) ===
kernel32: virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 0, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2850: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2864: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2989: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3007: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3088: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3112: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2794: Test failed: expected policy flags 1, got 3 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:2893: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2908: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2956: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:2971: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3152: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3177: Test failed: expected no STATUS_ACCESS_VIOLATION exception, got 1 exceptions virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2756: Test failed: NtSetInformationProcess failed with status c0000022 virtual.c:2795: Test failed: expected policy permanent FALSE, got 1 virtual.c:3214: Test failed: NtSetInformationProcess failed with status c0000022
=== w1064v1809 (32 bit report) ===
ntdll: virtual.c:51: Test failed: NtAllocateVirtualMemory returned c000000d virtual.c:60: Test failed: NtAllocateVirtualMemory returned c000000d virtual.c:69: Test failed: NtAllocateVirtualMemory returned c000000d
=== w1064v1809 (64 bit report) ===
ntdll: virtual.c:51: Test failed: NtAllocateVirtualMemory returned c000000d virtual.c:60: Test failed: NtAllocateVirtualMemory returned c000000d virtual.c:69: Test failed: NtAllocateVirtualMemory returned c000000d
On Wed, May 29, 2019 at 03:13:07PM +0200, Rémi Bernon wrote:
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
dlls/kernel32/tests/virtual.c | 47 ------------------- dlls/ntdll/tests/Makefile.in | 3 +- dlls/ntdll/tests/virtual.c | 88 +++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 48 deletions(-) create mode 100644 dlls/ntdll/tests/virtual.c
About the first few patches in this series in general. I would re-order them. First fix the tests in kernel32 (so put patch 2 first). Then move them, but combine this patch with patch 3. Then you can add new tests.
Some more comments below.
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c new file mode 100644 index 00000000000..63300ac9460 --- /dev/null +++ b/dlls/ntdll/tests/virtual.c @@ -0,0 +1,88 @@ +#include <stdio.h>
+#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winbase.h" +#include "winnt.h" +#include "winternl.h" +#include "winerror.h" +#include "winuser.h" +#include "excpt.h" +#include "wine/test.h"
+static NTSTATUS (WINAPI *pNtAllocateVirtualMemory)(HANDLE, PVOID *, ULONG, SIZE_T *, ULONG, ULONG); +static NTSTATUS (WINAPI *pNtFreeVirtualMemory)(HANDLE, PVOID *, SIZE_T *, ULONG);
I don't see any reason to dynamically load these fn ptrs, you can just call the functions directly.
+static void test_AllocateVirtualMemory(void) +{
- void *addr1, *addr2;
- NTSTATUS status;
- SIZE_T size;
- /* simple allocation should success */
- size = 0x1000;
- addr1 = NULL;
- status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr1, 0, &size,
MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- ok(status == STATUS_SUCCESS, "NtAllocateVirtualMemory returned %08x\n", status);
- /* allocation conflicts because of 64k align */
- size = 0x1000;
- addr2 = (char *)addr1 + 0x1000;
- status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 0, &size,
MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- ok(status == STATUS_CONFLICTING_ADDRESSES, "NtAllocateVirtualMemory returned %08x\n", status);
- /* it should conflict, even when zero_bits is explicitly set */
- size = 0x1000;
- addr2 = (char *)addr1 + 0x1000;
- status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 12, &size,
MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- todo_wine
- ok(status == STATUS_CONFLICTING_ADDRESSES, "NtAllocateVirtualMemory returned %08x\n", status);
- if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n");
- /* 21 zero bits is valid */
- size = 0x1000;
- addr2 = NULL;
- status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 21, &size,
MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- ok(status == STATUS_SUCCESS || status == STATUS_NO_MEMORY,
"NtAllocateVirtualMemory returned %08x\n", status);
This allocation always fails on Windows see:
https://testbot.winehq.org/JobDetails.pl?Key=53086
So as part of the test fixing before you move them to ntdll, I'd remove the STATUS_SUCCESS and you'll probably have to add a todo_wine at the same time.
- if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n");
As mentioned above, this will now call NtVirtualFreeMemory()
- /* 22 zero bits is invalid */
- size = 0x1000;
- addr2 = NULL;
- status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 22, &size,
MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- ok(status == STATUS_INVALID_PARAMETER_3, "NtAllocateVirtualMemory returned %08x\n", status);
- if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n");
- /* AT_ROUND_TO_PAGE flag is not supported for NtAllocateVirtualMemory */
- size = 0x1000;
- addr2 = (char *)addr1 + 0x1000;
- status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 0, &size, MEM_RESERVE |
MEM_COMMIT | AT_ROUND_TO_PAGE, PAGE_EXECUTE_READWRITE);
- todo_wine
- ok(status == STATUS_INVALID_PARAMETER_5, "NtAllocateVirtualMemory returned %08x\n", status);
- ok(VirtualFree(addr1, 0, MEM_RELEASE), "VirtualFree failed\n");
+}
+START_TEST(virtual) +{
- SYSTEM_INFO si;
- HMODULE hntdll;
- hntdll = GetModuleHandleA("ntdll.dll");
- pNtAllocateVirtualMemory = (void *)GetProcAddress( hntdll, "NtAllocateVirtualMemory" );
- pNtFreeVirtualMemory = (void *)GetProcAddress( hntdll, "NtFreeVirtualMemory" );
- GetSystemInfo(&si);
I'd probably use NtQuerySystemInformation( SystemCpuInformation, ...) instead.
Huw.
On Thu, 2019-05-30 at 13:19 +0100, Huw Davies wrote:
On Wed, May 29, 2019 at 03:13:07PM +0200, Rémi Bernon wrote:
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c new file mode 100644 index 00000000000..63300ac9460 --- /dev/null +++ b/dlls/ntdll/tests/virtual.c @@ -0,0 +1,88 @@ +#include <stdio.h>
+#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winbase.h" +#include "winnt.h" +#include "winternl.h" +#include "winerror.h" +#include "winuser.h" +#include "excpt.h" +#include "wine/test.h"
+static NTSTATUS (WINAPI *pNtAllocateVirtualMemory)(HANDLE, PVOID *, ULONG, SIZE_T *, ULONG, ULONG); +static NTSTATUS (WINAPI *pNtFreeVirtualMemory)(HANDLE, PVOID *, SIZE_T *, ULONG);
I don't see any reason to dynamically load these fn ptrs, you can just call the functions directly.
Is there a particular reason the tested functions are dynamically loaded in some test executables?
Rémi.
On Fri, May 31, 2019 at 10:31:10AM +0200, Rémi Bernon wrote:
Is there a particular reason the tested functions are dynamically loaded in some test executables?
The typical reason would be that the functions are not available on all of the Windows versions that we test.
As we retire testing on older Windows versions this can leave us dynamically loading functions that we need not any more.
Huw.
Huw Davies huw@codeweavers.com wrote:
On Fri, May 31, 2019 at 10:31:10AM +0200, Rémi Bernon wrote:
Is there a particular reason the tested functions are dynamically loaded in some test executables?
The typical reason would be that the functions are not available on all of the Windows versions that we test.
As we retire testing on older Windows versions this can leave us dynamically loading functions that we need not any more.
Another reason is that sometimes PSDK doesn't have an appropriate import library. Alphough it tends to get added in newer PSDK versions, but that's not a good reason to break compilation with older PSDK versions by removing dynamic API loading (some people abuse this very badly recently).
Dmitry Timoshkov dmitry@baikal.ru writes:
Huw Davies huw@codeweavers.com wrote:
On Fri, May 31, 2019 at 10:31:10AM +0200, Rémi Bernon wrote:
Is there a particular reason the tested functions are dynamically loaded in some test executables?
The typical reason would be that the functions are not available on all of the Windows versions that we test.
As we retire testing on older Windows versions this can leave us dynamically loading functions that we need not any more.
Another reason is that sometimes PSDK doesn't have an appropriate import library. Alphough it tends to get added in newer PSDK versions, but that's not a good reason to break compilation with older PSDK versions by removing dynamic API loading (some people abuse this very badly recently).
It's not unreasonable to require a recent PSDK, if that makes the code simpler.
Alexandre Julliard julliard@winehq.org wrote:
Dmitry Timoshkov dmitry@baikal.ru writes:
Huw Davies huw@codeweavers.com wrote:
On Fri, May 31, 2019 at 10:31:10AM +0200, Rémi Bernon wrote:
Is there a particular reason the tested functions are dynamically loaded in some test executables?
The typical reason would be that the functions are not available on all of the Windows versions that we test.
As we retire testing on older Windows versions this can leave us dynamically loading functions that we need not any more.
Another reason is that sometimes PSDK doesn't have an appropriate import library. Alphough it tends to get added in newer PSDK versions, but that's not a good reason to break compilation with older PSDK versions by removing dynamic API loading (some people abuse this very badly recently).
It's not unreasonable to require a recent PSDK, if that makes the code simpler.
Some of my test WMs running Widows XP, some Windows 7, it's pretty questionable to require installing a Windows 10 SDK there (if it will ever install under XP). On the other hand a test compiled under Windows 7 won't run under XP. Personally, I find testing under XP and Windows 7 very valueable, please don't ruin that ability.
On 5/31/19 4:17 AM, Dmitry Timoshkov wrote:
Alexandre Julliard julliard@winehq.org wrote:
Dmitry Timoshkov dmitry@baikal.ru writes:
Huw Davies huw@codeweavers.com wrote:
On Fri, May 31, 2019 at 10:31:10AM +0200, Rémi Bernon wrote:
Is there a particular reason the tested functions are dynamically loaded in some test executables?
The typical reason would be that the functions are not available on all of the Windows versions that we test.
As we retire testing on older Windows versions this can leave us dynamically loading functions that we need not any more.
Another reason is that sometimes PSDK doesn't have an appropriate import library. Alphough it tends to get added in newer PSDK versions, but that's not a good reason to break compilation with older PSDK versions by removing dynamic API loading (some people abuse this very badly recently).
It's not unreasonable to require a recent PSDK, if that makes the code simpler.
Some of my test WMs running Widows XP, some Windows 7, it's pretty questionable to require installing a Windows 10 SDK there (if it will ever install under XP). On the other hand a test compiled under Windows 7 won't run under XP. Personally, I find testing under XP and Windows 7 very valueable, please don't ruin that ability.
mingw-w64 works quite well for compiling tests to run under XP.
Zebediah Figura z.figura12@gmail.com wrote:
On 5/31/19 4:17 AM, Dmitry Timoshkov wrote:
Alexandre Julliard julliard@winehq.org wrote:
Dmitry Timoshkov dmitry@baikal.ru writes:
Huw Davies huw@codeweavers.com wrote:
On Fri, May 31, 2019 at 10:31:10AM +0200, Rémi Bernon wrote:
Is there a particular reason the tested functions are dynamically loaded in some test executables?
The typical reason would be that the functions are not available on all of the Windows versions that we test.
As we retire testing on older Windows versions this can leave us dynamically loading functions that we need not any more.
Another reason is that sometimes PSDK doesn't have an appropriate import library. Alphough it tends to get added in newer PSDK versions, but that's not a good reason to break compilation with older PSDK versions by removing dynamic API loading (some people abuse this very badly recently).
It's not unreasonable to require a recent PSDK, if that makes the code simpler.
Some of my test WMs running Widows XP, some Windows 7, it's pretty questionable to require installing a Windows 10 SDK there (if it will ever install under XP). On the other hand a test compiled under Windows 7 won't run under XP. Personally, I find testing under XP and Windows 7 very valueable, please don't ruin that ability.
mingw-w64 works quite well for compiling tests to run under XP.
Probably, but using native tools is always preferrable.
On 5/31/19 12:03 PM, Dmitry Timoshkov wrote:
Zebediah Figura z.figura12@gmail.com wrote:
On 5/31/19 4:17 AM, Dmitry Timoshkov wrote:
Alexandre Julliard julliard@winehq.org wrote:
Dmitry Timoshkov dmitry@baikal.ru writes:
Huw Davies huw@codeweavers.com wrote:
On Fri, May 31, 2019 at 10:31:10AM +0200, Rémi Bernon wrote: > Is there a particular reason the tested functions are dynamically > loaded in some test executables?
The typical reason would be that the functions are not available on all of the Windows versions that we test.
As we retire testing on older Windows versions this can leave us dynamically loading functions that we need not any more.
Another reason is that sometimes PSDK doesn't have an appropriate import library. Alphough it tends to get added in newer PSDK versions, but that's not a good reason to break compilation with older PSDK versions by removing dynamic API loading (some people abuse this very badly recently).
It's not unreasonable to require a recent PSDK, if that makes the code simpler.
Some of my test WMs running Widows XP, some Windows 7, it's pretty questionable to require installing a Windows 10 SDK there (if it will ever install under XP). On the other hand a test compiled under Windows 7 won't run under XP. Personally, I find testing under XP and Windows 7 very valueable, please don't ruin that ability.
mingw-w64 works quite well for compiling tests to run under XP.
Probably, but using native tools is always preferrable.
Why?
Zebediah Figura z.figura12@gmail.com wrote:
On 5/31/19 12:03 PM, Dmitry Timoshkov wrote:
Zebediah Figura z.figura12@gmail.com wrote:
On 5/31/19 4:17 AM, Dmitry Timoshkov wrote:
Alexandre Julliard julliard@winehq.org wrote:
Dmitry Timoshkov dmitry@baikal.ru writes:
Huw Davies huw@codeweavers.com wrote:
> On Fri, May 31, 2019 at 10:31:10AM +0200, Rémi Bernon wrote: >> Is there a particular reason the tested functions are dynamically >> loaded in some test executables? > > The typical reason would be that the functions are not available on > all of the Windows versions that we test. > > As we retire testing on older Windows versions this can leave us > dynamically loading functions that we need not any more.
Another reason is that sometimes PSDK doesn't have an appropriate import library. Alphough it tends to get added in newer PSDK versions, but that's not a good reason to break compilation with older PSDK versions by removing dynamic API loading (some people abuse this very badly recently).
It's not unreasonable to require a recent PSDK, if that makes the code simpler.
Some of my test WMs running Widows XP, some Windows 7, it's pretty questionable to require installing a Windows 10 SDK there (if it will ever install under XP). On the other hand a test compiled under Windows 7 won't run under XP. Personally, I find testing under XP and Windows 7 very valueable, please don't ruin that ability.
mingw-w64 works quite well for compiling tests to run under XP.
Probably, but using native tools is always preferrable.
Why?
As usually: to avoid bugs and incomplete headers/imports.