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 


Make a fullscreen game use window mode with dll

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

Joined: 11 Dec 2013
Posts: 67

PostPosted: Tue Mar 14, 2017 10:23 pm    Post subject: Make a fullscreen game use window mode with dll Reply with quote

How to make an old game (that always forces full screen) windowed from inside a DLL?

I've tried a load of apis and tests, but got nowhere. The program dxwnd can do it, so what's the secret?

I also assume that somewhere in this game, the window setting api is called - and I may be able to edit that directly.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 136

Joined: 25 Jan 2006
Posts: 7211
Location: 127.0.0.1

PostPosted: Tue Mar 14, 2017 11:35 pm    Post subject: Reply with quote

Depends on what graphics engine the game is using. dxwnd is a more or less 'all-in-one' type solution covering multiple enginges (dx7/8/9/gl/etc.)

For Direct3D8 and Direct3D9 you will need to hook CreateDevice and Reset mainly to tell the device adapter to run windowed. You may also have to hook CreateWindowA/CreateWindowW/CreateWindowExA/CreateWindowExW and other similar API to help enforce the windowing depending on how the game is coded.

For OpenGL, you would want to hook glViewport / glScissor / glCreateContext and similar to do pretty much the same as Direct3D, faking the device into thinking its windowed.

The source code to dxwnd is around the net somewhere if you look for it and want to see how it handles things. It's not the best in terms of code quality and overall usage for every game since some games implement things to attempt to prevent running in a window etc. that you will have to handle yourself differently.

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

Joined: 11 Dec 2013
Posts: 67

PostPosted: Wed Mar 15, 2017 2:42 am    Post subject: Reply with quote

Thanks. I also had a look at how someone else had done it. They basically called these:

//destroywindow(windowhan);
//adjustwindowrectex (....)
//windowhan:= createwindowex ( .... )
//showwindow(windowhan,SW_SHOW);

Destroying the current window just after it is created - and then planting a new one straight after.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 136

Joined: 25 Jan 2006
Posts: 7211
Location: 127.0.0.1

PostPosted: Fri Mar 17, 2017 2:08 am    Post subject: Reply with quote

dlpb wrote:
Thanks. I also had a look at how someone else had done it. They basically called these:

//destroywindow(windowhan);
//adjustwindowrectex (....)
//windowhan:= createwindowex ( .... )
//showwindow(windowhan,SW_SHOW);

Destroying the current window just after it is created - and then planting a new one straight after.


While in some cases it may be needed to do this (mainly to resize the window properly with the window rect etc.) the main device context still needs to be told to render windowed or in most cases you will just crash the game or it will have extremely weird window issues. (Flickering, invalid sizes, stretched textures etc.)

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

Joined: 11 Dec 2013
Posts: 67

PostPosted: Fri Mar 17, 2017 3:28 am    Post subject: Reply with quote

How does a ddraw app decide full screen mode? For that matter, what IS full screen mode? I don't see any documentation online that really explains this in terms of the apis.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 136

Joined: 25 Jan 2006
Posts: 7211
Location: 127.0.0.1

PostPosted: Fri Mar 17, 2017 1:31 pm    Post subject: Reply with quote

Fullscreen mode is when an application takes exclusive "ownership" of the graphics device and projects to the screen in a manner that renders to the whole screen regardless of what resolution is used.

For DDraw, I'm not that familiar with it personally. However MSDN has some old docs explaining that the internal palettes are what are used to draw to the hardware and are done either in exclusive mode (fullscreen) or in windowed mode here:
https://msdn.microsoft.com/en-us/library/aa451268.aspx

_________________
- 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