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.

1595 lines
38 KiB

  1. /*++
  2. Copyright (c) 1989-2000 Microsoft Corporation
  3. Module Name:
  4. iomgr.h
  5. Abstract:
  6. This module contains the private structure definitions and APIs used by
  7. the NT I/O system.
  8. Author:
  9. Nar Ganapathy (narg) 1-Jan-1999
  10. Revision History:
  11. --*/
  12. #ifndef _IOMGR_
  13. #define _IOMGR_
  14. //
  15. // Define Information fields values for the return value from popups when a
  16. // volume mount is in progress but failed.
  17. //
  18. #define IOP_ABORT 1
  19. #pragma warning(disable:4214) // bit field types other than int
  20. #pragma warning(disable:4201) // nameless struct/union
  21. #pragma warning(disable:4324) // alignment sensitive to declspec
  22. #pragma warning(disable:4127) // condition expression is constant
  23. #pragma warning(disable:4115) // named type definition in parentheses
  24. #pragma warning(disable:4706) // assignment within conditional expression
  25. #include "ntos.h"
  26. #include "ntdddisk.h"
  27. #include "ntddscsi.h"
  28. #include "mountmgr.h"
  29. #include "ntiolog.h"
  30. #include "ntiologc.h"
  31. #include "ntseapi.h"
  32. #include "fsrtl.h"
  33. #include "zwapi.h"
  34. #include "stdio.h"
  35. #include "stdlib.h"
  36. #include "string.h"
  37. #include "safeboot.h"
  38. #include "ioverifier.h"
  39. #include "iopcmn.h"
  40. #ifdef POOL_TAGGING
  41. #undef ExAllocatePool
  42. #define ExAllocatePool(a,b) ExAllocatePoolWithTag(a,b,' oI')
  43. #undef ExAllocatePoolWithQuota
  44. #define ExAllocatePoolWithQuota(a,b) ExAllocatePoolWithQuotaTag(a,b,' oI')
  45. #endif
  46. typedef struct _DUMP_CONTROL_BLOCK DUMP_CONTROL_BLOCK, *PDUMP_CONTROL_BLOCK;
  47. //
  48. // Define the type for entries placed on the driver reinitialization queue.
  49. // These entries are entered onto the tail when the driver requests that
  50. // it be reinitialized, and removed from the head by the code that actually
  51. // performs the reinitialization.
  52. //
  53. typedef struct _REINIT_PACKET {
  54. LIST_ENTRY ListEntry;
  55. PDRIVER_OBJECT DriverObject;
  56. PDRIVER_REINITIALIZE DriverReinitializationRoutine;
  57. PVOID Context;
  58. } REINIT_PACKET, *PREINIT_PACKET;
  59. //
  60. // Define transfer types for process counters.
  61. //
  62. typedef enum _TRANSFER_TYPE {
  63. ReadTransfer,
  64. WriteTransfer,
  65. OtherTransfer
  66. } TRANSFER_TYPE, *PTRANSFER_TYPE;
  67. //
  68. // Define the maximum amount of memory that can be allocated for all
  69. // outstanding error log packets.
  70. //
  71. #define IOP_MAXIMUM_LOG_ALLOCATION (100*PAGE_SIZE)
  72. //
  73. // Define an error log entry.
  74. //
  75. typedef struct _ERROR_LOG_ENTRY {
  76. USHORT Type;
  77. USHORT Size;
  78. LIST_ENTRY ListEntry;
  79. PDEVICE_OBJECT DeviceObject;
  80. PDRIVER_OBJECT DriverObject;
  81. LARGE_INTEGER TimeStamp;
  82. } ERROR_LOG_ENTRY, *PERROR_LOG_ENTRY;
  83. //
  84. // Define both the global IOP_HARD_ERROR_QUEUE and IOP_HARD_ERROR_PACKET
  85. // structures. Also set the maximum number of outstanding hard error
  86. // packets allowed.
  87. //
  88. typedef struct _IOP_HARD_ERROR_QUEUE {
  89. WORK_QUEUE_ITEM ExWorkItem;
  90. LIST_ENTRY WorkQueue;
  91. KSPIN_LOCK WorkQueueSpinLock;
  92. KSEMAPHORE WorkQueueSemaphore;
  93. BOOLEAN ThreadStarted;
  94. LONG NumPendingApcPopups;
  95. } IOP_HARD_ERROR_QUEUE, *PIOP_HARD_ERROR_QUEUE;
  96. typedef struct _IOP_HARD_ERROR_PACKET {
  97. LIST_ENTRY WorkQueueLinks;
  98. NTSTATUS ErrorStatus;
  99. UNICODE_STRING String;
  100. } IOP_HARD_ERROR_PACKET, *PIOP_HARD_ERROR_PACKET;
  101. typedef struct _IOP_APC_HARD_ERROR_PACKET {
  102. WORK_QUEUE_ITEM Item;
  103. PIRP Irp;
  104. PVPB Vpb;
  105. PDEVICE_OBJECT RealDeviceObject;
  106. } IOP_APC_HARD_ERROR_PACKET, *PIOP_APC_HARD_ERROR_PACKET;
  107. typedef
  108. NTSTATUS
  109. (FASTCALL *PIO_CALL_DRIVER) (
  110. IN PDEVICE_OBJECT DeviceObject,
  111. IN OUT PIRP Irp,
  112. IN PVOID ReturnAddress
  113. );
  114. typedef
  115. VOID
  116. (FASTCALL *PIO_COMPLETE_REQUEST) (
  117. IN PIRP Irp,
  118. IN CCHAR PriorityBoost
  119. );
  120. typedef
  121. VOID
  122. (*PIO_FREE_IRP) (
  123. IN struct _IRP *Irp
  124. );
  125. typedef
  126. PIRP
  127. (*PIO_ALLOCATE_IRP) (
  128. IN CCHAR StackSize,
  129. IN BOOLEAN ChargeQuota
  130. );
  131. extern IOP_HARD_ERROR_QUEUE IopHardError;
  132. extern PIOP_HARD_ERROR_PACKET IopCurrentHardError;
  133. #define IOP_MAXIMUM_OUTSTANDING_HARD_ERRORS 25
  134. typedef struct _IO_WORKITEM {
  135. WORK_QUEUE_ITEM WorkItem;
  136. PIO_WORKITEM_ROUTINE Routine;
  137. PDEVICE_OBJECT DeviceObject;
  138. PVOID Context;
  139. #if DBG
  140. ULONG Size;
  141. #endif
  142. } IO_WORKITEM;
  143. //
  144. // Define the global data for the error logger and I/O system.
  145. //
  146. extern WORK_QUEUE_ITEM IopErrorLogWorkItem;
  147. extern BOOLEAN IopErrorLogPortPending;
  148. extern BOOLEAN IopErrorLogDisabledThisBoot;
  149. extern KSPIN_LOCK IopErrorLogLock;
  150. extern LIST_ENTRY IopErrorLogListHead;
  151. extern LONG IopErrorLogAllocation;
  152. extern KSPIN_LOCK IopErrorLogAllocationLock;
  153. extern const GENERIC_MAPPING IopFileMapping;
  154. //
  155. // Define a dummy file object for use on stack for fast open operations.
  156. //
  157. typedef struct _DUMMY_FILE_OBJECT {
  158. OBJECT_HEADER ObjectHeader;
  159. CHAR FileObjectBody[ sizeof( FILE_OBJECT ) ];
  160. } DUMMY_FILE_OBJECT, *PDUMMY_FILE_OBJECT;
  161. //
  162. // Define the structures private to the I/O system.
  163. //
  164. #define OPEN_PACKET_PATTERN 0xbeaa0251
  165. //
  166. // Define an Open Packet (OP). An OP is used to communicate information
  167. // between the NtCreateFile service executing in the context of the caller
  168. // and the device object parse routine. It is the parse routine who actually
  169. // creates the file object for the file.
  170. //
  171. typedef struct _OPEN_PACKET {
  172. CSHORT Type;
  173. CSHORT Size;
  174. PFILE_OBJECT FileObject;
  175. NTSTATUS FinalStatus;
  176. ULONG_PTR Information;
  177. ULONG ParseCheck;
  178. PFILE_OBJECT RelatedFileObject;
  179. //
  180. // The following are the open-specific parameters. Notice that the desired
  181. // access field is passed through to the parse routine via the object
  182. // management architecture, so it does not need to be repeated here. Also
  183. // note that the same is true for the file name.
  184. //
  185. LARGE_INTEGER AllocationSize;
  186. ULONG CreateOptions;
  187. USHORT FileAttributes;
  188. USHORT ShareAccess;
  189. PVOID EaBuffer;
  190. ULONG EaLength;
  191. ULONG Options;
  192. ULONG Disposition;
  193. //
  194. // The following is used when performing a fast query during open to get
  195. // back the file attributes for a file.
  196. //
  197. PFILE_BASIC_INFORMATION BasicInformation;
  198. //
  199. // The following is used when performing a fast network query during open
  200. // to get back the network file attributes for a file.
  201. //
  202. PFILE_NETWORK_OPEN_INFORMATION NetworkInformation;
  203. //
  204. // The type of file to create.
  205. //
  206. CREATE_FILE_TYPE CreateFileType;
  207. //
  208. // The following pointer provides a way of passing the parameters
  209. // specific to the file type of the file being created to the parse
  210. // routine.
  211. //
  212. PVOID ExtraCreateParameters;
  213. //
  214. // The following is used to indicate that an open of a device has been
  215. // performed and the access check for the device has already been done,
  216. // but because of a reparse, the I/O system has been called again for
  217. // the same device. Since the access check has already been made, the
  218. // state cannot handle being called again (access was already granted)
  219. // and it need not anyway since the check has already been made.
  220. //
  221. BOOLEAN Override;
  222. //
  223. // The following is used to indicate that a file is being opened for the
  224. // sole purpose of querying its attributes. This causes a considerable
  225. // number of shortcuts to be taken in the parse, query, and close paths.
  226. //
  227. BOOLEAN QueryOnly;
  228. //
  229. // The following is used to indicate that a file is being opened for the
  230. // sole purpose of deleting it. This causes a considerable number of
  231. // shortcurs to be taken in the parse and close paths.
  232. //
  233. BOOLEAN DeleteOnly;
  234. //
  235. // The following is used to indicate that a file being opened for a query
  236. // only is being opened to query its network attributes rather than just
  237. // its FAT file attributes.
  238. //
  239. BOOLEAN FullAttributes;
  240. //
  241. // The following pointer is used when a fast open operation for a fast
  242. // delete or fast query attributes call is being made rather than a
  243. // general file open. The dummy file object is actually stored on the
  244. // the caller's stack rather than allocated pool to speed things up.
  245. //
  246. PDUMMY_FILE_OBJECT LocalFileObject;
  247. //
  248. // The following is used to indicate we passed through a mount point while
  249. // parsing the filename. We use this to do an extra check on the device type
  250. // for the final file
  251. //
  252. BOOLEAN TraversedMountPoint;
  253. //
  254. // Device object where the create should start if present on the stack
  255. // Applicable for kernel opens only.
  256. //
  257. ULONG InternalFlags; // Passed from IopCreateFile
  258. PDEVICE_OBJECT TopDeviceObjectHint;
  259. } OPEN_PACKET, *POPEN_PACKET;
  260. //
  261. // Define a Load Packet (LDP). An LDP is used to communicate load and unload
  262. // driver information between the appropriate system services and the routine
  263. // that actually performs the work. This is implemented using a packet
  264. // because various drivers need to be initialized in the context of THE
  265. // system process because they create threads within its context which open
  266. // handles to objects that henceforth are only valid in the context of that
  267. // process.
  268. //
  269. typedef struct _LOAD_PACKET {
  270. WORK_QUEUE_ITEM WorkQueueItem;
  271. KEVENT Event;
  272. PDRIVER_OBJECT DriverObject;
  273. PUNICODE_STRING DriverServiceName;
  274. NTSTATUS FinalStatus;
  275. } LOAD_PACKET, *PLOAD_PACKET;
  276. //
  277. // Define a Link Tracking Packet. A link tracking packet is used to open the
  278. // user-mode link tracking service's LPC port so that information about objects
  279. // which have been moved can be tracked.
  280. //
  281. typedef struct _LINK_TRACKING_PACKET {
  282. WORK_QUEUE_ITEM WorkQueueItem;
  283. KEVENT Event;
  284. NTSTATUS FinalStatus;
  285. } LINK_TRACKING_PACKET, *PLINK_TRACKING_PACKET;
  286. //
  287. // Define the type for entries placed on the driver shutdown notification queue.
  288. // These entries represent those drivers that would like to be notified that the
  289. // system is begin shutdown before it actually goes down.
  290. //
  291. typedef struct _SHUTDOWN_PACKET {
  292. LIST_ENTRY ListEntry;
  293. PDEVICE_OBJECT DeviceObject;
  294. } SHUTDOWN_PACKET, *PSHUTDOWN_PACKET;
  295. //
  296. // Define the type for entries placed on the file system registration change
  297. // notification queue.
  298. //
  299. typedef struct _NOTIFICATION_PACKET {
  300. LIST_ENTRY ListEntry;
  301. PDRIVER_OBJECT DriverObject;
  302. PDRIVER_FS_NOTIFICATION NotificationRoutine;
  303. } NOTIFICATION_PACKET, *PNOTIFICATION_PACKET;
  304. //
  305. // Define I/O completion packet types.
  306. //
  307. typedef enum _COMPLETION_PACKET_TYPE {
  308. IopCompletionPacketIrp,
  309. IopCompletionPacketMini,
  310. IopCompletionPacketQuota
  311. } COMPLETION_PACKET_TYPE, *PCOMPLETION_PACKET_TYPE;
  312. //
  313. // Define the type for completion packets inserted onto completion ports when
  314. // there is no full I/O request packet that was used to perform the I/O
  315. // operation. This occurs when the fast I/O path is used, and when the user
  316. // directly inserts a completion message.
  317. //
  318. typedef struct _IOP_MINI_COMPLETION_PACKET {
  319. //
  320. // The following unnamed structure must be exactly identical
  321. // to the unnamed structure used in the IRP overlay section used
  322. // for completion queue entries.
  323. //
  324. struct {
  325. //
  326. // List entry - used to queue the packet to completion queue, among
  327. // others.
  328. //
  329. LIST_ENTRY ListEntry;
  330. union {
  331. //
  332. // Current stack location - contains a pointer to the current
  333. // IO_STACK_LOCATION structure in the IRP stack. This field
  334. // should never be directly accessed by drivers. They should
  335. // use the standard functions.
  336. //
  337. struct _IO_STACK_LOCATION *CurrentStackLocation;
  338. //
  339. // Minipacket type.
  340. //
  341. ULONG PacketType;
  342. };
  343. };
  344. PVOID KeyContext;
  345. PVOID ApcContext;
  346. NTSTATUS IoStatus;
  347. ULONG_PTR IoStatusInformation;
  348. } IOP_MINI_COMPLETION_PACKET, *PIOP_MINI_COMPLETION_PACKET;
  349. typedef struct _IO_UNLOAD_SAFE_COMPLETION_CONTEXT {
  350. PDEVICE_OBJECT DeviceObject;
  351. PVOID Context;
  352. PIO_COMPLETION_ROUTINE CompletionRoutine;
  353. } IO_UNLOAD_SAFE_COMPLETION_CONTEXT, *PIO_UNLOAD_SAFE_COMPLETION_CONTEXT;
  354. typedef struct _IOP_RESERVE_IRP_ALLOCATOR {
  355. PIRP ReserveIrp;
  356. LONG IrpAllocated;
  357. KEVENT Event;
  358. CCHAR ReserveIrpStackSize;
  359. } IOP_RESERVE_IRP_ALLOCATOR, *PIOP_RESERVE_IRP_ALLOCATOR;
  360. //
  361. // This structure is the extension to a fileobject if the flag
  362. // FO_FILE_OBJECT_HAS_EXTENSION is set in the fileobject.
  363. //
  364. typedef struct _IOP_FILE_OBJECT_EXTENSION {
  365. ULONG FileObjectExtensionFlags;
  366. PDEVICE_OBJECT TopDeviceObjectHint;
  367. PVOID FilterContext; // Pointer where filter keeps its context
  368. } IOP_FILE_OBJECT_EXTENSION, *PIOP_FILE_OBJECT_EXTENSION;
  369. //
  370. // Structure to bookkeep stack profiler.
  371. //
  372. #define MAX_LOOKASIDE_IRP_STACK_COUNT 20 // Highest value for a lookaside stack count
  373. typedef struct _IOP_IRP_STACK_PROFILER {
  374. ULONG Profile[MAX_LOOKASIDE_IRP_STACK_COUNT];
  375. KTIMER Timer;
  376. KDPC Dpc;
  377. ULONG Flags;
  378. ULONG TriggerCount;
  379. ULONG ProfileDuration;
  380. } IOP_IRP_STACK_PROFILER, *PIOP_IRP_STACK_PROFILER;
  381. #define IOP_CREATE_USE_TOP_DEVICE_OBJECT_HINT 0x1 // Define for internal flags to IopCreateFile
  382. #define IOP_CREATE_IGNORE_SHARE_ACCESS_CHECK 0x2
  383. // Extension Flag definitions.
  384. #define FO_EXTENSION_IGNORE_SHARE_ACCESS_CHECK 0x1 // Ignore share access check.
  385. //
  386. // Define the global data for the I/O system.
  387. //
  388. #define IOP_FIXED_SIZE_MDL_PFNS 0x17
  389. #define MAX_RESERVE_IRP_STACK_SIZE 20 // Define 20 as the number of stacks needed for the reserve IRP
  390. #define IOP_PROFILE_TIME_PERIOD 60 // 60 seconds
  391. #define NUM_SAMPLE_IRPS 2000
  392. #define MIN_IRP_THRESHOLD 400 // At least 20 % should be allocated from a given stack location
  393. //
  394. // Define the default number of I/O stack locations a large IRP should
  395. // have if not specified by the registry.
  396. //
  397. #define DEFAULT_LARGE_IRP_LOCATIONS 8
  398. #define BASE_STACK_COUNT DEFAULT_LARGE_IRP_LOCATIONS
  399. //
  400. // Defines for IopIrpAllocatorFlags.
  401. //
  402. #define IOP_ENABLE_AUTO_SIZING 0x1
  403. #define IOP_PROFILE_STACK_COUNT 0x2
  404. #define IOP_PROFILE_DURATION 1 // 1*60 seconds
  405. #define IOP_PROFILE_TRIGGER_INTERVAL 10 // 10*60 seconds
  406. extern ERESOURCE IopDatabaseResource;
  407. extern ERESOURCE IopSecurityResource;
  408. extern ERESOURCE IopCrashDumpLock;
  409. extern LIST_ENTRY IopDiskFileSystemQueueHead;
  410. extern LIST_ENTRY IopCdRomFileSystemQueueHead;
  411. extern LIST_ENTRY IopNetworkFileSystemQueueHead;
  412. extern LIST_ENTRY IopTapeFileSystemQueueHead;
  413. extern LIST_ENTRY IopBootDriverReinitializeQueueHead;
  414. extern LIST_ENTRY IopNotifyShutdownQueueHead;
  415. extern LIST_ENTRY IopNotifyLastChanceShutdownQueueHead;
  416. extern LIST_ENTRY IopFsNotifyChangeQueueHead;
  417. extern KSPIN_LOCK IoStatisticsLock;
  418. extern KSPIN_LOCK IopTimerLock;
  419. extern LIST_ENTRY IopTimerQueueHead;
  420. extern KDPC IopTimerDpc;
  421. extern KTIMER IopTimer;
  422. extern ULONG IopTimerCount;
  423. extern ULONG IopLargeIrpStackLocations;
  424. extern ULONG IopFailZeroAccessCreate;
  425. extern ULONG IopFsRegistrationOps;
  426. extern POBJECT_TYPE IoAdapterObjectType;
  427. extern POBJECT_TYPE IoCompletionObjectType;
  428. extern POBJECT_TYPE IoControllerObjectType;
  429. extern POBJECT_TYPE IoDeviceHandlerObjectType;
  430. extern GENERAL_LOOKASIDE IopLargeIrpLookasideList;
  431. extern GENERAL_LOOKASIDE IopSmallIrpLookasideList;
  432. extern GENERAL_LOOKASIDE IopMdlLookasideList;
  433. extern GENERAL_LOOKASIDE IopCompletionLookasideList;
  434. extern const UCHAR IopQueryOperationLength[];
  435. extern const UCHAR IopSetOperationLength[];
  436. extern const ULONG IopQueryOperationAccess[];
  437. extern const ULONG IopSetOperationAccess[];
  438. extern const UCHAR IopQuerySetAlignmentRequirement[];
  439. extern const UCHAR IopQueryFsOperationLength[];
  440. extern const UCHAR IopSetFsOperationLength[];
  441. extern const ULONG IopQueryFsOperationAccess[];
  442. extern const ULONG IopSetFsOperationAccess[];
  443. extern const UCHAR IopQuerySetFsAlignmentRequirement[];
  444. extern UNICODE_STRING IoArcHalDeviceName;
  445. extern PUCHAR IoLoaderArcBootDeviceName;
  446. extern LONG IopUniqueDeviceObjectNumber;
  447. extern PVOID IopLinkTrackingServiceObject;
  448. extern PKEVENT IopLinkTrackingServiceEvent;
  449. extern HANDLE IopLinkTrackingServiceEventHandle;
  450. extern KEVENT IopLinkTrackingPortObject;
  451. extern LINK_TRACKING_PACKET IopLinkTrackingPacket;
  452. extern UNICODE_STRING IoArcBootDeviceName;
  453. extern PDUMP_CONTROL_BLOCK IopDumpControlBlock;
  454. extern ULONG IopDumpControlBlockChecksum;
  455. extern LIST_ENTRY IopDriverReinitializeQueueHead;
  456. extern BOOLEAN IopVerifierOn;
  457. extern PIO_CALL_DRIVER pIofCallDriver;
  458. extern PIO_COMPLETE_REQUEST pIofCompleteRequest;
  459. extern PIO_FREE_IRP pIoFreeIrp;
  460. extern PIO_ALLOCATE_IRP pIoAllocateIrp;
  461. extern IOP_RESERVE_IRP_ALLOCATOR IopReserveIrpAllocator;
  462. extern IOP_IRP_STACK_PROFILER IopIrpStackProfiler;
  463. //
  464. // The following declaration cannot go in EX.H since POBJECT_TYPE is not defined
  465. // until OB.H, which depends on EX.H. Hence, it is not exported by the EX
  466. // component at all.
  467. //
  468. extern POBJECT_TYPE ExEventObjectType;
  469. //
  470. // Define routines private to the I/O system.
  471. //
  472. VOID
  473. IopAbortRequest(
  474. IN PKAPC Apc
  475. );
  476. //+
  477. //
  478. // BOOLEAN
  479. // IopAcquireFastLock(
  480. // IN PFILE_OBJECT FileObject
  481. // )
  482. //
  483. // Routine Description:
  484. //
  485. // This routine is invoked to acquire the fast lock for a file object.
  486. // This lock protects the busy indicator in the file object resource.
  487. //
  488. // Arguments:
  489. //
  490. // FileObject - Pointer to the file object to be locked.
  491. //
  492. // Return Values:
  493. //
  494. // FALSE - the fileobject was not locked (it was busy)
  495. // TRUE - the fileobject was locked & the busy flag has been set to TRUE
  496. //
  497. //-
  498. static FORCEINLINE BOOLEAN
  499. IopAcquireFastLock(
  500. IN PFILE_OBJECT FileObject
  501. )
  502. {
  503. UNREFERENCED_PARAMETER(FileObject);
  504. if ( InterlockedExchange( (PLONG) &FileObject->Busy, (ULONG) TRUE ) == FALSE ) {
  505. ObReferenceObject(FileObject);
  506. return TRUE;
  507. }
  508. return FALSE;
  509. }
  510. #define IopAcquireCancelSpinLockAtDpcLevel() \
  511. KiAcquireQueuedSpinLock ( &KeGetCurrentPrcb()->LockQueue[LockQueueIoCancelLock] )
  512. #define IopReleaseCancelSpinLockFromDpcLevel() \
  513. KiReleaseQueuedSpinLock ( &KeGetCurrentPrcb()->LockQueue[LockQueueIoCancelLock] )
  514. #define IopAllocateIrp(StackSize, ChargeQuota) \
  515. IoAllocateIrp((StackSize), (ChargeQuota))
  516. #define IsIoVerifierOn() IopVerifierOn
  517. static __inline VOID
  518. IopProbeAndLockPages(
  519. IN OUT PMDL MemoryDescriptorList,
  520. IN KPROCESSOR_MODE AccessMode,
  521. IN LOCK_OPERATION Operation,
  522. IN PDEVICE_OBJECT DeviceObject,
  523. IN ULONG MajorFunction
  524. )
  525. {
  526. extern LOGICAL MmTrackLockedPages;
  527. MmProbeAndLockPages(MemoryDescriptorList, AccessMode, Operation);
  528. if (MmTrackLockedPages) {
  529. PVOID DriverRoutine;
  530. DriverRoutine = (PVOID)(ULONG_PTR)DeviceObject->DriverObject->MajorFunction[MajorFunction];
  531. MmUpdateMdlTracker(MemoryDescriptorList, DriverRoutine, DeviceObject);
  532. }
  533. }
  534. #define IopIsReserveIrp(Irp) ((Irp) == (IopReserveIrpAllocator.ReserveIrp))
  535. //
  536. // Bump the stack profile.
  537. //
  538. #define IopProfileIrpStackCount(StackSize) \
  539. ((StackSize < MAX_LOOKASIDE_IRP_STACK_COUNT) ? \
  540. IopIrpStackProfiler.Profile[StackSize]++ : 0)
  541. //
  542. // True if auto sizing is enabled.
  543. //
  544. #define IopIrpAutoSizingEnabled() ((IopIrpStackProfiler.Flags & IOP_ENABLE_AUTO_SIZING))
  545. //
  546. // True if stack profiling is enabled.
  547. //
  548. #define IopIrpProfileStackCountEnabled() \
  549. ((IopIrpStackProfiler.Flags & (IOP_PROFILE_STACK_COUNT|IOP_ENABLE_AUTO_SIZING)) \
  550. == (IOP_PROFILE_STACK_COUNT|IOP_ENABLE_AUTO_SIZING))
  551. //
  552. // Definitions for SecurityDescriptorFlavor.
  553. //
  554. #define IO_SD_LEGACY 0 // Sets per WIN2K settings.
  555. #define IO_SD_SYS_ALL_ADM_ALL_WORLD_E 1 // WORLD:E, Admins:ALL, System:ALL
  556. #define IO_SD_SYS_ALL_ADM_ALL_WORLD_E_RES_E 2 // WORLD:E, Admins:ALL, System:ALL, Restricted:E
  557. #define IO_SD_SYS_ALL_ADM_ALL_WORLD_RWE 3 // WORLD:RWE, Admins:ALL, System:ALL
  558. #define IO_SD_SYS_ALL_ADM_ALL_WORLD_RWE_RES_RE 4 // WORLD:RWE, Admins:ALL, System:ALL, Restricted:RE
  559. #define IO_SD_SYS_ALL_ADM_RE 5 // System:ALL, Admins:RE
  560. NTSTATUS
  561. IopAcquireFileObjectLock(
  562. IN PFILE_OBJECT FileObject,
  563. IN KPROCESSOR_MODE RequestorMode,
  564. IN BOOLEAN Alertable,
  565. OUT PBOOLEAN Interrupted
  566. );
  567. VOID
  568. IopAllocateIrpCleanup(
  569. IN PFILE_OBJECT FileObject,
  570. IN PKEVENT EventObject OPTIONAL
  571. );
  572. PIRP
  573. IopAllocateIrpMustSucceed(
  574. IN CCHAR StackSize
  575. );
  576. VOID
  577. IopApcHardError(
  578. IN PVOID StartContext
  579. );
  580. VOID
  581. IopCancelAlertedRequest(
  582. IN PKEVENT Event,
  583. IN PIRP Irp
  584. );
  585. VOID
  586. IopCheckBackupRestorePrivilege(
  587. IN PACCESS_STATE AccessState,
  588. IN OUT PULONG CreateOptions,
  589. IN KPROCESSOR_MODE PreviousMode,
  590. IN ULONG Disposition
  591. );
  592. NTSTATUS
  593. IopCheckGetQuotaBufferValidity(
  594. IN PFILE_GET_QUOTA_INFORMATION QuotaBuffer,
  595. IN ULONG QuotaLength,
  596. OUT PULONG_PTR ErrorOffset
  597. );
  598. VOID
  599. IopCloseFile(
  600. IN PEPROCESS Process OPTIONAL,
  601. IN PVOID Object,
  602. IN ULONG GrantedAccess,
  603. IN ULONG_PTR ProcessHandleCount,
  604. IN ULONG_PTR SystemHandleCount
  605. );
  606. VOID
  607. IopCompleteUnloadOrDelete(
  608. IN PDEVICE_OBJECT DeviceObject,
  609. IN BOOLEAN OnCleanStack,
  610. IN KIRQL Irql
  611. );
  612. VOID
  613. IopCompletePageWrite(
  614. IN PKAPC Apc,
  615. IN PKNORMAL_ROUTINE *NormalRoutine,
  616. IN PVOID *NormalContext,
  617. IN PVOID *SystemArgument1,
  618. IN PVOID *SystemArgument2
  619. );
  620. VOID
  621. IopCompleteRequest(
  622. IN PKAPC Apc,
  623. IN PKNORMAL_ROUTINE *NormalRoutine,
  624. IN PVOID *NormalContext,
  625. IN PVOID *SystemArgument1,
  626. IN PVOID *SystemArgument2
  627. );
  628. BOOLEAN
  629. IopConfigureCrashDump(
  630. IN HANDLE HandlePagingFile
  631. );
  632. VOID
  633. IopConnectLinkTrackingPort(
  634. IN PVOID Parameter
  635. );
  636. NTSTATUS
  637. IopCreateVpb (
  638. IN PDEVICE_OBJECT DeviceObject
  639. );
  640. VOID
  641. IopDeallocateApc(
  642. IN PKAPC Apc,
  643. IN PKNORMAL_ROUTINE *NormalRoutine,
  644. IN PVOID *NormalContext,
  645. IN PVOID *SystemArgument1,
  646. IN PVOID *SystemArgument2
  647. );
  648. VOID
  649. IopDecrementDeviceObjectRef(
  650. IN PDEVICE_OBJECT DeviceObject,
  651. IN BOOLEAN AlwaysUnload,
  652. IN BOOLEAN OnCleanStack
  653. );
  654. VOID
  655. IopDeleteDriver(
  656. IN PVOID Object
  657. );
  658. VOID
  659. IopDeleteDevice(
  660. IN PVOID Object
  661. );
  662. VOID
  663. IopDeleteFile(
  664. IN PVOID Object
  665. );
  666. VOID
  667. IopDeleteIoCompletion(
  668. IN PVOID Object
  669. );
  670. //+
  671. //
  672. // VOID
  673. // IopDequeueThreadIrp(
  674. // IN PIRP Irp
  675. // )
  676. //
  677. // Routine Description:
  678. //
  679. // This routine dequeues the specified I/O Request Packet (IRP) from the
  680. // thread IRP queue which it is currently queued.
  681. //
  682. // In checked we set Flink == Blink so we can assert free's of queue'd IRPs
  683. //
  684. // Arguments:
  685. //
  686. // Irp - Specifies the IRP that is dequeued.
  687. //
  688. // Return Value:
  689. //
  690. // None.
  691. //
  692. //-
  693. #define IopDequeueThreadIrp( Irp ) \
  694. { \
  695. RemoveEntryList( &Irp->ThreadListEntry ); \
  696. InitializeListHead( &Irp->ThreadListEntry ) ; \
  697. }
  698. #ifdef _WIN64
  699. #define IopApcRoutinePresent(ApcRoutine) ARGUMENT_PRESENT((ULONG_PTR)(ApcRoutine) & ~1)
  700. #define IopIsIosb32(ApcRoutine) ((ULONG_PTR)(ApcRoutine) & 1)
  701. #else
  702. #define IopApcRoutinePresent(ApcRoutine) ARGUMENT_PRESENT(ApcRoutine)
  703. #endif
  704. VOID
  705. IopDisassociateThreadIrp(
  706. VOID
  707. );
  708. BOOLEAN
  709. IopDmaDispatch(
  710. IN PKINTERRUPT Interrupt,
  711. IN PVOID ServiceContext
  712. );
  713. VOID
  714. IopDropIrp(
  715. IN PIRP Irp,
  716. IN PFILE_OBJECT FileObject
  717. );
  718. LONG
  719. IopExceptionFilter(
  720. IN PEXCEPTION_POINTERS ExceptionPointers,
  721. OUT PNTSTATUS ExceptionCode
  722. );
  723. VOID
  724. IopExceptionCleanup(
  725. IN PFILE_OBJECT FileObject,
  726. IN PIRP Irp,
  727. IN PKEVENT EventObject OPTIONAL,
  728. IN PKEVENT KernelEvent OPTIONAL
  729. );
  730. VOID
  731. IopErrorLogThread(
  732. IN PVOID StartContext
  733. );
  734. VOID
  735. IopFreeIrpAndMdls(
  736. IN PIRP Irp
  737. );
  738. PDEVICE_OBJECT
  739. IopGetDeviceAttachmentBase(
  740. IN PDEVICE_OBJECT DeviceObject
  741. );
  742. NTSTATUS
  743. IopGetFileInformation(
  744. IN PFILE_OBJECT FileObject,
  745. IN ULONG Length,
  746. IN FILE_INFORMATION_CLASS FileInformationClass,
  747. OUT PVOID FileInformation,
  748. OUT PULONG ReturnedLength
  749. );
  750. BOOLEAN
  751. IopGetMountFlag(
  752. IN PDEVICE_OBJECT DeviceObject
  753. );
  754. NTSTATUS
  755. IopGetRegistryValues(
  756. IN HANDLE KeyHandle,
  757. IN PKEY_VALUE_FULL_INFORMATION *ValueList
  758. );
  759. NTSTATUS
  760. IopGetSetObjectId(
  761. IN PFILE_OBJECT FileObject,
  762. IN OUT PVOID Buffer,
  763. IN ULONG Length,
  764. IN ULONG OperationFlags
  765. );
  766. NTSTATUS
  767. IopGetSetSecurityObject(
  768. IN PVOID Object,
  769. IN SECURITY_OPERATION_CODE OperationCode,
  770. IN PSECURITY_INFORMATION SecurityInformation,
  771. IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
  772. IN OUT PULONG CapturedLength,
  773. IN OUT PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor,
  774. IN POOL_TYPE PoolType,
  775. IN PGENERIC_MAPPING GenericMapping
  776. );
  777. NTSTATUS
  778. IopGetVolumeId(
  779. IN PFILE_OBJECT FileObject,
  780. IN OUT PLINK_TRACKING_INFORMATION ObjectId,
  781. IN ULONG Length
  782. );
  783. VOID
  784. IopHardErrorThread(
  785. PVOID StartContext
  786. );
  787. VOID
  788. IopInsertRemoveDevice(
  789. IN PDRIVER_OBJECT DriverObject,
  790. IN PDEVICE_OBJECT DeviceObject,
  791. IN BOOLEAN Insert
  792. );
  793. //
  794. // Interlocked list manipulation funtions using queued spin locks.
  795. //
  796. PLIST_ENTRY
  797. FASTCALL
  798. IopInterlockedInsertHeadList (
  799. IN PLIST_ENTRY ListHead,
  800. IN PLIST_ENTRY ListEntry
  801. );
  802. PLIST_ENTRY
  803. FASTCALL
  804. IopInterlockedInsertTailList (
  805. IN PLIST_ENTRY ListHead,
  806. IN PLIST_ENTRY ListEntry
  807. );
  808. PLIST_ENTRY
  809. FASTCALL
  810. IopInterlockedRemoveHeadList (
  811. IN PLIST_ENTRY ListHead
  812. );
  813. LOGICAL
  814. IopIsSameMachine(
  815. IN PFILE_OBJECT SourceFile,
  816. IN HANDLE TargetFile
  817. );
  818. VOID
  819. IopLoadFileSystemDriver(
  820. IN PDEVICE_OBJECT DeviceObject
  821. );
  822. VOID
  823. IopLoadUnloadDriver(
  824. IN PVOID Parameter
  825. );
  826. NTSTATUS
  827. IopLogErrorEvent(
  828. IN ULONG SequenceNumber,
  829. IN ULONG UniqueErrorValue,
  830. IN NTSTATUS FinalStatus,
  831. IN NTSTATUS SpecificIOStatus,
  832. IN ULONG LengthOfInsert1,
  833. IN PWCHAR Insert1,
  834. IN ULONG LengthOfInsert2,
  835. IN PWCHAR Insert2
  836. );
  837. NTSTATUS
  838. IopLookupBusStringFromID (
  839. IN HANDLE KeyHandle,
  840. IN INTERFACE_TYPE InterfaceType,
  841. OUT PWCHAR Buffer,
  842. IN ULONG Length,
  843. OUT PULONG BusFlags OPTIONAL
  844. );
  845. NTSTATUS
  846. IopMountVolume(
  847. IN PDEVICE_OBJECT DeviceObject,
  848. IN BOOLEAN AllowRawMount,
  849. IN BOOLEAN DeviceLockAlreadyHeld,
  850. IN BOOLEAN Alertable,
  851. OUT PVPB *Vpb
  852. );
  853. NTSTATUS
  854. IopOpenLinkOrRenameTarget(
  855. OUT PHANDLE TargetHandle,
  856. IN PIRP Irp,
  857. IN PVOID RenameBuffer,
  858. IN PFILE_OBJECT FileObject
  859. );
  860. NTSTATUS
  861. IopOpenRegistryKey(
  862. OUT PHANDLE Handle,
  863. IN HANDLE BaseHandle OPTIONAL,
  864. IN PUNICODE_STRING KeyName,
  865. IN ACCESS_MASK DesiredAccess,
  866. IN BOOLEAN Create
  867. );
  868. NTSTATUS
  869. IopParseDevice(
  870. IN PVOID ParseObject,
  871. IN PVOID ObjectType,
  872. IN PACCESS_STATE AccessState,
  873. IN KPROCESSOR_MODE AccessMode,
  874. IN ULONG Attributes,
  875. IN OUT PUNICODE_STRING CompleteName,
  876. IN OUT PUNICODE_STRING RemainingName,
  877. IN OUT PVOID Context OPTIONAL,
  878. IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
  879. OUT PVOID *Object
  880. );
  881. NTSTATUS
  882. IopParseFile(
  883. IN PVOID ParseObject,
  884. IN PVOID ObjectType,
  885. IN PACCESS_STATE AccessState,
  886. IN KPROCESSOR_MODE AccessMode,
  887. IN ULONG Attributes,
  888. IN OUT PUNICODE_STRING CompleteName,
  889. IN OUT PUNICODE_STRING RemainingName,
  890. IN OUT PVOID Context OPTIONAL,
  891. IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
  892. OUT PVOID *Object
  893. );
  894. BOOLEAN
  895. IopProtectSystemPartition(
  896. IN PLOADER_PARAMETER_BLOCK LoaderBlock
  897. );
  898. NTSTATUS
  899. IopQueryName(
  900. IN PVOID Object,
  901. IN BOOLEAN HasObjectName,
  902. OUT POBJECT_NAME_INFORMATION ObjectNameInfo,
  903. IN ULONG Length,
  904. OUT PULONG ReturnLength,
  905. IN KPROCESSOR_MODE Mode
  906. );
  907. NTSTATUS
  908. IopQueryNameInternal(
  909. IN PVOID Object,
  910. IN BOOLEAN HasObjectName,
  911. IN BOOLEAN UseDosDeviceName,
  912. OUT POBJECT_NAME_INFORMATION ObjectNameInfo,
  913. IN ULONG Length,
  914. OUT PULONG ReturnLength,
  915. IN KPROCESSOR_MODE Mode
  916. );
  917. NTSTATUS
  918. IopQueryXxxInformation(
  919. IN PFILE_OBJECT FileObject,
  920. IN ULONG InformationClass,
  921. IN ULONG Length,
  922. IN KPROCESSOR_MODE Mode,
  923. OUT PVOID Information,
  924. OUT PULONG ReturnedLength,
  925. IN BOOLEAN FileInformation
  926. );
  927. VOID
  928. IopQueueWorkRequest(
  929. IN PIRP Irp
  930. );
  931. VOID
  932. IopRaiseHardError(
  933. IN PVOID NormalContext,
  934. IN PVOID SystemArgument1,
  935. IN PVOID SystemArgument2
  936. );
  937. VOID
  938. IopRaiseInformationalHardError(
  939. IN PVOID NormalContext,
  940. IN PVOID SystemArgument1,
  941. IN PVOID SystemArgument2
  942. );
  943. VOID
  944. IopReadyDeviceObjects(
  945. IN PDRIVER_OBJECT DriverObject
  946. );
  947. //+
  948. //
  949. // VOID
  950. // IopReleaseFileObjectLock(
  951. // IN PFILE_OBJECT FileObject
  952. // )
  953. //
  954. // Routine Description:
  955. //
  956. // This routine is invoked to release ownership of the file object lock.
  957. // Dereference the fileobject acquired during the lock.
  958. //
  959. // Arguments:
  960. //
  961. // FileObject - Pointer to the file object whose ownership is to be
  962. // released.
  963. //
  964. // Return Value:
  965. //
  966. // None.
  967. //
  968. //-
  969. #define IopReleaseFileObjectLock( FileObject ) { \
  970. ULONG Result; \
  971. Result = InterlockedExchange( (PLONG) &FileObject->Busy, FALSE ); \
  972. ASSERT(Result != FALSE); \
  973. if (FileObject->Waiters != 0) { \
  974. KeSetEvent( &FileObject->Lock, 0, FALSE ); \
  975. } \
  976. ObDereferenceObject(FileObject); \
  977. }
  978. #if _WIN32_WINNT >= 0x0500
  979. NTSTATUS
  980. IopSendMessageToTrackService(
  981. IN PLINK_TRACKING_INFORMATION SourceVolumeId,
  982. IN PFILE_OBJECTID_BUFFER SourceObjectId,
  983. IN PFILE_TRACKING_INFORMATION TargetObjectInformation
  984. );
  985. #endif
  986. NTSTATUS
  987. IopSetEaOrQuotaInformationFile(
  988. IN HANDLE FileHandle,
  989. OUT PIO_STATUS_BLOCK IoStatusBlock,
  990. IN PVOID Buffer,
  991. IN ULONG Length,
  992. IN BOOLEAN SetEa
  993. );
  994. NTSTATUS
  995. IopSetRemoteLink(
  996. IN PFILE_OBJECT FileObject,
  997. IN PFILE_OBJECT DestinationFileObject OPTIONAL,
  998. IN PFILE_TRACKING_INFORMATION FileInformation OPTIONAL
  999. );
  1000. VOID
  1001. IopStartApcHardError(
  1002. IN PVOID StartContext
  1003. );
  1004. NTSTATUS
  1005. IopSynchronousApiServiceTail(
  1006. IN NTSTATUS ReturnedStatus,
  1007. IN PKEVENT Event,
  1008. IN PIRP Irp,
  1009. IN KPROCESSOR_MODE RequestorMode,
  1010. IN PIO_STATUS_BLOCK LocalIoStatus,
  1011. OUT PIO_STATUS_BLOCK IoStatusBlock
  1012. );
  1013. NTSTATUS
  1014. IopSynchronousServiceTail(
  1015. IN PDEVICE_OBJECT DeviceObject,
  1016. IN PIRP Irp,
  1017. IN PFILE_OBJECT FileObject,
  1018. IN BOOLEAN DeferredIoCompletion,
  1019. IN KPROCESSOR_MODE RequestorMode,
  1020. IN BOOLEAN SynchronousIo,
  1021. IN TRANSFER_TYPE TransferType
  1022. );
  1023. VOID
  1024. IopTimerDispatch(
  1025. IN PKDPC Dpc,
  1026. IN PVOID DeferredContext,
  1027. IN PVOID SystemArgument1,
  1028. IN PVOID SystemArgument2
  1029. );
  1030. NTSTATUS
  1031. IopTrackLink(
  1032. IN PFILE_OBJECT FileObject,
  1033. IN OUT PIO_STATUS_BLOCK IoStatusBlock,
  1034. IN PFILE_TRACKING_INFORMATION FileInformation,
  1035. IN ULONG Length,
  1036. IN PKEVENT Event,
  1037. IN KPROCESSOR_MODE RequestorMode
  1038. );
  1039. VOID
  1040. IopUserCompletion(
  1041. IN PKAPC Apc,
  1042. IN PKNORMAL_ROUTINE *NormalRoutine,
  1043. IN PVOID *NormalContext,
  1044. IN PVOID *SystemArgument1,
  1045. IN PVOID *SystemArgument2
  1046. );
  1047. NTSTATUS
  1048. IopXxxControlFile(
  1049. IN HANDLE FileHandle,
  1050. IN HANDLE Event OPTIONAL,
  1051. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  1052. IN PVOID ApcContext OPTIONAL,
  1053. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1054. IN ULONG IoControlCode,
  1055. IN PVOID InputBuffer OPTIONAL,
  1056. IN ULONG InputBufferLength,
  1057. OUT PVOID OutputBuffer OPTIONAL,
  1058. IN ULONG OutputBufferLength,
  1059. IN BOOLEAN DeviceIoControl
  1060. );
  1061. NTSTATUS
  1062. IopReportResourceUsage(
  1063. IN PUNICODE_STRING DriverClassName OPTIONAL,
  1064. IN PDRIVER_OBJECT DriverObject,
  1065. IN PCM_RESOURCE_LIST DriverList OPTIONAL,
  1066. IN ULONG DriverListSize OPTIONAL,
  1067. IN PDEVICE_OBJECT DeviceObject OPTIONAL,
  1068. IN PCM_RESOURCE_LIST DeviceList OPTIONAL,
  1069. IN ULONG DeviceListSize OPTIONAL,
  1070. IN BOOLEAN OverrideConflict,
  1071. OUT PBOOLEAN ConflictDetected
  1072. );
  1073. VOID
  1074. IopDoNameTransmogrify(
  1075. IN PIRP Irp,
  1076. IN PFILE_OBJECT FileObject,
  1077. IN PREPARSE_DATA_BUFFER ReparseBuffer
  1078. );
  1079. VOID
  1080. IopUpdateOtherOperationCount(
  1081. VOID
  1082. );
  1083. VOID
  1084. IopUpdateReadOperationCount(
  1085. VOID
  1086. );
  1087. VOID
  1088. IopUpdateWriteOperationCount(
  1089. VOID
  1090. );
  1091. VOID
  1092. IopUpdateOtherTransferCount(
  1093. IN ULONG TransferCount
  1094. );
  1095. VOID
  1096. IopUpdateReadTransferCount(
  1097. IN ULONG TransferCount
  1098. );
  1099. VOID
  1100. IopUpdateWriteTransferCount(
  1101. IN ULONG TransferCount
  1102. );
  1103. NTSTATUS
  1104. FORCEINLINE
  1105. IopfCallDriver(
  1106. IN PDEVICE_OBJECT DeviceObject,
  1107. IN OUT PIRP Irp
  1108. )
  1109. /*++
  1110. Routine Description:
  1111. This routine is invoked to pass an I/O Request Packet (IRP) to another
  1112. driver at its dispatch routine.
  1113. Arguments:
  1114. DeviceObject - Pointer to device object to which the IRP should be passed.
  1115. Irp - Pointer to IRP for request.
  1116. Return Value:
  1117. Return status from driver's dispatch routine.
  1118. --*/
  1119. {
  1120. PIO_STACK_LOCATION irpSp;
  1121. PDRIVER_OBJECT driverObject;
  1122. NTSTATUS status;
  1123. //
  1124. // Ensure that this is really an I/O Request Packet.
  1125. //
  1126. ASSERT( Irp->Type == IO_TYPE_IRP );
  1127. //
  1128. // Update the IRP stack to point to the next location.
  1129. //
  1130. Irp->CurrentLocation--;
  1131. if (Irp->CurrentLocation <= 0) {
  1132. KeBugCheckEx( NO_MORE_IRP_STACK_LOCATIONS, (ULONG_PTR) Irp, 0, 0, 0 );
  1133. }
  1134. irpSp = IoGetNextIrpStackLocation( Irp );
  1135. Irp->Tail.Overlay.CurrentStackLocation = irpSp;
  1136. //
  1137. // Save a pointer to the device object for this request so that it can
  1138. // be used later in completion.
  1139. //
  1140. irpSp->DeviceObject = DeviceObject;
  1141. //
  1142. // Invoke the driver at its dispatch routine entry point.
  1143. //
  1144. driverObject = DeviceObject->DriverObject;
  1145. //
  1146. // Prevent the driver from unloading.
  1147. //
  1148. status = driverObject->MajorFunction[irpSp->MajorFunction]( DeviceObject,
  1149. Irp );
  1150. return status;
  1151. }
  1152. VOID
  1153. FASTCALL
  1154. IopfCompleteRequest(
  1155. IN PIRP Irp,
  1156. IN CCHAR PriorityBost
  1157. );
  1158. PIRP
  1159. IopAllocateIrpPrivate(
  1160. IN CCHAR StackSize,
  1161. IN BOOLEAN ChargeQuota
  1162. );
  1163. VOID
  1164. IopFreeIrp(
  1165. IN PIRP Irp
  1166. );
  1167. PVOID
  1168. IopAllocateErrorLogEntry(
  1169. IN PDEVICE_OBJECT deviceObject,
  1170. IN PDRIVER_OBJECT driverObject,
  1171. IN UCHAR EntrySize
  1172. );
  1173. VOID
  1174. IopNotifyAlreadyRegisteredFileSystems(
  1175. IN PLIST_ENTRY ListHead,
  1176. IN PDRIVER_FS_NOTIFICATION DriverNotificationRoutine,
  1177. IN BOOLEAN SkipRaw
  1178. );
  1179. NTSTATUS
  1180. IopCheckUnloadDriver(
  1181. IN PDRIVER_OBJECT driverObject,
  1182. OUT PBOOLEAN unloadDriver
  1183. );
  1184. //
  1185. // Interlocked increment/decrement functions using queued spin locks.
  1186. //
  1187. ULONG
  1188. FASTCALL
  1189. IopInterlockedDecrementUlong (
  1190. IN KSPIN_LOCK_QUEUE_NUMBER Number,
  1191. IN OUT PLONG Addend
  1192. );
  1193. ULONG
  1194. FASTCALL
  1195. IopInterlockedIncrementUlong (
  1196. IN KSPIN_LOCK_QUEUE_NUMBER Number,
  1197. IN OUT PLONG Addend
  1198. );
  1199. VOID
  1200. IopShutdownBaseFileSystems(
  1201. IN PLIST_ENTRY ListHead
  1202. );
  1203. VOID
  1204. IopPerfLogFileCreate(
  1205. IN PFILE_OBJECT FileObject,
  1206. IN PUNICODE_STRING CompleteName
  1207. );
  1208. BOOLEAN
  1209. IopInitializeReserveIrp(
  1210. PIOP_RESERVE_IRP_ALLOCATOR Allocator
  1211. );
  1212. PIRP
  1213. IopAllocateReserveIrp(
  1214. IN CCHAR StackSize
  1215. );
  1216. VOID
  1217. IopFreeReserveIrp(
  1218. IN CCHAR PriorityBoost
  1219. );
  1220. NTSTATUS
  1221. IopGetBasicInformationFile(
  1222. IN PFILE_OBJECT FileObject,
  1223. IN PFILE_BASIC_INFORMATION BasicInformationBuffer
  1224. );
  1225. NTSTATUS
  1226. IopCreateFile(
  1227. OUT PHANDLE FileHandle,
  1228. IN ACCESS_MASK DesiredAccess,
  1229. IN POBJECT_ATTRIBUTES ObjectAttributes,
  1230. OUT PIO_STATUS_BLOCK IoStatusBlock,
  1231. IN PLARGE_INTEGER AllocationSize OPTIONAL,
  1232. IN ULONG FileAttributes,
  1233. IN ULONG ShareAccess,
  1234. IN ULONG Disposition,
  1235. IN ULONG CreateOptions,
  1236. IN PVOID EaBuffer OPTIONAL,
  1237. IN ULONG EaLength,
  1238. IN CREATE_FILE_TYPE CreateFileType,
  1239. IN PVOID ExtraCreateParameters OPTIONAL,
  1240. IN ULONG Options,
  1241. IN ULONG InternalFlags,
  1242. IN PVOID DeviceObject
  1243. );
  1244. BOOLEAN
  1245. IopVerifyDeviceObjectOnStack(
  1246. IN PDEVICE_OBJECT BaseDeviceObject,
  1247. IN PDEVICE_OBJECT TopDeviceObject
  1248. );
  1249. BOOLEAN
  1250. IopVerifyDiskSignature(
  1251. IN PDRIVE_LAYOUT_INFORMATION_EX DriveLayout,
  1252. IN PARC_DISK_SIGNATURE LoaderDiskBlock,
  1253. OUT PULONG DiskSignature
  1254. );
  1255. NTSTATUS
  1256. IopGetDriverPathInformation(
  1257. IN PFILE_OBJECT FileObject,
  1258. IN PFILE_FS_DRIVER_PATH_INFORMATION FsDpInfo,
  1259. IN ULONG Length
  1260. );
  1261. BOOLEAN
  1262. IopVerifyDriverObjectOnStack(
  1263. IN PDEVICE_OBJECT DeviceObject,
  1264. IN PDRIVER_OBJECT DriverObject
  1265. );
  1266. NTSTATUS
  1267. IopInitializeIrpStackProfiler(
  1268. VOID
  1269. );
  1270. VOID
  1271. IopIrpStackProfilerTimer(
  1272. IN struct _KDPC *Dpc,
  1273. IN PVOID DeferredContext,
  1274. IN PVOID SystemArgument1,
  1275. IN PVOID SystemArgument2
  1276. );
  1277. VOID
  1278. IopProcessIrpStackProfiler(
  1279. VOID
  1280. );
  1281. PDEVICE_OBJECT
  1282. IopAttachDeviceToDeviceStackSafe(
  1283. IN PDEVICE_OBJECT SourceDevice,
  1284. IN PDEVICE_OBJECT TargetDevice,
  1285. OUT PDEVICE_OBJECT *AttachedToDeviceObject OPTIONAL
  1286. );
  1287. NTSTATUS
  1288. IopCreateSecurityDescriptorPerType(
  1289. IN PSECURITY_DESCRIPTOR Descriptor,
  1290. IN ULONG SecurityDescriptorFlavor,
  1291. OUT PSECURITY_INFORMATION SecurityInformation OPTIONAL
  1292. );
  1293. BOOLEAN
  1294. IopReferenceVerifyVpb(
  1295. IN PDEVICE_OBJECT DeviceObject,
  1296. OUT PVPB *Vpb,
  1297. OUT PDEVICE_OBJECT *FsDeviceObject
  1298. );
  1299. VOID
  1300. IopDereferenceVpbAndFree(
  1301. IN PVPB Vpb
  1302. );
  1303. #endif // _IOMGR_