[NTOSKRNL]
[reactos.git] / reactos / ntoskrnl / include / internal / io.h
1 /*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/include/io.h
5 * PURPOSE: Internal header for the I/O Manager
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8 #include "ntdddisk.h"
9
10 //
11 // Define this if you want debugging support
12 //
13 #define _IO_DEBUG_ 0x01
14
15 //
16 // These define the Debug Masks Supported
17 //
18 #define IO_IRP_DEBUG 0x01
19 #define IO_FILE_DEBUG 0x02
20 #define IO_API_DEBUG 0x04
21 #define IO_CTL_DEBUG 0x08
22
23 //
24 // Debug/Tracing support
25 //
26 #if _IO_DEBUG_
27 #ifdef NEW_DEBUG_SYSTEM_IMPLEMENTED // enable when Debug Filters are implemented
28 #define IOTRACE(x, ...) \
29 { \
30 DbgPrintEx("%s [%.16s] - ", \
31 __FUNCTION__, \
32 PsGetCurrentProcess()->ImageFileName); \
33 DbgPrintEx(__VA_ARGS__); \
34 }
35 #else
36 #define IOTRACE(x, ...) \
37 if (x & IopTraceLevel) \
38 { \
39 DbgPrint("%s [%.16s] - ", \
40 __FUNCTION__, \
41 PsGetCurrentProcess()->ImageFileName); \
42 DbgPrint(__VA_ARGS__); \
43 }
44 #endif
45 #else
46 #define IOTRACE(x, fmt, ...) DPRINT(fmt, ##__VA_ARGS__)
47 #endif
48
49 //
50 // Registry path to the enumeration root key
51 //
52 #define ENUM_ROOT L"\\Registry\\Machine\\System\\CurrentControlSet\\Enum"
53
54 //
55 // Returns the type of METHOD_ used in this IOCTL
56 //
57 #define IO_METHOD_FROM_CTL_CODE(c) (c & 0x00000003)
58
59 //
60 // Bugcheck codes for RAM disk booting
61 //
62 //
63 // No LoaderXIPRom descriptor was found in the loader memory list
64 //
65 #define RD_NO_XIPROM_DESCRIPTOR 1
66 //
67 // Unable to open the RAM disk driver (ramdisk.sys or \Device\Ramdisk)
68 //
69 #define RD_NO_RAMDISK_DRIVER 2
70 //
71 // FSCTL_CREATE_RAM_DISK failed
72 //
73 #define RD_FSCTL_FAILED 3
74 //
75 // Unable to create GUID string from binary GUID
76 //
77 #define RD_GUID_CONVERT_FAILED 4
78 //
79 // Unable to create symbolic link pointing to the RAM disk device
80 //
81 #define RD_SYMLINK_CREATE_FAILED 5
82
83 //
84 // Max traversal of reparse points for a single open in IoParseDevice
85 //
86 #define IOP_MAX_REPARSE_TRAVERSAL 0x20
87
88 //
89 // We can call the Ob Inlined API, it's the same thing
90 //
91 #define IopAllocateMdlFromLookaside \
92 ObpAllocateObjectCreateInfoBuffer
93 #define IopFreeMdlFromLookaside \
94 ObpFreeCapturedAttributes
95
96 //
97 // Determines if the IRP is Synchronous
98 //
99 #define IsIrpSynchronous(Irp, FileObject) \
100 ((Irp->Flags & IRP_SYNCHRONOUS_API) || \
101 (!(FileObject) ? \
102 FALSE : \
103 FileObject->Flags & FO_SYNCHRONOUS_IO)) \
104
105 //
106 // Returns the internal Device Object Extension
107 //
108 #define IoGetDevObjExtension(DeviceObject) \
109 ((PEXTENDED_DEVOBJ_EXTENSION) \
110 (DeviceObject->DeviceObjectExtension)) \
111
112 //
113 // Returns the internal Driver Object Extension
114 //
115 #define IoGetDrvObjExtension(DriverObject) \
116 ((PEXTENDED_DRIVER_EXTENSION) \
117 (DriverObject->DriverExtension)) \
118
119 /*
120 * VOID
121 * IopDeviceNodeSetFlag(
122 * PDEVICE_NODE DeviceNode,
123 * ULONG Flag);
124 */
125 #define IopDeviceNodeSetFlag(DeviceNode, Flag) \
126 ((DeviceNode)->Flags |= (Flag))
127
128 /*
129 * VOID
130 * IopDeviceNodeClearFlag(
131 * PDEVICE_NODE DeviceNode,
132 * ULONG Flag);
133 */
134 #define IopDeviceNodeClearFlag(DeviceNode, Flag) \
135 ((DeviceNode)->Flags &= ~(Flag))
136
137 /*
138 * BOOLEAN
139 * IopDeviceNodeHasFlag(
140 * PDEVICE_NODE DeviceNode,
141 * ULONG Flag);
142 */
143 #define IopDeviceNodeHasFlag(DeviceNode, Flag) \
144 (((DeviceNode)->Flags & (Flag)) > 0)
145
146 /*
147 * VOID
148 * IopDeviceNodeSetUserFlag(
149 * PDEVICE_NODE DeviceNode,
150 * ULONG UserFlag);
151 */
152 #define IopDeviceNodeSetUserFlag(DeviceNode, UserFlag) \
153 ((DeviceNode)->UserFlags |= (UserFlag))
154
155 /*
156 * VOID
157 * IopDeviceNodeClearUserFlag(
158 * PDEVICE_NODE DeviceNode,
159 * ULONG UserFlag);
160 */
161 #define IopDeviceNodeClearUserFlag(DeviceNode, UserFlag)\
162 ((DeviceNode)->UserFlags &= ~(UserFlag))
163
164 /*
165 * BOOLEAN
166 * IopDeviceNodeHasUserFlag(
167 * PDEVICE_NODE DeviceNode,
168 * ULONG UserFlag);
169 */
170 #define IopDeviceNodeHasUserFlag(DeviceNode, UserFlag) \
171 (((DeviceNode)->UserFlags & (UserFlag)) > 0)
172
173 /*
174 * VOID
175 * IopDeviceNodeSetProblem(
176 * PDEVICE_NODE DeviceNode,
177 * ULONG Problem);
178 */
179 #define IopDeviceNodeSetProblem(DeviceNode, Problem) \
180 ((DeviceNode)->Problem |= (Problem))
181
182 /*
183 * VOID
184 * IopDeviceNodeClearProblem(
185 * PDEVICE_NODE DeviceNode,
186 * ULONG Problem);
187 */
188 #define IopDeviceNodeClearProblem(DeviceNode, Problem) \
189 ((DeviceNode)->Problem &= ~(Problem))
190
191 /*
192 * BOOLEAN
193 * IopDeviceNodeHasProblem(
194 * PDEVICE_NODE DeviceNode,
195 * ULONG Problem);
196 */
197 #define IopDeviceNodeHasProblem(DeviceNode, Problem) \
198 (((DeviceNode)->Problem & (Problem)) > 0)
199
200 /*
201 * VOID
202 * IopInitDeviceTreeTraverseContext(
203 * PDEVICETREE_TRAVERSE_CONTEXT DeviceTreeTraverseContext,
204 * PDEVICE_NODE DeviceNode,
205 * DEVICETREE_TRAVERSE_ROUTINE Action,
206 * PVOID Context);
207 */
208 #define IopInitDeviceTreeTraverseContext( \
209 _DeviceTreeTraverseContext, _DeviceNode, _Action, \
210 _Context) { \
211 (_DeviceTreeTraverseContext)->FirstDeviceNode = \
212 (_DeviceNode); \
213 (_DeviceTreeTraverseContext)->Action = (_Action); \
214 (_DeviceTreeTraverseContext)->Context = (_Context); }
215
216 /*
217 * BOOLEAN
218 * IopIsValidPhysicalDeviceObject(
219 * IN PDEVICE_OBJECT PhysicalDeviceObject);
220 */
221 #define IopIsValidPhysicalDeviceObject(PhysicalDeviceObject) \
222 (((PEXTENDED_DEVOBJ_EXTENSION)PhysicalDeviceObject) && \
223 (((PEXTENDED_DEVOBJ_EXTENSION)PhysicalDeviceObject->DeviceObjectExtension)->DeviceNode) && \
224 (((PEXTENDED_DEVOBJ_EXTENSION)PhysicalDeviceObject->DeviceObjectExtension)->DeviceNode->Flags & DNF_ENUMERATED))
225
226 //
227 // Device List Operations
228 //
229 typedef enum _IOP_DEVICE_LIST_OPERATION
230 {
231 IopRemove,
232 IopAdd
233 } IOP_DEVICE_LIST_OPERATION, *PIOP_DEVICE_LIST_OPERATION;
234
235 //
236 // Transfer statistics
237 //
238 typedef enum _IOP_TRANSFER_TYPE
239 {
240 IopReadTransfer,
241 IopWriteTransfer,
242 IopOtherTransfer
243 } IOP_TRANSFER_TYPE, *PIOP_TRANSFER_TYPE;
244
245 //
246 // Packet Types when piggybacking on the IRP Overlay
247 //
248 typedef enum _COMPLETION_PACKET_TYPE
249 {
250 IopCompletionPacketIrp,
251 IopCompletionPacketMini,
252 IopCompletionPacketQuota
253 } COMPLETION_PACKET_TYPE, *PCOMPLETION_PACKET_TYPE;
254
255 //
256 // Special version of the IRP Overlay used to optimize I/O completion
257 // by not using up a separate structure.
258 //
259 typedef struct _IOP_MINI_COMPLETION_PACKET
260 {
261 struct
262 {
263 LIST_ENTRY ListEntry;
264 union
265 {
266 struct _IO_STACK_LOCATION *CurrentStackLocation;
267 ULONG PacketType;
268 };
269 };
270 PVOID KeyContext;
271 PVOID ApcContext;
272 NTSTATUS IoStatus;
273 ULONG_PTR IoStatusInformation;
274 } IOP_MINI_COMPLETION_PACKET, *PIOP_MINI_COMPLETION_PACKET;
275
276 //
277 // I/O Completion Context for IoSetIoCompletionRoutineEx
278 //
279 typedef struct _IO_UNLOAD_SAFE_COMPLETION_CONTEXT
280 {
281 PDEVICE_OBJECT DeviceObject;
282 PVOID Context;
283 PIO_COMPLETION_ROUTINE CompletionRoutine;
284 } IO_UNLOAD_SAFE_COMPLETION_CONTEXT, *PIO_UNLOAD_SAFE_COMPLETION_CONTEXT;
285
286 //
287 // I/O Wrapper around the Executive Work Item
288 //
289 typedef struct _IO_WORKITEM
290 {
291 WORK_QUEUE_ITEM Item;
292 PDEVICE_OBJECT DeviceObject;
293 PIO_WORKITEM_ROUTINE WorkerRoutine;
294 PVOID Context;
295 } IO_WORKITEM;
296
297 //
298 // I/O Wrapper around the Kernel Interrupt
299 //
300 typedef struct _IO_INTERRUPT
301 {
302 KINTERRUPT FirstInterrupt;
303 PKINTERRUPT Interrupt[MAXIMUM_PROCESSORS];
304 KSPIN_LOCK SpinLock;
305 } IO_INTERRUPT, *PIO_INTERRUPT;
306
307 //
308 // I/O Error Log Packet Header
309 //
310 typedef struct _ERROR_LOG_ENTRY
311 {
312 CSHORT Type;
313 CSHORT Size;
314 LIST_ENTRY ListEntry;
315 PDEVICE_OBJECT DeviceObject;
316 PDRIVER_OBJECT DriverObject;
317 LARGE_INTEGER TimeStamp;
318 } ERROR_LOG_ENTRY, *PERROR_LOG_ENTRY;
319
320 //
321 // Event Log LPC Message
322 //
323 typedef struct _ELF_API_MSG
324 {
325 PORT_MESSAGE h;
326 ULONG Unknown[2];
327 IO_ERROR_LOG_MESSAGE IoErrorMessage;
328 } ELF_API_MSG, *PELF_API_MSG;
329
330 //
331 // To simplify matters, the kernel is made to support both the checked and free
332 // version of the I/O Remove Lock in the same binary. This structure includes
333 // both, since the DDK has the structure with a compile-time #ifdef.
334 //
335 typedef struct _EXTENDED_IO_REMOVE_LOCK
336 {
337 IO_REMOVE_LOCK_COMMON_BLOCK Common;
338 IO_REMOVE_LOCK_DBG_BLOCK Dbg;
339 } EXTENDED_IO_REMOVE_LOCK, *PEXTENDED_IO_REMOVE_LOCK;
340
341 //
342 // Dummy File Object used inside the Open Packet so that OB knows how to
343 // deal with the Object Pointer even though it's not a real file.
344 //
345 typedef struct _DUMMY_FILE_OBJECT
346 {
347 OBJECT_HEADER ObjectHeader;
348 CHAR FileObjectBody[sizeof(FILE_OBJECT)];
349 } DUMMY_FILE_OBJECT, *PDUMMY_FILE_OBJECT;
350
351 //
352 // Open packet used as a context for Device/File parsing so that the parse
353 // routine can know what operation is being requested.
354 //
355 typedef struct _OPEN_PACKET
356 {
357 CSHORT Type;
358 CSHORT Size;
359 PFILE_OBJECT FileObject;
360 NTSTATUS FinalStatus;
361 ULONG_PTR Information;
362 ULONG ParseCheck;
363 PFILE_OBJECT RelatedFileObject;
364 OBJECT_ATTRIBUTES OriginalAttributes;
365 LARGE_INTEGER AllocationSize;
366 ULONG CreateOptions;
367 USHORT FileAttributes;
368 USHORT ShareAccess;
369 PVOID EaBuffer;
370 ULONG EaLength;
371 ULONG Options;
372 ULONG Disposition;
373 PFILE_BASIC_INFORMATION BasicInformation;
374 PFILE_NETWORK_OPEN_INFORMATION NetworkInformation;
375 CREATE_FILE_TYPE CreateFileType;
376 PVOID ExtraCreateParameters;
377 BOOLEAN Override;
378 BOOLEAN QueryOnly;
379 BOOLEAN DeleteOnly;
380 BOOLEAN FullAttributes;
381 PDUMMY_FILE_OBJECT LocalFileObject;
382 BOOLEAN TraversedMountPoint;
383 ULONG InternalFlags;
384 PDEVICE_OBJECT TopDeviceObjectHint;
385 } OPEN_PACKET, *POPEN_PACKET;
386
387 //
388 // Parameters packet for Load/Unload work item's context
389 //
390 typedef struct _LOAD_UNLOAD_PARAMS
391 {
392 NTSTATUS Status;
393 PCUNICODE_STRING RegistryPath;
394 WORK_QUEUE_ITEM WorkItem;
395 KEVENT Event;
396 PDRIVER_OBJECT DriverObject;
397 } LOAD_UNLOAD_PARAMS, *PLOAD_UNLOAD_PARAMS;
398
399 //
400 // Boot Driver List Entry
401 //
402 typedef struct _DRIVER_INFORMATION
403 {
404 LIST_ENTRY Link;
405 PDRIVER_OBJECT DriverObject;
406 PBOOT_DRIVER_LIST_ENTRY DataTableEntry;
407 HANDLE ServiceHandle;
408 USHORT TagPosition;
409 ULONG Failed;
410 ULONG Processed;
411 NTSTATUS Status;
412 } DRIVER_INFORMATION, *PDRIVER_INFORMATION;
413
414 //
415 // Boot Driver Node
416 //
417 typedef struct _BOOT_DRIVER_NODE
418 {
419 BOOT_DRIVER_LIST_ENTRY ListEntry;
420 UNICODE_STRING Group;
421 UNICODE_STRING Name;
422 ULONG Tag;
423 ULONG ErrorControl;
424 } BOOT_DRIVER_NODE, *PBOOT_DRIVER_NODE;
425
426 //
427 // List of Bus Type GUIDs
428 //
429 typedef struct _IO_BUS_TYPE_GUID_LIST
430 {
431 ULONG GuidCount;
432 FAST_MUTEX Lock;
433 GUID Guids[1];
434 } IO_BUS_TYPE_GUID_LIST, *PIO_BUS_TYPE_GUID_LIST;
435 extern PIO_BUS_TYPE_GUID_LIST IopBusTypeGuidList;
436
437 //
438 // Shutdown entry for registed devices
439 //
440 typedef struct _SHUTDOWN_ENTRY
441 {
442 LIST_ENTRY ShutdownList;
443 PDEVICE_OBJECT DeviceObject;
444 } SHUTDOWN_ENTRY, *PSHUTDOWN_ENTRY;
445
446 //
447 // F/S Notification entry for registered File Systems
448 //
449 typedef struct _FS_CHANGE_NOTIFY_ENTRY
450 {
451 LIST_ENTRY FsChangeNotifyList;
452 PDRIVER_OBJECT DriverObject;
453 PDRIVER_FS_NOTIFICATION FSDNotificationProc;
454 } FS_CHANGE_NOTIFY_ENTRY, *PFS_CHANGE_NOTIFY_ENTRY;
455
456 //
457 // Driver (Boot) Re-Initialization Entry
458 //
459 typedef struct _DRIVER_REINIT_ITEM
460 {
461 LIST_ENTRY ItemEntry;
462 PDRIVER_OBJECT DriverObject;
463 PDRIVER_REINITIALIZE ReinitRoutine;
464 PVOID Context;
465 } DRIVER_REINIT_ITEM, *PDRIVER_REINIT_ITEM;
466
467 //
468 // Called on every visit of a node during a preorder-traversal of the device
469 // node tree.
470 // If the routine returns STATUS_UNSUCCESSFUL the traversal will stop and
471 // STATUS_SUCCESS is returned to the caller who initiated the tree traversal.
472 // Any other returned status code will be returned to the caller. If a status
473 // code that indicates an error (other than STATUS_UNSUCCESSFUL) is returned,
474 // the traversal is stopped immediately and the status code is returned to
475 // the caller.
476 //
477 typedef
478 NTSTATUS
479 (*DEVICETREE_TRAVERSE_ROUTINE)(
480 IN PDEVICE_NODE DeviceNode,
481 IN PVOID Context
482 );
483
484 //
485 // Context information for traversing the device tree
486 //
487 typedef struct _DEVICETREE_TRAVERSE_CONTEXT
488 {
489 //
490 // Current device node during a traversal
491 //
492 PDEVICE_NODE DeviceNode;
493
494 //
495 // Initial device node where we start the traversal
496 //
497 PDEVICE_NODE FirstDeviceNode;
498
499 //
500 // Action routine to be called for every device node
501 //
502 DEVICETREE_TRAVERSE_ROUTINE Action;
503
504 //
505 // Context passed to the action routine
506 //
507 PVOID Context;
508 } DEVICETREE_TRAVERSE_CONTEXT, *PDEVICETREE_TRAVERSE_CONTEXT;
509
510 //
511 // Resource code
512 //
513 ULONG
514 NTAPI
515 PnpDetermineResourceListSize(IN PCM_RESOURCE_LIST ResourceList);
516
517 NTSTATUS
518 NTAPI
519 IopAssignDeviceResources(
520 IN PDEVICE_NODE DeviceNode
521 );
522
523 NTSTATUS
524 NTAPI
525 IopFixupResourceListWithRequirements(
526 IN PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList,
527 OUT PCM_RESOURCE_LIST *ResourceList
528 );
529
530 NTSTATUS
531 NTAPI
532 IopDetectResourceConflict(
533 IN PCM_RESOURCE_LIST ResourceList,
534 IN BOOLEAN Silent,
535 OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor
536 );
537
538 //
539 // PNP Routines
540 //
541 NTSTATUS
542 NTAPI
543 PipCallDriverAddDevice(
544 IN PDEVICE_NODE DeviceNode,
545 IN BOOLEAN LoadDriver,
546 IN PDRIVER_OBJECT DriverObject
547 );
548
549 NTSTATUS
550 NTAPI
551 IopInitializePlugPlayServices(
552 VOID
553 );
554
555 BOOLEAN
556 NTAPI
557 PpInitSystem(
558 VOID
559 );
560
561 VOID
562 PnpInit2(
563 VOID
564 );
565
566 VOID
567 IopInitDriverImplementation(
568 VOID
569 );
570
571 VOID
572 IopInitPnpNotificationImplementation(
573 VOID
574 );
575
576 VOID
577 IopNotifyPlugPlayNotification(
578 IN PDEVICE_OBJECT DeviceObject,
579 IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory,
580 IN LPCGUID Event,
581 IN PVOID EventCategoryData1,
582 IN PVOID EventCategoryData2
583 );
584
585 NTSTATUS
586 IopGetSystemPowerDeviceObject(
587 IN PDEVICE_OBJECT *DeviceObject
588 );
589
590 PDEVICE_NODE
591 NTAPI
592 PipAllocateDeviceNode(
593 IN PDEVICE_OBJECT PhysicalDeviceObject
594 );
595
596 NTSTATUS
597 IopCreateDeviceNode(
598 IN PDEVICE_NODE ParentNode,
599 IN PDEVICE_OBJECT PhysicalDeviceObject,
600 IN PUNICODE_STRING ServiceName,
601 OUT PDEVICE_NODE *DeviceNode
602 );
603
604 NTSTATUS
605 IopFreeDeviceNode(
606 IN PDEVICE_NODE DeviceNode
607 );
608
609 NTSTATUS
610 NTAPI
611 IopQueryDeviceCapabilities(PDEVICE_NODE DeviceNode,
612 PDEVICE_CAPABILITIES DeviceCaps);
613
614 NTSTATUS
615 NTAPI
616 IopSynchronousCall(
617 IN PDEVICE_OBJECT DeviceObject,
618 IN PIO_STACK_LOCATION IoStackLocation,
619 OUT PVOID *Information
620 );
621
622 NTSTATUS
623 NTAPI
624 IopInitiatePnpIrp(
625 IN PDEVICE_OBJECT DeviceObject,
626 IN PIO_STATUS_BLOCK IoStatusBlock,
627 IN UCHAR MinorFunction,
628 IN PIO_STACK_LOCATION Stack
629 );
630
631 PDEVICE_NODE
632 FASTCALL
633 IopGetDeviceNode(
634 IN PDEVICE_OBJECT DeviceObject
635 );
636
637 NTSTATUS
638 IopActionConfigureChildServices(
639 IN PDEVICE_NODE DeviceNode,
640 IN PVOID Context
641 );
642
643 NTSTATUS
644 IopActionInitChildServices(
645 IN PDEVICE_NODE DeviceNode,
646 IN PVOID Context
647 );
648
649 NTSTATUS
650 IopEnumerateDevice(
651 IN PDEVICE_OBJECT DeviceObject
652 );
653
654 NTSTATUS
655 IoCreateDriverList(
656 VOID
657 );
658
659 NTSTATUS
660 IoDestroyDriverList(
661 VOID
662 );
663
664 NTSTATUS
665 INIT_FUNCTION
666 IopInitPlugPlayEvents(VOID);
667
668 NTSTATUS
669 IopQueueTargetDeviceEvent(
670 const GUID *Guid,
671 PUNICODE_STRING DeviceIds
672 );
673
674 NTSTATUS
675 IopInitializePnpServices(
676 IN PDEVICE_NODE DeviceNode);
677
678 NTSTATUS
679 NTAPI
680 IopOpenRegistryKeyEx(
681 PHANDLE KeyHandle,
682 HANDLE ParentKey,
683 PUNICODE_STRING Name,
684 ACCESS_MASK DesiredAccess);
685
686 NTSTATUS
687 NTAPI
688 IopGetRegistryValue(
689 IN HANDLE Handle,
690 IN PWSTR ValueName,
691 OUT PKEY_VALUE_FULL_INFORMATION *Information
692 );
693
694 NTSTATUS
695 NTAPI
696 IopCreateRegistryKeyEx(
697 OUT PHANDLE Handle,
698 IN HANDLE BaseHandle OPTIONAL,
699 IN PUNICODE_STRING KeyName,
700 IN ACCESS_MASK DesiredAccess,
701 IN ULONG CreateOptions,
702 OUT PULONG Disposition OPTIONAL
703 );
704
705
706 NTSTATUS
707 IopTraverseDeviceTree(
708 PDEVICETREE_TRAVERSE_CONTEXT Context);
709
710 //
711 // PnP Routines
712 //
713 NTSTATUS
714 NTAPI
715 IopUpdateRootKey(
716 VOID
717 );
718
719 NTSTATUS
720 NTAPI
721 PiInitCacheGroupInformation(
722 VOID
723 );
724
725 USHORT
726 NTAPI
727 PpInitGetGroupOrderIndex(
728 IN HANDLE ServiceHandle
729 );
730
731 USHORT
732 NTAPI
733 PipGetDriverTagPriority(
734 IN HANDLE ServiceHandle
735 );
736
737 NTSTATUS
738 NTAPI
739 PnpRegMultiSzToUnicodeStrings(
740 IN PKEY_VALUE_FULL_INFORMATION KeyValueInformation,
741 OUT PUNICODE_STRING *UnicodeStringList,
742 OUT PULONG UnicodeStringCount
743 );
744
745 BOOLEAN
746 NTAPI
747 PnpRegSzToString(
748 IN PWCHAR RegSzData,
749 IN ULONG RegSzLength,
750 OUT PUSHORT StringLength OPTIONAL
751 );
752
753 //
754 // Initialization Routines
755 //
756 NTSTATUS
757 NTAPI
758 IopCreateArcNames(
759 IN PLOADER_PARAMETER_BLOCK LoaderBlock
760 );
761
762 NTSTATUS
763 NTAPI
764 IopReassignSystemRoot(
765 IN PLOADER_PARAMETER_BLOCK LoaderBlock,
766 OUT PANSI_STRING NtBootPath
767 );
768
769 BOOLEAN
770 NTAPI
771 IoInitSystem(
772 IN PLOADER_PARAMETER_BLOCK LoaderBlock
773 );
774
775 BOOLEAN
776 NTAPI
777 IopVerifyDiskSignature(
778 IN PDRIVE_LAYOUT_INFORMATION_EX DriveLayout,
779 IN PARC_DISK_SIGNATURE ArcDiskSignature,
780 OUT PULONG Signature
781 );
782
783 //
784 // Device/Volume Routines
785 //
786 VOID
787 NTAPI
788 IopReadyDeviceObjects(
789 IN PDRIVER_OBJECT Driver
790 );
791
792 NTSTATUS
793 FASTCALL
794 IopInitializeDevice(
795 IN PDEVICE_NODE DeviceNode,
796 IN PDRIVER_OBJECT DriverObject
797 );
798
799 NTSTATUS
800 IopStartDevice(
801 IN PDEVICE_NODE DeviceNode
802 );
803
804 NTSTATUS
805 IopStopDevice(
806 IN PDEVICE_NODE DeviceNode
807 );
808
809 NTSTATUS
810 IopRemoveDevice(
811 IN PDEVICE_NODE DeviceNode
812 );
813
814 PVPB
815 NTAPI
816 IopCheckVpbMounted(
817 IN POPEN_PACKET OpenPacket,
818 IN PDEVICE_OBJECT DeviceObject,
819 IN PUNICODE_STRING RemainingName,
820 OUT PNTSTATUS Status
821 );
822
823 NTSTATUS
824 NTAPI
825 IopMountVolume(
826 IN PDEVICE_OBJECT DeviceObject,
827 IN BOOLEAN AllowRawMount,
828 IN BOOLEAN DeviceIsLocked,
829 IN BOOLEAN Alertable,
830 OUT PVPB *Vpb
831 );
832
833 PVOID
834 IoOpenSymlink(
835 IN PVOID SymbolicLink
836 );
837
838 PVOID
839 IoOpenFileOnDevice(
840 IN PVOID SymbolicLink,
841 IN PWCHAR Name
842 );
843
844 NTSTATUS
845 NTAPI
846 IopCreateVpb(
847 IN PDEVICE_OBJECT DeviceObject
848 );
849
850 VOID
851 NTAPI
852 IopDereferenceVpbAndFree(
853 IN PVPB Vpb
854 );
855
856 VOID
857 NTAPI
858 IoInitFileSystemImplementation(
859 VOID
860 );
861
862 VOID
863 NTAPI
864 IoInitVpbImplementation(
865 VOID
866 );
867
868 NTSTATUS
869 NTAPI
870 IopReferenceDeviceObject(
871 IN PDEVICE_OBJECT DeviceObject
872 );
873
874 VOID
875 NTAPI
876 IopDereferenceDeviceObject(
877 IN PDEVICE_OBJECT DeviceObject,
878 IN BOOLEAN ForceUnload
879 );
880
881 NTSTATUS
882 NTAPI
883 IoGetRelatedTargetDevice(
884 IN PFILE_OBJECT FileObject,
885 OUT PDEVICE_OBJECT *DeviceObject
886 );
887
888 VOID
889 NTAPI
890 IopUnloadDevice(
891 IN PDEVICE_OBJECT DeviceObject
892 );
893
894 //
895 // IRP Routines
896 //
897 NTSTATUS
898 NTAPI
899 IopCleanupFailedIrp(
900 IN PFILE_OBJECT FileObject,
901 IN PKEVENT EventObject,
902 IN PVOID Buffer OPTIONAL
903 );
904
905 VOID
906 NTAPI
907 IopAbortInterruptedIrp(
908 IN PKEVENT EventObject,
909 IN PIRP Irp
910 );
911
912 PIRP
913 NTAPI
914 IopAllocateIrpMustSucceed(
915 IN CCHAR StackSize
916 );
917
918 //
919 // Shutdown routines
920 //
921 VOID
922 IoInitShutdownNotification(
923 VOID
924 );
925
926 VOID
927 NTAPI
928 IoShutdownSystem(
929 IN ULONG Phase
930 );
931
932 VOID
933 NTAPI
934 IopShutdownBaseFileSystems(
935 IN PLIST_ENTRY ListHead
936 );
937
938 //
939 // Boot logging support
940 //
941 VOID
942 IopInitBootLog(
943 IN BOOLEAN StartBootLog
944 );
945
946 VOID
947 IopStartBootLog(
948 VOID
949 );
950
951 VOID
952 IopStopBootLog(
953 VOID
954 );
955
956 VOID
957 IopBootLog(
958 IN PUNICODE_STRING DriverName,
959 IN BOOLEAN Success
960 );
961
962 VOID
963 IopSaveBootLogToFile(
964 VOID
965 );
966
967 //
968 // I/O Cancellation Routines
969 //
970 VOID
971 NTAPI
972 IoCancelThreadIo(
973 IN PETHREAD Thread
974 );
975
976 VOID
977 IoInitCancelHandling(
978 VOID
979 );
980
981 //
982 // I/O Completion
983 //
984 VOID
985 NTAPI
986 IopCompleteRequest(
987 IN PKAPC Apc,
988 IN PKNORMAL_ROUTINE* NormalRoutine,
989 IN PVOID* NormalContext,
990 IN PVOID* SystemArgument1,
991 IN PVOID* SystemArgument2
992 );
993
994 //
995 // Error Logging Routines
996 //
997 VOID
998 NTAPI
999 IopInitErrorLog(
1000 VOID
1001 );
1002
1003 VOID
1004 NTAPI
1005 IopLogWorker(
1006 IN PVOID Parameter
1007 );
1008
1009 //
1010 // Raw File System MiniDriver
1011 //
1012 BOOLEAN
1013 RawFsIsRawFileSystemDeviceObject(
1014 IN PDEVICE_OBJECT DeviceObject
1015 );
1016
1017 NTSTATUS
1018 NTAPI
1019 RawFsDriverEntry(
1020 IN PDRIVER_OBJECT DriverObject,
1021 IN PUNICODE_STRING RegistryPath
1022 );
1023
1024 //
1025 // PnP Root MiniDriver
1026 //
1027 NTSTATUS
1028 NTAPI
1029 PnpRootDriverEntry(
1030 IN PDRIVER_OBJECT DriverObject,
1031 IN PUNICODE_STRING RegistryPath
1032 );
1033
1034 NTSTATUS
1035 PnpRootCreateDevice(
1036 IN PUNICODE_STRING ServiceName,
1037 IN OPTIONAL PDRIVER_OBJECT DriverObject,
1038 OUT PDEVICE_OBJECT *PhysicalDeviceObject,
1039 OUT OPTIONAL PUNICODE_STRING FullInstancePath
1040 );
1041
1042 NTSTATUS
1043 PnpRootRegisterDevice(
1044 IN PDEVICE_OBJECT DeviceObject);
1045
1046 //
1047 // Driver Routines
1048 //
1049 VOID
1050 FASTCALL
1051 IopInitializeBootDrivers(
1052 VOID
1053 );
1054
1055 VOID
1056 FASTCALL
1057 IopInitializeSystemDrivers(
1058 VOID
1059 );
1060
1061 NTSTATUS
1062 NTAPI
1063 IopCreateDriver(IN PUNICODE_STRING DriverName OPTIONAL,
1064 IN PDRIVER_INITIALIZE InitializationFunction,
1065 IN PUNICODE_STRING RegistryPath,
1066 IN PCUNICODE_STRING ServiceName,
1067 PLDR_DATA_TABLE_ENTRY ModuleObject,
1068 OUT PDRIVER_OBJECT *pDriverObject);
1069
1070 VOID
1071 NTAPI
1072 IopDeleteDriver(
1073 IN PVOID ObjectBody
1074 );
1075
1076 NTSTATUS
1077 FASTCALL
1078 IopGetDriverObject(
1079 OUT PDRIVER_OBJECT *DriverObject,
1080 IN PUNICODE_STRING ServiceName,
1081 IN BOOLEAN FileSystem
1082 );
1083
1084 NTSTATUS
1085 FASTCALL
1086 IopLoadServiceModule(
1087 IN PUNICODE_STRING ServiceName,
1088 OUT PLDR_DATA_TABLE_ENTRY *ModuleObject
1089 );
1090
1091 NTSTATUS
1092 NTAPI
1093 IopLoadUnloadDriver(
1094 _In_opt_ PCUNICODE_STRING RegistryPath,
1095 _Inout_ PDRIVER_OBJECT *DriverObject
1096 );
1097
1098 NTSTATUS
1099 FASTCALL
1100 IopInitializeDriverModule(
1101 IN PDEVICE_NODE DeviceNode,
1102 IN PLDR_DATA_TABLE_ENTRY ModuleObject,
1103 IN PUNICODE_STRING ServiceName,
1104 IN BOOLEAN FileSystemDriver,
1105 OUT PDRIVER_OBJECT *DriverObject
1106 );
1107
1108 NTSTATUS
1109 FASTCALL
1110 IopAttachFilterDrivers(
1111 IN PDEVICE_NODE DeviceNode,
1112 IN BOOLEAN Lower
1113 );
1114
1115 VOID
1116 NTAPI
1117 IopReinitializeDrivers(
1118 VOID
1119 );
1120
1121 VOID
1122 NTAPI
1123 IopReinitializeBootDrivers(
1124 VOID
1125 );
1126
1127 //
1128 // File Routines
1129 //
1130 VOID
1131 NTAPI
1132 IopDeleteDevice(IN PVOID ObjectBody);
1133
1134 NTSTATUS
1135 NTAPI
1136 IopParseDevice(
1137 IN PVOID ParseObject,
1138 IN PVOID ObjectType,
1139 IN OUT PACCESS_STATE AccessState,
1140 IN KPROCESSOR_MODE AccessMode,
1141 IN ULONG Attributes,
1142 IN OUT PUNICODE_STRING CompleteName,
1143 IN OUT PUNICODE_STRING RemainingName,
1144 IN OUT PVOID Context,
1145 IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
1146 OUT PVOID *Object
1147 );
1148
1149 NTSTATUS
1150 NTAPI
1151 IopParseFile(
1152 IN PVOID ParseObject,
1153 IN PVOID ObjectType,
1154 IN OUT PACCESS_STATE AccessState,
1155 IN KPROCESSOR_MODE AccessMode,
1156 IN ULONG Attributes,
1157 IN OUT PUNICODE_STRING CompleteName,
1158 IN OUT PUNICODE_STRING RemainingName,
1159 IN OUT PVOID Context OPTIONAL,
1160 IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
1161 OUT PVOID *Object
1162 );
1163
1164 VOID
1165 NTAPI
1166 IopDeleteFile(
1167 IN PVOID ObjectBody
1168 );
1169
1170 NTSTATUS
1171 NTAPI
1172 IopGetSetSecurityObject(
1173 IN PVOID ObjectBody,
1174 IN SECURITY_OPERATION_CODE OperationCode,
1175 IN PSECURITY_INFORMATION SecurityInformation,
1176 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
1177 IN OUT PULONG BufferLength,
1178 OUT PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
1179 IN POOL_TYPE PoolType,
1180 IN OUT PGENERIC_MAPPING GenericMapping
1181 );
1182
1183 NTSTATUS
1184 NTAPI
1185 IopQueryNameFile(
1186 IN PVOID ObjectBody,
1187 IN BOOLEAN HasName,
1188 OUT POBJECT_NAME_INFORMATION ObjectNameInfo,
1189 IN ULONG Length,
1190 OUT PULONG ReturnLength,
1191 IN KPROCESSOR_MODE PreviousMode
1192 );
1193
1194 VOID
1195 NTAPI
1196 IopCloseFile(
1197 IN PEPROCESS Process OPTIONAL,
1198 IN PVOID Object,
1199 IN ACCESS_MASK GrantedAccess,
1200 IN ULONG ProcessHandleCount,
1201 IN ULONG SystemHandleCount
1202 );
1203
1204 PVOID
1205 NTAPI
1206 IoGetFileObjectFilterContext(
1207 IN PFILE_OBJECT FileObject
1208 );
1209
1210 NTSTATUS
1211 NTAPI
1212 IoChangeFileObjectFilterContext(
1213 IN PFILE_OBJECT FileObject,
1214 IN PVOID FilterContext,
1215 IN BOOLEAN Define
1216 );
1217
1218 VOID
1219 NTAPI
1220 IopDoNameTransmogrify(
1221 IN PIRP Irp,
1222 IN PFILE_OBJECT FileObject,
1223 IN PREPARSE_DATA_BUFFER DataBuffer
1224 );
1225
1226 //
1227 // I/O Timer Routines
1228 //
1229 VOID
1230 FASTCALL
1231 IopInitTimerImplementation(
1232 VOID
1233 );
1234
1235 VOID
1236 NTAPI
1237 IopRemoveTimerFromTimerList(
1238 IN PIO_TIMER Timer
1239 );
1240
1241 //
1242 // I/O Completion Routines
1243 //
1244 VOID
1245 NTAPI
1246 IopDeleteIoCompletion(
1247 PVOID ObjectBody
1248 );
1249
1250 //
1251 // Ramdisk Routines
1252 //
1253 NTSTATUS
1254 NTAPI
1255 IopStartRamdisk(
1256 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1257 );
1258
1259 //
1260 // Configuration Routines
1261 //
1262 NTSTATUS
1263 NTAPI
1264 IopFetchConfigurationInformation(OUT PWSTR * SymbolicLinkList,
1265 IN GUID Guid,
1266 IN ULONG ExpectedInterfaces,
1267 IN PULONG Interfaces
1268 );
1269
1270 VOID
1271 NTAPI
1272 IopStoreSystemPartitionInformation(IN PUNICODE_STRING NtSystemPartitionDeviceName,
1273 IN PUNICODE_STRING OsLoaderPathName
1274 );
1275
1276 //
1277 // Global I/O Data
1278 //
1279 extern POBJECT_TYPE IoCompletionType;
1280 extern PDEVICE_NODE IopRootDeviceNode;
1281 extern KSPIN_LOCK IopDeviceTreeLock;
1282 extern ULONG IopTraceLevel;
1283 extern GENERAL_LOOKASIDE IopMdlLookasideList;
1284 extern GENERIC_MAPPING IopCompletionMapping;
1285 extern GENERIC_MAPPING IopFileMapping;
1286 extern POBJECT_TYPE _IoFileObjectType;
1287 extern HAL_DISPATCH _HalDispatchTable;
1288 extern LIST_ENTRY IopErrorLogListHead;
1289 extern ULONG IopNumTriageDumpDataBlocks;
1290 extern PVOID IopTriageDumpDataBlocks[64];
1291 extern PIO_BUS_TYPE_GUID_LIST PnpBusTypeGuidList;
1292 extern PDRIVER_OBJECT IopRootDriverObject;
1293 extern KSPIN_LOCK IopDeviceRelationsSpinLock;
1294 extern LIST_ENTRY IopDeviceRelationsRequestList;
1295
1296 //
1297 // Inlined Functions
1298 //
1299 #include "io_x.h"