能力值:
( LV3,RANK:30 )
|
-
-
2 楼
另外把正在开发的1.3版中的一个小功能放出来,可以作个小工具用
|
能力值:
( LV3,RANK:30 )
|
-
-
3 楼
;**************************************************************************************************************
;关于钩子的应用,钩子实际上不是什么复杂的东西,也许就难在其中较多的参数调用。
;下面是一个键盘钩子,这个钩子实现的功能是:
; 检测主调用程序输入的2个键值,看2个键组成的组合键是否同时按下,若同时按下,则修改结果参数为1,否则为0.
; 主程序通过检测结果参数,就可以断定是否同时按下了这2个键,从而作出相应的动作。
;==============================================================================================================
; WRITTEN BY LIYU
; EMAIL:LYWINU@163.COM
; 转载时请保留此信息
;***************************************************************************************************************
.386
.MODEL FLAT,STDCALL
OPTION CASEMAP:NONE
INCLUDE windows.inc
INCLUDE kernel32.inc
INCLUDELIB kernel32.lib
INCLUDE user32.inc
INCLUDELIB user32.lib
_KeyBHookProc PROTO ,:DWORD,:DWORD,:DWORD
.data
.data?
hKeyBHook dd ?
hWnd dd ?
hCWnd dd ?
hSelWnd dd ?
hInstance dd ?
dwTestCtl dd ?
dwTestChar dd ?
dwCtlScan dd ?
dwCharScan dd ?
dwResult dd ?
.CODE
_DllEntry proc, hInst,dwReason,dwReserved
mov eax,dwReason
push hInst
pop hInstance
mov eax,TRUE
ret
_DllEntry endp
_SetKeyBHookProc proc, _lpdwResult,_dwCtlScan,_dwCharScan
push _dwCtlScan
pop dwCtlScan
push _dwCharScan
pop dwCharScan
push _lpdwResult
pop dwResult
xor eax,eax
mov dwTestCtl,eax
mov dwTestChar,eax
mov eax,dwResult
xor ebx,ebx
mov [eax],ebx
invoke SetWindowsHookEx,WH_KEYBOARD,addr _KeyBHookProc,hInstance,0
mov hKeyBHook,eax
ret
_SetKeyBHookProc endp
_UnhookKeyBHookProc proc
invoke UnhookWindowsHookEx,hKeyBHook
ret
_UnhookKeyBHookProc endp
_KeyBHookProc proc ,_dwCode,_wParam,_lParam
mov eax,_dwCode
.if eax == HC_ACTION
mov eax,_lParam
mov ebx,eax
shr ebx,16
and ebx,000ffh
test eax,80000000h
je @f
.if ebx == dwCtlScan
inc dwTestCtl
mov eax,dwTestCtl
.if eax == dwTestChar
mov eax,_lParam
test eax,040000000h
jne @f
mov eax,dwResult
mov eax,[eax]
mov eax,1
invoke UnhookWindowsHookEx,hKeyBHook
ret
.endif
.elseif ebx == dwCharScan
inc dwTestChar
mov eax,dwTestCtl
.if eax == dwTestChar
mov eax,_lParam
test eax,040000000h
jne @f
mov eax,dwResult
mov eax,[eax]
mov eax,1
invoke UnhookWindowsHookEx,hKeyBHook
ret
.endif
.else
xor eax,eax
mov dwTestCtl,eax
mov dwTestChar,eax
.endif
.endif
@@:
invoke CallNextHookEx,hKeyBHook,_dwCode,_wParam,_lParam
ret
_KeyBHookProc endp
END _DllEntry
|