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.

783 lines
34 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. iodata.c
  5. Abstract:
  6. This module contains the global read/write data for the I/O system.
  7. Author:
  8. Darryl E. Havens (darrylh) April 27, 1989
  9. Revision History:
  10. --*/
  11. #include "iomgr.h"
  12. //
  13. // Define the global read/write data for the I/O system.
  14. //
  15. // The following lock is used to guard access to the CancelRoutine address
  16. // in IRPs. It must be locked to set the address of a routine, clear the
  17. // address of a routine, when a cancel routine is invoked, or when
  18. // manipulating any structure that will set a cancel routine address in
  19. // a packet.
  20. //
  21. // extern KSPIN_LOCK IopCancelSpinLock;
  22. //
  23. // The following lock is used to guard access to VPB data structures. It
  24. // must be held each time the reference count, mount flag, or device object
  25. // fields of a VPB are manipulated.
  26. //
  27. // extern KSPIN_LOCK IopVpbSpinLock;
  28. //
  29. // The following lock is used to guard access to the I/O system database for
  30. // unloading drivers. It must be locked to increment or decrement device
  31. // reference counts and to set the unload pending flag in a device object.
  32. // The lock is allocated by the I/O system during phase 1 initialization.
  33. //
  34. // This lock is also used to decrement the count of Associated IRPs for a
  35. // given Master IRP.
  36. //
  37. // extern KSPIN_LOCK IopDatabaseLock;
  38. //
  39. // The following resource is used to control access to the I/O system's
  40. // database. It allows exclusive access to the file system queue for
  41. // registering a file system as well as shared access to the same when
  42. // searching for a file system to mount a volume on some media. The resource
  43. // is initialized by the I/O system initialization code during phase 1
  44. // initialization.
  45. //
  46. ERESOURCE IopDatabaseResource;
  47. //
  48. // The following resource is used to control access to security descriptors
  49. // on devices. It allows multiple readers to perform security checks and
  50. // queries on device security, but only a single writer to modify the security
  51. // on a device at a time.
  52. //
  53. ERESOURCE IopSecurityResource;
  54. //
  55. // The following queue header contains the list of disk file systems currently
  56. // loaded into the system. The list actually contains the device objects
  57. // for each of the file systems in the system. Access to this queue is
  58. // protected using the IopDatabaseResource for exclusive (write) or shared
  59. // (read) access locks.
  60. //
  61. LIST_ENTRY IopDiskFileSystemQueueHead;
  62. //
  63. // The following queue header contains the list of CD ROM file systems currently
  64. // loaded into the system. The list actually contains the device objects
  65. // for each of the file systems in the system. Access to this queue is
  66. // protected using the IopDatabaseResource for exclusive (write) or shared
  67. // (read) access locks.
  68. //
  69. LIST_ENTRY IopCdRomFileSystemQueueHead;
  70. //
  71. // The following queue header contains the list of network file systems
  72. // (redirectors) currently loaded into the system. The list actually
  73. // contains the device objects for each of the network file systems in the
  74. // system. Access to this queue is protected using the IopDatabaseResource
  75. // for exclusive (write) or shared (read) access locks.
  76. //
  77. LIST_ENTRY IopNetworkFileSystemQueueHead;
  78. //
  79. // The following queue header contains the list of tape file systems currently
  80. // loaded into the system. The list actually contains the device objects
  81. // for each of the file systems in the system. Access to this queue is
  82. // protected using the IopDatabaseResource for exclusive (write) or shared
  83. // (read) access locks.
  84. //
  85. LIST_ENTRY IopTapeFileSystemQueueHead;
  86. //
  87. // The following queue header contains the list of boot drivers that have
  88. // registered for a call back once all devices have been enumerated.
  89. //
  90. LIST_ENTRY IopBootDriverReinitializeQueueHead;
  91. //
  92. // The following queue header contains the list of drivers that have
  93. // registered reinitialization routines.
  94. //
  95. LIST_ENTRY IopDriverReinitializeQueueHead;
  96. //
  97. // The following queue headers contain the lists of the drivers that have
  98. // registered shutdown notification routines.
  99. //
  100. LIST_ENTRY IopNotifyShutdownQueueHead;
  101. LIST_ENTRY IopNotifyLastChanceShutdownQueueHead;
  102. //
  103. // The following queue header contains the list of the driver that have
  104. // registered to be notified when a file system registers or unregisters itself
  105. // as an active file system.
  106. //
  107. LIST_ENTRY IopFsNotifyChangeQueueHead;
  108. //
  109. // The following are the lookaside lists used to keep track of the two I/O
  110. // Request Packet (IRP), the Memory Descriptor List (MDL) Lookaside list, and
  111. // the I/O Completion List (ICP) Lookaside list.
  112. //
  113. // The "large" IRP contains 4 stack locations, the maximum in the SDK, and the
  114. // "small" IRP contains a single entry, the most common case for devices other
  115. // than disks and network devices.
  116. //
  117. GENERAL_LOOKASIDE IopCompletionLookasideList;
  118. GENERAL_LOOKASIDE IopLargeIrpLookasideList;
  119. GENERAL_LOOKASIDE IopSmallIrpLookasideList;
  120. GENERAL_LOOKASIDE IopMdlLookasideList;
  121. ULONG IopLargeIrpStackLocations;
  122. //
  123. // The following spinlock is used to control access to the I/O system's error
  124. // log database. It is initialized by the I/O system initialization code when
  125. // the system is being initialized. This lock must be owned in order to insert
  126. // or remove entries from either the free or entry queue.
  127. //
  128. // extern KSPIN_LOCK IopErrorLogLock;
  129. //
  130. // The following is the list head for all error log entries in the system which
  131. // have not yet been sent to the error log process. Entries are written placed
  132. // onto the list by the IoWriteElEntry procedure.
  133. //
  134. LIST_ENTRY IopErrorLogListHead;
  135. //
  136. // The following is used to track how much memory is allocated to I/O error log
  137. // packets. The spinlock is used to protect this variable.
  138. //
  139. ULONG IopErrorLogAllocation;
  140. // extern KSPIN_LOCK IopErrorLogAllocationLock;
  141. //
  142. // The following spinlock is used by the I/O system to synchronize examining
  143. // the thread field of an I/O Request Packet so that the request can be
  144. // queued as a special kernel APC to the thread. The reason that the
  145. // spinlock must be used is for cases when the request times out, and so
  146. // the thread has been permitted to possibly exit.
  147. //
  148. // extern KSPIN_LOCK IopCompletionLock;
  149. //
  150. // The following global contains the queue of informational hard error
  151. // pop-ups.
  152. //
  153. IOP_HARD_ERROR_QUEUE IopHardError;
  154. //
  155. // The following global is non-null when there is a pop-up on the screen
  156. // waiting for user action. It points to that packet.
  157. //
  158. PIOP_HARD_ERROR_PACKET IopCurrentHardError;
  159. //
  160. // The following are used to implement the I/O system's one second timer.
  161. // The lock protects access to the queue, the queue contains an entry for
  162. // each driver that needs to be invoked, and the timer and DPC data
  163. // structures are used to actually get the internal timer routine invoked
  164. // once every second. The count is used to maintain the number of timer
  165. // entries that actually indicate that the driver is to be invoked.
  166. //
  167. // extern KSPIN_LOCK IopTimerLock;
  168. LIST_ENTRY IopTimerQueueHead;
  169. KDPC IopTimerDpc;
  170. KTIMER IopTimer;
  171. ULONG IopTimerCount;
  172. //
  173. // The following are the global pointers for the Object Type Descriptors that
  174. // are created when each of the I/O specific object types are created.
  175. //
  176. POBJECT_TYPE IoAdapterObjectType;
  177. POBJECT_TYPE IoControllerObjectType;
  178. POBJECT_TYPE IoCompletionObjectType;
  179. POBJECT_TYPE IoDeviceObjectType;
  180. POBJECT_TYPE IoDriverObjectType;
  181. POBJECT_TYPE IoDeviceHandlerObjectType;
  182. POBJECT_TYPE IoFileObjectType;
  183. ULONG IoDeviceHandlerObjectSize;
  184. //
  185. // The following is a global lock and counters for I/O operations requested
  186. // on a system-wide basis. The first three counters simply track the number
  187. // of read, write, and other types of operations that have been requested.
  188. // The latter three counters track the actual number of bytes that have been
  189. // transferred throughout the system.
  190. //
  191. // extern KSPIN_LOCK IoStatisticsLock;
  192. ULONG IoReadOperationCount;
  193. ULONG IoWriteOperationCount;
  194. ULONG IoOtherOperationCount;
  195. LARGE_INTEGER IoReadTransferCount;
  196. LARGE_INTEGER IoWriteTransferCount;
  197. LARGE_INTEGER IoOtherTransferCount;
  198. //
  199. // The following is the base pointer for the crash dump control block that is
  200. // used to control dumping all of physical memory to the paging file after a
  201. // system crash. And, the checksum for the dump control block is also declared.
  202. //
  203. PDUMP_CONTROL_BLOCK IopDumpControlBlock;
  204. ULONG IopDumpControlBlockChecksum;
  205. //
  206. // The following are the spin lock and event that allow the I/O system to
  207. // implement fast file object locks.
  208. //
  209. KEVENT IopFastLockEvent;
  210. //
  211. // The following is a monotonically increasing number (retrieved via
  212. // InterlockedIncrement) that is used by IoCreateDevice to automatically
  213. // generate a device object name when the FILE_AUTOGENERATED_DEVICE_NAME
  214. // device characteristic is specified.
  215. //
  216. LONG IopUniqueDeviceObjectNumber;
  217. //
  218. // IoRemoteBootClient indicates whether the system was booted as a remote
  219. // boot client.
  220. //
  221. BOOLEAN IoRemoteBootClient;
  222. //
  223. // Counts number of Fs registration/unregistrations
  224. //
  225. ULONG IopFsRegistrationOps;
  226. //
  227. // Reserve IRP allocator for paging reads.
  228. //
  229. IOP_RESERVE_IRP_ALLOCATOR IopReserveIrpAllocator;
  230. #if defined(REMOTE_BOOT)
  231. //
  232. // The following indicates whether or not the Client Side Caching subsystem
  233. // was successfully initialized.
  234. //
  235. BOOLEAN IoCscInitializationFailed;
  236. #endif
  237. //
  238. // The following are used to synchronize with the link tracking service while establishing a connection.
  239. //
  240. KEVENT IopLinkTrackingPortObject;
  241. LINK_TRACKING_PACKET IopLinkTrackingPacket;
  242. IOP_IRP_STACK_PROFILER IopIrpStackProfiler;
  243. //
  244. // Function pointers of key IO routines.
  245. // The functions need to be in their own cache lines as they are readonly and
  246. // never modified after boot.
  247. //
  248. #define CACHE_SIZE 128
  249. UCHAR IopPrePadding[CACHE_SIZE] = {0};
  250. PIO_CALL_DRIVER pIofCallDriver = 0;
  251. PIO_COMPLETE_REQUEST pIofCompleteRequest = 0;
  252. PIO_ALLOCATE_IRP pIoAllocateIrp = 0;
  253. PIO_FREE_IRP pIoFreeIrp = 0;
  254. UCHAR IopPostPadding[CACHE_SIZE] = {0};
  255. //*********
  256. //
  257. // Note: All of the following data is potentially pageable, depending on the
  258. // target platform.
  259. //
  260. //*********
  261. #ifdef ALLOC_DATA_PRAGMA
  262. #pragma data_seg("PAGEDATA")
  263. #pragma const_seg("PAGECONST")
  264. #endif
  265. //
  266. // The following are used to store the handle and a pointer to the referenced
  267. // whenever a file is moved across systems.
  268. //
  269. PVOID IopLinkTrackingServiceObject;
  270. PKEVENT IopLinkTrackingServiceEvent;
  271. HANDLE IopLinkTrackingServiceEventHandle;
  272. //
  273. // The following array specifies the minimum length of the FileInformation
  274. // buffer for an NtQueryInformationFile service.
  275. //
  276. // WARNING: This array depends on the order of the values in the
  277. // FileInformationClass enumerated type. Note that the
  278. // enumerated type is one-based and the array is zero-based.
  279. //
  280. const UCHAR IopQueryOperationLength[] =
  281. {
  282. 0,
  283. 0, // 1 FileDirectoryInformation
  284. 0, // 2 FileFullDirectoryInformation
  285. 0, // 3 FileBothDirectoryInformation
  286. sizeof( FILE_BASIC_INFORMATION ), // 4 FileBasicInformation
  287. sizeof( FILE_STANDARD_INFORMATION ), // 5 FileStandardInformation
  288. sizeof( FILE_INTERNAL_INFORMATION ), // 6 FileInternalInformation
  289. sizeof( FILE_EA_INFORMATION ), // 7 FileEaInformation
  290. sizeof( FILE_ACCESS_INFORMATION ), // 8 FileAccessInformation
  291. sizeof( FILE_NAME_INFORMATION ), // 9 FileNameInformation
  292. 0, // 10 FileRenameInformation
  293. 0, // 11 FileLinkInformation
  294. 0, // 12 FileNamesInformation
  295. 0, // 13 FileDispositionInformation
  296. sizeof( FILE_POSITION_INFORMATION ), // 14 FilePositionInformation
  297. 0, // 15 FileFullEaInformation
  298. sizeof( FILE_MODE_INFORMATION ), // 16 FileModeInformation
  299. sizeof( FILE_ALIGNMENT_INFORMATION ), // 17 FileAlignmentInformation
  300. sizeof( FILE_ALL_INFORMATION ), // 18 FileAllInformation
  301. 0, // 19 FileAllocationInformation
  302. 0, // 20 FileEndOfFileInformation
  303. sizeof( FILE_NAME_INFORMATION ), // 21 FileAlternateNameInformation
  304. sizeof( FILE_STREAM_INFORMATION ), // 22 FileStreamInformation
  305. sizeof( FILE_PIPE_INFORMATION ), // 23 FilePipeInformation
  306. sizeof( FILE_PIPE_LOCAL_INFORMATION ), // 24 FilePipeLocalInformation
  307. sizeof( FILE_PIPE_REMOTE_INFORMATION ), // 25 FilePipeRemoteInformation
  308. sizeof( FILE_MAILSLOT_QUERY_INFORMATION ), // 26 FileMailslotQueryInformation
  309. 0, // 27 FileMailslotSetInformation
  310. sizeof( FILE_COMPRESSION_INFORMATION ), // 28 FileCompressionInformation
  311. sizeof( FILE_OBJECTID_INFORMATION ), // 29 FileObjectIdInformation
  312. 0, // 30 FileCompletionInformation
  313. 0, // 31 FileMoveClusterInformation
  314. sizeof( FILE_QUOTA_INFORMATION ), // 32 FileQuotaInformation
  315. sizeof( FILE_REPARSE_POINT_INFORMATION ), // 33 FileReparsePointInformation
  316. sizeof( FILE_NETWORK_OPEN_INFORMATION), // 34 FileNetworkOpenInformation
  317. sizeof( FILE_ATTRIBUTE_TAG_INFORMATION), // 35 FileAttributeTagInformation
  318. 0, // 36 FileTrackingInformation
  319. 0, // 37 FileIdBothDiretoryInformation
  320. 0, // 38 FileIdFullDiretoryInformation
  321. 0, // 39 FileValidDataLengthInformation
  322. 0, // 40 FileShortNameInformation
  323. 0xff // FileMaximumInformation
  324. };
  325. //
  326. // The following array specifies the minimum length of the FileInformation
  327. // buffer for an NtSetInformationFile service.
  328. //
  329. // WARNING: This array depends on the order of the values in the
  330. // FileInformationClass enumerated type. Note that the
  331. // enumerated type is one-based and the array is zero-based.
  332. //
  333. const UCHAR IopSetOperationLength[] =
  334. {
  335. 0,
  336. 0, // 1 FileDirectoryInformation
  337. 0, // 2 FileFullDirectoryInformation
  338. 0, // 3 FileBothDirectoryInformation
  339. sizeof( FILE_BASIC_INFORMATION ), // 4 FileBasicInformation
  340. 0, // 5 FileStandardInformation
  341. 0, // 6 FileInternalInformation
  342. 0, // 7 FileEaInformation
  343. 0, // 8 FileAccessInformation
  344. 0, // 9 FileNameInformation
  345. sizeof( FILE_RENAME_INFORMATION ), // 10 FileRenameInformation
  346. sizeof( FILE_LINK_INFORMATION ), // 11 FileLinkInformation
  347. 0, // 12 FileNamesInformation
  348. sizeof( FILE_DISPOSITION_INFORMATION ), // 13 FileDispositionInformation
  349. sizeof( FILE_POSITION_INFORMATION ), // 14 FilePositionInformation
  350. 0, // 15 FileFullEaInformation
  351. sizeof( FILE_MODE_INFORMATION ), // 16 FileModeInformation
  352. 0, // 17 FileAlignmentInformation
  353. 0, // 18 FileAllInformation
  354. sizeof( FILE_ALLOCATION_INFORMATION ), // 19 FileAllocationInformation
  355. sizeof( FILE_END_OF_FILE_INFORMATION ), // 20 FileEndOfFileInformation
  356. 0, // 21 FileAlternateNameInformation
  357. 0, // 22 FileStreamInformation
  358. sizeof( FILE_PIPE_INFORMATION ), // 23 FilePipeInformation
  359. 0, // 24 FilePipeLocalInformation
  360. sizeof( FILE_PIPE_REMOTE_INFORMATION ), // 25 FilePipeRemoteInformation
  361. 0, // 26 FileMailslotQueryInformation
  362. sizeof( FILE_MAILSLOT_SET_INFORMATION ), // 27 FileMailslotSetInformation
  363. 0, // 28 FileCompressionInformation
  364. sizeof( FILE_OBJECTID_INFORMATION ), // 29 FileObjectIdInformation
  365. sizeof( FILE_COMPLETION_INFORMATION ), // 30 FileCompletionInformation
  366. sizeof( FILE_MOVE_CLUSTER_INFORMATION ), // 31 FileMoveClusterInformation
  367. sizeof( FILE_QUOTA_INFORMATION ), // 32 FileQuotaInformation
  368. 0, // 33 FileReparsePointInformation
  369. 0, // 34 FileNetworkOpenInformation
  370. 0, // 35 FileAttributeTagInformation
  371. sizeof( FILE_TRACKING_INFORMATION ), // 36 FileTrackingInformation
  372. 0, // 37 FileIdBothDiretoryInformation
  373. 0, // 38 FileIdFullDiretoryInformation
  374. sizeof( FILE_VALID_DATA_LENGTH_INFORMATION ), // 39 FileValidDataLengthInformation
  375. sizeof( FILE_NAME_INFORMATION ), // 40 FileShortNameInformation
  376. 0xff // FileMaximumInformation
  377. };
  378. //
  379. // The following array specifies the alignment requirement of both all query
  380. // and set operations, including directory operations, but not FS operations.
  381. //
  382. // WARNING: This array depends on the order of the values in the
  383. // FileInformationClass enumerated type. Note that the
  384. // enumerated type is one-based and the array is zero-based.
  385. //
  386. const UCHAR IopQuerySetAlignmentRequirement[] =
  387. {
  388. 0,
  389. sizeof( LONGLONG ), // 1 FileDirectoryInformation
  390. sizeof( LONGLONG ), // 2 FileFullDirectoryInformation
  391. sizeof( LONGLONG ), // 3 FileBothDirectoryInformation
  392. sizeof( LONGLONG ), // 4 FileBasicInformation
  393. sizeof( LONGLONG ), // 5 FileStandardInformation
  394. sizeof( LONGLONG ), // 6 FileInternalInformation
  395. sizeof( LONG ), // 7 FileEaInformation
  396. sizeof( LONG ), // 8 FileAccessInformation
  397. sizeof( LONG ), // 9 FileNameInformation
  398. sizeof( LONG ), // 10 FileRenameInformation
  399. sizeof( LONG ), // 11 FileLinkInformation
  400. sizeof( LONG ), // 12 FileNamesInformation
  401. sizeof( CHAR ), // 13 FileDispositionInformation
  402. sizeof( LONGLONG ), // 14 FilePositionInformation
  403. sizeof( LONG ), // 15 FileFullEaInformation
  404. sizeof( LONG ), // 16 FileModeInformation
  405. sizeof( LONG ), // 17 FileAlignmentInformation
  406. sizeof( LONGLONG ), // 18 FileAllInformation
  407. sizeof( LONGLONG ), // 19 FileAllocationInformation
  408. sizeof( LONGLONG ), // 20 FileEndOfFileInformation
  409. sizeof( LONG ), // 21 FileAlternateNameInformation
  410. sizeof( LONGLONG ), // 22 FileStreamInformation
  411. sizeof( LONG ), // 23 FilePipeInformation
  412. sizeof( LONG ), // 24 FilePipeLocalInformation
  413. sizeof( LONG ), // 25 FilePipeRemoteInformation
  414. sizeof( LONGLONG ), // 26 FileMailslotQueryInformation
  415. sizeof( LONG ), // 27 FileMailslotSetInformation
  416. sizeof( LONGLONG ), // 28 FileCompressionInformation
  417. sizeof( LONG ), // 29 FileObjectIdInformation
  418. sizeof( LONG ), // 30 FileCompletionInformation
  419. sizeof( LONG ), // 31 FileMoveClusterInformation
  420. sizeof( LONG ), // 32 FileQuotaInformation
  421. sizeof( LONG ), // 33 FileReparsePointInformation
  422. sizeof( LONGLONG ), // 34 FileNetworkOpenInformation
  423. sizeof( LONG ), // 35 FileAttributeTagInformation
  424. sizeof( LONG ), // 36 FileTrackingInformation
  425. sizeof( LONGLONG ), // 37 FileIdBothDiretoryInformation
  426. sizeof( LONGLONG ), // 38 FileIdFullDiretoryInformation
  427. sizeof( LONGLONG ), // 39 FileValidDataLengthInformation
  428. sizeof( LONG ), // 40 FileShortNameInformation
  429. 0xff // FileMaximumInformation
  430. };
  431. //
  432. // The following array specifies the required access mask for the caller to
  433. // access information in an NtQueryXxxFile service.
  434. //
  435. // WARNING: This array depends on the order of the values in the
  436. // FileInformationClass enumerated type. Note that the
  437. // enumerated type is one-based and the array is zero-based.
  438. //
  439. const ULONG IopQueryOperationAccess[] =
  440. {
  441. 0,
  442. 0, // 1 FileDirectoryInformation
  443. 0, // 2 FileFullDirectoryInformation
  444. 0, // 3 FileBothDirectoryInformation
  445. FILE_READ_ATTRIBUTES, // 4 FileBasicInformation
  446. 0, // 5 FileStandardInformation
  447. 0, // 6 FileInternalInformation
  448. 0, // 7 FileEaInformation
  449. 0, // 8 FileAccessInformation
  450. 0, // 9 FileNameInformation
  451. 0, // 10 FileRenameInformation
  452. 0, // 11 FileLinkInformation
  453. 0, // 12 FileNamesInformation
  454. 0, // 13 FileDispositionInformation
  455. 0, // 14 FilePositionInformation
  456. FILE_READ_EA, // 15 FileFullEaInformation
  457. 0, // 16 FileModeInformation
  458. 0, // 17 FileAlignmentInformation
  459. FILE_READ_ATTRIBUTES, // 18 FileAllInformation
  460. 0, // 19 FileAllocationInformation
  461. 0, // 20 FileEndOfFileInformation
  462. 0, // 21 FileAlternateNameInformation
  463. 0, // 22 FileStreamInformation
  464. FILE_READ_ATTRIBUTES, // 23 FilePipeInformation
  465. FILE_READ_ATTRIBUTES, // 24 FilePipeLocalInformation
  466. FILE_READ_ATTRIBUTES, // 25 FilePipeRemoteInformation
  467. 0, // 26 FileMailslotQueryInformation
  468. 0, // 27 FileMailslotSetInformation
  469. 0, // 28 FileCompressionInformation
  470. 0, // 29 FileObjectIdInformation
  471. 0, // 30 FileCompletionInformation
  472. 0, // 31 FileMoveClusterInformation
  473. 0, // 32 FileQuotaInformation
  474. 0, // 33 FileReparsePointInformation
  475. FILE_READ_ATTRIBUTES, // 34 FileNetworkOpenInformation
  476. FILE_READ_ATTRIBUTES, // 35 FileAttributeTagInformation
  477. 0, // 36 FileTrackingInformation
  478. 0, // 37 FileIdBothDiretoryInformation
  479. 0, // 38 FileIdFullDiretoryInformation
  480. 0, // 39 FileValidDataLengthInformation
  481. 0, // 40 FileShortNameInformation
  482. 0xffffffff // FileMaximumInformation
  483. };
  484. //
  485. // The following array specifies the required access mask for the caller to
  486. // access information in an NtSetXxxFile service.
  487. //
  488. // WARNING: This array depends on the order of the values in the
  489. // FILE_INFORMATION_CLASS enumerated type. Note that the
  490. // enumerated type is one-based and the array is zero-based.
  491. //
  492. const ULONG IopSetOperationAccess[] =
  493. {
  494. 0,
  495. 0, // 1 FileDirectoryInformation
  496. 0, // 2 FileFullDirectoryInformation
  497. 0, // 3 FileBothDirectoryInformation
  498. FILE_WRITE_ATTRIBUTES, // 4 FileBasicInformation
  499. 0, // 5 FileStandardInformation
  500. 0, // 6 FileInternalInformation
  501. 0, // 7 FileEaInformation
  502. 0, // 8 FileAccessInformation
  503. 0, // 9 FileNameInformation
  504. DELETE, // 10 FileRenameInformation
  505. 0, // 11 FileLinkInformation
  506. 0, // 12 FileNamesInformation
  507. DELETE, // 13 FileDispositionInformation
  508. 0, // 14 FilePositionInformation
  509. FILE_WRITE_EA, // 15 FileFullEaInformation
  510. 0, // 16 FileModeInformation
  511. 0, // 17 FileAlignmentInformation
  512. 0, // 18 FileAllInformation
  513. FILE_WRITE_DATA, // 19 FileAllocationInformation
  514. FILE_WRITE_DATA, // 20 FileEndOfFileInformation
  515. 0, // 21 FileAlternateNameInformation
  516. 0, // 22 FileStreamInformation
  517. FILE_WRITE_ATTRIBUTES, // 23 FilePipeInformation
  518. 0, // 24 FilePipeLocalInformation
  519. FILE_WRITE_ATTRIBUTES, // 25 FilePipeRemoteInformation
  520. 0, // 26 FileMailslotQueryInformation
  521. 0, // 27 FileMailslotSetInformation
  522. 0, // 28 FileCompressionInformation
  523. 0, // 29 FileObjectIdInformation
  524. 0, // 30 FileCompletionInformation
  525. FILE_WRITE_DATA, // 31 FileMoveClusterInformation
  526. 0, // 32 FileQuotaInformation
  527. 0, // 33 FileReparsePointInformation
  528. 0, // 34 FileNetworkOpenInformation
  529. 0, // 35 FileAttributeTagInformation
  530. FILE_WRITE_DATA, // 36 FileTrackingInformation
  531. 0, // 37 FileIdBothDiretoryInformation
  532. 0, // 38 FileIdFullDiretoryInformation
  533. FILE_WRITE_DATA, // 39 FileValidDataLengthInformation
  534. DELETE, // 40 FileShortNameInformation
  535. 0xffffffff // FileMaximumInformation
  536. };
  537. //
  538. // The following array specifies the minimum length of the FsInformation
  539. // buffer for an NtQueryVolumeInformation service.
  540. //
  541. // WARNING: This array depends on the order of the values in the
  542. // FS_INFORMATION_CLASS enumerated type. Note that the
  543. // enumerated type is one-based and the array is zero-based.
  544. //
  545. const UCHAR IopQueryFsOperationLength[] =
  546. {
  547. 0,
  548. sizeof( FILE_FS_VOLUME_INFORMATION ), // 1 FileFsVolumeInformation
  549. 0, // 2 FileFsLabelInformation
  550. sizeof( FILE_FS_SIZE_INFORMATION ), // 3 FileFsSizeInformation
  551. sizeof( FILE_FS_DEVICE_INFORMATION ), // 4 FileFsDeviceInformation
  552. sizeof( FILE_FS_ATTRIBUTE_INFORMATION ), // 5 FileFsAttributeInformation
  553. sizeof( FILE_FS_CONTROL_INFORMATION ), // 6 FileFsControlInformation
  554. sizeof( FILE_FS_FULL_SIZE_INFORMATION ), // 7 FileFsFullSizeInformation
  555. sizeof( FILE_FS_OBJECTID_INFORMATION ), // 8 FileFsObjectIdInformation
  556. sizeof( FILE_FS_DRIVER_PATH_INFORMATION),// 9 FileFsDriverPathInformation
  557. 0xff // FileFsMaximumInformation
  558. };
  559. //
  560. // The following array specifies the minimum length of the FsInformation
  561. // buffer for an NtSetVolumeInformation service.
  562. //
  563. // WARNING: This array depends on the order of the values in the
  564. // FS_INFORMATION_CLASS enumerated type. Note that the
  565. // enumerated type is one-based and the array is zero-based.
  566. //
  567. const UCHAR IopSetFsOperationLength[] =
  568. {
  569. 0,
  570. 0, // 1 FileFsVolumeInformation
  571. sizeof( FILE_FS_LABEL_INFORMATION ), // 2 FileFsLabelInformation
  572. 0, // 3 FileFsSizeInformation
  573. 0, // 4 FileFsDeviceInformation
  574. 0, // 5 FileFsAttributeInformation
  575. sizeof( FILE_FS_CONTROL_INFORMATION ), // 6 FileFsControlInformation
  576. 0, // 7 FileFsFullSizeInformation
  577. sizeof( FILE_FS_OBJECTID_INFORMATION ),// 8 FileFsObjectIdInformation
  578. 0, // 9 FileFsDriverPathInformation
  579. 0xff // FileFsMaximumInformation
  580. };
  581. //
  582. // The following array specifies the required access mask for the caller to
  583. // access information in an NtQueryVolumeInformation service.
  584. //
  585. // WARNING: This array depends on the order of the values in the
  586. // FS_INFORMATION_CLASS enumerated type. Note that the
  587. // enumerated type is one-based and the array is zero-based.
  588. //
  589. const ULONG IopQueryFsOperationAccess[] =
  590. {
  591. 0,
  592. 0, // 1 FileFsVolumeInformation [any access to file or volume]
  593. 0, // 2 FileFsLabelInformation [query is invalid]
  594. 0, // 3 FileFsSizeInformation [any access to file or volume]
  595. 0, // 4 FileFsDeviceInformation [any access to file or volume]
  596. 0, // 5 FileFsAttributeInformation [any access to file or vol]
  597. FILE_READ_DATA, // 6 FileFsControlInformation [vol read access]
  598. 0, // 7 FileFsFullSizeInformation [any access to file or volume]
  599. 0, // 8 FileFsObjectIdInformation [any access to file or volume]
  600. 0, // 9 FileFsDriverPathInformation [any access to file or volume]
  601. 0xffffffff // FileFsMaximumInformation
  602. };
  603. //
  604. // The following array specifies the required access mask for the caller to
  605. // access information in an NtSetVolumeInformation service.
  606. //
  607. // WARNING: This array depends on the order of the values in the
  608. // FS_INFORMATION_CLASS enumerated type. Note that the
  609. // enumerated type is one-based and the array is zero-based.
  610. //
  611. const ULONG IopSetFsOperationAccess[] =
  612. {
  613. 0,
  614. 0, // 1 FileFsVolumeInformation [set is invalid]
  615. FILE_WRITE_DATA, // 2 FileFsLabelInformation [write access to volume]
  616. 0, // 3 FileFsSizeInformation [set is invalid]
  617. 0, // 4 FileFsDeviceInformation [set is invalid]
  618. 0, // 5 FileFsAttributeInformation [set is invalid]
  619. FILE_WRITE_DATA, // 6 FileFsControlInformation [vol write access]
  620. 0, // 7 FileFsFullSizeInformation [set is invalid]
  621. FILE_WRITE_DATA, // 8 FileFsObjectIdInformation [write access to volume]
  622. 0, // 9 FileFsDriverPathInformation [set is invalid]
  623. 0xffffffff // FileFsMaximumInformation
  624. };
  625. //
  626. // The following array specifies the alignment requirements for all FS query
  627. // and set information services.
  628. //
  629. // WARNING: This array depends on the order of the values in the
  630. // FS_INFORMATION_CLASS enumerated type. Note that the
  631. // enumerated type is one-based and the array is zero-based.
  632. //
  633. const UCHAR IopQuerySetFsAlignmentRequirement[] =
  634. {
  635. 0,
  636. sizeof( LONGLONG ), // 1 FileFsVolumeInformation
  637. sizeof( LONG ), // 2 FileFsLabelInformation
  638. sizeof( LONGLONG ), // 3 FileFsSizeInformation
  639. sizeof( LONG ), // 4 FileFsDeviceInformation
  640. sizeof( LONG ), // 5 FileFsAttributeInformation
  641. sizeof( LONGLONG ), // 6 FileFsControlInformation
  642. sizeof( LONGLONG ), // 7 FileFsFullSizeInformation
  643. sizeof( LONGLONG ), // 8 FileFsObjectIdInformation
  644. sizeof( LONGLONG ), // 9 FileFsDriverPathInformation
  645. 0xff // FileFsMaximumInformation
  646. };
  647. PVOID IopLoaderBlock = NULL;
  648. const WCHAR IopWstrRaw[] = L".Raw";
  649. const WCHAR IopWstrTranslated[] = L".Translated";
  650. const WCHAR IopWstrBusRaw[] = L".Bus.Raw";
  651. const WCHAR IopWstrBusTranslated[] = L".Bus.Translated";
  652. const WCHAR IopWstrOtherDrivers[] = L"OtherDrivers";
  653. const WCHAR IopWstrAssignedResources[] = L"AssignedSystemResources";
  654. const WCHAR IopWstrRequestedResources[] = L"RequestedSystemResources";
  655. const WCHAR IopWstrSystemResources[] = L"Control\\SystemResources";
  656. const WCHAR IopWstrReservedResources[] = L"ReservedResources";
  657. const WCHAR IopWstrAssignmentOrdering[] = L"AssignmentOrdering";
  658. const WCHAR IopWstrBusValues[] = L"BusValues";
  659. UNICODE_STRING IoArcBootDeviceName = { 0 };
  660. UNICODE_STRING IoArcHalDeviceName = { 0 };
  661. PUCHAR IoLoaderArcBootDeviceName = NULL;
  662. //
  663. // Initialization time data
  664. //
  665. #ifdef ALLOC_DATA_PRAGMA
  666. #pragma const_seg("INITCONST")
  667. #endif
  668. const WCHAR IopWstrHal[] = L"Hardware Abstraction Layer";
  669. const WCHAR IopWstrSystem[] = L"System Resources";
  670. const WCHAR IopWstrPhysicalMemory[] = L"Physical Memory";
  671. const WCHAR IopWstrSpecialMemory[] = L"Reserved";
  672. const WCHAR IopWstrLoaderReservedMemory[] = L"Loader Reserved";
  673. #ifdef ALLOC_DATA_PRAGMA
  674. #pragma const_seg()
  675. #pragma data_seg()
  676. #endif