?
Solved

How would I integrate a dll into a exe programmatically

Posted on 2005-04-29
9
Medium Priority
?
5,577 Views
Last Modified: 2008-02-20
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.
0
Comment
Question by:tim102096
6 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 13895995
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:
http://www.codeproject.com/win32/binaryresources.asp

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.
0
 
LVL 8

Expert Comment

by:novitiate
ID: 13900513
>>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" ??

_novi_
0
 
LVL 3

Expert Comment

by:jcouture
ID: 13900736
Tim,

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.

JC.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:tim102096
ID: 13902454
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.
0
 

Author Comment

by:tim102096
ID: 13902462
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.
0
 
LVL 20

Accepted Solution

by:
Daniel Van Der Werken earned 2000 total points
ID: 14133030
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.

---Dan---
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question