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.

789 lines
35 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. LONG 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. // Storage for the registry Key.
  228. // By default this value is true.
  229. //
  230. ULONG IopFailZeroAccessCreate = TRUE;
  231. //
  232. // Reserve IRP allocator for paging reads.
  233. //
  234. IOP_RESERVE_IRP_ALLOCATOR IopReserveIrpAllocator;
  235. #if defined(REMOTE_BOOT)
  236. //
  237. // The following indicates whether or not the Client Side Caching subsystem
  238. // was successfully initialized.
  239. //
  240. BOOLEAN IoCscInitializationFailed;
  241. #endif
  242. //
  243. // The following are used to synchronize with the link tracking service while establishing a connection.
  244. //
  245. KEVENT IopLinkTrackingPortObject;
  246. LINK_TRACKING_PACKET IopLinkTrackingPacket;
  247. IOP_IRP_STACK_PROFILER IopIrpStackProfiler;
  248. //
  249. // Function pointers of key IO routines.
  250. // The functions need to be in their own cache lines as they are readonly and
  251. // never modified after boot.
  252. //
  253. #define CACHE_SIZE 128
  254. UCHAR IopPrePadding[CACHE_SIZE] = {0};
  255. PIO_CALL_DRIVER pIofCallDriver = 0;
  256. PIO_COMPLETE_REQUEST pIofCompleteRequest = 0;
  257. PIO_ALLOCATE_IRP pIoAllocateIrp = 0;
  258. PIO_FREE_IRP pIoFreeIrp = 0;
  259. UCHAR IopPostPadding[CACHE_SIZE] = {0};
  260. //*********
  261. //
  262. // Note: All of the following data is potentially pageable, depending on the
  263. // target platform.
  264. //
  265. //*********
  266. #ifdef ALLOC_DATA_PRAGMA
  267. #pragma data_seg("PAGEDATA")
  268. #pragma const_seg("PAGECONST")
  269. #endif
  270. //
  271. // The following are used to store the handle and a pointer to the referenced
  272. // whenever a file is moved across systems.
  273. //
  274. PVOID IopLinkTrackingServiceObject;
  275. PKEVENT IopLinkTrackingServiceEvent;
  276. HANDLE IopLinkTrackingServiceEventHandle;
  277. //
  278. // The following array specifies the minimum length of the FileInformation
  279. // buffer for an NtQueryInformationFile service.
  280. //
  281. // WARNING: This array depends on the order of the values in the
  282. // FileInformationClass enumerated type. Note that the
  283. // enumerated type is one-based and the array is zero-based.
  284. //
  285. const UCHAR IopQueryOperationLength[] =
  286. {
  287. 0,
  288. 0, // 1 FileDirectoryInformation
  289. 0, // 2 FileFullDirectoryInformation
  290. 0, // 3 FileBothDirectoryInformation
  291. sizeof( FILE_BASIC_INFORMATION ), // 4 FileBasicInformation
  292. sizeof( FILE_STANDARD_INFORMATION ), // 5 FileStandardInformation
  293. sizeof( FILE_INTERNAL_INFORMATION ), // 6 FileInternalInformation
  294. sizeof( FILE_EA_INFORMATION ), // 7 FileEaInformation
  295. sizeof( FILE_ACCESS_INFORMATION ), // 8 FileAccessInformation
  296. sizeof( FILE_NAME_INFORMATION ), // 9 FileNameInformation
  297. 0, // 10 FileRenameInformation
  298. 0, // 11 FileLinkInformation
  299. 0, // 12 FileNamesInformation
  300. 0, // 13 FileDispositionInformation
  301. sizeof( FILE_POSITION_INFORMATION ), // 14 FilePositionInformation
  302. 0, // 15 FileFullEaInformation
  303. sizeof( FILE_MODE_INFORMATION ), // 16 FileModeInformation
  304. sizeof( FILE_ALIGNMENT_INFORMATION ), // 17 FileAlignmentInformation
  305. sizeof( FILE_ALL_INFORMATION ), // 18 FileAllInformation
  306. 0, // 19 FileAllocationInformation
  307. 0, // 20 FileEndOfFileInformation
  308. sizeof( FILE_NAME_INFORMATION ), // 21 FileAlternateNameInformation
  309. sizeof( FILE_STREAM_INFORMATION ), // 22 FileStreamInformation
  310. sizeof( FILE_PIPE_INFORMATION ), // 23 FilePipeInformation
  311. sizeof( FILE_PIPE_LOCAL_INFORMATION ), // 24 FilePipeLocalInformation
  312. sizeof( FILE_PIPE_REMOTE_INFORMATION ), // 25 FilePipeRemoteInformation
  313. sizeof( FILE_MAILSLOT_QUERY_INFORMATION ), // 26 FileMailslotQueryInformation
  314. 0, // 27 FileMailslotSetInformation
  315. sizeof( FILE_COMPRESSION_INFORMATION ), // 28 FileCompressionInformation
  316. sizeof( FILE_OBJECTID_INFORMATION ), // 29 FileObjectIdInformation
  317. 0, // 30 FileCompletionInformation
  318. 0, // 31 FileMoveClusterInformation
  319. sizeof( FILE_QUOTA_INFORMATION ), // 32 FileQuotaInformation
  320. sizeof( FILE_REPARSE_POINT_INFORMATION ), // 33 FileReparsePointInformation
  321. sizeof( FILE_NETWORK_OPEN_INFORMATION), // 34 FileNetworkOpenInformation
  322. sizeof( FILE_ATTRIBUTE_TAG_INFORMATION), // 35 FileAttributeTagInformation
  323. 0, // 36 FileTrackingInformation
  324. 0, // 37 FileIdBothDiretoryInformation
  325. 0, // 38 FileIdFullDiretoryInformation
  326. 0, // 39 FileValidDataLengthInformation
  327. 0, // 40 FileShortNameInformation
  328. 0xff // FileMaximumInformation
  329. };
  330. //
  331. // The following array specifies the minimum length of the FileInformation
  332. // buffer for an NtSetInformationFile service.
  333. //
  334. // WARNING: This array depends on the order of the values in the
  335. // FileInformationClass enumerated type. Note that the
  336. // enumerated type is one-based and the array is zero-based.
  337. //
  338. const UCHAR IopSetOperationLength[] =
  339. {
  340. 0,
  341. 0, // 1 FileDirectoryInformation
  342. 0, // 2 FileFullDirectoryInformation
  343. 0, // 3 FileBothDirectoryInformation
  344. sizeof( FILE_BASIC_INFORMATION ), // 4 FileBasicInformation
  345. 0, // 5 FileStandardInformation
  346. 0, // 6 FileInternalInformation
  347. 0, // 7 FileEaInformation
  348. 0, // 8 FileAccessInformation
  349. 0, // 9 FileNameInformation
  350. sizeof( FILE_RENAME_INFORMATION ), // 10 FileRenameInformation
  351. sizeof( FILE_LINK_INFORMATION ), // 11 FileLinkInformation
  352. 0, // 12 FileNamesInformation
  353. sizeof( FILE_DISPOSITION_INFORMATION ), // 13 FileDispositionInformation
  354. sizeof( FILE_POSITION_INFORMATION ), // 14 FilePositionInformation
  355. 0, // 15 FileFullEaInformation
  356. sizeof( FILE_MODE_INFORMATION ), // 16 FileModeInformation
  357. 0, // 17 FileAlignmentInformation
  358. 0, // 18 FileAllInformation
  359. sizeof( FILE_ALLOCATION_INFORMATION ), // 19 FileAllocationInformation
  360. sizeof( FILE_END_OF_FILE_INFORMATION ), // 20 FileEndOfFileInformation
  361. 0, // 21 FileAlternateNameInformation
  362. 0, // 22 FileStreamInformation
  363. sizeof( FILE_PIPE_INFORMATION ), // 23 FilePipeInformation
  364. 0, // 24 FilePipeLocalInformation
  365. sizeof( FILE_PIPE_REMOTE_INFORMATION ), // 25 FilePipeRemoteInformation
  366. 0, // 26 FileMailslotQueryInformation
  367. sizeof( FILE_MAILSLOT_SET_INFORMATION ), // 27 FileMailslotSetInformation
  368. 0, // 28 FileCompressionInformation
  369. sizeof( FILE_OBJECTID_INFORMATION ), // 29 FileObjectIdInformation
  370. sizeof( FILE_COMPLETION_INFORMATION ), // 30 FileCompletionInformation
  371. sizeof( FILE_MOVE_CLUSTER_INFORMATION ), // 31 FileMoveClusterInformation
  372. sizeof( FILE_QUOTA_INFORMATION ), // 32 FileQuotaInformation
  373. 0, // 33 FileReparsePointInformation
  374. 0, // 34 FileNetworkOpenInformation
  375. 0, // 35 FileAttributeTagInformation
  376. sizeof( FILE_TRACKING_INFORMATION ), // 36 FileTrackingInformation
  377. 0, // 37 FileIdBothDiretoryInformation
  378. 0, // 38 FileIdFullDiretoryInformation
  379. sizeof( FILE_VALID_DATA_LENGTH_INFORMATION ), // 39 FileValidDataLengthInformation
  380. sizeof( FILE_NAME_INFORMATION ), // 40 FileShortNameInformation
  381. 0xff // FileMaximumInformation
  382. };
  383. //
  384. // The following array specifies the alignment requirement of both all query
  385. // and set operations, including directory operations, but not FS operations.
  386. //
  387. // WARNING: This array depends on the order of the values in the
  388. // FileInformationClass enumerated type. Note that the
  389. // enumerated type is one-based and the array is zero-based.
  390. //
  391. const UCHAR IopQuerySetAlignmentRequirement[] =
  392. {
  393. 0,
  394. sizeof( LONGLONG ), // 1 FileDirectoryInformation
  395. sizeof( LONGLONG ), // 2 FileFullDirectoryInformation
  396. sizeof( LONGLONG ), // 3 FileBothDirectoryInformation
  397. sizeof( LONGLONG ), // 4 FileBasicInformation
  398. sizeof( LONGLONG ), // 5 FileStandardInformation
  399. sizeof( LONGLONG ), // 6 FileInternalInformation
  400. sizeof( LONG ), // 7 FileEaInformation
  401. sizeof( LONG ), // 8 FileAccessInformation
  402. sizeof( LONG ), // 9 FileNameInformation
  403. sizeof( LONG ), // 10 FileRenameInformation
  404. sizeof( LONG ), // 11 FileLinkInformation
  405. sizeof( LONG ), // 12 FileNamesInformation
  406. sizeof( CHAR ), // 13 FileDispositionInformation
  407. sizeof( LONGLONG ), // 14 FilePositionInformation
  408. sizeof( LONG ), // 15 FileFullEaInformation
  409. sizeof( LONG ), // 16 FileModeInformation
  410. sizeof( LONG ), // 17 FileAlignmentInformation
  411. sizeof( LONGLONG ), // 18 FileAllInformation
  412. sizeof( LONGLONG ), // 19 FileAllocationInformation
  413. sizeof( LONGLONG ), // 20 FileEndOfFileInformation
  414. sizeof( LONG ), // 21 FileAlternateNameInformation
  415. sizeof( LONGLONG ), // 22 FileStreamInformation
  416. sizeof( LONG ), // 23 FilePipeInformation
  417. sizeof( LONG ), // 24 FilePipeLocalInformation
  418. sizeof( LONG ), // 25 FilePipeRemoteInformation
  419. sizeof( LONGLONG ), // 26 FileMailslotQueryInformation
  420. sizeof( LONG ), // 27 FileMailslotSetInformation
  421. sizeof( LONGLONG ), // 28 FileCompressionInformation
  422. sizeof( LONG ), // 29 FileObjectIdInformation
  423. sizeof( LONG ), // 30 FileCompletionInformation
  424. sizeof( LONG ), // 31 FileMoveClusterInformation
  425. sizeof( LONG ), // 32 FileQuotaInformation
  426. sizeof( LONG ), // 33 FileReparsePointInformation
  427. sizeof( LONGLONG ), // 34 FileNetworkOpenInformation
  428. sizeof( LONG ), // 35 FileAttributeTagInformation
  429. sizeof( LONG ), // 36 FileTrackingInformation
  430. sizeof( LONGLONG ), // 37 FileIdBothDiretoryInformation
  431. sizeof( LONGLONG ), // 38 FileIdFullDiretoryInformation
  432. sizeof( LONGLONG ), // 39 FileValidDataLengthInformation
  433. sizeof( LONG ), // 40 FileShortNameInformation
  434. 0xff // FileMaximumInformation
  435. };
  436. //
  437. // The following array specifies the required access mask for the caller to
  438. // access information in an NtQueryXxxFile service.
  439. //
  440. // WARNING: This array depends on the order of the values in the
  441. // FileInformationClass enumerated type. Note that the
  442. // enumerated type is one-based and the array is zero-based.
  443. //
  444. const ULONG IopQueryOperationAccess[] =
  445. {
  446. 0,
  447. 0, // 1 FileDirectoryInformation
  448. 0, // 2 FileFullDirectoryInformation
  449. 0, // 3 FileBothDirectoryInformation
  450. FILE_READ_ATTRIBUTES, // 4 FileBasicInformation
  451. 0, // 5 FileStandardInformation
  452. 0, // 6 FileInternalInformation
  453. 0, // 7 FileEaInformation
  454. 0, // 8 FileAccessInformation
  455. 0, // 9 FileNameInformation
  456. 0, // 10 FileRenameInformation
  457. 0, // 11 FileLinkInformation
  458. 0, // 12 FileNamesInformation
  459. 0, // 13 FileDispositionInformation
  460. 0, // 14 FilePositionInformation
  461. FILE_READ_EA, // 15 FileFullEaInformation
  462. 0, // 16 FileModeInformation
  463. 0, // 17 FileAlignmentInformation
  464. FILE_READ_ATTRIBUTES, // 18 FileAllInformation
  465. 0, // 19 FileAllocationInformation
  466. 0, // 20 FileEndOfFileInformation
  467. 0, // 21 FileAlternateNameInformation
  468. 0, // 22 FileStreamInformation
  469. FILE_READ_ATTRIBUTES, // 23 FilePipeInformation
  470. FILE_READ_ATTRIBUTES, // 24 FilePipeLocalInformation
  471. FILE_READ_ATTRIBUTES, // 25 FilePipeRemoteInformation
  472. 0, // 26 FileMailslotQueryInformation
  473. 0, // 27 FileMailslotSetInformation
  474. 0, // 28 FileCompressionInformation
  475. 0, // 29 FileObjectIdInformation
  476. 0, // 30 FileCompletionInformation
  477. 0, // 31 FileMoveClusterInformation
  478. 0, // 32 FileQuotaInformation
  479. 0, // 33 FileReparsePointInformation
  480. FILE_READ_ATTRIBUTES, // 34 FileNetworkOpenInformation
  481. FILE_READ_ATTRIBUTES, // 35 FileAttributeTagInformation
  482. 0, // 36 FileTrackingInformation
  483. 0, // 37 FileIdBothDiretoryInformation
  484. 0, // 38 FileIdFullDiretoryInformation
  485. 0, // 39 FileValidDataLengthInformation
  486. 0, // 40 FileShortNameInformation
  487. 0xffffffff // FileMaximumInformation
  488. };
  489. //
  490. // The following array specifies the required access mask for the caller to
  491. // access information in an NtSetXxxFile service.
  492. //
  493. // WARNING: This array depends on the order of the values in the
  494. // FILE_INFORMATION_CLASS enumerated type. Note that the
  495. // enumerated type is one-based and the array is zero-based.
  496. //
  497. const ULONG IopSetOperationAccess[] =
  498. {
  499. 0,
  500. 0, // 1 FileDirectoryInformation
  501. 0, // 2 FileFullDirectoryInformation
  502. 0, // 3 FileBothDirectoryInformation
  503. FILE_WRITE_ATTRIBUTES, // 4 FileBasicInformation
  504. 0, // 5 FileStandardInformation
  505. 0, // 6 FileInternalInformation
  506. 0, // 7 FileEaInformation
  507. 0, // 8 FileAccessInformation
  508. 0, // 9 FileNameInformation
  509. DELETE, // 10 FileRenameInformation
  510. 0, // 11 FileLinkInformation
  511. 0, // 12 FileNamesInformation
  512. DELETE, // 13 FileDispositionInformation
  513. 0, // 14 FilePositionInformation
  514. FILE_WRITE_EA, // 15 FileFullEaInformation
  515. 0, // 16 FileModeInformation
  516. 0, // 17 FileAlignmentInformation
  517. 0, // 18 FileAllInformation
  518. FILE_WRITE_DATA, // 19 FileAllocationInformation
  519. FILE_WRITE_DATA, // 20 FileEndOfFileInformation
  520. 0, // 21 FileAlternateNameInformation
  521. 0, // 22 FileStreamInformation
  522. FILE_WRITE_ATTRIBUTES, // 23 FilePipeInformation
  523. 0, // 24 FilePipeLocalInformation
  524. FILE_WRITE_ATTRIBUTES, // 25 FilePipeRemoteInformation
  525. 0, // 26 FileMailslotQueryInformation
  526. 0, // 27 FileMailslotSetInformation
  527. 0, // 28 FileCompressionInformation
  528. 0, // 29 FileObjectIdInformation
  529. 0, // 30 FileCompletionInformation
  530. FILE_WRITE_DATA, // 31 FileMoveClusterInformation
  531. 0, // 32 FileQuotaInformation
  532. 0, // 33 FileReparsePointInformation
  533. 0, // 34 FileNetworkOpenInformation
  534. 0, // 35 FileAttributeTagInformation
  535. FILE_WRITE_DATA, // 36 FileTrackingInformation
  536. 0, // 37 FileIdBothDiretoryInformation
  537. 0, // 38 FileIdFullDiretoryInformation
  538. FILE_WRITE_DATA, // 39 FileValidDataLengthInformation
  539. DELETE, // 40 FileShortNameInformation
  540. 0xffffffff // FileMaximumInformation
  541. };
  542. //
  543. // The following array specifies the minimum length of the FsInformation
  544. // buffer for an NtQueryVolumeInformation service.
  545. //
  546. // WARNING: This array depends on the order of the values in the
  547. // FS_INFORMATION_CLASS enumerated type. Note that the
  548. // enumerated type is one-based and the array is zero-based.
  549. //
  550. const UCHAR IopQueryFsOperationLength[] =
  551. {
  552. 0,
  553. sizeof( FILE_FS_VOLUME_INFORMATION ), // 1 FileFsVolumeInformation
  554. 0, // 2 FileFsLabelInformation
  555. sizeof( FILE_FS_SIZE_INFORMATION ), // 3 FileFsSizeInformation
  556. sizeof( FILE_FS_DEVICE_INFORMATION ), // 4 FileFsDeviceInformation
  557. sizeof( FILE_FS_ATTRIBUTE_INFORMATION ), // 5 FileFsAttributeInformation
  558. sizeof( FILE_FS_CONTROL_INFORMATION ), // 6 FileFsControlInformation
  559. sizeof( FILE_FS_FULL_SIZE_INFORMATION ), // 7 FileFsFullSizeInformation
  560. sizeof( FILE_FS_OBJECTID_INFORMATION ), // 8 FileFsObjectIdInformation
  561. sizeof( FILE_FS_DRIVER_PATH_INFORMATION),// 9 FileFsDriverPathInformation
  562. 0xff // FileFsMaximumInformation
  563. };
  564. //
  565. // The following array specifies the minimum length of the FsInformation
  566. // buffer for an NtSetVolumeInformation service.
  567. //
  568. // WARNING: This array depends on the order of the values in the
  569. // FS_INFORMATION_CLASS enumerated type. Note that the
  570. // enumerated type is one-based and the array is zero-based.
  571. //
  572. const UCHAR IopSetFsOperationLength[] =
  573. {
  574. 0,
  575. 0, // 1 FileFsVolumeInformation
  576. sizeof( FILE_FS_LABEL_INFORMATION ), // 2 FileFsLabelInformation
  577. 0, // 3 FileFsSizeInformation
  578. 0, // 4 FileFsDeviceInformation
  579. 0, // 5 FileFsAttributeInformation
  580. sizeof( FILE_FS_CONTROL_INFORMATION ), // 6 FileFsControlInformation
  581. 0, // 7 FileFsFullSizeInformation
  582. sizeof( FILE_FS_OBJECTID_INFORMATION ),// 8 FileFsObjectIdInformation
  583. 0, // 9 FileFsDriverPathInformation
  584. 0xff // FileFsMaximumInformation
  585. };
  586. //
  587. // The following array specifies the required access mask for the caller to
  588. // access information in an NtQueryVolumeInformation service.
  589. //
  590. // WARNING: This array depends on the order of the values in the
  591. // FS_INFORMATION_CLASS enumerated type. Note that the
  592. // enumerated type is one-based and the array is zero-based.
  593. //
  594. const ULONG IopQueryFsOperationAccess[] =
  595. {
  596. 0,
  597. 0, // 1 FileFsVolumeInformation [any access to file or volume]
  598. 0, // 2 FileFsLabelInformation [query is invalid]
  599. 0, // 3 FileFsSizeInformation [any access to file or volume]
  600. 0, // 4 FileFsDeviceInformation [any access to file or volume]
  601. 0, // 5 FileFsAttributeInformation [any access to file or vol]
  602. FILE_READ_DATA, // 6 FileFsControlInformation [vol read access]
  603. 0, // 7 FileFsFullSizeInformation [any access to file or volume]
  604. 0, // 8 FileFsObjectIdInformation [any access to file or volume]
  605. 0, // 9 FileFsDriverPathInformation [any access to file or volume]
  606. 0xffffffff // FileFsMaximumInformation
  607. };
  608. //
  609. // The following array specifies the required access mask for the caller to
  610. // access information in an NtSetVolumeInformation service.
  611. //
  612. // WARNING: This array depends on the order of the values in the
  613. // FS_INFORMATION_CLASS enumerated type. Note that the
  614. // enumerated type is one-based and the array is zero-based.
  615. //
  616. const ULONG IopSetFsOperationAccess[] =
  617. {
  618. 0,
  619. 0, // 1 FileFsVolumeInformation [set is invalid]
  620. FILE_WRITE_DATA, // 2 FileFsLabelInformation [write access to volume]
  621. 0, // 3 FileFsSizeInformation [set is invalid]
  622. 0, // 4 FileFsDeviceInformation [set is invalid]
  623. 0, // 5 FileFsAttributeInformation [set is invalid]
  624. FILE_WRITE_DATA, // 6 FileFsControlInformation [vol write access]
  625. 0, // 7 FileFsFullSizeInformation [set is invalid]
  626. FILE_WRITE_DATA, // 8 FileFsObjectIdInformation [write access to volume]
  627. 0, // 9 FileFsDriverPathInformation [set is invalid]
  628. 0xffffffff // FileFsMaximumInformation
  629. };
  630. //
  631. // The following array specifies the alignment requirements for all FS query
  632. // and set information services.
  633. //
  634. // WARNING: This array depends on the order of the values in the
  635. // FS_INFORMATION_CLASS enumerated type. Note that the
  636. // enumerated type is one-based and the array is zero-based.
  637. //
  638. const UCHAR IopQuerySetFsAlignmentRequirement[] =
  639. {
  640. 0,
  641. sizeof( LONGLONG ), // 1 FileFsVolumeInformation
  642. sizeof( LONG ), // 2 FileFsLabelInformation
  643. sizeof( LONGLONG ), // 3 FileFsSizeInformation
  644. sizeof( LONG ), // 4 FileFsDeviceInformation
  645. sizeof( LONG ), // 5 FileFsAttributeInformation
  646. sizeof( LONGLONG ), // 6 FileFsControlInformation
  647. sizeof( LONGLONG ), // 7 FileFsFullSizeInformation
  648. sizeof( LONGLONG ), // 8 FileFsObjectIdInformation
  649. sizeof( LONGLONG ), // 9 FileFsDriverPathInformation
  650. 0xff // FileFsMaximumInformation
  651. };
  652. PVOID IopLoaderBlock = NULL;
  653. const WCHAR IopWstrRaw[] = L".Raw";
  654. const WCHAR IopWstrTranslated[] = L".Translated";
  655. const WCHAR IopWstrBusRaw[] = L".Bus.Raw";
  656. const WCHAR IopWstrBusTranslated[] = L".Bus.Translated";
  657. const WCHAR IopWstrOtherDrivers[] = L"OtherDrivers";
  658. const WCHAR IopWstrAssignedResources[] = L"AssignedSystemResources";
  659. const WCHAR IopWstrRequestedResources[] = L"RequestedSystemResources";
  660. const WCHAR IopWstrSystemResources[] = L"Control\\SystemResources";
  661. const WCHAR IopWstrReservedResources[] = L"ReservedResources";
  662. const WCHAR IopWstrAssignmentOrdering[] = L"AssignmentOrdering";
  663. const WCHAR IopWstrBusValues[] = L"BusValues";
  664. UNICODE_STRING IoArcBootDeviceName = { 0 };
  665. UNICODE_STRING IoArcHalDeviceName = { 0 };
  666. PUCHAR IoLoaderArcBootDeviceName = NULL;
  667. //
  668. // Initialization time data
  669. //
  670. #ifdef ALLOC_DATA_PRAGMA
  671. #pragma const_seg("INITCONST")
  672. #endif
  673. const WCHAR IopWstrHal[] = L"Hardware Abstraction Layer";
  674. const WCHAR IopWstrSystem[] = L"System Resources";
  675. const WCHAR IopWstrPhysicalMemory[] = L"Physical Memory";
  676. const WCHAR IopWstrSpecialMemory[] = L"Reserved";
  677. const WCHAR IopWstrLoaderReservedMemory[] = L"Loader Reserved";
  678. #ifdef ALLOC_DATA_PRAGMA
  679. #pragma const_seg()
  680. #pragma data_seg()
  681. #endif