From ce07a77610dec0f273912425dc68fc646a7f3624 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Fri, 15 Apr 2016 10:03:52 +0200 Subject: [PATCH] services: Initialize environment block immediately after startup. Signed-off-by: Sebastian Lackner Signed-off-by: Alexandre Julliard --- programs/services/services.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/programs/services/services.c b/programs/services/services.c index 8f53e7e7cef..0f8615f1495 100644 --- a/programs/services/services.c +++ b/programs/services/services.c @@ -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)