Jump to content
  • Advertisement
Sign in to follow this  
Decept

exe starting a dll in a new process

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

I'm creating a lobby application (exe) that can in turn launch games located in a subfolder as dll files. Each game is located in its own dll. There is also a main dll which has all the common functionality that the lobby and games share. But how do I start a game from the lobby application? The game will launch in a new window, totally separate from the lobby window. I was thinking of using CreateProcess(), but how do I start the actual game inside? The msdn docs says that I shouldn't do any fancy stuff in DllMain(), so where should I do it? So far I have been using LoadLibrary on the dll so I can call functions on it, to get the game's name and other info. Should probably mention that I'm using C++ (VC2005).

Share this post


Link to post
Share on other sites
Advertisement
The easiest way I can see to do this is have a launcher application as a standalone .exe file which takes the game DLL to load as a command line argument. You could even make the launcher .exe the same as the lobby application, and if no command line arguments are provided just start the lobby.

The launcher application would just grab the DLL from the command line args passed to WinMain(), then call LoadLibrary() and so on. You can pass the command line arguments to the child process with CreateProcess().

EDIT: Is there a reason you don't make each game a .exe instead of a .dll? Then you could just call CreateProcess on them directly.

Share this post


Link to post
Share on other sites
Actually there probably is no reason anymore to have the games as dll files. Previously the idea was to launch the games inside the lobby application (same window). But now, as they will have their own window, they can just as well be exe files too.

Just realized though, how would one get information from the game to display in the lobby if each game is an exe? For example the game's name and version number.

Share this post


Link to post
Share on other sites
Quote:
Original post by Decept
Actually there probably is no reason anymore to have the games as dll files. Previously the idea was to launch the games inside the lobby application (same window). But now, as they will have their own window, they can just as well be exe files too.

Just realized though, how would one get information from the game to display in the lobby if each game is an exe? For example the game's name and version number.
You can abuse the OS a little and have a .exe file export symbols just the same as a DLL. Then you can use LoadLibrary() and GetProcAddress() as if it were a DLL.

Alternatively, have it take another command line argument (/version for instance), and print the version number to the standard output handle, which can then be read by the parent process (Which is a bit ugly). Another option would be to store the version and other information in a resource that can be read by the lobby app.

Share this post


Link to post
Share on other sites
I have a follow-up question. I've decided to have the games as exe files aswell and just launch them from the Lobby app using CreateProcess(). It works as expected but how do I debug a launched game? For example setting breakpoints inside the game?

Share this post


Link to post
Share on other sites
Well, you open the project / solution with Visual Studio, let your launcher start the new process and then hit Debug / Attach to process in Visual Studio, this will load the PDBs of the process and you can fully debug the application as if it was started from within Visual studio (as far as I know).

I'm currently doing the same stuff at work (bebugging two applications at once).

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!