some __stdcall fixes in ntoskrnl and ntdll
[reactos.git] / reactos / include / ddk / iofuncs.h
1 /* IO MANAGER ***************************************************************/
2
3 BOOLEAN
4 IoRaiseInformationalHardError (
5 NTSTATUS ErrorStatus,
6 PUNICODE_STRING String,
7 PKTHREAD Thread
8 );
9
10
11 /*
12 * FUNCTION: Registers the driver with WMI
13 * ARGUMENTS:
14 * DeviceObject = Device to register
15 * Action = Action to take
16 * RETURNS: Status (?)
17 */
18 //NTSTATUS IoWMIRegistrationControl(DeviceObject, WMIREGACTION Action);
19
20 /*
21 * FUNCTION: Synchronizes cancelable-state transistions for IRPs in a
22 * multiprocessor-safe way
23 * ARGUMENTS:
24 * Irpl = Variable to store the current IRQ level
25 */
26 VOID
27 IoAcquireCancelSpinLock (
28 PKIRQL Irpl
29 );
30
31 typedef
32 IO_ALLOCATION_ACTION
33 (*PDRIVER_CONTROL) (
34 PDEVICE_OBJECT DeviceObject,
35 PIRP irp,
36 PVOID MapRegisterBase,
37 PVOID Context
38 );
39
40 /*
41 * FUNCTION: Allocates an adaptor object for a DMA operation on the target
42 * device
43 * ARGUMENTS:
44 * Adaptor = Adapter channel or busmaster adapter to be allocated
45 * DeviceObject = Target device for DMA
46 * NumberOfMapRegisters = Number of map registers
47 * ExecutionRoutine = Routine to be called when the adaptor is
48 * available
49 * Context = driver defined contex that will be passed to the
50 * execution routine
51 * RETURNS: Success or failure code
52 */
53 NTSTATUS
54 IoAllocateAdapterChannel (
55 PADAPTER_OBJECT AdaperObject,
56 PDEVICE_OBJECT DeviceObject,
57 ULONG NumberOfMapRegisters,
58 PDRIVER_CONTROL ExecutionRoutine,
59 PVOID Context
60 );
61
62 /*
63 * FUNCTION: Sets up a call to a driver supplied controller object as
64 * soon as it is available
65 * ARGUMENTS:
66 * ControllerObject = Driver created controller object
67 * DeviceObject = target device
68 * ExecutionObject = Routine to be called
69 * Context = Driver determined context to be based to the routine
70 */
71 VOID
72 IoAllocateController (
73 PCONTROLLER_OBJECT ControllerObject,
74 PDEVICE_OBJECT DeviceObject,
75 PDRIVER_CONTROL ExecutionRoutine,
76 PVOID Context
77 );
78
79 /*
80 * FUNCTION: Allocates an error log packet
81 * ARGUMENTS:
82 * IoObject = Object which found the error
83 * EntrySize = Size in bytes of the packet to be allocated
84 * RETURNS: On success a pointer to the allocated packet
85 * On failure returns NULL
86 */
87 PVOID
88 IoAllocateErrorLogEntry (
89 PVOID IoObject,
90 UCHAR EntrySize
91 );
92
93 /*
94 * FUNCTION: Allocates an IRP
95 * ARGUMENTS:
96 * StackSize = number of stack locations to allocate
97 * ChargeQuota = Who knows
98 * RETURNS: On success the allocated IRP
99 * On failure NULL
100 */
101 PIRP
102 IoAllocateIrp (
103 CCHAR StackSize,
104 BOOLEAN ChargeQuota
105 );
106
107 /*
108 * FUNCTION: Allocates an MDL large enough to map the supplied buffer
109 * ARGUMENTS:
110 * VirtualAddress = base virtual address of the buffer to be mapped
111 * Length = length of the buffer to be mapped
112 * SecondaryBuffer = Whether the buffer is primary or secondary
113 * ChargeQuota = Charge non-paged pool quota to current thread
114 * Irp = Optional irp to be associated with the MDL
115 * RETURNS: On the success the allocated MDL
116 * On failure NULL
117 */
118 PMDL
119 IoAllocateMdl (
120 PVOID VirtualAddress,
121 ULONG Length,
122 BOOLEAN SecondaryBuffer,
123 BOOLEAN ChargeQuota,
124 PIRP Irp
125 );
126
127 /*
128 * FUNCTION: Creates a symbolic link between the ARC name of a physical
129 * device and the name of the corresponding device object
130 * ARGUMENTS:
131 * ArcName = ARC name of the device
132 * DeviceName = Name of the device object
133 */
134 VOID
135 IoAssignArcName (
136 PUNICODE_STRING ArcName,
137 PUNICODE_STRING DeviceName
138 );
139
140 enum
141 {
142 IO_NO_INCREMENT,
143 };
144
145 /*
146 * FUNCTION: Takes a list of requested hardware resources and allocates them
147 * ARGUMENTS:
148 * RegisterPath =
149 * DriverClassName =
150 * DriverObject = Driver object passed to the DriverEntry routine
151 * DeviceObject =
152 * RequestedResources = List of resources
153 * RETURNS:
154 */
155 NTSTATUS
156 IoAssignResources (
157 PUNICODE_STRING RegistryPath,
158 PUNICODE_STRING DriverClassName,
159 PDRIVER_OBJECT DriverObject,
160 PDEVICE_OBJECT DeviceObject,
161 PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources,
162 PCM_RESOURCE_LIST * AllocatedResources
163 );
164
165 /*
166 * FUNCTION: Attaches the callers device object to a named target device
167 * ARGUMENTS:
168 * SourceDevice = caller's device
169 * TargetDevice = Name of the target device
170 * AttachedDevice = Caller allocated storage. On return contains
171 * a pointer to the target device
172 * RETURNS: Success or failure code
173 */
174 NTSTATUS
175 IoAttachDevice (
176 PDEVICE_OBJECT SourceDevice,
177 PUNICODE_STRING TargetDevice,
178 PDEVICE_OBJECT * AttachedDevice
179 );
180
181 /*
182 * FUNCTION: Obsolete
183 * ARGUMENTS:
184 * SourceDevice = device to attach
185 * TargetDevice = device to be attached to
186 * RETURNS: Success or failure code
187 */
188 NTSTATUS
189 IoAttachDeviceByPointer (
190 PDEVICE_OBJECT SourceDevice,
191 PDEVICE_OBJECT TargetDevice
192 );
193
194 /*
195 * FUNCTION: Attaches the callers device to the highest device in the chain
196 * ARGUMENTS:
197 * SourceDevice = caller's device
198 * TargetDevice = Device to attach
199 * RETURNS: On success the previously highest device
200 * On failure NULL
201 */
202 PDEVICE_OBJECT
203 IoAttachDeviceToDeviceStack (
204 PDEVICE_OBJECT SourceDevice,
205 PDEVICE_OBJECT TargetDevice
206 );
207
208 /*
209 * FUNCTION: Builds a irp to be sent to lower level drivers
210 * ARGUMENTS:
211 * MajorFunction = Major function code to be set in the IRP
212 * DeviceObject = Next lower device object
213 * Buffer = Buffer (only required for some major function codes)
214 * Length = Length in bytes of the buffer
215 * StartingOffset = Starting offset on the target device
216 * IoStatusBlock = Storage for status about the operation (optional)
217 * RETURNS: On success the IRP allocated
218 * On failure NULL
219 */
220 PIRP
221 IoBuildAsynchronousFsdRequest (
222 ULONG MajorFunction,
223 PDEVICE_OBJECT DeviceObject,
224 PVOID Buffer,
225 ULONG Length,
226 PLARGE_INTEGER StartingOffset,
227 PIO_STATUS_BLOCK IoStatusBlock
228 );
229
230 /*
231 * FUNCTION: Allocates and sets up an IRP for a device control request
232 * ARGUMENTS:
233 * IoControlCode = Type of request
234 * DeviceObject = Target device
235 * InputBuffer = Optional input buffer to the driver
236 * InputBufferLength = Length of the input buffer
237 * OutputBuffer = Optional output buffer
238 * OutputBufferLength = Length of the output buffer
239 * InternalDeviceIoControl = TRUE if the request is internal
240 * Event = Initialized event for the caller to wait for the request
241 * to be completed
242 * IoStatusBlock = I/O status block to be set when the request is
243 * completed
244 * RETURNS: Returns the IRP created
245 */
246 PIRP
247 IoBuildDeviceIoControlRequest (
248 ULONG IoControlCode,
249 PDEVICE_OBJECT DeviceObject,
250 PVOID InputBuffer,
251 ULONG InputBufferLength,
252 PVOID OutputBuffer,
253 ULONG OutputBufferLength,
254 BOOLEAN InternalDeviceIoControl,
255 PKEVENT Event,
256 PIO_STATUS_BLOCK IoStatusBlock
257 );
258
259
260 VOID
261 IoBuildPartialMdl (
262 PMDL SourceMdl,
263 PMDL TargetMdl,
264 PVOID VirtualAddress,
265 ULONG Length
266 );
267
268 PIRP
269 IoBuildSynchronousFsdRequest (
270 ULONG MajorFunction,
271 PDEVICE_OBJECT DeviceObject,
272 PVOID Buffer,
273 ULONG Length,
274 PLARGE_INTEGER StartingOffset,
275 PKEVENT Event,
276 PIO_STATUS_BLOCK IoStatusBlock
277 );
278
279 /*
280 * FUNCTION: Sends an irp to the next lower driver
281 */
282 NTSTATUS
283 IoCallDriver (
284 PDEVICE_OBJECT DeviceObject,
285 PIRP irp
286 );
287
288 BOOLEAN
289 IoCancelIrp (
290 PIRP Irp
291 );
292
293 NTSTATUS
294 IoCheckShareAccess (
295 ACCESS_MASK DesiredAccess,
296 ULONG DesiredShareAccess,
297 PFILE_OBJECT FileObject,
298 PSHARE_ACCESS ShareAccess,
299 BOOLEAN Update
300 );
301
302 /*
303 * FUNCTION: Indicates the caller has finished all processing for a given
304 * I/O request and is returning the given IRP to the I/O manager
305 * ARGUMENTS:
306 * Irp = Irp to be cancelled
307 * PriorityBoost = Increment by which to boost the priority of the
308 * thread making the request
309 */
310 VOID
311 IoCompleteRequest (
312 PIRP Irp,
313 CCHAR PriorityBoost
314 );
315
316 NTSTATUS
317 IoConnectInterrupt (
318 PKINTERRUPT * InterruptObject,
319 PKSERVICE_ROUTINE ServiceRoutine,
320 PVOID ServiceContext,
321 PKSPIN_LOCK SpinLock,
322 ULONG Vector,
323 KIRQL Irql,
324 KIRQL SynchronizeIrql,
325 KINTERRUPT_MODE InterruptMode,
326 BOOLEAN ShareVector,
327 KAFFINITY ProcessorEnableMask,
328 BOOLEAN FloatingSave
329 );
330
331 PCONTROLLER_OBJECT
332 IoCreateController (
333 ULONG Size
334 );
335
336 /*
337 * FUNCTION: Allocates memory for and intializes a device object for use for
338 * a driver
339 * ARGUMENTS:
340 * DriverObject : Driver object passed by iomgr when the driver was
341 * loaded
342 * DeviceExtensionSize : Number of bytes for the device extension
343 * DeviceName : Unicode name of device
344 * DeviceType : Device type
345 * DeviceCharacteristics : Bit mask of device characteristics
346 * Exclusive : True if only one thread can access the device at a
347 * time
348 * RETURNS:
349 * Success or failure
350 * DeviceObject : Contains a pointer to allocated device object
351 * if the call succeeded
352 * NOTES: See the DDK documentation for more information
353 */
354 NTSTATUS
355 IoCreateDevice (
356 PDRIVER_OBJECT DriverObject,
357 ULONG DeviceExtensionSize,
358 PUNICODE_STRING DeviceName,
359 DEVICE_TYPE DeviceType,
360 ULONG DeviceCharacteristics,
361 BOOLEAN Exclusive,
362 PDEVICE_OBJECT * DeviceObject
363 );
364
365
366 PKEVENT
367 IoCreateNotificationEvent (
368 PUNICODE_STRING EventName,
369 PHANDLE EventHandle
370 );
371
372 NTSTATUS
373 STDCALL
374 IoCreateSymbolicLink (
375 PUNICODE_STRING SymbolicLinkName,
376 PUNICODE_STRING DeviceName
377 );
378
379 PKEVENT
380 IoCreateSynchronizationEvent (
381 PUNICODE_STRING EventName,
382 PHANDLE EventHandle
383 );
384
385 NTSTATUS
386 STDCALL
387 IoCreateUnprotectedSymbolicLink (
388 PUNICODE_STRING SymbolicLinkName,
389 PUNICODE_STRING DeviceName
390 );
391
392
393 VOID
394 IoDeassignArcName (
395 PUNICODE_STRING ArcName
396 );
397
398 VOID
399 IoDeleteController (
400 PCONTROLLER_OBJECT ControllerObject
401 );
402
403 VOID
404 IoDeleteDevice (
405 PDEVICE_OBJECT DeviceObject
406 );
407
408 NTSTATUS
409 STDCALL
410 IoDeleteSymbolicLink (
411 PUNICODE_STRING SymbolicLinkName
412 );
413
414 VOID
415 IoDetachDevice (
416 PDEVICE_OBJECT TargetDevice
417 );
418
419 VOID
420 IoDisconnectInterrupt (
421 PKINTERRUPT InterruptObject
422 );
423
424 BOOLEAN
425 IoFlushAdapterBuffers (
426 PADAPTER_OBJECT AdapterObject,
427 PMDL Mdl,
428 PVOID MapRegisterBase,
429 PVOID CurrentVa,
430 ULONG Length,
431 BOOLEAN WriteToDevice
432 );
433
434 VOID
435 IoFreeAdapterChannel (
436 PADAPTER_OBJECT AdapterObject
437 );
438
439 VOID
440 IoFreeController (
441 PCONTROLLER_OBJECT ControllerObject
442 );
443
444 VOID
445 IoFreeIrp (
446 PIRP Irp
447 );
448
449 VOID
450 IoFreeMapRegisters (
451 PADAPTER_OBJECT AdapterObject,
452 PVOID MapRegisterBase,
453 ULONG NumberOfMapRegisters
454 );
455
456 VOID
457 IoFreeMdl (
458 PMDL Mdl
459 );
460
461 PCONFIGURATION_INFORMATION
462 IoGetConfigurationInformation (VOID);
463
464
465 /*
466 * FUNCTION: Returns a pointer to the callers stack location in the irp
467 */
468 PIO_STACK_LOCATION
469 IoGetCurrentIrpStackLocation (
470 IRP * irp
471 );
472
473 struct _EPROCESS *
474 IoGetCurrentProcess (VOID);
475
476 NTSTATUS
477 IoGetDeviceObjectPointer (
478 PUNICODE_STRING ObjectName,
479 ACCESS_MASK DesiredAccess,
480 PFILE_OBJECT * FileObject,
481 PDEVICE_OBJECT * DeviceObject
482 );
483
484 PDEVICE_OBJECT
485 IoGetDeviceToVerify (
486 PETHREAD Thread
487 );
488
489 PGENERIC_MAPPING
490 IoGetFileObjectGenericMapping (VOID);
491
492 ULONG
493 IoGetFunctionCodeFromCtlCode (
494 ULONG ControlCode
495 );
496
497 PVOID
498 IoGetInitialStack (VOID);
499
500 /*
501 * FUNCTION:
502 */
503 PIO_STACK_LOCATION
504 IoGetNextIrpStackLocation (
505 IRP * irp
506 );
507
508 PDEVICE_OBJECT
509 IoGetRelatedDeviceObject (
510 PFILE_OBJECT FileObject
511 );
512
513 VOID
514 IoInitializeDpcRequest (
515 PDEVICE_OBJECT DeviceObject,
516 PIO_DPC_ROUTINE DpcRoutine
517 );
518
519 /*
520 * FUNCTION: Initalizes an irp allocated by the caller
521 * ARGUMENTS:
522 * Irp = IRP to initalize
523 * PacketSize = Size in bytes of the IRP
524 * StackSize = Number of stack locations in the IRP
525 */
526 VOID
527 IoInitializeIrp (
528 PIRP Irp,
529 USHORT PacketSize,
530 CCHAR StackSize
531 );
532
533 NTSTATUS
534 IoInitializeTimer (
535 PDEVICE_OBJECT DeviceObject,
536 PIO_TIMER_ROUTINE TimerRoutine,
537 PVOID Context
538 );
539
540 BOOLEAN
541 IoIsErrorUserInduced (
542 NTSTATUS Status
543 );
544
545 BOOLEAN
546 IoIsTotalDeviceFailure (
547 NTSTATUS Status
548 );
549
550 PIRP
551 IoMakeAssociatedIrp (
552 PIRP Irp,
553 CCHAR StackSize
554 );
555
556 PHYSICAL_ADDRESS
557 IoMapTransfer (
558 PADAPTER_OBJECT AdapterObject,
559 PMDL Mdl,
560 PVOID MapRegisterBase,
561 PVOID CurrentVa,
562 PULONG Length,
563 BOOLEAN WriteToDevice
564 );
565
566 /*
567 * FUNCTION: Marks an IRP as pending
568 * ARGUMENTS:
569 * Irp = Irp to mark
570 * NOTE: If a driver doesn't complete the irp in its dispatch routine it
571 * must mark it pending otherwise the I/O manager will complete it on
572 * return from the dispatch routine.
573 */
574 VOID
575 IoMarkIrpPending (
576 PIRP Irp
577 );
578
579 NTSTATUS
580 IoQueryDeviceDescription (
581 PINTERFACE_TYPE BusType,
582 PULONG BusNumber,
583 PCONFIGURATION_TYPE ControllerType,
584 PULONG ControllerNumber,
585 PCONFIGURATION_TYPE PeripheralType,
586 PULONG PeripheralNumber,
587 PIO_QUERY_DEVICE_ROUTINE CalloutRoutine,
588 PVOID Context
589 );
590
591 VOID
592 IoRaiseHardError (
593 PIRP Irp,
594 PVPB Vpb,
595 PDEVICE_OBJECT RealDeviceObject
596 );
597
598 BOOLEAN
599 IoRaiseHardInformationalError (
600 NTSTATUS ErrorStatus,
601 PUNICODE_STRING String,
602 PKTHREAD Thread
603 );
604
605 NTSTATUS
606 IoReadPartitionTable (
607 PDEVICE_OBJECT DeviceObject,
608 ULONG SectorSize,
609 BOOLEAN ReturnedRecognizedPartitions,
610 struct _DRIVE_LAYOUT_INFORMATION ** PBuffer
611 );
612
613 VOID
614 IoRegisterDriverReinitialization (
615 PDRIVER_OBJECT DriverObject,
616 PDRIVER_REINITIALIZE ReinitRoutine,
617 PVOID Context
618 );
619
620 NTSTATUS
621 IoRegisterShutdownNotification (
622 PDEVICE_OBJECT DeviceObject
623 );
624
625 VOID
626 IoReleaseCancelSpinLock (
627 KIRQL Irql
628 );
629
630 VOID
631 IoRemoveShareAccess (
632 PFILE_OBJECT FileObject,
633 PSHARE_ACCESS ShareAccess
634 );
635
636 NTSTATUS
637 IoReportResourceUsage (
638 PUNICODE_STRING DriverClassName,
639 PDRIVER_OBJECT DriverObject,
640 PCM_RESOURCE_LIST DriverList,
641 ULONG DriverListSize,
642 PDEVICE_OBJECT DeviceObject,
643 PCM_RESOURCE_LIST DeviceList,
644 ULONG DeviceListSize,
645 BOOLEAN OverrideConflict,
646 PBOOLEAN ConflictDetected
647 );
648
649 VOID
650 IoRequestDpc (
651 PDEVICE_OBJECT DeviceObject,
652 PIRP Irp,
653 PVOID Context
654 );
655
656 PDRIVER_CANCEL
657 IoSetCancelRoutine (
658 PIRP Irp,
659 PDRIVER_CANCEL CancelRoutine
660 );
661
662 VOID
663 IoSetCompletionRoutine (
664 PIRP Irp,
665 PIO_COMPLETION_ROUTINE CompletionRoutine,
666 PVOID Context,
667 BOOLEAN InvokeOnSuccess,
668 BOOLEAN InvokeOnError,
669 BOOLEAN InvokeOnCancel
670 );
671
672 VOID
673 IoSetHardErrorOrVerifyDevice (
674 PIRP Irp,
675 PDEVICE_OBJECT DeviceObject
676 );
677
678 VOID
679 IoSetNextIrpStackLocation (
680 PIRP Irp
681 );
682
683 NTSTATUS
684 IoSetPartitionInformation (
685 PDEVICE_OBJECT DeviceObject,
686 ULONG SectorSize,
687 ULONG PartitionNumber,
688 ULONG PartitionType
689 );
690
691 VOID
692 IoSetShareAccess (
693 ACCESS_MASK DesiredAccess,
694 ULONG DesiredShareAccess,
695 PFILE_OBJECT FileObject,
696 PSHARE_ACCESS ShareAccess
697 );
698
699 /*
700 * FUNCTION: Determines the size of an IRP
701 * ARGUMENTS:
702 * StackSize = number of stack locations in the IRP
703 * RETURNS: The size of the IRP in bytes
704 */
705 USHORT
706 IoSizeOfIrp (
707 CCHAR StackSize
708 );
709
710 /*
711 * FUNCTION: Dequeues the next IRP from the device's associated queue and
712 * calls its StartIo routine
713 * ARGUMENTS:
714 * DeviceObject = Device object
715 * Cancelable = True if IRPs in the queue can be cancelled
716 */
717 VOID
718 IoStartNextPacket (
719 PDEVICE_OBJECT DeviceObject,
720 BOOLEAN Cancelable
721 );
722
723 VOID
724 IoStartNextPacketByKey (
725 PDEVICE_OBJECT DeviceObject,
726 BOOLEAN Cancelable,
727 ULONG Key
728 );
729
730 /*
731 * FUNCTION: Calls the drivers StartIO routine with the IRP or queues it if
732 * the device is busy
733 * ARGUMENTS:
734 * DeviceObject = Device to pass the IRP to
735 * Irp = Irp to be processed
736 * Key = Optional value for where to insert the IRP
737 * CancelFunction = Entry point for a driver supplied cancel function
738 */
739 VOID
740 IoStartPacket (
741 PDEVICE_OBJECT DeviceObject,
742 PIRP Irp,
743 PULONG Key,
744 PDRIVER_CANCEL CancelFunction
745 );
746
747 VOID
748 IoStartTimer (
749 PDEVICE_OBJECT DeviceObject
750 );
751
752 VOID
753 IoStopTimer (
754 PDEVICE_OBJECT DeviceObject
755 );
756
757 VOID
758 IoUnregisterShutdownNotification (
759 PDEVICE_OBJECT DeviceObject
760 );
761
762 VOID
763 IoUpdateShareAccess (
764 PFILE_OBJECT FileObject,
765 PSHARE_ACCESS ShareAccess
766 );
767
768 VOID
769 IoWriteErrorLogEntry (
770 PVOID ElEntry
771 );
772
773 NTSTATUS
774 IoWritePartitionTable (
775 PDEVICE_OBJECT DeviceObject,
776 ULONG SectorSize,
777 ULONG SectorsPerTrack,
778 ULONG NumberOfHeads,
779 struct _DRIVE_LAYOUT_INFORMATION* PBuffer
780 );
781
782
783 // Preliminary guess
784 NTKERNELAPI
785 NTSTATUS
786 IoQueryFileVolumeInformation (
787 IN PFILE_OBJECT FileObject,
788 IN FS_INFORMATION_CLASS FsInformationClass,
789 IN ULONG Length,
790 OUT PVOID FsInformation,
791 OUT PULONG ReturnedLength
792 );
793
794 NTKERNELAPI // confirmed - Undocumented because it does not require a valid file handle
795 NTSTATUS
796 IoQueryFileInformation (
797 IN PFILE_OBJECT FileObject,
798 IN FILE_INFORMATION_CLASS FileInformationClass,
799 IN ULONG Length,
800 OUT PVOID FileInformation,
801 OUT PULONG ReturnedLength
802 );
803
804 VOID
805 IoRegisterFileSystem (
806 PDEVICE_OBJECT DeviceObject
807 );
808
809 PDEVICE_OBJECT
810 IoGetAttachedDevice (
811 PDEVICE_OBJECT DeviceObject
812 );
813
814 PFILE_OBJECT
815 IoCreateStreamFileObject (
816 PFILE_OBJECT FileObject,
817 PDEVICE_OBJECT DeviceObject
818 );
819