Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/ntdll/tests/virtual.c | 35 +++++++++++++++++++++++++++++++++-- include/winnt.h | 7 +++++++ 2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index f8bb3e97c86..d83ce597b17 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -274,8 +274,20 @@ static void test_NtAllocateVirtualMemory(void)
static void test_NtAllocateVirtualMemoryEx(void) { - void *addr1, *addr2; + static struct memreq_test + { + MEM_ADDRESS_REQUIREMENTS param; + NTSTATUS status; + } + memreq_tests[] = + { + { { NULL, (void *)0x10000000, 0 }, STATUS_INVALID_PARAMETER }, + { { NULL, (void *)0x01ffffff, 0 } }, + }; + MEM_EXTENDED_PARAMETER params[1]; NTSTATUS status; + unsigned int i; + void *addr1; SIZE_T size;
if (!pNtAllocateVirtualMemoryEx) @@ -291,7 +303,7 @@ static void test_NtAllocateVirtualMemoryEx(void) ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
size = 0; - status = NtFreeVirtualMemory(NtCurrentProcess(), &addr2, &size, MEM_RELEASE); + status = NtFreeVirtualMemory(NtCurrentProcess(), &addr1, &size, MEM_RELEASE); ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status);
/* specifying a count of >0 with NULL parameters should fail */ @@ -322,6 +334,25 @@ static void test_NtAllocateVirtualMemoryEx(void) status = NtFreeVirtualMemory(NtCurrentProcess(), &addr1, &size, MEM_RELEASE); ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status); } + + /* Memory requirements */ + + for (i = 0; i < ARRAY_SIZE(memreq_tests); ++i) + { + addr1 = NULL; + size = 0x10000; + memset(params, 0, sizeof(params)); + params[0].Type = MemExtendedParameterAddressRequirements; + params[0].Pointer = &memreq_tests[i].param; + status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE, PAGE_READWRITE, params, 1); + ok(status == memreq_tests[i].status, "Unexpected status %08lx.\n", status); + if (status == STATUS_SUCCESS) + { + size = 0; + status = NtFreeVirtualMemory(NtCurrentProcess(), &addr1, &size, MEM_RELEASE); + ok(status == STATUS_SUCCESS, "Unexpected status %08lx.\n", status); + } + } }
struct test_stack_size_thread_args diff --git a/include/winnt.h b/include/winnt.h index 7aafbcf0cfe..1007cfbe591 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -788,6 +788,13 @@ typedef struct DECLSPEC_ALIGN(8) MEM_EXTENDED_PARAMETER { } DUMMYUNIONNAME; } MEM_EXTENDED_PARAMETER, *PMEM_EXTENDED_PARAMETER;
+typedef struct _MEM_ADDRESS_REQUIREMENTS +{ + PVOID LowestStartingAddress; + PVOID HighestEndingAddress; + SIZE_T Alignment; +} MEM_ADDRESS_REQUIREMENTS, *PMEM_ADDRESS_REQUIREMENTS; + typedef struct _WIN32_MEMORY_RANGE_ENTRY { PVOID VirtualAddress;