如何从全局挂钩中排除线程. [英] How to exclude a thread from global hook.

查看:69
本文介绍了如何从全局挂钩中排除线程.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我们正在钩挂 GLOBAL 的TextOut(),ExtTextOut()和DrawText()方法.


hhook = SetWindowsHookEx(WH_CBT, function_address, module_handle, 0);

但是我们想从钩子中排除我们的应用程序(我们正在使用它来安装/卸载钩子).如果"SetWindowsHookEx()"的最后一个参数为0(零),它将钩住所有现有线程.如何在此处检查当前线程是否为"OurApplication.exe",然后将其从钩子中排除或立即将其脱钩.

请提供帮助.

谢谢:)

Hi,

We are hooking TextOut(),ExtTextOut() and DrawText() methods GLOBALLY.

i.e.
hhook = SetWindowsHookEx(WH_CBT, function_address, module_handle, 0);

But we want to exclude our application (which we are using to install/uninstall hook) from being hooked. If the last argument to "SetWindowsHookEx()" is 0(zero) it will hook all the existing threads.How to check here if the current thread is "OurApplication.exe" and then exclude it from hooking or immediately unhook it.

Please provide help.

Thank you :)

推荐答案

请看关于同一问题的第一个问题的2个答案! :)
Look at 2 answers to your first question about the same problem! :)


大家好,
我们找到了做到这一点的方法.现在我们在注入dll的入口处添加了以下代码块,并且工作正常.
Hi All,
We found the way to do that. Now we added the following block of code in the entry point of the injecting dll.And it is working fine.
BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD dwReason, PVOID lpReserved)  <br />
{    <br />
    switch (dwReason)  <br />
    { <br />
       case DLL_PROCESS_ATTACH: <br />
           IsDebuggerPresent(); <br />
 <br />
           // Exclude the "someapplication.exe" from hooking <br />
           GetModuleFileName( GetModuleHandle( NULL ),Work,sizeof(Work) ); <br />
           PathStripPath(Work ); <br />
 <br />
           if ( _stricmp( Work, "someapplication.exe" ) != 0 ) <br />
           { <br />
              InstallWindowHooks(); <br />
           } <br />
 <br />
         break; <br />
       case DLL_PROCESS_DETACH: <br />
           hWindowReceiver = NULL; <br />
           CleanUp(); <br />
         break;      <br />
    } <br />
    return TRUE; <br />
} 



谢谢.



Thank you.


这篇关于如何从全局挂钩中排除线程.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆