Dynamic Link Library (DLL)

A Dynamic Link Library (DLL) is a file that contains code and data that can be used by more than one program at the same time.

Components: 1. Code sections. 2. Data sections. 3. Resources. 4. Relocation table. Types: Extension DLLs, Regular DLLs.

        graph LR
  Center["Dynamic Link Library (DLL)"]:::main
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧒 Explain Like I'm 5

Imagine you and your friends are all building LEGO kits. Instead of each of you having your own instruction book, you share one big book that sits in the middle of the table. You only look at the pages you need when you need them. That instruction book is a DLL—it's a set of steps that many programs can look at and use whenever they want.

🤓 Expert Deep Dive

Technically, DLLs enable 'Late Binding', meaning the code is not linked into the executable at compile time but at runtime. When a program starts, the 'Windows Loader' maps the required DLLs into the process's virtual memory space. This is managed via the 'Export Address Table' (EAT). One of the most famous issues in Windows history was 'DLL Hell', where different programs required different versions of the same DLL, leading to crashes. Microsoft solved this using 'SxS' (Side-by-Side) assemblies in the WinSxS folder. For security, 'DLL Hijacking' is a concern where hackers place a malicious DLL in an application's directory, hoping the OS will load it instead of the legitimate one found in System32.

📚 Sources