services: Initialize environment block immediately after startup.

Signed-off-by: Sebastian Lackner <sebastian@fds-team.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Sebastian Lackner 2016-04-15 10:03:52 +02:00 committed by Alexandre Julliard
parent 99130182ba
commit ce07a77610
1 changed files with 11 additions and 11 deletions

View File

@ -724,17 +724,6 @@ static DWORD service_start_process(struct service_entry *service_entry)
service_lock(service_entry);
if (!env)
{
HANDLE htok;
if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY|TOKEN_DUPLICATE, &htok))
CreateEnvironmentBlock(&env, htok, FALSE);
if (!env)
WINE_ERR("failed to create services environment\n");
}
if ((err = get_service_binary_path(service_entry, &path)))
{
service_unlock(service_entry);
@ -976,9 +965,20 @@ static void load_registry_parameters(void)
int main(int argc, char *argv[])
{
static const WCHAR svcctl_started_event[] = SVCCTL_STARTED_EVENT;
HANDLE htok;
DWORD err;
g_hStartedEvent = CreateEventW(NULL, TRUE, FALSE, svcctl_started_event);
if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY|TOKEN_DUPLICATE, &htok))
{
CreateEnvironmentBlock(&env, htok, FALSE);
CloseHandle(htok);
}
if (!env)
WINE_ERR("failed to create services environment\n");
load_registry_parameters();
err = scmdatabase_create(&active_database);
if (err != ERROR_SUCCESS)