SetClassLong子类化,请大家帮忙检查下有关问题代码
SetClassLong子类化,请大家帮忙检查下问题代码
子类化窗口,吧SetClassLong 放到DLL中 然后注入目标进程。根据OutputDebugString显示信息 注入和执行SetClassLong 都成功了,为什么ListFilterProc却收不到 任何消息呢
------解决思路----------------------
看看MSDN:
Calling SetWindowLong with the GWL_WNDPROC index creates a subclass of the window class used to create the window. An application can subclass a system class, but should not subclass a window class created by another process. The SetWindowLong function creates the window subclass by changing the window procedure associated with a particular window class, causing the system to call the new window procedure instead of the previous one. An application must pass any messages not processed by the new window procedure to the previous window procedure by calling CallWindowProc. This allows the application to create a chain of window procedures.
------解决思路----------------------
lz用SetWindowLong子类化窗口试下。
http://www.cnblogs.com/wjl4934/archive/2012/07/16/2593173.html
子类化窗口,吧SetClassLong 放到DLL中 然后注入目标进程。根据OutputDebugString显示信息 注入和执行SetClassLong 都成功了,为什么ListFilterProc却收不到 任何消息呢
#include "stdafx.h"
#define MAGIC_NUMBER (0x20)
WNDPROC lpfnSupperClassProc=NULL;
__forceinline
LRESULT CALLBACK ListFilterProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
OutputDebugString("msg");
return CallWindowProc(lpfnSupperClassProc,hwnd,uMsg,wParam,lParam);
}
__forceinline
BOOL InstallListFilter()
{
OutputDebugString(_T("InstallFilter\n"));
BOOL bRet=FALSE;
HWND hWnd=NULL;
INITCOMMONCONTROLSEX cls={sizeof(INITCOMMONCONTROLSEX),ICC_WIN95_CLASSES};
bRet=InitCommonControlsEx(&cls);
if(bRet)
{
OutputDebugString(_T("InitCommonControlsEx\n"));
// hWnd=CreateWindow(_T("SysListView32"),_T(""),WS_CAPTION|LVS_REPORT,0,0,0,0,NULL,NULL,NULL,NULL);
hWnd=::FindWindow(0,"teszt");
if (hWnd)
{
OutputDebugString(_T("hWnd OK\n"));
}
lpfnSupperClassProc=(WNDPROC)GetClassLong(hWnd,GCL_WNDPROC);
if (SetClassLong(hWnd,GCL_WNDPROC,(LONG)ListFilterProc)==0)
{
OutputDebugString(_T("error\n"));
}
// DestroyWindow(hWnd);
}
return bRet;
}
BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call, LPVOID lpReserved)
{
if(DLL_PROCESS_ATTACH==ul_reason_for_call)
InstallListFilter();
return TRUE;
}
------解决思路----------------------
看看MSDN:
Calling SetWindowLong with the GWL_WNDPROC index creates a subclass of the window class used to create the window. An application can subclass a system class, but should not subclass a window class created by another process. The SetWindowLong function creates the window subclass by changing the window procedure associated with a particular window class, causing the system to call the new window procedure instead of the previous one. An application must pass any messages not processed by the new window procedure to the previous window procedure by calling CallWindowProc. This allows the application to create a chain of window procedures.
------解决思路----------------------
lz用SetWindowLong子类化窗口试下。
http://www.cnblogs.com/wjl4934/archive/2012/07/16/2593173.html