1 #ifndef W32_SVRAPI_H_INCLUDED
2 #define W32_SVRAPI_H_INCLUDED
3 /*********************************************************************
5 * File : $Source: /cvsroot/ijbswa/current/w32svrapi.h,v $
7 * Purpose : Win32 Services API for Privoxy.
8 * Provides the implementation of an Win32 service to
9 * allow the code to directly register and run as a
10 * native Windows service application.
12 * Since Win9x/ME platforms don't provide or support
13 * running programs as services, this code uses runtime
14 * loading and calling of the Win32 Service API, to
15 * prevent the possibility of getting "entry point not
16 * found" type errors on unsupported platforms. This adds
17 * a little more complexity to the code, but it is worth
18 * doing to provide that isolation.
20 * Copyright : Written by and Copyright (C) 2003 members of
21 * the Privoxy team. https://www.privoxy.org/
23 * Written by and Copyright (C) 2003 Ian Cummings
24 * <ian_a_c@hotmail.com>
26 * Special thanks to Mates Dolák <matesek@post.cz> for
27 * some very helpful feedback and suggestions during the
28 * development of this code.
31 * This program is free software; you can redistribute it
32 * and/or modify it under the terms of the GNU General
33 * Public License as published by the Free Software
34 * Foundation; either version 2 of the License, or (at
35 * your option) any later version.
37 * This program is distributed in the hope that it will
38 * be useful, but WITHOUT ANY WARRANTY; without even the
39 * implied warranty of MERCHANTABILITY or FITNESS FOR A
40 * PARTICULAR PURPOSE. See the GNU General Public
41 * License for more details.
43 * The GNU General Public License should be included with
44 * this file. If not, you can view it at
45 * http://www.gnu.org/copyleft/gpl.html
46 * or write to the Free Software Foundation, Inc., 59
47 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
49 *********************************************************************/
55 extern char szThisServiceName[];
56 extern BOOL bRunAsService;
57 extern SERVICE_TABLE_ENTRY w32ServiceDispatchTable[];
59 extern BOOL install_service(const char *service_name);
60 extern BOOL uninstall_service(const char *service_name);
61 extern void w32_service_exit_notify(void);
62 extern void w32_set_service_cwd(void);
63 extern void w32_service_listen_loop(void *p);
66 extern BOOL CanSystemSupportServices();
69 extern SC_HANDLE w32_open_sc_manager(
70 LPCTSTR lpMachineName, /* computer name */
71 LPCTSTR lpDatabaseName, /* SCM database name */
72 DWORD dwDesiredAccess); /* access type */
75 extern BOOL w32_close_service_handle(
76 SC_HANDLE hSCObject); /* handle to service or SCM object */
79 extern SC_HANDLE w32_open_service(
80 SC_HANDLE hSCManager, /* handle to SCM database */
81 LPCTSTR lpServiceName, /* service name */
82 DWORD dwDesiredAccess); /* access */
85 extern SC_HANDLE w32_create_service(
86 SC_HANDLE hSCManager, /* handle to SCM database */
87 LPCTSTR lpServiceName, /* name of service to start */
88 LPCTSTR lpDisplayName, /* display name */
89 DWORD dwDesiredAccess, /* type of access to service */
90 DWORD dwServiceType, /* type of service */
91 DWORD dwStartType, /* when to start service */
92 DWORD dwErrorControl, /* severity of service failure */
93 LPCTSTR lpBinaryPathName, /* name of binary file */
94 LPCTSTR lpLoadOrderGroup, /* name of load ordering group */
95 LPDWORD lpdwTagId, /* tag identifier */
96 LPCTSTR lpDependencies, /* array of dependency names */
97 LPCTSTR lpServiceStartName, /* account name */
98 LPCTSTR lpPassword); /* account password */
101 extern BOOL w32_delete_service(
102 SC_HANDLE hService); /* handle to service */
105 extern BOOL w32_query_service_config(
106 SC_HANDLE hService, /* handle to service */
107 LPQUERY_SERVICE_CONFIG lpServiceConfig, /* buffer */
108 DWORD cbBufSize, /* size of buffer */
109 LPDWORD pcbBytesNeeded); /* bytes needed */
112 extern BOOL w32_start_service_ctrl_dispatcher(
113 CONST LPSERVICE_TABLE_ENTRY lpServiceTable); /* service table */
116 extern SERVICE_STATUS_HANDLE w32_register_service_ctrl_handler(
117 LPCTSTR lpServiceName, /* service name */
118 LPHANDLER_FUNCTION lpHandlerProc); /* handler function */
121 extern BOOL w32_set_service_status(
122 SERVICE_STATUS_HANDLE hServiceStatus, /* service status handle */
123 LPSERVICE_STATUS lpServiceStatus); /* status buffer */
126 #endif /* def _WIN32 */
129 #endif /* ndef W32_SVRAPI_H_INCLUDED */