How executable locates functions from DLLs exactly? I know that DLL files have entry points but how does the executable locate those entry points with name since everything inside a DLL is 1s and 0s?
Asked
Active
Viewed 215 times
-2
-
1Everything in all files is just 1s and 0s. – Feb 20 '17 at 17:25
-
1http://stackoverflow.com/questions/124549/what-exactly-are-dll-files-and-how-do-they-work – Anil Feb 20 '17 at 17:26
-
DLL format is the same as EXE so [read here](https://msdn.microsoft.com/en-us/library/windows/desktop/ms680547(v=vs.85).aspx) – mpiatek Feb 20 '17 at 17:27
1 Answers
-1
You compile against a specific .lib file, and that .lib file is derived from the same code used to create the DLL. If you do that with the exact same settings then the entry points are maintained and the calling program has those entry points built right into the code. That's why compiling the DLL with a different version of VStudio can wreck things: the C Runtime Library and other details of the later VStudio aren't identical so both the DLL and EXE have different entry points. But if you compile both on the same generation of tech, then they line up automatically.

Jason Lang
- 1,079
- 9
- 17
-
Well, I've always been told that it includes machine instructions like executable. – Daniel Nyman Feb 20 '17 at 17:25
-
Well yeah, but you basically have an exact schematic of where everything is from the .lib file when you make your exe, so it knows where those things are already. This is the reason it won't let you compile to work with a DLL unless you have the correct .lib file made on the same compiler generation. – Jason Lang Feb 20 '17 at 17:31
-
So if my DLL has function "CreateWindow" would it include the instructions for creating window or just the name of the function? – Daniel Nyman Feb 20 '17 at 17:36
-
It doesn't necessarily have the name of the function in it, unless you do a Debug build of the DLL. The names are in the .lib file, with information on the location of the code in the DLL. The compiler takes the names and replaces them with the code calls in the exe. – Jason Lang Feb 20 '17 at 17:40
-
-
The LIB file contains that information. So the locations inside the DLL are known when you compile the EXE. That's why you need the LIB file that matches the DLL in your compiler – Jason Lang Feb 21 '17 at 02:18