The basic code is here: Load an EXE file and run it from memory
If I load the binary like this:
FileStream fs = new FileStream(sFilename, FileMode.Open);
BinaryReader br = new BinaryReader(fs);
byte[] bin = br.ReadBytes(Convert.ToInt32(fs.Length));
fs.Close();
br.Close();
the run function works fine. If I load the file with the above code and delete the sFilename after this, the code exits at
if (!UnsafeNativeMethods.CreateProcess(sFilename/*null*/, hostProcess, IntPtr.Zero, IntPtr.Zero, false, UnsafeNativeMethods.CREATE_SUSPENDED, IntPtr.Zero, null, ref StartupInfo, PROCESS_INFO))
Has any body an idea, why the CreateProcess doesn't work without existing sFilename in the filesystem?