Shoutbox

[SOLVED] ChooseFontW causes Messenger crash after closing window - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [SOLVED] ChooseFontW causes Messenger crash after closing window (/showthread.php?tid=82226)

[SOLVED] ChooseFontW causes Messenger crash after closing window by Matti on 03-09-2008 at 12:03 PM

Hello again!

It seems like I've stumbled on some kind of scripting problem once again. This time, it's much more problematic than [?] Weirdness. Evolved. or [?] Trying to get into the advanced stuff...

Here's what's happening:

  1. The user opens the script's window.
  2. The user clicks a button.
  3. The script calls ChooseFontW to open a font dialog.
    • If the result of this call is zero (meaning that the user clicked Cancel in the dialog), the script stops here.
    • If the result of this call is nonzero (meaning that the user clicked OK), the script continues.
  4. The script reads the selected font name from the result structure and sets the button text to this name.
  5. The user closes the script window.
  6. Messenger crashes.
There really is nothing I can do to prevent this crash. The structures are cleared, nothing else is done, it doesn't crash when the user clicks Cancel or doesn't click the "Choose a font" button at all... and I have no clue why or how this is happening.

Attached is a sample script which proves this behavior. Feel free to mess around with it, do whatever you want to test this.

Please, help me if you can! :)

System information:
Windows Vista Ultimate x64 (6.0.6000)
Windows Live Messenger 8.5.1018
Messenger Plus! Live 4.50.0.317 (private BETA received from Patchou to test new scripting methods)
RE: [?] ChooseFontW causes Messenger crash after closing window by matty on 03-09-2008 at 02:11 PM

1704 08/03/09 10:09:49| CChooseFont - created
1704 08/03/09 10:09:53| ERROR: CRT - HEAP CORRUPTION DETECTED: after Normal block (#43859) at 0x022D8AE0.
                        CRT detected that the application wrote to memory after end of heap buffer.
1704 08/03/09 10:09:53| CDebug::GenerateDumpFile has been called. Exception: 0xc0000005
1704 08/03/09 10:09:53| Minidump is being created...
1704 08/03/09 10:09:54| Minidump creation complete (0309_100953)
1704 08/03/09 10:09:54| CDebug::GenerateDumpFile has been called. Exception: 0xc0000005
1704 08/03/09 10:09:54| Minidump is being created...
1704 08/03/09 10:09:55| Minidump creation complete (0309_100954)


Appears to be the wrong structure size, I tried LF of 92 and it still did it so...


RE: [?] ChooseFontW causes Messenger crash after closing window by CookieRevised on 03-09-2008 at 03:22 PM

It doesnt crash here. It works nicely.

0510 08/03/09 16:24:09| A custom script window is being created
0510 08/03/09 16:24:09| CInterfaceWindow - Window creation: WndTest
0510 08/03/09 16:24:09| CScriptObjectCustomWnd created. This: 02213e30
0510 08/03/09 16:24:11| CChooseFont - created
0510 08/03/09 16:24:28| CInterfaceWindow - Window destruction: WndTest



HOWEVER, as Matty already stated, the LOGFONT structure's length must be 92 !

code:
var LF = Interop.Allocate(92); //must be 92, see MSDN docs!!!!

RE: [?] ChooseFontW causes Messenger crash after closing window by Matti on 03-09-2008 at 04:17 PM

Seems like that size thing fixed it. Thank you! :D