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.