Link to home
Start Free TrialLog in
Avatar of rupvis
rupvisFlag for Singapore

asked on

Window goes invisible when i activate my Hook

I have created a global hook which calls another dll to perform certain actions. The different kind of hooks i am using are  WH_CALLWNDPROC, WH_CBT,                   WH_GETMESSAGE,  WH_KEYBOARD, WH_MOUSE,  WH_MSGFILTER,               WH_SYSMSGFILTER, WH_DEBUG.

On calling a hook procedure through setwindowhookex a function (FARPROC) CallWndProcFunc() is invoked..
LRESULT CALLBACK CallWndProcFunc (int nCode, WPARAM wParam, LPARAM lParam )
{
   HDC               hDC;
   PCWPSTRUCT  pParamStruct;

   return CallNextHookEx(hhookHooks[CALLWNDPROCINDEX], nCode, wParam, lParam);
}

The issue i face is that the calling of this function turns all menu bars invisible. It is like a ghost image and clicking on it still takes me to the actual form. This is also experienced in all menu options within start -> program for windows.

What could be restricting display of these menu's in my program as it is just a skeleton function.

Any help will be greatly appreciated.
Avatar of jkr
jkr
Flag of Germany image

Any chance that something gets messed up in

   return CallNextHookEx(hhookHooks[CALLWNDPROCINDEX], nCode, wParam, lParam);

, i.e. the indices were assigned incorrectly?
Avatar of rupvis

ASKER

(hhookHooks[CALLWNDPROCINDEX] is setup from the return type of setwindowhookex.
Even if i plainly enter values without having an array used i still see window going transparent. Has anyone used a standard WH_CALLWNDPROC hook. If yes i would like to know the calling procedure.
There is a very complete example here:
    Using Hooks
    http://msdn.microsoft.com/en-us/library/ms644960(VS.85).aspx
But I have to say that it appears to be functionally equivallent to your stub... So I don't have a solution for you.  Just a couple of thoughts:
Perhaps some other hook proc is misbehaving (but only when your hook is installed).  I know of no way to detect active hooks, but if you could turn off the other hooks, you might learn something.  For instance, what if you don't call the hook chain (for testing purpose)?
Diagnotic aid:  Log the call info to a text file, show the data going into your proc and after calling the hook chain.
Question:  When does the oddness happen?  Is it immediately upon calling SetWindowsHookEx , or is it upon some action, such as a mouse move or a keystroke?
Question (just to be sure):  Doe this haappen when the ONLY hook you install is for WH_CALLWNDPROC (it's apparent that you are installing multiple hooks, and I want to rule out the possibility that one of the your other hooks is having a strange interaction.)
Avatar of rupvis

ASKER

Thanks you danrollins. When debugging i have realised that i get the issue only when WH_CALLWNDPROC is called. I can be sure of this since i deactivate all other hooks and just run WH_CALLWNDPROC  to still get the problem. One thing i noticed is my virus scan i.e Mcafee to have a conflict. Mcafee task manager is a process named mctray.exe in the process list. If i kill mctray all runs fine again. So now i tried putting the hook dll name as well as the calling exe iinto the exclusion list for mcafee. Yet no luck.
ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rupvis

ASKER

This is brilliant.. will test and let you know..