-1

I have a source that i get from my website, from this source i dynamically compiled form. My exe is protected and it's on C#, but when i use memory dumper i can easy get source code of my dynamically compiled form. Any way to protect it?

P.S. This is not duplicated thread. I have a good protector and my main program is well protected, so with dotPeek i can get only this dynamically compiled form source code that i load and compile in my main program, so my question is how to protect it? I can only obfuscate form source? Or there other ways?

enter image description here

This is how i compile my form

using System;
using System.CodeDom.Compiler;
using System.IO;
using Microsoft.CSharp;

namespace myForm
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var foo = new CSharpCodeProvider())
            {
                var parameters = new CompilerParameters
                {
                    GenerateInMemory = true,
                    GenerateExecutable = false
                };

                parameters.ReferencedAssemblies.Add("System.dll");
                parameters.ReferencedAssemblies.Add("System.Core.dll");
                parameters.ReferencedAssemblies.Add("System.Drawing.dll");
                parameters.ReferencedAssemblies.Add("System.Windows.Forms.dll");

                var source = File.ReadAllText("form.txt");
                CompilerResults results = foo.CompileAssemblyFromSource(parameters, source);
                Type type = results.CompiledAssembly.GetType("radarHack.mainForm");
            }
        }
    }
}
SLI
  • 713
  • 11
  • 29
  • 2
    You can't : http://stackoverflow.com/questions/506282/protect-net-code-from-reverse-engineering – Xiaoy312 May 11 '16 at 22:08
  • Ye i know that, but i found a good protector. It works fine with my main program and it's really hard to break it, but it's don't protect my dynamically compiled code that i get from txt. Thats my problem – SLI May 11 '16 at 22:11
  • encrypt the text and decrypt it on load... but you do realize the decryption code would have to be in place.... just saying, if you put protection in, it will attract attempts to reverse engineer it regardless of how good a "protector" is. What is the so called protector you are using? – t0mm13b May 11 '16 at 22:32
  • It's private and it's name will give you nothing – SLI May 12 '16 at 13:42
  • What did you mean by *private and its name will give you nothing* in other words, you wrote it yourself? – t0mm13b May 12 '16 at 21:01

1 Answers1

0

Dunno why you guys minus my question. I found a way. I make a dll with my source code and protect it. And now i can use it with Assembly.Load.

Assembly assembly = Assembly.Load(File.ReadAllBytes(Environment.CurrentDirectory + @"\mainForm.dll"));
Type type = assembly.GetType("mainForm");
object form = Activator.CreateInstance(type);
type.InvokeMember("ShowDialog", BindingFlags.Default | BindingFlags.InvokeMethod, null, form, null);

It's better protected, ye i know that with C# it's impossible to make 100% protection, but it will be much harder for cracker that it was before.

enter image description here

So now i checks the information on the server, if it is all ok, the server responds with the protected dll bytes and then i load them with Assemble.Load. A major program is nothing but a code assembly and can only communicate with the server and perform commands + it's does not even know what will be the next step.

SLI
  • 713
  • 11
  • 29
  • Here, Stop wasting time and energy in trying to protect the software, sounds like paranoia there for whatever reason you're hiding something. – t0mm13b May 12 '16 at 21:02