Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
4.8 KiB

  1. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  2. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  3. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  4. // PARTICULAR PURPOSE.
  5. //
  6. // Copyright (C) 1993-1995 Microsoft Corporation. All Rights Reserved.
  7. //
  8. // MODULE: service.h
  9. //
  10. // AUTHOR: Craig Link
  11. //
  12. //
  13. // Comments: The use of this header file and the accompanying service.c
  14. // file simplifies the process of writting a service. You as a developer
  15. // simply need to follow the TODO's outlined in this header file, and
  16. // implement the ServiceStart() and ServiceStop() functions.
  17. //
  18. // There is no need to modify the code in service.c. Just add service.c
  19. // to your project and link with the following libraries...
  20. //
  21. // libcmt.lib kernel32.lib advapi.lib shell32.lib
  22. //
  23. // This code also supports unicode. Be sure to compile both service.c and
  24. // and code #include "service.h" with the same Unicode setting.
  25. //
  26. // Upon completion, your code will have the following command line interface
  27. //
  28. // <service exe> -? to display this list
  29. // <service exe> -install to install the service
  30. // <service exe> -remove to remove the service
  31. // <service exe> -debug <params> to run as a console app for debugging
  32. //
  33. // Note: This code also implements Ctrl+C and Ctrl+Break handlers
  34. // when using the debug option. These console events cause
  35. // your ServiceStop routine to be called
  36. //
  37. // Also, this code only handles the OWN_SERVICE service type
  38. // running in the LOCAL_SYSTEM security context.
  39. //
  40. // To control your service ( start, stop, etc ) you may use the
  41. // Services control panel applet or the NET.EXE program.
  42. //
  43. // To aid in writing/debugging service, the
  44. // SDK contains a utility (MSTOOLS\BIN\SC.EXE) that
  45. // can be used to control, configure, or obtain service status.
  46. // SC displays complete status for any service/driver
  47. // in the service database, and allows any of the configuration
  48. // parameters to be easily changed at the command line.
  49. // For more information on SC.EXE, type SC at the command line.
  50. //
  51. #ifndef _SERVICE_H
  52. #define _SERVICE_H
  53. #ifdef __cplusplus
  54. extern "C" {
  55. #endif
  56. //////////////////////////////////////////////////////////////////////////////
  57. //// todo: change to desired strings
  58. ////
  59. // name of the executable
  60. #define SZAPPNAME L"cryptsvc"
  61. // internal name of the service
  62. #define SZSERVICENAME L"CryptSvc"
  63. // displayed name of the service
  64. #define SZSERVICEDISPLAYNAME L"Cryptographic Services"
  65. #define SZSERVICEDISPLAYNAMEA "Cryptographic Services"
  66. // list of service dependencies - "dep1\0dep2\0\0"
  67. // RPC must be running for us to work!
  68. #define SZDEPENDENCIES L"RpcSs\0" // doubly null terminated
  69. //////////////////////////////////////////////////////////////////////////////
  70. //////////////////////////////////////////////////////////////////////////////
  71. //// todo: ServiceStart()must be defined by in your code.
  72. //// The service should use ReportStatusToSCMgr to indicate
  73. //// progress. This routine must also be used by StartService()
  74. //// to report to the SCM when the service is running.
  75. ////
  76. //// If a ServiceStop procedure is going to take longer than
  77. //// 3 seconds to execute, it should spawn a thread to
  78. //// execute the stop code, and return. Otherwise, the
  79. //// ServiceControlManager will believe that the service has
  80. //// stopped responding
  81. ////
  82. DWORD ServiceStart (HINSTANCE hInstance, int nCmdShow);
  83. VOID ServiceStop();
  84. //////////////////////////////////////////////////////////////////////////////
  85. //////////////////////////////////////////////////////////////////////////////
  86. //// The following are procedures which
  87. //// may be useful to call within the above procedures,
  88. //// but require no implementation by the user.
  89. //// They are implemented in service.c
  90. //
  91. // FUNCTION: ReportStatusToSCMgr()
  92. //
  93. // PURPOSE: Sets the current status of the service and
  94. // reports it to the Service Control Manager
  95. //
  96. // PARAMETERS:
  97. // dwCurrentState - the state of the service
  98. // dwWin32ExitCode - error code to report
  99. // dwWaitHint - worst case estimate to next checkpoint
  100. //
  101. // RETURN VALUE:
  102. // TRUE - success
  103. // FALSE - failure
  104. //
  105. BOOL ReportStatusToSCMgr(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwWaitHint);
  106. //
  107. // FUNCTION: AddToMessageLog(LPWSTR lpszMsg)
  108. //
  109. // PURPOSE: Allows any thread to log an error message
  110. //
  111. // PARAMETERS:
  112. // lpszMsg - text for message
  113. //
  114. // RETURN VALUE:
  115. // none
  116. //
  117. void AddToMessageLog(LPWSTR lpszMsg);
  118. //////////////////////////////////////////////////////////////////////////////
  119. void StopRPCServer();
  120. // entry point to start the service from install stub.
  121. DWORD WINAPI Start( LPVOID lpV );
  122. #ifdef __cplusplus
  123. }
  124. #endif
  125. #endif