http://bugs.winehq.org/show_bug.cgi?id=19134
Summary: Wine GetSystemMenu returns nil window handle at inappropriate times Product: Wine Version: 1.0.1 Platform: All OS/Version: All Status: UNCONFIRMED Severity: normal Priority: P2 Component: user32 AssignedTo: wine-bugs@winehq.org ReportedBy: brent@mbari.org
Created an attachment (id=22098) --> (http://bugs.winehq.org/attachment.cgi?id=22098) Patch against Wine version 1.0.1 to fix this bug
GetSystemMenu() is always supposed to return a valid HMENU handle, but the logic in Wine's version would return nil in some cases where windows would return a valid HMENU. Specifically, when the relevant windows dwStyle mask did not include WS_SYSMENU, wine would return nil, but windows would still return a valid HMENU.
I've been trying to run this app in Wine for many years:
http://www.quadravox.com/AQ430.htm
The version I use is 2.0.6.9, but I strongly suspect the problem will show up in their current versions as well. You may download a 30-day trial version to verify the bug. However, I think the logic bug in GetSystemMenu is pretty obvious.
After a few hours of poking around with assembly code in the Wine debugger, it became clear that the Quadravox app was getting a nil HMENU from GetSystemMenu even though its bRevert parameter was false. Windows on-line docs state that GetSystemMenu() should return a nil HMENU only when reverting to the standard system menu. Real Windows apparently does not check whether the current window's dwStyle bits are set appropriately, where the wine version requires this. That's the easiest explanation for the behavior I observed...
To replicate: create a project in the Quadravox IDE try to build it.
Aborts with invalid read from address 0x4 after GetSystemMenu() returns the bogus nil handle.
The attached patch fixes the problem for me. Others should confirm this...