0

I have a dll library that I use in one of my projects. I don't want others to be able to link and access the methods in the library. Is it possible to protect it? Thanks!

EDIT: Is there a way to 'hide' method names or make them random inside dll?

Kristian
  • 1,348
  • 4
  • 16
  • 39
  • Is it possible to protect software from being hacked? I would like to know the way :) – David Goshadze Feb 20 '13 at 13:48
  • duplicate question: http://stackoverflow.com/questions/805461/how-to-protect-dlls – Tanner Feb 20 '13 at 13:48
  • It's as possible as preventing unauthorized people from launching your executable. –  Feb 20 '13 at 13:48
  • If some functionality of your program can access your DLL, then what is stopping a crafty reverse engineer from mimicing that functionality? Sorry, but there's no 100% guaranteed answer to this question. – autistic Feb 20 '13 at 13:48
  • well, there is a difference if I put the code into my binary or in dll where person can just import it into a project and start using. – Kristian Feb 20 '13 at 13:51
  • @Kristian - Its not possible to prevent somebody from importing your dll if they have your dll on their system. – Security Hound Feb 20 '13 at 14:01

4 Answers4

0

You can attempt to limit its use by requireing a key. If a wrong key is passed, your library will not work.

This however can be easily circumvented by decompiling your application and check what key you supply and simply use the same key.

Another possibility would be to add a check to every public method on every public class. That check would verify that the calling assembly is one of yours.
Depending on the implementation of this check, it is easily circumvented by creating a small proxy assembly that is named the same as one of yours.

In general: It is not possible to prevent it. Just like with copy protection, everything can be circumvented if the other party has access to your assembly - and I mean the compiled assembly, not the source code.

Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
0

Short answer is no. If somebody wants access to your library they will find a way.

You can obfuscate your library to make things harder for them however, but there is no sure-fire way of preventing them.

Lloyd
  • 29,197
  • 4
  • 84
  • 98
0

One way is Friend Assemblies You can mark your assembly internal and only specified assemblies can access your library.

But it just forbids to use your library in "easy way".

Dmitrii Dovgopolyi
  • 6,231
  • 2
  • 27
  • 44
0

You can protect your libraries and executables from anuthorized using with help of third party products like Sentinel Hasp, but it will cost to your application in performance, cost to you some money and it is not garanteed that nobody will break it. But to break protection pirates should work hard.

Kirill Bestemyanov
  • 11,946
  • 2
  • 24
  • 38