[英]Changing string after hooking WM_SETTEXT
I have setup a hook on WM_SETTEXT message using WH_CALLWNDPROC. 我已经使用WH_CALLWNDPROC在WM_SETTEXT消息上设置了一个钩子。
In hook procedure 挂机程序
CWPSTRUCT* info = (CWPSTRUCT*) lParam;
wchar_t *wsz = NULL;
switch(info->message)
{
case WM_SETTEXT:
wsz = (wchar_t *) info->lParam;
//info->lParam = (LPARAM) L"Hello";
//SendMessage(info->hWnd,WM_SETTEXT,0,(LPARAM)L"HEllo");
//SetWindowText(info->hWnd,L"Hello");
break;
}
Is it possible to change the string as done above in the code. 是否可以像上面的代码中那样更改字符串。 I tried by using APIs like
我尝试使用类似的API
SendMessage(info->hWnd,WM_SETTEXT,0,(LPARAM)L"HEllo");
SetWindowText(info->hWnd,L"Hello");
But none of them working.Idea here is to hook WM_SETTEXT message and change the string before it reached destination window. 但是它们都不起作用。这里的想法是钩住WM_SETTEXT消息并在字符串到达目标窗口之前对其进行更改。
No, the WH_CALLWNDPROC
doesn't allow you to modify messages, the documentation for CallWndProc directly states this. 不,
WH_CALLWNDPROC
不允许您修改消息, CallWndProc的文档直接说明了这一点。
The WH_GETMESSAGE
does allow you to modify the message. WH_GETMESSAGE
确实允许您修改消息。 See the documentation for GetMsgProc . 请参阅GetMsgProc的文档。 However, this probably won't work for what you want since it only messages that are retrieved with GetMessage() or PeekMessage() and send messages call the WndProc directly rather than using the message queue.
但是,这可能无法满足您的需求,因为它仅使用GetMessage()或PeekMessage()检索并发送消息的消息直接调用WndProc,而不是使用消息队列。
The way to do what you want is to use the WH_CBT
hook and listed for HCBT_CREATEWND
events. 执行所需操作的方法是使用
WH_CBT
挂钩,并为HCBT_CREATEWND
事件列出该挂钩。 Then subclass the window as it is created and handle the WM_SETTEXT
message. 然后在创建窗口时将其子类化,并处理
WM_SETTEXT
消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.