Hooked Procedure Early Return In/External Trigger

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Apr 2008
Posts: 15
Reputation: n00b3 is an unknown quantity at this point 
Solved Threads: 1
n00b3 n00b3 is offline Offline
Newbie Poster

Hooked Procedure Early Return In/External Trigger

 
0
  #1
Jun 27th, 2008
Hooked Procedure Early Return In/External Trigger

Hello,

I've hooked into an application succesfully using WH_CALLWNDPROCRET or WH_CALLWNDPROC both give the same issue detailed below.

In the hooked callback function I trigger my code by waiting for a spceific window message.

Once the hooked callback function receives this message, my code is triggered and executes a right click on an "Edit" window where normally a menu (which is a new handle) is created.

Here is the rub, the menu window is not created until my call back function returns its value.

So my code, though it sends the proper right click message, cannot find the menu, because the menu hasn't been created yet, because the hooked callback function has not returned its value (because my code is still executing).

However, if i execute the code from outside of a hook (say i trigger it myself from a command line), the menu appears and my code can find the menu and everything works as I expect.

What would be a work around for this.

For instance could I use the hook function to post a message to a program i create designed to handle messages from this hooked procedure.

I really don't want to do that, as that would mean changing from a command line to a gui event based program.

Or can I make a command line program event based?

My first question is, however, dealing with the 'delayed' menu window creation.

For instance, is there a way to instantly return my hooked call back procedure and then proceed with my code?

Thanks,
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 15
Reputation: n00b3 is an unknown quantity at this point 
Solved Threads: 1
n00b3 n00b3 is offline Offline
Newbie Poster

Re: Hooked Procedure Early Return In/External Trigger

 
0
  #2
Jun 29th, 2008
I needed to create another thread, so that the hooked procedure would return. The other thread, had a delay Sleep(1000); call so that the menu would get created in the original thread.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum


Views: 487 | Replies: 1
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC