1

It show only defination of function inside the class . For egs. I open Read function but it shows only definition like

public override int Read([In,Out], byte buffer[], int offset,int count)

But .Net reflector shows everything about my .dll file including logic.

Please help i want to hide my logic like microsoft .dll files

Glenn Ferrie
  • 10,290
  • 3
  • 42
  • 73
newuser
  • 27
  • 4
  • Exact function name could help... Or at least attributes from the function... – Alexei Levenkov May 21 '15 at 04:37
  • you should write your code in C++ – Glenn Ferrie May 21 '15 at 04:56
  • This is from System.IO namespace. BinaryReader Class Read() function – newuser May 21 '15 at 05:04
  • I can use Reflector to open System.IO.BinaryReader.Read (and others). Perhaps you're using Reflector incorrectly? – Hawkmooon May 21 '15 at 05:26
  • I want to know Code written in C++ can not be able to read by any reflector or tool. Is it completely safe or not. – newuser May 21 '15 at 12:52
  • @GlennFerrie It helps, because C++ isn't so easy to read back as code. Though any skilled reverse engineer can give you code that looks very close to it. I recommend putting your code behind a website. So only the result is shown, never the code itself (that generated the page/result). – Measurity May 21 '15 at 14:05
  • Hey @Measuring -- Here's some more info. the source code for the .NET Base Class Library (BCL) is available online for educational purposes. your answer is in there. There are details in my response here: http://stackoverflow.com/questions/15105575/how-is-reflection-implemented-in-c/15170733#15170733 – Glenn Ferrie May 22 '15 at 01:11
  • If i use WCF C# dll. Then it is safe. If i place all my important code in WCF dll and Add web service reference .Is it safe or not – newuser May 22 '15 at 04:41
  • @newuser Yes, if the code is run on a server instead of on the client, it's safe. You'll provide important code though a service using WCF like you said. – Measurity May 22 '15 at 15:07
  • If you don't mind please do accept the answer, if it solved your problem, so that it would be helpful for others as well. – Rohit Vipin Mathews Aug 02 '16 at 10:27

2 Answers2

4

You can't prevent a managed-DLL from being opened in a decompiler, all what you can do is to obfuscate it. You can use tools like Dotfuscator to obfuscate your code.

From the official site

Dotfuscator provides all “normal” obfuscation methodologies in addition to many unique ones. No obfuscation technology is 100 percent secure. As with other obfuscators, Dotfuscator makes life more difficult for decompilers and disassemblers; it does not claim 100 percent protection.

A few things it accomplishes are :

  • Identifier Renaming
  • Control Flow Obfuscation
  • User String Encryption
  • Watermarking
  • Tamper Notification and Runtime Intelligence with SO-signal
Rohit Vipin Mathews
  • 11,629
  • 15
  • 57
  • 112
  • I used Dotfuscator but it is not the complete solution for this. It just changes the function name.. – newuser May 21 '15 at 13:31
  • @newuser There's only one real way to protect your code. And that is to not give it away. Obfuscated, encrypted, whatever or not, there are tools to undo/assist in seeing your code anyway. You'll need to rethink your architecture if you want no one to see it. – Measurity May 21 '15 at 14:00
0

This is what the source code from the BCL looks like for that method:

 public virtual int Read(byte[] buffer, int index, int count) {
        if (buffer==null)
            throw new ArgumentNullException("buffer", Environment.GetResourceString("ArgumentNull_Buffer"));
        if (index < 0)
            throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
        if (count < 0)
            throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
        if (buffer.Length - index < count)
            throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen"));

        if (m_stream==null) __Error.FileNotOpen();
        return m_stream.Read(buffer, index, count);
    }

I think you'll need to dig deeper into the source code to find what you're looking for.

Happy Hunting!

BCL source code: https://www.microsoft.com/en-us/download/details.aspx?id=4917

Glenn Ferrie
  • 10,290
  • 3
  • 42
  • 73
  • if i want to make my code look like this .Then what concept i need to implement. – newuser May 22 '15 at 04:12
  • What is your objective? to inspect the code base? Download the source from the link I provided. If you want to get your disassembler to work -- make sure you have the debug symbols loaded. Try using Telerik JustDecompile. I think its a better tool than Reflector. – Glenn Ferrie May 22 '15 at 13:26