Jump to content
  • Advertisement
Sign in to follow this  
Dodi300

How to hook/overlay a game with C#?

This topic is 3169 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. Can anyone tell me how to hook/overlay a game in C#? I've searched around but I couldn't find anything. I've tried getting a fullscreen C# window to overlap a game, however it wont. After researching a little, I found out that I need to hook the game and then display the C# window. Can anyone explain how I would do this? :) Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Still can't find anything, except this:
http://www.gamedev.net/community/forums/topic.asp?topic_id=359794

Could I maybe get that to hook the game, and then run the C# program?
Would that make the C# program show, or doesn't it work like that?

Thanks for the help.
I really appreciate it.

Share this post


Link to post
Share on other sites
In general, in order to get C++ and C# code to communicate, you need to stuff your C++ code into a straight C DLL interface, and then have C# call functions from this DLL. It'll look something like this:


// Export.cpp
extern "C" DLLExport void MyFunc() { /* Call game code */ }

// NativeMethods.cs
[DllImport("DLLName.dll")]
public static extern void MyFunc();



The C# method will then reference the C method defined in your DLL. If you give us a better idea of what you're trying to do, we might be able to provide more specific advice.

Share this post


Link to post
Share on other sites
Thanks for the replies! :D

I'm trying to create an overlay for games.
Something like the ones both Steam and xFire have.

I've created an app (in C#) which launches games, but I would like to have an overlay as well.
The Steam overlay lets users surf the net while playing games, which is mainly the reason why I want it for my app.

I've tried creating another C# program but I can't get it to overlap/go on top of a directx game, even though it will go above any Windows program.

I want the overlay to display when a certain key is pressed. (Maybe something like "Alt+Z"?)

Any advice how I would do this would be very helpful.
Even if it's just pointers in the right direction.
Thanks.

Share this post


Link to post
Share on other sites
Make a forms application with a panel inside it, get the window handle for the panel, pass it to your native renderer, render to it, overlay the form with a c# gui of your choosing?

Share this post


Link to post
Share on other sites
Quote:
Original post by return0
Make a forms application with a panel inside it, get the window handle for the panel, pass it to your native renderer, render to it, overlay the form with a c# gui of your choosing?


Okay, I can make a app with a panel in it, but everything else I don't know what you mean.
I've never done any rendering before.

Also, when you say "overlay the form with a c# gui", couldn't I just use the gui of the forms?

Can you explain further please?
Thanks.

Share this post


Link to post
Share on other sites
You may want to take a look at http://www.codingthewheel.com/archives/how-to-inject-a-managed-assembly-dll

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!