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