I have a program stored in byte array.
Is it possible to run it inside C#?
Yes. This answer shows you can directly execute the contents of a byte array. Basically, you use VirtualAlloc to allocate an executable region on the heap with a known address (a IntPtr). You then copy your byte array to that address with Marshal.Copy. You convert the pointer to a delegate with GetDelegateForFunctionPointer, and finally call it as a normal delegate.
VirtualAlloc
IntPtr
Marshal.Copy
GetDelegateForFunctionPointer
2.1m questions
2.1m answers
60 comments
57.0k users