Leaked source code of windows server 2003
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.

141 lines
3.0 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. #include "precomp.h"
  23. #include "server.h"
  24. #include "client.h"
  25. #include "splsvr.h"
  26. #include "kmspool.h"
  27. extern DWORD dwCallExitProcessOnShutdown;
  28. DWORD
  29. SpoolerCtrlHandler(
  30. IN DWORD opcode,
  31. IN DWORD dwEventType,
  32. IN PVOID pEventData,
  33. IN PVOID pData
  34. )
  35. /*++
  36. Routine Description:
  37. This function receives control requests that come in from the
  38. Service Controller
  39. Arguments:
  40. opcode - This is the control code.
  41. Return Value:
  42. --*/
  43. {
  44. DWORD dwStatus = NO_ERROR;
  45. DBGMSG(DBG_TRACE,("Control Request Received\n"));
  46. switch (opcode) {
  47. case SERVICE_CONTROL_STOP:
  48. //
  49. //
  50. // When process dies the handle is automatically closed,
  51. // so no need to keep it.
  52. //
  53. (VOID) CreateEvent(NULL, TRUE, TRUE, szSpoolerExitingEvent);
  54. case SERVICE_CONTROL_SHUTDOWN:
  55. DBGMSG(DBG_TRACE, ("Control Request = STOP or SHUTDOWN\n"));
  56. //
  57. // Start the de-installation. This call includes the sending of
  58. // the new status to the Service Controller.
  59. //
  60. //
  61. // Update the Service Status to the pending state. And wake up
  62. // all threads so they will read it.
  63. //
  64. SpoolerShutdown();
  65. SetEvent(TerminateEvent);
  66. if ( dwCallExitProcessOnShutdown &&
  67. opcode == SERVICE_CONTROL_SHUTDOWN ) {
  68. ExitProcess(0);
  69. }
  70. break;
  71. case SERVICE_CONTROL_INTERROGATE:
  72. DBGMSG(DBG_TRACE, ("Control Request = INTERROGATE\n"));
  73. //
  74. // Send back an UPDATE_ONLY status.
  75. //
  76. SpoolerStatusUpdate(UPDATE_ONLY);
  77. break;
  78. case SERVICE_CONTROL_DEVICEEVENT:
  79. dwStatus = SplProcessPnPEvent(dwEventType, pEventData, pData);
  80. break;
  81. case SERVICE_CONTROL_POWEREVENT:
  82. //
  83. // If the spooler does not allow the system to be powered down, then
  84. // we can indicate that by returning any Win32 error.
  85. //
  86. dwStatus = SplPowerEvent(dwEventType) ? NO_ERROR : ERROR_INVALID_FUNCTION;
  87. break;
  88. default:
  89. DBGMSG(DBG_TRACE, ("Control Request = OTHER\n"));
  90. SpoolerStatusUpdate(UPDATE_ONLY);
  91. dwStatus = ERROR_CALL_NOT_IMPLEMENTED;
  92. break;
  93. }
  94. return dwStatus;
  95. }