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.

251 lines
4.6 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. mupdata.c
  5. Abstract:
  6. This module defines global MUP data.
  7. Author:
  8. Manny Weiser (mannyw) 20-Dec-1991
  9. Revision History:
  10. --*/
  11. #include "mup.h"
  12. //
  13. // MupGlobalLock is used to protect everything that is not protected
  14. // by its own lock.
  15. //
  16. MUP_LOCK MupGlobalLock = {0};
  17. //
  18. // MupVcbLock is used to protect access to the VCB itself.
  19. //
  20. ERESOURCE MupVcbLock = {0};
  21. //
  22. // MupPrefixTableLock is used to protect the prefix table.
  23. //
  24. MUP_LOCK MupPrefixTableLock = {0};
  25. //
  26. // MupCcbListLock is used to protect access to the CCB list for all FCBs
  27. //
  28. MUP_LOCK MupCcbListLock = {0};
  29. //
  30. // MupInterlock is used to protect access to block reference counts.
  31. //
  32. KSPIN_LOCK MupInterlock = {0};
  33. //
  34. // The global list of all providers. This list is protected by
  35. // MupGlobalLock.
  36. //
  37. LIST_ENTRY MupProviderList = {0};
  38. //
  39. // The list of Mup prefixes
  40. LIST_ENTRY MupPrefixList = {0};
  41. //
  42. // The list of active queries
  43. LIST_ENTRY MupMasterQueryList = {0};
  44. //
  45. // The number of registered providers.
  46. //
  47. ULONG MupProviderCount = 0;
  48. //
  49. // The prefix table save all known prefix blocks. It is protected by
  50. // MupPrefixTableLock.
  51. //
  52. UNICODE_PREFIX_TABLE MupPrefixTable = {0};
  53. //
  54. // The MUP IRP stack size.
  55. //
  56. CCHAR MupStackSize = 0;
  57. //
  58. // The MUP known prefix timeout. This is currently set at compile time.
  59. //
  60. LARGE_INTEGER MupKnownPrefixTimeout = {0};
  61. //
  62. // Indicator to know if provider ordering information has been read from
  63. // the registry.
  64. //
  65. BOOLEAN MupOrderInitialized = {0};
  66. //
  67. // When we need to ask several rdrs to do an operation, and they all fail,
  68. // we need to return a single error code. MupOrderedErrorList is a list
  69. // of status codes, from least important to most important, to guide in
  70. // determining which error codes should be returned. An error code
  71. // at a higher index will replace an error code at a lower index. An error
  72. // code not in the list always wins. This processing is in MupDereferenceMasterIoContext()
  73. //
  74. NTSTATUS MupOrderedErrorList[] = {
  75. STATUS_UNSUCCESSFUL,
  76. STATUS_INVALID_PARAMETER,
  77. STATUS_REDIRECTOR_NOT_STARTED,
  78. STATUS_BAD_NETWORK_NAME,
  79. STATUS_BAD_NETWORK_PATH,
  80. 0
  81. };
  82. //
  83. // This boolean indicates whether to enable the Dfs client or not.
  84. //
  85. BOOLEAN MupEnableDfs = FALSE;
  86. #ifdef MUPDBG
  87. MUP_LOCK MupDebugLock = {0};
  88. ULONG MupDebugTraceLevel = 0;
  89. ULONG MupDebugTraceIndent = 0;
  90. #endif
  91. #ifdef ALLOC_PRAGMA
  92. #pragma alloc_text( INIT, MupInitializeData )
  93. #pragma alloc_text( PAGE, MupUninitializeData )
  94. #endif
  95. NTSTATUS
  96. MupInitializeData(
  97. )
  98. /*++
  99. Routine Description:
  100. This routine initialize the MUP global data.
  101. Arguments:
  102. None
  103. Return Value:
  104. NTSTATUS - The function value is the final status from the data
  105. initialization.
  106. --*/
  107. {
  108. PAGED_CODE();
  109. INITIALIZE_LOCK(
  110. &MupGlobalLock,
  111. GLOBAL_LOCK_LEVEL,
  112. "MupGlobalLock"
  113. );
  114. INITIALIZE_LOCK(
  115. &MupPrefixTableLock,
  116. PREFIX_TABLE_LOCK_LEVEL,
  117. "MupPrefixTableLock"
  118. );
  119. INITIALIZE_LOCK(
  120. &MupCcbListLock,
  121. CCB_LIST_LOCK_LEVEL,
  122. "MupCcbListLock"
  123. );
  124. #ifdef MUPDBG
  125. INITIALIZE_LOCK(
  126. &MupDebugLock,
  127. DEBUG_LOCK_LEVEL,
  128. "MupDebugLock"
  129. );
  130. #endif
  131. KeInitializeSpinLock( &MupInterlock );
  132. ExInitializeResourceLite( &MupVcbLock );
  133. MupProviderCount = 0;
  134. InitializeListHead( &MupProviderList );
  135. InitializeListHead( &MupPrefixList );
  136. InitializeListHead( &MupMasterQueryList );
  137. RtlInitializeUnicodePrefix( &MupPrefixTable );
  138. MupStackSize = 3; // !!!
  139. //
  140. // Calculate the timeout in NT relative time.
  141. //
  142. MupKnownPrefixTimeout.QuadPart = UInt32x32To64(
  143. KNOWN_PREFIX_TIMEOUT * 60,
  144. 10 * 1000 * 1000
  145. );
  146. MupOrderInitialized = FALSE;
  147. return STATUS_SUCCESS;
  148. }
  149. VOID
  150. MupUninitializeData(
  151. )
  152. /*++
  153. Routine Description:
  154. This routine uninitializes the MUP global data.
  155. Arguments:
  156. None
  157. Return Value:
  158. None
  159. --*/
  160. {
  161. DELETE_LOCK(
  162. &MupGlobalLock
  163. );
  164. DELETE_LOCK(
  165. &MupPrefixTableLock
  166. );
  167. DELETE_LOCK(
  168. &MupCcbListLock
  169. );
  170. #ifdef MUPDBG
  171. DELETE_LOCK(
  172. &MupDebugLock
  173. );
  174. #endif
  175. ExDeleteResourceLite( &MupVcbLock );
  176. }