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.

184 lines
3.7 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. Init.c
  5. Abstract:
  6. This module contains the entry point for the Win32 Registry APIs
  7. client side DLL.
  8. Author:
  9. David J. Gilman (davegi) 06-Feb-1992
  10. --*/
  11. #include <rpc.h>
  12. #include "regrpc.h"
  13. #include "client.h"
  14. #include "ntconreg.h"
  15. #if DBG
  16. BOOLEAN BreakPointOnEntry = FALSE;
  17. #endif
  18. BOOL LocalInitializeRegCreateKey();
  19. BOOL LocalCleanupRegCreateKey();
  20. BOOL InitializePredefinedHandlesTable();
  21. BOOL CleanupPredefinedHandlesTable();
  22. BOOL InitializeClassesRoot();
  23. BOOL CleanupClassesRoot(BOOL fOnlyThisThread);
  24. #if defined(_REGCLASS_MALLOC_INSTRUMENTED_)
  25. BOOL InitializeInstrumentedRegClassHeap();
  26. BOOL CleanupInstrumentedRegClassHeap();
  27. #endif // defined(_REGCLASS_MALLOC_INSTRUMENTED_)
  28. #if defined(LEAK_TRACK)
  29. BOOL InitializeLeakTrackTable();
  30. BOOL CleanupLeakTrackTable();
  31. #endif // defined (LEAK_TRACK)
  32. enum
  33. {
  34. ENUM_TABLE_REMOVEKEY_CRITERIA_THISTHREAD = 1,
  35. ENUM_TABLE_REMOVEKEY_CRITERIA_ANYTHREAD = 2
  36. };
  37. HKEY HKEY_ClassesRoot = NULL;
  38. extern BOOL gbDllHasThreadState ;
  39. BOOL
  40. RegInitialize (
  41. IN HANDLE Handle,
  42. IN DWORD Reason,
  43. IN PVOID Reserved
  44. )
  45. /*++
  46. Routine Description:
  47. Returns TRUE.
  48. Arguments:
  49. Handle - Unused.
  50. Reason - Unused.
  51. Reserved - Unused.
  52. Return Value:
  53. BOOL - Returns TRUE.
  54. --*/
  55. {
  56. UNREFERENCED_PARAMETER( Handle );
  57. switch( Reason ) {
  58. case DLL_PROCESS_ATTACH:
  59. #ifndef REMOTE_NOTIFICATION_DISABLED
  60. if( !InitializeRegNotifyChangeKeyValue( ) ||
  61. !LocalInitializeRegCreateKey() ||
  62. !InitializePredefinedHandlesTable() ) {
  63. return( FALSE );
  64. }
  65. #else
  66. #if defined(_REGCLASS_MALLOC_INSTRUMENTED_)
  67. if ( !InitializeInstrumentedRegClassHeap()) {
  68. return FALSE;
  69. }
  70. #endif // defined(_REGCLASS_MALLOC_INSTRUMENTED_)
  71. if( !LocalInitializeRegCreateKey() ||
  72. !InitializePredefinedHandlesTable() ||
  73. !InitializeClassesRoot()) {
  74. return( FALSE );
  75. }
  76. #endif
  77. #if defined(LEAK_TRACK)
  78. InitializeLeakTrackTable();
  79. // ginore errors
  80. #endif // LEAK_TRACK
  81. return( TRUE );
  82. break;
  83. case DLL_PROCESS_DETACH:
  84. // Reserved == NULL when this is called via FreeLibrary,
  85. // we need to cleanup Performance keys.
  86. // Reserved != NULL when this is called during process exits,
  87. // no need to do anything.
  88. if( Reserved == NULL &&
  89. !CleanupPredefinedHandles()) {
  90. return( FALSE );
  91. }
  92. //initialized and used in ..\server\regclass.c
  93. if (NULL != HKEY_ClassesRoot)
  94. NtClose(HKEY_ClassesRoot);
  95. #ifndef REMOTE_NOTIFICATION_DISABLED
  96. if( !CleanupRegNotifyChangeKeyValue( ) ||
  97. !LocalCleanupRegCreateKey() ||
  98. !CleanupPredefinedHandlesTable() ||
  99. !CleanupClassesRoot( FALSE ) {
  100. return( FALSE );
  101. }
  102. #else
  103. if( !LocalCleanupRegCreateKey() ||
  104. !CleanupPredefinedHandlesTable() ||
  105. !CleanupClassesRoot( FALSE )) {
  106. return( FALSE );
  107. }
  108. #if defined(LEAK_TRACK)
  109. CleanupLeakTrackTable();
  110. #endif // LEAK_TRACK
  111. #if defined(_REGCLASS_MALLOC_INSTRUMENTED_)
  112. if ( !CleanupInstrumentedRegClassHeap()) {
  113. return FALSE;
  114. }
  115. #endif // defined(_REGCLASS_MALLOC_INSTRUMENTED_)
  116. #endif
  117. if ( !PerfRegCleanup() ) {
  118. return FALSE;
  119. }
  120. return( TRUE );
  121. break;
  122. case DLL_THREAD_ATTACH:
  123. break;
  124. case DLL_THREAD_DETACH:
  125. if ( gbDllHasThreadState ) {
  126. return CleanupClassesRoot( TRUE );
  127. }
  128. break;
  129. }
  130. return TRUE;
  131. }