w32svrapi.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #ifndef W32_SVRAPI_H_INCLUDED
  2. #define W32_SVRAPI_H_INCLUDED
  3. /*********************************************************************
  4. *
  5. * File : $Source: /cvsroot/ijbswa/current/w32svrapi.h,v $
  6. *
  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.
  11. *
  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.
  19. *
  20. * Copyright : Written by and Copyright (C) 2003 members of
  21. * the Privoxy team. https://www.privoxy.org/
  22. *
  23. * Written by and Copyright (C) 2003 Ian Cummings
  24. * <ian_a_c@hotmail.com>
  25. *
  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.
  29. *
  30. *
  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.
  36. *
  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.
  42. *
  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.
  48. *
  49. *********************************************************************/
  50. #ifdef _WIN32
  51. extern char szThisServiceName[];
  52. extern BOOL bRunAsService;
  53. extern SERVICE_TABLE_ENTRY w32ServiceDispatchTable[];
  54. extern BOOL install_service(const char *service_name);
  55. extern BOOL uninstall_service(const char *service_name);
  56. extern void w32_service_exit_notify(void);
  57. extern void w32_set_service_cwd(void);
  58. extern void w32_service_listen_loop(void *p);
  59. extern BOOL CanSystemSupportServices();
  60. extern SC_HANDLE w32_open_sc_manager(
  61. LPCTSTR lpMachineName, /* computer name */
  62. LPCTSTR lpDatabaseName, /* SCM database name */
  63. DWORD dwDesiredAccess); /* access type */
  64. extern BOOL w32_close_service_handle(
  65. SC_HANDLE hSCObject); /* handle to service or SCM object */
  66. extern SC_HANDLE w32_open_service(
  67. SC_HANDLE hSCManager, /* handle to SCM database */
  68. LPCTSTR lpServiceName, /* service name */
  69. DWORD dwDesiredAccess); /* access */
  70. extern SC_HANDLE w32_create_service(
  71. SC_HANDLE hSCManager, /* handle to SCM database */
  72. LPCTSTR lpServiceName, /* name of service to start */
  73. LPCTSTR lpDisplayName, /* display name */
  74. DWORD dwDesiredAccess, /* type of access to service */
  75. DWORD dwServiceType, /* type of service */
  76. DWORD dwStartType, /* when to start service */
  77. DWORD dwErrorControl, /* severity of service failure */
  78. LPCTSTR lpBinaryPathName, /* name of binary file */
  79. LPCTSTR lpLoadOrderGroup, /* name of load ordering group */
  80. LPDWORD lpdwTagId, /* tag identifier */
  81. LPCTSTR lpDependencies, /* array of dependency names */
  82. LPCTSTR lpServiceStartName, /* account name */
  83. LPCTSTR lpPassword); /* account password */
  84. extern BOOL w32_delete_service(
  85. SC_HANDLE hService); /* handle to service */
  86. extern BOOL w32_query_service_config(
  87. SC_HANDLE hService, /* handle to service */
  88. LPQUERY_SERVICE_CONFIG lpServiceConfig, /* buffer */
  89. DWORD cbBufSize, /* size of buffer */
  90. LPDWORD pcbBytesNeeded); /* bytes needed */
  91. extern BOOL w32_start_service_ctrl_dispatcher(
  92. CONST LPSERVICE_TABLE_ENTRY lpServiceTable); /* service table */
  93. extern SERVICE_STATUS_HANDLE w32_register_service_ctrl_handler(
  94. LPCTSTR lpServiceName, /* service name */
  95. LPHANDLER_FUNCTION lpHandlerProc); /* handler function */
  96. extern BOOL w32_set_service_status(
  97. SERVICE_STATUS_HANDLE hServiceStatus, /* service status handle */
  98. LPSERVICE_STATUS lpServiceStatus); /* status buffer */
  99. #endif /* def _WIN32 */
  100. #endif /* ndef W32_SVRAPI_H_INCLUDED */