Menu patch breakage

Andreas Mohr andi at rhlx01.fht-esslingen.de
Thu Aug 29 08:17:31 CDT 2002


On Thu, Aug 29, 2002 at 01:03:38PM +0200, Rein Klazes wrote:
> Hi,
> 
> Yesterday's destroymenu patch broke a number of applications, among
> them Forte Agent. Because I don't quite understand the issues yet, I
> have uploaded a +relay,+menu log to
> www.xs4all.nl/~rklazes/temp/ag.log.bz2 if anyone wants to have a look.
ARGL ! ;)

Hah, but I guess I understand it, fortunately ! :-)

The program first creates a window:
0806eae8:Call user32.CreateWindowExA(00000000,005c4183 "ForteAgent:Main",417123b
0 "Agent",1acf0000,80000000,00000000,80000000,00000000,00000000,0000008c,0040000
0,00000000) ret=00598ea1
trace:menu:MENU_GetSysMenu loading system menu, hWnd 10025, hPopupMenu 0000
trace:menu:CreateMenu return 00c8
trace:menu:MENU_GetSysMenu hWnd 10025 (hMenu 00c8)

then it assigns a menu to this window:
trace:menu:SetMenu (10025, 008c);

later it does:
0806eae8:Call window proc 0x406fc3dc (hwnd=00010026,msg=WM_MDISETMENU,wp=0000010
4,lp=0000053c)
trace:menu:GetMenu for 10025 returning 008c
trace:menu:SetMenu (10025, 0104);
0806eae8:Ret  window proc 0x406fc3dc (hwnd=00010026,msg=WM_MDISETMENU,wp=0000010
4,lp=0000053c) retval=0000008c

And since hmenu 0x008c isn't used any more, it does:
0806eae8:Call user32.DestroyMenu(0000008c) ret=004dd671
trace:menu:DestroyMenu (008c)
0806eae8:Ret  user32.DestroyMenu() retval=00000001 ret=004dd671

and thus WIPING OUT the hMenu member of the window, since 0x008c's hWnd
member *still* points to the hWnd now owning the 0x0104 hMenu,
and thus lets DestroyMenu() wipe out the *old*, wrong hWnd's hMenu member !

So either:
a) DestroyMenu should check whether the hMenu's "owner" window still
contains the very same menu handle and set it to 0 in this case *only*
(i.e.: not eliminate "foreign" hMenu values)
or
b) a SetMenu should unregister the hWnd member of the hMenu previously
assigned to the window (i.e.: set hMenu->hWnd to 0).

I'll do some testing to find out which path to take ASAP.
For now, I'd assume that b) is the correct answer.

Thank you very much for this report !

-- 
Microsoft Licensing 6.0: "Pay us now in advance, so that we can own you later."



More information about the wine-devel mailing list