Global hook performance...
-
I am working on a project that requires a global hook. I only need to process a single message (WM_ACTIVATE), and I am using a WH_CALLWNDPROCRET type hook. Basically if I get this message I fire off another thread in the DLL that runs at THREAD_PRIORITY_LOWEST that modifies some of the window's styles. Anyway, when the hook is running taskmgr takes about 30% - 40% of the CPU time with nothing else going on. I assume this is from processing the messages because moving the mouse quickly increases this to 50% - 60%. The first thing I do in the hook is check if it is the message I want, and if it is not I call the next hook. I am also checking for nCode < 0 and calling the next hook without executing mine if this is true. Can anyone tell me what the best performance hook is? I think it is weird that the hook causes that much CPU usage in taskmgr. Oh, yes I am using DisableThreadLibraryCalls() for each process that uses the DLL. Thanks! -- Dana Holt Xenos Software
-
I am working on a project that requires a global hook. I only need to process a single message (WM_ACTIVATE), and I am using a WH_CALLWNDPROCRET type hook. Basically if I get this message I fire off another thread in the DLL that runs at THREAD_PRIORITY_LOWEST that modifies some of the window's styles. Anyway, when the hook is running taskmgr takes about 30% - 40% of the CPU time with nothing else going on. I assume this is from processing the messages because moving the mouse quickly increases this to 50% - 60%. The first thing I do in the hook is check if it is the message I want, and if it is not I call the next hook. I am also checking for nCode < 0 and calling the next hook without executing mine if this is true. Can anyone tell me what the best performance hook is? I think it is weird that the hook causes that much CPU usage in taskmgr. Oh, yes I am using DisableThreadLibraryCalls() for each process that uses the DLL. Thanks! -- Dana Holt Xenos Software
I'm use WH_GETMESSAGE and WH_SHELL hooks in my program without any strange performance effects. Why do you need to create separate thread? I'm perform needed actions by posting message (PostMessage API) in main window when I plan to do long time action handling (because PostMessage don't stops the thread), and by sending message (SendMessage API) for simple actions. Sorry for wrong English ;-))