How to create a child process to an existing process in windows - C/C++

Asked

Viewed 1,003 times

0

I need to call via Createprocess() or another function of windows a process and link to an existing process, it is possible to?

thank you!

  • Specify what you’re looking for, try for an example.

  • One program x is running in windows, I want to via another program, identify this process (this part I’ve already done) and create another process (call another program) linked as sub-process to the program I identified earlier. In linux you use the Fork() command to assign a subprocess to an already running process. I would like to do something similar in windows.

  • What I managed was to create a sub-process of the program I’m running, but I couldn’t create a subprocess of another program (process).

  • How do you do this on Linux? That I know of, fork() only creates child processes of the process invoking it, never of a third process. How is it that a third process, who does not know that won a child, would be able to collect it when finished (via waitpid() and allies)?

  • is true @Wtrmute Fork() creates only its own child. But my question is just this, it is possible to create a process and link to a third?

1 answer

0


Unfortunately, no. The CreateProcess() (as well as the fork() in Unix) create processes linked to the process that created them (for example, they report to it status output, it is from him that they inherit the environment variables, etc..). A third lawsuit wouldn’t know that she had a child raised by someone else to receive the status outgoing or whatever.

If you need to create a process that communicates with an existing one, Windows has several options of Interprocessual Communication (IPC) that you can try to use. But the preexisting process has to support these communication methods.

Ultimately, DebugActiveProcess() and allies (mainly WriteProcessMemory() may allow you (under certain circumstances) to inject information into an active process, but the way to determine variable mapping to memory addresses is extremely non-trivial. Then add code to make the debugged process run CreateProcess() he himself and manages the physical process requires a fairly deep machine language knowledge, and may ultimately fail to meet his true requirement, whatever it may be.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.