Jump to content
  • Advertisement
Sign in to follow this  
owl

Ms. Windows Hooking. Can I stop an app from recieving a shortcut message?

This topic is 5058 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Yes sorry:

I want to catch an application defined shortcut (hot-key) command message before it reaches the target window. (if that's really the way hotkeys work, I've seen that Spy++ catchs WM_ messages related to shortcuts but I'm not really sure if they are the same).

I'm using hooking in a plug-in that hides an application's menu, but in some special parts of this app, there is a hot key that re-enables the menu, and I don't want that to happen.

Share this post


Link to post
Share on other sites
you can do everything.
inject the dll in the target process, subclass the window, if you recognize a message you want to trap, just don't forward it to the original wiindow procedure..
that helps ?

Share this post


Link to post
Share on other sites
heh, yes. My mind just made the "click".

Once I hook the thread I want, I just set my own wndproc as I would normally do with my own windows? Isn't? I guess that's what hooking is all about :) I'm new to this stuff...

So inside my DLL I would catch all messages and if the window that message is going to has the title I want, I just set my own wndproc to that window like this:



(WNDPROC)SetWindowLong(hWnd, GWL_WNDPROC, (DWORD)MyOwnWndProc);



Thank you. You've just been rated.

Share this post


Link to post
Share on other sites
yes, that's about it, once you get your dll injected in the target process, you can access all its memory, a simple (WNDPROC)SetWindowLong(hWnd, GWL_WNDPROC, (DWORD)MyOwnWndProc); will do the job fine. don't forget to restore the original proc when you quit if you don't want the target process to crash.

one thing that bugged me : SetWindowLong will return a HANDLE to the previous window proc, on some win32 platforms, this HANDLE is nothing more than the pointer to the procedure, and on some other win32 platforms, it's really a HANDLE.. then always use the CallWindowProc(...) API to forward the messages.

in fact, hooking is only used to inject the dll in the target process space, but you could do it diferently.
replacing a window proc is called subclassing.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!