Skip to content
Advertisement

MacOS Create a Process in suspended state

Use-case

  1. Create a new process ( running an arbitrary application ) in suspended mode ( using eg. exec )
  2. Process created ( MachO loaded ) but no single line of code executed
  3. Do some stuff w/ the suspended process memory
  4. Resume the process

On windows, once can use CreateProcess in conjunction with the “CREATE_SUSPENDED” to achieve the above mentioned.

Is there a “CREATE_SUSPENDED” C++/Obj-C equivalent for MacOS ???
( NSTask created in suspended mode is an equivalent of what I am looking for )

Advertisement

Answer

You can use posix_spawn() with a spawn attribute of POSIX_SPAWN_START_SUSPENDED.

It’s a bit of a pain to use but will do what you want, however I am unsure how you can access the memory of the child process.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement