http://bugs.winehq.org/show_bug.cgi?id=16911
Summary: WriteProcessMemory() not working for memory protected by X11DRV_DIB_DoProtectDIBSection() Product: Wine Version: 1.1.12 Platform: PC OS/Version: Linux Status: UNCONFIRMED Keywords: patch, source Severity: minor Priority: P2 Component: winex11.drv AssignedTo: wine-bugs@winehq.org ReportedBy: thestig@google.com
Created an attachment (id=18660) --> (http://bugs.winehq.org/attachment.cgi?id=18660) test program
Hi, I have a test case here that works on WinXP but not Wine. I deliberately wrote a standalone test case because I'm not sure which unit test to put it in. It's in fact based off of dlls/kernel32/tests/virtual.c where the other WriteProcessMemory() test is.
In this test case, we call CreateDIBSection() which returns a HBITMAP (hbitmap) and some memory (mem). Next, we call SetDIBits() with hbitmap. We get into X11DRV_SetDIBits(), where it calls X11DRV_DIB_Lock( physBitmap, DIB_Status_GdiMod );.
This marks the memory (mem) as PAGE_NOACCESS, and leaves it in that state as SetDIBts() returns. Normally if the process tries to access it, we get a page fault that's handled by X11DRV_DIB_FaultHandler(), and everything works.
However, when the test code calls WriteProcessMemory(), we talk to wineserver in NtWriteVirtualMemory(). In wine_server_call(), we do send_request(), where writev() tries to read 'mem' and fails with EFAULT. This doesn't trigger X11DRV_DIB_FaultHandler(), and WriteProcessMemory() fails.
http://bugs.winehq.org/show_bug.cgi?id=16911
--- Comment #1 from Lei Zhang thestig@google.com 2009-01-12 18:52:37 --- Created an attachment (id=18661) --> (http://bugs.winehq.org/attachment.cgi?id=18661) proposed patch
Now, I don't completely understand all code involved here, but it seems the simplest way to fix this is to not leave 'mem' with permissions set to PAGE_NOACCESS at the end of X11DRV_SetDIBits().
The attached patch sets the permissions to PAGE_READONLY, which fixes the problem for me. This patch doesn't break any other unit tests in Wine, which tells me it's not obviously wrong, but I'm not sure if it's correct, so comments are welcome.
http://bugs.winehq.org/show_bug.cgi?id=16911
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |FIXED
--- Comment #2 from Alexandre Julliard julliard@winehq.org 2009-01-15 08:52:22 --- Should be fixed by 858a7efdd40e21895bd6b0e6f2954563fc729039.
http://bugs.winehq.org/show_bug.cgi?id=16911
Lei Zhang thestig@google.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|winex11.drv |ntdll
--- Comment #3 from Lei Zhang thestig@google.com 2009-01-15 12:28:05 --- Works for me. Thanks.
http://bugs.winehq.org/show_bug.cgi?id=16911
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #4 from Alexandre Julliard julliard@winehq.org 2009-01-16 10:39:54 --- Closing bugs fixed in 1.1.13.
https://bugs.winehq.org/show_bug.cgi?id=16911
admin@sewer56.dev changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |admin@sewer56.dev