winapi - calling setwindowshookex with WH_GETMESSAGE doesn't work on any process except the injector -


i asked question similar believe time circumstances different.

i have dll has standard hook, unhook , msgproc functions. load dll in main application , call 'hook', below:

hookdll_api bool sethook( hwnd hwnd, dword threadid ) {  if( hwndserver != null )     return false;  hook = setwindowshookex( wh_getmessage, (hookproc)msghook, hinstance, threadid );  if( hook != null ) {     hwndserver = hwnd;      ofstream logfile;     logfile.open( "log.txt" );     logfile << "hooked for: " << hwndserver << endl;     logfile.close();      return true; }  return false; } 

the problem if make global, threadid = 0, msghook , captures messages received window of process loaded library , nothing else, if supposed global hook.

if supply threadid of other window, don't receive messages @ all.

what perhaps reason it?

  • are using 64-bit windows? if so, hook process , dll must match bitness of process(es) wish hook.

  • what hinstance in example? dll or exe instance? should dll contains msghook function.

  • what msghook do? how detect whether or not being called? note called within process(es) hook, not within own process. (so if you've set breakpoint on it, won't triggered unless attach debugger process you've hooked, rather process installed hook.)


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -