}
+VOID
+WaitForLSA(VOID)
+{
+ HANDLE hEvent;
+ DWORD dwError;
+
+ DPRINT1("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;
+ }
+ }
+ }
+
+ DPRINT1("Wait for LSA!\n");
+ WaitForSingleObject(hEvent, INFINITE);
+ DPRINT1("LSA is available!\n");
+
+ CloseHandle(hEvent);
+
+ DPRINT1("WaitForLSA() done\n");
+}
+
+
DWORD
ScmCreateServiceDatabase(VOID)
{
RegCloseKey(hServicesKey);
+ /* Wait for LSA */
+ WaitForLSA();
+
/* Delete services that are marked for delete */
ScmDeleteMarkedServices();
static BOOL
StartServicesManager(VOID)
{
- HANDLE ServicesInitEvent = NULL;
STARTUPINFOW StartupInfo;
PROCESS_INFORMATION ProcessInformation;
- DWORD Count;
LPCWSTR ServiceString = L"services.exe";
BOOL res;
/* Start the service control manager (services.exe) */
+ ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
StartupInfo.cb = sizeof(StartupInfo);
StartupInfo.lpReserved = NULL;
StartupInfo.lpDesktop = NULL;
return FALSE;
}
- /* Wait for event creation (by SCM) for max. 20 seconds */
- for (Count = 0; Count < 20; Count++)
- {
- Sleep(1000);
-
- TRACE("WL: Attempting to open event \"SvcctrlStartEvent_A3752DX\"\n");
- ServicesInitEvent = OpenEventW(
- SYNCHRONIZE,
- FALSE,
- L"SvcctrlStartEvent_A3752DX");
- if (ServicesInitEvent)
- break;
- }
+ TRACE("WL: Created new process - %S\n", ServiceString);
- if (!ServicesInitEvent)
- {
- ERR("WL: Failed to open event \"SvcctrlStartEvent_A3752DX\"\n");
- return FALSE;
- }
+ CloseHandle(ProcessInformation.hThread);
+ CloseHandle(ProcessInformation.hProcess);
- /* Wait for event signalization */
- WaitForSingleObject(ServicesInitEvent, INFINITE);
- CloseHandle(ServicesInitEvent);
TRACE("WL: StartServicesManager() done.\n");
return TRUE;
BOOL res;
/* Start the service control manager (services.exe) */
+ ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
StartupInfo.cb = sizeof(StartupInfo);
StartupInfo.lpReserved = NULL;
StartupInfo.lpDesktop = NULL;
&StartupInfo,
&ProcessInformation);
+ TRACE("WL: Created new process - %S\n", ServiceString);
+
+ CloseHandle(ProcessInformation.hThread);
+ CloseHandle(ProcessInformation.hProcess);
+
return res;
}