Auto-restart killed process

J

Jay

Hey There,
Can anyone point in me in the direction of what the procedure is for
a code that will launch a process and have it be protected by Windows
in the sense that if it is killed, it is automatically re-launched? I
have seen viruses do this, and am trying to reproduce that methodology.
Just to assure anyone out there, this is NOT for creating a virus. This
is for legitimate code that will be used.

-Jay
(patelj27b at gmail dot com)
 
B

Bruno van Dooren

Hey There,
Can anyone point in me in the direction of what the procedure is for
a code that will launch a process and have it be protected by Windows
in the sense that if it is killed, it is automatically re-launched? I
have seen viruses do this, and am trying to reproduce that methodology.
Just to assure anyone out there, this is NOT for creating a virus. This
is for legitimate code that will be used.

-Jay
(patelj27b at gmail dot com)

one way to do this is using 2 processes. they can monitor each other, and if
one process sees that the other one disappears, it can launch a new
instance.

of course, you would also have to design a mechanism for enabling them to
shutdown properly (using events for example). otherwise it is impossible to
end the processes without restarting them when you want them to end.

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
W

William DePalo [MVP VC++]

Jay said:
Can anyone point in me in the direction of what the procedure is for
a code that will launch a process and have it be protected by Windows
in the sense that if it is killed, it is automatically re-launched? I
have seen viruses do this, and am trying to reproduce that methodology.

You need another application to monitor the one whose continued execution
you care about. It waits on the target's process handle and when signalled,
calls CreateProcess() to resurrect it.

The Service Control Manager has logic to monitor the lifetime of services.
Just realize that it takes an administrator to install a service and that
service processes (should) have no UI.
Just to assure anyone out there, this is NOT for creating a virus. This
is for legitimate code that will be used.

:)

Regards,
Will
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top