iczelion tut24[5]

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

本文简介:选择自 jimgreen 的 blog

                        invoke setdlgitemtext,hdlg,idc_hook,addr hooktext
                        mov hookflag,false
                        invoke setdlgitemtext,hdlg,idc_classname,null
                        invoke setdlgitemtext,hdlg,idc_handle,null
                        invoke setdlgitemtext,hdlg,idc_wndproc,null
                    .endif
                .endif
            .endif
        .endif
    .else
        mov eax,false
        ret
    .endif
    mov eax,true
    ret
dlgfunc endp

end start

;----------------------------------------------------- this is the source code of the dll --------------------------------------
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib

.const
wm_mousehook equ wm_user+6

.data
hinstance dd 0

.data?
hhook dd ?
hwnd dd ?

.code
dllentry proc hinst:hinstance, reason:dword, reserved1:dword
    .if reason==dll_process_attach
        push hinst
        pop hinstance
    .endif
    mov  eax,true
    ret
dllentry endp

mouseproc proc ncode:dword,wparam:dword,lparam:dword
    invoke callnexthookex,hhook,ncode,wparam,lparam
    mov edx,lparam
    assume edx:ptr mousehookstruct
    invoke windowfrompoint,[edx].pt.x,[edx].pt.y
    invoke postmessage,hwnd,wm_mousehook,eax,0
    assume edx:nothing
    xor eax,eax
    ret
mouseproc endp

installhook proc hwnd:dword
    push hwnd
    pop hwnd
    invoke setwindowshookex,wh_mouse,addr mouseproc,hinstance,null
    mov hhook,eax
    ret
installhook endp

uninstallhook proc
    invoke unhookwindowshookex,hhook
    ret
uninstallhook endp

end dllentry

;---------------------------------------------- this is the makefile of the dll ----------------------------------------------

name=mousehook
$(name).dll: $(name).obj
        link /section:.bss,s  /dll /def:$(name).def /subsystem:windows /libpath:c:\masm\lib $(name).obj
$(name).obj: $(name).asm
        ml /c /coff /cp $(name).asm
 

analysis:

the example will display a dialog box with three edit controls that will be filled with the class name, window handle and the address of the window procedure associated with the window under the mouse cursor. there are two buttons, hook and exit. when you press the hook button, the program hooks the mouse input and the text on the button changes to unhook. when you move the mouse cursor over a window, the info about that window will be displayed in the main window of the example. when you press unhook button, the program removes the mouse hook.

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

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

go top