He montado este codigo, pero me dice que la imagen no es valida.
Creo un array de bytes ( byte[] ) con el archivo dentro y al intentar lanzarlo con Assembly.Load(buffer) me da error.
// alphabet.txt contains "abcdefghijklmnopqrstuvwxyz"
using (FileStream fs
= new FileStream
(@"2.bin", FileMode
.Open, FileAccess
.Read)) {
long length = fs.Length;
Byte[] coming
= new byte[length
]; byte readd;
int i = 0;
FileStream fileStream
= new FileStream
(fileName, FileMode
.Create); for (offset = 1; offset <= fs.Length; offset++)
{
fs.Seek(-offset, SeekOrigin.End);
//Console.Write(Convert.ToChar(fs.ReadByte()));
int readb = fs.ReadByte();
readd = Convert.ToByte(readb);
//fileStream.WriteByte(readd);
coming[i] =readd;
//Console.WriteLine(i);
i++;
//Console.ReadLine();
}
//Console.Write(coming);
MemExe(coming);
}
static void MemExe(byte[] buffer)
{
Assembly asm = Assembly.Load(buffer);//----------------->> AQUI DA EL ERROR.
if (asm.EntryPoint == null)
throw new ApplicationException
("No entry point found!");
MethodInfo ePoint = asm.EntryPoint;
object ins = asm.CreateInstance(ePoint.Name);
ePoint.Invoke(ins, null);
}