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.

408 lines
14 KiB

  1. /*++
  2. Copyright (c) 1990, 1991 Microsoft Corporation
  3. Module Name:
  4. cmdat.c
  5. Abstract:
  6. This module contains registry "static" data, except for data
  7. also used by setup, which is in cmdat2.c.
  8. Author:
  9. Bryan Willman (bryanwi) 19-Oct-93
  10. Environment:
  11. Kernel mode.
  12. Revision History:
  13. --*/
  14. #include "cmp.h"
  15. //
  16. // ***** INIT *****
  17. //
  18. #ifdef ALLOC_DATA_PRAGMA
  19. #pragma data_seg("INIT")
  20. #pragma const_seg("INITCONST")
  21. #endif
  22. //
  23. // ---------------------------
  24. //
  25. UNICODE_STRING CmpLoadOptions = { 0 }; // sys options from FW or boot.ini
  26. //
  27. // CmpClassString - contains strings which are used as the class
  28. // strings in the keynode.
  29. // The associated enumerated type is CONFIGURATION_CLASS in arc.h
  30. //
  31. UNICODE_STRING CmClassName[MaximumClass + 1] = { 0 };
  32. const PWCHAR CmClassString[MaximumClass + 1] = {
  33. L"System",
  34. L"Processor",
  35. L"Cache",
  36. L"Adapter",
  37. L"Controller",
  38. L"Peripheral",
  39. L"MemoryClass",
  40. L"Undefined"
  41. };
  42. struct {
  43. PCHAR AscString;
  44. USHORT InterfaceType;
  45. USHORT Count;
  46. } CmpMultifunctionTypes[] = {
  47. "ISA", Isa, 0,
  48. "MCA", MicroChannel, 0,
  49. "PCI", PCIBus, 0,
  50. "VME", VMEBus, 0,
  51. "PCMCIA", PCMCIABus, 0,
  52. "CBUS", CBus, 0,
  53. "MPIPI", MPIBus, 0,
  54. "MPSA", MPSABus, 0,
  55. NULL, Internal, 0
  56. };
  57. USHORT CmpUnknownBusCount = 0;
  58. ULONG CmpConfigurationAreaSize = 0x4000; // Initialize size = 16K
  59. PCM_FULL_RESOURCE_DESCRIPTOR CmpConfigurationData = { 0 };
  60. //
  61. // The following strings will be used as the keynames for registry
  62. // nodes.
  63. // The associated enumerated type is CONFIGURATION_TYPE in arc.h
  64. //
  65. UNICODE_STRING CmTypeName[MaximumType + 1] = { 0 };
  66. //
  67. // ***** PAGE *****
  68. //
  69. #ifdef ALLOC_DATA_PRAGMA
  70. #pragma data_seg("PAGEDATA")
  71. #pragma const_seg("PAGECONST")
  72. #endif
  73. const PWCHAR CmTypeString[MaximumType + 1] = {
  74. L"System",
  75. L"CentralProcessor",
  76. L"FloatingPointProcessor",
  77. L"PrimaryICache",
  78. L"PrimaryDCache",
  79. L"SecondaryICache",
  80. L"SecondaryDCache",
  81. L"SecondaryCache",
  82. L"EisaAdapter",
  83. L"TcAdapter",
  84. L"ScsiAdapter",
  85. L"DtiAdapter",
  86. L"MultifunctionAdapter",
  87. L"DiskController",
  88. L"TapeController",
  89. L"CdRomController",
  90. L"WormController",
  91. L"SerialController",
  92. L"NetworkController",
  93. L"DisplayController",
  94. L"ParallelController",
  95. L"PointerController",
  96. L"KeyboardController",
  97. L"AudioController",
  98. L"OtherController",
  99. L"DiskPeripheral",
  100. L"FloppyDiskPeripheral",
  101. L"TapePeripheral",
  102. L"ModemPeripheral",
  103. L"MonitorPeripheral",
  104. L"PrinterPeripheral",
  105. L"PointerPeripheral",
  106. L"KeyboardPeripheral",
  107. L"TerminalPeripheral",
  108. L"OtherPeripheral",
  109. L"LinePeripheral",
  110. L"NetworkPeripheral",
  111. L"SystemMemory",
  112. L"DockingInformation",
  113. L"RealModeIrqRoutingTable",
  114. L"RealModePCIEnumeration",
  115. L"Undefined"
  116. };
  117. //
  118. // CmpTypeCount[] - For each 'type', a count is used to keep track how many
  119. // keys have been created.
  120. //
  121. ULONG CmpTypeCount[NUMBER_TYPES] = {
  122. 0, // ArcSystem
  123. 0, // CentralProcessor",
  124. 0, // FloatingPointProcessor",
  125. 0, // PrimaryICache",
  126. 0, // PrimaryDCache",
  127. 0, // SecondaryICache",
  128. 0, // SecondaryDCache",
  129. 0, // SecondaryCache",
  130. 0, // EisaAdapter", (8)
  131. 0, // TcAdapter", (9)
  132. 0, // ScsiAdapter",
  133. 0, // DtiAdapter",
  134. 0, // MultifunctionAdapter", (12)
  135. 0, // DiskController", (13)
  136. 0, // TapeController",
  137. 0, // CdRomController",
  138. 0, // WormController",
  139. 0, // SerialController",
  140. 0, // NetworkController",
  141. 0, // DisplayController",
  142. 0, // ParallelController",
  143. 0, // PointerController",
  144. 0, // KeyboardController",
  145. 0, // AudioController",
  146. 0, // OtherController",
  147. 0, // DiskPeripheral",
  148. 0, // FloppyDiskPeripheral",
  149. 0, // TapePeripheral",
  150. 0, // ModemPeripheral",
  151. 0, // MonitorPeripheral",
  152. 0, // PrinterPeripheral",
  153. 0, // PointerPeripheral",
  154. 0, // KeyboardPeripheral",
  155. 0, // TerminalPeripheral",
  156. 0, // OtherPeripheral",
  157. 0, // LinePeripheral",
  158. 0, // NetworkPeripheral",
  159. 0, // SystemMemory",
  160. 0, // DockingInformation,
  161. 0, // RealModeIrqRoutingTable
  162. 0 // Undefined"
  163. };
  164. const UNICODE_STRING nullclass = { 0, 0, NULL };
  165. //
  166. // All names used by the registry
  167. //
  168. UNICODE_STRING CmRegistryRootName = { 0 };
  169. UNICODE_STRING CmRegistryMachineName = { 0 };
  170. UNICODE_STRING CmRegistryMachineHardwareName = { 0 };
  171. UNICODE_STRING CmRegistryMachineHardwareDescriptionName = { 0 };
  172. UNICODE_STRING CmRegistryMachineHardwareDescriptionSystemName = { 0 };
  173. UNICODE_STRING CmRegistryMachineHardwareDeviceMapName = { 0 };
  174. UNICODE_STRING CmRegistryMachineHardwareResourceMapName = { 0 };
  175. UNICODE_STRING CmRegistryMachineHardwareOwnerMapName = { 0 };
  176. UNICODE_STRING CmRegistryMachineSystemName = { 0 };
  177. UNICODE_STRING CmRegistryMachineSystemCurrentControlSet = { 0 };
  178. UNICODE_STRING CmRegistryMachineSystemCurrentControlSetEnumName = { 0 };
  179. UNICODE_STRING CmRegistryMachineSystemCurrentControlSetEnumRootName = { 0 };
  180. UNICODE_STRING CmRegistryMachineSystemCurrentControlSetServices = { 0 };
  181. UNICODE_STRING CmRegistryMachineSystemCurrentControlSetHardwareProfilesCurrent = { 0 };
  182. UNICODE_STRING CmRegistryMachineSystemCurrentControlSetControlClass = { 0 };
  183. UNICODE_STRING CmRegistryMachineSystemCurrentControlSetControlSafeBoot = { 0 };
  184. UNICODE_STRING CmRegistryMachineSystemCurrentControlSetControlSessionManagerMemoryManagement = { 0 };
  185. UNICODE_STRING CmRegistryMachineSystemCurrentControlSetControlBootLog = { 0 };
  186. UNICODE_STRING CmRegistryMachineSystemCurrentControlSetServicesEventLog = { 0 };
  187. UNICODE_STRING CmRegistryUserName = { 0 };
  188. UNICODE_STRING CmRegistrySystemCloneName = { 0 };
  189. UNICODE_STRING CmpSystemFileName = { 0 };
  190. UNICODE_STRING CmSymbolicLinkValueName = { 0 };
  191. #ifdef _WANT_MACHINE_IDENTIFICATION
  192. UNICODE_STRING CmRegistryMachineSystemCurrentControlSetControlBiosInfo = { 0 };
  193. #endif
  194. const PWCHAR CmpRegistryRootString = L"\\REGISTRY";
  195. const PWCHAR CmpRegistryMachineString = L"\\REGISTRY\\MACHINE";
  196. const PWCHAR CmpRegistryMachineHardwareString =
  197. L"\\REGISTRY\\MACHINE\\HARDWARE";
  198. const PWCHAR CmpRegistryMachineHardwareDescriptionString =
  199. L"\\REGISTRY\\MACHINE\\HARDWARE\\DESCRIPTION";
  200. const PWCHAR CmpRegistryMachineHardwareDescriptionSystemString =
  201. L"\\REGISTRY\\MACHINE\\HARDWARE\\DESCRIPTION\\SYSTEM";
  202. const PWCHAR CmpRegistryMachineHardwareDeviceMapString =
  203. L"\\REGISTRY\\MACHINE\\HARDWARE\\DEVICEMAP";
  204. const PWCHAR CmpRegistryMachineHardwareResourceMapString =
  205. L"\\REGISTRY\\MACHINE\\HARDWARE\\RESOURCEMAP";
  206. const PWCHAR CmpRegistryMachineHardwareOwnerMapString =
  207. L"\\REGISTRY\\MACHINE\\HARDWARE\\OWNERMAP";
  208. const PWCHAR CmpRegistryMachineSystemString =
  209. L"\\REGISTRY\\MACHINE\\SYSTEM";
  210. const PWCHAR CmpRegistryMachineSystemCurrentControlSetString =
  211. L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET";
  212. const PWCHAR CmpRegistryMachineSystemCurrentControlSetEnumString =
  213. L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET\\ENUM";
  214. const PWCHAR CmpRegistryMachineSystemCurrentControlSetEnumRootString =
  215. L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET\\ENUM\\ROOT";
  216. const PWCHAR CmpRegistryMachineSystemCurrentControlSetServicesString =
  217. L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET\\SERVICES";
  218. const PWCHAR CmpRegistryMachineSystemCurrentControlSetHardwareProfilesCurrentString =
  219. L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET\\HARDWARE PROFILES\\CURRENT";
  220. const PWCHAR CmpRegistryMachineSystemCurrentControlSetControlClassString =
  221. L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET\\CONTROL\\CLASS";
  222. const PWCHAR CmpRegistryMachineSystemCurrentControlSetControlSafeBootString =
  223. L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET\\CONTROL\\SAFEBOOT";
  224. const PWCHAR CmpRegistryMachineSystemCurrentControlSetControlSessionManagerMemoryManagementString =
  225. L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET\\CONTROL\\SESSION MANAGER\\MEMORY MANAGEMENT";
  226. const PWCHAR CmpRegistryMachineSystemCurrentControlSetControlBootLogString =
  227. L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET\\CONTROL\\BOOTLOG";
  228. const PWCHAR CmpRegistryMachineSystemCurrentControlSetServicesEventLogString =
  229. L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET\\SERVICES\\EVENTLOG";
  230. const PWCHAR CmpRegistryUserString = L"\\REGISTRY\\USER";
  231. const PWCHAR CmpRegistrySystemCloneString = L"\\REGISTRY\\MACHINE\\CLONE";
  232. const PWCHAR CmpRegistrySystemFileNameString = L"SYSTEM";
  233. const PWCHAR CmpRegistryPerflibString = L"\\REGISTRY\\MACHINE\\SOFTWARE\\MICROSOFT\\WINDOWS NT\\CURRENTVERSION\\PERFLIB";
  234. const PWCHAR CmpProcessorControl = L"ProcessorControl";
  235. const PWCHAR CmpControlSessionManager = L"Control\\Session Manager";
  236. const PWCHAR CmpSymbolicLinkValueName = L"SymbolicLinkValue";
  237. #ifdef _WANT_MACHINE_IDENTIFICATION
  238. const PWCHAR CmpRegistryMachineSystemCurrentControlSetControlBiosInfoString =
  239. L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET\\CONTROL\\BIOSINFO";
  240. #endif
  241. //
  242. // N.B. The CLONE hive is left out of the machine Hive list if
  243. // we will not be using it to clone the current control set,
  244. // since that is that Hive's only purpose.
  245. //
  246. HIVE_LIST_ENTRY CmpMachineHiveList[] = {
  247. { L"HARDWARE", L"MACHINE\\", NULL, HIVE_VOLATILE , 0 , NULL, FALSE, FALSE, FALSE},
  248. { L"SECURITY", L"MACHINE\\", NULL, 0 , 0 , NULL, FALSE, FALSE, FALSE},
  249. { L"SOFTWARE", L"MACHINE\\", NULL, 0 , 0 , NULL, FALSE, FALSE, FALSE},
  250. { L"SYSTEM", L"MACHINE\\", NULL, 0 , 0 , NULL, FALSE, FALSE, FALSE},
  251. { L"DEFAULT", L"USER\\.DEFAULT", NULL, 0 , CM_CMHIVE_FLAG_UNTRUSTED , NULL, FALSE, FALSE, FALSE},
  252. { L"SAM", L"MACHINE\\", NULL, HIVE_NOLAZYFLUSH , 0 , NULL, FALSE, FALSE, FALSE},
  253. #if CLONE_CONTROL_SET
  254. { L"CLONE", L"MACHINE\\", NULL, HIVE_VOLATILE , 0 , NULL, FALSE, FALSE, FALSE},
  255. #endif
  256. // { L"TEST", L"MACHINE\\", NULL, HIVE_NOLAZYFLUSH , 0 , NULL, FALSE, FALSE, FALSE},
  257. { NULL, NULL, 0, 0 , 0 , NULL, FALSE, FALSE, FALSE}
  258. };
  259. UCHAR SystemHiveFullPathBuffer[MAX_NAME];
  260. UNICODE_STRING SystemHiveFullPathName;
  261. //
  262. // Master Hive
  263. //
  264. // The KEY_NODEs for \REGISTRY, \REGISTRY\MACHINE, and \REGISTRY\USER
  265. // are stored in a small memory only hive called the Master Hive.
  266. // All other hives have link nodes in this hive which point to them.
  267. //
  268. PCMHIVE CmpMasterHive = { 0 };
  269. BOOLEAN CmpNoMasterCreates = FALSE; // Set TRUE after we're done to
  270. // prevent random creates in the
  271. // master hive, which is not backed
  272. // by a file.
  273. LIST_ENTRY CmpHiveListHead = { 0 }; // List of CMHIVEs
  274. FAST_MUTEX CmpHiveListHeadLock; // used to protect the list above
  275. //
  276. // Addresses of object type descriptors:
  277. //
  278. POBJECT_TYPE CmpKeyObjectType = { 0 };
  279. //
  280. // Write-Control:
  281. // CmpNoWrite is initially true. When set this way write and flush
  282. // do nothing, simply returning success. When cleared to FALSE, I/O
  283. // is enabled. This change is made after the I/O system is started
  284. // AND autocheck (chkdsk) has done its thing.
  285. //
  286. BOOLEAN CmpNoWrite = TRUE;
  287. //
  288. // NtInitializeRegistry global status flags
  289. //
  290. //
  291. // If CmFirstTime is TRUE, then NtInitializeRegistry has not yet been
  292. // called to perform basic registry initialization
  293. //
  294. BOOLEAN CmFirstTime = TRUE;
  295. //
  296. // trick to allow paralel threads to access the registry
  297. //
  298. BOOLEAN CmpSpecialBootCondition = FALSE;
  299. //
  300. // If CmBootAcceptFirstTime is TRUE, then NtInitializeRegistry has not
  301. // yet been called to accept the current Boot and save the boot
  302. // control set as the LKG control set.
  303. //
  304. BOOLEAN CmBootAcceptFirstTime = TRUE;
  305. //
  306. // CmpWasSetupBoot indicates whether or not the boot
  307. // is into text mode setup. If so, we do not turn
  308. // on global quotas.
  309. //
  310. BOOLEAN CmpWasSetupBoot;
  311. //
  312. // Indicates whether the hives need to be loaded in memory
  313. // and in scratch mode
  314. //
  315. BOOLEAN CmpMiniNTBoot = FALSE;
  316. //
  317. // Indicates whether the system hives need to be opened in a
  318. // shared mode. Generally needed if we are booting WinPE (MiniNT)
  319. // on network
  320. //
  321. BOOLEAN CmpShareSystemHives = FALSE;
  322. //
  323. // Where are we booting from
  324. //
  325. ULONG CmpBootType;
  326. //
  327. // Self healing hives control switch
  328. //
  329. BOOLEAN CmpSelfHeal = TRUE;
  330. #ifdef ALLOC_DATA_PRAGMA
  331. #pragma const_seg()
  332. #pragma data_seg()
  333. #endif
  334. //
  335. // ***** FIXED *****
  336. //