[NTOS]: Rewrite boot driver loading code (not the driver code itself) to use the...
[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 VOID
513 PnpInit(
514 VOID
515 );
516
517 BOOLEAN
518 NTAPI
519 PpInitSystem(
520 VOID
521 );
522
523 VOID
524 PnpInit2(
525 VOID
526 );
527
528 VOID
529 IopInitDriverImplementation(
530 VOID
531 );
532
533 VOID
534 IopInitPnpNotificationImplementation(
535 VOID
536 );
537
538 VOID
539 IopNotifyPlugPlayNotification(
540 IN PDEVICE_OBJECT DeviceObject,
541 IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory,
542 IN LPCGUID Event,
543 IN PVOID EventCategoryData1,
544 IN PVOID EventCategoryData2
545 );
546
547 NTSTATUS
548 IopGetSystemPowerDeviceObject(
549 IN PDEVICE_OBJECT *DeviceObject
550 );
551
552 NTSTATUS
553 IopCreateDeviceNode(
554 IN PDEVICE_NODE ParentNode,
555 IN PDEVICE_OBJECT PhysicalDeviceObject,
556 IN PUNICODE_STRING ServiceName,
557 OUT PDEVICE_NODE *DeviceNode
558 );
559
560 NTSTATUS
561 IopFreeDeviceNode(
562 IN PDEVICE_NODE DeviceNode
563 );
564
565 NTSTATUS
566 IopInitiatePnpIrp(
567 IN PDEVICE_OBJECT DeviceObject,
568 IN PIO_STATUS_BLOCK IoStatusBlock,
569 IN ULONG MinorFunction,
570 IN PIO_STACK_LOCATION Stack
571 );
572
573 PDEVICE_NODE
574 FASTCALL
575 IopGetDeviceNode(
576 IN PDEVICE_OBJECT DeviceObject
577 );
578
579 NTSTATUS
580 IopActionConfigureChildServices(
581 IN PDEVICE_NODE DeviceNode,
582 IN PVOID Context
583 );
584
585 NTSTATUS
586 IopActionInitChildServices(
587 IN PDEVICE_NODE DeviceNode,
588 IN PVOID Context
589 );
590
591 NTSTATUS
592 IopEnumerateDevice(
593 IN PDEVICE_OBJECT DeviceObject
594 );
595
596 NTSTATUS
597 IoCreateDriverList(
598 VOID
599 );
600
601 NTSTATUS
602 IoDestroyDriverList(
603 VOID
604 );
605
606 NTSTATUS
607 INIT_FUNCTION
608 IopInitPlugPlayEvents(VOID);
609
610 NTSTATUS
611 IopQueueTargetDeviceEvent(
612 const GUID *Guid,
613 PUNICODE_STRING DeviceIds
614 );
615
616 NTSTATUS
617 IopInitializePnpServices(
618 IN PDEVICE_NODE DeviceNode);
619
620 NTSTATUS
621 NTAPI
622 IopOpenRegistryKeyEx(
623 PHANDLE KeyHandle,
624 HANDLE ParentKey,
625 PUNICODE_STRING Name,
626 ACCESS_MASK DesiredAccess);
627
628 NTSTATUS
629 NTAPI
630 IopGetRegistryValue(IN HANDLE Handle,
631 IN PWSTR ValueName,
632 OUT PKEY_VALUE_FULL_INFORMATION *Information);
633
634
635 //
636 // PnP Routines
637 //
638 NTSTATUS
639 NTAPI
640 PiInitCacheGroupInformation(
641 VOID
642 );
643
644 USHORT
645 NTAPI
646 PpInitGetGroupOrderIndex(
647 IN HANDLE ServiceHandle
648 );
649
650 USHORT
651 NTAPI
652 PipGetDriverTagPriority(
653 IN HANDLE ServiceHandle
654 );
655
656 NTSTATUS
657 NTAPI
658 PnpRegMultiSzToUnicodeStrings(
659 IN PKEY_VALUE_FULL_INFORMATION KeyValueInformation,
660 OUT PUNICODE_STRING *UnicodeStringList,
661 OUT PULONG UnicodeStringCount
662 );
663
664 BOOLEAN
665 NTAPI
666 PnpRegSzToString(
667 IN PWCHAR RegSzData,
668 IN ULONG RegSzLength,
669 OUT PUSHORT StringLength OPTIONAL
670 );
671
672 //
673 // Initialization Routines
674 //
675 NTSTATUS
676 NTAPI
677 IopCreateArcNames(
678 IN PLOADER_PARAMETER_BLOCK LoaderBlock
679 );
680
681 NTSTATUS
682 NTAPI
683 IopReassignSystemRoot(
684 IN PLOADER_PARAMETER_BLOCK LoaderBlock,
685 OUT PANSI_STRING NtBootPath
686 );
687
688 BOOLEAN
689 NTAPI
690 IoInitSystem(
691 IN PLOADER_PARAMETER_BLOCK LoaderBlock
692 );
693
694 //
695 // Device/Volume Routines
696 //
697 NTSTATUS
698 FASTCALL
699 IopInitializeDevice(
700 IN PDEVICE_NODE DeviceNode,
701 IN PDRIVER_OBJECT DriverObject
702 );
703
704 NTSTATUS
705 IopStartDevice(
706 IN PDEVICE_NODE DeviceNode
707 );
708
709 PVPB
710 NTAPI
711 IopCheckVpbMounted(
712 IN POPEN_PACKET OpenPacket,
713 IN PDEVICE_OBJECT DeviceObject,
714 IN PUNICODE_STRING RemainingName,
715 OUT PNTSTATUS Status
716 );
717
718 NTSTATUS
719 NTAPI
720 IopMountVolume(
721 IN PDEVICE_OBJECT DeviceObject,
722 IN BOOLEAN AllowRawMount,
723 IN BOOLEAN DeviceIsLocked,
724 IN BOOLEAN Alertable,
725 OUT PVPB *Vpb
726 );
727
728 PVOID
729 IoOpenSymlink(
730 IN PVOID SymbolicLink
731 );
732
733 PVOID
734 IoOpenFileOnDevice(
735 IN PVOID SymbolicLink,
736 IN PWCHAR Name
737 );
738
739 NTSTATUS
740 NTAPI
741 IopCreateVpb(
742 IN PDEVICE_OBJECT DeviceObject
743 );
744
745 VOID
746 NTAPI
747 IopDereferenceVpb(
748 IN PVPB Vpb
749 );
750
751 VOID
752 NTAPI
753 IoInitFileSystemImplementation(
754 VOID
755 );
756
757 VOID
758 NTAPI
759 IoInitVpbImplementation(
760 VOID
761 );
762
763 NTSTATUS
764 NTAPI
765 IopReferenceDeviceObject(
766 IN PDEVICE_OBJECT DeviceObject
767 );
768
769 VOID
770 NTAPI
771 IopDereferenceDeviceObject(
772 IN PDEVICE_OBJECT DeviceObject,
773 IN BOOLEAN ForceUnload
774 );
775
776 NTSTATUS
777 NTAPI
778 IoGetRelatedTargetDevice(IN PFILE_OBJECT FileObject,
779 OUT PDEVICE_OBJECT *DeviceObject
780 );
781
782 //
783 // IRP Routines
784 //
785 NTSTATUS
786 NTAPI
787 IopCleanupFailedIrp(
788 IN PFILE_OBJECT FileObject,
789 IN PKEVENT EventObject,
790 IN PVOID Buffer OPTIONAL
791 );
792
793 VOID
794 NTAPI
795 IopAbortInterruptedIrp(
796 IN PKEVENT EventObject,
797 IN PIRP Irp
798 );
799
800 //
801 // Shutdown routines
802 //
803 VOID
804 IoInitShutdownNotification(
805 VOID
806 );
807
808 VOID
809 NTAPI
810 IoShutdownSystem(
811 IN ULONG Phase
812 );
813
814 VOID
815 NTAPI
816 IopShutdownBaseFileSystems(
817 IN PLIST_ENTRY ListHead
818 );
819
820 //
821 // Boot logging support
822 //
823 VOID
824 IopInitBootLog(
825 IN BOOLEAN StartBootLog
826 );
827
828 VOID
829 IopStartBootLog(
830 VOID
831 );
832
833 VOID
834 IopStopBootLog(
835 VOID
836 );
837
838 VOID
839 IopBootLog(
840 IN PUNICODE_STRING DriverName,
841 IN BOOLEAN Success
842 );
843
844 VOID
845 IopSaveBootLogToFile(
846 VOID
847 );
848
849 //
850 // I/O Cancellation Routines
851 //
852 VOID
853 NTAPI
854 IoCancelThreadIo(
855 IN PETHREAD Thread
856 );
857
858 VOID
859 IoInitCancelHandling(
860 VOID
861 );
862
863 //
864 // I/O Completion
865 //
866 VOID
867 NTAPI
868 IopCompleteRequest(
869 IN PKAPC Apc,
870 IN PKNORMAL_ROUTINE* NormalRoutine,
871 IN PVOID* NormalContext,
872 IN PVOID* SystemArgument1,
873 IN PVOID* SystemArgument2
874 );
875
876 //
877 // Error Logging Routines
878 //
879 VOID
880 NTAPI
881 IopInitErrorLog(
882 VOID
883 );
884
885 VOID
886 NTAPI
887 IopLogWorker(
888 IN PVOID Parameter
889 );
890
891 //
892 // Raw File System MiniDriver
893 //
894 BOOLEAN
895 RawFsIsRawFileSystemDeviceObject(
896 IN PDEVICE_OBJECT DeviceObject
897 );
898
899 NTSTATUS
900 NTAPI
901 RawFsDriverEntry(
902 IN PDRIVER_OBJECT DriverObject,
903 IN PUNICODE_STRING RegistryPath
904 );
905
906 //
907 // PnP Root MiniDriver
908 //
909 NTSTATUS
910 NTAPI
911 PnpRootDriverEntry(
912 IN PDRIVER_OBJECT DriverObject,
913 IN PUNICODE_STRING RegistryPath
914 );
915
916 NTSTATUS
917 PnpRootCreateDevice(
918 IN PUNICODE_STRING ServiceName,
919 OUT PDEVICE_OBJECT *PhysicalDeviceObject,
920 OUT OPTIONAL PUNICODE_STRING FullInstancePath
921 );
922
923 //
924 // Driver Routines
925 //
926 VOID
927 FASTCALL
928 IopInitializeBootDrivers(
929 VOID
930 );
931
932 VOID
933 FASTCALL
934 IopInitializeSystemDrivers(
935 VOID
936 );
937
938 NTSTATUS
939 NTAPI
940 IopCreateDriver(IN PUNICODE_STRING DriverName OPTIONAL,
941 IN PDRIVER_INITIALIZE InitializationFunction,
942 IN PUNICODE_STRING RegistryPath,
943 IN PVOID DllBase,
944 IN ULONG SizeOfImage,
945 OUT PDRIVER_OBJECT *pDriverObject);
946
947 VOID
948 NTAPI
949 IopDeleteDriver(
950 IN PVOID ObjectBody
951 );
952
953 NTSTATUS
954 FASTCALL
955 IopGetDriverObject(
956 OUT PDRIVER_OBJECT *DriverObject,
957 IN PUNICODE_STRING ServiceName,
958 IN BOOLEAN FileSystem
959 );
960
961 NTSTATUS
962 FASTCALL
963 IopLoadServiceModule(
964 IN PUNICODE_STRING ServiceName,
965 OUT PLDR_DATA_TABLE_ENTRY *ModuleObject
966 );
967
968 VOID
969 NTAPI
970 IopLoadUnloadDriver(
971 IN OUT PLOAD_UNLOAD_PARAMS LoadParams
972 );
973
974 NTSTATUS
975 FASTCALL
976 IopInitializeDriverModule(
977 IN PDEVICE_NODE DeviceNode,
978 IN PLDR_DATA_TABLE_ENTRY ModuleObject,
979 IN PUNICODE_STRING ServiceName,
980 IN BOOLEAN FileSystemDriver,
981 OUT PDRIVER_OBJECT *DriverObject
982 );
983
984 NTSTATUS
985 FASTCALL
986 IopAttachFilterDrivers(
987 IN PDEVICE_NODE DeviceNode,
988 IN BOOLEAN Lower
989 );
990
991 VOID
992 NTAPI
993 IopReinitializeDrivers(
994 VOID
995 );
996
997 VOID
998 NTAPI
999 IopReinitializeBootDrivers(
1000 VOID
1001 );
1002
1003 //
1004 // File Routines
1005 //
1006 VOID
1007 NTAPI
1008 IopDeleteDevice(IN PVOID ObjectBody);
1009
1010 NTSTATUS
1011 NTAPI
1012 IopParseDevice(
1013 IN PVOID ParseObject,
1014 IN PVOID ObjectType,
1015 IN OUT PACCESS_STATE AccessState,
1016 IN KPROCESSOR_MODE AccessMode,
1017 IN ULONG Attributes,
1018 IN OUT PUNICODE_STRING CompleteName,
1019 IN OUT PUNICODE_STRING RemainingName,
1020 IN OUT PVOID Context OPTIONAL,
1021 IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
1022 OUT PVOID *Object
1023 );
1024
1025 NTSTATUS
1026 NTAPI
1027 IopParseFile(
1028 IN PVOID ParseObject,
1029 IN PVOID ObjectType,
1030 IN OUT PACCESS_STATE AccessState,
1031 IN KPROCESSOR_MODE AccessMode,
1032 IN ULONG Attributes,
1033 IN OUT PUNICODE_STRING CompleteName,
1034 IN OUT PUNICODE_STRING RemainingName,
1035 IN OUT PVOID Context OPTIONAL,
1036 IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
1037 OUT PVOID *Object
1038 );
1039
1040 VOID
1041 NTAPI
1042 IopDeleteFile(
1043 IN PVOID ObjectBody
1044 );
1045
1046 NTSTATUS
1047 NTAPI
1048 IopSecurityFile(
1049 IN PVOID ObjectBody,
1050 IN SECURITY_OPERATION_CODE OperationCode,
1051 IN PSECURITY_INFORMATION SecurityInformation,
1052 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
1053 IN OUT PULONG BufferLength,
1054 OUT PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
1055 IN POOL_TYPE PoolType,
1056 IN OUT PGENERIC_MAPPING GenericMapping
1057 );
1058
1059 NTSTATUS
1060 NTAPI
1061 IopQueryNameFile(
1062 IN PVOID ObjectBody,
1063 IN BOOLEAN HasName,
1064 OUT POBJECT_NAME_INFORMATION ObjectNameInfo,
1065 IN ULONG Length,
1066 OUT PULONG ReturnLength,
1067 IN KPROCESSOR_MODE PreviousMode
1068 );
1069
1070 VOID
1071 NTAPI
1072 IopCloseFile(
1073 IN PEPROCESS Process OPTIONAL,
1074 IN PVOID Object,
1075 IN ACCESS_MASK GrantedAccess,
1076 IN ULONG ProcessHandleCount,
1077 IN ULONG SystemHandleCount
1078 );
1079
1080 //
1081 // I/O Timer Routines
1082 //
1083 VOID
1084 FASTCALL
1085 IopInitTimerImplementation(
1086 VOID
1087 );
1088
1089 VOID
1090 NTAPI
1091 IopRemoveTimerFromTimerList(
1092 IN PIO_TIMER Timer
1093 );
1094
1095 //
1096 // I/O Completion Routines
1097 //
1098 VOID
1099 NTAPI
1100 IopDeleteIoCompletion(
1101 PVOID ObjectBody
1102 );
1103
1104 //
1105 // Ramdisk Routines
1106 //
1107 NTSTATUS
1108 NTAPI
1109 IopStartRamdisk(
1110 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1111 );
1112
1113 //
1114 // Global I/O Data
1115 //
1116 extern POBJECT_TYPE IoCompletionType;
1117 extern PDEVICE_NODE IopRootDeviceNode;
1118 extern ULONG IopTraceLevel;
1119 extern GENERAL_LOOKASIDE IopMdlLookasideList;
1120 extern GENERIC_MAPPING IopCompletionMapping;
1121 extern GENERIC_MAPPING IopFileMapping;
1122 extern POBJECT_TYPE _IoFileObjectType;
1123 extern HAL_DISPATCH _HalDispatchTable;
1124 extern LIST_ENTRY IopErrorLogListHead;
1125 extern ULONG IopNumTriageDumpDataBlocks;
1126 extern PVOID IopTriageDumpDataBlocks[64];
1127
1128 //
1129 // Inlined Functions
1130 //
1131 #include "io_x.h"