mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 17:44:45 +00:00
Let services.exe load the auto-start drivers.
svn path=/trunk/; revision=3023
This commit is contained in:
parent
e1a2eb2f0b
commit
33cc33c731
7 changed files with 692 additions and 131 deletions
|
@ -245,10 +245,11 @@ extern "C" {
|
|||
|
||||
/* ChangeServiceConfig */
|
||||
#define SERVICE_NO_CHANGE (-1)
|
||||
#define SERVICE_KERNEL_DRIVER (1)
|
||||
#define SERVICE_FILE_SYSTEM_DRIVER (2)
|
||||
#define SERVICE_RECOGNIZER_DRIVER (8)
|
||||
#define SERVICE_WIN32_OWN_PROCESS (16)
|
||||
#define SERVICE_WIN32_SHARE_PROCESS (32)
|
||||
#define SERVICE_KERNEL_DRIVER (1)
|
||||
#define SERVICE_FILE_SYSTEM_DRIVER (2)
|
||||
#define SERVICE_INTERACTIVE_PROCESS (256)
|
||||
#define SERVICE_BOOT_START (0)
|
||||
#define SERVICE_SYSTEM_START (1)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: loader.c,v 1.104 2002/05/16 06:41:30 ekohl Exp $
|
||||
/* $Id: loader.c,v 1.105 2002/06/07 20:09:06 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -970,26 +970,6 @@ VOID LdrLoadAutoConfigDrivers (VOID)
|
|||
* NDIS library
|
||||
*/
|
||||
LdrLoadAutoConfigDriver(L"ndis.sys");
|
||||
|
||||
/*
|
||||
* Novell Eagle 2000 driver
|
||||
*/
|
||||
//LdrLoadAutoConfigDriver(L"ne2000.sys");
|
||||
|
||||
/*
|
||||
* TCP/IP protocol driver
|
||||
*/
|
||||
LdrLoadAutoConfigDriver(L"tcpip.sys");
|
||||
|
||||
/*
|
||||
* TDI test driver
|
||||
*/
|
||||
//LdrLoadAutoConfigDriver(L"tditest.sys");
|
||||
|
||||
/*
|
||||
* Ancillary Function Driver
|
||||
*/
|
||||
LdrLoadAutoConfigDriver(L"afd.sys");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
508
reactos/subsys/system/services/database.c
Normal file
508
reactos/subsys/system/services/database.c
Normal file
|
@ -0,0 +1,508 @@
|
|||
/* $Id: database.c,v 1.1 2002/06/07 20:09:56 ekohl Exp $
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#define NTOS_MODE_USER
|
||||
#include <ntos.h>
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include "services.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
|
||||
/* TYPES *********************************************************************/
|
||||
|
||||
typedef struct _SERVICE_GROUP
|
||||
{
|
||||
LIST_ENTRY GroupListEntry;
|
||||
PWSTR GroupName;
|
||||
|
||||
BOOLEAN ServicesRunning;
|
||||
|
||||
} SERVICE_GROUP, *PSERVICE_GROUP;
|
||||
|
||||
|
||||
typedef struct _SERVICE
|
||||
{
|
||||
LIST_ENTRY ServiceListEntry;
|
||||
PWSTR ServiceName;
|
||||
PWSTR GroupName;
|
||||
|
||||
PWSTR ImagePath;
|
||||
|
||||
ULONG Start;
|
||||
ULONG Type;
|
||||
ULONG ErrorControl;
|
||||
ULONG Tag;
|
||||
|
||||
BOOLEAN ServiceRunning; // needed ??
|
||||
|
||||
} SERVICE, *PSERVICE;
|
||||
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
LIST_ENTRY GroupListHead = {NULL, NULL};
|
||||
|
||||
LIST_ENTRY ServiceListHead = {NULL, NULL};
|
||||
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
|
||||
static NTSTATUS STDCALL
|
||||
CreateGroupListRoutine(PWSTR ValueName,
|
||||
ULONG ValueType,
|
||||
PVOID ValueData,
|
||||
ULONG ValueLength,
|
||||
PVOID Context,
|
||||
PVOID EntryContext)
|
||||
{
|
||||
PSERVICE_GROUP Group;
|
||||
|
||||
if (ValueType == REG_SZ)
|
||||
{
|
||||
// PrintString("Data: '%S'\n", (PWCHAR)ValueData);
|
||||
|
||||
Group = (PSERVICE_GROUP)HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
sizeof(SERVICE_GROUP));
|
||||
if (Group == NULL)
|
||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||
|
||||
|
||||
Group->GroupName = (PWSTR)HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
ValueLength);
|
||||
if (Group->GroupName == NULL)
|
||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||
|
||||
wcscpy(Group->GroupName,
|
||||
(PWSTR)ValueData);
|
||||
|
||||
|
||||
InsertTailList(&GroupListHead,
|
||||
&Group->GroupListEntry);
|
||||
|
||||
|
||||
}
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
static NTSTATUS STDCALL
|
||||
CreateServiceListEntry(PUNICODE_STRING ServiceName)
|
||||
{
|
||||
RTL_QUERY_REGISTRY_TABLE QueryTable[6];
|
||||
WCHAR ServiceGroupBuffer[MAX_PATH];
|
||||
WCHAR ImagePathBuffer[MAX_PATH];
|
||||
UNICODE_STRING ServiceGroup;
|
||||
UNICODE_STRING ImagePath;
|
||||
PSERVICE_GROUP Group;
|
||||
PSERVICE Service;
|
||||
NTSTATUS Status;
|
||||
|
||||
// PrintString("Service: '%wZ'\n", ServiceName);
|
||||
|
||||
Service = (PSERVICE)HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
sizeof(SERVICE));
|
||||
if (Service == NULL)
|
||||
{
|
||||
PrintString(" - HeapAlloc() (1) failed\n");
|
||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||
}
|
||||
|
||||
Service->ServiceName = (PWSTR)HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
ServiceName->Length);
|
||||
if (Service->ServiceName == NULL)
|
||||
{
|
||||
PrintString(" - HeapAlloc() (2) failed\n");
|
||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||
}
|
||||
|
||||
wcscpy(Service->ServiceName,
|
||||
ServiceName->Buffer);
|
||||
|
||||
|
||||
ServiceGroup.Length = 0;
|
||||
ServiceGroup.MaximumLength = MAX_PATH * sizeof(WCHAR);
|
||||
ServiceGroup.Buffer = ServiceGroupBuffer;
|
||||
RtlZeroMemory(ServiceGroupBuffer,
|
||||
MAX_PATH * sizeof(WCHAR));
|
||||
|
||||
ImagePath.Length = 0;
|
||||
ImagePath.MaximumLength = MAX_PATH * sizeof(WCHAR);
|
||||
ImagePath.Buffer = ImagePathBuffer;
|
||||
RtlZeroMemory(ImagePathBuffer,
|
||||
MAX_PATH * sizeof(WCHAR));
|
||||
|
||||
|
||||
/* Get service data */
|
||||
RtlZeroMemory(&QueryTable,
|
||||
sizeof(QueryTable));
|
||||
|
||||
QueryTable[0].Name = L"Start";
|
||||
QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED;
|
||||
QueryTable[0].EntryContext = &Service->Start;
|
||||
|
||||
QueryTable[1].Name = L"Type";
|
||||
QueryTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED;
|
||||
QueryTable[1].EntryContext = &Service->Type;
|
||||
|
||||
QueryTable[2].Name = L"ErrorControl";
|
||||
QueryTable[2].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED;
|
||||
QueryTable[2].EntryContext = &Service->ErrorControl;
|
||||
|
||||
QueryTable[3].Name = L"Group";
|
||||
QueryTable[3].Flags = RTL_QUERY_REGISTRY_DIRECT;
|
||||
QueryTable[3].EntryContext = &ServiceGroup;
|
||||
|
||||
QueryTable[4].Name = L"ImagePath";
|
||||
QueryTable[4].Flags = RTL_QUERY_REGISTRY_DIRECT;
|
||||
QueryTable[4].EntryContext = &ImagePath;
|
||||
|
||||
|
||||
Status = RtlQueryRegistryValues(RTL_REGISTRY_SERVICES,
|
||||
ServiceName->Buffer,
|
||||
QueryTable,
|
||||
NULL,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
PrintString("RtlQueryRegistryValues() failed (Status %lx)\n", Status);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
/* Copy the service group name */
|
||||
if (ServiceGroup.Length > 0)
|
||||
{
|
||||
Service->GroupName = (PWSTR)HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
ServiceGroup.Length + sizeof(WCHAR));
|
||||
if (Service->GroupName == NULL)
|
||||
{
|
||||
PrintString(" - HeapAlloc() (3) failed\n");
|
||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||
}
|
||||
|
||||
memcpy(Service->GroupName,
|
||||
ServiceGroup.Buffer,
|
||||
ServiceGroup.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
Service->GroupName = NULL;
|
||||
}
|
||||
|
||||
/* Copy the image path */
|
||||
if (ImagePath.Length > 0)
|
||||
{
|
||||
Service->ImagePath = (PWSTR)HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
ImagePath.Length + sizeof(WCHAR));
|
||||
if (Service->ImagePath == NULL)
|
||||
{
|
||||
PrintString(" - HeapAlloc() (4) failed\n");
|
||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||
}
|
||||
|
||||
memcpy(Service->ImagePath,
|
||||
ImagePath.Buffer,
|
||||
ImagePath.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
Service->ImagePath = NULL;
|
||||
}
|
||||
|
||||
// PrintString(" Type: %lx\n", Service->Type);
|
||||
// PrintString(" Start: %lx\n", Service->Start);
|
||||
// PrintString(" Group: '%wZ'\n", &ServiceGroup);
|
||||
|
||||
|
||||
/* Append service entry */
|
||||
InsertTailList(&ServiceListHead,
|
||||
&Service->ServiceListEntry);
|
||||
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
ScmCreateServiceDataBase(VOID)
|
||||
{
|
||||
RTL_QUERY_REGISTRY_TABLE QueryTable[2];
|
||||
WCHAR NameBuffer[MAX_PATH];
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING ServicesKeyName;
|
||||
UNICODE_STRING SubKeyName;
|
||||
HKEY ServicesKey;
|
||||
NTSTATUS Status;
|
||||
ULONG Index;
|
||||
|
||||
/* Initialize basic variables */
|
||||
InitializeListHead(&GroupListHead);
|
||||
InitializeListHead(&ServiceListHead);
|
||||
|
||||
|
||||
/* Build group order list */
|
||||
RtlZeroMemory(&QueryTable,
|
||||
sizeof(QueryTable));
|
||||
|
||||
QueryTable[0].Name = L"List";
|
||||
QueryTable[0].QueryRoutine = CreateGroupListRoutine;
|
||||
|
||||
Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL,
|
||||
L"ServiceGroupOrder",
|
||||
QueryTable,
|
||||
NULL,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return(Status);
|
||||
|
||||
|
||||
RtlInitUnicodeString(&ServicesKeyName,
|
||||
L"\\Registry\\Machine\\System\\CurrentControlSet\\Services");
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&ServicesKeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = RtlpNtOpenKey(&ServicesKey,
|
||||
0x10001,
|
||||
&ObjectAttributes,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return(Status);
|
||||
|
||||
SubKeyName.Length = 0;
|
||||
SubKeyName.MaximumLength = MAX_PATH * sizeof(WCHAR);
|
||||
SubKeyName.Buffer = NameBuffer;
|
||||
|
||||
Index = 0;
|
||||
while (TRUE)
|
||||
{
|
||||
Status = RtlpNtEnumerateSubKey(ServicesKey,
|
||||
&SubKeyName,
|
||||
Index,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
break;
|
||||
|
||||
CreateServiceListEntry(&SubKeyName);
|
||||
|
||||
Index++;
|
||||
}
|
||||
|
||||
// PrintString("ScmCreateServiceDataBase() done\n");
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
ScmGetBootAndSystemDriverState(VOID)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
static NTSTATUS
|
||||
ScmLoadDriver(PSERVICE Service)
|
||||
{
|
||||
WCHAR ServicePath[MAX_PATH];
|
||||
UNICODE_STRING DriverPath;
|
||||
|
||||
// PrintString("ScmLoadDriver(%S) called\n", Service->ServiceName);
|
||||
|
||||
if (Service->ImagePath == NULL)
|
||||
{
|
||||
wcscpy(ServicePath, L"\\SystemRoot\\system32\\drivers\\");
|
||||
wcscat(ServicePath, Service->ServiceName);
|
||||
wcscat(ServicePath, L".sys");
|
||||
}
|
||||
else
|
||||
{
|
||||
wcscpy(ServicePath, L"\\SystemRoot\\");
|
||||
wcscat(ServicePath, Service->ImagePath);
|
||||
}
|
||||
|
||||
RtlInitUnicodeString(&DriverPath, ServicePath);
|
||||
|
||||
// PrintString(" DriverPath: '%wZ'\n", &DriverPath);
|
||||
|
||||
return(NtLoadDriver(&DriverPath));
|
||||
}
|
||||
|
||||
|
||||
static NTSTATUS
|
||||
ScmStartService(PSERVICE Service)
|
||||
{
|
||||
#if 0
|
||||
PROCESS_INFORMATION ProcessInformation;
|
||||
STARTUPINFO StartupInfo;
|
||||
WCHAR CommandLine[MAX_PATH];
|
||||
BOOL Result;
|
||||
#endif
|
||||
|
||||
PrintString("ScmStartService(%S) called\n", Service->ServiceName);
|
||||
|
||||
#if 0
|
||||
GetSystemDirectoryW(CommandLine, MAX_PATH);
|
||||
_tcscat(CommandLine, "\\");
|
||||
_tcscat(CommandLine, FileName);
|
||||
|
||||
PrintString("SCM: %s\n", CommandLine);
|
||||
|
||||
/* FIXME: create '\\.\pipe\net\NtControlPipe' instance */
|
||||
|
||||
StartupInfo.cb = sizeof(StartupInfo);
|
||||
StartupInfo.lpReserved = NULL;
|
||||
StartupInfo.lpDesktop = NULL;
|
||||
StartupInfo.lpTitle = NULL;
|
||||
StartupInfo.dwFlags = 0;
|
||||
StartupInfo.cbReserved2 = 0;
|
||||
StartupInfo.lpReserved2 = 0;
|
||||
|
||||
Result = CreateProcessW(CommandLine,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
FALSE,
|
||||
DETACHED_PROCESS,
|
||||
NULL,
|
||||
NULL,
|
||||
&StartupInfo,
|
||||
&ProcessInformation);
|
||||
if (!Result)
|
||||
{
|
||||
/* FIXME: close control pipe */
|
||||
|
||||
PrintString("SCM: Failed to start '%s'\n", FileName);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
/* FIXME: connect control pipe */
|
||||
#endif
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
ScmAutoStartServices(VOID)
|
||||
{
|
||||
PLIST_ENTRY GroupEntry;
|
||||
PLIST_ENTRY ServiceEntry;
|
||||
PSERVICE_GROUP CurrentGroup;
|
||||
PSERVICE CurrentService;
|
||||
NTSTATUS Status;
|
||||
|
||||
GroupEntry = GroupListHead.Flink;
|
||||
while (GroupEntry != &GroupListHead)
|
||||
{
|
||||
CurrentGroup = CONTAINING_RECORD(GroupEntry, SERVICE_GROUP, GroupListEntry);
|
||||
|
||||
// PrintString(" %S\n", CurrentGroup->GroupName);
|
||||
|
||||
ServiceEntry = ServiceListHead.Flink;
|
||||
while (ServiceEntry != &ServiceListHead)
|
||||
{
|
||||
CurrentService = CONTAINING_RECORD(ServiceEntry, SERVICE, ServiceListEntry);
|
||||
|
||||
if ((wcsicmp(CurrentGroup->GroupName, CurrentService->GroupName) == 0) &&
|
||||
(CurrentService->Start == SERVICE_AUTO_START))
|
||||
{
|
||||
if (CurrentService->Type == SERVICE_KERNEL_DRIVER ||
|
||||
CurrentService->Type == SERVICE_FILE_SYSTEM_DRIVER ||
|
||||
CurrentService->Type == SERVICE_RECOGNIZER_DRIVER)
|
||||
{
|
||||
/* Load driver */
|
||||
Status = ScmLoadDriver(CurrentService);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Start service */
|
||||
Status = ScmStartService(CurrentService);
|
||||
}
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
CurrentGroup->ServicesRunning = TRUE;
|
||||
CurrentService->ServiceRunning = TRUE;
|
||||
}
|
||||
#if 0
|
||||
else
|
||||
{
|
||||
if (CurrentService->ErrorControl == 1)
|
||||
{
|
||||
/* Log error */
|
||||
|
||||
}
|
||||
else if (CurrentService->ErrorControl == 2)
|
||||
{
|
||||
if (IsLastKnownGood == FALSE)
|
||||
{
|
||||
/* Boot last known good configuration */
|
||||
|
||||
}
|
||||
}
|
||||
else if (CurrentService->ErrorControl == 3)
|
||||
{
|
||||
if (IsLastKnownGood == FALSE)
|
||||
{
|
||||
/* Boot last known good configuration */
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* BSOD! */
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
ServiceEntry = ServiceEntry->Flink;
|
||||
}
|
||||
|
||||
GroupEntry = GroupEntry->Flink;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: makefile,v 1.3 2001/08/21 20:13:04 chorns Exp $
|
||||
# $Id: makefile,v 1.4 2002/06/07 20:09:56 ekohl Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
|
@ -12,7 +12,7 @@ TARGET_INSTALLDIR = system32
|
|||
|
||||
TARGET_SDKLIBS = ntdll.a kernel32.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o database.o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: services.c,v 1.5 2002/02/08 02:57:05 chorns Exp $
|
||||
/* $Id: services.c,v 1.6 2002/06/07 20:09:57 ekohl Exp $
|
||||
*
|
||||
* service control manager
|
||||
*
|
||||
|
@ -31,12 +31,16 @@
|
|||
|
||||
#define NTOS_MODE_USER
|
||||
#include <ntos.h>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include "services.h"
|
||||
|
||||
#define DBG
|
||||
//#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
|
||||
|
||||
/* GLOBALS ******************************************************************/
|
||||
|
||||
#define PIPE_BUFSIZE 1024
|
||||
|
@ -45,7 +49,8 @@
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
void PrintString (char* fmt,...)
|
||||
void
|
||||
PrintString(char* fmt,...)
|
||||
{
|
||||
#ifdef DBG
|
||||
char buffer[512];
|
||||
|
@ -60,35 +65,36 @@ void PrintString (char* fmt,...)
|
|||
}
|
||||
|
||||
|
||||
BOOL ScmCreateStartEvent(PHANDLE StartEvent)
|
||||
BOOL
|
||||
ScmCreateStartEvent(PHANDLE StartEvent)
|
||||
{
|
||||
HANDLE hEvent;
|
||||
HANDLE hEvent;
|
||||
|
||||
hEvent = CreateEvent(NULL,
|
||||
TRUE,
|
||||
FALSE,
|
||||
_T("SvcctrlStartEvent_A3725DX"));
|
||||
if (hEvent == NULL)
|
||||
{
|
||||
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
hEvent = OpenEvent(EVENT_ALL_ACCESS,
|
||||
FALSE,
|
||||
"SvcctrlStartEvent_A3725DX");
|
||||
if (hEvent == NULL)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
hEvent = CreateEvent(NULL,
|
||||
TRUE,
|
||||
FALSE,
|
||||
_T("SvcctrlStartEvent_A3725DX"));
|
||||
if (hEvent == NULL)
|
||||
{
|
||||
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
hEvent = OpenEvent(EVENT_ALL_ACCESS,
|
||||
FALSE,
|
||||
_T("SvcctrlStartEvent_A3725DX"));
|
||||
if (hEvent == NULL)
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
*StartEvent = hEvent;
|
||||
*StartEvent = hEvent;
|
||||
|
||||
return TRUE;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -167,51 +173,48 @@ BOOL ScmCreateNamedPipe(VOID)
|
|||
HANDLE hThread;
|
||||
HANDLE hPipe;
|
||||
|
||||
hPipe = CreateNamedPipe(
|
||||
"\\\\.\\pipe\\Ntsvcs",
|
||||
PIPE_ACCESS_DUPLEX,
|
||||
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
|
||||
PIPE_UNLIMITED_INSTANCES,
|
||||
PIPE_BUFSIZE,
|
||||
PIPE_BUFSIZE,
|
||||
PIPE_TIMEOUT,
|
||||
NULL);
|
||||
hPipe = CreateNamedPipe("\\\\.\\pipe\\Ntsvcs",
|
||||
PIPE_ACCESS_DUPLEX,
|
||||
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
|
||||
PIPE_UNLIMITED_INSTANCES,
|
||||
PIPE_BUFSIZE,
|
||||
PIPE_BUFSIZE,
|
||||
PIPE_TIMEOUT,
|
||||
NULL);
|
||||
if (hPipe == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DPRINT("CreateNamedPipe() failed (%d)\n", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fConnected = ConnectNamedPipe(
|
||||
hPipe,
|
||||
NULL) ? TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);
|
||||
if (fConnected)
|
||||
{
|
||||
DPRINT("Pipe connected\n");
|
||||
|
||||
hThread = CreateThread(
|
||||
NULL,
|
||||
0,
|
||||
ScmNamedPipeThread,
|
||||
(LPVOID)hPipe,
|
||||
0,
|
||||
&dwThreadId);
|
||||
if (!hThread)
|
||||
{
|
||||
DPRINT("Could not create thread (%d)\n", GetLastError());
|
||||
DPRINT("CreateNamedPipe() failed (%d)\n", GetLastError());
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
fConnected = ConnectNamedPipe(hPipe,
|
||||
NULL) ? TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);
|
||||
if (fConnected)
|
||||
{
|
||||
DPRINT("Pipe connected\n");
|
||||
|
||||
hThread = CreateThread(NULL,
|
||||
0,
|
||||
ScmNamedPipeThread,
|
||||
(LPVOID)hPipe,
|
||||
0,
|
||||
&dwThreadId);
|
||||
if (!hThread)
|
||||
{
|
||||
DPRINT("Could not create thread (%d)\n", GetLastError());
|
||||
|
||||
DisconnectNamedPipe(hPipe);
|
||||
CloseHandle(hPipe);
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT("Pipe not connected\n");
|
||||
|
||||
DisconnectNamedPipe(hPipe);
|
||||
CloseHandle(hPipe);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT("Pipe not connected\n");
|
||||
|
||||
CloseHandle(hPipe);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -223,28 +226,34 @@ WinMain(HINSTANCE hInstance,
|
|||
LPSTR lpCmdLine,
|
||||
int nShowCmd)
|
||||
{
|
||||
HANDLE hScmStartEvent;
|
||||
HANDLE hEvent;
|
||||
|
||||
PrintString("Service Control Manager\n");
|
||||
|
||||
/* Create start event */
|
||||
if (!ScmCreateStartEvent(&hScmStartEvent))
|
||||
{
|
||||
PrintString("SERVICES: Failed to create start event\n");
|
||||
ExitThread(0);
|
||||
}
|
||||
|
||||
HANDLE hScmStartEvent;
|
||||
HANDLE hEvent;
|
||||
NTSTATUS Status;
|
||||
|
||||
PrintString("Service Control Manager\n");
|
||||
|
||||
/* Create start event */
|
||||
if (!ScmCreateStartEvent(&hScmStartEvent))
|
||||
{
|
||||
PrintString("SERVICES: Failed to create start event\n");
|
||||
ExitThread(0);
|
||||
}
|
||||
|
||||
|
||||
/* FIXME: more initialization */
|
||||
|
||||
/* FIXME: more initialization */
|
||||
|
||||
/* FIXME: create service database */
|
||||
// ScmCreateServiceDB();
|
||||
/* Create the service database */
|
||||
Status = ScmCreateServiceDataBase();
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
PrintString("ScmCreateServiceDataBase() failed (Status %lx)\n", Status);
|
||||
ExitThread(0);
|
||||
}
|
||||
|
||||
/* Update service database */
|
||||
ScmGetBootAndSystemDriverState();
|
||||
|
||||
/* FIXME: update service database */
|
||||
// ScmGetBootAndSystemDriverState();
|
||||
#if 0
|
||||
/* Create named pipe */
|
||||
if (!ScmCreateNamedPipe())
|
||||
|
@ -255,31 +264,29 @@ WinMain(HINSTANCE hInstance,
|
|||
#endif
|
||||
/* FIXME: create listener thread for pipe */
|
||||
|
||||
/* FIXME: register process as service process */
|
||||
// RegisterServiceProcess();
|
||||
|
||||
PrintString("SERVICES: Initialized.\n");
|
||||
/* FIXME: register process as service process */
|
||||
// RegisterServiceProcess();
|
||||
|
||||
/* Signal start event */
|
||||
SetEvent(hScmStartEvent);
|
||||
PrintString("SERVICES: Initialized.\n");
|
||||
|
||||
/* FIXME: register event handler (used for system shutdown) */
|
||||
// SetConsoleCtrlHandler(...);
|
||||
/* Signal start event */
|
||||
SetEvent(hScmStartEvent);
|
||||
|
||||
/* FIXME: register event handler (used for system shutdown) */
|
||||
// SetConsoleCtrlHandler(...);
|
||||
|
||||
|
||||
/* FIXME: start auto-start services */
|
||||
// ScmAutoStartServices();
|
||||
/* Start auto-start services */
|
||||
ScmAutoStartServices();
|
||||
|
||||
/* FIXME: more to do ? */
|
||||
/* FIXME: more to do ? */
|
||||
|
||||
|
||||
PrintString("SERVICES: Running.\n");
|
||||
|
||||
hEvent = CreateEvent(NULL,
|
||||
TRUE,
|
||||
FALSE,
|
||||
NULL);
|
||||
WaitForSingleObject(hEvent, INFINITE);
|
||||
PrintString("SERVICES: Running.\n");
|
||||
|
||||
hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
WaitForSingleObject(hEvent, INFINITE);
|
||||
#if 0
|
||||
for (;;)
|
||||
{
|
||||
|
@ -287,10 +294,10 @@ WinMain(HINSTANCE hInstance,
|
|||
}
|
||||
#endif
|
||||
|
||||
PrintString("SERVICES: Finished.\n");
|
||||
PrintString("SERVICES: Finished.\n");
|
||||
|
||||
ExitThread (0);
|
||||
return 0;
|
||||
ExitThread(0);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
19
reactos/subsys/system/services/services.h
Normal file
19
reactos/subsys/system/services/services.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* services.h
|
||||
*/
|
||||
|
||||
|
||||
/* services.c */
|
||||
|
||||
void PrintString(char* fmt,...);
|
||||
|
||||
|
||||
/* database.c */
|
||||
|
||||
NTSTATUS ScmCreateServiceDataBase(VOID);
|
||||
VOID ScmGetBootAndSystemDriverState(VOID);
|
||||
VOID ScmAutoStartServices(VOID);
|
||||
|
||||
|
||||
/* EOF */
|
||||
|
|
@ -38,7 +38,10 @@ REGEDIT4
|
|||
"InstallLanguage"="0409"
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Control\ServiceGroupOrder]
|
||||
"List"="SCSI Port;SCSI Miniport;Primary Disk;SCSI Class Helper;SCSI Class;Boot File System;Base;Pointer Port;Keyboard Port;Pointer Class;Keyboard Class;Video;File System"
|
||||
"List"=multi:"SCSI Port", "SCSI Miniport", "Primary Disk", "SCSI Class Helper", \
|
||||
"SCSI Class", "Boot File System", "Base", "Pointer Port", \
|
||||
"Keyboard Port", "Pointer Class", "Keyboard Class", "Video", \
|
||||
"File System", "NDIS", "PNP_TDI", "TDI", "Extended Base"
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Control\Session Manager]
|
||||
"BootExecute"=multi:"autocheck autochk *"
|
||||
|
@ -63,91 +66,134 @@ REGEDIT4
|
|||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services]
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Afd]
|
||||
"ErrorControl"=dword:00000001
|
||||
"Group"="TDI"
|
||||
"ImagePath"="system32\drivers\afd.sys"
|
||||
"Start"=dword:00000002
|
||||
"Type"=dword:00000001
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Atapi]
|
||||
"ErrorControl"=dword:00000000
|
||||
"Group"="SCSI Miniport"
|
||||
"ImagePath"="system32\drivers\atapi.sys"
|
||||
"Start"=dword:00000000
|
||||
"Type"=dword:00000001
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Beep]
|
||||
"ErrorControl"=dword:00000000
|
||||
"Group"="Base"
|
||||
"ImagePath"="system32\drivers\beep.sys"
|
||||
"Start"=dword:00000001
|
||||
"Type"=dword:00000001
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Cdfs]
|
||||
"ErrorControl"=dword:00000000
|
||||
"Group"="File System"
|
||||
"ImagePath"="system32\drivers\cdfs.sys"
|
||||
"Start"=dword:00000004
|
||||
"Type"=dword:00000002
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Cdrom]
|
||||
"ErrorControl"=dword:00000000
|
||||
"Group"="SCSI Class"
|
||||
"ImagePath"="system32\drivers\cdrom.sys"
|
||||
"Start"=dword:00000000
|
||||
"Type"=dword:00000001
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Class2]
|
||||
"ErrorControl"=dword:00000000
|
||||
"Group"="SCSI Class Helper"
|
||||
"ImagePath"="system32\drivers\class2.sys"
|
||||
"Start"=dword:00000000
|
||||
"Type"=dword:00000001
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Disk]
|
||||
"ErrorControl"=dword:00000000
|
||||
"Group"="SCSI Class"
|
||||
"ImagePath"="system32\drivers\disk.sys"
|
||||
"Start"=dword:00000000
|
||||
"Type"=dword:00000001
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\EventLog]
|
||||
"ErrorControl"=dword:00000000
|
||||
"Group"="Error log"
|
||||
"ImagePath"="%SystemRoot%\system32\services.exe"
|
||||
"Start"=dword:00000004
|
||||
"Type"=dword:00000020
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Floppy]
|
||||
"ErrorControl"=dword:00000000
|
||||
"Group"="Primary Disk"
|
||||
"ImagePath"="system32\drivers\floppy.sys"
|
||||
"Start"=dword:00000001
|
||||
"Type"=dword:00000001
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Fs_Rec]
|
||||
"ErrorControl"=dword:00000000
|
||||
"Group"="Boot file system"
|
||||
"ImagePath"="system32\drivers\fs_rec.sys"
|
||||
"Start"=dword:00000000
|
||||
"Type"=dword:00000008
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Ide]
|
||||
"ErrorControl"=dword:00000000
|
||||
"Group"="Primary Disk"
|
||||
"ImagePath"="system32\drivers\ide.sys"
|
||||
"Start"=dword:00000004
|
||||
"Type"=dword:00000001
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Msfs]
|
||||
"ErrorControl"=dword:00000000
|
||||
"Group"="File System"
|
||||
"ImagePath"="system32\drivers\msfs.sys"
|
||||
"Start"=dword:00000001
|
||||
"Type"=dword:00000002
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Ne2000]
|
||||
"ErrorControl"=dword:00000001
|
||||
"Group"="NDIS"
|
||||
"ImagePath"="system32\drivers\ne2000.sys"
|
||||
"Start"=dword:00000004
|
||||
"Type"=dword:00000001
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Ndis]
|
||||
"ErrorControl"=dword:00000001
|
||||
"Group"="NDIS"
|
||||
"ImagePath"="system32\drivers\ndis.sys"
|
||||
"Start"=dword:00000001
|
||||
"Type"=dword:00000001
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Npfs]
|
||||
"ErrorControl"=dword:00000000
|
||||
"Group"="File System"
|
||||
"ImagePath"="system32\drivers\npfs.sys"
|
||||
"Start"=dword:00000001
|
||||
"Type"=dword:00000002
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Null]
|
||||
"ErrorControl"=dword:00000000
|
||||
"Group"="Base"
|
||||
"ImagePath"="system32\drivers\null.sys"
|
||||
"Start"=dword:00000001
|
||||
"Type"=dword:00000001
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Scsiport]
|
||||
"ErrorControl"=dword:00000000
|
||||
"Group"="SCSI Port"
|
||||
"ImagePath"="system32\drivers\scsiport.sys"
|
||||
"Start"=dword:00000000
|
||||
"Type"=dword:00000001
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Tcpip]
|
||||
"ErrorControl"=dword:00000001
|
||||
"Group"="PNP_TDI"
|
||||
"ImagePath"="system32\drivers\tcpip.sys"
|
||||
"Start"=dword:00000002
|
||||
"Type"=dword:00000001
|
||||
|
||||
[\Registry\Machine\SYSTEM\CurrentControlSet\Services\Vfatfs]
|
||||
"ErrorControl"=dword:00000000
|
||||
"Group"="Boot File System"
|
||||
"ImagePath"="system32\drivers\vfatfs.sys"
|
||||
"Start"=dword:00000000
|
||||
|
|
Loading…
Reference in a new issue