Visual C code to change parent process of new created process

Hi All,
I have a problem while working in Visual C. I want to change the parent of a newly created process by my own code.
E.g: "I am opening a notepad.exe by using CreateProcess API in Visual Basic 6.0 and another Visual C application is also runing that need to track the newly created process (notepad.exe) . The parent process of newly created process (notepad.exe) is visual basic application from which the notepad.exe in initiated. What i need to do is just change the process parent from visual basic application to whom i want."
Please any one could tell me the answer or any suggestion.
Regards,
Kamran Ali




Answer this question

Visual C code to change parent process of new created process

  • honclfibr

    Hi Martin,
    1. Is there any way to set the parent process of the process that we are creating
    2. Could it possible in VC++ that to track the process hierarchy (means if we had tracked a process already and if another process created from this process.Would we can track this child process as well, becuse it will be in the hierarchy)
    Regards,
    Kamran Ali

  • eax

    It is not possible to change the parent process!

  • jcollake

    We can discuss it here or nowhere...

    Tell me more what you want. If you just want to control if the process is running, this shouldn't be a problem, because you can use the process handle.

    Hooking has nothing to do with this. Hoking is only needed if you need to control the input to a program at any level.

  • SirKnight

    Hi Martin,
    Please tell me why isnot possible.
    Basically i am running DOS application that use the ntmedium.exe.
    Regards,
    Kamran

  • TommK

    Hello Martin,
    Ok. I am running a visual basic application, Which forms as a switching board application for other programms (win or dos based). User by running this application can execute multiple programs that has links to these programs in it. When ever a user run any program (win or dos based) from this application the newly created process takes this application process as parent process. I want to change this inheritance behaviour and when ever the new program opend from this application donot get this application process as parent porcess and open at the same level as this application (means parent of newly created process should be same as the parent of this application).
    Note: I had developed this application in Visual Basic 6.0 and used CreateProcess API for opening new programs(processes).
    Please let me know how i can do this (change parent process) either in Visual basic 6 or Visual C.
    Regards,
    Kamran Ali

  • Bransam72783

    There is simply no function for it in the Win32 API!

  • GeyikBaba

    It is not possible to change the parent of the process after the process is created, there is no way!

    Your description still does not show me the need to set a new process parent!
    What should be the effect

    The process that calls CreateProcess is the one that is the parent. So the only way would be that an application send a message (in any form) to the process that should create the new process. BUT! What about rights and access descriptors. You can not pass them bewteen processes!

    Again: Why do you need it



  • Marvin Hassan

    The function CreateprocessWithLogon can not change the parent process to one you can choose AFAIK it uses always svchost as parent for the new process!

    We know what you want! And AFAIK it is not possible to, so we are asking you:
    Why do you need this
    Do you have any problems to explain this



  • asitkk

    Hi Martin,
    What you think about Hooking.
    Please if possible come on MSN Messenger and send my your MSN ID, so we can discuss it properly.
    Best Wishes,
    Kamran Ali


  • csharpkid

    I want to set Explorer.exe as parent process. Could you send me few lines of code that do the same job.
    Regards,
    Kamran Ali

  • DonovanDicodemy

    Hello.

    You could use WINAPI CreateProcessWithLogonW to set svchost.exe as the parent process.
    You could create a service that you remote against to start your programs.
    Both of these solutions will give you a multitude of new challenges, I think.
    To "set" the parent process is for hackers. If you find a way to do it, I hope virus killers will find out and stop you.

    Hope this helps.


  • Visual C code to change parent process of new created process