编译这个DLL的时候记住要这样:(否则会失败哦!)
ml /c /coff HookDll.asm
link /section:.bss,S /DLL /subsystem:windows /def:HookDll.def HookDll.obj
---------- 主程序调用 ----------
文件名: GetPsw.asm
-------------------------------
;******************************************************
;程序名称:获取密码框的密码,适用于Win9x/WinMe/Win2000/WinXP
;作者:罗聪
;日期:2002-10-8
;出处:http://www.luocong.com/(老罗的缤纷天地)
;注意事项:如欲转载,请保持本程序的完整,并注明:
;转载自“老罗的缤纷天地”(http://www.luocong.com/)
;******************************************************
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include HookDll.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib HookDll.lib
WndProc proto WORD, WORD, WORD, WORD
.const
IDC_EDIT_OUTPUT equ 3000
WM_MOUSEHOOK equ WM_USER + 6
.data
szDlgName db "lc_dialog", 0
szPsw db 255 dup(0)
.code
main:
invoke GetModuleHandle, NULL
invoke DialogBoxParam, eax, offset szDlgName, 0, WndProc, 0
invoke ExitProcess, eax
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL rect: RECT
.if uMsg == WM_CLOSE
;卸载鼠标钩子:
invoke UninstallHook
invoke EndDialog, hWnd, 0
.elseif uMsg == WM_INITDIALOG
;获得主程序的rect:
invoke GetWindowRect, hWnd, addr rect
;把主程序设置成“始终在最前面”:
invoke SetWindowPos, hWnd, HWND_TOPMOST, rect.left, rect.top, rect.right,
rect.bottom, SWP_SHOWWINDOW
;鼠标钩子函数启动:
invoke InstallHook, hWnd
;处理鼠标钩子函数的消息:
.elseif uMsg == WM_MOUSEHOOK
;获得密码:
invoke GetPsw
;输出:
invoke SetDlgItemText, hWnd, IDC_EDIT_OUTPUT