local buffer[128]:byte
local buffer1[128]:byte
local rect:rect
.if umsg==wm_close
.if hookflag==true
invoke uninstallhook
.endif
invoke enddialog,hdlg,null
.elseif umsg==wm_initdialog
invoke getwindowrect,hdlg,addr rect
invoke setwindowpos, hdlg, hwnd_topmost, rect.left, rect.top, rect.right, rect.bottom, swp_showwindow
.elseif umsg==wm_mousehook
invoke getdlgitemtext,hdlg,idc_handle,addr buffer1,128
invoke wsprintf,addr buffer,addr template,wparam
invoke lstrcmpi,addr buffer,addr buffer1
.if eax!=0
invoke setdlgitemtext,hdlg,idc_handle,addr buffer
.endif
invoke getdlgitemtext,hdlg,idc_classname,addr buffer1,128
invoke getclassname,wparam,addr buffer,128
invoke lstrcmpi,addr buffer,addr buffer1
.if eax!=0
invoke setdlgitemtext,hdlg,idc_classname,addr buffer
.endif
invoke getdlgitemtext,hdlg,idc_wndproc,addr buffer1,128
invoke getclasslong,wparam,gcl_wndproc
invoke wsprintf,addr buffer,addr template,eax
invoke lstrcmpi,addr buffer,addr buffer1
.if eax!=0
invoke setdlgitemtext,hdlg,idc_wndproc,addr buffer
.endif
.elseif umsg==wm_command
.if lparam!=0
mov eax,wparam
mov edx,eax
shr edx,16
.if dx==bn_clicked
.if ax==idc_exit
invoke sendmessage,hdlg,wm_close,0,0
.else
.if hookflag==false
invoke installhook,hdlg
.if eax!=null
mov hookflag,true
invoke setdlgitemtext,hdlg,idc_hook,addr unhooktext
.endif
.else
invoke uninstallhook