xref: /reactos/sdk/include/xdk/iofuncs.h (revision cce399e7)
1 /******************************************************************************
2  *                         I/O Manager Functions                              *
3  ******************************************************************************/
4 
5 #include <section_attribs.h>
6 
7 $if (_WDMDDK_)
8 /*
9  * NTSTATUS
10  * IoAcquireRemoveLock(
11  *   IN PIO_REMOVE_LOCK  RemoveLock,
12  *   IN OPTIONAL PVOID  Tag)
13  */
14 #if DBG
15 #define IoAcquireRemoveLock(RemoveLock, Tag) \
16   IoAcquireRemoveLockEx(RemoveLock, Tag, __FILE__, __LINE__, sizeof (IO_REMOVE_LOCK))
17 #else
18 #define IoAcquireRemoveLock(RemoveLock, Tag) \
19   IoAcquireRemoveLockEx(RemoveLock, Tag, "", 1, sizeof (IO_REMOVE_LOCK))
20 #endif
21 
22 /*
23  * VOID
24  * IoAdjustPagingPathCount(
25  *   IN PLONG  Count,
26  *   IN BOOLEAN  Increment)
27  */
28 #define IoAdjustPagingPathCount(_Count, \
29                                 _Increment) \
30 { \
31   if (_Increment) \
32     { \
33       InterlockedIncrement(_Count); \
34     } \
35   else \
36     { \
37       InterlockedDecrement(_Count); \
38     } \
39 }
40 
41 #if !defined(_M_AMD64)
42 NTHALAPI
43 VOID
44 NTAPI
45 READ_PORT_BUFFER_UCHAR(
46   IN PUCHAR Port,
47   IN PUCHAR Buffer,
48   IN ULONG Count);
49 
50 NTHALAPI
51 VOID
52 NTAPI
53 READ_PORT_BUFFER_ULONG(
54   IN PULONG Port,
55   IN PULONG Buffer,
56   IN ULONG Count);
57 
58 NTHALAPI
59 VOID
60 NTAPI
61 READ_PORT_BUFFER_USHORT(
62   IN PUSHORT Port,
63   IN PUSHORT Buffer,
64   IN ULONG Count);
65 
66 NTHALAPI
67 UCHAR
68 NTAPI
69 READ_PORT_UCHAR(
70   IN PUCHAR Port);
71 
72 NTHALAPI
73 ULONG
74 NTAPI
75 READ_PORT_ULONG(
76   IN PULONG Port);
77 
78 NTHALAPI
79 USHORT
80 NTAPI
81 READ_PORT_USHORT(
82   IN PUSHORT Port);
83 
84 NTKERNELAPI
85 VOID
86 NTAPI
87 READ_REGISTER_BUFFER_UCHAR(
88   IN PUCHAR Register,
89   IN PUCHAR Buffer,
90   IN ULONG Count);
91 
92 NTKERNELAPI
93 VOID
94 NTAPI
95 READ_REGISTER_BUFFER_ULONG(
96   IN PULONG Register,
97   IN PULONG Buffer,
98   IN ULONG Count);
99 
100 NTKERNELAPI
101 VOID
102 NTAPI
103 READ_REGISTER_BUFFER_USHORT(
104   IN PUSHORT Register,
105   IN PUSHORT Buffer,
106   IN ULONG Count);
107 
108 NTKERNELAPI
109 UCHAR
110 NTAPI
111 READ_REGISTER_UCHAR(
112   IN PUCHAR Register);
113 
114 NTKERNELAPI
115 ULONG
116 NTAPI
117 READ_REGISTER_ULONG(
118   IN PULONG Register);
119 
120 NTKERNELAPI
121 USHORT
122 NTAPI
123 READ_REGISTER_USHORT(
124   IN PUSHORT Register);
125 
126 NTHALAPI
127 VOID
128 NTAPI
129 WRITE_PORT_BUFFER_UCHAR(
130   IN PUCHAR Port,
131   IN PUCHAR Buffer,
132   IN ULONG Count);
133 
134 NTHALAPI
135 VOID
136 NTAPI
137 WRITE_PORT_BUFFER_ULONG(
138   IN PULONG Port,
139   IN PULONG Buffer,
140   IN ULONG Count);
141 
142 NTHALAPI
143 VOID
144 NTAPI
145 WRITE_PORT_BUFFER_USHORT(
146   IN PUSHORT Port,
147   IN PUSHORT Buffer,
148   IN ULONG Count);
149 
150 NTHALAPI
151 VOID
152 NTAPI
153 WRITE_PORT_UCHAR(
154   IN PUCHAR Port,
155   IN UCHAR Value);
156 
157 NTHALAPI
158 VOID
159 NTAPI
160 WRITE_PORT_ULONG(
161   IN PULONG Port,
162   IN ULONG Value);
163 
164 NTHALAPI
165 VOID
166 NTAPI
167 WRITE_PORT_USHORT(
168   IN PUSHORT Port,
169   IN USHORT Value);
170 
171 NTKERNELAPI
172 VOID
173 NTAPI
174 WRITE_REGISTER_BUFFER_UCHAR(
175   IN PUCHAR Register,
176   IN PUCHAR Buffer,
177   IN ULONG Count);
178 
179 NTKERNELAPI
180 VOID
181 NTAPI
182 WRITE_REGISTER_BUFFER_ULONG(
183   IN PULONG Register,
184   IN PULONG Buffer,
185   IN ULONG Count);
186 
187 NTKERNELAPI
188 VOID
189 NTAPI
190 WRITE_REGISTER_BUFFER_USHORT(
191   IN PUSHORT Register,
192   IN PUSHORT Buffer,
193   IN ULONG Count);
194 
195 NTKERNELAPI
196 VOID
197 NTAPI
198 WRITE_REGISTER_UCHAR(
199   IN PUCHAR Register,
200   IN UCHAR Value);
201 
202 NTKERNELAPI
203 VOID
204 NTAPI
205 WRITE_REGISTER_ULONG(
206   IN PULONG Register,
207   IN ULONG Value);
208 
209 NTKERNELAPI
210 VOID
211 NTAPI
212 WRITE_REGISTER_USHORT(
213   IN PUSHORT Register,
214   IN USHORT Value);
215 
216 #else
217 
218 FORCEINLINE
219 VOID
220 READ_PORT_BUFFER_UCHAR(
221   IN PUCHAR Port,
222   IN PUCHAR Buffer,
223   IN ULONG Count)
224 {
225   __inbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count);
226 }
227 
228 FORCEINLINE
229 VOID
230 READ_PORT_BUFFER_ULONG(
231   IN PULONG Port,
232   IN PULONG Buffer,
233   IN ULONG Count)
234 {
235   __indwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
236 }
237 
238 FORCEINLINE
239 VOID
240 READ_PORT_BUFFER_USHORT(
241   IN PUSHORT Port,
242   IN PUSHORT Buffer,
243   IN ULONG Count)
244 {
245   __inwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
246 }
247 
248 FORCEINLINE
249 UCHAR
250 READ_PORT_UCHAR(
251   IN PUCHAR Port)
252 {
253   return __inbyte((USHORT)(ULONG_PTR)Port);
254 }
255 
256 FORCEINLINE
257 ULONG
258 READ_PORT_ULONG(
259   IN PULONG Port)
260 {
261   return __indword((USHORT)(ULONG_PTR)Port);
262 }
263 
264 FORCEINLINE
265 USHORT
266 READ_PORT_USHORT(
267   IN PUSHORT Port)
268 {
269   return __inword((USHORT)(ULONG_PTR)Port);
270 }
271 
272 FORCEINLINE
273 VOID
274 READ_REGISTER_BUFFER_UCHAR(
275   IN PUCHAR Register,
276   IN PUCHAR Buffer,
277   IN ULONG Count)
278 {
279   __movsb(Register, Buffer, Count);
280 }
281 
282 FORCEINLINE
283 VOID
284 READ_REGISTER_BUFFER_ULONG(
285   IN PULONG Register,
286   IN PULONG Buffer,
287   IN ULONG Count)
288 {
289   __movsd(Register, Buffer, Count);
290 }
291 
292 FORCEINLINE
293 VOID
294 READ_REGISTER_BUFFER_USHORT(
295   IN PUSHORT Register,
296   IN PUSHORT Buffer,
297   IN ULONG Count)
298 {
299   __movsw(Register, Buffer, Count);
300 }
301 
302 FORCEINLINE
303 UCHAR
304 READ_REGISTER_UCHAR(
305   IN volatile UCHAR *Register)
306 {
307   return *Register;
308 }
309 
310 FORCEINLINE
311 ULONG
312 READ_REGISTER_ULONG(
313   IN volatile ULONG *Register)
314 {
315   return *Register;
316 }
317 
318 FORCEINLINE
319 USHORT
320 READ_REGISTER_USHORT(
321   IN volatile USHORT *Register)
322 {
323   return *Register;
324 }
325 
326 FORCEINLINE
327 VOID
328 WRITE_PORT_BUFFER_UCHAR(
329   IN PUCHAR Port,
330   IN PUCHAR Buffer,
331   IN ULONG Count)
332 {
333   __outbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count);
334 }
335 
336 FORCEINLINE
337 VOID
338 WRITE_PORT_BUFFER_ULONG(
339   IN PULONG Port,
340   IN PULONG Buffer,
341   IN ULONG Count)
342 {
343   __outdwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
344 }
345 
346 FORCEINLINE
347 VOID
348 WRITE_PORT_BUFFER_USHORT(
349   IN PUSHORT Port,
350   IN PUSHORT Buffer,
351   IN ULONG Count)
352 {
353   __outwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
354 }
355 
356 FORCEINLINE
357 VOID
358 WRITE_PORT_UCHAR(
359   IN PUCHAR Port,
360   IN UCHAR Value)
361 {
362   __outbyte((USHORT)(ULONG_PTR)Port, Value);
363 }
364 
365 FORCEINLINE
366 VOID
367 WRITE_PORT_ULONG(
368   IN PULONG Port,
369   IN ULONG Value)
370 {
371   __outdword((USHORT)(ULONG_PTR)Port, Value);
372 }
373 
374 FORCEINLINE
375 VOID
376 WRITE_PORT_USHORT(
377   IN PUSHORT Port,
378   IN USHORT Value)
379 {
380   __outword((USHORT)(ULONG_PTR)Port, Value);
381 }
382 
383 FORCEINLINE
384 VOID
385 WRITE_REGISTER_BUFFER_UCHAR(
386   IN PUCHAR Register,
387   IN PUCHAR Buffer,
388   IN ULONG Count)
389 {
390   LONG Synch;
391   __movsb(Register, Buffer, Count);
392   InterlockedOr(&Synch, 1);
393 }
394 
395 FORCEINLINE
396 VOID
397 WRITE_REGISTER_BUFFER_ULONG(
398   IN PULONG Register,
399   IN PULONG Buffer,
400   IN ULONG Count)
401 {
402   LONG Synch;
403   __movsd(Register, Buffer, Count);
404   InterlockedOr(&Synch, 1);
405 }
406 
407 FORCEINLINE
408 VOID
409 WRITE_REGISTER_BUFFER_USHORT(
410   IN PUSHORT Register,
411   IN PUSHORT Buffer,
412   IN ULONG Count)
413 {
414   LONG Synch;
415   __movsw(Register, Buffer, Count);
416   InterlockedOr(&Synch, 1);
417 }
418 
419 FORCEINLINE
420 VOID
421 WRITE_REGISTER_UCHAR(
422   IN volatile UCHAR *Register,
423   IN UCHAR Value)
424 {
425   LONG Synch;
426   *Register = Value;
427   InterlockedOr(&Synch, 1);
428 }
429 
430 FORCEINLINE
431 VOID
432 WRITE_REGISTER_ULONG(
433   IN volatile ULONG *Register,
434   IN ULONG Value)
435 {
436   LONG Synch;
437   *Register = Value;
438   InterlockedOr(&Synch, 1);
439 }
440 
441 FORCEINLINE
442 VOID
443 WRITE_REGISTER_USHORT(
444   IN volatile USHORT *Register,
445   IN USHORT Value)
446 {
447   LONG Sync;
448   *Register = Value;
449   InterlockedOr(&Sync, 1);
450 }
451 #endif
452 
453 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && \
454    (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_)
455 
456 #define DMA_MACROS_DEFINED
457 
458 _IRQL_requires_max_(DISPATCH_LEVEL)
459 _IRQL_requires_min_(DISPATCH_LEVEL)
460 FORCEINLINE
461 NTSTATUS
462 IoAllocateAdapterChannel(
463   _In_ PDMA_ADAPTER DmaAdapter,
464   _In_ PDEVICE_OBJECT DeviceObject,
465   _In_ ULONG NumberOfMapRegisters,
466   _In_ PDRIVER_CONTROL ExecutionRoutine,
467   _In_ PVOID Context)
468 {
469   PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel;
470   AllocateAdapterChannel =
471       *(DmaAdapter)->DmaOperations->AllocateAdapterChannel;
472   ASSERT(AllocateAdapterChannel);
473   return AllocateAdapterChannel(DmaAdapter,
474                                 DeviceObject,
475                                 NumberOfMapRegisters,
476                                 ExecutionRoutine,
477                                 Context);
478 }
479 
480 FORCEINLINE
481 BOOLEAN
482 NTAPI
483 IoFlushAdapterBuffers(
484   _In_ PDMA_ADAPTER DmaAdapter,
485   _In_ PMDL Mdl,
486   _In_ PVOID MapRegisterBase,
487   _In_ PVOID CurrentVa,
488   _In_ ULONG Length,
489   _In_ BOOLEAN WriteToDevice)
490 {
491   PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers;
492   FlushAdapterBuffers = *(DmaAdapter)->DmaOperations->FlushAdapterBuffers;
493   ASSERT(FlushAdapterBuffers);
494   return FlushAdapterBuffers(DmaAdapter,
495                              Mdl,
496                              MapRegisterBase,
497                              CurrentVa,
498                              Length,
499                              WriteToDevice);
500 }
501 
502 FORCEINLINE
503 VOID
504 NTAPI
505 IoFreeAdapterChannel(
506   _In_ PDMA_ADAPTER DmaAdapter)
507 {
508   PFREE_ADAPTER_CHANNEL FreeAdapterChannel;
509   FreeAdapterChannel = *(DmaAdapter)->DmaOperations->FreeAdapterChannel;
510   ASSERT(FreeAdapterChannel);
511   FreeAdapterChannel(DmaAdapter);
512 }
513 
514 FORCEINLINE
515 VOID
516 NTAPI
517 IoFreeMapRegisters(
518   _In_ PDMA_ADAPTER DmaAdapter,
519   _In_ PVOID MapRegisterBase,
520   _In_ ULONG NumberOfMapRegisters)
521 {
522   PFREE_MAP_REGISTERS FreeMapRegisters;
523   FreeMapRegisters = *(DmaAdapter)->DmaOperations->FreeMapRegisters;
524   ASSERT(FreeMapRegisters);
525   FreeMapRegisters(DmaAdapter, MapRegisterBase, NumberOfMapRegisters);
526 }
527 
528 FORCEINLINE
529 PHYSICAL_ADDRESS
530 NTAPI
531 IoMapTransfer(
532   _In_ PDMA_ADAPTER DmaAdapter,
533   _In_ PMDL Mdl,
534   _In_ PVOID MapRegisterBase,
535   _In_ PVOID CurrentVa,
536   _Inout_ PULONG Length,
537   _In_ BOOLEAN WriteToDevice)
538 {
539   PMAP_TRANSFER MapTransfer;
540 
541   MapTransfer = *(DmaAdapter)->DmaOperations->MapTransfer;
542   ASSERT(MapTransfer);
543   return MapTransfer(DmaAdapter,
544                      Mdl,
545                      MapRegisterBase,
546                      CurrentVa,
547                      Length,
548                      WriteToDevice);
549 }
550 #endif
551 
552 $endif (_WDMDDK_)
553 $if (_NTDDK_)
554 /*
555  * VOID IoAssignArcName(
556  *   IN PUNICODE_STRING  ArcName,
557  *   IN PUNICODE_STRING  DeviceName);
558  */
559 #define IoAssignArcName(_ArcName, _DeviceName) ( \
560   IoCreateSymbolicLink((_ArcName), (_DeviceName)))
561 
562 /*
563  * VOID
564  * IoDeassignArcName(
565  *   IN PUNICODE_STRING  ArcName)
566  */
567 #define IoDeassignArcName IoDeleteSymbolicLink
568 
569 FORCEINLINE
570 VOID
571 NTAPI
572 IoInitializeDriverCreateContext(
573   PIO_DRIVER_CREATE_CONTEXT DriverContext)
574 {
575   RtlZeroMemory(DriverContext, sizeof(IO_DRIVER_CREATE_CONTEXT));
576   DriverContext->Size = sizeof(IO_DRIVER_CREATE_CONTEXT);
577 }
578 
579 $endif (_NTDDK_)
580 $if (_NTIFS_)
581 #define IoIsFileOpenedExclusively(FileObject) ( \
582     (BOOLEAN) !(                                \
583     (FileObject)->SharedRead ||                 \
584     (FileObject)->SharedWrite ||                \
585     (FileObject)->SharedDelete                  \
586     )                                           \
587 )
588 
589 #if (NTDDI_VERSION == NTDDI_WIN2K)
590 NTKERNELAPI
591 NTSTATUS
592 NTAPI
593 IoRegisterFsRegistrationChangeEx(
594   _In_ PDRIVER_OBJECT DriverObject,
595   _In_ PDRIVER_FS_NOTIFICATION DriverNotificationRoutine);
596 #endif
597 $endif (_NTIFS_)
598 #if (NTDDI_VERSION >= NTDDI_WIN2K)
599 
600 $if (_WDMDDK_)
601 _Acquires_lock_(_Global_cancel_spin_lock_)
602 _Requires_lock_not_held_(_Global_cancel_spin_lock_)
603 _IRQL_requires_max_(DISPATCH_LEVEL)
604 _IRQL_raises_(DISPATCH_LEVEL)
605 NTKERNELAPI
606 VOID
607 NTAPI
608 IoAcquireCancelSpinLock(
609   _Out_ _At_(*Irql, _IRQL_saves_) PKIRQL Irql);
610 
611 _IRQL_requires_max_(DISPATCH_LEVEL)
612 NTKERNELAPI
613 NTSTATUS
614 NTAPI
615 IoAcquireRemoveLockEx(
616   _Inout_ PIO_REMOVE_LOCK RemoveLock,
617   _In_opt_ PVOID Tag,
618   _In_ PCSTR File,
619   _In_ ULONG Line,
620   _In_ ULONG RemlockSize);
621 
622 _IRQL_requires_max_(DISPATCH_LEVEL)
623 _Ret_range_(<=, 0)
624 NTKERNELAPI
625 NTSTATUS
626 NTAPI
627 IoAllocateDriverObjectExtension(
628   _In_ PDRIVER_OBJECT DriverObject,
629   _In_ PVOID ClientIdentificationAddress,
630   _In_ ULONG DriverObjectExtensionSize,
631   _Post_ _At_(*DriverObjectExtension, _When_(return==0,
632     __drv_aliasesMem __drv_allocatesMem(Mem) _Post_notnull_))
633   _When_(return == 0, _Outptr_result_bytebuffer_(DriverObjectExtensionSize))
634     PVOID *DriverObjectExtension);
635 
636 _IRQL_requires_max_(DISPATCH_LEVEL)
637 NTKERNELAPI
638 PVOID
639 NTAPI
640 IoAllocateErrorLogEntry(
641   _In_ PVOID IoObject,
642   _In_ UCHAR EntrySize);
643 
644 _Must_inspect_result_
645 _IRQL_requires_max_(DISPATCH_LEVEL)
646 NTKERNELAPI
647 PIRP
648 NTAPI
649 IoAllocateIrp(
650   _In_ CCHAR StackSize,
651   _In_ BOOLEAN ChargeQuota);
652 
653 _IRQL_requires_max_(DISPATCH_LEVEL)
654 NTKERNELAPI
655 PMDL
656 NTAPI
657 IoAllocateMdl(
658   _In_opt_ __drv_aliasesMem PVOID VirtualAddress,
659   _In_ ULONG Length,
660   _In_ BOOLEAN SecondaryBuffer,
661   _In_ BOOLEAN ChargeQuota,
662   _Inout_opt_ PIRP Irp);
663 
664 __drv_allocatesMem(Mem)
665 _IRQL_requires_max_(DISPATCH_LEVEL)
666 NTKERNELAPI
667 PIO_WORKITEM
668 NTAPI
669 IoAllocateWorkItem(
670   _In_ PDEVICE_OBJECT DeviceObject);
671 
672 _IRQL_requires_max_(APC_LEVEL)
673 _Ret_range_(<=, 0)
674 NTKERNELAPI
675 NTSTATUS
676 NTAPI
677 IoAttachDevice(
678   _In_ _Kernel_requires_resource_held_(Memory) _When_(return==0, __drv_aliasesMem)
679     PDEVICE_OBJECT SourceDevice,
680   _In_ PUNICODE_STRING TargetDevice,
681   _Out_ PDEVICE_OBJECT *AttachedDevice);
682 
683 _Must_inspect_result_
684 _IRQL_requires_max_(DISPATCH_LEVEL)
685 NTKERNELAPI
686 PDEVICE_OBJECT
687 NTAPI
688 IoAttachDeviceToDeviceStack(
689   _In_ _Kernel_requires_resource_held_(Memory) _When_(return!=0, __drv_aliasesMem)
690     PDEVICE_OBJECT SourceDevice,
691   _In_ PDEVICE_OBJECT TargetDevice);
692 
693 _Must_inspect_result_
694 __drv_aliasesMem
695 _IRQL_requires_max_(DISPATCH_LEVEL)
696 NTKERNELAPI
697 PIRP
698 NTAPI
699 IoBuildAsynchronousFsdRequest(
700   _In_ ULONG MajorFunction,
701   _In_ PDEVICE_OBJECT DeviceObject,
702   _Inout_opt_ PVOID Buffer,
703   _In_opt_ ULONG Length,
704   _In_opt_ PLARGE_INTEGER StartingOffset,
705   _In_opt_ PIO_STATUS_BLOCK IoStatusBlock);
706 
707 _Must_inspect_result_
708 __drv_aliasesMem
709 _IRQL_requires_max_(PASSIVE_LEVEL)
710 NTKERNELAPI
711 PIRP
712 NTAPI
713 IoBuildDeviceIoControlRequest(
714   _In_ ULONG IoControlCode,
715   _In_ PDEVICE_OBJECT DeviceObject,
716   _In_opt_ PVOID InputBuffer,
717   _In_ ULONG InputBufferLength,
718   _Out_opt_ PVOID OutputBuffer,
719   _In_ ULONG OutputBufferLength,
720   _In_ BOOLEAN InternalDeviceIoControl,
721   _In_opt_ PKEVENT Event,
722   _Out_ PIO_STATUS_BLOCK IoStatusBlock);
723 
724 _IRQL_requires_max_(DISPATCH_LEVEL)
725 NTKERNELAPI
726 VOID
727 NTAPI
728 IoBuildPartialMdl(
729   _In_ PMDL SourceMdl,
730   _Inout_ PMDL TargetMdl,
731   _In_ PVOID VirtualAddress,
732   _In_ ULONG Length);
733 
734 _Must_inspect_result_
735 __drv_aliasesMem
736 _IRQL_requires_max_(PASSIVE_LEVEL)
737 NTKERNELAPI
738 PIRP
739 NTAPI
740 IoBuildSynchronousFsdRequest(
741   _In_ ULONG MajorFunction,
742   _In_ PDEVICE_OBJECT DeviceObject,
743   _Inout_opt_ PVOID Buffer,
744   _In_opt_ ULONG Length,
745   _In_opt_ PLARGE_INTEGER StartingOffset,
746   _In_ PKEVENT Event,
747   _Out_ PIO_STATUS_BLOCK IoStatusBlock);
748 
749 _IRQL_requires_max_(DISPATCH_LEVEL)
750 _Success_(TRUE)
751 NTKERNELAPI
752 NTSTATUS
753 FASTCALL
754 IofCallDriver(
755   _In_ PDEVICE_OBJECT DeviceObject,
756   _Inout_ __drv_aliasesMem PIRP Irp);
757 #define IoCallDriver IofCallDriver
758 
759 _IRQL_requires_max_(DISPATCH_LEVEL)
760 NTKERNELAPI
761 VOID
762 FASTCALL
763 IofCompleteRequest(
764   _In_ PIRP Irp,
765   _In_ CCHAR PriorityBoost);
766 #define IoCompleteRequest IofCompleteRequest
767 
768 _IRQL_requires_max_(DISPATCH_LEVEL)
769 NTKERNELAPI
770 BOOLEAN
771 NTAPI
772 IoCancelIrp(
773   _In_ PIRP Irp);
774 
775 _IRQL_requires_max_(PASSIVE_LEVEL)
776 NTKERNELAPI
777 NTSTATUS
778 NTAPI
779 IoCheckShareAccess(
780   _In_ ACCESS_MASK DesiredAccess,
781   _In_ ULONG DesiredShareAccess,
782   _Inout_ PFILE_OBJECT FileObject,
783   _Inout_ PSHARE_ACCESS ShareAccess,
784   _In_ BOOLEAN Update);
785 
786 _IRQL_requires_max_(DISPATCH_LEVEL)
787 NTKERNELAPI
788 VOID
789 FASTCALL
790 IofCompleteRequest(
791   _In_ PIRP Irp,
792   _In_ CCHAR PriorityBoost);
793 
794 _IRQL_requires_max_(PASSIVE_LEVEL)
795 NTKERNELAPI
796 NTSTATUS
797 NTAPI
798 IoConnectInterrupt(
799   _Out_ PKINTERRUPT *InterruptObject,
800   _In_ PKSERVICE_ROUTINE ServiceRoutine,
801   _In_opt_ PVOID ServiceContext,
802   _In_opt_ PKSPIN_LOCK SpinLock,
803   _In_ ULONG Vector,
804   _In_ KIRQL Irql,
805   _In_ KIRQL SynchronizeIrql,
806   _In_ KINTERRUPT_MODE InterruptMode,
807   _In_ BOOLEAN ShareVector,
808   _In_ KAFFINITY ProcessorEnableMask,
809   _In_ BOOLEAN FloatingSave);
810 
811 _IRQL_requires_max_(APC_LEVEL)
812 _Ret_range_(<=, 0)
813 NTKERNELAPI
814 NTSTATUS
815 NTAPI
816 IoCreateDevice(
817   _In_ PDRIVER_OBJECT DriverObject,
818   _In_ ULONG DeviceExtensionSize,
819   _In_opt_ PUNICODE_STRING DeviceName,
820   _In_ DEVICE_TYPE DeviceType,
821   _In_ ULONG DeviceCharacteristics,
822   _In_ BOOLEAN Exclusive,
823   _Outptr_result_nullonfailure_
824   _At_(*DeviceObject,
825     __drv_allocatesMem(Mem)
826     _When_(((_In_function_class_(DRIVER_INITIALIZE))
827       ||(_In_function_class_(DRIVER_DISPATCH))),
828       __drv_aliasesMem))
829     PDEVICE_OBJECT *DeviceObject);
830 
831 _IRQL_requires_max_(PASSIVE_LEVEL)
832 NTKERNELAPI
833 NTSTATUS
834 NTAPI
835 IoCreateFile(
836   _Out_ PHANDLE FileHandle,
837   _In_ ACCESS_MASK DesiredAccess,
838   _In_ POBJECT_ATTRIBUTES ObjectAttributes,
839   _Out_ PIO_STATUS_BLOCK IoStatusBlock,
840   _In_opt_ PLARGE_INTEGER AllocationSize,
841   _In_ ULONG FileAttributes,
842   _In_ ULONG ShareAccess,
843   _In_ ULONG Disposition,
844   _In_ ULONG CreateOptions,
845   _In_opt_ PVOID EaBuffer,
846   _In_ ULONG EaLength,
847   _In_ CREATE_FILE_TYPE CreateFileType,
848   _In_opt_ PVOID InternalParameters,
849   _In_ ULONG Options);
850 
851 _IRQL_requires_max_(PASSIVE_LEVEL)
852 NTKERNELAPI
853 PKEVENT
854 NTAPI
855 IoCreateNotificationEvent(
856   _In_ PUNICODE_STRING EventName,
857   _Out_ PHANDLE EventHandle);
858 
859 _IRQL_requires_max_(PASSIVE_LEVEL)
860 NTKERNELAPI
861 NTSTATUS
862 NTAPI
863 IoCreateSymbolicLink(
864   _In_ PUNICODE_STRING SymbolicLinkName,
865   _In_ PUNICODE_STRING DeviceName);
866 
867 _IRQL_requires_max_(PASSIVE_LEVEL)
868 NTKERNELAPI
869 PKEVENT
870 NTAPI
871 IoCreateSynchronizationEvent(
872   _In_ PUNICODE_STRING EventName,
873   _Out_ PHANDLE EventHandle);
874 
875 _IRQL_requires_max_(PASSIVE_LEVEL)
876 NTKERNELAPI
877 NTSTATUS
878 NTAPI
879 IoCreateUnprotectedSymbolicLink(
880   _In_ PUNICODE_STRING SymbolicLinkName,
881   _In_ PUNICODE_STRING DeviceName);
882 
883 _IRQL_requires_max_(APC_LEVEL)
884 _Kernel_clear_do_init_(__yes)
885 NTKERNELAPI
886 VOID
887 NTAPI
888 IoDeleteDevice(
889   _In_ _Kernel_requires_resource_held_(Memory) __drv_freesMem(Mem)
890     PDEVICE_OBJECT DeviceObject);
891 
892 _IRQL_requires_max_(PASSIVE_LEVEL)
893 NTKERNELAPI
894 NTSTATUS
895 NTAPI
896 IoDeleteSymbolicLink(
897   _In_ PUNICODE_STRING SymbolicLinkName);
898 
899 _IRQL_requires_max_(PASSIVE_LEVEL)
900 NTKERNELAPI
901 VOID
902 NTAPI
903 IoDetachDevice(
904   _Inout_ PDEVICE_OBJECT TargetDevice);
905 
906 _IRQL_requires_max_(PASSIVE_LEVEL)
907 NTKERNELAPI
908 VOID
909 NTAPI
910 IoDisconnectInterrupt(
911   _In_ PKINTERRUPT InterruptObject);
912 
913 __drv_freesMem(Mem)
914 _IRQL_requires_max_(DISPATCH_LEVEL)
915 NTKERNELAPI
916 VOID
917 NTAPI
918 IoFreeIrp(
919   _In_ PIRP Irp);
920 
921 _IRQL_requires_max_(DISPATCH_LEVEL)
922 NTKERNELAPI
923 VOID
924 NTAPI
925 IoFreeMdl(
926   PMDL Mdl);
927 
928 _IRQL_requires_max_(DISPATCH_LEVEL)
929 NTKERNELAPI
930 VOID
931 NTAPI
932 IoFreeWorkItem(
933   _In_ __drv_freesMem(Mem) PIO_WORKITEM IoWorkItem);
934 
935 NTKERNELAPI
936 PDEVICE_OBJECT
937 NTAPI
938 IoGetAttachedDevice(
939   IN PDEVICE_OBJECT DeviceObject);
940 
941 _IRQL_requires_max_(DISPATCH_LEVEL)
942 NTKERNELAPI
943 PDEVICE_OBJECT
944 NTAPI
945 IoGetAttachedDeviceReference(
946   _In_ PDEVICE_OBJECT DeviceObject);
947 
948 NTKERNELAPI
949 NTSTATUS
950 NTAPI
951 IoGetBootDiskInformation(
952   _Inout_ PBOOTDISK_INFORMATION BootDiskInformation,
953   _In_ ULONG Size);
954 
955 _IRQL_requires_max_(PASSIVE_LEVEL)
956 _Must_inspect_result_
957 NTKERNELAPI
958 NTSTATUS
959 NTAPI
960 IoGetDeviceInterfaceAlias(
961   _In_ PUNICODE_STRING SymbolicLinkName,
962   _In_ CONST GUID *AliasInterfaceClassGuid,
963   _Out_
964   _When_(return==0, _At_(AliasSymbolicLinkName->Buffer, __drv_allocatesMem(Mem)))
965     PUNICODE_STRING AliasSymbolicLinkName);
966 
967 NTKERNELAPI
968 PEPROCESS
969 NTAPI
970 IoGetCurrentProcess(VOID);
971 
972 _IRQL_requires_max_(PASSIVE_LEVEL)
973 _Must_inspect_result_
974 NTKERNELAPI
975 NTSTATUS
976 NTAPI
977 IoGetDeviceInterfaces(
978   _In_ CONST GUID *InterfaceClassGuid,
979   _In_opt_ PDEVICE_OBJECT PhysicalDeviceObject,
980   _In_ ULONG Flags,
981   _Outptr_result_nullonfailure_
982   _At_(*SymbolicLinkList, _When_(return==0, __drv_allocatesMem(Mem)))
983     PZZWSTR *SymbolicLinkList);
984 
985 _IRQL_requires_max_(PASSIVE_LEVEL)
986 NTKERNELAPI
987 NTSTATUS
988 NTAPI
989 IoGetDeviceObjectPointer(
990   _In_ PUNICODE_STRING ObjectName,
991   _In_ ACCESS_MASK DesiredAccess,
992   _Out_ PFILE_OBJECT *FileObject,
993   _Out_ PDEVICE_OBJECT *DeviceObject);
994 
995 _IRQL_requires_max_(PASSIVE_LEVEL)
996 _When_((DeviceProperty & __string_type),
997   _At_(PropertyBuffer, _Post_z_))
998 _When_((DeviceProperty & __multiString_type),
999   _At_(PropertyBuffer, _Post_ _NullNull_terminated_))
1000 NTKERNELAPI
1001 NTSTATUS
1002 NTAPI
1003 IoGetDeviceProperty(
1004   _In_ PDEVICE_OBJECT DeviceObject,
1005   _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty,
1006   _In_ ULONG BufferLength,
1007   _Out_writes_bytes_opt_(BufferLength) PVOID PropertyBuffer,
1008   _Deref_out_range_(<=, BufferLength) PULONG ResultLength);
1009 
1010 _Must_inspect_result_
1011 _IRQL_requires_max_(PASSIVE_LEVEL)
1012 NTKERNELAPI
1013 PDMA_ADAPTER
1014 NTAPI
1015 IoGetDmaAdapter(
1016   _In_opt_ PDEVICE_OBJECT PhysicalDeviceObject,
1017   _In_ PDEVICE_DESCRIPTION DeviceDescription,
1018   _Out_ _When_(return!=0, _Kernel_IoGetDmaAdapter_ _At_(*NumberOfMapRegisters, _Must_inspect_result_))
1019     PULONG NumberOfMapRegisters);
1020 
1021 __drv_aliasesMem
1022 _IRQL_requires_max_(DISPATCH_LEVEL)
1023 NTKERNELAPI
1024 PVOID
1025 NTAPI
1026 IoGetDriverObjectExtension(
1027   _In_ PDRIVER_OBJECT DriverObject,
1028   _In_ PVOID ClientIdentificationAddress);
1029 
1030 _IRQL_requires_max_(APC_LEVEL)
1031 NTKERNELAPI
1032 PVOID
1033 NTAPI
1034 IoGetInitialStack(VOID);
1035 
1036 NTKERNELAPI
1037 PDEVICE_OBJECT
1038 NTAPI
1039 IoGetRelatedDeviceObject(
1040   _In_ PFILE_OBJECT FileObject);
1041 
1042 _IRQL_requires_max_(DISPATCH_LEVEL)
1043 NTKERNELAPI
1044 VOID
1045 NTAPI
1046 IoQueueWorkItem(
1047   _Inout_ PIO_WORKITEM IoWorkItem,
1048   _In_ PIO_WORKITEM_ROUTINE WorkerRoutine,
1049   _In_ WORK_QUEUE_TYPE QueueType,
1050   _In_opt_ __drv_aliasesMem PVOID Context);
1051 
1052 _IRQL_requires_max_(DISPATCH_LEVEL)
1053 NTKERNELAPI
1054 VOID
1055 NTAPI
1056 IoInitializeIrp(
1057   _Inout_ PIRP Irp,
1058   _In_ USHORT PacketSize,
1059   _In_ CCHAR StackSize);
1060 
1061 _IRQL_requires_max_(PASSIVE_LEVEL)
1062 NTKERNELAPI
1063 VOID
1064 NTAPI
1065 IoInitializeRemoveLockEx(
1066   _Out_ PIO_REMOVE_LOCK Lock,
1067   _In_ ULONG AllocateTag,
1068   _In_ ULONG MaxLockedMinutes,
1069   _In_ ULONG HighWatermark,
1070   _In_ ULONG RemlockSize);
1071 
1072 _IRQL_requires_max_(PASSIVE_LEVEL)
1073 NTKERNELAPI
1074 NTSTATUS
1075 NTAPI
1076 IoInitializeTimer(
1077   _In_ PDEVICE_OBJECT DeviceObject,
1078   _In_ PIO_TIMER_ROUTINE TimerRoutine,
1079   _In_opt_ __drv_aliasesMem PVOID Context);
1080 
1081 _IRQL_requires_max_(DISPATCH_LEVEL)
1082 NTKERNELAPI
1083 VOID
1084 NTAPI
1085 IoInvalidateDeviceRelations(
1086   _In_ PDEVICE_OBJECT DeviceObject,
1087   _In_ DEVICE_RELATION_TYPE Type);
1088 
1089 _IRQL_requires_max_(DISPATCH_LEVEL)
1090 NTKERNELAPI
1091 VOID
1092 NTAPI
1093 IoInvalidateDeviceState(
1094   _In_ PDEVICE_OBJECT PhysicalDeviceObject);
1095 
1096 _IRQL_requires_max_(PASSIVE_LEVEL)
1097 NTKERNELAPI
1098 BOOLEAN
1099 NTAPI
1100 IoIsWdmVersionAvailable(
1101   _When_(MajorVersion!=1&&MajorVersion!=6, _In_ __drv_reportError("MajorVersion must be 1 or 6"))
1102     UCHAR MajorVersion,
1103   _In_ _When_(MinorVersion!=0 && MinorVersion!=5 &&
1104               MinorVersion!=16 && MinorVersion!=32 &&
1105               MinorVersion!=48, __drv_reportError("MinorVersion must be 0, 0x5, 0x10, 0x20, or 0x30"))
1106     UCHAR MinorVersion);
1107 
1108 _IRQL_requires_max_(PASSIVE_LEVEL)
1109 _Must_inspect_result_
1110 NTKERNELAPI
1111 NTSTATUS
1112 NTAPI
1113 IoOpenDeviceInterfaceRegistryKey(
1114   _In_ PUNICODE_STRING SymbolicLinkName,
1115   _In_ ACCESS_MASK DesiredAccess,
1116   _Out_ PHANDLE DeviceInterfaceKey);
1117 
1118 _IRQL_requires_max_(PASSIVE_LEVEL)
1119 _Must_inspect_result_
1120 NTKERNELAPI
1121 NTSTATUS
1122 NTAPI
1123 IoOpenDeviceRegistryKey(
1124   _In_ PDEVICE_OBJECT DeviceObject,
1125   _In_ ULONG DevInstKeyType,
1126   _In_ ACCESS_MASK DesiredAccess,
1127   _Out_ PHANDLE DevInstRegKey);
1128 
1129 _IRQL_requires_max_(PASSIVE_LEVEL)
1130 _Must_inspect_result_
1131 NTKERNELAPI
1132 NTSTATUS
1133 NTAPI
1134 IoRegisterDeviceInterface(
1135   _In_ PDEVICE_OBJECT PhysicalDeviceObject,
1136   _In_ CONST GUID *InterfaceClassGuid,
1137   _In_opt_ PUNICODE_STRING ReferenceString,
1138   _Out_ _When_(return==0, _At_(SymbolicLinkName->Buffer, __drv_allocatesMem(Mem)))
1139     PUNICODE_STRING SymbolicLinkName);
1140 
1141 _IRQL_requires_max_(PASSIVE_LEVEL)
1142 _Must_inspect_result_
1143 CODE_SEG("PAGE")
1144 NTKERNELAPI
1145 NTSTATUS
1146 NTAPI
1147 IoRegisterPlugPlayNotification(
1148   _In_ IO_NOTIFICATION_EVENT_CATEGORY EventCategory,
1149   _In_ ULONG EventCategoryFlags,
1150   _In_opt_ PVOID EventCategoryData,
1151   _In_ PDRIVER_OBJECT DriverObject,
1152   _In_ PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine,
1153   _Inout_opt_ __drv_aliasesMem PVOID Context,
1154   _Outptr_result_nullonfailure_
1155   _At_(*NotificationEntry, _When_(return==0, __drv_allocatesMem(Mem)))
1156     PVOID *NotificationEntry);
1157 
1158 _IRQL_requires_max_(PASSIVE_LEVEL)
1159 NTKERNELAPI
1160 NTSTATUS
1161 NTAPI
1162 IoRegisterShutdownNotification(
1163   _In_ PDEVICE_OBJECT DeviceObject);
1164 
1165 _Requires_lock_held_(_Global_cancel_spin_lock_)
1166 _Releases_lock_(_Global_cancel_spin_lock_)
1167 _IRQL_requires_max_(DISPATCH_LEVEL)
1168 _IRQL_requires_min_(DISPATCH_LEVEL)
1169 NTKERNELAPI
1170 VOID
1171 NTAPI
1172 IoReleaseCancelSpinLock(
1173   _In_ _IRQL_restores_ _IRQL_uses_cancel_ KIRQL Irql);
1174 
1175 _IRQL_requires_max_(PASSIVE_LEVEL)
1176 NTKERNELAPI
1177 VOID
1178 NTAPI
1179 IoReleaseRemoveLockAndWaitEx(
1180   _Inout_ PIO_REMOVE_LOCK RemoveLock,
1181   _In_opt_ PVOID Tag,
1182   _In_ ULONG RemlockSize);
1183 
1184 NTKERNELAPI
1185 VOID
1186 NTAPI
1187 IoReleaseRemoveLockEx(
1188   _Inout_ PIO_REMOVE_LOCK RemoveLock,
1189   _In_opt_ PVOID Tag,
1190   _In_ ULONG RemlockSize);
1191 
1192 _IRQL_requires_max_(PASSIVE_LEVEL)
1193 NTKERNELAPI
1194 VOID
1195 NTAPI
1196 IoRemoveShareAccess(
1197   _In_ PFILE_OBJECT FileObject,
1198   _Inout_ PSHARE_ACCESS ShareAccess);
1199 
1200 _IRQL_requires_max_(PASSIVE_LEVEL)
1201 NTKERNELAPI
1202 NTSTATUS
1203 NTAPI
1204 IoReportTargetDeviceChange(
1205   _In_ PDEVICE_OBJECT PhysicalDeviceObject,
1206   _In_ PVOID NotificationStructure);
1207 
1208 _IRQL_requires_max_(DISPATCH_LEVEL)
1209 NTKERNELAPI
1210 NTSTATUS
1211 NTAPI
1212 IoReportTargetDeviceChangeAsynchronous(
1213   _In_ PDEVICE_OBJECT PhysicalDeviceObject,
1214   _In_ PVOID NotificationStructure,
1215   _In_opt_ PDEVICE_CHANGE_COMPLETE_CALLBACK Callback,
1216   _In_opt_ PVOID Context);
1217 
1218 _IRQL_requires_max_(DISPATCH_LEVEL)
1219 NTKERNELAPI
1220 VOID
1221 NTAPI
1222 IoRequestDeviceEject(
1223   _In_ PDEVICE_OBJECT PhysicalDeviceObject);
1224 
1225 _IRQL_requires_max_(DISPATCH_LEVEL)
1226 NTKERNELAPI
1227 VOID
1228 NTAPI
1229 IoReuseIrp(
1230   _Inout_ PIRP Irp,
1231   _In_ NTSTATUS Status);
1232 
1233 _IRQL_requires_max_(PASSIVE_LEVEL)
1234 _Must_inspect_result_
1235 NTKERNELAPI
1236 NTSTATUS
1237 NTAPI
1238 IoSetDeviceInterfaceState(
1239   _In_ PUNICODE_STRING SymbolicLinkName,
1240   _In_ BOOLEAN Enable);
1241 
1242 NTKERNELAPI
1243 VOID
1244 NTAPI
1245 IoSetShareAccess(
1246   _In_ ACCESS_MASK DesiredAccess,
1247   _In_ ULONG DesiredShareAccess,
1248   _Inout_ PFILE_OBJECT FileObject,
1249   _Out_ PSHARE_ACCESS ShareAccess);
1250 
1251 _IRQL_requires_max_(DISPATCH_LEVEL)
1252 _IRQL_requires_min_(DISPATCH_LEVEL)
1253 NTKERNELAPI
1254 VOID
1255 NTAPI
1256 IoStartNextPacket(
1257   _In_ PDEVICE_OBJECT DeviceObject,
1258   _In_ BOOLEAN Cancelable);
1259 
1260 _IRQL_requires_max_(DISPATCH_LEVEL)
1261 NTKERNELAPI
1262 VOID
1263 NTAPI
1264 IoStartNextPacketByKey(
1265   _In_ PDEVICE_OBJECT DeviceObject,
1266   _In_ BOOLEAN Cancelable,
1267   _In_ ULONG Key);
1268 
1269 _IRQL_requires_max_(DISPATCH_LEVEL)
1270 NTKERNELAPI
1271 VOID
1272 NTAPI
1273 IoStartPacket(
1274   _In_ PDEVICE_OBJECT DeviceObject,
1275   _In_ PIRP Irp,
1276   _In_opt_ PULONG Key,
1277   _In_opt_ PDRIVER_CANCEL CancelFunction);
1278 
1279 _IRQL_requires_max_(DISPATCH_LEVEL)
1280 NTKERNELAPI
1281 VOID
1282 NTAPI
1283 IoStartTimer(
1284   _In_ PDEVICE_OBJECT DeviceObject);
1285 
1286 _IRQL_requires_max_(DISPATCH_LEVEL)
1287 NTKERNELAPI
1288 VOID
1289 NTAPI
1290 IoStopTimer(
1291   _In_ PDEVICE_OBJECT DeviceObject);
1292 
1293 _IRQL_requires_max_(PASSIVE_LEVEL)
1294 __drv_freesMem(Pool)
1295 CODE_SEG("PAGE")
1296 NTKERNELAPI
1297 NTSTATUS
1298 NTAPI
1299 IoUnregisterPlugPlayNotification(
1300   _In_ PVOID NotificationEntry);
1301 
1302 _IRQL_requires_max_(PASSIVE_LEVEL)
1303 NTKERNELAPI
1304 VOID
1305 NTAPI
1306 IoUnregisterShutdownNotification(
1307   _In_ PDEVICE_OBJECT DeviceObject);
1308 
1309 _IRQL_requires_max_(PASSIVE_LEVEL)
1310 NTKERNELAPI
1311 VOID
1312 NTAPI
1313 IoUpdateShareAccess(
1314   _In_ PFILE_OBJECT FileObject,
1315   _Inout_ PSHARE_ACCESS ShareAccess);
1316 
1317 _IRQL_requires_max_(PASSIVE_LEVEL)
1318 NTKERNELAPI
1319 NTSTATUS
1320 NTAPI
1321 IoWMIAllocateInstanceIds(
1322   _In_ GUID *Guid,
1323   _In_ ULONG InstanceCount,
1324   _Out_ ULONG *FirstInstanceId);
1325 
1326 NTKERNELAPI
1327 NTSTATUS
1328 NTAPI
1329 IoWMIQuerySingleInstanceMultiple(
1330   _In_reads_(ObjectCount) PVOID *DataBlockObjectList,
1331   _In_reads_(ObjectCount) PUNICODE_STRING InstanceNames,
1332   _In_ ULONG ObjectCount,
1333   _Inout_ ULONG *InOutBufferSize,
1334   _Out_writes_bytes_opt_(*InOutBufferSize) PVOID OutBuffer);
1335 
1336 _IRQL_requires_max_(PASSIVE_LEVEL)
1337 NTKERNELAPI
1338 NTSTATUS
1339 NTAPI
1340 IoWMIRegistrationControl(
1341   _In_ PDEVICE_OBJECT DeviceObject,
1342   _In_ ULONG Action);
1343 
1344 NTKERNELAPI
1345 NTSTATUS
1346 NTAPI
1347 IoWMISuggestInstanceName(
1348   _In_opt_ PDEVICE_OBJECT PhysicalDeviceObject,
1349   _In_opt_ PUNICODE_STRING SymbolicLinkName,
1350   _In_ BOOLEAN CombineNames,
1351   _Out_ PUNICODE_STRING SuggestedInstanceName);
1352 
1353 _Must_inspect_result_
1354 _IRQL_requires_max_(DISPATCH_LEVEL)
1355 _Ret_range_(<=, 0)
1356 NTKERNELAPI
1357 NTSTATUS
1358 NTAPI
1359 IoWMIWriteEvent(
1360   _Inout_ _When_(return==0, __drv_aliasesMem) PVOID WnodeEventItem);
1361 
1362 _IRQL_requires_max_(DISPATCH_LEVEL)
1363 NTKERNELAPI
1364 VOID
1365 NTAPI
1366 IoWriteErrorLogEntry(
1367   _In_ PVOID ElEntry);
1368 
1369 NTKERNELAPI
1370 PIRP
1371 NTAPI
1372 IoGetTopLevelIrp(VOID);
1373 
1374 _IRQL_requires_max_(PASSIVE_LEVEL)
1375 NTKERNELAPI
1376 NTSTATUS
1377 NTAPI
1378 IoRegisterLastChanceShutdownNotification(
1379   _In_ PDEVICE_OBJECT DeviceObject);
1380 
1381 NTKERNELAPI
1382 VOID
1383 NTAPI
1384 IoSetTopLevelIrp(
1385   _In_opt_ PIRP Irp);
1386 
1387 $endif (_WDMDDK_)
1388 $if (_NTDDK_)
1389 #if !(defined(USE_DMA_MACROS) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_))
1390 _IRQL_requires_max_(DISPATCH_LEVEL)
1391 _IRQL_requires_min_(DISPATCH_LEVEL)
1392 NTKERNELAPI
1393 NTSTATUS
1394 NTAPI
1395 IoAllocateAdapterChannel(
1396   _In_ PADAPTER_OBJECT AdapterObject,
1397   _In_ PDEVICE_OBJECT DeviceObject,
1398   _In_ ULONG NumberOfMapRegisters,
1399   _In_ PDRIVER_CONTROL ExecutionRoutine,
1400   _In_ PVOID Context);
1401 #endif
1402 
1403 #if !defined(DMA_MACROS_DEFINED)
1404 //DECLSPEC_DEPRECATED_DDK
1405 NTHALAPI
1406 PHYSICAL_ADDRESS
1407 NTAPI
1408 IoMapTransfer(
1409   _In_ PADAPTER_OBJECT AdapterObject,
1410   _In_ PMDL Mdl,
1411   _In_ PVOID MapRegisterBase,
1412   _In_ PVOID CurrentVa,
1413   _Inout_ PULONG Length,
1414   _In_ BOOLEAN WriteToDevice);
1415 #endif
1416 
1417 _IRQL_requires_max_(DISPATCH_LEVEL)
1418 _IRQL_requires_min_(DISPATCH_LEVEL)
1419 NTKERNELAPI
1420 VOID
1421 NTAPI
1422 IoAllocateController(
1423   _In_ PCONTROLLER_OBJECT ControllerObject,
1424   _In_ PDEVICE_OBJECT DeviceObject,
1425   _In_ PDRIVER_CONTROL ExecutionRoutine,
1426   _In_opt_ PVOID Context);
1427 
1428 _IRQL_requires_max_(PASSIVE_LEVEL)
1429 NTKERNELAPI
1430 PCONTROLLER_OBJECT
1431 NTAPI
1432 IoCreateController(
1433   _In_ ULONG Size);
1434 
1435 _IRQL_requires_max_(PASSIVE_LEVEL)
1436 NTKERNELAPI
1437 VOID
1438 NTAPI
1439 IoDeleteController(
1440   _In_ PCONTROLLER_OBJECT ControllerObject);
1441 
1442 _IRQL_requires_max_(DISPATCH_LEVEL)
1443 _IRQL_requires_min_(DISPATCH_LEVEL)
1444 NTKERNELAPI
1445 VOID
1446 NTAPI
1447 IoFreeController(
1448   _In_ PCONTROLLER_OBJECT ControllerObject);
1449 
1450 _IRQL_requires_max_(PASSIVE_LEVEL)
1451 NTKERNELAPI
1452 PCONFIGURATION_INFORMATION
1453 NTAPI
1454 IoGetConfigurationInformation(VOID);
1455 
1456 _IRQL_requires_max_(PASSIVE_LEVEL)
1457 NTKERNELAPI
1458 PDEVICE_OBJECT
1459 NTAPI
1460 IoGetDeviceToVerify(
1461   _In_ PETHREAD Thread);
1462 
1463 NTKERNELAPI
1464 VOID
1465 NTAPI
1466 IoCancelFileOpen(
1467   _In_ PDEVICE_OBJECT DeviceObject,
1468   _In_ PFILE_OBJECT FileObject);
1469 
1470 _IRQL_requires_max_(PASSIVE_LEVEL)
1471 NTKERNELAPI
1472 PGENERIC_MAPPING
1473 NTAPI
1474 IoGetFileObjectGenericMapping(VOID);
1475 
1476 _IRQL_requires_max_(DISPATCH_LEVEL)
1477 NTKERNELAPI
1478 PIRP
1479 NTAPI
1480 IoMakeAssociatedIrp(
1481   _In_ PIRP Irp,
1482   _In_ CCHAR StackSize);
1483 
1484 NTKERNELAPI
1485 NTSTATUS
1486 NTAPI
1487 IoQueryDeviceDescription(
1488   _In_opt_ PINTERFACE_TYPE BusType,
1489   _In_opt_ PULONG BusNumber,
1490   _In_opt_ PCONFIGURATION_TYPE ControllerType,
1491   _In_opt_ PULONG ControllerNumber,
1492   _In_opt_ PCONFIGURATION_TYPE PeripheralType,
1493   _In_opt_ PULONG PeripheralNumber,
1494   _In_ PIO_QUERY_DEVICE_ROUTINE CalloutRoutine,
1495   _In_opt_ PVOID Context);
1496 
1497 _IRQL_requires_max_(APC_LEVEL)
1498 NTKERNELAPI
1499 VOID
1500 NTAPI
1501 IoRaiseHardError(
1502   _In_ PIRP Irp,
1503   _In_opt_ PVPB Vpb,
1504   _In_ PDEVICE_OBJECT RealDeviceObject);
1505 
1506 _IRQL_requires_max_(APC_LEVEL)
1507 NTKERNELAPI
1508 BOOLEAN
1509 NTAPI
1510 IoRaiseInformationalHardError(
1511   _In_ NTSTATUS ErrorStatus,
1512   _In_opt_ PUNICODE_STRING String,
1513   _In_opt_ PKTHREAD Thread);
1514 
1515 _IRQL_requires_max_(PASSIVE_LEVEL)
1516 NTKERNELAPI
1517 VOID
1518 NTAPI
1519 IoRegisterBootDriverReinitialization(
1520   _In_ PDRIVER_OBJECT DriverObject,
1521   _In_ PDRIVER_REINITIALIZE DriverReinitializationRoutine,
1522   _In_opt_ PVOID Context);
1523 
1524 _IRQL_requires_max_(PASSIVE_LEVEL)
1525 NTKERNELAPI
1526 VOID
1527 NTAPI
1528 IoRegisterDriverReinitialization(
1529   _In_ PDRIVER_OBJECT DriverObject,
1530   _In_ PDRIVER_REINITIALIZE DriverReinitializationRoutine,
1531   _In_opt_ PVOID Context);
1532 
1533 NTKERNELAPI
1534 NTSTATUS
1535 NTAPI
1536 IoAttachDeviceByPointer(
1537   _In_ PDEVICE_OBJECT SourceDevice,
1538   _In_ PDEVICE_OBJECT TargetDevice);
1539 
1540 _IRQL_requires_max_(PASSIVE_LEVEL)
1541 _Must_inspect_result_
1542 NTKERNELAPI
1543 NTSTATUS
1544 NTAPI
1545 IoReportDetectedDevice(
1546   _In_ PDRIVER_OBJECT DriverObject,
1547   _In_ INTERFACE_TYPE LegacyBusType,
1548   _In_ ULONG BusNumber,
1549   _In_ ULONG SlotNumber,
1550   _In_opt_ PCM_RESOURCE_LIST ResourceList,
1551   _In_opt_ PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements,
1552   _In_ BOOLEAN ResourceAssigned,
1553   _Inout_ PDEVICE_OBJECT *DeviceObject);
1554 
1555 NTKERNELAPI
1556 NTSTATUS
1557 NTAPI
1558 IoReportResourceForDetection(
1559   _In_ PDRIVER_OBJECT DriverObject,
1560   _In_reads_bytes_opt_(DriverListSize) PCM_RESOURCE_LIST DriverList,
1561   _In_opt_ ULONG DriverListSize,
1562   _In_opt_ PDEVICE_OBJECT DeviceObject,
1563   _In_reads_bytes_opt_(DeviceListSize) PCM_RESOURCE_LIST DeviceList,
1564   _In_opt_ ULONG DeviceListSize,
1565   _Out_ PBOOLEAN ConflictDetected);
1566 
1567 NTKERNELAPI
1568 NTSTATUS
1569 NTAPI
1570 IoReportResourceUsage(
1571   _In_opt_ PUNICODE_STRING DriverClassName,
1572   _In_ PDRIVER_OBJECT DriverObject,
1573   _In_reads_bytes_opt_(DriverListSize) PCM_RESOURCE_LIST DriverList,
1574   _In_opt_ ULONG DriverListSize,
1575   _In_opt_ PDEVICE_OBJECT DeviceObject,
1576   _In_reads_bytes_opt_(DeviceListSize) PCM_RESOURCE_LIST DeviceList,
1577   _In_opt_ ULONG DeviceListSize,
1578   _In_ BOOLEAN OverrideConflict,
1579   _Out_ PBOOLEAN ConflictDetected);
1580 
1581 _IRQL_requires_max_(DISPATCH_LEVEL)
1582 NTKERNELAPI
1583 VOID
1584 NTAPI
1585 IoSetHardErrorOrVerifyDevice(
1586   _In_ PIRP Irp,
1587   _In_ PDEVICE_OBJECT DeviceObject);
1588 
1589 NTKERNELAPI
1590 NTSTATUS
1591 NTAPI
1592 IoAssignResources(
1593   _In_ PUNICODE_STRING RegistryPath,
1594   _In_opt_ PUNICODE_STRING DriverClassName,
1595   _In_ PDRIVER_OBJECT DriverObject,
1596   _In_opt_ PDEVICE_OBJECT DeviceObject,
1597   _In_opt_ PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources,
1598   _Inout_ PCM_RESOURCE_LIST *AllocatedResources);
1599 
1600 _IRQL_requires_max_(DISPATCH_LEVEL)
1601 NTKERNELAPI
1602 BOOLEAN
1603 NTAPI
1604 IoSetThreadHardErrorMode(
1605   _In_ BOOLEAN EnableHardErrors);
1606 
1607 $endif (_NTDDK_)
1608 $if (_NTIFS_)
1609 
1610 NTKERNELAPI
1611 VOID
1612 NTAPI
1613 IoAcquireVpbSpinLock(
1614   _Out_ PKIRQL Irql);
1615 
1616 NTKERNELAPI
1617 NTSTATUS
1618 NTAPI
1619 IoCheckDesiredAccess(
1620   _Inout_ PACCESS_MASK DesiredAccess,
1621   _In_ ACCESS_MASK GrantedAccess);
1622 
1623 NTKERNELAPI
1624 NTSTATUS
1625 NTAPI
1626 IoCheckEaBufferValidity(
1627   _In_ PFILE_FULL_EA_INFORMATION EaBuffer,
1628   _In_ ULONG EaLength,
1629   _Out_ PULONG ErrorOffset);
1630 
1631 NTKERNELAPI
1632 NTSTATUS
1633 NTAPI
1634 IoCheckFunctionAccess(
1635   _In_ ACCESS_MASK GrantedAccess,
1636   _In_ UCHAR MajorFunction,
1637   _In_ UCHAR MinorFunction,
1638   _In_ ULONG IoControlCode,
1639   _In_opt_ PVOID Argument1,
1640   _In_opt_ PVOID Argument2);
1641 
1642 NTKERNELAPI
1643 NTSTATUS
1644 NTAPI
1645 IoCheckQuerySetFileInformation(
1646   _In_ FILE_INFORMATION_CLASS FileInformationClass,
1647   _In_ ULONG Length,
1648   _In_ BOOLEAN SetOperation);
1649 
1650 NTKERNELAPI
1651 NTSTATUS
1652 NTAPI
1653 IoCheckQuerySetVolumeInformation(
1654   _In_ FS_INFORMATION_CLASS FsInformationClass,
1655   _In_ ULONG Length,
1656   _In_ BOOLEAN SetOperation);
1657 
1658 NTKERNELAPI
1659 NTSTATUS
1660 NTAPI
1661 IoCheckQuotaBufferValidity(
1662   _In_ PFILE_QUOTA_INFORMATION QuotaBuffer,
1663   _In_ ULONG QuotaLength,
1664   _Out_ PULONG ErrorOffset);
1665 
1666 NTKERNELAPI
1667 PFILE_OBJECT
1668 NTAPI
1669 IoCreateStreamFileObject(
1670   _In_opt_ PFILE_OBJECT FileObject,
1671   _In_opt_ PDEVICE_OBJECT DeviceObject);
1672 
1673 NTKERNELAPI
1674 PFILE_OBJECT
1675 NTAPI
1676 IoCreateStreamFileObjectLite(
1677   _In_opt_ PFILE_OBJECT FileObject,
1678   _In_opt_ PDEVICE_OBJECT DeviceObject);
1679 
1680 NTKERNELAPI
1681 BOOLEAN
1682 NTAPI
1683 IoFastQueryNetworkAttributes(
1684   _In_ POBJECT_ATTRIBUTES ObjectAttributes,
1685   _In_ ACCESS_MASK DesiredAccess,
1686   _In_ ULONG OpenOptions,
1687   _Out_ PIO_STATUS_BLOCK IoStatus,
1688   _Out_ PFILE_NETWORK_OPEN_INFORMATION Buffer);
1689 
1690 NTKERNELAPI
1691 NTSTATUS
1692 NTAPI
1693 IoPageRead(
1694   _In_ PFILE_OBJECT FileObject,
1695   _In_ PMDL Mdl,
1696   _In_ PLARGE_INTEGER Offset,
1697   _In_ PKEVENT Event,
1698   _Out_ PIO_STATUS_BLOCK IoStatusBlock);
1699 
1700 NTKERNELAPI
1701 PDEVICE_OBJECT
1702 NTAPI
1703 IoGetBaseFileSystemDeviceObject(
1704   _In_ PFILE_OBJECT FileObject);
1705 
1706 _IRQL_requires_max_(PASSIVE_LEVEL)
1707 NTKERNELAPI
1708 PCONFIGURATION_INFORMATION
1709 NTAPI
1710 IoGetConfigurationInformation(VOID);
1711 
1712 NTKERNELAPI
1713 ULONG
1714 NTAPI
1715 IoGetRequestorProcessId(
1716   _In_ PIRP Irp);
1717 
1718 NTKERNELAPI
1719 PEPROCESS
1720 NTAPI
1721 IoGetRequestorProcess(
1722   _In_ PIRP Irp);
1723 
1724 NTKERNELAPI
1725 PIRP
1726 NTAPI
1727 IoGetTopLevelIrp(VOID);
1728 
1729 NTKERNELAPI
1730 BOOLEAN
1731 NTAPI
1732 IoIsOperationSynchronous(
1733   _In_ PIRP Irp);
1734 
1735 NTKERNELAPI
1736 BOOLEAN
1737 NTAPI
1738 IoIsSystemThread(
1739   _In_ PETHREAD Thread);
1740 
1741 NTKERNELAPI
1742 BOOLEAN
1743 NTAPI
1744 IoIsValidNameGraftingBuffer(
1745   _In_ PIRP Irp,
1746   _In_ PREPARSE_DATA_BUFFER ReparseBuffer);
1747 
1748 NTKERNELAPI
1749 NTSTATUS
1750 NTAPI
1751 IoQueryFileInformation(
1752   _In_ PFILE_OBJECT FileObject,
1753   _In_ FILE_INFORMATION_CLASS FileInformationClass,
1754   _In_ ULONG Length,
1755   _Out_ PVOID FileInformation,
1756   _Out_ PULONG ReturnedLength);
1757 
1758 NTKERNELAPI
1759 NTSTATUS
1760 NTAPI
1761 IoQueryVolumeInformation(
1762   _In_ PFILE_OBJECT FileObject,
1763   _In_ FS_INFORMATION_CLASS FsInformationClass,
1764   _In_ ULONG Length,
1765   _Out_ PVOID FsInformation,
1766   _Out_ PULONG ReturnedLength);
1767 
1768 NTKERNELAPI
1769 VOID
1770 NTAPI
1771 IoQueueThreadIrp(
1772   _In_ PIRP Irp);
1773 
1774 NTKERNELAPI
1775 VOID
1776 NTAPI
1777 IoRegisterFileSystem(
1778   _In_ __drv_aliasesMem PDEVICE_OBJECT DeviceObject);
1779 
1780 NTKERNELAPI
1781 NTSTATUS
1782 NTAPI
1783 IoRegisterFsRegistrationChange(
1784   _In_ PDRIVER_OBJECT DriverObject,
1785   _In_ PDRIVER_FS_NOTIFICATION DriverNotificationRoutine);
1786 
1787 NTKERNELAPI
1788 VOID
1789 NTAPI
1790 IoReleaseVpbSpinLock(
1791   _In_ KIRQL Irql);
1792 
1793 NTKERNELAPI
1794 VOID
1795 NTAPI
1796 IoSetDeviceToVerify(
1797   _In_ PETHREAD Thread,
1798   _In_opt_ PDEVICE_OBJECT DeviceObject);
1799 
1800 NTKERNELAPI
1801 NTSTATUS
1802 NTAPI
1803 IoSetInformation(
1804   _In_ PFILE_OBJECT FileObject,
1805   _In_ FILE_INFORMATION_CLASS FileInformationClass,
1806   _In_ ULONG Length,
1807   _In_ PVOID FileInformation);
1808 
1809 NTKERNELAPI
1810 VOID
1811 NTAPI
1812 IoSetTopLevelIrp(
1813   _In_opt_ PIRP Irp);
1814 
1815 NTKERNELAPI
1816 NTSTATUS
1817 NTAPI
1818 IoSynchronousPageWrite(
1819   _In_ PFILE_OBJECT FileObject,
1820   _In_ PMDL Mdl,
1821   _In_ PLARGE_INTEGER FileOffset,
1822   _In_ PKEVENT Event,
1823   _Out_ PIO_STATUS_BLOCK IoStatusBlock);
1824 
1825 NTKERNELAPI
1826 PEPROCESS
1827 NTAPI
1828 IoThreadToProcess(
1829   _In_ PETHREAD Thread);
1830 
1831 NTKERNELAPI
1832 VOID
1833 NTAPI
1834 IoUnregisterFileSystem(
1835   _In_ PDEVICE_OBJECT DeviceObject);
1836 
1837 NTKERNELAPI
1838 VOID
1839 NTAPI
1840 IoUnregisterFsRegistrationChange(
1841   _In_ PDRIVER_OBJECT DriverObject,
1842   _In_ PDRIVER_FS_NOTIFICATION DriverNotificationRoutine);
1843 
1844 NTKERNELAPI
1845 NTSTATUS
1846 NTAPI
1847 IoVerifyVolume(
1848   _In_ PDEVICE_OBJECT DeviceObject,
1849   _In_ BOOLEAN AllowRawMount);
1850 
1851 NTKERNELAPI
1852 NTSTATUS
1853 NTAPI
1854 IoGetRequestorSessionId(
1855   _In_ PIRP Irp,
1856   _Out_ PULONG pSessionId);
1857 $endif (_NTIFS_)
1858 
1859 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
1860 
1861 $if (_NTDDK_)
1862 #if (NTDDI_VERSION >= NTDDI_WIN2KSP3)
1863 
1864 NTKERNELAPI
1865 BOOLEAN
1866 NTAPI
1867 IoIsFileOriginRemote(
1868   _In_ PFILE_OBJECT FileObject);
1869 
1870 NTKERNELAPI
1871 NTSTATUS
1872 NTAPI
1873 IoSetFileOrigin(
1874   _In_ PFILE_OBJECT FileObject,
1875   _In_ BOOLEAN Remote);
1876 
1877 #endif /* (NTDDI_VERSION >= NTDDI_WIN2KSP3) */
1878 $endif (_NTDDK_)
1879 
1880 #if (NTDDI_VERSION >= NTDDI_WINXP)
1881 
1882 $if (_WDMDDK_)
1883 NTKERNELAPI
1884 NTSTATUS
1885 NTAPI
1886 IoCsqInitialize(
1887   _Out_ PIO_CSQ Csq,
1888   _In_ PIO_CSQ_INSERT_IRP CsqInsertIrp,
1889   _In_ PIO_CSQ_REMOVE_IRP CsqRemoveIrp,
1890   _In_ PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp,
1891   _In_ PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock,
1892   _In_ PIO_CSQ_RELEASE_LOCK CsqReleaseLock,
1893   _In_ PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp);
1894 
1895 NTKERNELAPI
1896 VOID
1897 NTAPI
1898 IoCsqInsertIrp(
1899   _Inout_ PIO_CSQ Csq,
1900   _Inout_ PIRP Irp,
1901   _Out_opt_ PIO_CSQ_IRP_CONTEXT Context);
1902 
1903 NTKERNELAPI
1904 PIRP
1905 NTAPI
1906 IoCsqRemoveIrp(
1907   _Inout_ PIO_CSQ Csq,
1908   _Inout_ PIO_CSQ_IRP_CONTEXT Context);
1909 
1910 NTKERNELAPI
1911 PIRP
1912 NTAPI
1913 IoCsqRemoveNextIrp(
1914   _Inout_ PIO_CSQ Csq,
1915   _In_opt_ PVOID PeekContext);
1916 
1917 NTKERNELAPI
1918 BOOLEAN
1919 NTAPI
1920 IoForwardIrpSynchronously(
1921   _In_ PDEVICE_OBJECT DeviceObject,
1922   _In_ PIRP Irp);
1923 
1924 #define IoForwardAndCatchIrp IoForwardIrpSynchronously
1925 
1926 NTKERNELAPI
1927 VOID
1928 NTAPI
1929 IoFreeErrorLogEntry(
1930   _In_ PVOID ElEntry);
1931 
1932 _IRQL_requires_max_(DISPATCH_LEVEL)
1933 _Must_inspect_result_
1934 NTKERNELAPI
1935 NTSTATUS
1936 NTAPI
1937 IoSetCompletionRoutineEx(
1938   _In_ PDEVICE_OBJECT DeviceObject,
1939   _In_ PIRP Irp,
1940   _In_ PIO_COMPLETION_ROUTINE CompletionRoutine,
1941   _In_opt_ PVOID Context,
1942   _In_ BOOLEAN InvokeOnSuccess,
1943   _In_ BOOLEAN InvokeOnError,
1944   _In_ BOOLEAN InvokeOnCancel);
1945 
1946 VOID
1947 NTAPI
1948 IoSetStartIoAttributes(
1949   _In_ PDEVICE_OBJECT DeviceObject,
1950   _In_ BOOLEAN DeferredStartIo,
1951   _In_ BOOLEAN NonCancelable);
1952 
1953 NTKERNELAPI
1954 NTSTATUS
1955 NTAPI
1956 IoWMIDeviceObjectToInstanceName(
1957   _In_ PVOID DataBlockObject,
1958   _In_ PDEVICE_OBJECT DeviceObject,
1959   _Out_ PUNICODE_STRING InstanceName);
1960 
1961 NTKERNELAPI
1962 NTSTATUS
1963 NTAPI
1964 IoWMIExecuteMethod(
1965   _In_ PVOID DataBlockObject,
1966   _In_ PUNICODE_STRING InstanceName,
1967   _In_ ULONG MethodId,
1968   _In_ ULONG InBufferSize,
1969   _Inout_ PULONG OutBufferSize,
1970   _Inout_updates_bytes_to_opt_(*OutBufferSize, InBufferSize) PUCHAR InOutBuffer);
1971 
1972 NTKERNELAPI
1973 NTSTATUS
1974 NTAPI
1975 IoWMIHandleToInstanceName(
1976   _In_ PVOID DataBlockObject,
1977   _In_ HANDLE FileHandle,
1978   _Out_ PUNICODE_STRING InstanceName);
1979 
1980 NTKERNELAPI
1981 NTSTATUS
1982 NTAPI
1983 IoWMIOpenBlock(
1984   _In_ LPCGUID DataBlockGuid,
1985   _In_ ULONG DesiredAccess,
1986   _Out_ PVOID *DataBlockObject);
1987 
1988 NTKERNELAPI
1989 NTSTATUS
1990 NTAPI
1991 IoWMIQueryAllData(
1992   _In_ PVOID DataBlockObject,
1993   _Inout_ ULONG *InOutBufferSize,
1994   _Out_writes_bytes_opt_(*InOutBufferSize) PVOID OutBuffer);
1995 
1996 NTKERNELAPI
1997 NTSTATUS
1998 NTAPI
1999 IoWMIQueryAllDataMultiple(
2000   _In_reads_(ObjectCount) PVOID *DataBlockObjectList,
2001   _In_ ULONG ObjectCount,
2002   _Inout_ ULONG *InOutBufferSize,
2003   _Out_writes_bytes_opt_(*InOutBufferSize) PVOID OutBuffer);
2004 
2005 NTKERNELAPI
2006 NTSTATUS
2007 NTAPI
2008 IoWMIQuerySingleInstance(
2009   _In_ PVOID DataBlockObject,
2010   _In_ PUNICODE_STRING InstanceName,
2011   _Inout_ ULONG *InOutBufferSize,
2012   _Out_writes_bytes_opt_(*InOutBufferSize) PVOID OutBuffer);
2013 
2014 NTKERNELAPI
2015 NTSTATUS
2016 NTAPI
2017 IoWMISetNotificationCallback(
2018   _Inout_ PVOID Object,
2019   _In_ WMI_NOTIFICATION_CALLBACK Callback,
2020   _In_opt_ PVOID Context);
2021 
2022 NTKERNELAPI
2023 NTSTATUS
2024 NTAPI
2025 IoWMISetSingleInstance(
2026   _In_ PVOID DataBlockObject,
2027   _In_ PUNICODE_STRING InstanceName,
2028   _In_ ULONG Version,
2029   _In_ ULONG ValueBufferSize,
2030   _In_reads_bytes_(ValueBufferSize) PVOID ValueBuffer);
2031 
2032 NTKERNELAPI
2033 NTSTATUS
2034 NTAPI
2035 IoWMISetSingleItem(
2036   _In_ PVOID DataBlockObject,
2037   _In_ PUNICODE_STRING InstanceName,
2038   _In_ ULONG DataItemId,
2039   _In_ ULONG Version,
2040   _In_ ULONG ValueBufferSize,
2041   _In_reads_bytes_(ValueBufferSize) PVOID ValueBuffer);
2042 $endif (_WDMDDK_)
2043 $if (_NTDDK_)
2044 _IRQL_requires_max_(PASSIVE_LEVEL)
2045 NTKERNELAPI
2046 NTSTATUS
2047 FASTCALL
2048 IoReadPartitionTable(
2049   _In_ PDEVICE_OBJECT DeviceObject,
2050   _In_ ULONG SectorSize,
2051   _In_ BOOLEAN ReturnRecognizedPartitions,
2052   _Out_ struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer);
2053 
2054 _IRQL_requires_max_(PASSIVE_LEVEL)
2055 NTKERNELAPI
2056 NTSTATUS
2057 FASTCALL
2058 IoSetPartitionInformation(
2059   _In_ PDEVICE_OBJECT DeviceObject,
2060   _In_ ULONG SectorSize,
2061   _In_ ULONG PartitionNumber,
2062   _In_ ULONG PartitionType);
2063 
2064 _IRQL_requires_max_(PASSIVE_LEVEL)
2065 NTKERNELAPI
2066 NTSTATUS
2067 FASTCALL
2068 IoWritePartitionTable(
2069   _In_ PDEVICE_OBJECT DeviceObject,
2070   _In_ ULONG SectorSize,
2071   _In_ ULONG SectorsPerTrack,
2072   _In_ ULONG NumberOfHeads,
2073   _In_ struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer);
2074 
2075 NTKERNELAPI
2076 NTSTATUS
2077 NTAPI
2078 IoCreateDisk(
2079   _In_ PDEVICE_OBJECT DeviceObject,
2080   _In_opt_ struct _CREATE_DISK* Disk);
2081 
2082 NTKERNELAPI
2083 NTSTATUS
2084 NTAPI
2085 IoReadDiskSignature(
2086   _In_ PDEVICE_OBJECT DeviceObject,
2087   _In_ ULONG BytesPerSector,
2088   _Out_ PDISK_SIGNATURE Signature);
2089 
2090 _IRQL_requires_max_(PASSIVE_LEVEL)
2091 NTKERNELAPI
2092 NTSTATUS
2093 NTAPI
2094 IoReadPartitionTableEx(
2095   _In_ PDEVICE_OBJECT DeviceObject,
2096   _Out_ struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer);
2097 
2098 _IRQL_requires_max_(PASSIVE_LEVEL)
2099 NTKERNELAPI
2100 NTSTATUS
2101 NTAPI
2102 IoSetPartitionInformationEx(
2103   _In_ PDEVICE_OBJECT DeviceObject,
2104   _In_ ULONG PartitionNumber,
2105   _In_ struct _SET_PARTITION_INFORMATION_EX *PartitionInfo);
2106 
2107 NTKERNELAPI
2108 NTSTATUS
2109 NTAPI
2110 IoSetSystemPartition(
2111   _In_ PUNICODE_STRING VolumeNameString);
2112 
2113 NTKERNELAPI
2114 NTSTATUS
2115 NTAPI
2116 IoVerifyPartitionTable(
2117   _In_ PDEVICE_OBJECT DeviceObject,
2118   _In_ BOOLEAN FixErrors);
2119 
2120 NTKERNELAPI
2121 NTSTATUS
2122 NTAPI
2123 IoVolumeDeviceToDosName(
2124   _In_ PVOID VolumeDeviceObject,
2125   _Out_ _When_(return==0,
2126     _At_(DosName->Buffer, __drv_allocatesMem(Mem)))
2127     PUNICODE_STRING DosName);
2128 
2129 _IRQL_requires_max_(PASSIVE_LEVEL)
2130 NTKERNELAPI
2131 NTSTATUS
2132 NTAPI
2133 IoWritePartitionTableEx(
2134   _In_ PDEVICE_OBJECT DeviceObject,
2135   _In_reads_(_Inexpressible_(FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION_EX, PartitionEntry[0])))
2136     struct _DRIVE_LAYOUT_INFORMATION_EX *DriveLayout);
2137 
2138 NTKERNELAPI
2139 NTSTATUS
2140 NTAPI
2141 IoCreateFileSpecifyDeviceObjectHint(
2142   _Out_ PHANDLE FileHandle,
2143   _In_ ACCESS_MASK DesiredAccess,
2144   _In_ POBJECT_ATTRIBUTES ObjectAttributes,
2145   _Out_ PIO_STATUS_BLOCK IoStatusBlock,
2146   _In_opt_ PLARGE_INTEGER AllocationSize,
2147   _In_ ULONG FileAttributes,
2148   _In_ ULONG ShareAccess,
2149   _In_ ULONG Disposition,
2150   _In_ ULONG CreateOptions,
2151   _In_opt_ PVOID EaBuffer,
2152   _In_ ULONG EaLength,
2153   _In_ CREATE_FILE_TYPE CreateFileType,
2154   _In_opt_ PVOID InternalParameters,
2155   _In_ ULONG Options,
2156   _In_opt_ PVOID DeviceObject);
2157 
2158 NTKERNELAPI
2159 NTSTATUS
2160 NTAPI
2161 IoAttachDeviceToDeviceStackSafe(
2162   _In_ PDEVICE_OBJECT SourceDevice,
2163   _In_ PDEVICE_OBJECT TargetDevice,
2164   _Outptr_ PDEVICE_OBJECT *AttachedToDeviceObject);
2165 
2166 $endif (_NTDDK_)
2167 $if (_NTIFS_)
2168 
2169 NTKERNELAPI
2170 PFILE_OBJECT
2171 NTAPI
2172 IoCreateStreamFileObjectEx(
2173   _In_opt_ PFILE_OBJECT FileObject,
2174   _In_opt_ PDEVICE_OBJECT DeviceObject,
2175   _Out_opt_ PHANDLE FileObjectHandle);
2176 
2177 NTKERNELAPI
2178 NTSTATUS
2179 NTAPI
2180 IoQueryFileDosDeviceName(
2181   _In_ PFILE_OBJECT FileObject,
2182   _Out_ POBJECT_NAME_INFORMATION *ObjectNameInformation);
2183 
2184 NTKERNELAPI
2185 NTSTATUS
2186 NTAPI
2187 IoEnumerateDeviceObjectList(
2188   _In_ PDRIVER_OBJECT DriverObject,
2189   _Out_writes_bytes_to_opt_(DeviceObjectListSize,(*ActualNumberDeviceObjects)*sizeof(PDEVICE_OBJECT))
2190     PDEVICE_OBJECT *DeviceObjectList,
2191   _In_ ULONG DeviceObjectListSize,
2192   _Out_ PULONG ActualNumberDeviceObjects);
2193 
2194 NTKERNELAPI
2195 PDEVICE_OBJECT
2196 NTAPI
2197 IoGetLowerDeviceObject(
2198   _In_ PDEVICE_OBJECT DeviceObject);
2199 
2200 NTKERNELAPI
2201 PDEVICE_OBJECT
2202 NTAPI
2203 IoGetDeviceAttachmentBaseRef(
2204   _In_ PDEVICE_OBJECT DeviceObject);
2205 
2206 NTKERNELAPI
2207 NTSTATUS
2208 NTAPI
2209 IoGetDiskDeviceObject(
2210   _In_ PDEVICE_OBJECT FileSystemDeviceObject,
2211   _Out_ PDEVICE_OBJECT *DiskDeviceObject);
2212 $endif (_NTIFS_)
2213 
2214 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
2215 
2216 $if (_WDMDDK_)
2217 #if (NTDDI_VERSION >= NTDDI_WINXPSP1)
2218 NTKERNELAPI
2219 NTSTATUS
2220 NTAPI
2221 IoValidateDeviceIoControlAccess(
2222   _In_ PIRP Irp,
2223   _In_ ULONG RequiredAccess);
2224 #endif
2225 
2226 $endif (_WDMDDK_)
2227 $if (_WDMDDK_ || _NTDDK_)
2228 #if (NTDDI_VERSION >= NTDDI_WS03)
2229 $endif (_WDMDDK_ || _NTDDK_)
2230 $if (_NTDDK_)
2231 NTKERNELAPI
2232 IO_PAGING_PRIORITY
2233 FASTCALL
2234 IoGetPagingIoPriority(
2235   _In_ PIRP Irp);
2236 
2237 $endif (_NTDDK_)
2238 $if (_WDMDDK_)
2239 NTKERNELAPI
2240 NTSTATUS
2241 NTAPI
2242 IoCsqInitializeEx(
2243   _Out_ PIO_CSQ Csq,
2244   _In_ PIO_CSQ_INSERT_IRP_EX CsqInsertIrp,
2245   _In_ PIO_CSQ_REMOVE_IRP CsqRemoveIrp,
2246   _In_ PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp,
2247   _In_ PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock,
2248   _In_ PIO_CSQ_RELEASE_LOCK CsqReleaseLock,
2249   _In_ PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp);
2250 
2251 NTKERNELAPI
2252 NTSTATUS
2253 NTAPI
2254 IoCsqInsertIrpEx(
2255   _Inout_ PIO_CSQ Csq,
2256   _Inout_ PIRP Irp,
2257   _Out_opt_ PIO_CSQ_IRP_CONTEXT Context,
2258   _In_opt_ PVOID InsertContext);
2259 $endif (_WDMDDK_)
2260 $if (_WDMDDK_ || _NTDDK_)
2261 #endif /* (NTDDI_VERSION >= NTDDI_WS03) */
2262 $endif (_WDMDDK_ || _NTDDK_)
2263 $if (_NTDDK_ || _NTIFS_)
2264 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
2265 $endif (_NTDDK_ || _NTIFS_)
2266 
2267 $if (_NTDDK_)
2268 BOOLEAN
2269 NTAPI
2270 IoTranslateBusAddress(
2271   _In_ INTERFACE_TYPE InterfaceType,
2272   _In_ ULONG BusNumber,
2273   _In_ PHYSICAL_ADDRESS BusAddress,
2274   _Inout_ PULONG AddressSpace,
2275   _Out_ PPHYSICAL_ADDRESS TranslatedAddress);
2276 $endif (_NTDDK_)
2277 $if (_NTIFS_)
2278 
2279 NTKERNELAPI
2280 NTSTATUS
2281 NTAPI
2282 IoEnumerateRegisteredFiltersList(
2283   _Out_writes_bytes_to_opt_(DriverObjectListSize,(*ActualNumberDriverObjects)*sizeof(PDRIVER_OBJECT))
2284     PDRIVER_OBJECT *DriverObjectList,
2285   _In_ ULONG DriverObjectListSize,
2286   _Out_ PULONG ActualNumberDriverObjects);
2287 $endif (_NTIFS_)
2288 $if (_NTDDK_ || _NTIFS_)
2289 #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */
2290 $endif (_NTDDK_ || _NTIFS_)
2291 
2292 #if (NTDDI_VERSION >= NTDDI_VISTA)
2293 $if (_WDMDDK_)
2294 NTKERNELAPI
2295 NTSTATUS
2296 NTAPI
2297 IoGetBootDiskInformationLite(
2298   _Outptr_ PBOOTDISK_INFORMATION_LITE *BootDiskInformation);
2299 
2300 NTKERNELAPI
2301 NTSTATUS
2302 NTAPI
2303 IoCheckShareAccessEx(
2304   _In_ ACCESS_MASK DesiredAccess,
2305   _In_ ULONG DesiredShareAccess,
2306   _Inout_ PFILE_OBJECT FileObject,
2307   _Inout_ PSHARE_ACCESS ShareAccess,
2308   _In_ BOOLEAN Update,
2309   _In_ PBOOLEAN WritePermission);
2310 
2311 NTKERNELAPI
2312 NTSTATUS
2313 NTAPI
2314 IoConnectInterruptEx(
2315   _Inout_ PIO_CONNECT_INTERRUPT_PARAMETERS Parameters);
2316 
2317 NTKERNELAPI
2318 VOID
2319 NTAPI
2320 IoDisconnectInterruptEx(
2321   _In_ PIO_DISCONNECT_INTERRUPT_PARAMETERS Parameters);
2322 
2323 LOGICAL
2324 NTAPI
2325 IoWithinStackLimits(
2326   _In_ ULONG_PTR RegionStart,
2327   _In_ SIZE_T RegionSize);
2328 
2329 NTKERNELAPI
2330 VOID
2331 NTAPI
2332 IoSetShareAccessEx(
2333   _In_ ACCESS_MASK DesiredAccess,
2334   _In_ ULONG DesiredShareAccess,
2335   _Inout_ PFILE_OBJECT FileObject,
2336   _Out_ PSHARE_ACCESS ShareAccess,
2337   _In_ PBOOLEAN WritePermission);
2338 
2339 ULONG
2340 NTAPI
2341 IoSizeofWorkItem(VOID);
2342 
2343 VOID
2344 NTAPI
2345 IoInitializeWorkItem(
2346   _In_ PVOID IoObject,
2347   _Out_ PIO_WORKITEM IoWorkItem);
2348 
2349 VOID
2350 NTAPI
2351 IoUninitializeWorkItem(
2352   _Inout_ PIO_WORKITEM IoWorkItem);
2353 
2354 _IRQL_requires_max_(DISPATCH_LEVEL)
2355 NTKRNLVISTAAPI
2356 VOID
2357 NTAPI
2358 IoQueueWorkItemEx(
2359   _Inout_ PIO_WORKITEM IoWorkItem,
2360   _In_ PIO_WORKITEM_ROUTINE_EX WorkerRoutine,
2361   _In_ WORK_QUEUE_TYPE QueueType,
2362   _In_opt_ __drv_aliasesMem PVOID Context);
2363 
2364 NTKRNLVISTAAPI
2365 IO_PRIORITY_HINT
2366 NTAPI
2367 IoGetIoPriorityHint(
2368   _In_ PIRP Irp);
2369 
2370 NTSTATUS
2371 NTAPI
2372 IoSetIoPriorityHint(
2373   _In_ PIRP Irp,
2374   _In_ IO_PRIORITY_HINT PriorityHint);
2375 
2376 NTSTATUS
2377 NTAPI
2378 IoAllocateSfioStreamIdentifier(
2379   _In_ PFILE_OBJECT FileObject,
2380   _In_ ULONG Length,
2381   _In_ PVOID Signature,
2382   _Out_ PVOID *StreamIdentifier);
2383 
2384 PVOID
2385 NTAPI
2386 IoGetSfioStreamIdentifier(
2387   _In_ PFILE_OBJECT FileObject,
2388   _In_ PVOID Signature);
2389 
2390 NTSTATUS
2391 NTAPI
2392 IoFreeSfioStreamIdentifier(
2393   _In_ PFILE_OBJECT FileObject,
2394   _In_ PVOID Signature);
2395 
2396 _IRQL_requires_max_(DISPATCH_LEVEL)
2397 _Must_inspect_result_
2398 NTKERNELAPI
2399 NTSTATUS
2400 NTAPI
2401 IoRequestDeviceEjectEx(
2402   _In_ PDEVICE_OBJECT PhysicalDeviceObject,
2403   _In_opt_ PIO_DEVICE_EJECT_CALLBACK Callback,
2404   _In_opt_ PVOID Context,
2405   _In_opt_ PDRIVER_OBJECT DriverObject);
2406 
2407 _IRQL_requires_max_(PASSIVE_LEVEL)
2408 _Must_inspect_result_
2409 NTKRNLVISTAAPI
2410 NTSTATUS
2411 NTAPI
2412 IoSetDevicePropertyData(
2413   _In_ PDEVICE_OBJECT Pdo,
2414   _In_ CONST DEVPROPKEY *PropertyKey,
2415   _In_ LCID Lcid,
2416   _In_ ULONG Flags,
2417   _In_ DEVPROPTYPE Type,
2418   _In_ ULONG Size,
2419   _In_opt_ PVOID Data);
2420 
2421 _IRQL_requires_max_(PASSIVE_LEVEL)
2422 _Must_inspect_result_
2423 NTKRNLVISTAAPI
2424 NTSTATUS
2425 NTAPI
2426 IoGetDevicePropertyData(
2427   _In_ PDEVICE_OBJECT Pdo,
2428   _In_ CONST DEVPROPKEY *PropertyKey,
2429   _In_ LCID Lcid,
2430   _Reserved_ ULONG Flags,
2431   _In_ ULONG Size,
2432   _Out_ PVOID Data,
2433   _Out_ PULONG RequiredSize,
2434   _Out_ PDEVPROPTYPE Type);
2435 
2436 $endif (_WDMDDK_)
2437 $if (_NTDDK_)
2438 NTKERNELAPI
2439 NTSTATUS
2440 NTAPI
2441 IoUpdateDiskGeometry(
2442   _In_ PDEVICE_OBJECT DeviceObject,
2443   _In_ struct _DISK_GEOMETRY_EX* OldDiskGeometry,
2444   _In_ struct _DISK_GEOMETRY_EX* NewDiskGeometry);
2445 
2446 PTXN_PARAMETER_BLOCK
2447 NTAPI
2448 IoGetTransactionParameterBlock(
2449   _In_ PFILE_OBJECT FileObject);
2450 
2451 NTKERNELAPI
2452 NTSTATUS
2453 NTAPI
2454 IoCreateFileEx(
2455   _Out_ PHANDLE FileHandle,
2456   _In_ ACCESS_MASK DesiredAccess,
2457   _In_ POBJECT_ATTRIBUTES ObjectAttributes,
2458   _Out_ PIO_STATUS_BLOCK IoStatusBlock,
2459   _In_opt_ PLARGE_INTEGER AllocationSize,
2460   _In_ ULONG FileAttributes,
2461   _In_ ULONG ShareAccess,
2462   _In_ ULONG Disposition,
2463   _In_ ULONG CreateOptions,
2464   _In_opt_ PVOID EaBuffer,
2465   _In_ ULONG EaLength,
2466   _In_ CREATE_FILE_TYPE CreateFileType,
2467   _In_opt_ PVOID InternalParameters,
2468   _In_ ULONG Options,
2469   _In_opt_ PIO_DRIVER_CREATE_CONTEXT DriverContext);
2470 
2471 NTSTATUS
2472 NTAPI
2473 IoSetIrpExtraCreateParameter(
2474   _Inout_ PIRP Irp,
2475   _In_ struct _ECP_LIST *ExtraCreateParameter);
2476 
2477 VOID
2478 NTAPI
2479 IoClearIrpExtraCreateParameter(
2480   _Inout_ PIRP Irp);
2481 
2482 NTKRNLVISTAAPI
2483 NTSTATUS
2484 NTAPI
2485 IoGetIrpExtraCreateParameter(
2486   _In_ PIRP Irp,
2487   _Outptr_result_maybenull_ struct _ECP_LIST **ExtraCreateParameter);
2488 
2489 BOOLEAN
2490 NTAPI
2491 IoIsFileObjectIgnoringSharing(
2492   _In_ PFILE_OBJECT FileObject);
2493 
2494 $endif (_NTDDK_)
2495 $if (_NTIFS_)
2496 
2497 FORCEINLINE
2498 VOID
2499 NTAPI
2500 IoInitializePriorityInfo(
2501     _In_ PIO_PRIORITY_INFO PriorityInfo)
2502 {
2503     PriorityInfo->Size = sizeof(IO_PRIORITY_INFO);
2504     PriorityInfo->ThreadPriority = 0xffff;
2505     PriorityInfo->IoPriority = IoPriorityNormal;
2506     PriorityInfo->PagePriority = 0;
2507 }
2508 $endif (_NTIFS_)
2509 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
2510 
2511 $if (_WDMDDK_)
2512 #define IoCallDriverStackSafeDefault(a, b) IoCallDriver(a, b)
2513 
2514 #if (NTDDI_VERSION >= NTDDI_WS08)
2515 _IRQL_requires_max_(PASSIVE_LEVEL)
2516 _Must_inspect_result_
2517 NTKERNELAPI
2518 NTSTATUS
2519 NTAPI
2520 IoReplacePartitionUnit(
2521   _In_ PDEVICE_OBJECT TargetPdo,
2522   _In_ PDEVICE_OBJECT SparePdo,
2523   _In_ ULONG Flags);
2524 #endif
2525 
2526 $endif (_WDMDDK_)
2527 #if (NTDDI_VERSION >= NTDDI_WIN7)
2528 
2529 $if (_WDMDDK_)
2530 NTKERNELAPI
2531 NTSTATUS
2532 NTAPI
2533 IoGetAffinityInterrupt(
2534   _In_ PKINTERRUPT InterruptObject,
2535   _Out_ PGROUP_AFFINITY GroupAffinity);
2536 
2537 NTSTATUS
2538 NTAPI
2539 IoGetContainerInformation(
2540   _In_ IO_CONTAINER_INFORMATION_CLASS InformationClass,
2541   _In_opt_ PVOID ContainerObject,
2542   _Inout_updates_bytes_opt_(BufferLength) PVOID Buffer,
2543   _In_ ULONG BufferLength);
2544 
2545 NTSTATUS
2546 NTAPI
2547 IoRegisterContainerNotification(
2548   _In_ IO_CONTAINER_NOTIFICATION_CLASS NotificationClass,
2549   _In_ PIO_CONTAINER_NOTIFICATION_FUNCTION CallbackFunction,
2550   _In_reads_bytes_opt_(NotificationInformationLength) PVOID NotificationInformation,
2551   _In_ ULONG NotificationInformationLength,
2552   _Out_ PVOID CallbackRegistration);
2553 
2554 VOID
2555 NTAPI
2556 IoUnregisterContainerNotification(
2557   _In_ PVOID CallbackRegistration);
2558 
2559 _IRQL_requires_max_(PASSIVE_LEVEL)
2560 __drv_freesMem(Pool)
2561 NTKERNELAPI
2562 NTSTATUS
2563 NTAPI
2564 IoUnregisterPlugPlayNotificationEx(
2565   _In_ PVOID NotificationEntry);
2566 
2567 _IRQL_requires_max_(PASSIVE_LEVEL)
2568 _Must_inspect_result_
2569 NTKERNELAPI
2570 NTSTATUS
2571 NTAPI
2572 IoGetDeviceNumaNode(
2573   _In_ PDEVICE_OBJECT Pdo,
2574   _Out_ PUSHORT NodeNumber);
2575 
2576 $endif (_WDMDDK_)
2577 $if (_NTDDK_)
2578 NTSTATUS
2579 NTAPI
2580 IoSetFileObjectIgnoreSharing(
2581   _In_ PFILE_OBJECT FileObject);
2582 
2583 $endif (_NTDDK_)
2584 $if (_NTIFS_)
2585 
2586 NTKERNELAPI
2587 NTSTATUS
2588 NTAPI
2589 IoRegisterFsRegistrationChangeMountAware(
2590   _In_ PDRIVER_OBJECT DriverObject,
2591   _In_ PDRIVER_FS_NOTIFICATION DriverNotificationRoutine,
2592   _In_ BOOLEAN SynchronizeWithMounts);
2593 
2594 NTKERNELAPI
2595 NTSTATUS
2596 NTAPI
2597 IoReplaceFileObjectName(
2598   _In_ PFILE_OBJECT FileObject,
2599   _In_reads_bytes_(FileNameLength) PWSTR NewFileName,
2600   _In_ USHORT FileNameLength);
2601 $endif (_NTIFS_)
2602 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
2603 
2604 #if (NTDDI_VERSION >= NTDDI_WIN8)
2605 
2606 $if (_WDMDDK_)
2607 _IRQL_requires_max_(PASSIVE_LEVEL)
2608 _Must_inspect_result_
2609 NTKRNLVISTAAPI
2610 NTSTATUS
2611 IoSetDeviceInterfacePropertyData(
2612   _In_ PUNICODE_STRING SymbolicLinkName,
2613   _In_ CONST DEVPROPKEY *PropertyKey,
2614   _In_ LCID Lcid,
2615   _In_ ULONG Flags,
2616   _In_ DEVPROPTYPE Type,
2617   _In_ ULONG Size,
2618   _In_reads_bytes_opt_(Size) PVOID Data);
2619 
2620 _IRQL_requires_max_(PASSIVE_LEVEL)
2621 _Must_inspect_result_
2622 NTKERNELAPI
2623 NTSTATUS
2624 IoGetDeviceInterfacePropertyData (
2625   _In_ PUNICODE_STRING SymbolicLinkName,
2626   _In_ CONST DEVPROPKEY *PropertyKey,
2627   _In_ LCID Lcid,
2628   _Reserved_ ULONG Flags,
2629   _In_ ULONG Size,
2630   _Out_writes_bytes_to_(Size, *RequiredSize) PVOID Data,
2631   _Out_ PULONG RequiredSize,
2632   _Out_ PDEVPROPTYPE Type);
2633 $endif (_WDMDDK_)
2634 $if (_NTDDK_)
2635 
2636 NTKRNLVISTAAPI
2637 VOID
2638 IoSetMasterIrpStatus(
2639   _Inout_ PIRP MasterIrp,
2640   _In_ NTSTATUS Status);
2641 $endif (_NTDDK_)
2642 
2643 #endif /* (NTDDI_VERSION >= NTDDI_WIN8) */
2644 
2645 $if (_WDMDDK_)
2646 #if defined(_WIN64)
2647 NTKERNELAPI
2648 ULONG
2649 NTAPI
2650 IoWMIDeviceObjectToProviderId(
2651   _In_ PDEVICE_OBJECT DeviceObject);
2652 #else
2653 #define IoWMIDeviceObjectToProviderId(DeviceObject) ((ULONG)(DeviceObject))
2654 #endif
2655 
2656 /*
2657  * USHORT
2658  * IoSizeOfIrp(
2659  *   IN CCHAR  StackSize)
2660  */
2661 #define IoSizeOfIrp(_StackSize) \
2662   ((USHORT) (sizeof(IRP) + ((_StackSize) * (sizeof(IO_STACK_LOCATION)))))
2663 
2664 FORCEINLINE
2665 VOID
2666 IoSkipCurrentIrpStackLocation(
2667   _Inout_ PIRP Irp)
2668 {
2669   ASSERT(Irp->CurrentLocation <= Irp->StackCount);
2670   Irp->CurrentLocation++;
2671 #ifdef NONAMELESSUNION
2672   Irp->Tail.Overlay.s.u.CurrentStackLocation++;
2673 #else
2674   Irp->Tail.Overlay.CurrentStackLocation++;
2675 #endif
2676 }
2677 
2678 FORCEINLINE
2679 VOID
2680 IoSetNextIrpStackLocation(
2681   _Inout_ PIRP Irp)
2682 {
2683   ASSERT(Irp->CurrentLocation > 0);
2684   Irp->CurrentLocation--;
2685 #ifdef NONAMELESSUNION
2686   Irp->Tail.Overlay.s.u.CurrentStackLocation--;
2687 #else
2688   Irp->Tail.Overlay.CurrentStackLocation--;
2689 #endif
2690 }
2691 
2692 __drv_aliasesMem
2693 FORCEINLINE
2694 PIO_STACK_LOCATION
2695 IoGetNextIrpStackLocation(
2696   _In_ PIRP Irp)
2697 {
2698   ASSERT(Irp->CurrentLocation > 0);
2699 #ifdef NONAMELESSUNION
2700   return ((Irp)->Tail.Overlay.s.u.CurrentStackLocation - 1 );
2701 #else
2702   return ((Irp)->Tail.Overlay.CurrentStackLocation - 1 );
2703 #endif
2704 }
2705 
2706 _IRQL_requires_max_(DISPATCH_LEVEL)
2707 FORCEINLINE
2708 VOID
2709 IoSetCompletionRoutine(
2710   _In_ PIRP Irp,
2711   _In_opt_ PIO_COMPLETION_ROUTINE CompletionRoutine,
2712   _In_opt_ __drv_aliasesMem PVOID Context,
2713   _In_ BOOLEAN InvokeOnSuccess,
2714   _In_ BOOLEAN InvokeOnError,
2715   _In_ BOOLEAN InvokeOnCancel)
2716 {
2717   PIO_STACK_LOCATION irpSp;
2718   ASSERT( (InvokeOnSuccess || InvokeOnError || InvokeOnCancel) ? (CompletionRoutine != NULL) : TRUE );
2719   irpSp = IoGetNextIrpStackLocation(Irp);
2720   irpSp->CompletionRoutine = CompletionRoutine;
2721   irpSp->Context = Context;
2722   irpSp->Control = 0;
2723 
2724   if (InvokeOnSuccess) {
2725     irpSp->Control = SL_INVOKE_ON_SUCCESS;
2726   }
2727 
2728   if (InvokeOnError) {
2729     irpSp->Control |= SL_INVOKE_ON_ERROR;
2730   }
2731 
2732   if (InvokeOnCancel) {
2733     irpSp->Control |= SL_INVOKE_ON_CANCEL;
2734   }
2735 }
2736 
2737 _IRQL_requires_max_(DISPATCH_LEVEL)
2738 _Ret_maybenull_
2739 FORCEINLINE
2740 PDRIVER_CANCEL
2741 IoSetCancelRoutine(
2742     _Inout_ PIRP Irp,
2743     _In_opt_ PDRIVER_CANCEL CancelRoutine)
2744 {
2745     return (PDRIVER_CANCEL)(ULONG_PTR) InterlockedExchangePointer((PVOID *)&(Irp)->CancelRoutine, (PVOID)(ULONG_PTR)(CancelRoutine));
2746 }
2747 
2748 FORCEINLINE
2749 VOID
2750 IoRequestDpc(
2751     _Inout_ PDEVICE_OBJECT DeviceObject,
2752     _In_opt_ PIRP Irp,
2753     _In_opt_ __drv_aliasesMem PVOID Context)
2754 {
2755     KeInsertQueueDpc(&DeviceObject->Dpc, Irp, Context);
2756 }
2757 
2758 /*
2759  * VOID
2760  * IoReleaseRemoveLock(
2761  *   IN PIO_REMOVE_LOCK  RemoveLock,
2762  *   IN PVOID  Tag)
2763  */
2764 #define IoReleaseRemoveLock(_RemoveLock, \
2765                             _Tag) \
2766   IoReleaseRemoveLockEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK))
2767 
2768 /*
2769  * VOID
2770  * IoReleaseRemoveLockAndWait(
2771  *   IN PIO_REMOVE_LOCK  RemoveLock,
2772  *   IN PVOID  Tag)
2773  */
2774 #define IoReleaseRemoveLockAndWait(_RemoveLock, \
2775                                    _Tag) \
2776   IoReleaseRemoveLockAndWaitEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK))
2777 
2778 #if defined(_WIN64)
2779 _IRQL_requires_max_(DISPATCH_LEVEL)
2780 NTKERNELAPI
2781 BOOLEAN
2782 IoIs32bitProcess(
2783   _In_opt_ PIRP Irp);
2784 #endif
2785 
2786 #define PLUGPLAY_REGKEY_DEVICE                            1
2787 #define PLUGPLAY_REGKEY_DRIVER                            2
2788 #define PLUGPLAY_REGKEY_CURRENT_HWPROFILE                 4
2789 
2790 __drv_aliasesMem
2791 FORCEINLINE
2792 PIO_STACK_LOCATION
2793 IoGetCurrentIrpStackLocation(
2794   _In_ PIRP Irp)
2795 {
2796   ASSERT(Irp->CurrentLocation <= Irp->StackCount + 1);
2797 #ifdef NONAMELESSUNION
2798   return Irp->Tail.Overlay.s.u.CurrentStackLocation;
2799 #else
2800   return Irp->Tail.Overlay.CurrentStackLocation;
2801 #endif
2802 }
2803 
2804 FORCEINLINE
2805 VOID
2806 IoMarkIrpPending(
2807   _Inout_ PIRP Irp)
2808 {
2809     IoGetCurrentIrpStackLocation((Irp))->Control |= SL_PENDING_RETURNED;
2810 }
2811 
2812 /*
2813  * BOOLEAN
2814  * IoIsErrorUserInduced(
2815  *   IN NTSTATUS  Status);
2816  */
2817 #define IoIsErrorUserInduced(Status) \
2818    ((BOOLEAN)(((Status) == STATUS_DEVICE_NOT_READY) || \
2819    ((Status) == STATUS_IO_TIMEOUT) || \
2820    ((Status) == STATUS_MEDIA_WRITE_PROTECTED) || \
2821    ((Status) == STATUS_NO_MEDIA_IN_DEVICE) || \
2822    ((Status) == STATUS_VERIFY_REQUIRED) || \
2823    ((Status) == STATUS_UNRECOGNIZED_MEDIA) || \
2824    ((Status) == STATUS_WRONG_VOLUME)))
2825 
2826 /* VOID
2827  * IoInitializeRemoveLock(
2828  *   IN PIO_REMOVE_LOCK  Lock,
2829  *   IN ULONG  AllocateTag,
2830  *   IN ULONG  MaxLockedMinutes,
2831  *   IN ULONG  HighWatermark)
2832  */
2833 #define IoInitializeRemoveLock( \
2834   Lock, AllocateTag, MaxLockedMinutes, HighWatermark) \
2835   IoInitializeRemoveLockEx(Lock, AllocateTag, MaxLockedMinutes, \
2836     HighWatermark, sizeof(IO_REMOVE_LOCK))
2837 
2838 FORCEINLINE
2839 VOID
2840 IoInitializeDpcRequest(
2841   _In_ PDEVICE_OBJECT DeviceObject,
2842   _In_ PIO_DPC_ROUTINE DpcRoutine)
2843 {
2844 #ifdef _MSC_VER
2845 #pragma warning(push)
2846 #pragma warning(disable:28024)
2847 #endif
2848   KeInitializeDpc(&DeviceObject->Dpc,
2849                   (PKDEFERRED_ROUTINE) DpcRoutine,
2850                   DeviceObject);
2851 #ifdef _MSC_VER
2852 #pragma warning(pop)
2853 #endif
2854 }
2855 
2856 #define DEVICE_INTERFACE_INCLUDE_NONACTIVE 0x00000001
2857 
2858 /*
2859  * ULONG
2860  * IoGetFunctionCodeFromCtlCode(
2861  *   IN ULONG  ControlCode)
2862  */
2863 #define IoGetFunctionCodeFromCtlCode(_ControlCode) \
2864   (((_ControlCode) >> 2) & 0x00000FFF)
2865 
2866 FORCEINLINE
2867 VOID
2868 IoCopyCurrentIrpStackLocationToNext(
2869     _Inout_ PIRP Irp)
2870 {
2871     PIO_STACK_LOCATION irpSp;
2872     PIO_STACK_LOCATION nextIrpSp;
2873     irpSp = IoGetCurrentIrpStackLocation(Irp);
2874     nextIrpSp = IoGetNextIrpStackLocation(Irp);
2875     RtlCopyMemory(nextIrpSp, irpSp, FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine));
2876     nextIrpSp->Control = 0;
2877 }
2878 
2879 _IRQL_requires_max_(APC_LEVEL)
2880 NTKERNELAPI
2881 VOID
2882 NTAPI
2883 IoGetStackLimits(
2884   _Out_ PULONG_PTR LowLimit,
2885   _Out_ PULONG_PTR HighLimit);
2886 
2887 _IRQL_requires_max_(APC_LEVEL)
2888 FORCEINLINE
2889 ULONG_PTR
2890 IoGetRemainingStackSize(VOID)
2891 {
2892     ULONG_PTR End, Begin;
2893     ULONG_PTR Result;
2894 
2895     IoGetStackLimits(&Begin, &End);
2896     Result = (ULONG_PTR)(&End) - Begin;
2897     return Result;
2898 }
2899 
2900 #if (NTDDI_VERSION >= NTDDI_WS03)
2901 FORCEINLINE
2902 VOID
2903 IoInitializeThreadedDpcRequest(
2904     _In_ PDEVICE_OBJECT DeviceObject,
2905     _In_ PIO_DPC_ROUTINE DpcRoutine)
2906 {
2907 #ifdef _MSC_VER
2908 #pragma warning(push)
2909 #pragma warning(disable:28024)
2910 #pragma warning(disable:28128)
2911 #endif
2912     KeInitializeThreadedDpc(&DeviceObject->Dpc,
2913                             (PKDEFERRED_ROUTINE) DpcRoutine,
2914                             DeviceObject );
2915 #ifdef _MSC_VER
2916 #pragma warning(pop)
2917 #endif
2918 }
2919 #endif
2920 
2921 $endif (_WDMDDK_)
2922