Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 Jul : Killing Processes and Starting Services from within a System Service

www.cryer.info
Managed Newsgroup Archive

Killing Processes and Starting Services from within a System Service

Subject:Killing Processes and Starting Services from within a System Service
Posted by:"Brett Watters" (bwatte..@geometrix.bc.ca)
Date:Fri, 8 Jul 2005 12:11:54

Hi,

I'm trying to execute code from within the SYSTEM service which
can both kill another service and restart it. It's an ISAPI.DLL which
I'd like to be able to terminate another service and restart it.

It should be possible since I know that the Interbase Guardian service
does this with the Interbase service when it goes down. I have found
some code  for both.


The KillProcess uses
a) Code to set privilages for SeDbugPrivilage.
b) OpenProcess, and
c) TerminateProcess

It works perfectly in non-system space against a normal service.
However, in SYSTEM space, the code can't adjust privilages.

The code to restart a service uses:
a) OpenSCManager with GENERIC_EXECUTE permissions, and
b) OpenService calls.

Again, it works when logged in, but in SYSTEM space, the
OpenSCManager call won't operate with the GENERIC_EXECUTE
permissions?


Does anyone know of a way to get this code to work from within
a SYSTEM service?

Thanks,

Brett

Replies:

www.cryer.info
Managed Newsgroup Archive