2519a8134d206f80b672bf780ca396e004e6a590
[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 // List of Bus Type GUIDs
400 //
401 typedef struct _IO_BUS_TYPE_GUID_LIST
402 {
403 ULONG GuidCount;
404 FAST_MUTEX Lock;
405 GUID Guids[1];
406 } IO_BUS_TYPE_GUID_LIST, *PIO_BUS_TYPE_GUID_LIST;
407 extern PIO_BUS_TYPE_GUID_LIST IopBusTypeGuidList;
408
409 //
410 // Shutdown entry for registed devices
411 //
412 typedef struct _SHUTDOWN_ENTRY
413 {
414 LIST_ENTRY ShutdownList;
415 PDEVICE_OBJECT DeviceObject;
416 } SHUTDOWN_ENTRY, *PSHUTDOWN_ENTRY;
417
418 //
419 // F/S Notification entry for registered File Systems
420 //
421 typedef struct _FS_CHANGE_NOTIFY_ENTRY
422 {
423 LIST_ENTRY FsChangeNotifyList;
424 PDRIVER_OBJECT DriverObject;
425 PDRIVER_FS_NOTIFICATION FSDNotificationProc;
426 } FS_CHANGE_NOTIFY_ENTRY, *PFS_CHANGE_NOTIFY_ENTRY;
427
428 //
429 // Driver (Boot) Re-Initialization Entry
430 //
431 typedef struct _DRIVER_REINIT_ITEM
432 {
433 LIST_ENTRY ItemEntry;
434 PDRIVER_OBJECT DriverObject;
435 PDRIVER_REINITIALIZE ReinitRoutine;
436 PVOID Context;
437 } DRIVER_REINIT_ITEM, *PDRIVER_REINIT_ITEM;
438
439 //
440 // Called on every visit of a node during a preorder-traversal of the device
441 // node tree.
442 // If the routine returns STATUS_UNSUCCESSFUL the traversal will stop and
443 // STATUS_SUCCESS is returned to the caller who initiated the tree traversal.
444 // Any other returned status code will be returned to the caller. If a status
445 // code that indicates an error (other than STATUS_UNSUCCESSFUL) is returned,
446 // the traversal is stopped immediately and the status code is returned to
447 // the caller.
448 //
449 typedef
450 NTSTATUS
451 (*DEVICETREE_TRAVERSE_ROUTINE)(
452 IN PDEVICE_NODE DeviceNode,
453 IN PVOID Context
454 );
455
456 //
457 // Context information for traversing the device tree
458 //
459 typedef struct _DEVICETREE_TRAVERSE_CONTEXT
460 {
461 //
462 // Current device node during a traversal
463 //
464 PDEVICE_NODE DeviceNode;
465
466 //
467 // Initial device node where we start the traversal
468 //
469 PDEVICE_NODE FirstDeviceNode;
470
471 //
472 // Action routine to be called for every device node
473 //
474 DEVICETREE_TRAVERSE_ROUTINE Action;
475
476 //
477 // Context passed to the action routine
478 //
479 PVOID Context;
480 } DEVICETREE_TRAVERSE_CONTEXT, *PDEVICETREE_TRAVERSE_CONTEXT;
481
482 //
483 // PNP Routines
484 //
485 VOID
486 PnpInit(
487 VOID
488 );
489
490 BOOLEAN
491 NTAPI
492 PpInitSystem(
493 VOID
494 );
495
496 VOID
497 PnpInit2(
498 VOID
499 );
500
501 VOID
502 IopInitDriverImplementation(
503 VOID
504 );
505
506 VOID
507 IopInitPnpNotificationImplementation(
508 VOID
509 );
510
511 VOID
512 IopNotifyPlugPlayNotification(
513 IN PDEVICE_OBJECT DeviceObject,
514 IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory,
515 IN LPCGUID Event,
516 IN PVOID EventCategoryData1,
517 IN PVOID EventCategoryData2
518 );
519
520 NTSTATUS
521 IopGetSystemPowerDeviceObject(
522 IN PDEVICE_OBJECT *DeviceObject
523 );
524
525 NTSTATUS
526 IopCreateDeviceNode(
527 IN PDEVICE_NODE ParentNode,
528 IN PDEVICE_OBJECT PhysicalDeviceObject,
529 IN PUNICODE_STRING ServiceName,
530 OUT PDEVICE_NODE *DeviceNode
531 );
532
533 NTSTATUS
534 IopFreeDeviceNode(
535 IN PDEVICE_NODE DeviceNode
536 );
537
538 NTSTATUS
539 IopInitiatePnpIrp(
540 IN PDEVICE_OBJECT DeviceObject,
541 IN PIO_STATUS_BLOCK IoStatusBlock,
542 IN ULONG MinorFunction,
543 IN PIO_STACK_LOCATION Stack
544 );
545
546 PDEVICE_NODE
547 FASTCALL
548 IopGetDeviceNode(
549 IN PDEVICE_OBJECT DeviceObject
550 );
551
552 NTSTATUS
553 IopActionConfigureChildServices(
554 IN PDEVICE_NODE DeviceNode,
555 IN PVOID Context
556 );
557
558 NTSTATUS
559 IopActionInitChildServices(
560 IN PDEVICE_NODE DeviceNode,
561 IN PVOID Context
562 );
563
564 NTSTATUS
565 IopEnumerateDevice(
566 IN PDEVICE_OBJECT DeviceObject
567 );
568
569 NTSTATUS
570 IoCreateDriverList(
571 VOID
572 );
573
574 NTSTATUS
575 IoDestroyDriverList(
576 VOID
577 );
578
579 NTSTATUS
580 INIT_FUNCTION
581 IopInitPlugPlayEvents(VOID);
582
583 NTSTATUS
584 IopQueueTargetDeviceEvent(
585 const GUID *Guid,
586 PUNICODE_STRING DeviceIds
587 );
588
589 NTSTATUS
590 IopInitializePnpServices(
591 IN PDEVICE_NODE DeviceNode);
592
593 NTSTATUS
594 NTAPI
595 IopOpenRegistryKeyEx(
596 PHANDLE KeyHandle,
597 HANDLE ParentKey,
598 PUNICODE_STRING Name,
599 ACCESS_MASK DesiredAccess);
600
601 NTSTATUS
602 NTAPI
603 IopGetRegistryValue(IN HANDLE Handle,
604 IN PWSTR ValueName,
605 OUT PKEY_VALUE_FULL_INFORMATION *Information);
606
607
608 //
609 // Initialization Routines
610 //
611 NTSTATUS
612 NTAPI
613 IopCreateArcNames(
614 IN PLOADER_PARAMETER_BLOCK LoaderBlock
615 );
616
617 NTSTATUS
618 NTAPI
619 IopReassignSystemRoot(
620 IN PLOADER_PARAMETER_BLOCK LoaderBlock,
621 OUT PANSI_STRING NtBootPath
622 );
623
624 BOOLEAN
625 NTAPI
626 IoInitSystem(
627 IN PLOADER_PARAMETER_BLOCK LoaderBlock
628 );
629
630 //
631 // Device/Volume Routines
632 //
633 NTSTATUS
634 FASTCALL
635 IopInitializeDevice(
636 IN PDEVICE_NODE DeviceNode,
637 IN PDRIVER_OBJECT DriverObject
638 );
639
640 NTSTATUS
641 IopStartDevice(
642 IN PDEVICE_NODE DeviceNode
643 );
644
645 PVPB
646 NTAPI
647 IopCheckVpbMounted(
648 IN POPEN_PACKET OpenPacket,
649 IN PDEVICE_OBJECT DeviceObject,
650 IN PUNICODE_STRING RemainingName,
651 OUT PNTSTATUS Status
652 );
653
654 NTSTATUS
655 NTAPI
656 IopMountVolume(
657 IN PDEVICE_OBJECT DeviceObject,
658 IN BOOLEAN AllowRawMount,
659 IN BOOLEAN DeviceIsLocked,
660 IN BOOLEAN Alertable,
661 OUT PVPB *Vpb
662 );
663
664 PVOID
665 IoOpenSymlink(
666 IN PVOID SymbolicLink
667 );
668
669 PVOID
670 IoOpenFileOnDevice(
671 IN PVOID SymbolicLink,
672 IN PWCHAR Name
673 );
674
675 NTSTATUS
676 NTAPI
677 IopCreateVpb(
678 IN PDEVICE_OBJECT DeviceObject
679 );
680
681 VOID
682 NTAPI
683 IopDereferenceVpb(
684 IN PVPB Vpb
685 );
686
687 VOID
688 NTAPI
689 IoInitFileSystemImplementation(
690 VOID
691 );
692
693 VOID
694 NTAPI
695 IoInitVpbImplementation(
696 VOID
697 );
698
699 NTSTATUS
700 NTAPI
701 IopReferenceDeviceObject(
702 IN PDEVICE_OBJECT DeviceObject
703 );
704
705 VOID
706 NTAPI
707 IopDereferenceDeviceObject(
708 IN PDEVICE_OBJECT DeviceObject,
709 IN BOOLEAN ForceUnload
710 );
711
712 NTSTATUS
713 NTAPI
714 IoGetRelatedTargetDevice(IN PFILE_OBJECT FileObject,
715 OUT PDEVICE_OBJECT *DeviceObject
716 );
717
718 //
719 // IRP Routines
720 //
721 NTSTATUS
722 NTAPI
723 IopCleanupFailedIrp(
724 IN PFILE_OBJECT FileObject,
725 IN PKEVENT EventObject,
726 IN PVOID Buffer OPTIONAL
727 );
728
729 VOID
730 NTAPI
731 IopAbortInterruptedIrp(
732 IN PKEVENT EventObject,
733 IN PIRP Irp
734 );
735
736 //
737 // Shutdown routines
738 //
739 VOID
740 IoInitShutdownNotification(
741 VOID
742 );
743
744 VOID
745 NTAPI
746 IoShutdownSystem(
747 IN ULONG Phase
748 );
749
750 VOID
751 NTAPI
752 IopShutdownBaseFileSystems(
753 IN PLIST_ENTRY ListHead
754 );
755
756 //
757 // Boot logging support
758 //
759 VOID
760 IopInitBootLog(
761 IN BOOLEAN StartBootLog
762 );
763
764 VOID
765 IopStartBootLog(
766 VOID
767 );
768
769 VOID
770 IopStopBootLog(
771 VOID
772 );
773
774 VOID
775 IopBootLog(
776 IN PUNICODE_STRING DriverName,
777 IN BOOLEAN Success
778 );
779
780 VOID
781 IopSaveBootLogToFile(
782 VOID
783 );
784
785 //
786 // I/O Cancellation Routines
787 //
788 VOID
789 NTAPI
790 IoCancelThreadIo(
791 IN PETHREAD Thread
792 );
793
794 VOID
795 IoInitCancelHandling(
796 VOID
797 );
798
799 //
800 // I/O Completion
801 //
802 VOID
803 NTAPI
804 IopCompleteRequest(
805 IN PKAPC Apc,
806 IN PKNORMAL_ROUTINE* NormalRoutine,
807 IN PVOID* NormalContext,
808 IN PVOID* SystemArgument1,
809 IN PVOID* SystemArgument2
810 );
811
812 //
813 // Error Logging Routines
814 //
815 VOID
816 NTAPI
817 IopInitErrorLog(
818 VOID
819 );
820
821 VOID
822 NTAPI
823 IopLogWorker(
824 IN PVOID Parameter
825 );
826
827 //
828 // Raw File System MiniDriver
829 //
830 BOOLEAN
831 RawFsIsRawFileSystemDeviceObject(
832 IN PDEVICE_OBJECT DeviceObject
833 );
834
835 NTSTATUS
836 NTAPI
837 RawFsDriverEntry(
838 IN PDRIVER_OBJECT DriverObject,
839 IN PUNICODE_STRING RegistryPath
840 );
841
842 //
843 // PnP Root MiniDriver
844 //
845 NTSTATUS
846 NTAPI
847 PnpRootDriverEntry(
848 IN PDRIVER_OBJECT DriverObject,
849 IN PUNICODE_STRING RegistryPath
850 );
851
852 NTSTATUS
853 PnpRootCreateDevice(
854 IN PUNICODE_STRING ServiceName,
855 OUT PDEVICE_OBJECT *PhysicalDeviceObject,
856 OUT OPTIONAL PUNICODE_STRING FullInstancePath
857 );
858
859 //
860 // Driver Routines
861 //
862 VOID
863 FASTCALL
864 IopInitializeBootDrivers(
865 VOID
866 );
867
868 VOID
869 FASTCALL
870 IopInitializeSystemDrivers(
871 VOID
872 );
873
874 NTSTATUS
875 NTAPI
876 IopCreateDriver(IN PUNICODE_STRING DriverName OPTIONAL,
877 IN PDRIVER_INITIALIZE InitializationFunction,
878 IN PUNICODE_STRING RegistryPath,
879 IN PVOID DllBase,
880 IN ULONG SizeOfImage,
881 OUT PDRIVER_OBJECT *pDriverObject);
882
883 VOID
884 NTAPI
885 IopDeleteDriver(
886 IN PVOID ObjectBody
887 );
888
889 NTSTATUS
890 FASTCALL
891 IopGetDriverObject(
892 OUT PDRIVER_OBJECT *DriverObject,
893 IN PUNICODE_STRING ServiceName,
894 IN BOOLEAN FileSystem
895 );
896
897 NTSTATUS
898 FASTCALL
899 IopLoadServiceModule(
900 IN PUNICODE_STRING ServiceName,
901 OUT PLDR_DATA_TABLE_ENTRY *ModuleObject
902 );
903
904 VOID
905 NTAPI
906 IopLoadUnloadDriver(
907 IN OUT PLOAD_UNLOAD_PARAMS LoadParams
908 );
909
910 NTSTATUS
911 FASTCALL
912 IopInitializeDriverModule(
913 IN PDEVICE_NODE DeviceNode,
914 IN PLDR_DATA_TABLE_ENTRY ModuleObject,
915 IN PUNICODE_STRING ServiceName,
916 IN BOOLEAN FileSystemDriver,
917 OUT PDRIVER_OBJECT *DriverObject
918 );
919
920 NTSTATUS
921 FASTCALL
922 IopAttachFilterDrivers(
923 IN PDEVICE_NODE DeviceNode,
924 IN BOOLEAN Lower
925 );
926
927 VOID
928 NTAPI
929 IopReinitializeDrivers(
930 VOID
931 );
932
933 VOID
934 NTAPI
935 IopReinitializeBootDrivers(
936 VOID
937 );
938
939 //
940 // File Routines
941 //
942 VOID
943 NTAPI
944 IopDeleteDevice(IN PVOID ObjectBody);
945
946 NTSTATUS
947 NTAPI
948 IopParseDevice(
949 IN PVOID ParseObject,
950 IN PVOID ObjectType,
951 IN OUT PACCESS_STATE AccessState,
952 IN KPROCESSOR_MODE AccessMode,
953 IN ULONG Attributes,
954 IN OUT PUNICODE_STRING CompleteName,
955 IN OUT PUNICODE_STRING RemainingName,
956 IN OUT PVOID Context OPTIONAL,
957 IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
958 OUT PVOID *Object
959 );
960
961 NTSTATUS
962 NTAPI
963 IopParseFile(
964 IN PVOID ParseObject,
965 IN PVOID ObjectType,
966 IN OUT PACCESS_STATE AccessState,
967 IN KPROCESSOR_MODE AccessMode,
968 IN ULONG Attributes,
969 IN OUT PUNICODE_STRING CompleteName,
970 IN OUT PUNICODE_STRING RemainingName,
971 IN OUT PVOID Context OPTIONAL,
972 IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
973 OUT PVOID *Object
974 );
975
976 VOID
977 NTAPI
978 IopDeleteFile(
979 IN PVOID ObjectBody
980 );
981
982 NTSTATUS
983 NTAPI
984 IopSecurityFile(
985 IN PVOID ObjectBody,
986 IN SECURITY_OPERATION_CODE OperationCode,
987 IN PSECURITY_INFORMATION SecurityInformation,
988 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
989 IN OUT PULONG BufferLength,
990 OUT PSECURITY_DESCRIPTOR *OldSecurityDescriptor,
991 IN POOL_TYPE PoolType,
992 IN OUT PGENERIC_MAPPING GenericMapping
993 );
994
995 NTSTATUS
996 NTAPI
997 IopQueryNameFile(
998 IN PVOID ObjectBody,
999 IN BOOLEAN HasName,
1000 OUT POBJECT_NAME_INFORMATION ObjectNameInfo,
1001 IN ULONG Length,
1002 OUT PULONG ReturnLength,
1003 IN KPROCESSOR_MODE PreviousMode
1004 );
1005
1006 VOID
1007 NTAPI
1008 IopCloseFile(
1009 IN PEPROCESS Process OPTIONAL,
1010 IN PVOID Object,
1011 IN ACCESS_MASK GrantedAccess,
1012 IN ULONG ProcessHandleCount,
1013 IN ULONG SystemHandleCount
1014 );
1015
1016 //
1017 // I/O Timer Routines
1018 //
1019 VOID
1020 FASTCALL
1021 IopInitTimerImplementation(
1022 VOID
1023 );
1024
1025 VOID
1026 NTAPI
1027 IopRemoveTimerFromTimerList(
1028 IN PIO_TIMER Timer
1029 );
1030
1031 //
1032 // I/O Completion Routines
1033 //
1034 VOID
1035 NTAPI
1036 IopDeleteIoCompletion(
1037 PVOID ObjectBody
1038 );
1039
1040 //
1041 // Ramdisk Routines
1042 //
1043 NTSTATUS
1044 NTAPI
1045 IopStartRamdisk(
1046 IN PLOADER_PARAMETER_BLOCK LoaderBlock
1047 );
1048
1049 //
1050 // Global I/O Data
1051 //
1052 extern POBJECT_TYPE IoCompletionType;
1053 extern PDEVICE_NODE IopRootDeviceNode;
1054 extern ULONG IopTraceLevel;
1055 extern GENERAL_LOOKASIDE IopMdlLookasideList;
1056 extern GENERIC_MAPPING IopCompletionMapping;
1057 extern GENERIC_MAPPING IopFileMapping;
1058 extern POBJECT_TYPE _IoFileObjectType;
1059 extern HAL_DISPATCH _HalDispatchTable;
1060 extern LIST_ENTRY IopErrorLogListHead;
1061 extern ULONG IopNumTriageDumpDataBlocks;
1062 extern PVOID IopTriageDumpDataBlocks[64];
1063
1064 //
1065 // Inlined Functions
1066 //
1067 #include "io_x.h"