Updated IoIsSystemThread() prototype.
[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 typedef struct _ETHREAD *PETHREAD;
761 BOOLEAN
762 STDCALL
763 IoIsSystemThread (
764         IN PETHREAD Thread
765         );
766 PIRP
767 STDCALL
768 IoMakeAssociatedIrp (
769         PIRP    Irp,
770         CCHAR   StackSize
771         );
772
773 /*
774  * FUNCTION: Marks the specified irp, indicating further processing will
775  * be required by other driver routines
776  * ARGUMENTS:
777  *      Irp = Irp to mark
778  * NOTES:
779  *      VOID
780  *      IoMarkIrpPending (PIRP Irp)
781  */
782 #define IoMarkIrpPending(Irp) \
783         (IoGetCurrentIrpStackLocation(Irp)->Control |= SL_PENDING_RETURNED)
784
785
786 NTSTATUS
787 STDCALL
788 IoOpenDeviceInstanceKey (
789         DWORD   Unknown0,
790         DWORD   Unknown1,
791         DWORD   Unknown2,
792         DWORD   Unknown3,
793         DWORD   Unknown4
794         );
795 NTSTATUS
796 STDCALL
797 IoQueryDeviceDescription (
798         PINTERFACE_TYPE                 BusType,
799         PULONG                          BusNumber,
800         PCONFIGURATION_TYPE             ControllerType,
801         PULONG                          ControllerNumber,
802         PCONFIGURATION_TYPE             PeripheralType,
803         PULONG                          PeripheralNumber,
804         PIO_QUERY_DEVICE_ROUTINE        CalloutRoutine,
805         PVOID                           Context
806         );
807 DWORD
808 STDCALL
809 IoQueryDeviceEnumInfo (
810         DWORD   Unknown0,
811         DWORD   Unknown1
812         );
813 // IoQueryFileInformation: confirmed - Undocumented because it does not require a valid file handle 
814 NTSTATUS 
815 STDCALL
816 IoQueryFileInformation (
817         IN      PFILE_OBJECT            FileObject,
818         IN      FILE_INFORMATION_CLASS  FileInformationClass,
819         IN      ULONG                   Length,
820         OUT     PVOID                   FileInformation,
821         OUT     PULONG                  ReturnedLength  
822         );
823 NTSTATUS
824 STDCALL
825 IoQueryVolumeInformation (
826         IN      PFILE_OBJECT            FileObject,
827         IN      FS_INFORMATION_CLASS    FsInformationClass,
828         IN      ULONG                   Length,
829         OUT     PVOID                   FsInformation,
830         OUT     PULONG                  ReturnedLength
831         );
832 VOID
833 STDCALL
834 IoQueueThreadIrp (
835         IN      PIRP    Irp
836         );
837
838 VOID
839 STDCALL
840 IoQueueWorkItem(
841     IN PIO_WORKITEM IoWorkItem, 
842         IN PIO_WORKITEM_ROUTINE WorkerRoutine, 
843         IN WORK_QUEUE_TYPE QueueType, 
844         IN PVOID Context
845         );
846
847 VOID
848 STDCALL
849 IoFreeWorkItem(
850     PIO_WORKITEM IoWorkItem
851         );
852
853 PIO_WORKITEM
854 STDCALL
855 IoAllocateWorkItem(
856         PDEVICE_OBJECT DeviceObject
857         );
858
859 VOID
860 STDCALL
861 IoRaiseHardError (
862         PIRP            Irp,
863         PVPB            Vpb,
864         PDEVICE_OBJECT  RealDeviceObject
865         );
866 BOOLEAN
867 STDCALL
868 IoRaiseInformationalHardError (
869         NTSTATUS        ErrorStatus,
870         PUNICODE_STRING String,
871         struct _KTHREAD*        Thread
872         );
873 VOID
874 STDCALL
875 IoRegisterDriverReinitialization (
876         PDRIVER_OBJECT          DriverObject,
877         PDRIVER_REINITIALIZE    ReinitRoutine,
878         PVOID                   Context
879         );
880 VOID
881 STDCALL
882 IoRegisterFileSystem (
883         PDEVICE_OBJECT  DeviceObject
884         );
885 #if (_WIN32_WINNT >= 0x0400)
886 NTSTATUS
887 STDCALL
888 IoRegisterFsRegistrationChange (
889         IN      PDRIVER_OBJECT          DriverObject,
890         IN      PFSDNOTIFICATIONPROC    FSDNotificationProc
891         );
892 #endif // (_WIN32_WINNT >= 0x0400)
893 NTSTATUS
894 STDCALL
895 IoRegisterShutdownNotification (
896         PDEVICE_OBJECT  DeviceObject
897         );
898 VOID
899 STDCALL
900 IoReleaseCancelSpinLock (
901         IN      KIRQL   Irql
902         );
903 VOID
904 STDCALL
905 IoReleaseVpbSpinLock (
906         IN      KIRQL   Irql
907         );
908 VOID
909 STDCALL
910 IoRemoveShareAccess (
911         PFILE_OBJECT    FileObject,
912         PSHARE_ACCESS   ShareAccess
913         );
914 NTSTATUS
915 STDCALL
916 IoReportHalResourceUsage (
917         IN      PUNICODE_STRING         HalDescription,
918         IN      PCM_RESOURCE_LIST       RawList,
919         IN      PCM_RESOURCE_LIST       TranslatedList,
920         IN      ULONG                   ListSize
921         );
922 NTSTATUS
923 STDCALL
924 IoReportResourceUsage (
925         PUNICODE_STRING         DriverClassName,
926         PDRIVER_OBJECT          DriverObject,
927         PCM_RESOURCE_LIST       DriverList,
928         ULONG                   DriverListSize,
929         PDEVICE_OBJECT          DeviceObject,
930         PCM_RESOURCE_LIST       DeviceList,
931         ULONG                   DeviceListSize,
932         BOOLEAN                 OverrideConflict,
933         PBOOLEAN                ConflictDetected
934         );
935
936 #define IoRequestDpc(DeviceObject,Irp,Context) \
937         (KeInsertQueueDpc(&(DeviceObject)->Dpc,(Irp),(Context)))
938
939 #define IoSetCancelRoutine(Irp,NewCancelRoutine) \
940         ((PDRIVER_CANCEL)InterlockedExchangePointer(&(Irp)->CancelRoutine, \
941                                              NewCancelRoutine))
942
943 // AG: Context is now NewContext, otherwise we end up with this:
944 // param->LocalLength=(LocalLength)
945 // ...which isn't possible.
946
947 #define IoSetCompletionRoutine(Irp,Routine,NewContext,Success,Error,Cancel) \
948         { \
949                 PIO_STACK_LOCATION param; \
950                 assert((Success)||(Error)||(Cancel)?(Routine)!=NULL:TRUE); \
951                 param = IoGetNextIrpStackLocation((Irp)); \
952                 param->CompletionRoutine=(Routine); \
953                 param->Context=(NewContext); \
954                 param->Control = 0; \
955                 if ((Success)) \
956                         param->Control = SL_INVOKE_ON_SUCCESS; \
957                 if ((Error)) \
958                         param->Control |= SL_INVOKE_ON_ERROR; \
959                 if ((Cancel)) \
960                         param->Control |= SL_INVOKE_ON_CANCEL; \
961         } 
962
963 VOID STDCALL
964 IoSetDeviceToVerify (IN struct _ETHREAD* Thread,
965                      IN PDEVICE_OBJECT DeviceObject);
966 VOID
967 STDCALL
968 IoSetHardErrorOrVerifyDevice (
969         IN      PIRP            Irp,
970         IN      PDEVICE_OBJECT  DeviceObject
971         );
972 NTSTATUS
973 STDCALL
974 IoSetInformation (
975         IN      PFILE_OBJECT            FileObject,
976         IN      FILE_INFORMATION_CLASS  FileInformationClass,
977         IN      ULONG                   Length,
978         OUT     PVOID                   FileInformation
979         );
980
981 #define IoSetNextIrpStackLocation(Irp) \
982 { \
983         (Irp)->CurrentLocation--; \
984         (Irp)->Tail.Overlay.CurrentStackLocation--; \
985
986
987 VOID
988 STDCALL
989 IoSetShareAccess (
990         ACCESS_MASK     DesiredAccess,
991         ULONG           DesiredShareAccess,
992         PFILE_OBJECT    FileObject,
993         PSHARE_ACCESS   ShareAccess
994         );
995 BOOLEAN
996 STDCALL
997 IoSetThreadHardErrorMode (
998         IN      BOOLEAN HardErrorEnabled
999         );
1000 VOID
1001 STDCALL
1002 IoSetTopLevelIrp (
1003         IN      PIRP    Irp
1004         );
1005
1006 /*
1007  * FUNCTION:  Determines the size of an IRP
1008  * ARGUMENTS: 
1009  *           StackSize = number of stack locations in the IRP
1010  * RETURNS: The size of the IRP in bytes 
1011 USHORT
1012 IoSizeOfIrp (CCHAR StackSize)
1013  */
1014 #define IoSizeOfIrp(StackSize) \
1015         ((USHORT)(sizeof(IRP)+(((StackSize)-1)*sizeof(IO_STACK_LOCATION))))
1016
1017 /* original macro */
1018 /*
1019 #define IoSizeOfIrp(StackSize) \
1020         ((USHORT)(sizeof(IRP)+((StackSize)*sizeof(IO_STACK_LOCATION))))
1021 */
1022
1023 /*
1024  * FUNCTION: Dequeues the next IRP from the device's associated queue and
1025  * calls its StartIo routine
1026  * ARGUMENTS:
1027  *          DeviceObject = Device object
1028  *          Cancelable = True if IRPs in the queue can be cancelled
1029  */
1030 VOID
1031 STDCALL
1032 IoStartNextPacket (
1033         PDEVICE_OBJECT  DeviceObject,
1034         BOOLEAN         Cancelable
1035         );
1036 VOID
1037 STDCALL
1038 IoStartNextPacketByKey (
1039         PDEVICE_OBJECT  DeviceObject,
1040         BOOLEAN         Cancelable,
1041         ULONG           Key
1042         );
1043 /*
1044  * FUNCTION: Calls the drivers StartIO routine with the IRP or queues it if
1045  * the device is busy
1046  * ARGUMENTS:
1047  *         DeviceObject = Device to pass the IRP to 
1048  *         Irp = Irp to be processed
1049  *         Key = Optional value for where to insert the IRP
1050  *         CancelFunction = Entry point for a driver supplied cancel function
1051  */
1052 VOID
1053 STDCALL
1054 IoStartPacket (
1055         PDEVICE_OBJECT  DeviceObject,
1056         PIRP            Irp,
1057         PULONG          Key,
1058         PDRIVER_CANCEL  CancelFunction
1059         );
1060 VOID
1061 STDCALL
1062 IoStartTimer (
1063         PDEVICE_OBJECT  DeviceObject
1064         );
1065 VOID
1066 STDCALL
1067 IoStopTimer (
1068         PDEVICE_OBJECT  DeviceObject
1069         );
1070
1071 NTSTATUS STDCALL
1072 IoPageRead(PFILE_OBJECT         FileObject,
1073            PMDL                 Mdl,
1074            PLARGE_INTEGER       Offset,
1075            PKEVENT              Event,
1076            PIO_STATUS_BLOCK     StatusBlock);
1077
1078 NTSTATUS STDCALL 
1079 IoSynchronousPageWrite (PFILE_OBJECT        FileObject,
1080                         PMDL                Mdl,
1081                         PLARGE_INTEGER      Offset,
1082                         PKEVENT             Event,
1083                         PIO_STATUS_BLOCK    StatusBlock);
1084
1085 struct _EPROCESS* STDCALL IoThreadToProcess (struct _ETHREAD*   Thread);
1086 VOID
1087 STDCALL
1088 IoUnregisterFileSystem (
1089         IN      PDEVICE_OBJECT  DeviceObject
1090         );
1091 #if (_WIN32_WINNT >= 0x0400)
1092 VOID
1093 STDCALL
1094 IoUnregisterFsRegistrationChange (
1095         IN      PDRIVER_OBJECT          DriverObject,
1096         IN      PFSDNOTIFICATIONPROC    FSDNotificationProc
1097         );
1098 #endif // (_WIN32_WINNT >= 0x0400)
1099 VOID
1100 STDCALL
1101 IoUnregisterShutdownNotification (
1102         IN      PDEVICE_OBJECT  DeviceObject
1103         );
1104 VOID
1105 STDCALL
1106 IoUpdateShareAccess (
1107         IN      PFILE_OBJECT    FileObject,
1108         IN      PSHARE_ACCESS   ShareAccess
1109         );
1110 NTSTATUS
1111 STDCALL
1112 IoVerifyVolume (
1113         IN      PDEVICE_OBJECT  DeviceObject,
1114         IN      BOOLEAN         AllowRawMount
1115         );
1116 VOID
1117 STDCALL
1118 IoWriteErrorLogEntry (
1119         PVOID   ElEntry
1120         );
1121 /*
1122  * FUNCTION: Sends an irp to the next lower driver
1123  */
1124 NTSTATUS
1125 FASTCALL
1126 IofCallDriver (
1127         PDEVICE_OBJECT  DeviceObject,
1128         PIRP            Irp
1129         );
1130 /*
1131  * FUNCTION: Indicates the caller has finished all processing for a given
1132  * I/O request and is returning the given IRP to the I/O manager
1133  * ARGUMENTS:
1134  *         Irp = Irp to be cancelled
1135  *         PriorityBoost = Increment by which to boost the priority of the
1136  *                         thread making the request
1137  */
1138 VOID
1139 FASTCALL
1140 IofCompleteRequest (
1141         PIRP    Irp,
1142         CCHAR   PriorityBoost
1143         );
1144
1145 /* --- EXPORTED BY HAL --- */
1146
1147 BOOLEAN
1148 STDCALL
1149 IoFlushAdapterBuffers (
1150         PADAPTER_OBJECT AdapterObject,
1151         PMDL            Mdl,
1152         PVOID           MapRegisterBase,
1153         PVOID           CurrentVa,
1154         ULONG           Length,
1155         BOOLEAN         WriteToDevice
1156         );
1157
1158 VOID
1159 STDCALL
1160 IoFreeAdapterChannel (
1161         PADAPTER_OBJECT AdapterObject
1162         );
1163
1164 VOID
1165 STDCALL
1166 IoFreeMapRegisters (
1167         PADAPTER_OBJECT AdapterObject,
1168         PVOID           MapRegisterBase,
1169         ULONG           NumberOfMapRegisters
1170         );
1171
1172 PHYSICAL_ADDRESS
1173 STDCALL
1174 IoMapTransfer (
1175         PADAPTER_OBJECT AdapterObject,
1176         PMDL            Mdl,
1177         PVOID           MapRegisterBase,
1178         PVOID           CurrentVa,
1179         PULONG          Length,
1180         BOOLEAN         WriteToDevice
1181         );
1182
1183 NTSTATUS
1184 STDCALL
1185 IoReadPartitionTable (
1186         PDEVICE_OBJECT                  DeviceObject,
1187         ULONG                           SectorSize,
1188         BOOLEAN                         ReturnedRecognizedPartitions,
1189         PDRIVE_LAYOUT_INFORMATION       * PartitionBuffer
1190         );
1191
1192 NTSTATUS
1193 STDCALL
1194 IoSetPartitionInformation (
1195         PDEVICE_OBJECT  DeviceObject,
1196         ULONG           SectorSize,
1197         ULONG           PartitionNumber,
1198         ULONG           PartitionType
1199         );
1200
1201 NTSTATUS
1202 STDCALL
1203 IoWritePartitionTable (
1204         PDEVICE_OBJECT                  DeviceObject,
1205         ULONG                           SectorSize,
1206         ULONG                           SectorsPerTrack,
1207         ULONG                           NumberOfHeads,
1208         PDRIVE_LAYOUT_INFORMATION       PartitionBuffer
1209         );
1210
1211
1212 /* --- --- --- INTERNAL or REACTOS ONLY --- --- --- */
1213
1214 /*
1215  * FUNCTION: Registers the driver with WMI
1216  * ARGUMENTS:
1217  *          DeviceObject = Device to register
1218  *          Action = Action to take
1219  * RETURNS: Status (?)
1220  */
1221 /*
1222 NTSTATUS
1223 IoWMIRegistrationControl (
1224         PDEVICE_OBJECT DeviceObject,
1225         WMIREGACTION Action);
1226 */
1227
1228 BOOLEAN
1229 IoIsTotalDeviceFailure (
1230         NTSTATUS        Status
1231         );
1232
1233
1234 #endif /* ndef _INCLUDE_DDK_IOFUNCS_H */