• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5603
  • Last Modified:

How would I integrate a dll into a exe programmatically

Basically i want to package a dll into an exe so when the exe makes a call to the dll it instead calls the function from within itself.
I know their is software out their to do this, but i wish to further understanding of these concepts and have custom control of it.

I am an advanced Visual Basic programmer, a beginner c++, and beginner in asm; beginner meaning experienced enough to write simple programs without help. Ive done quite a bit dissassembling and this where ive gotten my ASM knowledge from. If anything a general procedure of going about this would be appreciated.
1 Solution
The only thing you forgot to mention is the language in which you want to implement this.
If this is C++, see the following article:

Using this way, it is possible to embed Dll into exe resources. At run time, Dll is extracted from resources and saved to file. After this exe file can call functions from Dll using LoadLibrary and GetProcAddress.
This same way is used for embedded drivers, most utilities from www.sysinternals.com work with their own drivers extracted from resources.
>>Basically i want to package a dll into an exe so when the exe makes a call to the dll it instead calls the function from within itself.

that is what happens, a dll loads into exe's process space. so at runtime that function is in the process.

there is also some thing called static library, if you use them then the function becomes part of exe at compile more specifically linking time itself.

what exactly do you mean by ,  "i want to package a dll into an exe" ??


Not sure this will help, but I'll offer this suggestion until you can clarify a few things.

Clarifications needed:  
1. Programming language you are using?  
2.  Is the DLL coded by you or a third party DLL?

Suggestion:  For now, I'll assume that you wrote the DLL and offer you this suggestion.
Instead of compiling the DLL, move the code to a class module within your application.

Of course, this is a totally worthless suggestion if you don't have the code to the DLL.  But we'll try to help once we get some more info from you.

Good luck.

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

tim102096Author Commented:
1. Visual Basic is the main one.
2. DLLS are coded by third party (msvbvm6.dll, etc.)

I have played around with static dll injection and dynamic dll injection adn succeeded, however this only works if the program is being run in memory as a process. I want to pack them into the actual exe on disc. Theirs a program called PE Packer which i beleive does very similar to what i wish to do.
tim102096Author Commented:
I understand that i could inject the dlls into the end of the exe by declaring a blank data segment, then extract them using code to disc, however i wish to have them completely inside the exe and run from within the exe without ever copying the file to disc. This is for cleaness and to keep clutter out of the directory becuase several other functions are processing any extra files in the directories.
Daniel Van Der WerkenIndependent ConsultantCommented:
There exists a program called IMPLIB.EXE that Microsoft put out a while back.  I think it may ship as part of the Platform SDK or Visual Studio.

Anyway, here's what you do:

1.  Run implib.exe against the DLL to convert it to a .LIB file.
2.  You'll need the header file for the DLL or have function definitions that you intend to use.
3.  Add the .LIB as part of your project.
4.  Include the header file or add the appropriate function prototypes.
5.  Compile, link with the .LIB, and it should be good to go.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now