Is it possible for a file to be both an executable (EXE) and a dynamic-link library (DLL) at the same time? (I.e. it can be executed as an EXE and loaded at run-time as a shared library.)
I can't see why it shouldn't be possible, but maybe someone can give an explanation?
Yes, the Core and Utils code will be duplicated. Instead of building them as static libs you can build them as dlls and use anywhere.
Difference between exe and dll-1. EXE is an extension used for executable files while DLL is the extension for a dynamic link library. 2.An EXE file can be run independently while a DLL is used by other applications. 3.An EXE file defines an entry point while a DLL does not.
A DLL file is not by it self executable, though it may contain executable code. A DLL (Dynamic-Link Library) contains code, data, resources etc. usable by other programs. You need an EXE file for the operating system to execute code within DLL files, like "RUNDLL.
What is a dynamic link library (DLL)? A dynamic link library (DLL) is a collection of small programs that larger programs can load when needed to complete specific tasks. The small program, called a DLL file, contains instructions that help the larger program handle what may not be a core function of the original program.
An executable file links to (or loads) a DLL in one of two ways: Implicit linking, where the operating system loads the DLL when the executable using it is loaded. Explicit linking, where the operating system loads the DLL on demand at runtime.
The two methods of linking are load-time dynamic linking and run-time dynamic linking. In load-time dynamic linking, an application makes explicit calls to exported DLL functions like local functions. To use load-time dynamic linking, provide a header (.h) file and an import library (.lib) file when you compile and link the application.
What is the difference between an EXE and a DLL and how is it getting generated? If an assembly is compiled as a class library and provides types for other assemblies to use, then it has the file extension .dll (dynamic link library),
From LoadLibrary documentation:
The name of the module. This can be either a library module (a .dll file) or an executable module (an .exe file). The name specified is the file name of the module and is not related to the name stored in the library module itself, as specified by the LIBRARY keyword in the module-definition (.def) file.
EDIT: I expected downvotes when I wrote this answer. I know many people think it is not possible (SO questions and answers from comments confirm it). But for those who are interested I can provide POC (or simply look at well known "process explorer" sources)
Note that if you need to export symbols from module you need to use those EXPORT statements in .def
file. Then you can use GetProcAddress
Actually, I see that this SO question, also mentioned in comments, has answer that points to article "Load EXE as DLL: Mission Possible", which I also was going to quote. That answer is not accepted, accepted answer says "no" and even is taken as community wiki. Well "SO doesn't claim to be (in part) a library reference"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With