Execute binary from memory in C# .net with binary protected from a 3rd party software

Posted by NoobTom on Stack Overflow See other posts from Stack Overflow or by NoobTom
Published on 2012-04-10T11:26:03Z Indexed on 2012/04/10 11:28 UTC
Read the original article Hit count: 256

Filed under:
|
|
|

i've the following scenario:

  1. i've a C# application.exe

  2. i pack application.exe inside TheMida, a software anti-piracy/reverse engineering.

  3. i encrypt application.exe with aes256. (i wrote my own aes encryption/decryption and it is working)

Now, when i want to execute my application i do the following:

  1. decrypt application.exe in memory

  2. execute the application.exe with the following code:

            BinaryReader br = new BinaryReader(decOutput);
            byte[] bin = br.ReadBytes(Convert.ToInt32(decOutput.Length));
            decOutput.Close();
            br.Close();
    
            // load the bytes into Assembly
            Assembly a = Assembly.Load(bin);
            // search for the Entry Point
            MethodInfo method = a.EntryPoint;
            if (method != null) {
                // create an istance of the Startup form Main method
                object o = a.CreateInstance(method.Name);
                // invoke the application starting point
                method.Invoke(o, null);
    
  3. the application does not execute correctly.

Now, the problem i think, is that this method is only to execute .NET executable.

Since i packed my application.exe inside TheMida this does not work. Is there a workaround to this situation? Any suggestion?

Thank you in advance.

© Stack Overflow or respective owner

Related posts about c#

Related posts about security