24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 656  |  回复: 6
当前主题已经存档。
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

magic7004

金虫 (职业作家)

[交流] 【原创】关于Low Level Keyboard Hook,万恶的SDK啊~~

今天要做点事情,需要屏蔽Win键,于是想到用WH_KEYBOARD_LL,随便看了下VS6.0自带的MSDN里LowLevelKeyboardProc的描述:
The LowLevelKeyboardProc hook procedure is an application-defined or library-defined callback function used with the SetWindowsHookEx function. The system calls this function every time a new keyboard input event is about to be posted into a thread input queue. The keyboard input can come from the local keyboard driver or from calls to thekeybd_event function. If the input comes from a call to keybd_event, the input was "injected".

于是写了类似下面的代码:
void f()
{
    HHOOK hHook = NULL;
    HANDLE hThread = NULL;
  __try
  {
       hHOOK = SetWindowHookExhInstance,WH_KEYBOARD_LL,LowLevelKeyboardProc,0);
      if(NULL == hHook) __leave;
      hThread=(HANDLE) _beginthread(.......);  
      if ((HANDLE)1 == hThread) __leave;
      WaitForSingleObject(hThread);
  }
  __finally
{
      if (NULL != hThread) CloseHandle(hThread);
      if (NULL != hHook) UnhookWindowsHookEx(hHook);
  }
}

结果发现,安装的HOOK不起作用,研究了很久也不明白怎么回事,正在郁闷中,突然看到Win2K3的SDK Documentation里对LowLevelKeyboardProc的描述是:
The LowLevelKeyboardProc hook procedure is an application-defined or library-defined callback function used with the SetWindowsHookEx function. The system calls this function every time a new keyboard input event is about to be posted into a thread input queue. The keyboard input can come from the local keyboard driver or from calls to the keybd_event function. If the input comes from a call to keybd_event, the input was "injected". However, the WH_KEYBOARD_LL hook is not injected into another process. Instead, the context switches back to the process that installed the hook and it is called in its original context. Then the context switches back to the application that generated the event.   

天啊,平白无故的多出来一段,真是万恶的SDK啊~~!
回复此楼

» 猜你喜欢

流氓不可怕,可怕的是流氓有文化,有文化又BH的流氓无敌~~!
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

magic7004

金虫 (职业作家)

★ ★
wangen994(金币+2,VIP+0):欢迎常来程序软件版 9-10 20:35
Ctr+Alt+Del是Winlogon的热键,WinlogoN是SYSTEM的进程,它不在当前用户的会话中,机制不一样的啦。
流氓不可怕,可怕的是流氓有文化,有文化又BH的流氓无敌~~!
3楼2009-09-10 19:48:13
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 7 个回答

木叶清风

木虫 (正式写手)

★ ★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
wangen994(金币+2,VIP+0):辛苦了,加油 9-10 20:35
单独屏蔽一个键都还好,屏蔽ctr+alt+del比较难
www.cvdelver.com
2楼2009-09-10 18:54:17
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

木叶清风

木虫 (正式写手)


小木虫(金币+0.5):给个红包,谢谢回帖交流
引用回帖:
Originally posted by magic7004 at 2009-9-10 19:48:
Ctr+Alt+Del是Winlogon的热键,WinlogoN是SYSTEM的进程,它不在当前用户的会话中,机制不一样的啦。

呵呵,是呀,我大二的时候帮老师做项目为了屏蔽这个组合键弄了好久才屏蔽掉
www.cvdelver.com
4楼2009-09-10 21:36:48
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

magic7004

金虫 (职业作家)

引用回帖:
Originally posted by 木叶清风 at 2009-9-10 21:36:

呵呵,是呀,我大二的时候帮老师做项目为了屏蔽这个组合键弄了好久才屏蔽掉

传说HOOK WINLOGON中的MSGINA.DLL中的某个API就解决问题了。
用CreateRemoteThread注入。
准备明天玩玩看。
流氓不可怕,可怕的是流氓有文化,有文化又BH的流氓无敌~~!
5楼2009-09-11 00:04:32
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 085701求调剂初试286分 +4 secret0328 2026-03-28 4/200 2026-03-28 21:09 by 15366876211
[考研] 315求调剂 +4 akie... 2026-03-28 5/250 2026-03-28 21:05 by zhq0425
[考研] 295材料工程专硕求调剂 +7 1428151015 2026-03-27 7/350 2026-03-28 19:58 by S240
[考研] 调剂求院校招收 +4 鹤鲸鸽 2026-03-28 4/200 2026-03-28 13:38 by 唐沐儿
[考研] 311求调剂 +9 lin0039 2026-03-26 9/450 2026-03-28 13:05 by 唐沐儿
[考研] 286求调剂 +12 PolarBear11 2026-03-26 12/600 2026-03-28 12:14 by zllcz
[考研] 308求调剂 +7 墨墨漠 2026-03-27 7/350 2026-03-28 07:43 by 热情沙漠
[考研] 一志愿 西北大学 总分282 英语一62 求调剂 +7 18419759900 2026-03-25 8/400 2026-03-27 16:38 by 18419759900
[考研] 安徽大学专硕生物与医药专业(086000)324分,英语已过四六级,六级521,求调剂 +4 美味可乐鸡翅 2026-03-26 4/200 2026-03-27 15:27 by 星空星月
[考研] 333求调剂 +3 question挽风 2026-03-23 3/150 2026-03-27 11:29 by 不吃魚的貓
[考研] 081200-11408-276学硕求调剂 +3 崔wj 2026-03-26 3/150 2026-03-26 19:57 by nihaoar
[考研] 材料调剂 5+4 想要一壶桃花水 2026-03-25 10/500 2026-03-26 19:56 by 不吃魚的貓
[考研] 总分322求生物学/生化与分子/生物信息学相关调剂 +5 星沉uu 2026-03-26 6/300 2026-03-26 19:02 by macy2011
[考研] 085601求调剂总分293英一数二 +4 钢铁大炮 2026-03-24 4/200 2026-03-26 16:28 by dick_runner
[考研] 求b区院校调剂 +4 周56 2026-03-24 5/250 2026-03-25 17:12 by yishunmin
[考研] 各位老师您好:本人初试372分 +5 jj涌77 2026-03-25 6/300 2026-03-25 14:15 by mapenggao
[考博] 26申博自荐 +3 whh869393 2026-03-24 3/150 2026-03-24 09:55 by 21018060
[考研] 070300,一志愿北航320求调剂 +3 Jerry0216 2026-03-22 5/250 2026-03-23 09:16 by 。。堂堂
[考研] 石河子大学(211、双一流)硕博研究生长期招生公告 +3 李子目 2026-03-22 3/150 2026-03-22 21:01 by 怎么释怀
[考研] 306求调剂 +5 来好运来来来 2026-03-22 5/250 2026-03-22 16:17 by BruceLiu320
信息提示
请填处理意见