Update indentation.
Modified: trunk/reactos/subsys/system/services/database.c
Modified: trunk/reactos/subsys/system/services/rpcserver.c
Modified: trunk/reactos/subsys/system/services/services.c
_____
Modified: trunk/reactos/subsys/system/services/database.c
--- trunk/reactos/subsys/system/services/database.c 2005-10-22
18:59:39 UTC (rev 18685)
+++ trunk/reactos/subsys/system/services/database.c 2005-10-22
19:46:00 UTC (rev 18686)
@@ -58,29 +58,29 @@
PSERVICE
ScmGetServiceEntryByName(LPWSTR lpServiceName)
{
- PLIST_ENTRY ServiceEntry;
- PSERVICE CurrentService;
+ PLIST_ENTRY ServiceEntry;
+ PSERVICE CurrentService;
- DPRINT("ScmGetServiceEntryByName() called\n");
+ DPRINT("ScmGetServiceEntryByName() called\n");
- ServiceEntry = ServiceListHead.Flink;
- while (ServiceEntry != &ServiceListHead)
+ ServiceEntry = ServiceListHead.Flink;
+ while (ServiceEntry != &ServiceListHead)
{
- CurrentService = CONTAINING_RECORD(ServiceEntry,
- SERVICE,
- ServiceListEntry);
- if (_wcsicmp(CurrentService->lpServiceName, lpServiceName) == 0)
- {
- DPRINT("Found service: '%S'\n",
CurrentService->lpServiceName);
- return CurrentService;
- }
+ CurrentService = CONTAINING_RECORD(ServiceEntry,
+ SERVICE,
+ ServiceListEntry);
+ if (_wcsicmp(CurrentService->lpServiceName, lpServiceName) ==
0)
+ {
+ DPRINT("Found service: '%S'\n",
CurrentService->lpServiceName);
+ return CurrentService;
+ }
- ServiceEntry = ServiceEntry->Flink;
+ ServiceEntry = ServiceEntry->Flink;
}
- DPRINT("Couldn't find a matching service\n");
+ DPRINT("Couldn't find a matching service\n");
- return NULL;
+ return NULL;
}
@@ -135,11 +135,11 @@
static NTSTATUS STDCALL
CreateGroupListRoutine(PWSTR ValueName,
- ULONG ValueType,
- PVOID ValueData,
- ULONG ValueLength,
- PVOID Context,
- PVOID EntryContext)
+ ULONG ValueType,
+ PVOID ValueData,
+ ULONG ValueLength,
+ PVOID Context,
+ PVOID EntryContext)
{
PSERVICE_GROUP Group;
RTL_QUERY_REGISTRY_TABLE QueryTable[2];
@@ -185,734 +185,735 @@
static NTSTATUS STDCALL
CreateServiceListEntry(LPWSTR lpServiceName)
{
- RTL_QUERY_REGISTRY_TABLE QueryTable[6];
- UNICODE_STRING ServiceName;
- PSERVICE Service = NULL;
- NTSTATUS Status;
+ RTL_QUERY_REGISTRY_TABLE QueryTable[6];
+ UNICODE_STRING ServiceName;
+ PSERVICE Service = NULL;
+ NTSTATUS Status;
- DPRINT("Service: '%wZ'\n", ServiceName);
+ DPRINT("Service: '%wZ'\n", ServiceName);
- /* Allocate service entry */
- Service = HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- sizeof(SERVICE) + ((wcslen(lpServiceName) + 1) *
sizeof(WCHAR)));
- if (Service == NULL)
+ /* Allocate service entry */
+ Service = HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ sizeof(SERVICE) + ((wcslen(lpServiceName) + 1)
* sizeof(WCHAR)));
+ if (Service == NULL)
{
- return STATUS_INSUFFICIENT_RESOURCES;
+ return STATUS_INSUFFICIENT_RESOURCES;
}
- /* Copy service name */
- wcscpy(Service->szServiceName, lpServiceName);
- Service->lpServiceName = Service->szServiceName;
+ /* Copy service name */
+ wcscpy(Service->szServiceName, lpServiceName);
+ Service->lpServiceName = Service->szServiceName;
- /* Get service data */
- RtlZeroMemory(&QueryTable,
- sizeof(QueryTable));
+ /* 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->dwStartType;
+ QueryTable[0].Name = L"Start";
+ QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT |
RTL_QUERY_REGISTRY_REQUIRED;
+ QueryTable[0].EntryContext = &Service->dwStartType;
- QueryTable[1].Name = L"Type";
- QueryTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT |
RTL_QUERY_REGISTRY_REQUIRED;
- QueryTable[1].EntryContext = &Service->Status.dwServiceType;
+ QueryTable[1].Name = L"Type";
+ QueryTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT |
RTL_QUERY_REGISTRY_REQUIRED;
+ QueryTable[1].EntryContext = &Service->Status.dwServiceType;
- QueryTable[2].Name = L"ErrorControl";
- QueryTable[2].Flags = RTL_QUERY_REGISTRY_DIRECT |
RTL_QUERY_REGISTRY_REQUIRED;
- QueryTable[2].EntryContext = &Service->dwErrorControl;
+ QueryTable[2].Name = L"ErrorControl";
+ QueryTable[2].Flags = RTL_QUERY_REGISTRY_DIRECT |
RTL_QUERY_REGISTRY_REQUIRED;
+ QueryTable[2].EntryContext = &Service->dwErrorControl;
- QueryTable[3].Name = L"Group";
- QueryTable[3].Flags = RTL_QUERY_REGISTRY_DIRECT;
- QueryTable[3].EntryContext = &Service->ServiceGroup;
+ QueryTable[3].Name = L"Group";
+ QueryTable[3].Flags = RTL_QUERY_REGISTRY_DIRECT;
+ QueryTable[3].EntryContext = &Service->ServiceGroup;
- QueryTable[4].Name = L"Tag";
- QueryTable[4].Flags = RTL_QUERY_REGISTRY_DIRECT;
- QueryTable[4].EntryContext = &Service->dwTag;
+ QueryTable[4].Name = L"Tag";
+ QueryTable[4].Flags = RTL_QUERY_REGISTRY_DIRECT;
+ QueryTable[4].EntryContext = &Service->dwTag;
- Status = RtlQueryRegistryValues(RTL_REGISTRY_SERVICES,
- lpServiceName,
- QueryTable,
- NULL,
- NULL);
- if (!NT_SUCCESS(Status))
+ Status = RtlQueryRegistryValues(RTL_REGISTRY_SERVICES,
+ lpServiceName,
+ QueryTable,
+ NULL,
+ NULL);
+ if (!NT_SUCCESS(Status))
{
- PrintString("RtlQueryRegistryValues() failed (Status %lx)\n",
Status);
- HeapFree(GetProcessHeap(), 0, Service);
- return Status;
+ PrintString("RtlQueryRegistryValues() failed (Status %lx)\n",
Status);
+ HeapFree(GetProcessHeap(), 0, Service);
+ return Status;
}
- DPRINT("ServiceName: '%S'\n", Service->lpServiceName);
- DPRINT("ServiceGroup: '%wZ'\n", &Service->ServiceGroup);
- DPRINT("Start %lx Type %lx Tag %lx ErrorControl %lx\n",
- Service->dwStartType,
- Service->Status.dwServiceType,
- Service->dwTag,
- Service->dwErrorControl);
+ DPRINT("ServiceName: '%S'\n", Service->lpServiceName);
+ DPRINT("ServiceGroup: '%wZ'\n", &Service->ServiceGroup);
+ DPRINT("Start %lx Type %lx Tag %lx ErrorControl %lx\n",
+ Service->dwStartType,
+ Service->Status.dwServiceType,
+ Service->dwTag,
+ Service->dwErrorControl);
- /* Append service entry */
- InsertTailList(&ServiceListHead,
- &Service->ServiceListEntry);
+ /* Append service entry */
+ InsertTailList(&ServiceListHead,
+ &Service->ServiceListEntry);
- Service->Status.dwCurrentState = SERVICE_STOPPED;
- Service->Status.dwControlsAccepted = 0;
- Service->Status.dwWin32ExitCode = 0;
- Service->Status.dwServiceSpecificExitCode = 0;
- Service->Status.dwCheckPoint = 0;
- Service->Status.dwWaitHint = 2000; /* 2 seconds */
+ Service->Status.dwCurrentState = SERVICE_STOPPED;
+ Service->Status.dwControlsAccepted = 0;
+ Service->Status.dwWin32ExitCode = 0;
+ Service->Status.dwServiceSpecificExitCode = 0;
+ Service->Status.dwCheckPoint = 0;
+ Service->Status.dwWaitHint = 2000; /* 2 seconds */
- return STATUS_SUCCESS;
+ return STATUS_SUCCESS;
}
NTSTATUS
ScmCreateServiceDataBase(VOID)
{
- RTL_QUERY_REGISTRY_TABLE QueryTable[2];
- OBJECT_ATTRIBUTES ObjectAttributes;
- UNICODE_STRING ServicesKeyName =
-
RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Se
rvices");
- UNICODE_STRING SubKeyName;
- HKEY ServicesKey;
- ULONG Index;
- NTSTATUS Status;
+ RTL_QUERY_REGISTRY_TABLE QueryTable[2];
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING ServicesKeyName =
+
RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Se
rvices");
+ UNICODE_STRING SubKeyName;
+ HKEY ServicesKey;
+ ULONG Index;
+ NTSTATUS Status;
- PKEY_BASIC_INFORMATION KeyInfo = NULL;
- ULONG KeyInfoLength = 0;
- ULONG ReturnedLength;
+ PKEY_BASIC_INFORMATION KeyInfo = NULL;
+ ULONG KeyInfoLength = 0;
+ ULONG ReturnedLength;
- DPRINT("ScmCreateServiceDataBase() called\n");
+ DPRINT("ScmCreateServiceDataBase() called\n");
- /* Initialize basic variables */
- InitializeListHead(&GroupListHead);
- InitializeListHead(&ServiceListHead);
+ /* Initialize basic variables */
+ InitializeListHead(&GroupListHead);
+ InitializeListHead(&ServiceListHead);
- /* Initialize the database lock */
- RtlInitializeResource(&DatabaseLock);
+ /* Initialize the database lock */
+ RtlInitializeResource(&DatabaseLock);
- /* Build group order list */
- RtlZeroMemory(&QueryTable,
- sizeof(QueryTable));
+ /* Build group order list */
+ RtlZeroMemory(&QueryTable,
+ sizeof(QueryTable));
- QueryTable[0].Name = L"List";
- QueryTable[0].QueryRoutine = CreateGroupListRoutine;
+ 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;
+ Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL,
+ L"ServiceGroupOrder",
+ QueryTable,
+ NULL,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ return Status;
- RtlInitUnicodeString(&ServicesKeyName,
-
L"\\Registry\\Machine\\System\\CurrentControlSet\\Services");
+ RtlInitUnicodeString(&ServicesKeyName,
+
L"\\Registry\\Machine\\System\\CurrentControlSet\\Services");
- InitializeObjectAttributes(&ObjectAttributes,
- &ServicesKeyName,
- OBJ_CASE_INSENSITIVE,
- NULL,
- NULL);
+ InitializeObjectAttributes(&ObjectAttributes,
+ &ServicesKeyName,
+ OBJ_CASE_INSENSITIVE,
+ NULL,
+ NULL);
- Status = RtlpNtOpenKey(&ServicesKey,
- KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS,
- &ObjectAttributes,
- 0);
- if (!NT_SUCCESS(Status))
- return Status;
+ Status = RtlpNtOpenKey(&ServicesKey,
+ KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS,
+ &ObjectAttributes,
+ 0);
+ if (!NT_SUCCESS(Status))
+ return Status;
- /* Allocate key info buffer */
- KeyInfoLength = sizeof(KEY_BASIC_INFORMATION) + MAX_PATH *
sizeof(WCHAR);
- KeyInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
KeyInfoLength);
- if (KeyInfo == NULL)
+ /* Allocate key info buffer */
+ KeyInfoLength = sizeof(KEY_BASIC_INFORMATION) + MAX_PATH *
sizeof(WCHAR);
+ KeyInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
KeyInfoLength);
+ if (KeyInfo == NULL)
{
- NtClose(ServicesKey);
- return STATUS_INSUFFICIENT_RESOURCES;
+ NtClose(ServicesKey);
+ return STATUS_INSUFFICIENT_RESOURCES;
}
- Index = 0;
- while (TRUE)
+ Index = 0;
+ while (TRUE)
{
- Status = NtEnumerateKey(ServicesKey,
- Index,
- KeyBasicInformation,
- KeyInfo,
- KeyInfoLength,
- &ReturnedLength);
- if (NT_SUCCESS(Status))
- {
- if (KeyInfo->NameLength < MAX_PATH * sizeof(WCHAR))
- {
+ Status = NtEnumerateKey(ServicesKey,
+ Index,
+ KeyBasicInformation,
+ KeyInfo,
+ KeyInfoLength,
+ &ReturnedLength);
+ if (NT_SUCCESS(Status))
+ {
+ if (KeyInfo->NameLength < MAX_PATH * sizeof(WCHAR))
+ {
+ SubKeyName.Length = KeyInfo->NameLength;
+ SubKeyName.MaximumLength = KeyInfo->NameLength +
sizeof(WCHAR);
+ SubKeyName.Buffer = KeyInfo->Name;
+ SubKeyName.Buffer[SubKeyName.Length / sizeof(WCHAR)] =
0;
- SubKeyName.Length = KeyInfo->NameLength;
- SubKeyName.MaximumLength = KeyInfo->NameLength +
sizeof(WCHAR);
- SubKeyName.Buffer = KeyInfo->Name;
- SubKeyName.Buffer[SubKeyName.Length / sizeof(WCHAR)] = 0;
+ DPRINT("KeyName: '%wZ'\n", &SubKeyName);
+ Status = CreateServiceListEntry(SubKeyName.Buffer);
- DPRINT("KeyName: '%wZ'\n", &SubKeyName);
- Status = CreateServiceListEntry(SubKeyName.Buffer);
+ /* Ignore services without proper registry. */
+ if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
+ {
+ Status = STATUS_SUCCESS;
+ }
+ }
+ }
- /* Ignore services without proper registry. */
- if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
- {
- Status = STATUS_SUCCESS;
- }
- }
- }
+ if (!NT_SUCCESS(Status))
+ break;
- if (!NT_SUCCESS(Status))
- break;
-
- Index++;
+ Index++;
}
- HeapFree(GetProcessHeap(), 0, KeyInfo);
- NtClose(ServicesKey);
+ HeapFree(GetProcessHeap(), 0, KeyInfo);
+ NtClose(ServicesKey);
- DPRINT("ScmCreateServiceDataBase() done\n");
+ DPRINT("ScmCreateServiceDataBase() done\n");
- return STATUS_SUCCESS;
+ return STATUS_SUCCESS;
}
static NTSTATUS
ScmCheckDriver(PSERVICE Service)
{
- OBJECT_ATTRIBUTES ObjectAttributes;
- UNICODE_STRING DirName;
- HANDLE DirHandle;
- NTSTATUS Status;
- POBJECT_DIRECTORY_INFORMATION DirInfo;
- ULONG BufferLength;
- ULONG DataLength;
- ULONG Index;
- PLIST_ENTRY GroupEntry;
- PSERVICE_GROUP CurrentGroup;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING DirName;
+ HANDLE DirHandle;
+ NTSTATUS Status;
+ POBJECT_DIRECTORY_INFORMATION DirInfo;
+ ULONG BufferLength;
+ ULONG DataLength;
+ ULONG Index;
+ PLIST_ENTRY GroupEntry;
+ PSERVICE_GROUP CurrentGroup;
- DPRINT("ScmCheckDriver(%S) called\n", Service->lpServiceName);
+ DPRINT("ScmCheckDriver(%S) called\n", Service->lpServiceName);
- if (Service->Status.dwServiceType == SERVICE_KERNEL_DRIVER)
+ if (Service->Status.dwServiceType == SERVICE_KERNEL_DRIVER)
{
- RtlInitUnicodeString(&DirName,
- L"\\Driver");
+ RtlInitUnicodeString(&DirName,
+ L"\\Driver");
}
- else
+ else
{
- RtlInitUnicodeString(&DirName,
- L"\\FileSystem");
+ RtlInitUnicodeString(&DirName,
+ L"\\FileSystem");
}
- InitializeObjectAttributes(&ObjectAttributes,
- &DirName,
- 0,
- NULL,
- NULL);
+ InitializeObjectAttributes(&ObjectAttributes,
+ &DirName,
+ 0,
+ NULL,
+ NULL);
- Status = NtOpenDirectoryObject(&DirHandle,
- DIRECTORY_QUERY | DIRECTORY_TRAVERSE,
- &ObjectAttributes);
- if (!NT_SUCCESS(Status))
+ Status = NtOpenDirectoryObject(&DirHandle,
+ DIRECTORY_QUERY |
DIRECTORY_TRAVERSE,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
{
- return Status;
+ return Status;
}
- BufferLength = sizeof(OBJECT_DIRECTORY_INFORMATION) +
- 2 * MAX_PATH * sizeof(WCHAR);
- DirInfo = HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- BufferLength);
+ BufferLength = sizeof(OBJECT_DIRECTORY_INFORMATION) +
+ 2 * MAX_PATH * sizeof(WCHAR);
+ DirInfo = HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ BufferLength);
- Index = 0;
- while (TRUE)
+ Index = 0;
+ while (TRUE)
{
- Status = NtQueryDirectoryObject(DirHandle,
- DirInfo,
- BufferLength,
- TRUE,
- FALSE,
- &Index,
- &DataLength);
- if (Status == STATUS_NO_MORE_ENTRIES)
- {
- /* FIXME: Add current service to 'failed service' list */
- DPRINT("Service '%S' failed\n", Service->lpServiceName);
- break;
- }
+ Status = NtQueryDirectoryObject(DirHandle,
+ DirInfo,
+ BufferLength,
+ TRUE,
+ FALSE,
+ &Index,
+ &DataLength);
+ if (Status == STATUS_NO_MORE_ENTRIES)
+ {
+ /* FIXME: Add current service to 'failed service' list */
+ DPRINT("Service '%S' failed\n",
Service->lpServiceName);
+ break;
+ }
- if (!NT_SUCCESS(Status))
- break;
+ if (!NT_SUCCESS(Status))
+ break;
- DPRINT("Comparing: '%S' '%wZ'\n",
Service->lpServiceName,
&DirInfo->ObjectName);
+ DPRINT("Comparing: '%S' '%wZ'\n",
Service->lpServiceName,
&DirInfo->ObjectName);
- if (_wcsicmp(Service->lpServiceName, DirInfo->ObjectName.Buffer)
== 0)
- {
- DPRINT("Found: '%S' '%wZ'\n", Service->lpServiceName,
&DirInfo->ObjectName);
+ if (_wcsicmp(Service->lpServiceName,
DirInfo->ObjectName.Buffer) == 0)
+ {
+ DPRINT("Found: '%S' '%wZ'\n",
+ Service->lpServiceName, &DirInfo->ObjectName);
- /* Mark service as 'running' */
- Service->Status.dwCurrentState = SERVICE_RUNNING;
+ /* Mark service as 'running' */
+ Service->Status.dwCurrentState = SERVICE_RUNNING;
- /* Find the driver's group and mark it as 'running' */
- if (Service->ServiceGroup.Buffer != NULL)
- {
- GroupEntry = GroupListHead.Flink;
- while (GroupEntry != &GroupListHead)
- {
- CurrentGroup = CONTAINING_RECORD(GroupEntry,
SERVICE_GROUP, GroupListEntry);
+ /* Find the driver's group and mark it as 'running' */
+ if (Service->ServiceGroup.Buffer != NULL)
+ {
+ GroupEntry = GroupListHead.Flink;
+ while (GroupEntry != &GroupListHead)
+ {
+ CurrentGroup = CONTAINING_RECORD(GroupEntry,
SERVICE_GROUP, GroupListEntry);
- DPRINT("Checking group '%wZ'\n",
&CurrentGroup->GroupName);
- if (RtlEqualUnicodeString(&Service->ServiceGroup,
&CurrentGroup->GroupName, TRUE))
- {
- CurrentGroup->ServicesRunning = TRUE;
- }
+ DPRINT("Checking group '%wZ'\n",
&CurrentGroup->GroupName);
+ if (RtlEqualUnicodeString(&Service->ServiceGroup,
&CurrentGroup->GroupName, TRUE))
+ {
+ CurrentGroup->ServicesRunning = TRUE;
+ }
- GroupEntry = GroupEntry->Flink;
- }
- }
- break;
- }
+ GroupEntry = GroupEntry->Flink;
+ }
+ }
+ break;
+ }
}
- HeapFree(GetProcessHeap(),
- 0,
- DirInfo);
- NtClose(DirHandle);
+ HeapFree(GetProcessHeap(),
+ 0,
+ DirInfo);
+ NtClose(DirHandle);
- return STATUS_SUCCESS;
+ return STATUS_SUCCESS;
}
VOID
ScmGetBootAndSystemDriverState(VOID)
{
- PLIST_ENTRY ServiceEntry;
- PSERVICE CurrentService;
+ PLIST_ENTRY ServiceEntry;
+ PSERVICE CurrentService;
- DPRINT("ScmGetBootAndSystemDriverState() called\n");
+ DPRINT("ScmGetBootAndSystemDriverState() called\n");
- ServiceEntry = ServiceListHead.Flink;
- while (ServiceEntry != &ServiceListHead)
+ ServiceEntry = ServiceListHead.Flink;
+ while (ServiceEntry != &ServiceListHead)
{
- CurrentService = CONTAINING_RECORD(ServiceEntry, SERVICE,
ServiceListEntry);
+ CurrentService = CONTAINING_RECORD(ServiceEntry, SERVICE,
ServiceListEntry);
- if (CurrentService->dwStartType == SERVICE_BOOT_START ||
- CurrentService->dwStartType == SERVICE_SYSTEM_START)
- {
- /* Check driver */
- DPRINT(" Checking service: %S\n",
CurrentService->lpServiceName);
+ if (CurrentService->dwStartType == SERVICE_BOOT_START ||
+ CurrentService->dwStartType == SERVICE_SYSTEM_START)
+ {
+ /* Check driver */
+ DPRINT(" Checking service: %S\n",
CurrentService->lpServiceName);
- ScmCheckDriver(CurrentService);
- }
- ServiceEntry = ServiceEntry->Flink;
+ ScmCheckDriver(CurrentService);
+ }
+
+ ServiceEntry = ServiceEntry->Flink;
}
- DPRINT("ScmGetBootAndSystemDriverState() done\n");
+ DPRINT("ScmGetBootAndSystemDriverState() done\n");
}
static NTSTATUS
ScmSendStartCommand(PSERVICE Service, LPWSTR Arguments)
{
- PSCM_START_PACKET StartPacket;
- DWORD TotalLength;
+ PSCM_START_PACKET StartPacket;
+ DWORD TotalLength;
#if 0
- DWORD Length;
+ DWORD Length;
#endif
- PWSTR Ptr;
- DWORD Count;
+ PWSTR Ptr;
+ DWORD Count;
- DPRINT("ScmSendStartCommand() called\n");
+ DPRINT("ScmSendStartCommand() called\n");
- /* Calculate the total length of the start command line */
- TotalLength = wcslen(Service->lpServiceName) + 1;
+ /* Calculate the total length of the start command line */
+ TotalLength = wcslen(Service->lpServiceName) + 1;
#if 0
- if (Arguments != NULL)
- {
- Ptr = Arguments;
- while (*Ptr)
+ if (Arguments != NULL)
{
- Length = wcslen(Ptr) + 1;
- TotalLength += Length;
- Ptr += Length;
+ Ptr = Arguments;
+ while (*Ptr)
+ {
+ Length = wcslen(Ptr) + 1;
+ TotalLength += Length;
+ Ptr += Length;
+ }
}
- }
#endif
- TotalLength++;
+ TotalLength++;
- /* Allocate start command packet */
- StartPacket = HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- sizeof(SCM_START_PACKET) + (TotalLength - 1) *
sizeof(WCHAR));
- if (StartPacket == NULL)
- return STATUS_INSUFFICIENT_RESOURCES;
+ /* Allocate start command packet */
+ StartPacket = HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ sizeof(SCM_START_PACKET) + (TotalLength -
1) * sizeof(WCHAR));
+ if (StartPacket == NULL)
+ return STATUS_INSUFFICIENT_RESOURCES;
- StartPacket->Command = SCM_START_COMMAND;
- StartPacket->Size = TotalLength;
- Ptr = &StartPacket->Arguments[0];
- wcscpy(Ptr, Service->lpServiceName);
- Ptr += (wcslen(Service->lpServiceName) + 1);
+ StartPacket->Command = SCM_START_COMMAND;
+ StartPacket->Size = TotalLength;
+ Ptr = &StartPacket->Arguments[0];
+ wcscpy(Ptr, Service->lpServiceName);
+ Ptr += (wcslen(Service->lpServiceName) + 1);
- /* FIXME: Copy argument list */
+ /* FIXME: Copy argument list */
- *Ptr = 0;
+ *Ptr = 0;
- /* Send the start command */
- WriteFile(Service->ControlPipeHandle,
- StartPacket,
- sizeof(SCM_START_PACKET) + (TotalLength - 1) *
sizeof(WCHAR),
- &Count,
- NULL);
+ /* Send the start command */
+ WriteFile(Service->ControlPipeHandle,
+ StartPacket,
+ sizeof(SCM_START_PACKET) + (TotalLength - 1) *
sizeof(WCHAR),
+ &Count,
+ NULL);
- /* FIXME: Read the reply */
+ /* FIXME: Read the reply */
- HeapFree(GetProcessHeap(),
- 0,
- StartPacket);
+ HeapFree(GetProcessHeap(),
+ 0,
+ StartPacket);
- DPRINT("ScmSendStartCommand() done\n");
+ DPRINT("ScmSendStartCommand() done\n");
- return STATUS_SUCCESS;
+ return STATUS_SUCCESS;
}
static NTSTATUS
ScmStartUserModeService(PSERVICE Service)
{
- RTL_QUERY_REGISTRY_TABLE QueryTable[3];
- PROCESS_INFORMATION ProcessInformation;
- STARTUPINFOW StartupInfo;
- UNICODE_STRING ImagePath;
- ULONG Type;
- BOOL Result;
- NTSTATUS Status;
+ RTL_QUERY_REGISTRY_TABLE QueryTable[3];
+ PROCESS_INFORMATION ProcessInformation;
+ STARTUPINFOW StartupInfo;
+ UNICODE_STRING ImagePath;
+ ULONG Type;
+ BOOL Result;
+ NTSTATUS Status;
- RtlInitUnicodeString(&ImagePath, NULL);
+ RtlInitUnicodeString(&ImagePath, NULL);
- /* Get service data */
- RtlZeroMemory(&QueryTable,
- sizeof(QueryTable));
+ /* Get service data */
+ RtlZeroMemory(&QueryTable,
+ sizeof(QueryTable));
- QueryTable[0].Name = L"Type";
- QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT |
RTL_QUERY_REGISTRY_REQUIRED;
- QueryTable[0].EntryContext = &Type;
+ QueryTable[0].Name = L"Type";
+ QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT |
RTL_QUERY_REGISTRY_REQUIRED;
+ QueryTable[0].EntryContext = &Type;
- QueryTable[1].Name = L"ImagePath";
- QueryTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT |
RTL_QUERY_REGISTRY_REQUIRED;
- QueryTable[1].EntryContext = &ImagePath;
+ QueryTable[1].Name = L"ImagePath";
+ QueryTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT |
RTL_QUERY_REGISTRY_REQUIRED;
+ QueryTable[1].EntryContext = &ImagePath;
- Status = RtlQueryRegistryValues(RTL_REGISTRY_SERVICES,
- Service->lpServiceName,
- QueryTable,
- NULL,
- NULL);
- if (!NT_SUCCESS(Status))
+ Status = RtlQueryRegistryValues(RTL_REGISTRY_SERVICES,
+ Service->lpServiceName,
+ QueryTable,
+ NULL,
+ NULL);
+ if (!NT_SUCCESS(Status))
{
- DPRINT1("RtlQueryRegistryValues() failed (Status %lx)\n",
Status);
- return Status;
+ DPRINT1("RtlQueryRegistryValues() failed (Status %lx)\n",
Status);
+ return Status;
}
- DPRINT("ImagePath: '%S'\n", ImagePath.Buffer);
- DPRINT("Type: %lx\n", Type);
+ DPRINT("ImagePath: '%S'\n", ImagePath.Buffer);
+ DPRINT("Type: %lx\n", Type);
- /* Create '\\.\pipe\net\NtControlPipe' instance */
- Service->ControlPipeHandle =
CreateNamedPipeW(L"\\\\.\\pipe\\net\\NtControlPipe",
- PIPE_ACCESS_DUPLEX,
- PIPE_TYPE_MESSAGE |
PIPE_READMODE_MESSAGE | PIPE_WAIT,
- 100,
- 8000,
- 4,
- 30000,
- NULL);
- DPRINT("CreateNamedPipeW() done\n");
- if (Service->ControlPipeHandle == INVALID_HANDLE_VALUE)
+ /* Create '\\.\pipe\net\NtControlPipe' instance */
+ Service->ControlPipeHandle =
CreateNamedPipeW(L"\\\\.\\pipe\\net\\NtControlPipe",
+ PIPE_ACCESS_DUPLEX,
+ PIPE_TYPE_MESSAGE |
PIPE_READMODE_MESSAGE | PIPE_WAIT,
+ 100,
+ 8000,
+ 4,
+ 30000,
+ NULL);
+ DPRINT("CreateNamedPipeW() done\n");
+ if (Service->ControlPipeHandle == INVALID_HANDLE_VALUE)
{
- DPRINT1("Failed to create control pipe!\n");
- return STATUS_UNSUCCESSFUL;
+ DPRINT1("Failed to create control pipe!\n");
+ return STATUS_UNSUCCESSFUL;
}
- StartupInfo.cb = sizeof(StartupInfo);
- StartupInfo.lpReserved = NULL;
- StartupInfo.lpDesktop = NULL;
- StartupInfo.lpTitle = NULL;
- StartupInfo.dwFlags = 0;
- StartupInfo.cbReserved2 = 0;
- StartupInfo.lpReserved2 = 0;
+ StartupInfo.cb = sizeof(StartupInfo);
+ StartupInfo.lpReserved = NULL;
+ StartupInfo.lpDesktop = NULL;
+ StartupInfo.lpTitle = NULL;
+ StartupInfo.dwFlags = 0;
+ StartupInfo.cbReserved2 = 0;
+ StartupInfo.lpReserved2 = 0;
- Result = CreateProcessW(ImagePath.Buffer,
- NULL,
- NULL,
- NULL,
- FALSE,
- DETACHED_PROCESS | CREATE_SUSPENDED,
- NULL,
- NULL,
- &StartupInfo,
- &ProcessInformation);
- RtlFreeUnicodeString(&ImagePath);
+ Result = CreateProcessW(ImagePath.Buffer,
+ NULL,
+ NULL,
+ NULL,
+ FALSE,
+ DETACHED_PROCESS | CREATE_SUSPENDED,
+ NULL,
+ NULL,
+ &StartupInfo,
+ &ProcessInformation);
+ RtlFreeUnicodeString(&ImagePath);
- if (!Result)
+ if (!Result)
{
- /* Close control pipe */
- CloseHandle(Service->ControlPipeHandle);
- Service->ControlPipeHandle = INVALID_HANDLE_VALUE;
+ /* Close control pipe */
+ CloseHandle(Service->ControlPipeHandle);
+ Service->ControlPipeHandle = INVALID_HANDLE_VALUE;
- DPRINT1("Starting '%S' failed!\n", Service->lpServiceName);
- return STATUS_UNSUCCESSFUL;
+ DPRINT1("Starting '%S' failed!\n", Service->lpServiceName);
+ return STATUS_UNSUCCESSFUL;
}
- DPRINT("Process Id: %lu Handle %lx\n",
- ProcessInformation.dwProcessId,
- ProcessInformation.hProcess);
- DPRINT("Thread Id: %lu Handle %lx\n",
- ProcessInformation.dwThreadId,
- ProcessInformation.hThread);
+ DPRINT("Process Id: %lu Handle %lx\n",
+ ProcessInformation.dwProcessId,
+ ProcessInformation.hProcess);
+ DPRINT("Thread Id: %lu Handle %lx\n",
+ ProcessInformation.dwThreadId,
+ ProcessInformation.hThread);
- /* Get process and thread ids */
- Service->ProcessId = ProcessInformation.dwProcessId;
- Service->ThreadId = ProcessInformation.dwThreadId;
+ /* Get process and thread ids */
+ Service->ProcessId = ProcessInformation.dwProcessId;
+ Service->ThreadId = ProcessInformation.dwThreadId;
- /* Resume Thread */
- ResumeThread(ProcessInformation.hThread);
+ /* Resume Thread */
+ ResumeThread(ProcessInformation.hThread);
- /* Connect control pipe */
- if (ConnectNamedPipe(Service->ControlPipeHandle, NULL))
+ /* Connect control pipe */
+ if (ConnectNamedPipe(Service->ControlPipeHandle, NULL))
{
- DWORD dwProcessId = 0;
- DWORD dwRead = 0;
+ DWORD dwProcessId = 0;
+ DWORD dwRead = 0;
- DPRINT("Control pipe connected!\n");
+ DPRINT("Control pipe connected!\n");
- /* Read thread id from pipe */
- if (!ReadFile(Service->ControlPipeHandle,
- (LPVOID)&dwProcessId,
- sizeof(DWORD),
- &dwRead,
- NULL))
- {
- DPRINT1("Reading the service control pipe failed (Error
%lu)\n",
- GetLastError());
- Status = STATUS_UNSUCCESSFUL;
- }
- else
- {
- DPRINT("Received process id %lu\n", dwProcessId);
+ /* Read thread id from pipe */
+ if (!ReadFile(Service->ControlPipeHandle,
+ (LPVOID)&dwProcessId,
+ sizeof(DWORD),
+ &dwRead,
+ NULL))
+ {
+ DPRINT1("Reading the service control pipe failed (Error
%lu)\n",
+ GetLastError());
+ Status = STATUS_UNSUCCESSFUL;
+ }
+ else
+ {
+ DPRINT("Received process id %lu\n", dwProcessId);
- /* FIXME: Send start command */
+ /* FIXME: Send start command */
- Status = STATUS_SUCCESS;
- }
+ Status = STATUS_SUCCESS;
+ }
}
- else
+ else
{
- DPRINT("Connecting control pipe failed!\n");
+ DPRINT("Connecting control pipe failed!\n");
- /* Close control pipe */
- CloseHandle(Service->ControlPipeHandle);
- Service->ControlPipeHandle = INVALID_HANDLE_VALUE;
- Service->ProcessId = 0;
- Service->ThreadId = 0;
- Status = STATUS_UNSUCCESSFUL;
+ /* Close control pipe */
+ CloseHandle(Service->ControlPipeHandle);
+ Service->ControlPipeHandle = INVALID_HANDLE_VALUE;
+ Service->ProcessId = 0;
+ Service->ThreadId = 0;
+ Status = STATUS_UNSUCCESSFUL;
}
- ScmSendStartCommand(Service, NULL);
+ ScmSendStartCommand(Service, NULL);
- /* Close process and thread handle */
- CloseHandle(ProcessInformation.hThread);
- CloseHandle(ProcessInformation.hProcess);
+ /* Close process and thread handle */
+ CloseHandle(ProcessInformation.hThread);
+ CloseHandle(ProcessInformation.hProcess);
- return Status;
+ return Status;
}
static NTSTATUS
ScmStartService(PSERVICE Service,
- PSERVICE_GROUP Group)
+ PSERVICE_GROUP Group)
{
- WCHAR szDriverPath[MAX_PATH];
- UNICODE_STRING DriverPath;
- NTSTATUS Status;
[truncated at 1000 lines; 1627 more skipped]