I had a bugreport here: https://bugs.winehq.org/show_bug.cgi?id=56161
This pull req fixes the bug that programs that do VirtualAlloc(placeholder)/VirtualFree(keep placeholder)/MapViewOfFile3(replace placeholder), do not run. Like the dotnet pe loader in .net 7 for example.
It was not clear to me at first, because i didnt notice it on msdn, but the way that Dmitry Timoshkov "hacked" it in https://bugs.winehq.org/show_bug.cgi?id=56122 is actually exactly how it is supposed to happen according to msdn.
From here: https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-m... ![image](/uploads/58614927d38c15d4c23517aa5dc09d77/image.png)
So thanks to Dmitry Timoshkov. If you are interested you could also look into the thing i mentioned in the bug report, that MapViewOfFile3 doesn't round down to 64k, but, i don't think this is a serious problem yet.
From: Felix Münchhalfenjan.felix.muenchhalfen@rwth-aachen.de
--- dlls/ntdll/unix/virtual.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index abe1b4dc4ec..fb4fa6f1439 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -5466,7 +5466,8 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p } #endif
- if ((offset.u.LowPart & mask) || (*addr_ptr && ((UINT_PTR)*addr_ptr & mask))) + if (!(alloc_type & MEM_REPLACE_PLACEHOLDER) && + ((offset.u.LowPart & mask) || (*addr_ptr && ((UINT_PTR)*addr_ptr & mask)))) return STATUS_MAPPED_ALIGNMENT;
if (process != NtCurrentProcess()) @@ -5535,7 +5536,8 @@ NTSTATUS WINAPI NtMapViewOfSectionEx( HANDLE handle, HANDLE process, PVOID *addr } #endif
- if ((offset.u.LowPart & mask) || (*addr_ptr && ((UINT_PTR)*addr_ptr & mask))) + if (!(alloc_type & MEM_REPLACE_PLACEHOLDER) && + ((offset.u.LowPart & mask) || (*addr_ptr && ((UINT_PTR)*addr_ptr & mask)))) return STATUS_MAPPED_ALIGNMENT;
if (process != NtCurrentProcess())
Thank you for the MR. We'll definitely need a test for this, preferably for both the syscall and user wrapper in kernel32.
Alex Henrie (@alexhenrie) commented about dlls/ntdll/unix/virtual.c:
}
#endif
- if ((offset.u.LowPart & mask) || (*addr_ptr && ((UINT_PTR)*addr_ptr & mask)))
- if (!(alloc_type & MEM_REPLACE_PLACEHOLDER) &&
Please don't leave a space at the end of the line. Trailing whitespace causes warnings in Git.
Alex Henrie (@alexhenrie) commented about dlls/ntdll/unix/virtual.c:
}
#endif
- if ((offset.u.LowPart & mask) || (*addr_ptr && ((UINT_PTR)*addr_ptr & mask)))
- if (!(alloc_type & MEM_REPLACE_PLACEHOLDER) &&
Same here