Jump to content
  • Advertisement
Sign in to follow this  

Making a hook to call a program's function

This topic is 3295 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

Hello, Internet! I've recently come across a little dilemma, and that's that I like to stream music to friends over Ventrilo (a voice communication program for those who don't know or care), however sometimes they like to ask me: "Hey, Etyrn! What's the name of that song, and who is it by?". Well this is normally solved by using the built-in integration Ventrilo has to read what song is currently playing on either winamp, wmp, or itunes and then add it into your comment (a bit of customizable text after your username). However I do not like to use these media players! I like to use foobar2000! As Ventrilo is not open-source and not extensible I'm stuck with few options for remedying this. I started off by trying to automate some Win32 calls but ran into problems getting the hWnd dealie of the dialog box that pops up for comments and even then it appears I'd need some elaborate work around to edit the text box that dictates what your comment will be as WM_SETTEXT is said not to work on applications that are not your own! So I'm left with the idea of making a hook that calls the function which changes your comment and uploads it to the Ventrilo server for all to see. So far I've managed to come across examples of how to get a DLL into the process itself, but as to what I do from there I'm rather at a loss. I do not know how to find the address of the function I wish to call, nor how to figure out what arguments it takes and how to push those. Or perhaps I have the process of how I'd be going about this a little mixed up. I find it all to be kind of confusing and my Google skills aren't exactly the greatest (though I did try for a good couple hours to research this). What I'm hoping for is someone who could dumb down the situation and the procedure I should be following to achieve my goal. Any and all help would be much appreciated!

Share this post

Link to post
Share on other sites
What your asking about isn't easily dumbed down. You're crossing process boundaries, possibly scanning pe file headers, guessing about function argument types, and probably a couple of other things that I've forgotten about.

Once inside your target, try using GetProcAddress on the function you want to call. If you don't have a signature for the function, you'll probably need to use a disassembler to examine the machine instructions in the function.

PE Browse works pretty good for that: Windows Debugger, Disassembler, Code Analyzers

You might also want to pick up Dependency Walker and Process Explorer too.

These utilities are free.

Here are a couple of google searches.

google: function+hook
google: osterlund+pe+file

Wikipedia might help too.


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!