diff --git a/reactos/base/system/services/config.c b/reactos/base/system/services/config.c index 922a3967952..6ecda57189f 100644 --- a/reactos/base/system/services/config.c +++ b/reactos/base/system/services/config.c @@ -1,5 +1,10 @@ /* - * config.c + * PROJECT: ReactOS Service Control Manager + * LICENSE: GPL - See COPYING in the top level directory + * FILE: base/system/services/config.c + * PURPOSE: Service configuration interface + * COPYRIGHT: Copyright 2005 Eric Kohl + * */ /* INCLUDES *****************************************************************/ diff --git a/reactos/base/system/services/database.c b/reactos/base/system/services/database.c index 140c10ce75d..4bb79519e5e 100644 --- a/reactos/base/system/services/database.c +++ b/reactos/base/system/services/database.c @@ -1,25 +1,11 @@ /* - * - * service control manager - * - * ReactOS Operating System - * - * -------------------------------------------------------------------- - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.LIB. If not, write - * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, - * MA 02139, USA. + * PROJECT: ReactOS Service Control Manager + * LICENSE: GPL - See COPYING in the top level directory + * FILE: base/system/services/database.c + * PURPOSE: Database control interface + * COPYRIGHT: Copyright 2002-2006 Eric Kohl + * Copyright 2006 Hervé Poussineau + * Copyright 2007 Ged Murphy * */ @@ -439,6 +425,18 @@ ScmCreateServiceDatabase(VOID) } +VOID +ScmShutdownServiceDatabase(VOID) +{ + DPRINT("ScmShutdownServiceDatabase() called\n"); + + ScmDeleteMarkedServices(); + RtlDeleteResource(&DatabaseLock); + + DPRINT("ScmShutdownServiceDatabase() done\n"); +} + + static NTSTATUS ScmCheckDriver(PSERVICE Service) { @@ -1000,4 +998,32 @@ ScmAutoStartServices(VOID) } } + +VOID +ScmAutoShutdownServices(VOID) +{ + PLIST_ENTRY ServiceEntry; + PSERVICE CurrentService; + SERVICE_STATUS ServiceStatus; + + DPRINT("ScmAutoShutdownServices() called\n"); + + ServiceEntry = ServiceListHead.Flink; + while (ServiceEntry != &ServiceListHead) + { + CurrentService = CONTAINING_RECORD(ServiceEntry, SERVICE, ServiceListEntry); + + if (CurrentService->Status.dwCurrentState == SERVICE_RUNNING || + CurrentService->Status.dwCurrentState == SERVICE_START_PENDING) + { + /* shutdown service */ + ScmControlService(CurrentService, SERVICE_CONTROL_STOP, &ServiceStatus); + } + + ServiceEntry = ServiceEntry->Flink; + } + + DPRINT("ScmGetBootAndSystemDriverState() done\n"); +} + /* EOF */ diff --git a/reactos/base/system/services/driver.c b/reactos/base/system/services/driver.c index 9fd18abe4df..bc7889792d5 100644 --- a/reactos/base/system/services/driver.c +++ b/reactos/base/system/services/driver.c @@ -1,5 +1,10 @@ /* - * driver.c + * PROJECT: ReactOS Service Control Manager + * LICENSE: GPL - See COPYING in the top level directory + * FILE: base/system/services/driver.c + * PURPOSE: Driver control interface + * COPYRIGHT: Copyright 2005-2006 Eric Kohl + * */ /* INCLUDES *****************************************************************/ diff --git a/reactos/base/system/services/groupdb.c b/reactos/base/system/services/groupdb.c index 4b2ffee1448..bedfca57ad3 100644 --- a/reactos/base/system/services/groupdb.c +++ b/reactos/base/system/services/groupdb.c @@ -1,5 +1,10 @@ /* - * groupdb.c + * PROJECT: ReactOS Service Control Manager + * LICENSE: GPL - See COPYING in the top level directory + * FILE: base/system/services/groupdb.c + * PURPOSE: Service group control interface + * COPYRIGHT: Copyright 2005 Eric Kohl + * */ /* INCLUDES *****************************************************************/ diff --git a/reactos/base/system/services/rpcserver.c b/reactos/base/system/services/rpcserver.c index 62d12756afd..4bf657a9822 100644 --- a/reactos/base/system/services/rpcserver.c +++ b/reactos/base/system/services/rpcserver.c @@ -1,5 +1,12 @@ /* - + * PROJECT: ReactOS Service Control Manager + * LICENSE: GPL - See COPYING in the top level directory + * FILE: base/system/services/rpcserver.c + * PURPOSE: RPC server interface for the advapi32 calls + * COPYRIGHT: Copyright 2005-2006 Eric Kohl + * Copyright 2006-2007 Hervé Poussineau + * Copyright 2007 Ged Murphy + * */ /* INCLUDES ****************************************************************/ diff --git a/reactos/base/system/services/services.c b/reactos/base/system/services/services.c index 60ad9fd45a1..f89f5858070 100644 --- a/reactos/base/system/services/services.c +++ b/reactos/base/system/services/services.c @@ -1,24 +1,10 @@ /* - * service control manager - * - * ReactOS Operating System - * - * -------------------------------------------------------------------- - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.LIB. If not, write - * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, - * MA 02139, USA. + * PROJECT: ReactOS Service Control Manager + * LICENSE: GPL - See COPYING in the top level directory + * FILE: base/system/services/services.c + * PURPOSE: Main SCM controller + * COPYRIGHT: Copyright 2001-2005 Eric Kohl + * Copyright 2007 Ged Murphy * */ @@ -298,7 +284,8 @@ ShutdownHandlerRoutine(DWORD dwCtrlType) DPRINT1("Shutdown event received!\n"); ScmShutdown = TRUE; - /* FIXME: Shut all services down */ + ScmAutoShutdownServices(); + ScmShutdownServiceDatabase(); } return TRUE; @@ -378,6 +365,8 @@ WinMain(HINSTANCE hInstance, } #endif + CloseHandle(hScmStartEvent); + DPRINT("SERVICES: Finished.\n"); ExitThread(0); diff --git a/reactos/base/system/services/services.h b/reactos/base/system/services/services.h index f823a7816aa..a0f5e72fd5f 100644 --- a/reactos/base/system/services/services.h +++ b/reactos/base/system/services/services.h @@ -94,8 +94,10 @@ DWORD ScmReadString(HKEY hServiceKey, /* database.c */ DWORD ScmCreateServiceDatabase(VOID); +VOID ScmShutdownServiceDatabase(VOID); VOID ScmGetBootAndSystemDriverState(VOID); VOID ScmAutoStartServices(VOID); +VOID ScmAutoShutdownServices(VOID); DWORD ScmStartService(PSERVICE Service, LPWSTR lpArgs);