Click here to Skip to main content
16,022,542 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 :)
Posted

Look at 2 answers to your first question about the same problem! :)
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900