标题:钩子键盘消息的保存
只看楼主
逆鳞雪狮
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-10-12
结帖率:100%
已结贴  问题点数:20 回复次数:1 
钩子键盘消息的保存
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Sample code for < Win32ASM Programming 4th Edition>
; by 罗云彬, luoyunbin@
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Main.asm
; 键盘钩子演示程序的主程序,调用 dll 装载键盘钩子
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 使用 nmake 或下列命令进行编译和链接:
; ml /c /coff Main.asm
; rc Main.rc
; Link  /subsystem:windows Main.obj Main.res
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        .386
        .model flat, stdcall
        option casemap :none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Include 文件定义
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include        windows.inc
include        user32.inc
includelib    user32.lib
include        kernel32.inc
includelib    kernel32.lib
include        Hookdll.inc
includelib    Hookdll.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Equ 等值定义
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ICO_MAIN    equ    1000
DLG_MAIN    equ    1000
IDC_TEXT    equ    1001
WM_HOOK        equ    WM_USER + 100h
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 代码段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

  .data
szaa db '8.txt',0
da  dd 0
da1 dd 0

        .code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_ProcDlgMain    proc    uses ebx edi esi hWnd,wMsg,wParam,lParam
        local    @dwTemp
        
        local  @szcc [1000]:byte
        mov    eax,wMsg
;********************************************************************
        .if    eax ==    WM_CLOSE
            invoke    UninstallHook
            invoke    EndDialog,hWnd,NULL
;********************************************************************
        .elseif    eax ==    WM_INITDIALOG
            invoke    InstallHook,hWnd,WM_HOOK
            
            
               mov da,eax            
            .if    ! eax
                invoke    EndDialog,hWnd,NULL
               
            .endif

;********************************************************************
        .elseif    eax ==    WM_HOOK
            mov    eax,wParam
            .if    al == 0dh
                mov    eax,0a0dh
            .endif
            mov    @dwTemp,eax
            invoke    SendDlgItemMessage,hWnd,IDC_TEXT,EM_REPLACESEL,0,addr @dwTemp
            invoke    CreateFile,addr szaa,GENERIC_WRITE,FILE_SHARE_READ,\
               0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0
            
            mov da1,eax
            invoke WriteFile,da1,addr @dwTemp ,sizeof @dwTemp,addr @szcc,0
            invoke FlushFileBuffers,da1
        .else
            mov    eax,FALSE
            ret
        .endif
        mov    eax,TRUE
        ret

_ProcDlgMain    endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
        invoke    GetModuleHandle,NULL
        invoke    DialogBoxParam,eax,DLG_MAIN,NULL,offset _ProcDlgMain,NULL
        invoke    ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
        end    start

我想把键盘钩子勾到消息保存在自己建的文件里面,可是文件正常建立了,就是里面没有内容,
搜索更多相关主题的帖子: windows 主程序 键盘 
2015-10-12 23:15
hu9jj
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:红土地
等 级:贵宾
威 望:396
帖 子:11713
专家分:43267
注 册:2006-5-13
得分:20 
HK啊

活到老,学到老! http://www. E-mail:hu-jj@
2015-10-13 07:39



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-458132-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018202 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved