Sign in to follow this  

Load a DLL embedded in a file

This topic is 3744 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all. I'm loading dynamically a DLL using LoadLibrary and GetProcAddress to get functions. This work very fine. Now, I want to embedded that DLL into a pak of my own. So the informations I have, is the offset position in the pak file of my DLL. The DLL is in there at it's total integrity. I'm wondering if there is not a windows call to acheive this? Similar to LoadLibrary, but which let me specify the filename (As now) AND an offset position where it starts in it. Thanks :)

Share this post


Link to post
Share on other sites
Hum that's complicated :|

I've tried his library, and it doesn't load it. I pass the exact same file in *data and can't load it.

There is really no simple "win32" way of doing this??

Share this post


Link to post
Share on other sites
Quote:
Original post by Mike.Popoloski
If you know the offset position, how hard could it be to write it out to a temporary file?


It's easy, but I don't really like the idea.
Because if the app crash (Shouldn't) but let say. The user will have all the DLL in the folders! Hax issue, ergonomic issue.

And I can have multiple module with the exact same name.
It's the pak name that change, but inside I have mainWin32.dlh for example.
So I would have to increment and name the files this way:
01~.tmp
02~.tmp
03~.tmp

I really don't like the idea ;)

Better solutions?

Share this post


Link to post
Share on other sites
Just out of curiosity why do you need to have a dll embeded into a pack file?

(Sorry for not being helpful. The temp file sound like a good idea to me too)

Edit: Ok,

All packs have different names? You could try to create a temp file using FILE_FLAG_DELETE_ON_CLOSE, and name your file like yourPakName.mainWin32.dll ?

Stills sounds like a hack though.

JA

Share this post


Link to post
Share on other sites
Quote:
Original post by janta
Just out of curiosity why do you need to have a dll embeded into a pack file?


because if we want to distribute the pack let say in a web player. We have only one file to get (like an swf) and we can include both .dll and .so (for linux and mac) into this pack :)

There are lot more reason too.

Share this post


Link to post
Share on other sites
If you're only reason is that you don't want the user to see the DLL, you should really rethink your design. If it is only "hidden" by an offset, you really won't be able to hide anything that you deem to be important.

In fact, in your situation I would have an unpacker utility that would take a big PAK file downloaded from the server and unpack it into the application folder. Then, you could easily load all the files from disk, probably speeding up load times. Besides, you really can't hide anything client side. If it's on the client's computer, it can be discovered.

Share this post


Link to post
Share on other sites
Ya that's true, it's more for Practical and esthetic's.
One pack is practical. If the app crashes, you have temp files left all over :S...

That's the only issue here.

I think I'll do that anyway :(

Share this post


Link to post
Share on other sites
As I said, I think that FILE_FLAG_DELETE_ON_CLOSE (see CreateFile) would allow you to create a file that automatically deletes itself when no more handles refer to it (which happens when you program crashes) You should check it out.

However, I think it would not work in case of a power failure. You program needs to terminate (in any way, correctly or crashing) for this to work (I think...)

JA

Share this post


Link to post
Share on other sites

This topic is 3744 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this