http://bugs.winehq.org/show_bug.cgi?id=12783
--- Comment #9 from Albert Lee trisk+winehq@acm.jhu.edu 2008-06-10 17:28:46 --- (In reply to comment #8)
(In reply to comment #7)
The particular case addr = (void *)0x7ffe0000; size = 0x10000; NtAllocateVirtualMemory( NtCurrentProcess(), &addr, 0, &size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE ); user_shared_data = addr; probably should have some way to say MAP_FIXED, but I cannot find such a way. [Hint: valgrind presents such a kernel that ignores the first argument to mmap() unless MAP_FIXED.]
There is no reason to check for this particular allocation unless to die immediately if it fails. It's the special data structure [Shared User Data] present on all NT+ windows at the constant address. If your kernel can not honor this, then it's broken and have to be fixed. Or listed as incompatible with Wine. This area is critical to most copy-protection systems. Also lots of programs make a use of this data structure.
The semantics of mmap are well-defined and require applications to not assume the segment has been mapped at the requested address unless MAP_FIXED is set.
For MEM_RESERVE allocations map_view in ntdll is called, if it's in a "reserved" area mmap is called with MAP_FIXED, otherwise with 0. map_view always returns an error if the returned address is not the same as the requested one.