DebugProc中DEBUGHOOKINFO的成员idThread值总是为当前线程ID解决方案
DebugProc中DEBUGHOOKINFO的成员idThread值总是为当前线程ID
下面的代码中debug->idThread的值总是固定不变。
我用SPY++查看时居然也没有变,非常奇怪。
如果是 WH_CALLWNDPROC类型的HOOK,可以检查到目标窗口改变了。现在的问题是如何在DebugProc中得到目标窗口。
------解决方案--------------------
你要捕捉什么啊?
------解决方案--------------------
不是很明白 你的意思..
------解决方案--------------------
idThread
Type: DWORD
A handle to the thread containing the filter function.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms644965(v=vs.85).aspx
下面的代码中debug->idThread的值总是固定不变。
我用SPY++查看时居然也没有变,非常奇怪。
如果是 WH_CALLWNDPROC类型的HOOK,可以检查到目标窗口改变了。现在的问题是如何在DebugProc中得到目标窗口。
- C/C++ code
LRESULT CALLBACK DebugProc(int nCode, WPARAM wParam, LPARAM lParam) //WH_DEBUG钩子例程 { DEBUGHOOKINFO *debug=(DEBUGHOOKINFO *)lParam; //防止键盘被监听 if(debug->idThread!=debug->idThreadInstaller && wParam== WH_KEYBOARD) { return 1; } return ::CallNextHookEx(DEBUG_hhook, nCode, wParam ,lParam); } BOOL APIENTRY DllMain( HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { handle = hModule; return TRUE; } bool WINAPI InstallHook() { DEBUG_hhook =::SetWindowsHookEx(WH_DEBUG,(HOOKPROC)DebugProc,handle, NULL); if(DEBUG_hhook == NULL) return false; return true; } bool WINAPI UnInstallHook() { UnhookWindowsHookEx(DEBUG_hhook); return true; }
------解决方案--------------------
你要捕捉什么啊?
------解决方案--------------------
不是很明白 你的意思..
------解决方案--------------------
idThread
Type: DWORD
A handle to the thread containing the filter function.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms644965(v=vs.85).aspx