From ac3f571e56bc31b7b23686fc19cc804133769a83 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 28 Jan 2019 15:52:24 +0100 Subject: [PATCH] services: Store a list of service handles in service_entry. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- programs/services/rpc.c | 6 ++++++ programs/services/services.c | 3 +++ programs/services/services.h | 1 + 3 files changed, 10 insertions(+) diff --git a/programs/services/rpc.c b/programs/services/rpc.c index efbcd7645b9..623e1fafbd0 100644 --- a/programs/services/rpc.c +++ b/programs/services/rpc.c @@ -78,6 +78,7 @@ struct sc_manager_handle /* service control manager handle */ struct sc_service_handle /* service handle */ { struct sc_handle hdr; + struct list entry; struct service_entry *service_entry; }; @@ -311,6 +312,7 @@ static void SC_RPC_HANDLE_destroy(SC_RPC_HANDLE handle) { struct sc_service_handle *service = (struct sc_service_handle *)hdr; service_lock(service->service_entry); + list_remove(&service->entry); if (service->service_entry->notify && service->service_entry->notify->service == service) { @@ -431,7 +433,11 @@ static DWORD create_handle_for_service(struct service_entry *entry, DWORD dwDesi service->hdr.type = SC_HTYPE_SERVICE; service->hdr.access = dwDesiredAccess; RtlMapGenericMask(&service->hdr.access, &g_svc_generic); + + service_lock(entry); service->service_entry = entry; + list_add_tail(&entry->handles, &service->entry); + service_unlock(entry); *phService = &service->hdr; return ERROR_SUCCESS; diff --git a/programs/services/services.c b/programs/services/services.c index 3de46bd2003..fe605aca701 100644 --- a/programs/services/services.c +++ b/programs/services/services.c @@ -21,6 +21,7 @@ #define WIN32_LEAN_AND_MEAN #include +#include #include #include #include @@ -114,6 +115,7 @@ DWORD service_create(LPCWSTR name, struct service_entry **entry) if (!*entry) return ERROR_NOT_ENOUGH_SERVER_MEMORY; (*entry)->name = strdupW(name); + list_init(&(*entry)->handles); if (!(*entry)->name) { HeapFree(GetProcessHeap(), 0, *entry); @@ -136,6 +138,7 @@ DWORD service_create(LPCWSTR name, struct service_entry **entry) void free_service_entry(struct service_entry *entry) { + assert(list_empty(&entry->handles)); CloseHandle(entry->status_changed_event); HeapFree(GetProcessHeap(), 0, entry->name); HeapFree(GetProcessHeap(), 0, entry->config.lpBinaryPathName); diff --git a/programs/services/services.h b/programs/services/services.h index 5a79c35778a..c78f71c35b5 100644 --- a/programs/services/services.h +++ b/programs/services/services.h @@ -67,6 +67,7 @@ struct service_entry BOOL is_wow64; BOOL status_notified; struct sc_notify_handle *notify; + struct list handles; }; extern struct scmdatabase *active_database;