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.

162 lines
2.5 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. BOOL InitializeRemoteSecurity( );
  16. BOOL InitializeRegCreateKey( );
  17. extern PSVCHOST_GLOBAL_DATA g_svcsGlobalData;
  18. BOOL
  19. StartWinregRPCServer(
  20. )
  21. {
  22. LPWSTR ServiceName;
  23. NTSTATUS Status;
  24. if( !g_svcsGlobalData ) {
  25. return FALSE;
  26. }
  27. ServiceName = INTERFACE_NAME;
  28. Status = g_svcsGlobalData->StartRpcServer(
  29. ServiceName,
  30. winreg_ServerIfHandle
  31. );
  32. ASSERT( NT_SUCCESS( Status ));
  33. if( ! NT_SUCCESS( Status )) {
  34. return FALSE;
  35. }
  36. return TRUE;
  37. }
  38. BOOL
  39. InitializeWinreg(
  40. )
  41. /*++
  42. Routine Description:
  43. Initialize the Winreg RPC server by creating the notify thread,
  44. starting the server and creating the external synchronization event.
  45. Arguments:
  46. None.
  47. Return Value:
  48. BOOL - Returns TRUE if initialization is succesful.
  49. --*/
  50. {
  51. BOOL Success;
  52. HANDLE PublicEvent;
  53. //
  54. // Create the notify thread.
  55. //
  56. Success = InitializeRegNotifyChangeKeyValue( );
  57. ASSERT( Success == TRUE );
  58. if( Success == FALSE ) {
  59. return FALSE;
  60. }
  61. //
  62. // Initialize BaseRegCreateKey
  63. //
  64. Success = InitializeRegCreateKey( );
  65. ASSERT( Success == TRUE );
  66. if( Success == FALSE ) {
  67. return FALSE;
  68. }
  69. //
  70. // Initialize support for remote security
  71. //
  72. Success = InitializeRemoteSecurity( );
  73. if ( Success == FALSE )
  74. {
  75. return( FALSE );
  76. }
  77. //
  78. // Start the Winreg RPC server.
  79. //
  80. Success = StartWinregRPCServer( );
  81. if ( Success == FALSE )
  82. {
  83. return( FALSE );
  84. }
  85. //
  86. // Let the world know that the server is running.
  87. //
  88. PublicEvent = CreateEvent( NULL, TRUE, TRUE, PUBLIC_EVENT );
  89. ASSERT( PublicEvent );
  90. if( !PublicEvent ) {
  91. return FALSE;
  92. }
  93. //
  94. // Success!
  95. //
  96. return TRUE;
  97. }
  98. BOOL
  99. ShutdownWinreg(
  100. )
  101. /*++
  102. Routine Description:
  103. Stops the Winreg RPC server.
  104. Arguments:
  105. None.
  106. Return Value:
  107. None
  108. --*/
  109. {
  110. //
  111. // Stop the rpc server
  112. //
  113. if( !g_svcsGlobalData ) {
  114. return FALSE;
  115. }
  116. g_svcsGlobalData->StopRpcServer( winreg_ServerIfHandle );
  117. return TRUE;
  118. }