Execute binary from memory in C# .net with binary protected from a 3rd party software
- by NoobTom
i've the following scenario:
i've a C# application.exe
i pack application.exe inside TheMida, a software
anti-piracy/reverse engineering.
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:
decrypt application.exe in memory
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);
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.