1 /* $Id: iofuncs.h,v 1.7 2000/03/06 01:02:30 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
110 * FUNCTION: Allocates an MDL large enough to map the supplied buffer
112 * VirtualAddress = base virtual address of the buffer to be mapped
113 * Length = length of the buffer to be mapped
114 * SecondaryBuffer = Whether the buffer is primary or secondary
115 * ChargeQuota = Charge non-paged pool quota to current thread
116 * Irp = Optional irp to be associated with the MDL
117 * RETURNS: On the success the allocated MDL
122 PVOID VirtualAddress
,
124 BOOLEAN SecondaryBuffer
,
130 * FUNCTION: Creates a symbolic link between the ARC name of a physical
131 * device and the name of the corresponding device object
133 * ArcName = ARC name of the device
134 * DeviceName = Name of the device object
138 PUNICODE_STRING ArcName
,
139 PUNICODE_STRING DeviceName
148 * FUNCTION: Takes a list of requested hardware resources and allocates them
152 * DriverObject = Driver object passed to the DriverEntry routine
154 * RequestedResources = List of resources
159 PUNICODE_STRING RegistryPath
,
160 PUNICODE_STRING DriverClassName
,
161 PDRIVER_OBJECT DriverObject
,
162 PDEVICE_OBJECT DeviceObject
,
163 PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources
,
164 PCM_RESOURCE_LIST
* AllocatedResources
168 * FUNCTION: Attaches the callers device object to a named target device
170 * SourceDevice = caller's device
171 * TargetDevice = Name of the target device
172 * AttachedDevice = Caller allocated storage. On return contains
173 * a pointer to the target device
174 * RETURNS: Success or failure code
178 PDEVICE_OBJECT SourceDevice
,
179 PUNICODE_STRING TargetDevice
,
180 PDEVICE_OBJECT
* AttachedDevice
186 * SourceDevice = device to attach
187 * TargetDevice = device to be attached to
188 * RETURNS: Success or failure code
191 IoAttachDeviceByPointer (
192 PDEVICE_OBJECT SourceDevice
,
193 PDEVICE_OBJECT TargetDevice
197 * FUNCTION: Attaches the callers device to the highest device in the chain
199 * SourceDevice = caller's device
200 * TargetDevice = Device to attach
201 * RETURNS: On success the previously highest device
205 IoAttachDeviceToDeviceStack (
206 PDEVICE_OBJECT SourceDevice
,
207 PDEVICE_OBJECT TargetDevice
211 * FUNCTION: Builds a irp to be sent to lower level drivers
213 * MajorFunction = Major function code to be set in the IRP
214 * DeviceObject = Next lower device object
215 * Buffer = Buffer (only required for some major function codes)
216 * Length = Length in bytes of the buffer
217 * StartingOffset = Starting offset on the target device
218 * IoStatusBlock = Storage for status about the operation (optional)
219 * RETURNS: On success the IRP allocated
223 IoBuildAsynchronousFsdRequest (
225 PDEVICE_OBJECT DeviceObject
,
228 PLARGE_INTEGER StartingOffset
,
229 PIO_STATUS_BLOCK IoStatusBlock
233 * FUNCTION: Allocates and sets up an IRP for a device control request
235 * IoControlCode = Type of request
236 * DeviceObject = Target device
237 * InputBuffer = Optional input buffer to the driver
238 * InputBufferLength = Length of the input buffer
239 * OutputBuffer = Optional output buffer
240 * OutputBufferLength = Length of the output buffer
241 * InternalDeviceIoControl = TRUE if the request is internal
242 * Event = Initialized event for the caller to wait for the request
244 * IoStatusBlock = I/O status block to be set when the request is
246 * RETURNS: Returns the IRP created
249 IoBuildDeviceIoControlRequest (
251 PDEVICE_OBJECT DeviceObject
,
253 ULONG InputBufferLength
,
255 ULONG OutputBufferLength
,
256 BOOLEAN InternalDeviceIoControl
,
258 PIO_STATUS_BLOCK IoStatusBlock
266 PVOID VirtualAddress
,
271 IoBuildSynchronousFsdRequest (
273 PDEVICE_OBJECT DeviceObject
,
276 PLARGE_INTEGER StartingOffset
,
278 PIO_STATUS_BLOCK IoStatusBlock
282 * FUNCTION: Sends an irp to the next lower driver
287 PDEVICE_OBJECT DeviceObject
,
293 PDEVICE_OBJECT DeviceObject
,
303 ACCESS_MASK DesiredAccess
,
304 ULONG DesiredShareAccess
,
305 PFILE_OBJECT FileObject
,
306 PSHARE_ACCESS ShareAccess
,
311 * FUNCTION: Indicates the caller has finished all processing for a given
312 * I/O request and is returning the given IRP to the I/O manager
314 * Irp = Irp to be cancelled
315 * PriorityBoost = Increment by which to boost the priority of the
316 * thread making the request
332 PKINTERRUPT
* InterruptObject
,
333 PKSERVICE_ROUTINE ServiceRoutine
,
334 PVOID ServiceContext
,
335 PKSPIN_LOCK SpinLock
,
338 KIRQL SynchronizeIrql
,
339 KINTERRUPT_MODE InterruptMode
,
341 KAFFINITY ProcessorEnableMask
,
351 * FUNCTION: Allocates memory for and intializes a device object for use for
354 * DriverObject : Driver object passed by iomgr when the driver was
356 * DeviceExtensionSize : Number of bytes for the device extension
357 * DeviceName : Unicode name of device
358 * DeviceType : Device type
359 * DeviceCharacteristics : Bit mask of device characteristics
360 * Exclusive : True if only one thread can access the device at a
364 * DeviceObject : Contains a pointer to allocated device object
365 * if the call succeeded
366 * NOTES: See the DDK documentation for more information
370 PDRIVER_OBJECT DriverObject
,
371 ULONG DeviceExtensionSize
,
372 PUNICODE_STRING DeviceName
,
373 DEVICE_TYPE DeviceType
,
374 ULONG DeviceCharacteristics
,
376 PDEVICE_OBJECT
* DeviceObject
382 OUT PHANDLE FileHandle
,
383 IN ACCESS_MASK DesiredAccess
,
384 IN POBJECT_ATTRIBUTES ObjectAttributes
,
385 OUT PIO_STATUS_BLOCK IoStatusBlock
,
386 IN PLARGE_INTEGER AllocationSize OPTIONAL
,
387 IN ULONG FileAttributes
,
388 IN ULONG ShareAccess
,
389 IN ULONG CreateDisposition
,
390 IN ULONG CreateOptions
,
391 IN PVOID EaBuffer OPTIONAL
,
393 IN CREATE_FILE_TYPE CreateFileType
,
394 IN ULONG ExtraCreateParameters
,
398 IoCreateNotificationEvent (
399 PUNICODE_STRING EventName
,
405 IoCreateSymbolicLink (
406 PUNICODE_STRING SymbolicLinkName
,
407 PUNICODE_STRING DeviceName
411 IoCreateSynchronizationEvent (
412 PUNICODE_STRING EventName
,
418 IoCreateUnprotectedSymbolicLink (
419 PUNICODE_STRING SymbolicLinkName
,
420 PUNICODE_STRING DeviceName
426 PUNICODE_STRING ArcName
431 PCONTROLLER_OBJECT ControllerObject
436 PDEVICE_OBJECT DeviceObject
441 IoDeleteSymbolicLink (
442 PUNICODE_STRING SymbolicLinkName
447 PDEVICE_OBJECT TargetDevice
451 IoDisconnectInterrupt (
452 PKINTERRUPT InterruptObject
456 IoFlushAdapterBuffers (
457 PADAPTER_OBJECT AdapterObject
,
459 PVOID MapRegisterBase
,
462 BOOLEAN WriteToDevice
466 IoFreeAdapterChannel (
467 PADAPTER_OBJECT AdapterObject
472 PCONTROLLER_OBJECT ControllerObject
481 PADAPTER_OBJECT AdapterObject
,
482 PVOID MapRegisterBase
,
483 ULONG NumberOfMapRegisters
492 IoGetBaseFileSystemDeviceObject (
493 IN PFILE_OBJECT FileObject
495 PCONFIGURATION_INFORMATION
496 IoGetConfigurationInformation (VOID
);
500 * FUNCTION: Returns a pointer to the callers stack location in the irp
503 IoGetCurrentIrpStackLocation (
508 IoGetCurrentProcess (VOID
);
511 IoGetDeviceObjectPointer (
512 PUNICODE_STRING ObjectName
,
513 ACCESS_MASK DesiredAccess
,
514 PFILE_OBJECT
* FileObject
,
515 PDEVICE_OBJECT
* DeviceObject
519 IoGetDeviceToVerify (
523 IoGetFileObjectGenericMapping (VOID
);
526 IoGetFunctionCodeFromCtlCode (
531 IoGetInitialStack (VOID
);
537 IoGetNextIrpStackLocation (
543 IoGetRelatedDeviceObject (
544 PFILE_OBJECT FileObject
548 IoInitializeDpcRequest (
549 PDEVICE_OBJECT DeviceObject
,
550 PIO_DPC_ROUTINE DpcRoutine
554 * FUNCTION: Initalizes an irp allocated by the caller
556 * Irp = IRP to initalize
557 * PacketSize = Size in bytes of the IRP
558 * StackSize = Number of stack locations in the IRP
570 PDEVICE_OBJECT DeviceObject
,
571 PIO_TIMER_ROUTINE TimerRoutine
,
576 IoIsErrorUserInduced (
581 IoIsOperationSynchronous (
585 IoIsTotalDeviceFailure (
590 IoMakeAssociatedIrp (
596 PADAPTER_OBJECT AdapterObject
,
598 PVOID MapRegisterBase
,
601 BOOLEAN WriteToDevice
605 * FUNCTION: Marks an IRP as pending
608 * NOTE: If a driver doesn't complete the irp in its dispatch routine it
609 * must mark it pending otherwise the I/O manager will complete it on
610 * return from the dispatch routine.
618 IoQueryDeviceDescription (
619 PINTERFACE_TYPE BusType
,
621 PCONFIGURATION_TYPE ControllerType
,
622 PULONG ControllerNumber
,
623 PCONFIGURATION_TYPE PeripheralType
,
624 PULONG PeripheralNumber
,
625 PIO_QUERY_DEVICE_ROUTINE CalloutRoutine
,
633 PDEVICE_OBJECT RealDeviceObject
637 IoRaiseHardInformationalError (
638 NTSTATUS ErrorStatus
,
639 PUNICODE_STRING String
,
644 IoReadPartitionTable (
645 PDEVICE_OBJECT DeviceObject
,
647 BOOLEAN ReturnedRecognizedPartitions
,
648 struct _DRIVE_LAYOUT_INFORMATION
** PBuffer
652 IoRegisterDriverReinitialization (
653 PDRIVER_OBJECT DriverObject
,
654 PDRIVER_REINITIALIZE ReinitRoutine
,
659 IoRegisterShutdownNotification (
660 PDEVICE_OBJECT DeviceObject
664 IoReleaseCancelSpinLock (
669 IoRemoveShareAccess (
670 PFILE_OBJECT FileObject
,
671 PSHARE_ACCESS ShareAccess
675 IoReportResourceUsage (
676 PUNICODE_STRING DriverClassName
,
677 PDRIVER_OBJECT DriverObject
,
678 PCM_RESOURCE_LIST DriverList
,
679 ULONG DriverListSize
,
680 PDEVICE_OBJECT DeviceObject
,
681 PCM_RESOURCE_LIST DeviceList
,
682 ULONG DeviceListSize
,
683 BOOLEAN OverrideConflict
,
684 PBOOLEAN ConflictDetected
689 PDEVICE_OBJECT DeviceObject
,
697 PDRIVER_CANCEL CancelRoutine
701 IoSetCompletionRoutine (
703 PIO_COMPLETION_ROUTINE CompletionRoutine
,
705 BOOLEAN InvokeOnSuccess
,
706 BOOLEAN InvokeOnError
,
707 BOOLEAN InvokeOnCancel
711 IoSetHardErrorOrVerifyDevice (
713 PDEVICE_OBJECT DeviceObject
717 IoSetNextIrpStackLocation (
722 IoSetPartitionInformation (
723 PDEVICE_OBJECT DeviceObject
,
725 ULONG PartitionNumber
,
731 ACCESS_MASK DesiredAccess
,
732 ULONG DesiredShareAccess
,
733 PFILE_OBJECT FileObject
,
734 PSHARE_ACCESS ShareAccess
738 * FUNCTION: Determines the size of an IRP
740 * StackSize = number of stack locations in the IRP
741 * RETURNS: The size of the IRP in bytes
749 * FUNCTION: Dequeues the next IRP from the device's associated queue and
750 * calls its StartIo routine
752 * DeviceObject = Device object
753 * Cancelable = True if IRPs in the queue can be cancelled
757 PDEVICE_OBJECT DeviceObject
,
762 IoStartNextPacketByKey (
763 PDEVICE_OBJECT DeviceObject
,
769 * FUNCTION: Calls the drivers StartIO routine with the IRP or queues it if
772 * DeviceObject = Device to pass the IRP to
773 * Irp = Irp to be processed
774 * Key = Optional value for where to insert the IRP
775 * CancelFunction = Entry point for a driver supplied cancel function
779 PDEVICE_OBJECT DeviceObject
,
782 PDRIVER_CANCEL CancelFunction
787 PDEVICE_OBJECT DeviceObject
792 PDEVICE_OBJECT DeviceObject
796 IoUnregisterShutdownNotification (
797 PDEVICE_OBJECT DeviceObject
801 IoUpdateShareAccess (
802 PFILE_OBJECT FileObject
,
803 PSHARE_ACCESS ShareAccess
807 IoWriteErrorLogEntry (
812 IoWritePartitionTable (
813 PDEVICE_OBJECT DeviceObject
,
815 ULONG SectorsPerTrack
,
817 struct _DRIVE_LAYOUT_INFORMATION
* PBuffer
824 IoQueryFileVolumeInformation (
825 IN PFILE_OBJECT FileObject
,
826 IN FS_INFORMATION_CLASS FsInformationClass
,
828 OUT PVOID FsInformation
,
829 OUT PULONG ReturnedLength
832 NTKERNELAPI
// confirmed - Undocumented because it does not require a valid file handle
834 IoQueryFileInformation (
835 IN PFILE_OBJECT FileObject
,
836 IN FILE_INFORMATION_CLASS FileInformationClass
,
838 OUT PVOID FileInformation
,
839 OUT PULONG ReturnedLength
843 IoRegisterFileSystem (
844 PDEVICE_OBJECT DeviceObject
848 IoGetAttachedDevice (
849 PDEVICE_OBJECT DeviceObject
853 IoCreateStreamFileObject (
854 PFILE_OBJECT FileObject
,
855 PDEVICE_OBJECT DeviceObject