Monday, May 24, 2010

How to make a c# dll that cannot be referenced by other project?

i've made a c# program,one exe and one dll,


now i just want my dll can only be used by the exe file,and it cannot be referenced by other project,so that the public members of the dll are inaccessible to others. and it cannot be parsed by the MSIL Disassembler program in Visual Studio Tools





help me please...


help me,

How to make a c# dll that cannot be referenced by other project?
The short answer is you cannot, but you can make it difficult.





Read on for the long answer if you care.





What it sounds like you want to do is use some sort of a DRM solution. The basic concept behind DRM is that you have your files encrypted, and only give the decryption keys to programs that are trusted not to do things you don't want them to.





In this case because it is an actual program or part of a program then you need to have windows do the decryption, or decrypt it yourself just before windows uses it, but that leaves a lot of other security holes. The problem is that Windows does not support this type of thing natively, so you have to write, or buy, extensions to Windows that will.





But, Windows also supports debugging tools and hibernate which can give someone else access to your unencrypted dll in RAM so you have to patch windows to some how keep other people from seeing the dll through these interfaces. But even then someone can load up your program and through some hardware hacks read the RAM out of your computer on another computer that is not trying to protect it. Or run windows in a simulation of a computer and just pull the unencrypted data out of where ever windows decided to put it.





If what you are trying to hide is valuable then just give up now. Sony, Microsoft, Apple and many many others have all tried this sort of thing and all of them have been cracked, because you cannot keep something secret if you do not control the hardware it is running on. What is more trying to keep people out may just tell those very people that something here is valuable and make them want to get in.





What you can do, and this will keep out most of the people is first don't use a dll. Why split the program up into two if you don't have to, especially if you don't want anyone but your program using your dll. Second strip out all unnecessary debug info. Most script kiddies will not go looking inside a single program and even if they do with no debug info most will give up fairly quickly, but not all. And stripping a program is common enough everywhere that real hackers will not think twice about it.





You also could try and use an obfuscater to make your program more confusing and jumbled, but again that is likely to just draw attention and make people try and hack in.





If you do find a way to truly protect the data on an untrusted computer then patent it quick. You will make some very serious money selling it to every Music, Movie, and Game company out there.


No comments:

Post a Comment