钩子的问题

lght 2010-06-17 07:37:08
翻了MSDN,上面说可以阻止消息传递给目标窗口,这个怎么弄?

还说可以修改消息,我拦截了WM_SETTEXT,修改了消息中的窗口内容的那个参数,显示出来的还是原来的文字,这个怎么改?
...全文
79 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
husion01 2010-06-19
  • 打赏
  • 举报
回复
mark
cnzdgs 2010-06-19
  • 打赏
  • 举报
回复
在你贴出的链接的中间部分,“Types of Hooks”下面:
WH_CALLWNDPROC
Windows calls this hook whenever the Windows SendMessage function is called. The filter functions receive a hook code from Windows indicating whether the message was sent from the current thread and receive a pointer to a structure containing the actual message.

The CWPSTRUCT structure has the following form:

Copytypedef struct tagCWPSTRUCT {
LPARAM lParam;
WPARAM wParam;
DWORD message;
HWND hwnd;
} CWPSTRUCT, *PCWPSTRUCT, NEAR *NPCWPSTRUCT, FAR *LPCWPSTRUCT;

Filters can process the message, but cannot modify the message (this was possible in 16-bit Windows). The message is sent to the Windows function for which it was intended. This hook is a significant drain on system performance, especially when it is installed as a systemwide hook, so use it only as a development or debugging tool.
天火 2010-06-18
  • 打赏
  • 举报
回复
有意思,顶一下。
Mit1208 2010-06-18
  • 打赏
  • 举报
回复
嘿..他感觉你好欺负.
lght 2010-06-18
  • 打赏
  • 举报
回复
Hooks provide powerful capabilities for Windows-based applications. These applications can use hooks to:

Process or modify all messages meant for all the dialog boxes, message boxes, scroll bars, or menus for an application (WH_MSGFILTER).
Process or modify all messages meant for all the dialog boxes, message boxes, scroll bars, or menus for the system (WH_SYSMSGFILTER).
Process or modify all messages (of any type) for the system whenever a GetMessage or a PeekMessage function is called (WH_GETMESSAGE).
Process or modify all messages (of any type) whenever a SendMessage function is called (WH_CALLWNDPROC).
Record or play back keyboard and mouse events (WH_JOURNALRECORD, WH_JOURNALPLAYBACK).
Process, modify, or remove keyboard events (WH_KEYBOARD).
Process, modify, or discard mouse events (WH_MOUSE).
Respond to certain system actions, making it possible to develop computer-based training (CBT) for applications (WH_CBT).
Prevent another filter from being called (WH_DEBUG).

http://msdn.microsoft.com/en-us/library/ms997537.aspx
难道MSDN忽悠我?
cnzdgs 2010-06-17
  • 打赏
  • 举报
回复
WH_GETMESSAGE可以修改消息,WH_CALLWNDPROC不能修改,通过SendMessage发送的消息都不经过WH_GETMESSAGE,所以都不能修改。
可以利用钩子将代码注入到目标进程,再通过用SetWindowLong替换窗口的WNDPROC,在自己的窗口函数中修改消息。
iqyely 2010-06-17
  • 打赏
  • 举报
回复
学习下。

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧