What are DLL Files, and How Do They Work?

Most of the time we only come across DLL files when a given software is unable to work due to the lack of some .dll file. After this prompt, we go online to get that DLL file, put it in the proper folder and get the software running. And that is it – case closed about DLL files.

However, it should be interesting to understand more about these particular files. They seem important, as their absence can prevent softwares from running, so what are they, anyway? And how do they work? Let’s get some answers.

dll-dlls1

Almost everyone has, at some point in time, dealt with DLL files, often when a newly installed software does not work because one of those files is missing.

DLL stands for “Dynamic-Link Library”, and is Microsoft’s implementation of the shared library concept in the Microsoft Windows and OS/2 operating systems. They are essentially the same as EXEs, but are named differently for clarity in the linking process. DLL files cannot, however, be directly executed, hence the existence of tools like rundll.exe and rundll32.exe.

DLL files are nothing more than a means for developers to use shared code and data, allowing to upgrade functionalities without the need to re-link or re-compile applications. In other words, DLL files contain code and data that is used by several different applications. A single DLL file can be used by different applications, if they should require it, eliminating the need for multiple copies of the same information.

dll-internet

Imagine two distinct files: “example.exe,” a common executable file, and “library.dll,” a DLL that is used by that executable. How are those files connected by the operating system when “example.exe” runs?

When “example.exe” runs, the operating system loads it and finds a table of data within it, stating that (obviously not in words) “this program uses the following list of functions from the DLL file library.dll,” which is technically called “imports” or “imported functions” from the DLL “library.dll” in the program “example.exe.”

Then, the loader code searches for “library.dll” and, if it finds it, the file is loaded. Inside this DLL file, there is another list, called “export list,” which connects specific addresses to each of the functions inside the DLL file. From this point on, when “example.exe” needs to call a function from “library.dll,” it simply uses that address.

dll-search

When a given software lacks a DLL file, the usual approach is to search that file online and store it in our hard drive. It will work if you place the DLL inside the software’s folder, but as I explained above, several software might need that file, so it is better to store it where they all can reach it – and that is the “System32″ folder (C:\Windows\System32). x64 users should also copy the DLL file to “C:\Windows\SysWOW64″ (both these operations need Administrator privileges to be carried out).

However, this method is not recommended by everyone, as it may bring some risks like outdated DLLs, virus infections and so on. From my personal experience, I never had problems with DLL files (I usually get them from this site, but be sure to choose the “Download Zip File” option to avoid third-party software), so in the end it all comes down to personal taste.

Did you know this information about DLL files? Is there something important missing from this article? Let us know in the comments.