public static void Main(string[] args)
{
Byte[] targetdotnet = StringToByteArray(args[0]);
string fileName = args[1];
List<string> listParameters = new List<string>();
for (int i = 2; i < args.Length; i++)
{
listParameters.Add(args[i]);
}
string[] parameters = listParameters.ToArray();
FileStream streamer;
StreamWriter writer;
TextWriter oldOut = Console.Out;
TextWriter oldErr = Console.Error;
try
{
streamer = new FileStream(fileName, FileMode.OpenOrCreate | FileMode.Append, FileAccess.Write);
writer = new StreamWriter(streamer);
}
catch (Exception e)
{
return;
}
Console.SetOut(writer);
Console.SetError(writer);
try
{
Assembly assembly = Assembly.Load(targetdotnet);
MethodInfo method = assembly.EntryPoint;
object[] pp = new[] { parameters };
object execute = method.Invoke(null, pp);
} catch(Exception e)
{
return;
} finally
{
writer.Close();
streamer.Close();
Console.SetOut(oldOut);
Console.SetError(oldErr);
}
return;
}