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.

165 lines
3.3 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. splctrlh.c
  5. Abstract:
  6. The Spooler Service Control Handling routine. This file contains
  7. the following functions.
  8. SpoolerCtrlHandler
  9. Author:
  10. Krishna Ganugapati 12-Oct-1993
  11. Environment:
  12. User Mode -Win32
  13. Revision History:
  14. 4-Jan-1999 Khaleds
  15. Added Code for optimiziting the load time of the spooler by decoupling
  16. the startup dependency between spoolsv and spoolss
  17. 12-Oct-1993 krishnaG
  18. --*/
  19. //
  20. // Includes
  21. //
  22. #define NOMINMAX
  23. #include <nt.h>
  24. #include <ntrtl.h>
  25. #include <nturtl.h>
  26. #include <windows.h>
  27. #include <winspool.h>
  28. #include <winsplp.h>
  29. #include <winsvc.h> //SERVICE_STOP
  30. #include <rpc.h>
  31. #include "splsvr.h"
  32. #include "splr.h"
  33. #include "server.h"
  34. #include "client.h"
  35. #include "kmspool.h"
  36. extern DWORD dwCallExitProcessOnShutdown;
  37. DWORD
  38. SpoolerCtrlHandler(
  39. IN DWORD opcode,
  40. IN DWORD dwEventType,
  41. IN PVOID pEventData,
  42. IN PVOID pData
  43. )
  44. /*++
  45. Routine Description:
  46. This function receives control requests that come in from the
  47. Service Controller
  48. Arguments:
  49. opcode - This is the control code.
  50. Return Value:
  51. --*/
  52. {
  53. DWORD dwStatus = NO_ERROR;
  54. DBGMSG(DBG_TRACE,("Control Request Received\n"));
  55. switch (opcode) {
  56. case SERVICE_CONTROL_STOP:
  57. //
  58. //
  59. // When process dies the handle is automatically closed,
  60. // so no need to keep it.
  61. //
  62. (VOID) CreateEvent(NULL, TRUE, TRUE, szSpoolerExitingEvent);
  63. case SERVICE_CONTROL_SHUTDOWN:
  64. DBGMSG(DBG_TRACE, ("Control Request = STOP or SHUTDOWN\n"));
  65. //
  66. // Start the de-installation. This call includes the sending of
  67. // the new status to the Service Controller.
  68. //
  69. //
  70. // Update the Service Status to the pending state. And wake up
  71. // all threads so they will read it.
  72. //
  73. SpoolerShutdown();
  74. SetEvent(TerminateEvent);
  75. if ( dwCallExitProcessOnShutdown &&
  76. opcode == SERVICE_CONTROL_SHUTDOWN ) {
  77. ExitProcess(0);
  78. }
  79. break;
  80. case SERVICE_CONTROL_INTERROGATE:
  81. DBGMSG(DBG_TRACE, ("Control Request = INTERROGATE\n"));
  82. //
  83. // Send back an UPDATE_ONLY status.
  84. //
  85. SpoolerStatusUpdate(UPDATE_ONLY);
  86. break;
  87. case SERVICE_CONTROL_DEVICEEVENT:
  88. dwStatus = SplProcessPnPEvent(dwEventType, pEventData, pData);
  89. break;
  90. #if 0
  91. case SERVICE_CONTROL_SYSTEM_IDLE:
  92. //
  93. // This message from the SCM allows the spooler to complete it's
  94. // second phase initialization.
  95. //
  96. SplStartPhase2Init();
  97. break;
  98. #endif
  99. case SERVICE_CONTROL_POWEREVENT:
  100. //
  101. // If the spooler does not allow the system to be powered down, then
  102. // we can indicate that by returning any Win32 error.
  103. //
  104. dwStatus = SplPowerEvent(dwEventType) ? NO_ERROR : ERROR_INVALID_FUNCTION;
  105. break;
  106. default:
  107. DBGMSG(DBG_TRACE, ("Control Request = OTHER\n"));
  108. SpoolerStatusUpdate(UPDATE_ONLY);
  109. dwStatus = ERROR_CALL_NOT_IMPLEMENTED;
  110. break;
  111. }
  112. return dwStatus;
  113. }