I have a program stored in byte array.
Is it possible to run it inside C#?
See Question&Answers more detail:osI have a program stored in byte array.
Is it possible to run it inside C#?
See Question&Answers more detail:osYes. 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.