iczelion tut24[7]

[入库:2005年8月19日] [更新:2007年3月24日]

本文简介:选择自 jimgreen 的 blog

mouseproc endp

the first thing it does is to call callnexthookex to give the other hooks the chance to process the mouse event. after that, it calls windowfrompoint function to retrieve the handle of the window at the specified screen coordinate. note that we use the point structure in the mousehookstruct structure pointed to by lparam as the current mouse coordinate. after that we send the window handle to the main program via postmessage with wm_mousehook message. one thing you should remember is that: you should not use sendmessage inside the hook procedure, it can cause message deadlock. postmessage is recommended. the mousehookstruct structure is defined below:

mousehookstruct struct dword
  pt            point <>
  hwnd          dword      ?
  whittestcode  dword      ?
  dwextrainfo   dword      ?
mousehookstruct ends
 

  • pt is the current screen coordinate of the mouse cursor
  • hwnd is the handle of the window that will receive the mouse message. it's usually the window under the mouse cursor but not always. if a window calls setcapture, the mouse input will be redirected to that window instead. because of this reason, i don't use the hwnd member of this structure but choose to call windowfrompoint instead.
  • whittestcode specifies the hit-test value. the hit-test value gives more information about the current mouse cursor position. it specifies on what part of window the mouse cursor is. for complete list, check your win32 api reference under wm_nchittest message.
  • dwextrainfo contains the extra information associated with the message. normally this value is set by calling mouse_event and retrieved by calling getmessageextrainfo.
when the main window receives wm_mousehook message, it uses the window handle in wparam to retrieve the information about the window.

    .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

to avoid flickers, we check the text already in the edit controls and the text we will put into them if they are identical. if they are, we skip them.
we retrieve the class name by calling getclassname, the address of the window procedure by calling getclasslong with gcl_wndproc and then format them into strings and put them into the appropriate edit controls.

                        invoke uninstallhook
                        invoke setdlgitemtext,hdlg,idc_hook,addr hooktext
                        mov hookflag,false

本文关键:iczelion asm
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top