services: Store a list of service handles in service_entry.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-01-28 15:52:24 +01:00 committed by Alexandre Julliard
parent 9084b9761d
commit ac3f571e56
3 changed files with 10 additions and 0 deletions

View File

@ -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;

View File

@ -21,6 +21,7 @@
#define WIN32_LEAN_AND_MEAN
#include <stdarg.h>
#include <assert.h>
#include <windows.h>
#include <winsvc.h>
#include <rpc.h>
@ -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);

View File

@ -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;