Signed-off-by: Myah Caron qsniyg@protonmail.com --- This patchset doesn't yet fix anything as far as I know, I only encountered it while debugging a program that crashed soon after initializing mimalloc. While it didn't fix the program in question, I thought I might as well send it in. Considering the apparent trend of games requiring newer Windows APIs without supporting fallbacks, it may be rendered useful soon...
dlls/ntdll/ntdll.spec | 2 ++ dlls/ntdll/tests/virtual.c | 21 +++++++++++++++++++++ dlls/ntdll/unix/virtual.c | 15 +++++++++++++++ include/winternl.h | 1 + 4 files changed, 39 insertions(+)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index ca427c46c04..dbd2eab1fa1 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -141,6 +141,7 @@ # @ stub NtAllocateUserPhysicalPages @ stdcall -syscall NtAllocateUuids(ptr ptr ptr ptr) @ stdcall -syscall NtAllocateVirtualMemory(long ptr long ptr long long) +@ stdcall -syscall NtAllocateVirtualMemoryEx(long ptr ptr long long ptr long) @ stdcall -syscall NtAreMappedFilesTheSame(ptr ptr) @ stdcall -syscall NtAssignProcessToJobObject(long long) @ stub NtCallbackReturn @@ -1146,6 +1147,7 @@ # @ stub ZwAllocateUserPhysicalPages @ stdcall -private -syscall ZwAllocateUuids(ptr ptr ptr ptr) NtAllocateUuids @ stdcall -private -syscall ZwAllocateVirtualMemory(long ptr long ptr long long) NtAllocateVirtualMemory +@ stdcall -private -syscall ZwAllocateVirtualMemoryEx(long ptr ptr long long ptr long) NtAllocateVirtualMemoryEx @ stdcall -private -syscall ZwAreMappedFilesTheSame(ptr ptr) NtAreMappedFilesTheSame @ stdcall -private -syscall ZwAssignProcessToJobObject(long long) NtAssignProcessToJobObject @ stub ZwCallbackReturn diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index 7049f234a9f..9c2cf824018 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -34,6 +34,8 @@ static NTSTATUS (WINAPI *pRtlCreateUserStack)(SIZE_T, SIZE_T, ULONG, SIZE_T, SIZ static ULONG64 (WINAPI *pRtlGetEnabledExtendedFeatures)(ULONG64); static NTSTATUS (WINAPI *pRtlFreeUserStack)(void *); static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL); +static NTSTATUS (WINAPI *pNtAllocateVirtualMemoryEx)(HANDLE, PVOID *, SIZE_T *, ULONG, ULONG, + MEM_EXTENDED_PARAMETER *, ULONG); static const BOOL is_win64 = sizeof(void*) != sizeof(int);
static SYSTEM_BASIC_INFORMATION sbi; @@ -215,6 +217,24 @@ static void test_NtAllocateVirtualMemory(void) size = 0; status = NtFreeVirtualMemory(NtCurrentProcess(), &addr1, &size, MEM_RELEASE); ok(status == STATUS_SUCCESS, "NtFreeVirtualMemory failed\n"); + + if (!pNtAllocateVirtualMemoryEx) + { + win_skip("NtAllocateVirtualMemoryEx() is missing\n"); + return; + } + + /* simple allocation should succeed */ + size = 0x1000; + addr1 = NULL; + status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_COMMIT, + PAGE_EXECUTE_READWRITE, NULL, 0); + ok(status == STATUS_SUCCESS, "NtAllocateVirtualMemoryEx returned %08x\n", status); + + /* specifying a count of >0 with NULL parameters should fail */ + status = pNtAllocateVirtualMemoryEx(NtCurrentProcess(), &addr1, &size, MEM_RESERVE | MEM_COMMIT, + PAGE_EXECUTE_READWRITE, NULL, 1); + ok(status == STATUS_INVALID_PARAMETER, "NtAllocateVirtualMemoryEx returned %08x\n", status); }
static void test_RtlCreateUserStack(void) @@ -648,6 +668,7 @@ START_TEST(virtual) pRtlCreateUserStack = (void *)GetProcAddress(mod, "RtlCreateUserStack"); pRtlFreeUserStack = (void *)GetProcAddress(mod, "RtlFreeUserStack"); pRtlGetEnabledExtendedFeatures = (void *)GetProcAddress(mod, "RtlGetEnabledExtendedFeatures"); + pNtAllocateVirtualMemoryEx = (void *)GetProcAddress(mod, "NtAllocateVirtualMemoryEx");
NtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), NULL); trace("system page size %#x\n", sbi.PageSize); diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index d79e3de662e..614159b7d90 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -3452,6 +3452,21 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG_PTR z return status; }
+/*********************************************************************** + * NtAllocateVirtualMemoryEx (NTDLL.@) + * ZwAllocateVirtualMemoryEx (NTDLL.@) + */ +NTSTATUS WINAPI NtAllocateVirtualMemoryEx( HANDLE process, PVOID *ret, SIZE_T *size_ptr, ULONG type, + ULONG protect, MEM_EXTENDED_PARAMETER *parameters, + ULONG count ) +{ + if (count && !parameters) return STATUS_INVALID_PARAMETER; + + if (count) FIXME( "Ignoring %d extended parameters %p\n", count, parameters ); + + return NtAllocateVirtualMemory( process, ret, 0, size_ptr, type, protect ); +} +
/*********************************************************************** * NtFreeVirtualMemory (NTDLL.@) diff --git a/include/winternl.h b/include/winternl.h index 89ea58c2d93..fbce63655ba 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -3020,6 +3020,7 @@ NTSYSAPI NTSTATUS WINAPI NtAlertThread(HANDLE ThreadHandle); NTSYSAPI NTSTATUS WINAPI NtAllocateLocallyUniqueId(PLUID lpLuid); NTSYSAPI NTSTATUS WINAPI NtAllocateUuids(PULARGE_INTEGER,PULONG,PULONG,PUCHAR); NTSYSAPI NTSTATUS WINAPI NtAllocateVirtualMemory(HANDLE,PVOID*,ULONG_PTR,SIZE_T*,ULONG,ULONG); +NTSYSAPI NTSTATUS WINAPI NtAllocateVirtualMemoryEx(HANDLE,PVOID*,SIZE_T*,ULONG,ULONG,MEM_EXTENDED_PARAMETER*,ULONG); NTSYSAPI NTSTATUS WINAPI NtAreMappedFilesTheSame(PVOID,PVOID); NTSYSAPI NTSTATUS WINAPI NtAssignProcessToJobObject(HANDLE,HANDLE); NTSYSAPI NTSTATUS WINAPI NtCallbackReturn(PVOID,ULONG,NTSTATUS); -- 2.28.0
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=80526
Your paranoid android.
=== debiant (32 bit report) ===
ntdll: change.c:241: Test failed: should be ready change.c:247: Test failed: action wrong change.c:277: Test failed: should be ready change.c:280: Test failed: info not set change.c:293: Test failed: status set too soon change.c:294: Test failed: info set too soon