Run a process from memory in another process?

I would like to have a small application loader program that receives other binary application files via TCP from an external server and runs them.

I could do this by saving the transferred file to the hard drive and using the system () call to run it. However, I am wondering if it is possible to launch a new application from memory without touching the hard drive.

The state of the bootloader application does not matter after loading a new application. I prefer to stick with C, but C ++ solutions are also welcome. I would also like to stick with the standard Linux C features and not use any external libraries if possible.

+5
source share
3 answers

The short answer is no.

: , , . -, , , , , , - .

- ASAP. "" , tmpfs .

, , - , - LLVM, JIT'd// . , .

fmemopen, fileno fexecve, :

  • fexecve() manpage:

    " fd , , "

    .. fd, .

  • fmemopen() manpage:

    " , , (.. fileno(3) , )"

+3

, , C tmpfs. , //, exec. , .

, , , , , "" ( ) .

  • ,
  • tmpfs
  • ftruncate
  • "" mmap,
  • recv
  • munmap
  • exec
  • rm . , .
0

You can look at and reuse UPX , which decompresses the executable into memory, and then transfers control to ld-linuxrun it.

0
source

All Articles