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.

167 lines
3.8 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. shutcall.c
  5. Abstract:
  6. This module contains callbacks for RP-Calling into winlogon's
  7. shutdown interface
  8. Author:
  9. Dragos C. Sambotin (dragoss) 21-May-1999
  10. Notes:
  11. Revision History:
  12. --*/
  13. #include <rpc.h>
  14. #include "shutinit.h"
  15. #include "regconn.h"
  16. LONG
  17. NewShutdownCallback(
  18. IN RPC_BINDING_HANDLE *pbinding,
  19. IN PREG_UNICODE_STRING Message,
  20. IN PSHUTDOWN_CONTEXT ShutdownContext
  21. )
  22. /*++
  23. Routine Description:
  24. New callback for binding to a machine to initiate a shutdown.
  25. This will call into BaseInitiateShutdown from InitShutdown interface (in winlogon),
  26. instead of BaseInitiateSystemShutdown from winreg interface
  27. Arguments:
  28. pbinding - Supplies a pointer to the RPC binding context
  29. Message - Supplies message to display during shutdown timeout period.
  30. ShutdownContext - Supplies remaining parameters for BaseInitiateSystemShutdown
  31. Return Value:
  32. ERROR_SUCCESS if no error.
  33. --*/
  34. {
  35. DWORD Result;
  36. RpcTryExcept {
  37. Result = BaseInitiateShutdown((PREGISTRY_SERVER_NAME)pbinding,
  38. Message,
  39. ShutdownContext->dwTimeout,
  40. ShutdownContext->bForceAppsClosed,
  41. ShutdownContext->bRebootAfterShutdown);
  42. } RpcExcept(EXCEPTION_EXECUTE_HANDLER) {
  43. Result = RpcExceptionCode();
  44. } RpcEndExcept;
  45. if (Result != ERROR_SUCCESS) {
  46. RpcBindingFree(pbinding);
  47. }
  48. return(Result);
  49. }
  50. LONG
  51. NewShutdownCallbackEx(
  52. IN RPC_BINDING_HANDLE *pbinding,
  53. IN PREG_UNICODE_STRING Message,
  54. IN PSHUTDOWN_CONTEXTEX ShutdownContext
  55. )
  56. /*++
  57. Routine Description:
  58. New version of callback for binding to a machine to initiate a shutdown.
  59. This will call BaseInitiateShutdownEx from InitShutdown interface (in winlogon)
  60. instead of BaseInitiateSystemShutdownEx from winreg interface
  61. Arguments:
  62. pbinding - Supplies a pointer to the RPC binding context
  63. Message - Supplies message to display during shutdown timeout period.
  64. ShutdownContext - Supplies remaining parameters for BaseInitiateSystemShutdown
  65. Return Value:
  66. ERROR_SUCCESS if no error.
  67. --*/
  68. {
  69. DWORD Result;
  70. RpcTryExcept {
  71. Result = BaseInitiateShutdownEx((PREGISTRY_SERVER_NAME)pbinding,
  72. Message,
  73. ShutdownContext->dwTimeout,
  74. ShutdownContext->bForceAppsClosed,
  75. ShutdownContext->bRebootAfterShutdown,
  76. ShutdownContext->dwReason);
  77. } RpcExcept(EXCEPTION_EXECUTE_HANDLER) {
  78. Result = RpcExceptionCode();
  79. } RpcEndExcept;
  80. if (Result != ERROR_SUCCESS) {
  81. RpcBindingFree(pbinding);
  82. }
  83. return(Result);
  84. }
  85. LONG
  86. NewAbortShutdownCallback(
  87. IN RPC_BINDING_HANDLE *pbinding,
  88. IN PVOID Unused1,
  89. IN PVOID Unused2
  90. )
  91. /*++
  92. Routine Description:
  93. New callback for binding to a machine to abort a shutdown.
  94. This will call into BaseAbortShutdown in InitShutdown interface (in winlogon),
  95. instead of BaseAbortSystemShutdown in winreg interface
  96. Arguments:
  97. pbinding - Supplies a pointer to the RPC binding context
  98. Return Value:
  99. ERROR_SUCCESS if no error.
  100. --*/
  101. {
  102. DWORD Result;
  103. RpcTryExcept {
  104. Result = BaseAbortShutdown((PREGISTRY_SERVER_NAME)pbinding);
  105. } RpcExcept(EXCEPTION_EXECUTE_HANDLER) {
  106. Result = RpcExceptionCode();
  107. } RpcEndExcept;
  108. if (Result != ERROR_SUCCESS) {
  109. RpcBindingFree(pbinding);
  110. }
  111. return(Result);
  112. }