wined3d: Fix / update reported driver model version.
[wine/zf.git] / programs / services / services.h
blob0d400e591836f574483809ec6b293c85e25a2199
1 /*
2 * Services.exe - include file
4 * Copyright 2007 Google (Mikolaj Zalewski)
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.
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.
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
21 #ifndef WINE_PROGRAMS_UTILS_H_
22 #define WINE_PROGRAMS_UTILS_H_
24 #include "wine/list.h"
26 struct scmdatabase
28 HKEY root_key;
29 LONG service_start_lock;
30 struct list processes;
31 struct list services;
32 CRITICAL_SECTION cs;
35 struct process_entry
37 struct list entry;
38 struct scmdatabase *db;
39 LONG ref_count;
40 LONG use_count;
41 DWORD process_id;
42 HANDLE process;
43 HANDLE control_mutex;
44 HANDLE control_pipe;
45 HANDLE overlapped_event;
48 struct service_entry
50 struct list entry;
51 struct scmdatabase *db;
52 LONG ref_count; /* number of references - if goes to zero and the service is deleted the structure will be freed */
53 LPWSTR name;
54 SERVICE_STATUS status;
55 HANDLE status_changed_event;
56 QUERY_SERVICE_CONFIGW config;
57 DWORD preshutdown_timeout;
58 LPWSTR description;
59 LPWSTR dependOnServices;
60 LPWSTR dependOnGroups;
61 struct process_entry *process;
62 BOOL shared_process;
63 BOOL force_shutdown;
64 BOOL marked_for_delete;
65 BOOL is_wow64;
66 BOOL delayed_autostart;
67 struct list handles;
70 extern struct scmdatabase *active_database;
72 /* SCM database functions */
74 struct service_entry *scmdatabase_find_service(struct scmdatabase *db, LPCWSTR name);
75 struct service_entry *scmdatabase_find_service_by_displayname(struct scmdatabase *db, LPCWSTR name);
76 DWORD scmdatabase_add_service(struct scmdatabase *db, struct service_entry *entry);
78 BOOL scmdatabase_lock_startup(struct scmdatabase *db, int timeout);
79 void scmdatabase_unlock_startup(struct scmdatabase *db);
81 void scmdatabase_lock(struct scmdatabase *db);
82 void scmdatabase_unlock(struct scmdatabase *db);
84 /* Service functions */
86 DWORD service_create(LPCWSTR name, struct service_entry **entry);
87 BOOL validate_service_name(LPCWSTR name);
88 BOOL validate_service_config(struct service_entry *entry);
89 DWORD save_service_config(struct service_entry *entry);
90 void free_service_entry(struct service_entry *entry);
91 struct service_entry *grab_service(struct service_entry *service);
92 void release_service(struct service_entry *service);
93 void service_lock(struct service_entry *service);
94 void service_unlock(struct service_entry *service);
95 DWORD service_start(struct service_entry *service, DWORD service_argc, LPCWSTR *service_argv);
97 /* Process functions */
99 struct process_entry *grab_process(struct process_entry *process);
100 void release_process(struct process_entry *process);
101 BOOL process_send_control(struct process_entry *process, BOOL winedevice, const WCHAR *name,
102 DWORD control, const BYTE *data, DWORD data_size, DWORD *result);
103 void process_terminate(struct process_entry *process);
105 extern DWORD service_pipe_timeout;
106 extern DWORD service_kill_timeout;
107 extern HANDLE exit_event;
109 DWORD RPC_Init(void);
110 void RPC_Stop(void);
112 /* from utils.c */
113 LPWSTR strdupW(LPCWSTR str);
115 BOOL check_multisz(LPCWSTR lpMultiSz, DWORD cbSize);
117 DWORD load_reg_string(HKEY hKey, LPCWSTR szValue, BOOL bExpand, LPWSTR *output);
118 DWORD load_reg_multisz(HKEY hKey, LPCWSTR szValue, BOOL bAllowSingle, LPWSTR *output);
119 DWORD load_reg_dword(HKEY hKey, LPCWSTR szValue, DWORD *output);
121 static inline LPCWSTR get_display_name(struct service_entry *service)
123 return service->config.lpDisplayName ? service->config.lpDisplayName : service->name;
126 static inline BOOL is_marked_for_delete(struct service_entry *service)
128 return service->marked_for_delete;
131 static inline DWORD mark_for_delete(struct service_entry *service)
133 service->marked_for_delete = TRUE;
134 return ERROR_SUCCESS;
137 #endif /*WINE_PROGRAMS_UTILS_H_*/