AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sub-classed window + WinGetClass = Access Violation

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
Lexikos



Joined: 17 Oct 2006
Posts: 2364
Location: Australia, Qld

PostPosted: Sun Mar 23, 2008 10:41 am    Post subject: Sub-classed window + WinGetClass = Access Violation Reply with quote

AutoHotkey v1.0.47.06

WinGetClass causes an access violation if one of the script's windows is sub-classed by the script.
Code:
Gui, +LastFound
Gui, Show, W100 H100
WindowProcOld := DllCall("SetWindowLong", "uint", WinExist(), "int", -4
                            , "int", RegisterCallback("WindowProc"))

WinGetClass, class, Window title required.

WindowProc(hwnd, uMsg, wParam, lParam) {
    global WindowProcOld
    Critical
    ; Contents not important.
    return DllCall("CallWindowProc", "uint", WindowProcOld
                    , "uint", hwnd, "uint", uMsg, "uint", wParam, "uint", lParam)
}

Quote:
Unhandled exception at 0x00551f56 in AutoHotkey.exe: 0xC0000005: Access violation reading location 0x0000000f.

This occurs because WM_GETTEXT is sent to the GUI, triggering the window procedure. The script callback then executes and invalidates sArgVar[0], which WinGetClass attempts to dereference.

For details, see: Here comes the Drain Blamage again.... (Thanks to TodWulff for bringing this issue to my attention.)

Solution:
WinGetTitle resolves the OUTPUT_VAR (*sArgVar) macro once, before searching for the window. I suggest the same be done for WinGetClass.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group