Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hook into wndproc of another application?

I have a small question hoping someone will help me. Is there any way to hook into other applications WNDPROC?

The situation is that I want to insert a menu in the other app menubar and I want to define the commands for every menu item.

I was able to insert the menu with menu items using some Win32 API functions (user32.dll), but I can't set the commands of that menu item so that it actually does something if clicked.

With some googling, I got some information about wndprocess, and I should intercept the ID Command sent and trigger some function, but I'm stuck.

Can anyone help me?

like image 633
K7rim Avatar asked Mar 20 '12 21:03

K7rim


1 Answers

You are going about this the wrong way. If you think about it, you'll realize that responding to menu events with your custom "actions" must require some code to run in the process that you're targeting. This means you'll need to inject code into the other process in order to achieve what you want.

Since you're going to need to inject code anyway, I strongly suggest you look at DLL-injecting into the other process (search "Dll Injection example"). This will bootstrap your code into the other process, and you can construct your menu there.

This also has the advantage that the foreign app won't be reliant on your app being responsive - it'll all be in-process.

like image 98
SecurityMatt Avatar answered Sep 17 '22 14:09

SecurityMatt