services: Move ChangeServiceConfigW implementation from advapi32.dll to services...
[wine] / programs / services / services.h
1 /*
2  * Services.exe - include file
3  *
4  * Copyright 2007 Google (Mikolaj Zalewski)
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #ifndef WINE_PROGRAMS_UTILS_H_
22 #define WINE_PROGRAMS_UTILS_H_
23
24 #include "wine/list.h"
25
26 struct service_entry
27 {
28     struct list entry;
29     LONG ref_count;                    /* number of references - if goes to zero and the service is deleted the structure will be freed */
30     LPWSTR name;
31     SERVICE_STATUS_PROCESS status;
32     QUERY_SERVICE_CONFIGW config;
33     LPWSTR description;
34     LPWSTR dependOnServices;
35     LPWSTR dependOnGroups;
36 };
37
38 BOOL validate_service_name(LPCWSTR name);
39 BOOL validate_service_config(struct service_entry *entry);
40 struct service_entry *find_service(LPCWSTR name);
41 struct service_entry *find_service_by_displayname(LPCWSTR name);
42 DWORD add_service(struct service_entry *entry);
43 DWORD remove_service(struct service_entry *entry);
44 DWORD save_service_config(struct service_entry *entry);
45 void free_service_entry(struct service_entry *entry);
46 void release_service(struct service_entry *service);
47
48 void lock_services(void);
49 void unlock_services(void);
50
51 extern HANDLE g_hStartedEvent;
52
53 DWORD RPC_MainLoop(void);
54
55 /* from utils.c */
56 LPWSTR strdupW(LPCWSTR str);
57
58 BOOL check_multisz(LPCWSTR lpMultiSz, DWORD cbSize);
59
60 DWORD load_reg_string(HKEY hKey, LPCWSTR szValue, BOOL bExpand, LPWSTR *output);
61 DWORD load_reg_multisz(HKEY hKey, LPCWSTR szValue, LPWSTR *output);
62 DWORD load_reg_dword(HKEY hKey, LPCWSTR szValue, DWORD *output);
63
64 static inline LPCWSTR get_display_name(struct service_entry *service)
65 {
66     return service->config.lpDisplayName ? service->config.lpDisplayName : service->name;
67 }
68
69 static inline BOOL is_marked_for_delete(struct service_entry *service)
70 {
71     return service->entry.next == NULL;
72 }
73
74 #endif /*WINE_PROGRAMS_UTILS_H_*/