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
1.4m articles
1.4m replys
5 comments
57.0k users