http://bugs.winehq.org/show_bug.cgi?id=12351
--- Comment #1 from Alexandre Julliard julliard@winehq.org 2008-04-04 02:52:18 --- (In reply to comment #0)
--- snip example code ---- MEMORY_BASIC_INFORMATION mbi; DWORD oldProtect;
SetLastError(0xdeadbeef); ok(VirtualQuery( &mbi, &mbi, sizeof(MEMORY_BASIC_INFORMATION)) == sizeof(mbi)); ok(!VirtualProtect( mbi.BaseAddress, mbi.RegionSize, PAGE_GUARD, &oldProtect)); ok(GetLastError() == ERROR_INVALID_PARAMETER); --- snip example code ----
Glibc mprotect() code triggers the segfault.
Actually this is not testing guard pages, it just demonstrates that Wine is less strict about rejecting invalid protection flags. The protection needs to be something like PAGE_READWRITE|PAGE_GUARD, and then the VirtualProtect call will succeed both on Windows and Wine.
The second example works fine for me too, you just have to make the buffer smaller than a page to make sure to hit the last guard page.