Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How to C# In-game overlay for Trainers?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Tybobobo
Cheater
Reputation: 0

Joined: 24 May 2016
Posts: 25

PostPosted: Wed May 25, 2016 4:07 pm    Post subject: How to C# In-game overlay for Trainers? Reply with quote

I am trying to figure out how it is possible to create a C# Program that gives you an in-game overlay that displays some cheat options.

I have made trainers using C# Window Applications, but I am interested learning more and finding out how to create in-game overlays where I can display various options, such as "Unlimited Health: Enabled" just so the user wont have to minimize the game in order to see the trainer status/options. Smile

Any and all help will be much appreciated - especially if it points me in the right direction Smile
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Wed May 25, 2016 7:51 pm    Post subject: Reply with quote

Create a transparent layered window that is top-most.

You can set those properties via SetWindowLongPtr using:
- GWL_EXSTYLE
- WS_EX_COMPOSITED | WS_EX_TRANSPARENT | WS_EX_LAYERED

In C# you will also need to enforce user drawing and paint the form yourself for proper overlaying. You can do that via:
Code:
this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);


Every so often you can find the window you are trying to draw over and reposition your overlay as needed etc.

On newer systems (Windows Vista and higher) the Dwm API will be of interest as well to deal with various window sizes / Aero effects:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa969512(v=vs.85).aspx

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Tybobobo
Cheater
Reputation: 0

Joined: 24 May 2016
Posts: 25

PostPosted: Wed May 25, 2016 11:14 pm    Post subject: Reply with quote

atom0s wrote:
Create a transparent layered window that is top-most.

You can set those properties via SetWindowLongPtr using:
- GWL_EXSTYLE
- WS_EX_COMPOSITED | WS_EX_TRANSPARENT | WS_EX_LAYERED

In C# you will also need to enforce user drawing and paint the form yourself for proper overlaying. You can do that via:
Code:
this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);


Every so often you can find the window you are trying to draw over and reposition your overlay as needed etc.

On newer systems (Windows Vista and higher) the Dwm API will be of interest as well to deal with various window sizes / Aero effects:


As I understand it; this will only work when playing in Windowed mode; otherwise I would need... injection or something? Read that I might have to use DirectX or something. Unsure about the specifics. :X
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu May 26, 2016 1:44 am    Post subject: Reply with quote

Yes, an overlay like this will only work on Windowed Mode / Fullscreen Windowed Mode games.

If you want to render things in the game, that's not really considered an overlay then. You'll have to either hook the rendering engine being used (OpenGL/Direct3D/etc.) or hook the games engine and use its own functions to draw things etc.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites