Catched STDCALL IRP (*CompletionRoutine)() and (*CancelRoutine)().
[reactos.git] / include / ddk / iofuncs.h
1 #ifndef _INCLUDE_DDK_IOFUNCS_H
2 #define _INCLUDE_DDK_IOFUNCS_H
3 /* $Id$ */
4
5 /* --- EXPORTED BY NTOSKRNL --- */
6
7 /**********************************************************************
8  * NAME                                                 EXPORTED
9  *      IoAcquireCancelSpinLock@4
10  *      
11  * DESCRIPTION
12  *      Synchronizes cancelable-state transistions for IRPs in a 
13  *      multiprocessor-safe way.
14  *      
15  * ARGUMENTS
16  *      Irpl
17  *              Variable to store the current IRQ level.
18  *
19  * RETURN VALUE
20  *      None.
21  *
22  * REVISIONS
23  *
24  */
25 VOID
26 STDCALL
27 IoAcquireCancelSpinLock (
28         PKIRQL  Irpl
29         );
30 VOID
31 STDCALL
32 IoAcquireVpbSpinLock (
33         PKIRQL  Irpl
34         );
35 /**********************************************************************
36  * NAME                                                 EXPORTED
37  *      IoAllocateAdapterChannel@
38  *      
39  * DESCRIPTION
40  *      Allocates an adaptor object for a DMA operation on the target
41  *      device.
42  *      
43  * ARGUMENTS
44  *      Adaptor
45  *              Adapter channel or busmaster adapter to be allocated;
46  *              
47  *      DeviceObject
48  *              Target device for DMA;
49  *              
50  *      NumberOfMapRegisters
51  *              Number of map registers;
52  *              
53  *      ExecutionRoutine
54  *              Routine to be called when the adaptor is available;
55  *              
56  *      Context
57  *              Driver defined contex that will be passed to the
58  *              execution routine.
59  *              
60  * RETURN VALUE
61  *      Success or failure code.
62  *
63  * REVISIONS
64  *
65  */
66 NTSTATUS
67 STDCALL
68 IoAllocateAdapterChannel (
69         PADAPTER_OBJECT AdaperObject,
70         PDEVICE_OBJECT  DeviceObject,
71         ULONG           NumberOfMapRegisters,
72         PDRIVER_CONTROL ExecutionRoutine,
73         PVOID           Context
74         );
75 /**********************************************************************
76  * NAME                                                 EXPORTED
77  *      IoAllocateController@16
78  *
79  * DESCRIPTION
80  *      Sets up a call to a driver supplied controller object as 
81  *      soon as it is available.
82  *
83  * ARGUMENTS
84  *      ControllerObject
85  *              Driver created controller object;
86  *
87  *      DeviceObject
88  *              Target device;
89  *
90  *      ExecutionObject
91  *              Routine to be called;
92  *
93  *      Context
94  *              Driver determined context to be based to the
95  *              routine.
96  *
97  * RETURN VALUE
98  *      None.
99  *
100  * REVISIONS
101  *
102  */
103 VOID
104 STDCALL
105 IoAllocateController (
106         PCONTROLLER_OBJECT      ControllerObject,
107         PDEVICE_OBJECT          DeviceObject,
108         PDRIVER_CONTROL         ExecutionRoutine,
109         PVOID                   Context
110         );
111 /**********************************************************************
112  * NAME                                                 EXPORTED
113  *      IoAllocateErrorLogEntry@8
114  *      
115  * DESCRIPTION
116  *      Allocates an error log packet.
117  *
118  * ARGUMENTS
119  *      IoObject
120  *              Object which found the error;
121  *              
122  *      EntrySize
123  *              Size in bytes of the packet to be allocated.
124  *
125  * RETURN VALUE
126  *      On success, a pointer to the allocated packet.
127  *      On failure, it returns NULL.
128  */
129 PVOID
130 STDCALL
131 IoAllocateErrorLogEntry (
132         PVOID   IoObject,
133         UCHAR   EntrySize
134         );
135 /**********************************************************************
136  * NAME                                                 EXPORTED
137  *      IoAllocateIrp@8
138  *      
139  * DESCRIPTION
140  *      Allocates an IRP.
141  *      
142  * ARGUMENTS
143  *      StackSize
144  *              Number of stack locations to allocate;
145  *              
146  *      ChargeQuota
147  *              Who knows.
148  *              
149  * RETURN VALUE
150  *      On success, the allocated IRP. On failure, NULL.
151  */
152 PIRP
153 STDCALL
154 IoAllocateIrp (
155         CCHAR   StackSize,
156         BOOLEAN ChargeQuota
157         );
158 /**********************************************************************
159  * NAME                                                 EXPORTED
160  *      IoAllocateMdl@20
161  *
162  * DESCRIPTION
163  *      Allocates an MDL large enough to map the supplied buffer.
164  *      
165  * ARGUMENTS
166  *      VirtualAddress
167  *              Base virtual address of the buffer to be mapped;
168  *              
169  *      Length
170  *              Length of the buffer to be mapped;
171  *              
172  *      SecondaryBuffer
173  *              Whether the buffer is primary or secondary;
174  *              
175  *      ChargeQuota
176  *              Charge non-paged pool quota to current thread;
177  *              
178  *      Irp
179  *              Optional irp to be associated with the MDL.
180  *      
181  * RETURN VALUE
182  *      On success, the allocated MDL; on failure, NULL.
183  */
184 PMDL
185 STDCALL
186 IoAllocateMdl (
187         PVOID   VirtualAddress,
188         ULONG   Length,
189         BOOLEAN SecondaryBuffer,
190         BOOLEAN ChargeQuota,
191         PIRP    Irp
192         );
193
194 /**********************************************************************
195  * NAME                                                 MACRO
196  *      IoAssignArcName
197  *
198  * DESCRIPTION
199  *      Creates a symbolic link between the ARC name of a physical
200  *      device and the name of the corresponding device object
201  *
202  * ARGUMENTS
203  *      ArcName
204  *              ARC name of the device
205  *
206  *      DeviceName
207  *              Name of the device object
208  *
209  * NOTES
210  *      VOID
211  *      IoAssignArcName (
212  *              PUNICODE_STRING ArcName,
213  *              PUNICODE_STRING DeviceName
214  *              );
215  */
216 #define IoAssignArcName(ArcName,DeviceName) \
217         (IoCreateSymbolicLink((ArcName),(DeviceName)))
218
219 /**********************************************************************
220  * NAME                                                 EXPORTED
221  *      IoAssignResources@24
222  *
223  * DESCRIPTION
224  *      Takes a list of requested hardware resources and allocates
225  *      them.
226  *
227  * ARGUMENTS
228  *      RegisterPath
229  *              ?
230  *
231  *      DriverClassName
232  *              ?
233  *
234  *      DriverObject
235  *              Driver object passed to the DriverEntry routine;
236  *
237  *      DeviceObject
238  *              ?
239  *
240  *      RequestedResources
241  *              List of resources.
242  *
243  * RETURN VALUE
244  */
245 NTSTATUS
246 STDCALL
247 IoAssignResources (
248         PUNICODE_STRING                 RegistryPath,
249         PUNICODE_STRING                 DriverClassName,
250         PDRIVER_OBJECT                  DriverObject,
251         PDEVICE_OBJECT                  DeviceObject,
252         PIO_RESOURCE_REQUIREMENTS_LIST  RequestedResources,
253         PCM_RESOURCE_LIST               * AllocatedResources
254         );
255 /*
256  * FUNCTION: Attaches the callers device object to a named target device
257  * ARGUMENTS:
258  *        SourceDevice = caller's device
259  *        TargetDevice = Name of the target device
260  *        AttachedDevice = Caller allocated storage. On return contains
261  *                         a pointer to the target device
262  * RETURNS: Success or failure code
263  */
264 NTSTATUS
265 STDCALL
266 IoAttachDevice (
267         PDEVICE_OBJECT  SourceDevice,
268         PUNICODE_STRING TargetDevice,
269         PDEVICE_OBJECT  * AttachedDevice
270         );
271 /*
272  * FUNCTION: Obsolete
273  * ARGUMENTS:
274  *       SourceDevice = device to attach
275  *       TargetDevice = device to be attached to
276  * RETURNS: Success or failure code
277  */
278 NTSTATUS
279 STDCALL
280 IoAttachDeviceByPointer (
281         PDEVICE_OBJECT  SourceDevice,
282         PDEVICE_OBJECT  TargetDevice
283         );
284 /*
285  * FUNCTION: Attaches the callers device to the highest device in the chain
286  * ARGUMENTS:
287  *       SourceDevice = caller's device
288  *       TargetDevice = Device to attach
289  * RETURNS: On success the previously highest device
290  *          On failure NULL
291  */
292 PDEVICE_OBJECT
293 STDCALL
294 IoAttachDeviceToDeviceStack (
295         PDEVICE_OBJECT  SourceDevice,
296         PDEVICE_OBJECT  TargetDevice
297         );
298 /*
299  * FUNCTION: Builds a irp to be sent to lower level drivers
300  * ARGUMENTS:
301  *       MajorFunction = Major function code to be set in the IRP
302  *       DeviceObject = Next lower device object
303  *       Buffer = Buffer (only required for some major function codes)
304  *       Length = Length in bytes of the buffer 
305  *       StartingOffset = Starting offset on the target device
306  *       IoStatusBlock = Storage for status about the operation (optional)
307  * RETURNS: On success the IRP allocated
308  *          On failure NULL
309  */
310 PIRP
311 STDCALL
312 IoBuildAsynchronousFsdRequest (
313         ULONG                   MajorFunction,
314         PDEVICE_OBJECT          DeviceObject,
315         PVOID                   Buffer,
316         ULONG                   Length,
317         PLARGE_INTEGER          StartingOffset,
318         PIO_STATUS_BLOCK        IoStatusBlock
319         );
320 /*
321  * FUNCTION: Allocates and sets up an IRP for a device control request
322  * ARGUMENTS:
323  *        IoControlCode = Type of request
324  *        DeviceObject = Target device
325  *        InputBuffer = Optional input buffer to the driver
326  *        InputBufferLength = Length of the input buffer
327  *        OutputBuffer = Optional output buffer
328  *        OutputBufferLength = Length of the output buffer
329  *        InternalDeviceIoControl = TRUE if the request is internal
330  *        Event = Initialized event for the caller to wait for the request
331  *                to be completed
332  *        IoStatusBlock = I/O status block to be set when the request is
333  *                        completed
334  * RETURNS: Returns the IRP created
335  */
336 PIRP
337 STDCALL
338 IoBuildDeviceIoControlRequest (
339         ULONG                   IoControlCode,
340         PDEVICE_OBJECT          DeviceObject,
341         PVOID                   InputBuffer,
342         ULONG                   InputBufferLength,
343         PVOID                   OutputBuffer,
344         ULONG                   OutputBufferLength,
345         BOOLEAN                 InternalDeviceIoControl,
346         PKEVENT                 Event,
347         PIO_STATUS_BLOCK        IoStatusBlock
348         );
349 VOID
350 STDCALL
351 IoBuildPartialMdl (
352         PMDL    SourceMdl,
353         PMDL    TargetMdl,
354         PVOID   VirtualAddress,
355         ULONG   Length
356         );
357 PIRP
358 STDCALL
359 IoBuildSynchronousFsdRequest (
360         ULONG                   MajorFunction,
361         PDEVICE_OBJECT          DeviceObject,
362         PVOID                   Buffer,
363         ULONG                   Length,
364         PLARGE_INTEGER          StartingOffset,
365         PKEVENT                 Event,
366         PIO_STATUS_BLOCK        IoStatusBlock
367         );
368 NTSTATUS
369 STDCALL
370 IoCallDriver (
371         PDEVICE_OBJECT  DeviceObject,
372         PIRP            Irp
373         );
374 BOOLEAN
375 STDCALL
376 IoCancelIrp (
377         PIRP    Irp
378         );
379
380 NTSTATUS STDCALL
381 IoCheckDesiredAccess(IN OUT PACCESS_MASK DesiredAccess,
382                      IN ACCESS_MASK GrantedAccess);
383
384 NTSTATUS STDCALL
385 IoCheckEaBufferValidity(IN PFILE_FULL_EA_INFORMATION EaBuffer,
386                         IN ULONG EaLength,
387                         OUT PULONG ErrorOffset);
388
389 NTSTATUS STDCALL
390 IoCheckFunctionAccess(IN ACCESS_MASK GrantedAccess,
391                       IN UCHAR MajorFunction,
392                       IN UCHAR MinorFunction,
393                       IN ULONG IoControlCode,
394                       IN PFILE_INFORMATION_CLASS FileInformationClass OPTIONAL,
395                       IN PFS_INFORMATION_CLASS FsInformationClass OPTIONAL);
396
397 NTSTATUS
398 STDCALL
399 IoCheckShareAccess (
400         ACCESS_MASK     DesiredAccess,
401         ULONG           DesiredShareAccess,
402         PFILE_OBJECT    FileObject,
403         PSHARE_ACCESS   ShareAccess,
404         BOOLEAN         Update
405         );
406 VOID
407 STDCALL
408 IoCompleteRequest (
409         PIRP    Irp,
410         CCHAR   PriorityBoost
411         );
412 NTSTATUS
413 STDCALL
414 IoConnectInterrupt (
415         PKINTERRUPT             * InterruptObject,
416         PKSERVICE_ROUTINE       ServiceRoutine,
417         PVOID                   ServiceContext,
418         PKSPIN_LOCK             SpinLock,
419         ULONG                   Vector,
420         KIRQL                   Irql,
421         KIRQL                   SynchronizeIrql,
422         KINTERRUPT_MODE         InterruptMode,
423         BOOLEAN                 ShareVector,
424         KAFFINITY               ProcessorEnableMask,
425         BOOLEAN                 FloatingSave
426         );
427
428 PCONTROLLER_OBJECT
429 STDCALL
430 IoCreateController (
431         ULONG   Size
432         );
433 /*
434  * FUNCTION: Allocates memory for and intializes a device object for use for
435  * a driver
436  * ARGUMENTS:
437  *         DriverObject : Driver object passed by iomgr when the driver was
438  *                        loaded
439  *         DeviceExtensionSize : Number of bytes for the device extension
440  *         DeviceName : Unicode name of device
441  *         DeviceType : Device type
442  *         DeviceCharacteristics : Bit mask of device characteristics
443  *         Exclusive : True if only one thread can access the device at a
444  *                     time
445  * RETURNS:
446  *         Success or failure
447  *         DeviceObject : Contains a pointer to allocated device object
448  *                        if the call succeeded
449  * NOTES: See the DDK documentation for more information        
450  */
451 NTSTATUS
452 STDCALL
453 IoCreateDevice (
454         PDRIVER_OBJECT  DriverObject,
455         ULONG           DeviceExtensionSize,
456         PUNICODE_STRING DeviceName,
457         DEVICE_TYPE     DeviceType,
458         ULONG           DeviceCharacteristics,
459         BOOLEAN         Exclusive,
460         PDEVICE_OBJECT  * DeviceObject
461         );
462 NTSTATUS
463 STDCALL
464 IoCreateFile (
465         OUT     PHANDLE                 FileHandle,
466         IN      ACCESS_MASK             DesiredAccess,
467         IN      POBJECT_ATTRIBUTES      ObjectAttributes,
468         OUT     PIO_STATUS_BLOCK        IoStatusBlock,
469         IN      PLARGE_INTEGER          AllocationSize          OPTIONAL,
470         IN      ULONG                   FileAttributes,
471         IN      ULONG                   ShareAccess,
472         IN      ULONG                   CreateDisposition,
473         IN      ULONG                   CreateOptions,
474         IN      PVOID                   EaBuffer                OPTIONAL,
475         IN      ULONG                   EaLength,
476         IN      CREATE_FILE_TYPE        CreateFileType,
477         IN      PVOID                   ExtraCreateParameters   OPTIONAL,
478         IN      ULONG                   Options
479         );
480 PKEVENT
481 STDCALL
482 IoCreateNotificationEvent (
483         PUNICODE_STRING EventName,
484         PHANDLE EventHandle
485         );
486 PFILE_OBJECT
487 STDCALL
488 IoCreateStreamFileObject (
489         PFILE_OBJECT    FileObject,
490         PDEVICE_OBJECT  DeviceObject
491         );
492 NTSTATUS
493 STDCALL
494 IoCreateSymbolicLink (
495         PUNICODE_STRING SymbolicLinkName,
496         PUNICODE_STRING DeviceName
497         );
498 PKEVENT
499 STDCALL
500 IoCreateSynchronizationEvent (
501         PUNICODE_STRING EventName,
502         PHANDLE EventHandle
503         );
504 NTSTATUS
505 STDCALL
506 IoCreateUnprotectedSymbolicLink (
507         PUNICODE_STRING SymbolicLinkName,
508         PUNICODE_STRING DeviceName
509         );
510
511 /*
512  * FUNCTION:
513  *      Deletes a symbolic link between the ARC name of a physical
514  *      device and the name of the corresponding device object
515  *
516  * ARGUMENTS:
517  *      ArcName = ARC name of the device
518  *
519  * NOTES:
520  *      VOID
521  *      IoDeassignArcName (
522  *              PUNICODE_STRING ArcName
523  *              );
524  */
525 #define IoDeassignArcName(ArcName) \
526         (IoDeleteSymbolicLink((ArcName)))
527
528 VOID
529 STDCALL
530 IoDeleteController (
531         PCONTROLLER_OBJECT      ControllerObject
532         );
533 VOID
534 STDCALL
535 IoDeleteDevice (
536         PDEVICE_OBJECT  DeviceObject
537         );
538 NTSTATUS
539 STDCALL
540 IoDeleteSymbolicLink (
541         PUNICODE_STRING SymbolicLinkName
542         );
543 VOID
544 STDCALL
545 IoDetachDevice (
546         PDEVICE_OBJECT  TargetDevice
547         );
548 VOID
549 STDCALL
550 IoDisconnectInterrupt (
551         PKINTERRUPT     InterruptObject
552         );
553 VOID
554 STDCALL
555 IoEnqueueIrp (
556         PIRP    Irp
557         );
558
559 BOOLEAN STDCALL
560 IoFastQueryNetworkAttributes(IN POBJECT_ATTRIBUTES ObjectAttributes,
561                              IN ACCESS_MASK DesiredAccess,
562                              IN ULONG OpenOptions,
563                              OUT PIO_STATUS_BLOCK IoStatus,
564                              OUT PFILE_NETWORK_OPEN_INFORMATION Buffer);
565
566 VOID
567 STDCALL
568 IoFreeController (
569         PCONTROLLER_OBJECT      ControllerObject
570         );
571 VOID
572 STDCALL
573 IoFreeIrp (
574         PIRP    Irp
575         );
576 VOID
577 STDCALL
578 IoFreeMdl (
579         PMDL    Mdl
580         );
581 PDEVICE_OBJECT
582 STDCALL
583 IoGetAttachedDevice (
584         PDEVICE_OBJECT  DeviceObject
585         );
586 PDEVICE_OBJECT
587 STDCALL
588 IoGetAttachedDeviceReference (
589         PDEVICE_OBJECT  DeviceObject
590         );
591 PDEVICE_OBJECT
592 STDCALL
593 IoGetBaseFileSystemDeviceObject (
594         IN      PFILE_OBJECT    FileObject
595         );
596 PCONFIGURATION_INFORMATION
597 STDCALL
598 IoGetConfigurationInformation (
599         VOID
600         );
601
602 /*
603  * FUNCTION: Gets a pointer to the callers location in the I/O stack in
604  * the given IRP
605  * ARGUMENTS:
606  *         Irp = Points to the IRP
607  * RETURNS: A pointer to the stack location
608  *
609  * NOTES:
610  *      PIO_STACK_LOCATION
611  *      IoGetCurrentIrpStackLocation (PIRP Irp)
612  */
613 #define IoGetCurrentIrpStackLocation(Irp) \
614         ((Irp)->Tail.Overlay.CurrentStackLocation)
615
616 #define IoGetPreviousIrpStackLocation(Irp) \
617         ((Irp)->Tail.Overlay.CurrentStackLocation+1)
618
619 #define IoSetNextIrpStackLocation(Irp) { \
620   (Irp)->CurrentLocation--; \
621   (Irp)->Tail.Overlay.CurrentStackLocation--; }
622
623 #define IoCopyCurrentIrpStackLocationToNext(Irp) { \
624   PIO_STACK_LOCATION IrpSp; \
625   PIO_STACK_LOCATION NextIrpSp; \
626   IrpSp = IoGetCurrentIrpStackLocation((Irp)); \
627   NextIrpSp = IoGetNextIrpStackLocation((Irp)); \
628   RtlCopyMemory(NextIrpSp, IrpSp, \
629     FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine)); \
630   NextIrpSp->Control = 0; }
631
632 #define IoSkipCurrentIrpStackLocation(Irp) \
633   (Irp)->CurrentLocation++; \
634   (Irp)->Tail.Overlay.CurrentStackLocation++;
635
636 #define IoSetPreviousIrpStackLocation(Irp) \
637   IoSkipCurrentIrpStackLocation(Irp)
638
639 #define IoRetardCurrentIrpStackLocation(Irp) \
640   IoSkipCurrentIrpStackLocation(Irp)
641
642 struct _EPROCESS*
643 STDCALL
644 IoGetCurrentProcess (
645         VOID
646         );
647 NTSTATUS
648 STDCALL
649 IoGetDeviceObjectPointer (
650         PUNICODE_STRING ObjectName,
651         ACCESS_MASK     DesiredAccess,
652         PFILE_OBJECT    * FileObject,
653         PDEVICE_OBJECT  * DeviceObject
654         );
655 PDEVICE_OBJECT
656 STDCALL
657 IoGetDeviceToVerify (
658         struct _ETHREAD*        Thread
659         );
660 PGENERIC_MAPPING
661 STDCALL
662 IoGetFileObjectGenericMapping (
663         VOID
664         );
665
666 #define IoGetFunctionCodeFromCtlCode(ControlCode) \
667         ((ControlCode >> 2) & 0x00000FFF)
668
669 PVOID
670 STDCALL
671 IoGetInitialStack (
672         VOID
673         );
674
675 /*
676  * FUNCTION: Gives a higher level driver access to the next lower driver's 
677  * I/O stack location
678  * ARGUMENTS: 
679  *           Irp = points to the irp
680  * RETURNS: A pointer to the stack location
681  *
682  * NOTES:
683  *      PIO_STACK_LOCATION
684  *      IoGetNextIrpStackLocation (PIRP Irp)
685  */
686 #define IoGetNextIrpStackLocation(Irp) \
687         ((Irp)->Tail.Overlay.CurrentStackLocation-1)
688
689
690 PDEVICE_OBJECT
691 STDCALL
692 IoGetRelatedDeviceObject (
693         PFILE_OBJECT    FileObject
694         );
695 struct _EPROCESS*
696 STDCALL
697 IoGetRequestorProcess (
698         IN      PIRP    Irp
699         );
700
701 VOID
702 STDCALL
703 IoGetStackLimits (
704         PULONG  LowLimit,
705         PULONG  HighLimit
706         );
707
708 PIRP
709 STDCALL
710 IoGetTopLevelIrp (
711         VOID
712         );
713
714 #define IoInitializeDpcRequest(DeviceObject,DpcRoutine) \
715         (KeInitializeDpc(&(DeviceObject)->Dpc, \
716                          (PKDEFERRED_ROUTINE)(DpcRoutine), \
717                          (DeviceObject)))
718
719 /*
720  * FUNCTION: Initalizes an irp allocated by the caller
721  * ARGUMENTS:
722  *          Irp = IRP to initalize
723  *          PacketSize = Size in bytes of the IRP
724  *          StackSize = Number of stack locations in the IRP
725  */
726 VOID
727 STDCALL
728 IoInitializeIrp (
729         PIRP    Irp,
730         USHORT  PacketSize,
731         CCHAR   StackSize
732         );
733 NTSTATUS
734 STDCALL
735 IoInitializeTimer (
736         PDEVICE_OBJECT          DeviceObject,
737         PIO_TIMER_ROUTINE       TimerRoutine,
738         PVOID                   Context
739         );
740
741 /*
742  * NOTES:
743  *      BOOLEAN
744  *      IsErrorUserInduced (NTSTATUS Status)
745  */
746 #define IoIsErrorUserInduced(Status) \
747         ((BOOLEAN)(((Status) == STATUS_DEVICE_NOT_READY) || \
748                    ((Status) == STATUS_IO_TIMEOUT) || \
749                    ((Status) == STATUS_MEDIA_WRITE_PROTECTED) || \
750                    ((Status) == STATUS_NO_MEDIA_IN_DRIVE) || \
751                    ((Status) == STATUS_VERIFY_REQUIRED) || \
752                    ((Status) == STATUS_UNRECOGNIZED_MEDIA) || \
753                    ((Status) == STATUS_WRONG_VOLUME)))
754
755 BOOLEAN
756 STDCALL
757 IoIsOperationSynchronous (
758         IN      PIRP    Irp
759         );
760 BOOLEAN
761 STDCALL
762 IoIsSystemThread (
763         PVOID   Unknown0
764         );
765 PIRP
766 STDCALL
767 IoMakeAssociatedIrp (
768         PIRP    Irp,
769         CCHAR   StackSize
770         );
771
772 /*
773  * FUNCTION: Marks the specified irp, indicating further processing will
774  * be required by other driver routines
775  * ARGUMENTS:
776  *      Irp = Irp to mark
777  * NOTES:
778  *      VOID
779  *      IoMarkIrpPending (PIRP Irp)
780  */
781 #define IoMarkIrpPending(Irp) \
782         (IoGetCurrentIrpStackLocation(Irp)->Control |= SL_PENDING_RETURNED)
783
784
785 NTSTATUS
786 STDCALL
787 IoOpenDeviceInstanceKey (
788         DWORD   Unknown0,
789         DWORD   Unknown1,
790         DWORD   Unknown2,
791         DWORD   Unknown3,
792         DWORD   Unknown4
793         );
794 NTSTATUS
795 STDCALL
796 IoQueryDeviceDescription (
797         PINTERFACE_TYPE                 BusType,
798         PULONG                          BusNumber,
799         PCONFIGURATION_TYPE             ControllerType,
800         PULONG                          ControllerNumber,
801         PCONFIGURATION_TYPE             PeripheralType,
802         PULONG                          PeripheralNumber,
803         PIO_QUERY_DEVICE_ROUTINE        CalloutRoutine,
804         PVOID                           Context
805         );
806 DWORD
807 STDCALL
808 IoQueryDeviceEnumInfo (
809         DWORD   Unknown0,
810         DWORD   Unknown1
811         );
812 // IoQueryFileInformation: confirmed - Undocumented because it does not require a valid file handle 
813 NTSTATUS 
814 STDCALL
815 IoQueryFileInformation (
816         IN      PFILE_OBJECT            FileObject,
817         IN      FILE_INFORMATION_CLASS  FileInformationClass,
818         IN      ULONG                   Length,
819         OUT     PVOID                   FileInformation,
820         OUT     PULONG                  ReturnedLength  
821         );
822 NTSTATUS
823 STDCALL
824 IoQueryVolumeInformation (
825         IN      PFILE_OBJECT            FileObject,
826         IN      FS_INFORMATION_CLASS    FsInformationClass,
827         IN      ULONG                   Length,
828         OUT     PVOID                   FsInformation,
829         OUT     PULONG                  ReturnedLength
830         );
831 VOID
832 STDCALL
833 IoQueueThreadIrp (
834         IN      PIRP    Irp
835         );
836
837 VOID
838 STDCALL
839 IoQueueWorkItem(
840     IN PIO_WORKITEM IoWorkItem, 
841         IN PIO_WORKITEM_ROUTINE WorkerRoutine, 
842         IN WORK_QUEUE_TYPE QueueType, 
843         IN PVOID Context
844         );
845
846 VOID
847 STDCALL
848 IoFreeWorkItem(
849     PIO_WORKITEM IoWorkItem
850         );
851
852 PIO_WORKITEM
853 STDCALL
854 IoAllocateWorkItem(
855         PDEVICE_OBJECT DeviceObject
856         );
857
858 VOID
859 STDCALL
860 IoRaiseHardError (
861         PIRP            Irp,
862         PVPB            Vpb,
863         PDEVICE_OBJECT  RealDeviceObject
864         );
865 BOOLEAN
866 STDCALL
867 IoRaiseInformationalHardError (
868         NTSTATUS        ErrorStatus,
869         PUNICODE_STRING String,
870         struct _KTHREAD*        Thread
871         );
872 VOID
873 STDCALL
874 IoRegisterDriverReinitialization (
875         PDRIVER_OBJECT          DriverObject,
876         PDRIVER_REINITIALIZE    ReinitRoutine,
877         PVOID                   Context
878         );
879 VOID
880 STDCALL
881 IoRegisterFileSystem (
882         PDEVICE_OBJECT  DeviceObject
883         );
884 #if (_WIN32_WINNT >= 0x0400)
885 NTSTATUS
886 STDCALL
887 IoRegisterFsRegistrationChange (
888         IN      PDRIVER_OBJECT          DriverObject,
889         IN      PFSDNOTIFICATIONPROC    FSDNotificationProc
890         );
891 #endif // (_WIN32_WINNT >= 0x0400)
892 NTSTATUS
893 STDCALL
894 IoRegisterShutdownNotification (
895         PDEVICE_OBJECT  DeviceObject
896         );
897 VOID
898 STDCALL
899 IoReleaseCancelSpinLock (
900         IN      KIRQL   Irql
901         );
902 VOID
903 STDCALL
904 IoReleaseVpbSpinLock (
905         IN      KIRQL   Irql
906         );
907 VOID
908 STDCALL
909 IoRemoveShareAccess (
910         PFILE_OBJECT    FileObject,
911         PSHARE_ACCESS   ShareAccess
912         );
913 NTSTATUS
914 STDCALL
915 IoReportHalResourceUsage (
916         IN      PUNICODE_STRING         HalDescription,
917         IN      PCM_RESOURCE_LIST       RawList,
918         IN      PCM_RESOURCE_LIST       TranslatedList,
919         IN      ULONG                   ListSize
920         );
921 NTSTATUS
922 STDCALL
923 IoReportResourceUsage (
924         PUNICODE_STRING         DriverClassName,
925         PDRIVER_OBJECT          DriverObject,
926         PCM_RESOURCE_LIST       DriverList,
927         ULONG                   DriverListSize,
928         PDEVICE_OBJECT          DeviceObject,
929         PCM_RESOURCE_LIST       DeviceList,
930         ULONG                   DeviceListSize,
931         BOOLEAN                 OverrideConflict,
932         PBOOLEAN                ConflictDetected
933         );
934
935 #define IoRequestDpc(DeviceObject,Irp,Context) \
936         (KeInsertQueueDpc(&(DeviceObject)->Dpc,(Irp),(Context)))
937
938 #define IoSetCancelRoutine(Irp,NewCancelRoutine) \
939         ((PDRIVER_CANCEL)InterlockedExchangePointer(&(Irp)->CancelRoutine, \
940                                              NewCancelRoutine))
941
942 // AG: Context is now NewContext, otherwise we end up with this:
943 // param->LocalLength=(LocalLength)
944 // ...which isn't possible.
945
946 #define IoSetCompletionRoutine(Irp,Routine,NewContext,Success,Error,Cancel) \
947         { \
948                 PIO_STACK_LOCATION param; \
949                 assert((Success)||(Error)||(Cancel)?(Routine)!=NULL:TRUE); \
950                 param = IoGetNextIrpStackLocation((Irp)); \
951                 param->CompletionRoutine=(Routine); \
952                 param->Context=(NewContext); \
953                 param->Control = 0; \
954                 if ((Success)) \
955                         param->Control = SL_INVOKE_ON_SUCCESS; \
956                 if ((Error)) \
957                         param->Control |= SL_INVOKE_ON_ERROR; \
958                 if ((Cancel)) \
959                         param->Control |= SL_INVOKE_ON_CANCEL; \
960         } 
961
962 VOID STDCALL
963 IoSetDeviceToVerify (IN struct _ETHREAD* Thread,
964                      IN PDEVICE_OBJECT DeviceObject);
965 VOID
966 STDCALL
967 IoSetHardErrorOrVerifyDevice (
968         IN      PIRP            Irp,
969         IN      PDEVICE_OBJECT  DeviceObject
970         );
971 NTSTATUS
972 STDCALL
973 IoSetInformation (
974         IN      PFILE_OBJECT            FileObject,
975         IN      FILE_INFORMATION_CLASS  FileInformationClass,
976         IN      ULONG                   Length,
977         OUT     PVOID                   FileInformation
978         );
979
980 #define IoSetNextIrpStackLocation(Irp) \
981 { \
982         (Irp)->CurrentLocation--; \
983         (Irp)->Tail.Overlay.CurrentStackLocation--; \
984
985
986 VOID
987 STDCALL
988 IoSetShareAccess (
989         ACCESS_MASK     DesiredAccess,
990         ULONG           DesiredShareAccess,
991         PFILE_OBJECT    FileObject,
992         PSHARE_ACCESS   ShareAccess
993         );
994 BOOLEAN
995 STDCALL
996 IoSetThreadHardErrorMode (
997         IN      BOOLEAN HardErrorEnabled
998         );
999 VOID
1000 STDCALL
1001 IoSetTopLevelIrp (
1002         IN      PIRP    Irp
1003         );
1004
1005 /*
1006  * FUNCTION:  Determines the size of an IRP
1007  * ARGUMENTS: 
1008  *           StackSize = number of stack locations in the IRP
1009  * RETURNS: The size of the IRP in bytes 
1010 USHORT
1011 IoSizeOfIrp (CCHAR StackSize)
1012  */
1013 #define IoSizeOfIrp(StackSize) \
1014         ((USHORT)(sizeof(IRP)+(((StackSize)-1)*sizeof(IO_STACK_LOCATION))))
1015
1016 /* original macro */
1017 /*
1018 #define IoSizeOfIrp(StackSize) \
1019         ((USHORT)(sizeof(IRP)+((StackSize)*sizeof(IO_STACK_LOCATION))))
1020 */
1021
1022 /*
1023  * FUNCTION: Dequeues the next IRP from the device's associated queue and
1024  * calls its StartIo routine
1025  * ARGUMENTS:
1026  *          DeviceObject = Device object
1027  *          Cancelable = True if IRPs in the queue can be cancelled
1028  */
1029 VOID
1030 STDCALL
1031 IoStartNextPacket (
1032         PDEVICE_OBJECT  DeviceObject,
1033         BOOLEAN         Cancelable
1034         );
1035 VOID
1036 STDCALL
1037 IoStartNextPacketByKey (
1038         PDEVICE_OBJECT  DeviceObject,
1039         BOOLEAN         Cancelable,
1040         ULONG           Key
1041         );
1042 /*
1043  * FUNCTION: Calls the drivers StartIO routine with the IRP or queues it if
1044  * the device is busy
1045  * ARGUMENTS:
1046  *         DeviceObject = Device to pass the IRP to 
1047  *         Irp = Irp to be processed
1048  *         Key = Optional value for where to insert the IRP
1049  *         CancelFunction = Entry point for a driver supplied cancel function
1050  */
1051 VOID
1052 STDCALL
1053 IoStartPacket (
1054         PDEVICE_OBJECT  DeviceObject,
1055         PIRP            Irp,
1056         PULONG          Key,
1057         PDRIVER_CANCEL  CancelFunction
1058         );
1059 VOID
1060 STDCALL
1061 IoStartTimer (
1062         PDEVICE_OBJECT  DeviceObject
1063         );
1064 VOID
1065 STDCALL
1066 IoStopTimer (
1067         PDEVICE_OBJECT  DeviceObject
1068         );
1069
1070 NTSTATUS STDCALL
1071 IoPageRead(PFILE_OBJECT         FileObject,
1072            PMDL                 Mdl,
1073            PLARGE_INTEGER       Offset,
1074            PKEVENT              Event,
1075            PIO_STATUS_BLOCK     StatusBlock);
1076
1077 NTSTATUS STDCALL 
1078 IoSynchronousPageWrite (PFILE_OBJECT        FileObject,
1079                         PMDL                Mdl,
1080                         PLARGE_INTEGER      Offset,
1081                         PKEVENT             Event,
1082                         PIO_STATUS_BLOCK    StatusBlock);
1083
1084 struct _EPROCESS* STDCALL IoThreadToProcess (struct _ETHREAD*   Thread);
1085 VOID
1086 STDCALL
1087 IoUnregisterFileSystem (
1088         IN      PDEVICE_OBJECT  DeviceObject
1089         );
1090 #if (_WIN32_WINNT >= 0x0400)
1091 VOID
1092 STDCALL
1093 IoUnregisterFsRegistrationChange (
1094         IN      PDRIVER_OBJECT          DriverObject,
1095         IN      PFSDNOTIFICATIONPROC    FSDNotificationProc
1096         );
1097 #endif // (_WIN32_WINNT >= 0x0400)
1098 VOID
1099 STDCALL
1100 IoUnregisterShutdownNotification (
1101         IN      PDEVICE_OBJECT  DeviceObject
1102         );
1103 VOID
1104 STDCALL
1105 IoUpdateShareAccess (
1106         IN      PFILE_OBJECT    FileObject,
1107         IN      PSHARE_ACCESS   ShareAccess
1108         );
1109 NTSTATUS
1110 STDCALL
1111 IoVerifyVolume (
1112         IN      PDEVICE_OBJECT  DeviceObject,
1113         IN      BOOLEAN         AllowRawMount
1114         );
1115 VOID
1116 STDCALL
1117 IoWriteErrorLogEntry (
1118         PVOID   ElEntry
1119         );
1120 /*
1121  * FUNCTION: Sends an irp to the next lower driver
1122  */
1123 NTSTATUS
1124 FASTCALL
1125 IofCallDriver (
1126         PDEVICE_OBJECT  DeviceObject,
1127         PIRP            Irp
1128         );
1129 /*
1130  * FUNCTION: Indicates the caller has finished all processing for a given
1131  * I/O request and is returning the given IRP to the I/O manager
1132  * ARGUMENTS:
1133  *         Irp = Irp to be cancelled
1134  *         PriorityBoost = Increment by which to boost the priority of the
1135  *                         thread making the request
1136  */
1137 VOID
1138 FASTCALL
1139 IofCompleteRequest (
1140         PIRP    Irp,
1141         CCHAR   PriorityBoost
1142         );
1143
1144 /* --- EXPORTED BY HAL --- */
1145
1146 BOOLEAN
1147 STDCALL
1148 IoFlushAdapterBuffers (
1149         PADAPTER_OBJECT AdapterObject,
1150         PMDL            Mdl,
1151         PVOID           MapRegisterBase,
1152         PVOID           CurrentVa,
1153         ULONG           Length,
1154         BOOLEAN         WriteToDevice
1155         );
1156
1157 VOID
1158 STDCALL
1159 IoFreeAdapterChannel (
1160         PADAPTER_OBJECT AdapterObject
1161         );
1162
1163 VOID
1164 STDCALL
1165 IoFreeMapRegisters (
1166         PADAPTER_OBJECT AdapterObject,
1167         PVOID           MapRegisterBase,
1168         ULONG           NumberOfMapRegisters
1169         );
1170
1171 PHYSICAL_ADDRESS
1172 STDCALL
1173 IoMapTransfer (
1174         PADAPTER_OBJECT AdapterObject,
1175         PMDL            Mdl,
1176         PVOID           MapRegisterBase,
1177         PVOID           CurrentVa,
1178         PULONG          Length,
1179         BOOLEAN         WriteToDevice
1180         );
1181
1182 NTSTATUS
1183 STDCALL
1184 IoReadPartitionTable (
1185         PDEVICE_OBJECT                  DeviceObject,
1186         ULONG                           SectorSize,
1187         BOOLEAN                         ReturnedRecognizedPartitions,
1188         PDRIVE_LAYOUT_INFORMATION       * PartitionBuffer
1189         );
1190
1191 NTSTATUS
1192 STDCALL
1193 IoSetPartitionInformation (
1194         PDEVICE_OBJECT  DeviceObject,
1195         ULONG           SectorSize,
1196         ULONG           PartitionNumber,
1197         ULONG           PartitionType
1198         );
1199
1200 NTSTATUS
1201 STDCALL
1202 IoWritePartitionTable (
1203         PDEVICE_OBJECT                  DeviceObject,
1204         ULONG                           SectorSize,
1205         ULONG                           SectorsPerTrack,
1206         ULONG                           NumberOfHeads,
1207         PDRIVE_LAYOUT_INFORMATION       PartitionBuffer
1208         );
1209
1210
1211 /* --- --- --- INTERNAL or REACTOS ONLY --- --- --- */
1212
1213 /*
1214  * FUNCTION: Registers the driver with WMI
1215  * ARGUMENTS:
1216  *          DeviceObject = Device to register
1217  *          Action = Action to take
1218  * RETURNS: Status (?)
1219  */
1220 /*
1221 NTSTATUS
1222 IoWMIRegistrationControl (
1223         PDEVICE_OBJECT DeviceObject,
1224         WMIREGACTION Action);
1225 */
1226
1227 BOOLEAN
1228 IoIsTotalDeviceFailure (
1229         NTSTATUS        Status
1230         );
1231
1232
1233 #endif /* ndef _INCLUDE_DDK_IOFUNCS_H */