Уроки Iczelion'а



         

Урок 24. Windows-хуки - часть 6


.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

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

;----------------------------------------------------- ; Это исходный код 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




Содержание  Назад  Вперед