Question

I put a executable file into my project resources and set its build action to "Embedded resource". When I request this resource I get an array of byte. How can I execute this resource as if it is a executable file? If this is possible I prefer a solution without having to write the byte array into a executable file and execute this file.

Was it helpful?

Solution

For managed assemblies, this is easy to do. So I assume that you are referring to unmanaged executables. There is no officially supported way to create an unmanaged process from a file held in memory. The only supported way to do this is to write it to a file and use, CreateProcess or similar.

Having said that, if you are prepared to break the rules, there are plenty of libraries and code samples around that will trick Windows into creating a process from an executable image held in memory. Do be prepared for anti-malware programs to take an interest in your program once it starts doing this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top