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"
29 LONG service_start_lock
;
30 struct list processes
;
38 struct scmdatabase
*db
;
45 HANDLE overlapped_event
;
48 struct sc_notify_handle
;
53 struct scmdatabase
*db
;
54 LONG ref_count
; /* number of references - if goes to zero and the service is deleted the structure will be freed */
56 SERVICE_STATUS status
;
57 HANDLE status_changed_event
;
58 QUERY_SERVICE_CONFIGW config
;
59 DWORD preshutdown_timeout
;
61 LPWSTR dependOnServices
;
62 LPWSTR dependOnGroups
;
63 struct process_entry
*process
;
66 BOOL marked_for_delete
;
69 struct sc_notify_handle
*notify
;
72 extern struct scmdatabase
*active_database
;
74 /* SCM database functions */
76 struct service_entry
*scmdatabase_find_service(struct scmdatabase
*db
, LPCWSTR name
);
77 struct service_entry
*scmdatabase_find_service_by_displayname(struct scmdatabase
*db
, LPCWSTR name
);
78 DWORD
scmdatabase_add_service(struct scmdatabase
*db
, struct service_entry
*entry
);
80 BOOL
scmdatabase_lock_startup(struct scmdatabase
*db
, int timeout
);
81 void scmdatabase_unlock_startup(struct scmdatabase
*db
);
83 void scmdatabase_lock(struct scmdatabase
*db
);
84 void scmdatabase_unlock(struct scmdatabase
*db
);
86 /* Service functions */
88 DWORD
service_create(LPCWSTR name
, struct service_entry
**entry
);
89 BOOL
validate_service_name(LPCWSTR name
);
90 BOOL
validate_service_config(struct service_entry
*entry
);
91 DWORD
save_service_config(struct service_entry
*entry
);
92 void free_service_entry(struct service_entry
*entry
);
93 struct service_entry
*grab_service(struct service_entry
*service
);
94 void release_service(struct service_entry
*service
);
95 void service_lock(struct service_entry
*service
);
96 void service_unlock(struct service_entry
*service
);
97 DWORD
service_start(struct service_entry
*service
, DWORD service_argc
, LPCWSTR
*service_argv
);
99 /* Process functions */
101 struct process_entry
*grab_process(struct process_entry
*process
);
102 void release_process(struct process_entry
*process
);
103 BOOL
process_send_control(struct process_entry
*process
, BOOL winedevice
, const WCHAR
*name
,
104 DWORD control
, const BYTE
*data
, DWORD data_size
, DWORD
*result
);
105 void process_terminate(struct process_entry
*process
);
107 extern DWORD service_pipe_timeout
;
108 extern DWORD service_kill_timeout
;
109 extern HANDLE exit_event
;
111 DWORD
RPC_Init(void);
115 LPWSTR
strdupW(LPCWSTR str
);
117 BOOL
check_multisz(LPCWSTR lpMultiSz
, DWORD cbSize
);
119 DWORD
load_reg_string(HKEY hKey
, LPCWSTR szValue
, BOOL bExpand
, LPWSTR
*output
);
120 DWORD
load_reg_multisz(HKEY hKey
, LPCWSTR szValue
, BOOL bAllowSingle
, LPWSTR
*output
);
121 DWORD
load_reg_dword(HKEY hKey
, LPCWSTR szValue
, DWORD
*output
);
123 static inline LPCWSTR
get_display_name(struct service_entry
*service
)
125 return service
->config
.lpDisplayName
? service
->config
.lpDisplayName
: service
->name
;
128 static inline BOOL
is_marked_for_delete(struct service_entry
*service
)
130 return service
->marked_for_delete
;
133 static inline DWORD
mark_for_delete(struct service_entry
*service
)
135 service
->marked_for_delete
= TRUE
;
136 return ERROR_SUCCESS
;
139 #endif /*WINE_PROGRAMS_UTILS_H_*/