Difference between .dll and .exe?

I want to know the exact difference between a DLL and an EXE file.

+82
exe windows dll
Jul 31 '09 at 6:03
source share
14 answers

EXE:

  • This is an executable file.
  • When loading the executable file, the export is not called, but only the entry point of the module.
  • When the system starts a new executable file, a new process is created.
  • The input stream is called in the context of the main thread of this process.

DLL:

  • This is a dynamic link library.
  • There are several exported characters.
  • The system loads the DLL into the context of an existing process.

More details: http://www.c-sharpcorner.com/Interviews/Answer/Answers.aspxQuestionId=1431&MajorCategoryId=1&MinorCategoryId=1 http://wiki.answers.com/Q/What_is_the_difference_between_an_EXE_and_a_DLL

Link: http://www.dotnetspider.com/forum/34260-What-difference-between-dll-exe.aspx

+64
Jul 31 '09 at 6:09
source share

I do not know why everyone answers this question in the context of .NET. The question was general and did not mention .NET anywhere.

Well, the main differences are as follows:

Exe

  • exe always works in its own address space, that is, it is a separate process.
  • The purpose of the EXE is to run a standalone application.

Dll

  • A DLL always requires exe to run in order to run. that is, it can never work in its own address space.
  • The purpose of a DLL is to have a set of methods / classes that can be reused from another application.
  • A DLL is an implementation of a Microsoft shared library.

The file format of the DLL and exe is essentially the same. Windows recognizes the difference between DLL and EXE through the PE Header in the file. For more information on PE Header, you can read this article on MSDN .

+116
Jul 31 '09 at 6:41
source share

The difference is that the EXE has an entry point, the "main" method that will be executed on execution.

The code inside the DLL must be called from another application.

+26
Sep 29 '09 at 15:08
source share

There are a few more differences regarding the structure you might mention.

  • Both DLL and EXE use the same file structure - Portable Executable or PE. To differentiate them, you can look in the Characteristics element IMAGE_FILE_HEADER inside IMAGE_NT_HEADERS . For a DLL, it has the IMAGE_FILE_DLL flag (0x2000). For EXE, this is the IMAGE_FILE_EXECUTABLE_IMAGE (0x2) flag.
  • PE files consist of some headers and several sections. Usually there is a section for code, a section for data, a section that lists the imported functions, and a section for resources. Some sections may contain more than one. The header also describes the list of data directories that are in the sections. These data directories allow Windows to find what it needs in PE. But one type of data directory that an EXE will never have (unless you create exe frankenstein) is an export directory. Here, DLL files have a list of functions that they export, and can be used by other EXE or DLL files. On the other hand, every DLL and EXE has an import directory that lists the functions and DLL files that you need to run.
  • Also in the PE headers ( IMAGE_OPTIONAL_HEADER ) is an ImageBase member. It determines the virtual address at which the PE assumes that it will be loaded. If it is loaded at a different address, some pointers may indicate incorrect memory. Since EXE files are among the first to be loaded into their new address space, the Windows boot loader can provide a constant download address and usually 0x00400000. This luxury does not exist for a DLL. Two DLL files loaded into the same process can request the same address. This is why there is another data directory in the DLL called Base Relocation Directory, which is usually located in its own section - .reloc . This directory contains a list of places in the DLL that need to be repackaged / fixed so that they point to the correct memory. Most EXE files do not have this directory, but some older compilers generate them.

You can read more on this topic @ MSDN .

+24
Nov 24 '10 at 11:21
source share

This answer was a bit more detailed than I thought, but read it.

DLL:
In most cases, a DLL file is a library. There are several types of libraries, dynamic and static - read about the differences . DLL means dynamic link library , which tells us that this is part of the program, but not all of this. It consists of reusable software components ( library ) that you could use for more than one program. Keep in mind that you can always use the source code of a library in many applications using copy-paste, but the idea of ​​the DLL / Static library is that you can update the library code and at the same time update all applications using it - without compilation .

For example:
Imagine you are creating a Windows GUI component as a button . In most cases, you want to reuse the code you wrote because it is a complex but common component. You want many applications to use it, but you do not want to tell them the source code. You cannot copy the -paste code for a button in each program, so you decide that you want to create a DL-Library (DLL) .

This "button" library is required to use EXE cutables, and without it they won’t start because they don’t know how to create a button, just how to talk to it.

Likewise, a DLL cannot be executed - it is executed because it is only part of the program, but does not contain the information necessary to create the process. "

EXE:
The executable file is a program. He knows how to create a process and how to talk to a DLL. To create a button, a DLL is required, and without it, the application does not start - ERROR.

hope this helps ....

+16
Jul 31 '09 at 7:04
source share

Both DLL and EXE Portable Executable (PE) formats

A Dynamic Link Library (DLL) is a library and therefore cannot be executed directly. If you try to start it, you will receive an error message with a missing entry point. He needs an entry point (main function) to execute, this entry point can be any application or exe. DLL binding occurs at runtime. That's why it is called the Dynamic Link library.

An executable file (EXE) is a program that can be executed. It has its own entry point. A flag inside the PE header indicates what type of file it has (it does not matter for the file extension). The PE header has a field in which the entry point for the program resides. The DLL is not used (or at least not as an entry point).

There are many software for checking header information. The only difference that makes it work differently is a bit in the header, as shown in the diagram below.

header

An EXE file has only one main entry, which means that it is an isolated application, when the system starts exe, a new process is created, while DLLs have many entry points, so when the application does not use it, the new process does not start, the DLL can reuse and version. A DLL reduces memory because different programs can use the same DLL.

+14
Jan 10 '14 at 11:24
source share

Dll v / s exe

1) DLL file is a dynamic link library that can be used in exe files and other DLL files.
An exe file is an executable file that runs in a separate process that is controlled by the OS.

2) DLLs are not executed directly. These are separate files containing functions that can be called by programs and other DLLs to perform calculations and functions.
EXE is a program that can be executed. Example: Windows program

3) Reusable
DLL: they can be reused for another application. So far, the encoder knows the names and parameters of functions and procedures in the DLL file.
EXE: For a specific purpose only.

4) The DLL will use the same process and the memory space of the calling application, and the EXE will create a separate process and memory space.

5) Uses
DLL: you want many applications to use it, but you do not want to tell them the source code. You cannot copy the code for the button in each program, so you decided to create a DL library (DLL).

EXE: When we work with project templates such as Windows Forms applications, console applications, WPF applications, and Windows services, they generate an exe assembly when compiled.

6) Similarities:
Both DLL and EXE are binary files that have a complex nested structure defined in the Portable Executable format, and they are not intended for editing by users.

+4
Sep 11 '15 at 12:05
source share

Two things: the extension and the header flag stored in the file.

Both files are PE files. Both contain the same layout. A DLL is a library and therefore cannot be executed. If you try to start it, you will receive an error message with a missing entry point. EXE is a program that can be executed. It has an entry point. A flag inside the PE header indicates what type of file it is (it does not matter for the file extension). The PE header has a field in which the entry point for the program resides. The DLL is not used (or at least not as an entry point).

One of the minor differences is that in most cases, a DLL has an export section in which characters are exported. There should never be an export section in an EXE, since they are not libraries, but nothing prevents this. For the Win32 bootloader anyway.

In addition, they are identical. So, in general, EXEs are executable programs, and DLLs are libraries that are loaded into a process and contain useful functions, such as security, database access, or something like that.

+3
Aug 25 2018-11-11T00:
source share

The system sees the EXE as a regular Win32 executable file. Its point entry refers to a small bootloader that initializes the .NET runtime and tells it to load and execute the assembly contained in the EXE. The DLL is visible to the system as a Win32 DLL, but most likely without any entry point. The .NET runtime stores assembly information in its own header.

dll is a collection of reusable functions, where .exe is an executable file that can call these Functions

+2
Jul 31 '09 at 6:06
source share

.exe is a program. A DLL is a library that can be accessed by .exe (or another .dll).

What sakthivignesh says may be true in that one .exe can use the other as if it were a library, and this is done (for example) with some COM components. In this case, the β€œslave .exe” is a separate program (strictly speaking, a separate process - it may work on a separate machine), but one that accepts and processes requests from other programs / components / independently.

However, if you simply select random .exe and .dll files from a folder in your program files, the likelihood that COM doesn't matter is just a program and its dynamically linked libraries.

Using the Win32 API, the program can load and use DLLs using the LoadLibrary and GetProcAddress API, IIRC functions. Win16 had similar features.

COM is largely an evolution of the idea of ​​a DLL, originally derived as the basis for OLE2, while .NET is a descendant of COM. DLLs have been around since Windows 1, IIRC. Initially, they were a way of sharing binary code (especially system APIs) between several running programs in order to minimize memory usage.

+1
Sep 29 '09 at 15:25
source share

● .exe and dll are a compiled version of C # code, also called nodes.

● .exe is a standalone executable file, which means that it can be executed directly.

● .dll is a reusable component that cannot be executed directly, and it requires other programs to execute it.

+1
May 31 '16 at 1:19
source share

Exe is an executable program, while a DLL is a file that can be loaded and executed dynamically by programs.

0
Jul 31 '09 at 6:06
source share

The difference in DLL and EXE:

1) DLL is an in-process component that means working in the same memory space as the client process. EXE is a component of Out-Process, which means that it works in its own separate memory space.

2) DLL contains functions and procedures that other programs can use (promotes reuse), while EXE cannot be used in conjunction with other programs.

3) DLLs cannot be started directly, as they are designed to be downloaded and launched by other programs. EXE is a program that runs directly.

0
Apr 04 '19 at 21:19
source share

The main exact difference between a DLL and an EXE is that the DLL does not have an entry point and an EXE. If you are familiar with C ++, you can see that there is a main () function in the EXE assembly, and the DLL is not :)

-2
Jul 31 '09 at 6:11
source share



All Articles