1faff6bfcea238fb9534bdd5c3427097ced464e4
[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_ 0x00
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, ...) DPRINT(__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 // We can call the Ob Inlined API, it's the same thing
85 //
86 #define IopAllocateMdlFromLookaside \
87 ObpAllocateObjectCreateInfoBuffer
88 #define IopFreeMdlFromLookaside \
89 ObpFreeCapturedAttributes
90
91 //
92 // Returns the size of a CM_RESOURCE_LIST
93 //
94 #define CM_RESOURCE_LIST_SIZE(ResList) \
95 (ResList->Count == 1) ? \
96 FIELD_OFFSET( \
97 CM_RESOURCE_LIST, \
98 List[0].PartialResourceList. \
99 PartialDescriptors[(ResList)-> \
100 List[0]. \
101 PartialResourceList. \
102 Count]) \
103 : \
104 FIELD_OFFSET(CM_RESOURCE_LIST, List)
105
106 //
107 // Determines if the IRP is Synchronous
108 //
109 #define IsIrpSynchronous(Irp, FileObject) \
110 ((Irp->Flags & IRP_SYNCHRONOUS_API) || \
111 (!(FileObject) ? \
112 FALSE : \
113 FileObject->Flags & FO_SYNCHRONOUS_IO)) \
114
115 //
116 // Returns the internal Device Object Extension
117 //
118 #define IoGetDevObjExtension(DeviceObject) \
119 ((PEXTENDED_DEVOBJ_EXTENSION) \
120 (DeviceObject->DeviceObjectExtension)) \
121
122 //
123 // Returns the internal Driver Object Extension
124 //
125 #define IoGetDrvObjExtension(DriverObject) \
126 ((PEXTENDED_DRIVER_EXTENSION) \
127 (DriverObject->DriverExtension)) \
128
129 /*
130 * VOID
131 * IopDeviceNodeSetFlag(
132 * PDEVICE_NODE DeviceNode,
133 * ULONG Flag);
134 */
135 #define IopDeviceNodeSetFlag(DeviceNode, Flag) \
136 ((DeviceNode)->Flags |= (Flag))
137
138 /*
139 * VOID
140 * IopDeviceNodeClearFlag(
141 * PDEVICE_NODE DeviceNode,
142 * ULONG Flag);
143 */
144 #define IopDeviceNodeClearFlag(DeviceNode, Flag) \
145 ((DeviceNode)->Flags &= ~(Flag))
146
147 /*
148 * BOOLEAN
149 * IopDeviceNodeHasFlag(
150 * PDEVICE_NODE DeviceNode,
151 * ULONG Flag);
152 */
153 #define IopDeviceNodeHasFlag(DeviceNode, Flag) \
154 (((DeviceNode)->Flags & (Flag)) > 0)
155
156 /*
157 * VOID
158 * IopDeviceNodeSetUserFlag(
159 * PDEVICE_NODE DeviceNode,
160 * ULONG UserFlag);
161 */
162 #define IopDeviceNodeSetUserFlag(DeviceNode, UserFlag) \
163 ((DeviceNode)->UserFlags |= (UserFlag))
164
165 /*
166 * VOID
167 * IopDeviceNodeClearUserFlag(
168 * PDEVICE_NODE DeviceNode,
169 * ULONG UserFlag);
170 */
171 #define IopDeviceNodeClearUserFlag(DeviceNode, UserFlag)\
172 ((DeviceNode)->UserFlags &= ~(UserFlag))
173
174 /*
175 * BOOLEAN
176 * IopDeviceNodeHasUserFlag(
177 * PDEVICE_NODE DeviceNode,
178 * ULONG UserFlag);
179 */
180 #define IopDeviceNodeHasUserFlag(DeviceNode, UserFlag) \
181 (((DeviceNode)->UserFlags & (UserFlag)) > 0)
182
183 /*
184 * VOID
185 * IopDeviceNodeSetProblem(
186 * PDEVICE_NODE DeviceNode,
187 * ULONG Problem);
188 */
189 #define IopDeviceNodeSetProblem(DeviceNode, Problem) \
190 ((DeviceNode)->Problem |= (Problem))
191
192 /*
193 * VOID
194 * IopDeviceNodeClearProblem(
195 * PDEVICE_NODE DeviceNode,
196 * ULONG Problem);
197 */
198 #define IopDeviceNodeClearProblem(DeviceNode, Problem) \
199 ((DeviceNode)->Problem &= ~(Problem))
200
201 /*
202 * BOOLEAN
203 * IopDeviceNodeHasProblem(
204 * PDEVICE_NODE DeviceNode,
205 * ULONG Problem);
206 */
207 #define IopDeviceNodeHasProblem(DeviceNode, Problem) \
208 (((DeviceNode)->Problem & (Problem)) > 0)
209
210 /*
211 * VOID
212 * IopInitDeviceTreeTraverseContext(
213 * PDEVICETREE_TRAVERSE_CONTEXT DeviceTreeTraverseContext,
214 * PDEVICE_NODE DeviceNode,
215 * DEVICETREE_TRAVERSE_ROUTINE Action,
216 * PVOID Context);
217 */
218 #define IopInitDeviceTreeTraverseContext( \
219 _DeviceTreeTraverseContext, _DeviceNode, _Action, \
220 _Context) { \
221 (_DeviceTreeTraverseContext)->FirstDeviceNode = \
222 (_DeviceNode); \
223 (_DeviceTreeTraverseContext)->Action = (_Action); \
224 (_DeviceTreeTraverseContext)->Context = (_Context); }
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 MailslotOrPipeParameters;
377 BOOLEAN Override;
378 BOOLEAN QueryOnly;
379 BOOLEAN DeleteOnly;
380 BOOLEAN FullAttributes;
381 PDUMMY_FILE_OBJECT DummyFileObject;
382 ULONG InternalFlags;
383 //PIO_DRIVER_CREATE_CONTEXT DriverCreateContext; Vista only, needs ROS DDK Update
384 } OPEN_PACKET, *POPEN_PACKET;
385
386 //
387 // Parameters packet for Load/Unload work item's context
388 //
389 typedef struct _LOAD_UNLOAD_PARAMS
390 {
391 NTSTATUS Status;
392 PUNICODE_STRING ServiceName;
393 WORK_QUEUE_ITEM WorkItem;
394 KEVENT Event;
395 PDRIVER_OBJECT DriverObject;
396 } LOAD_UNLOAD_PARAMS, *PLOAD_UNLOAD_PARAMS;
397
398 //
399 // Boot Driver List Entry
400 //
401 typedef struct _DRIVER_INFORMATION
402 {
403 LIST_ENTRY Link;
404 PDRIVER_OBJECT DriverObject;
405 PBOOT_DRIVER_LIST_ENTRY DataTableEntry;
406 HANDLE ServiceHandle;
407 USHORT TagPosition;
408 ULONG Failed;
409 ULONG Processed;
410 NTSTATUS Status;
411 } DRIVER_INFORMATION, *PDRIVER_INFORMATION;
412
413 //
414 // Boot Driver Node
415 //
416 typedef struct _BOOT_DRIVER_NODE
417 {
418 BOOT_DRIVER_LIST_ENTRY ListEntry;
419 UNICODE_STRING Group;
420 UNICODE_STRING Name;
421 ULONG Tag;
422 ULONG ErrorControl;
423 } BOOT_DRIVER_NODE, *PBOOT_DRIVER_NODE;
424
425 //
426 // List of Bus Type GUIDs
427 //
428 typedef struct _IO_BUS_TYPE_GUID_LIST
429 {
430 ULONG GuidCount;
431 FAST_MUTEX Lock;
432 GUID Guids[1];
433 } IO_BUS_TYPE_GUID_LIST, *PIO_BUS_TYPE_GUID_LIST;
434 extern PIO_BUS_TYPE_GUID_LIST IopBusTypeGuidList;
435
436 //
437 // Shutdown entry for registed devices
438 //
439 typedef struct _SHUTDOWN_ENTRY
440 {
441 LIST_ENTRY ShutdownList;
442 PDEVICE_OBJECT DeviceObject;
443 } SHUTDOWN_ENTRY, *PSHUTDOWN_ENTRY;
444
445 //
446 // F/S Notification entry for registered File Systems
447 //
448 typedef struct _FS_CHANGE_NOTIFY_ENTRY
449 {
450 LIST_ENTRY FsChangeNotifyList;
451 PDRIVER_OBJECT DriverObject;
452 PDRIVER_FS_NOTIFICATION FSDNotificationProc;
453 } FS_CHANGE_NOTIFY_ENTRY, *PFS_CHANGE_NOTIFY_ENTRY;
454
455 //
456 // Driver (Boot) Re-Initialization Entry
457 //
458 typedef struct _DRIVER_REINIT_ITEM
459 {
460 LIST_ENTRY ItemEntry;
461 PDRIVER_OBJECT DriverObject;
462 PDRIVER_REINITIALIZE ReinitRoutine;
463 PVOID Context;
464 } DRIVER_REINIT_ITEM, *PDRIVER_REINIT_ITEM;
465
466 //
467 // Called on every visit of a node during a preorder-traversal of the device
468 // node tree.
469 // If the routine returns STATUS_UNSUCCESSFUL the traversal will stop and
470 // STATUS_SUCCESS is returned to the caller who initiated the tree traversal.
471 // Any other returned status code will be returned to the caller. If a status
472 // code that indicates an error (other than STATUS_UNSUCCESSFUL) is returned,
473 // the traversal is stopped immediately and the status code is returned to
474 // the caller.
475 //
476 typedef
477 NTSTATUS
478 (*DEVICETREE_TRAVERSE_ROUTINE)(
479 IN PDEVICE_NODE DeviceNode,
480 IN PVOID Context
481 );
482
483 //
484 // Context information for traversing the device tree
485 //
486 typedef struct _DEVICETREE_TRAVERSE_CONTEXT
487 {
488 //
489 // Current device node during a traversal
490 //
491 PDEVICE_NODE DeviceNode;
492
493 //
494 // Initial device node where we start the traversal
495 //
496 PDEVICE_NODE FirstDeviceNode;
497
498 //
499 // Action routine to be called for every device node
500 //
501 DEVICETREE_TRAVERSE_ROUTINE Action;
502
503 //
504 // Context passed to the action routine
505 //
506 PVOID Context;
507 } DEVICETREE_TRAVERSE_CONTEXT, *PDEVICETREE_TRAVERSE_CONTEXT;
508
509 //
510 // PNP Routines
511 //
512 NTSTATUS
513 NTAPI
514 PipCallDriverAddDevice(
515 IN PDEVICE_NODE DeviceNode,
516 IN BOOLEAN LoadDriver,
517 IN PDRIVER_OBJECT DriverObject
518 );
519
520 NTSTATUS
521 NTAPI
522 IopInitializePlugPlayServices(
523 VOID
524 );
525
526 BOOLEAN
527 NTAPI
528 PpInitSystem(
529 VOID
530 );
531
532 VOID
533 PnpInit2(
534 VOID
535 );
536
537 VOID
538 IopInitDriverImplementation(
539 VOID
540 );
541
542 VOID
543 IopInitPnpNotificationImplementation(
544 VOID
545 );
546
547 VOID
548 IopNotifyPlugPlayNotification(
549 IN PDEVICE_OBJECT DeviceObject,
550 IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory,
551 IN LPCGUID Event,
552 IN PVOID EventCategoryData1,
553 IN PVOID EventCategoryData2
554 );
555
556 NTSTATUS
557 IopGetSystemPowerDeviceObject(
558 IN PDEVICE_OBJECT *DeviceObject
559 );
560
561 PDEVICE_NODE
562 NTAPI
563 PipAllocateDeviceNode(
564 IN PDEVICE_OBJECT PhysicalDeviceObject
565 );
566
567 NTSTATUS
568 IopCreateDeviceNode(
569 IN PDEVICE_NODE ParentNode,
570 IN PDEVICE_OBJECT PhysicalDeviceObject,
571 IN PUNICODE_STRING ServiceName,
572 OUT PDEVICE_NODE *DeviceNode
573 );
574
575 NTSTATUS
576 IopFreeDeviceNode(
577 IN PDEVICE_NODE DeviceNode
578 );
579
580 NTSTATUS
581 NTAPI
582 IopSynchronousCall(
583 IN PDEVICE_OBJECT DeviceObject,
584 IN PIO_STACK_LOCATION IoStackLocation,
585 OUT PVOID *Information
586 );
587
588 NTSTATUS
589 NTAPI
590 IopInitiatePnpIrp(
591 IN PDEVICE_OBJECT DeviceObject,
592 IN PIO_STATUS_BLOCK IoStatusBlock,
593 IN ULONG MinorFunction,
594 IN PIO_STACK_LOCATION Stack
595 );
596
597 PDEVICE_NODE
598 FASTCALL
599 IopGetDeviceNode(
600 IN PDEVICE_OBJECT DeviceObject
601 );
602
603 NTSTATUS
604 IopActionConfigureChildServices(
605 IN PDEVICE_NODE DeviceNode,
606 IN PVOID Context
607 );
608
609 NTSTATUS
610 IopActionInitChildServices(
611 IN PDEVICE_NODE DeviceNode,
612 IN PVOID Context
613 );
614
615 NTSTATUS
616 IopEnumerateDevice(
617 IN PDEVICE_OBJECT DeviceObject
618 );
619
620 NTSTATUS
621 IoCreateDriverList(
622 VOID
623 );
624
625 NTSTATUS
626 IoDestroyDriverList(
627 VOID
628 );
629
630 NTSTATUS
631 INIT_FUNCTION
632 IopInitPlugPlayEvents(VOID);
633
634 NTSTATUS
635 IopQueueTargetDeviceEvent(
636 const GUID *Guid,
637 PUNICODE_STRING DeviceIds
638 );
639
640 NTSTATUS
641 IopInitializePnpServices(
642 IN PDEVICE_NODE DeviceNode);
643
644 NTSTATUS
645 NTAPI
646 IopOpenRegistryKeyEx(
647 PHANDLE KeyHandle,
648 HANDLE ParentKey,
649 PUNICODE_STRING Name,
650 ACCESS_MASK DesiredAccess);
651
652 NTSTATUS
653 NTAPI
654 IopGetRegistryValue(
655 IN HANDLE Handle,
656 IN PWSTR ValueName,
657 OUT PKEY_VALUE_FULL_INFORMATION *Information
658 );
659
660 NTSTATUS
661 NTAPI
662 IopCreateRegistryKeyEx(
663 OUT PHANDLE Handle,
664 IN HANDLE BaseHandle OPTIONAL,
665 IN PUNICODE_STRING KeyName,
666 IN ACCESS_MASK DesiredAccess,
667 IN ULONG CreateOptions,
668 OUT PULONG Disposition OPTIONAL
669 );
670
671 //
672 // PnP Routines
673 //
674 NTSTATUS
675 NTAPI
676 IopUpdateRootKey(
677 VOID
678 );
679
680 NTSTATUS
681 NTAPI
682 PiInitCacheGroupInformation(
683 VOID
684 );
685
686 USHORT
687 NTAPI
688 PpInitGetGroupOrderIndex(
689 IN HANDLE ServiceHandle
690 );
691
692 USHORT
693 NTAPI
694 PipGetDriverTagPriority(
695 IN HANDLE ServiceHandle
696 );
697
698 NTSTATUS
699 NTAPI
700 PnpRegMultiSzToUnicodeStrings(
701 IN PKEY_VALUE_FULL_INFORMATION KeyValueInformation,
702 OUT PUNICODE_STRING *UnicodeStringList,
703 OUT PULONG UnicodeStringCount
704 );
705
706 BOOLEAN
707 NTAPI
708 PnpRegSzToString(
709 IN PWCHAR RegSzData,
710 IN ULONG RegSzLength,
711 OUT PUSHORT StringLength OPTIONAL
712 );
713
714 //
715 // Initialization Routines
716 //
717 NTSTATUS
718 NTAPI
719 IopCreateArcNames(
720 IN PLOADER_PARAMETER_BLOCK LoaderBlock
721 );
722
723 NTSTATUS
724 NTAPI
725 IopReassignSystemRoot(
726 IN PLOADER_PARAMETER_BLOCK LoaderBlock,
727 OUT PANSI_STRING NtBootPath
728 );
729
730 BOOLEAN
731 NTAPI
732 IoInitSystem(
733 IN PLOADER_PARAMETER_BLOCK LoaderBlock
734 );
735
736 //
737 // Device/Volume Routines
738 //
739 VOID
740 NTAPI
741 IopReadyDeviceObjects(
742 IN PDRIVER_OBJECT Driver
743 );
744
745 NTSTATUS
746 FASTCALL
747 IopInitializeDevice(
748 IN PDEVICE_NODE DeviceNode,
749 IN PDRIVER_OBJECT DriverObject
750 );
751
752 NTSTATUS
753 IopStartDevice(
754 IN PDEVICE_NODE DeviceNode
755 );
756
757 PVPB
758 NTAPI
759 IopCheckVpbMounted(
760 IN POPEN_PACKET OpenPacket,
761 IN PDEVICE_OBJECT DeviceObject,
762 IN PUNICODE_STRING RemainingName,
763 OUT PNTSTATUS Status
764 );
765
766 NTSTATUS
767 NTAPI
768 IopMountVolume(
769 IN PDEVICE_OBJECT DeviceObject,
770 IN BOOLEAN AllowRawMount,
771 IN BOOLEAN DeviceIsLocked,
772 IN BOOLEAN Alertable,
773 OUT PVPB *Vpb
774 );
775
776 PVOID
777 IoOpenSymlink(
778 IN PVOID SymbolicLink
779 );
780
781 PVOID
782 IoOpenFileOnDevice(
783 IN PVOID SymbolicLink,
784 IN PWCHAR Name
785 );
786
787 NTSTATUS
788 NTAPI
789 IopCreateVpb(
790 IN PDEVICE_OBJECT DeviceObject
791 );
792
793 VOID
794 NTAPI
795 IopDereferenceVpb(
796 IN PVPB Vpb
797 );
798
799 VOID
800 NTAPI
801 IoInitFileSystemImplementation(
802 VOID
803 );
804
805 VOID
806 NTAPI
807 IoInitVpbImplementation(
808 VOID
809 );
810
811 NTSTATUS
812 NTAPI
813 IopReferenceDeviceObject(
814 IN PDEVICE_OBJECT DeviceObject
815 );
816
817 VOID
818 NTAPI
819 IopDereferenceDeviceObject(
820 IN PDEVICE_OBJECT DeviceObject,
821 IN BOOLEAN ForceUnload
822 );
823
824 NTSTATUS
825 NTAPI
826 IoGetRelatedTargetDevice(IN PFILE_OBJECT FileObject,
827 OUT PDEVICE_OBJECT *DeviceObject
828 );
829
830 //
831 // IRP Routines
832 //
833 NTSTATUS
834 NTAPI
835 IopCleanupFailedIrp(
836 IN PFILE_OBJECT FileObject,
837 IN PKEVENT EventObject,
838 IN PVOID Buffer OPTIONAL
839 );
840
841 VOID
842 NTAPI
843 IopAbortInterruptedIrp(
844 IN PKEVENT EventObject,
845 IN PIRP Irp
846 );
847
848 //
849 // Shutdown routines
850 //
851 VOID
852 IoInitShutdownNotification(
853 VOID
854 );
855
856 VOID
857 NTAPI
858 IoShutdownSystem(
859 IN ULONG Phase
860 );
861
862 VOID
863 NTAPI
864 IopShutdownBaseFileSystems(
865 IN PLIST_ENTRY ListHead
866 );
867
868 //
869 // Boot logging support
870 //
871 VOID
872 IopInitBootLog(
873 IN BOOLEAN StartBootLog
874 );
875
876 VOID
877 IopStartBootLog(
878 VOID
879 );
880
881 VOID
882 IopStopBootLog(
883 VOID
884 );
885
886 VOID
887 IopBootLog(
888 IN PUNICODE_STRING DriverName,
889 IN BOOLEAN Success
890 );
891
892 VOID
893 IopSaveBootLogToFile(
894 VOID
895 );
896
897 //
898 // I/O Cancellation Routines
899 //
900 VOID
901 NTAPI
902 IoCancelThreadIo(
903 IN PETHREAD Thread
904 );
905
906 VOID
907 IoInitCancelHandling(
908 VOID
909 );
910
911 //
912 // I/O Completion
913 //
914 VOID
915 NTAPI
916 IopCompleteRequest(
917 IN PKAPC Apc,
918 IN PKNORMAL_ROUTINE* NormalRoutine,
919 IN PVOID* NormalContext,
920 IN PVOID* SystemArgument1,
921 IN PVOID* SystemArgument2
922 );
923
924 //
925 // Error Logging Routines
926 //
927 VOID
928 NTAPI
929 IopInitErrorLog(
930 VOID
931 );
932
933 VOID
934 NTAPI
935 IopLogWorker(
936 IN PVOID Parameter
937 );
938
939 //
940 // Raw File System MiniDriver
941 //
942 BOOLEAN
943 RawFsIsRawFileSystemDeviceObject(
944 IN PDEVICE_OBJECT DeviceObject
945 );
946
947 NTSTATUS
948 NTAPI
949 RawFsDriverEntry(
950 IN PDRIVER_OBJECT DriverObject,
951 IN PUNICODE_STRING RegistryPath
952 );
953
954 //
955 // PnP Root MiniDriver
956 //
957 NTSTATUS
958 NTAPI
959 PnpRootDriverEntry(
960 IN PDRIVER_OBJECT DriverObject,
961 IN PUNICODE_STRING RegistryPath
962 );
963
964 NTSTATUS
965 PnpRootCreateDevice(
966 IN PUNICODE_STRING ServiceName,
967 OUT PDEVICE_OBJECT *PhysicalDeviceObject,
968 OUT OPTIONAL PUNICODE_STRING FullInstancePath
969 );
970
971 //
972 // Driver Routines
973 //
974 VOID
975 FASTCALL
976 IopInitializeBootDrivers(
977 VOID
978 );
979
980 VOID
981 FASTCALL
982 IopInitializeSystemDrivers(
983 VOID
984 );
985
986 NTSTATUS
987 NTAPI
988 IopCreateDriver(IN PUNICODE_STRING DriverName OPTIONAL,
989 IN PDRIVER_INITIALIZE InitializationFunction,
990 IN PUNICODE_STRING RegistryPath,
991 IN PVOID DllBase,
992 IN ULONG SizeOfImage,
993 OUT PDRIVER_OBJECT *pDriverObject);
994
995 VOID
996 NTAPI
997 IopDeleteDriver(
998 IN PVOID ObjectBody
999 );
1000
1001 NTSTATUS
1002 FASTCALL
1003 IopGetDriverObject(
1004 OUT PDRIVER_OBJECT *DriverObject,
1005 IN PUNICODE_STRING ServiceName,
1006 IN BOOLEAN FileSystem
1007 );
1008
1009 NTSTATUS
1010 FASTCALL
1011 IopLoadServiceModule(
1012 IN PUNICODE_STRING ServiceName,
1013 OUT PLDR_DATA_TABLE_ENTRY *ModuleObject
1014 );
1015
1016 VOID
1017 NTAPI
1018 IopLoadUnloadDriver(
1019 IN OUT PLOAD_UNLOAD_PARAMS LoadParams
1020 );
1021
1022 NTSTATUS
1023 FASTCALL
1024 IopInitializeDriverModule(
1025 IN PDEVICE_NODE DeviceNode,
1026 IN PLDR_DATA_TABLE_ENTRY ModuleObject,
1027 IN PUNICODE_STRING ServiceName,
1028 IN BOOLEAN FileSystemDriver,
1029 OUT PDRIVER_OBJECT *DriverObject
1030 );
1031
1032 NTSTATUS
1033 FASTCALL
1034 IopAttachFilterDrivers(
1035 IN PDEVICE_NODE DeviceNode,
1036 IN BOOLEAN Lower
1037 );
1038
1039 VOID
1040 NTAPI
1041 IopReinitializeDrivers(
1042 VOID
1043 );
1044
1045 VOID
1046 NTAPI
1047 IopReinitializeBootDrivers(
1048 VOID
1049 );
1050
1051 //
1052 // File Routines
1053 //
1054 VOID
1055 NTAPI
1056 IopDeleteDevice(IN PVOID ObjectBody);
1057
1058 NTSTATUS
1059 NTAPI
1060 IopParseDevice(
1061 IN PVOID ParseObject,
1062 IN PVOID ObjectType,
1063 IN OUT PACCESS_STATE AccessState,
1064 IN KPROCESSOR_MODE AccessMode,
1065 IN ULONG Attributes,
1066 IN OUT PUNICODE_STRING CompleteName,
1067 IN OUT PUNICODE_STRING RemainingName,
1068 IN OUT PVOID Context OPTIONAL,
1069 IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
1070 OUT PVOID *Object
1071 );
1072
1073 NTSTATUS
1074 NTAPI
1075 IopParseFile(
1076 IN PVOID ParseObject,
1077 IN PVOID ObjectType,
1078 IN OUT PACCESS_STATE AccessState,
1079 IN KPROCESSOR_MODE AccessMode,
1080 IN ULONG Attributes,
1081 IN OUT PUNICODE_STRING CompleteName,
1082 IN OUT PUNICODE_STRING RemainingName,
1083 IN OUT PVOID Context OPTIONAL,
1084 IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
1085 OUT PVOID *Object
1086 );
1087
1088 VOID
1089 NTAPI
1090 IopDeleteFile(
1091 IN PVOID ObjectBody
1092 );
1093
1094 NTSTATUS
1095 NTAPI
1096 IopSecurityFile(
1097 IN PVOID ObjectBody,
1098 IN SECURITY_OPERATION_CODE OperationCode,
1099 IN PSECURITY_INFORMATION SecurityInformation,
1100 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
1101 IN OUT PULONG BufferLength,
1102 OUT PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
1103 IN POOL_TYPE PoolType,
1104 IN OUT PGENERIC_MAPPING GenericMapping
1105 );
1106
1107 NTSTATUS
1108 NTAPI
1109 IopQueryNameFile(
1110 IN PVOID ObjectBody,
1111 IN BOOLEAN HasName,
1112 OUT POBJECT_NAME_INFORMATION ObjectNameInfo,
1113 IN ULONG Length,
1114 OUT PULONG ReturnLength,
1115 IN KPROCESSOR_MODE PreviousMode
1116 );
1117
1118 VOID
1119 NTAPI
1120 IopCloseFile(
1121 IN PEPROCESS Process OPTIONAL,
1122 IN PVOID Object,
1123 IN ACCESS_MASK GrantedAccess,
1124 IN ULONG ProcessHandleCount,
1125 IN ULONG SystemHandleCount
1126 );
1127
1128 //
1129 // I/O Timer Routines
1130 //
1131 VOID
1132 FASTCALL
1133 IopInitTimerImplementation(
1134 VOID
1135 );
1136
1137 VOID
1138 NTAPI
1139 IopRemoveTimerFromTimerList(
1140 IN PIO_TIMER Timer
1141 );
1142
1143 //
1144 // I/O Completion Routines
1145 //
1146 VOID
1147 NTAPI
1148 IopDeleteIoCompletion(
1149 PVOID ObjectBody
1150 );
1151
1152 //
1153 // Ramdisk Routines
1154 //
1155 NTSTATUS
1156 NTAPI
1157 IopStartRamdisk(
1158 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1159 );
1160
1161 //
1162 // Global I/O Data
1163 //
1164 extern POBJECT_TYPE IoCompletionType;
1165 extern PDEVICE_NODE IopRootDeviceNode;
1166 extern KSPIN_LOCK IopDeviceTreeLock;
1167 extern ULONG IopTraceLevel;
1168 extern GENERAL_LOOKASIDE IopMdlLookasideList;
1169 extern GENERIC_MAPPING IopCompletionMapping;
1170 extern GENERIC_MAPPING IopFileMapping;
1171 extern POBJECT_TYPE _IoFileObjectType;
1172 extern HAL_DISPATCH _HalDispatchTable;
1173 extern LIST_ENTRY IopErrorLogListHead;
1174 extern ULONG IopNumTriageDumpDataBlocks;
1175 extern PVOID IopTriageDumpDataBlocks[64];
1176 extern PIO_BUS_TYPE_GUID_LIST PnpBusTypeGuidList;
1177 extern PDRIVER_OBJECT IopRootDriverObject;
1178
1179 //
1180 // Inlined Functions
1181 //
1182 #include "io_x.h"