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.

175 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. Init.c
  5. Abstract:
  6. This module contains the initialization routine for the Win32 Registry
  7. API RPC server.
  8. Author:
  9. David J. Gilman (davegi) 15-May-1992
  10. --*/
  11. #include <ntrpcp.h>
  12. #include <rpc.h>
  13. #include <svcs.h>
  14. #include "regrpc.h"
  15. #include "..\perflib\ntconreg.h"
  16. BOOL InitializeRemoteSecurity( );
  17. BOOL InitializeRegCreateKey( );
  18. NTSTATUS InitRestrictedMachineHandle( );
  19. VOID CleanupRestrictedMachineHandle( );
  20. extern PSVCHOST_GLOBAL_DATA g_svcsGlobalData;
  21. BOOL
  22. StartWinregRPCServer(
  23. )
  24. {
  25. LPWSTR ServiceName;
  26. NTSTATUS Status;
  27. if( !g_svcsGlobalData ) {
  28. return FALSE;
  29. }
  30. ServiceName = INTERFACE_NAME;
  31. Status = g_svcsGlobalData->StartRpcServer(
  32. ServiceName,
  33. winreg_ServerIfHandle
  34. );
  35. ASSERT( NT_SUCCESS( Status ));
  36. if( ! NT_SUCCESS( Status )) {
  37. return FALSE;
  38. }
  39. return TRUE;
  40. }
  41. BOOL
  42. InitializeWinreg(
  43. )
  44. /*++
  45. Routine Description:
  46. Initialize the Winreg RPC server by creating the notify thread,
  47. starting the server and creating the external synchronization event.
  48. Arguments:
  49. None.
  50. Return Value:
  51. BOOL - Returns TRUE if initialization is succesful.
  52. --*/
  53. {
  54. BOOL Success;
  55. HANDLE PublicEvent;
  56. if( !NT_SUCCESS(InitRestrictedMachineHandle()) ) {
  57. return FALSE;
  58. }
  59. //
  60. // Create the notify thread.
  61. //
  62. Success = InitializeRegNotifyChangeKeyValue( );
  63. ASSERT( Success == TRUE );
  64. if( Success == FALSE ) {
  65. return FALSE;
  66. }
  67. //
  68. // Initialize BaseRegCreateKey
  69. //
  70. Success = InitializeRegCreateKey( );
  71. ASSERT( Success == TRUE );
  72. if( Success == FALSE ) {
  73. return FALSE;
  74. }
  75. //
  76. // Initialize support for remote security
  77. //
  78. Success = InitializeRemoteSecurity( );
  79. if ( Success == FALSE )
  80. {
  81. return( FALSE );
  82. }
  83. //
  84. // Start the Winreg RPC server.
  85. //
  86. Success = StartWinregRPCServer( );
  87. if ( Success == FALSE )
  88. {
  89. return( FALSE );
  90. }
  91. //
  92. // Let the world know that the server is running.
  93. //
  94. PublicEvent = CreateEvent( NULL, TRUE, TRUE, PUBLIC_EVENT );
  95. ASSERT( PublicEvent );
  96. if( !PublicEvent ) {
  97. return FALSE;
  98. }
  99. //
  100. // Success!
  101. //
  102. return TRUE;
  103. }
  104. BOOL
  105. ShutdownWinreg(
  106. )
  107. /*++
  108. Routine Description:
  109. Stops the Winreg RPC server.
  110. Arguments:
  111. None.
  112. Return Value:
  113. None
  114. --*/
  115. {
  116. //
  117. // Stop the rpc server
  118. //
  119. if( !g_svcsGlobalData ) {
  120. return FALSE;
  121. }
  122. g_svcsGlobalData->StopRpcServer( winreg_ServerIfHandle );
  123. if ( !PerfRegCleanup() ) {
  124. return FALSE;
  125. }
  126. CleanupRestrictedMachineHandle();
  127. return TRUE;
  128. }