2
\$\begingroup\$

I was taking a look at Cryengine's and Unreal's code and when built both engines generates lots of dlls. Inside Cryengine's System code I could see that it calls LoadLibrary to load the dlls and Initialize the modules.

Ex:. LoadLibrary("CryPhysics.dll")

But when you see Cryengine's or Unreal's deployed games they have only a single big .exe and no first-party dlls. In Crysis 3 Bin32 directory there is only Crysis3.exe and some third-party dlls, there is no CryPhysics.dll for example.

How do they achieve that? How can the LoadLibrary work without those dlls?

PS:. There is no #if wrapping the LoadLibrary to differentiate Debug from Release mode

\$\endgroup\$
1
  • \$\begingroup\$ Can you open the executable with an archive tool such as 7zip? \$\endgroup\$ Commented Jun 27, 2019 at 6:33

2 Answers 2

2
\$\begingroup\$

Generally, game engines that do this support two build modes: building with components as DLLs, and building with the components compiled directly in to a monolithic executable. This is definitely the way that Unreal achieves it, and there are preprocessor directives and similar execution path branches that simply cause the game not to try to load any DLLs in the monolithic case, since the desired code and data is already there.

I can’t speak to how CryEngine specifically handles it, but I’d feel pretty confident saying it’s similar.

\$\endgroup\$
3
  • \$\begingroup\$ In Unreal I've found a preprocessor called IS_MONOLITHIC that branches the code as you said but wouldn't it requires the full rebuild of the engine so a game could be deployed? About the LoadModule it was a typo, I've just fixed it. \$\endgroup\$ Commented Jun 27, 2019 at 14:15
  • \$\begingroup\$ Okay, then it’s probably just the case that the branching you’d want to look for is elsewhere. The process of linking and loading modules can be fairly complex so it’s unlikely that you’re seeing the complete solution by just looking at a few LoadLibrary calls. \$\endgroup\$ Commented Jun 27, 2019 at 14:21
  • \$\begingroup\$ IS_MONOLITHIC is part of UE’s solution to this. And yes, it does require that the game be rebuilt. This generally is fine, since the non-monolithic configurations are generally for editor builds, which you wouldn’t ship anyway. \$\endgroup\$ Commented Jun 28, 2019 at 0:09
2
\$\begingroup\$

DLLs can be packaged in an archive format (PAK, ZIP, BIN, etc) along with other game assets, extracted to a temporary directory on startup, and loaded from there - so have a look for the other supporting files that come with the game, and you're likely going to find a large one which is this archive file.

The primary advantage of this kind of approach is that the game's distributors get to retain a measure of control over these DLLs, which can help to deter casual hackers.

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.