PSERVICE
-ScmGetServiceEntryByName(LPWSTR lpServiceName)
+ScmGetServiceEntryByName(LPCWSTR lpServiceName)
{
PLIST_ENTRY ServiceEntry;
PSERVICE CurrentService;
PSERVICE
-ScmGetServiceEntryByDisplayName(LPWSTR lpDisplayName)
+ScmGetServiceEntryByDisplayName(LPCWSTR lpDisplayName)
{
PLIST_ENTRY ServiceEntry;
PSERVICE CurrentService;
PSERVICE
-ScmGetServiceEntryByClientHandle(ULONG Handle)
+ScmGetServiceEntryByClientHandle(HANDLE Handle)
{
PLIST_ENTRY ServiceEntry;
PSERVICE CurrentService;
DPRINT("ScmGetServiceEntryByClientHandle() called\n");
- DPRINT("looking for %lu\n", Handle);
+ DPRINT("looking for %p\n", Handle);
ServiceEntry = ServiceListHead.Flink;
while (ServiceEntry != &ServiceListHead)
DWORD
-ScmCreateNewServiceRecord(LPWSTR lpServiceName,
+ScmCreateNewServiceRecord(LPCWSTR lpServiceName,
PSERVICE *lpServiceRecord)
{
PSERVICE lpService = NULL;
static DWORD
-CreateServiceListEntry(LPWSTR lpServiceName,
+CreateServiceListEntry(LPCWSTR lpServiceName,
HKEY hServiceKey)
{
PSERVICE lpService = NULL;
}
+VOID
+WaitForLSA(VOID)
+{
+ HANDLE hEvent;
+ DWORD dwError;
+
+ DPRINT("WaitForLSA() called\n");
+
+ hEvent = CreateEventW(NULL,
+ TRUE,
+ FALSE,
+ L"LSA_RPC_SERVER_ACTIVE");
+ if (hEvent == NULL)
+ {
+ dwError = GetLastError();
+ DPRINT1("Failed to create the notication event (Error %lu)\n", dwError);
+
+ if (dwError == ERROR_ALREADY_EXISTS)
+ {
+ hEvent = OpenEventW(SYNCHRONIZE,
+ FALSE,
+ L"LSA_RPC_SERVER_ACTIVE");
+ if (hEvent != NULL)
+ {
+ DPRINT1("Could not open the notification event!\n");
+ return;
+ }
+ }
+ }
+
+ DPRINT("Wait for LSA!\n");
+ WaitForSingleObject(hEvent, INFINITE);
+ DPRINT("LSA is available!\n");
+
+ CloseHandle(hEvent);
+
+ DPRINT("WaitForLSA() done\n");
+}
+
+
DWORD
ScmCreateServiceDatabase(VOID)
{
RegCloseKey(hServicesKey);
+ /* Wait for LSA */
+ WaitForLSA();
+
/* Delete services that are marked for delete */
ScmDeleteMarkedServices();
ControlPacket->dwSize = TotalLength;
wcscpy(&ControlPacket->szArguments[0], Service->lpServiceName);
- /* Send the start command */
+ /* Send the control packet */
WriteFile(Service->ControlPipeHandle,
ControlPacket,
sizeof(SCM_CONTROL_PACKET) + (TotalLength * sizeof(WCHAR)),
{
Group->ServicesRunning = TRUE;
}
- Service->Status.dwCurrentState = SERVICE_RUNNING;
+ Service->Status.dwCurrentState = SERVICE_START_PENDING;
}
#if 0
else