Click here to Skip to main content
15,868,292 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
So, i've been developing a DLL to use it in all my applications. As far as i know, you can use DLL's functionality without having to link it at build time. AutoHotKey seems to do exactly that (using DLL's functionality having only .dll file).

So my question is:
• Is there a way to make a DLL "private" so no one can access its functionality?

Edit after accepting the solution: i apologize to everyone: only after reading all the answers i realized that the question i wanted to ask is actually whether there was implemented a design which would allow a user easily make a choice between "public" and "private" DLL.
But all the answers are good, and now i even have more info about this in case i need it in the future. Thank you all!

What I have tried:

It seems really strange, but i don't find any similar questions using Google. Am i from another planet?
Posted
Updated 8-Oct-21 1:03am
v2
Comments
Dave Kreskowiak 8-Oct-21 7:18am    
No, there is no such thing as a "private" DLL in Windows. There is no "simple" option to make a DLL "private".
Avtem 8-Oct-21 7:23am    
Yeah, i see it now!

Assuming you are meaning that you only want your applications to be able to use this DLL and no-one else's then you could require a licence key to be part of every call into it.

Starting point A simple software key useful to protect software components[^]
 
Share this answer
 
Not really, DLL are also konow as "shared libraries". The only thing you can possibly do is edit the DllMain in order to recognize somehow the process that's trying to link it and prevent access on the basis of that.

I never did something like that, but I did alter the DllMain to give different functionalities based on what client used it.

Another solution would be to keep the DLL encrypted and decrypt it at runtime before explicitly linking the functions, maybe there are even OS provided ways to do it - I'm not developing on Windows since 2018 and I was still targeting XP at that time.

Otherwise why bother with a DLL and not simply statically link the code?
 
Share this answer
 
No, not really.
A DLL is a library file - in effect it's an executable that lacks the "stub" that tells Windows where to start running the code.
As such, you can't encrypt it without Windows not knowing what to do with it!

And DLL files are - by design - supposed to be shared by multiple apps, that was part of the original design brief to reduce the size of EXE files by being able to dynamically link libraries (hence the DLL extension) so you had one copy of the library files, and a dozen EXE files that used them.
 
Share this answer
 
Comments
den2k88 8-Oct-21 6:24am    
You actually can, since once encrypted it becomes a standard DLL loadable with LoadModule. I know some company use this approach to have the same licensing / encription DLLs across all their products and only their products.
Avtem 8-Oct-21 6:38am    
Oh, someone's using that? That's interesting!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900