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.
LVL 2
rupvisAsked:
Who is Participating?
 
DanRollinsConnect With a Mentor Commented:
I doubt if McAffe's exclusion list logic is smart enough to identify window hooking modules (I think it's more about virus scanning rather than realtime checking).  
But I think I have a glimmer of why this might be happeneing.  The "fade-in effect" might be one of those oddball messages that get handled without going through normal queuing logic.  There is a discussion here:
   http://www.rootsecure.net/content/downloads/pdf/shatter_attack_redux.pdf
...see PREVENTING MESSAGE-BASED ATTACKS"
It is possble that McAfee is trying to monitor those messages and in so-doing, corrupts the window-hooking chain -- or something like that.  
As a possible way to verify this theory:  Go to the Display Control Panel, Appearance tab, click [Effects] and uncheck the "Use the following effects for menus and tooltips..." option.  And then test your app while McAfee is running.
0
 
jkrCommented:
Any chance that something gets messed up in

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

, i.e. the indices were assigned incorrectly?
0
 
rupvisAuthor Commented:
(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.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
DanRollinsCommented:
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.)
0
 
rupvisAuthor Commented:
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.
0
 
rupvisAuthor Commented:
This is brilliant.. will test and let you know..
0
All Courses

From novice to tech pro — start learning today.