1 /* $Id: iofuncs.h,v 1.6 2000/03/05 19:17:37 ea Exp $ */
2 /* IO MANAGER ***************************************************************/
5 IoRaiseInformationalHardError (
7 PUNICODE_STRING String
,
13 * FUNCTION: Registers the driver with WMI
15 * DeviceObject = Device to register
16 * Action = Action to take
19 //NTSTATUS IoWMIRegistrationControl(DeviceObject, WMIREGACTION Action);
22 * FUNCTION: Synchronizes cancelable-state transistions for IRPs in a
23 * multiprocessor-safe way
25 * Irpl = Variable to store the current IRQ level
28 IoAcquireCancelSpinLock (
35 PDEVICE_OBJECT DeviceObject
,
37 PVOID MapRegisterBase
,
42 * FUNCTION: Allocates an adaptor object for a DMA operation on the target
45 * Adaptor = Adapter channel or busmaster adapter to be allocated
46 * DeviceObject = Target device for DMA
47 * NumberOfMapRegisters = Number of map registers
48 * ExecutionRoutine = Routine to be called when the adaptor is
50 * Context = driver defined contex that will be passed to the
52 * RETURNS: Success or failure code
55 IoAllocateAdapterChannel (
56 PADAPTER_OBJECT AdaperObject
,
57 PDEVICE_OBJECT DeviceObject
,
58 ULONG NumberOfMapRegisters
,
59 PDRIVER_CONTROL ExecutionRoutine
,
64 * FUNCTION: Sets up a call to a driver supplied controller object as
65 * soon as it is available
67 * ControllerObject = Driver created controller object
68 * DeviceObject = target device
69 * ExecutionObject = Routine to be called
70 * Context = Driver determined context to be based to the routine
73 IoAllocateController (
74 PCONTROLLER_OBJECT ControllerObject
,
75 PDEVICE_OBJECT DeviceObject
,
76 PDRIVER_CONTROL ExecutionRoutine
,
81 * FUNCTION: Allocates an error log packet
83 * IoObject = Object which found the error
84 * EntrySize = Size in bytes of the packet to be allocated
85 * RETURNS: On success a pointer to the allocated packet
86 * On failure returns NULL
89 IoAllocateErrorLogEntry (
95 * FUNCTION: Allocates an IRP
97 * StackSize = number of stack locations to allocate
98 * ChargeQuota = Who knows
99 * RETURNS: On success the allocated IRP
109 * FUNCTION: Allocates an MDL large enough to map the supplied buffer
111 * VirtualAddress = base virtual address of the buffer to be mapped
112 * Length = length of the buffer to be mapped
113 * SecondaryBuffer = Whether the buffer is primary or secondary
114 * ChargeQuota = Charge non-paged pool quota to current thread
115 * Irp = Optional irp to be associated with the MDL
116 * RETURNS: On the success the allocated MDL
121 PVOID VirtualAddress
,
123 BOOLEAN SecondaryBuffer
,
129 * FUNCTION: Creates a symbolic link between the ARC name of a physical
130 * device and the name of the corresponding device object
132 * ArcName = ARC name of the device
133 * DeviceName = Name of the device object
137 PUNICODE_STRING ArcName
,
138 PUNICODE_STRING DeviceName
147 * FUNCTION: Takes a list of requested hardware resources and allocates them
151 * DriverObject = Driver object passed to the DriverEntry routine
153 * RequestedResources = List of resources
158 PUNICODE_STRING RegistryPath
,
159 PUNICODE_STRING DriverClassName
,
160 PDRIVER_OBJECT DriverObject
,
161 PDEVICE_OBJECT DeviceObject
,
162 PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources
,
163 PCM_RESOURCE_LIST
* AllocatedResources
167 * FUNCTION: Attaches the callers device object to a named target device
169 * SourceDevice = caller's device
170 * TargetDevice = Name of the target device
171 * AttachedDevice = Caller allocated storage. On return contains
172 * a pointer to the target device
173 * RETURNS: Success or failure code
177 PDEVICE_OBJECT SourceDevice
,
178 PUNICODE_STRING TargetDevice
,
179 PDEVICE_OBJECT
* AttachedDevice
185 * SourceDevice = device to attach
186 * TargetDevice = device to be attached to
187 * RETURNS: Success or failure code
190 IoAttachDeviceByPointer (
191 PDEVICE_OBJECT SourceDevice
,
192 PDEVICE_OBJECT TargetDevice
196 * FUNCTION: Attaches the callers device to the highest device in the chain
198 * SourceDevice = caller's device
199 * TargetDevice = Device to attach
200 * RETURNS: On success the previously highest device
204 IoAttachDeviceToDeviceStack (
205 PDEVICE_OBJECT SourceDevice
,
206 PDEVICE_OBJECT TargetDevice
210 * FUNCTION: Builds a irp to be sent to lower level drivers
212 * MajorFunction = Major function code to be set in the IRP
213 * DeviceObject = Next lower device object
214 * Buffer = Buffer (only required for some major function codes)
215 * Length = Length in bytes of the buffer
216 * StartingOffset = Starting offset on the target device
217 * IoStatusBlock = Storage for status about the operation (optional)
218 * RETURNS: On success the IRP allocated
222 IoBuildAsynchronousFsdRequest (
224 PDEVICE_OBJECT DeviceObject
,
227 PLARGE_INTEGER StartingOffset
,
228 PIO_STATUS_BLOCK IoStatusBlock
232 * FUNCTION: Allocates and sets up an IRP for a device control request
234 * IoControlCode = Type of request
235 * DeviceObject = Target device
236 * InputBuffer = Optional input buffer to the driver
237 * InputBufferLength = Length of the input buffer
238 * OutputBuffer = Optional output buffer
239 * OutputBufferLength = Length of the output buffer
240 * InternalDeviceIoControl = TRUE if the request is internal
241 * Event = Initialized event for the caller to wait for the request
243 * IoStatusBlock = I/O status block to be set when the request is
245 * RETURNS: Returns the IRP created
248 IoBuildDeviceIoControlRequest (
250 PDEVICE_OBJECT DeviceObject
,
252 ULONG InputBufferLength
,
254 ULONG OutputBufferLength
,
255 BOOLEAN InternalDeviceIoControl
,
257 PIO_STATUS_BLOCK IoStatusBlock
265 PVOID VirtualAddress
,
270 IoBuildSynchronousFsdRequest (
272 PDEVICE_OBJECT DeviceObject
,
275 PLARGE_INTEGER StartingOffset
,
277 PIO_STATUS_BLOCK IoStatusBlock
281 * FUNCTION: Sends an irp to the next lower driver
285 PDEVICE_OBJECT DeviceObject
,
296 ACCESS_MASK DesiredAccess
,
297 ULONG DesiredShareAccess
,
298 PFILE_OBJECT FileObject
,
299 PSHARE_ACCESS ShareAccess
,
304 * FUNCTION: Indicates the caller has finished all processing for a given
305 * I/O request and is returning the given IRP to the I/O manager
307 * Irp = Irp to be cancelled
308 * PriorityBoost = Increment by which to boost the priority of the
309 * thread making the request
319 PKINTERRUPT
* InterruptObject
,
320 PKSERVICE_ROUTINE ServiceRoutine
,
321 PVOID ServiceContext
,
322 PKSPIN_LOCK SpinLock
,
325 KIRQL SynchronizeIrql
,
326 KINTERRUPT_MODE InterruptMode
,
328 KAFFINITY ProcessorEnableMask
,
338 * FUNCTION: Allocates memory for and intializes a device object for use for
341 * DriverObject : Driver object passed by iomgr when the driver was
343 * DeviceExtensionSize : Number of bytes for the device extension
344 * DeviceName : Unicode name of device
345 * DeviceType : Device type
346 * DeviceCharacteristics : Bit mask of device characteristics
347 * Exclusive : True if only one thread can access the device at a
351 * DeviceObject : Contains a pointer to allocated device object
352 * if the call succeeded
353 * NOTES: See the DDK documentation for more information
357 PDRIVER_OBJECT DriverObject
,
358 ULONG DeviceExtensionSize
,
359 PUNICODE_STRING DeviceName
,
360 DEVICE_TYPE DeviceType
,
361 ULONG DeviceCharacteristics
,
363 PDEVICE_OBJECT
* DeviceObject
369 OUT PHANDLE FileHandle
,
370 IN ACCESS_MASK DesiredAccess
,
371 IN POBJECT_ATTRIBUTES ObjectAttributes
,
372 OUT PIO_STATUS_BLOCK IoStatusBlock
,
373 IN PLARGE_INTEGER AllocationSize OPTIONAL
,
374 IN ULONG FileAttributes
,
375 IN ULONG ShareAccess
,
376 IN ULONG CreateDisposition
,
377 IN ULONG CreateOptions
,
378 IN PVOID EaBuffer OPTIONAL
,
380 IN CREATE_FILE_TYPE CreateFileType
,
381 IN ULONG ExtraCreateParameters
,
385 IoCreateNotificationEvent (
386 PUNICODE_STRING EventName
,
392 IoCreateSymbolicLink (
393 PUNICODE_STRING SymbolicLinkName
,
394 PUNICODE_STRING DeviceName
398 IoCreateSynchronizationEvent (
399 PUNICODE_STRING EventName
,
405 IoCreateUnprotectedSymbolicLink (
406 PUNICODE_STRING SymbolicLinkName
,
407 PUNICODE_STRING DeviceName
413 PUNICODE_STRING ArcName
418 PCONTROLLER_OBJECT ControllerObject
423 PDEVICE_OBJECT DeviceObject
428 IoDeleteSymbolicLink (
429 PUNICODE_STRING SymbolicLinkName
434 PDEVICE_OBJECT TargetDevice
438 IoDisconnectInterrupt (
439 PKINTERRUPT InterruptObject
443 IoFlushAdapterBuffers (
444 PADAPTER_OBJECT AdapterObject
,
446 PVOID MapRegisterBase
,
449 BOOLEAN WriteToDevice
453 IoFreeAdapterChannel (
454 PADAPTER_OBJECT AdapterObject
459 PCONTROLLER_OBJECT ControllerObject
469 PADAPTER_OBJECT AdapterObject
,
470 PVOID MapRegisterBase
,
471 ULONG NumberOfMapRegisters
480 IoGetBaseFileSystemDeviceObject (
481 IN PFILE_OBJECT FileObject
483 PCONFIGURATION_INFORMATION
484 IoGetConfigurationInformation (VOID
);
488 * FUNCTION: Returns a pointer to the callers stack location in the irp
491 IoGetCurrentIrpStackLocation (
496 IoGetCurrentProcess (VOID
);
499 IoGetDeviceObjectPointer (
500 PUNICODE_STRING ObjectName
,
501 ACCESS_MASK DesiredAccess
,
502 PFILE_OBJECT
* FileObject
,
503 PDEVICE_OBJECT
* DeviceObject
507 IoGetDeviceToVerify (
512 IoGetFileObjectGenericMapping (VOID
);
515 IoGetFunctionCodeFromCtlCode (
520 IoGetInitialStack (VOID
);
526 IoGetNextIrpStackLocation (
532 IoGetRelatedDeviceObject (
533 PFILE_OBJECT FileObject
537 IoInitializeDpcRequest (
538 PDEVICE_OBJECT DeviceObject
,
539 PIO_DPC_ROUTINE DpcRoutine
543 * FUNCTION: Initalizes an irp allocated by the caller
545 * Irp = IRP to initalize
546 * PacketSize = Size in bytes of the IRP
547 * StackSize = Number of stack locations in the IRP
558 PDEVICE_OBJECT DeviceObject
,
559 PIO_TIMER_ROUTINE TimerRoutine
,
564 IoIsErrorUserInduced (
569 IoIsTotalDeviceFailure (
574 IoMakeAssociatedIrp (
581 PADAPTER_OBJECT AdapterObject
,
583 PVOID MapRegisterBase
,
586 BOOLEAN WriteToDevice
590 * FUNCTION: Marks an IRP as pending
593 * NOTE: If a driver doesn't complete the irp in its dispatch routine it
594 * must mark it pending otherwise the I/O manager will complete it on
595 * return from the dispatch routine.
603 IoQueryDeviceDescription (
604 PINTERFACE_TYPE BusType
,
606 PCONFIGURATION_TYPE ControllerType
,
607 PULONG ControllerNumber
,
608 PCONFIGURATION_TYPE PeripheralType
,
609 PULONG PeripheralNumber
,
610 PIO_QUERY_DEVICE_ROUTINE CalloutRoutine
,
618 PDEVICE_OBJECT RealDeviceObject
622 IoRaiseHardInformationalError (
623 NTSTATUS ErrorStatus
,
624 PUNICODE_STRING String
,
629 IoReadPartitionTable (
630 PDEVICE_OBJECT DeviceObject
,
632 BOOLEAN ReturnedRecognizedPartitions
,
633 struct _DRIVE_LAYOUT_INFORMATION
** PBuffer
637 IoRegisterDriverReinitialization (
638 PDRIVER_OBJECT DriverObject
,
639 PDRIVER_REINITIALIZE ReinitRoutine
,
644 IoRegisterShutdownNotification (
645 PDEVICE_OBJECT DeviceObject
649 IoReleaseCancelSpinLock (
654 IoRemoveShareAccess (
655 PFILE_OBJECT FileObject
,
656 PSHARE_ACCESS ShareAccess
660 IoReportResourceUsage (
661 PUNICODE_STRING DriverClassName
,
662 PDRIVER_OBJECT DriverObject
,
663 PCM_RESOURCE_LIST DriverList
,
664 ULONG DriverListSize
,
665 PDEVICE_OBJECT DeviceObject
,
666 PCM_RESOURCE_LIST DeviceList
,
667 ULONG DeviceListSize
,
668 BOOLEAN OverrideConflict
,
669 PBOOLEAN ConflictDetected
674 PDEVICE_OBJECT DeviceObject
,
682 PDRIVER_CANCEL CancelRoutine
686 IoSetCompletionRoutine (
688 PIO_COMPLETION_ROUTINE CompletionRoutine
,
690 BOOLEAN InvokeOnSuccess
,
691 BOOLEAN InvokeOnError
,
692 BOOLEAN InvokeOnCancel
696 IoSetHardErrorOrVerifyDevice (
698 PDEVICE_OBJECT DeviceObject
702 IoSetNextIrpStackLocation (
707 IoSetPartitionInformation (
708 PDEVICE_OBJECT DeviceObject
,
710 ULONG PartitionNumber
,
716 ACCESS_MASK DesiredAccess
,
717 ULONG DesiredShareAccess
,
718 PFILE_OBJECT FileObject
,
719 PSHARE_ACCESS ShareAccess
723 * FUNCTION: Determines the size of an IRP
725 * StackSize = number of stack locations in the IRP
726 * RETURNS: The size of the IRP in bytes
734 * FUNCTION: Dequeues the next IRP from the device's associated queue and
735 * calls its StartIo routine
737 * DeviceObject = Device object
738 * Cancelable = True if IRPs in the queue can be cancelled
742 PDEVICE_OBJECT DeviceObject
,
747 IoStartNextPacketByKey (
748 PDEVICE_OBJECT DeviceObject
,
754 * FUNCTION: Calls the drivers StartIO routine with the IRP or queues it if
757 * DeviceObject = Device to pass the IRP to
758 * Irp = Irp to be processed
759 * Key = Optional value for where to insert the IRP
760 * CancelFunction = Entry point for a driver supplied cancel function
764 PDEVICE_OBJECT DeviceObject
,
767 PDRIVER_CANCEL CancelFunction
772 PDEVICE_OBJECT DeviceObject
777 PDEVICE_OBJECT DeviceObject
781 IoUnregisterShutdownNotification (
782 PDEVICE_OBJECT DeviceObject
786 IoUpdateShareAccess (
787 PFILE_OBJECT FileObject
,
788 PSHARE_ACCESS ShareAccess
792 IoWriteErrorLogEntry (
797 IoWritePartitionTable (
798 PDEVICE_OBJECT DeviceObject
,
800 ULONG SectorsPerTrack
,
802 struct _DRIVE_LAYOUT_INFORMATION
* PBuffer
809 IoQueryFileVolumeInformation (
810 IN PFILE_OBJECT FileObject
,
811 IN FS_INFORMATION_CLASS FsInformationClass
,
813 OUT PVOID FsInformation
,
814 OUT PULONG ReturnedLength
817 NTKERNELAPI
// confirmed - Undocumented because it does not require a valid file handle
819 IoQueryFileInformation (
820 IN PFILE_OBJECT FileObject
,
821 IN FILE_INFORMATION_CLASS FileInformationClass
,
823 OUT PVOID FileInformation
,
824 OUT PULONG ReturnedLength
828 IoRegisterFileSystem (
829 PDEVICE_OBJECT DeviceObject
833 IoGetAttachedDevice (
834 PDEVICE_OBJECT DeviceObject
838 IoCreateStreamFileObject (
839 PFILE_OBJECT FileObject
,
840 PDEVICE_OBJECT DeviceObject