Modify

Opened 12 years ago

Closed 12 years ago

#2176 closed Bug (Fixed)

DllCallbackRegister crash on x64

Reported by: Melba23 Owned by: trancexx
Milestone: 3.3.9.3 Component: AutoIt
Version: 3.3.9.2 Severity: None
Keywords: Cc:

Description

As requested by trancexx http://www.autoitscript.com/forum/topic/119505-guiframe-udf-melba23-version-24-mar-12/page__view__findpost__p__976627 here is a short reproducer script that crashes when run as x64 under the lastest Beta (3.3.9.2) and does nto in x32:

#include <WinAPI.au3>
OnAutoItExitRegister("On_Exit")

; Store registered Callback handle
Global $hRegCallBack = DllCallbackRegister("_NewWndProc", "lresult", "hwnd;uint;wparam;lparam")
$pProcPointer = DllCallbackGetPtr($hRegCallBack)

; Create a GUI
$hGUI = GUICreate("Test", 500, 500)
GUISetState(@SW_SHOW, $hGUI)

; Create a child
$hGUI_Child = GUICreate("Child", 200, 200, 100, 100, 0x40000000, -1, $hGUI) ;$WS_CHILD
GUICtrlCreateLabel("", 0, 0, 200, 200, -1, 0x01) ; $WS_EX_DLGMODALFRAME
GUICtrlSetCursor(-1, 11)
GUISetState(@SW_SHOW, $hGUI_Child)

; Subclass the child
;Global $pOldWndProc = 0
Global $pOldWndProc = _Child_SubClass($hGUI_Child)
ConsoleWrite($pOldWndProc & @CRLF)
If $pOldWndProc = 0 Then
	MsgBox(0, "Subclass", "Error")
	Exit
EndIf

While 1
	If GUIGetMsg() = -3 Then Exit
WEnd

Func _Child_SubClass($hWnd)

	Local $aRet

    ; Subclass GUI
	If @AutoItX64 Then
		$aRet = DllCall('user32.dll', 'long_ptr', 'SetWindowLongPtrW', 'hwnd', $hWnd, 'int', -4, 'long_ptr', $pProcPointer) ; $GWL_WNDPROC
	Else
		$aRet = DllCall('user32.dll', 'long', 'SetWindowLongW', 'hwnd', $hWnd, 'int', -4, 'long', $pProcPointer) ; $GWL_WNDPROC
	EndIf
	; Check for subclassing error
	If @error Or $aRet[0] = 0 Then Return 0
	; Return success
    Return $aRet[0]

EndFunc   ;==>_Child_SubClass

Func _NewWndProc($hWnd, $iMsg, $wParam, $lParam)

    Return ProcPassMsg($hWnd, $iMsg, $wParam, $lParam)

EndFunc   ;==>_NewWndProc

Func ProcPassMsg($hWnd, $iMsg, $wParam, $lParam)

    Return _WinAPI_CallWindowProc($pOldWndProc, $hWnd, $iMsg, $wParam, $lParam)

EndFunc   ;==>ProcPassMsg

Func On_Exit()

    ; Delete child
	GUIDelete($hGUI_Child)
    ; Free registered Callback handle
    DllCallbackFree($hRegCallBack)

EndFunc   ;==>On_Exit

M23

Attachments (0)

Change History (1)

comment:1 Changed 12 years ago by trancexx

  • Milestone set to 3.3.9.3
  • Owner set to trancexx
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [6896] in version: 3.3.9.3

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain trancexx.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.