Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / Embedding a dll into a dll

Author
Message
Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 17th Feb 2007 13:38
I've made a dll for dbpro (in dev c++), which seems to work fine, but it needs another 3 dll's to be placed into the dbpro's project folder to work. Is it possible to embed these dll's into my single dll, in the same sort of way that dbpro allows you to embed files into its exe's? If so, how?

Thanks,

Ric.

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Feb 2007 14:53
Yes - add them as a resource (don't know how to do that with Dev-C++), and then extract them at runtime if they don't exist in the current folder.

The problem that you have to avoid (which is harder than it sounds) is you can't use them until they exist. That means, you must call functions within them using LoadLibrary/GetProcAddress, or use delayed loading (don't know if that is available in Dev-C++).

Also, from MSDN:
Quote: "It is not safe to call LoadLibrary from DllMain. For more information, see the Remarks section in DllMain"

So you must engineer a way for these libraries to be loaded elsewhere.

jasonhtml
20
Years of Service
User Offline
Joined: 20th Mar 2004
Location: OC, California, USA
Posted: 17th Feb 2007 15:41
omg... why didnt someone tell me this in the VERY similiar post i made of this not that long ago

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Feb 2007 23:24
It only occurred to me today. There are some big drawbacks with it, not least of which is just getting it working. There's also the problem of screwing up someone else's program by potentially providing an incompatible version of a DLL they already have. Then there are the moral issues of including someone else's DLL without their permission.

It's really not a good idea, but it's possible.

Ric
19
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 17th Feb 2007 23:55
Just read Jason's thread too! On reflection, it seems that keeping the dll's separate sounds more sensible, (and legal!). Thanks for the advice.

Xarshi
18
Years of Service
User Offline
Joined: 25th Dec 2005
Location: Ohio
Posted: 18th Feb 2007 05:15 Edited at: 18th Feb 2007 08:48
two questions,how do you add a resource and how would you extract the dll at runtime?(sorta want to know this,for reference at least).

Edit - Hm... I am too wondering if its a good idea...I guess I shouldn't...

Edit 2 - I think I found out how. I went through resHack and added a dll with the type of "DLL" and the name "TEST",and then I would make a function in the dll that has all the dlls in it,say like:


I'm probably wrong,arent I

Hello
jasonhtml
20
Years of Service
User Offline
Joined: 20th Mar 2004
Location: OC, California, USA
Posted: 18th Feb 2007 16:57
i guess ill just have to require that the people have a certain version of whatever dlls they might need its not a very hard thing to ask, but its a pain

heartbone
21
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 22nd Feb 2007 04:24
ILLINK -- Microsoft (R) .NET Framework IL Linker
Version 1.0

Only pure-IL modules, such as those generated by C#, VB.NET or ILASM compilers, can be linked.

--------------------------------------------------------------

perhaps this can help?

I'm unique, just like everybody else.
JDforce
19
Years of Service
User Offline
Joined: 27th Jul 2004
Location: Sea of Tranquility
Posted: 2nd Mar 2007 16:15
Just use molebox and all your packing problems are solved. The only thing I could not pack with molebox is a gamemaker executable, which is already packed and encrypted.
For dll's and media it works great, and for activeX it even register them when running the program.

May the 3d force B with U
heartbone
21
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 13th Mar 2007 03:03
How about this method Ric?
The first time unpack the data to dll file.
On subsequent runs just check if the dlls are are already there to skip the unpack.

I'm unique, just like everybody else.

Login to post a reply

Server time is: 2024-06-24 13:43:13
Your offset time is: 2024-06-24 13:43:13