Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

io.h File Reference

#include "pshpack4.h"
#include "poppack.h"

Go to the source code of this file.

Classes

struct  _INITIALIZATION_CONTEXT
struct  _NAMED_PIPE_CREATE_PARAMETERS
struct  _MAILSLOT_CREATE_PARAMETERS
struct  DUMP_STACK_IMAGE
struct  DUMP_STACK_CONTEXT
struct  _FAST_IO_DISPATCH
struct  _IO_INTERRUPT_STRUCTURE
struct  _IO_SECURITY_CONTEXT
struct  _IO_TIMER
struct  _IO_CLIENT_EXTENSION
struct  _VPB
struct  _WAIT_CONTEXT_BLOCK
struct  _CONTROLLER_OBJECT
struct  _DEVICE_OBJECT
struct  _DEVOBJ_EXTENSION
struct  _DRIVER_EXTENSION
struct  _DRIVER_OBJECT
struct  _DEVICE_HANDLER_OBJECT
struct  _SECTION_OBJECT_POINTERS
struct  _IO_COMPLETION_CONTEXT
struct  _FILE_OBJECT
struct  _IRP
struct  _DEVICE_RELATIONS
struct  _INTERFACE
struct  _DEVICE_CAPABILITIES
struct  _POWER_SEQUENCE
struct  _IO_STACK_LOCATION
struct  _SHARE_ACCESS
struct  _CONFIGURATION_INFORMATION
struct  _BOOTDISK_INFORMATION
struct  _IO_REMOVE_LOCK_COMMON_BLOCK
struct  _IO_REMOVE_LOCK_DBG_BLOCK
struct  _IO_REMOVE_LOCK
struct  _BOOT_LOG_RECORD

Defines

#define IO_TYPE_ADAPTER   0x00000001
#define IO_TYPE_CONTROLLER   0x00000002
#define IO_TYPE_DEVICE   0x00000003
#define IO_TYPE_DRIVER   0x00000004
#define IO_TYPE_FILE   0x00000005
#define IO_TYPE_IRP   0x00000006
#define IO_TYPE_MASTER_ADAPTER   0x00000007
#define IO_TYPE_OPEN_PACKET   0x00000008
#define IO_TYPE_TIMER   0x00000009
#define IO_TYPE_VPB   0x0000000a
#define IO_TYPE_ERROR_LOG   0x0000000b
#define IO_TYPE_ERROR_MESSAGE   0x0000000c
#define IO_TYPE_DEVICE_OBJECT_EXTENSION   0x0000000d
#define IRP_MJ_CREATE   0x00
#define IRP_MJ_CREATE_NAMED_PIPE   0x01
#define IRP_MJ_CLOSE   0x02
#define IRP_MJ_READ   0x03
#define IRP_MJ_WRITE   0x04
#define IRP_MJ_QUERY_INFORMATION   0x05
#define IRP_MJ_SET_INFORMATION   0x06
#define IRP_MJ_QUERY_EA   0x07
#define IRP_MJ_SET_EA   0x08
#define IRP_MJ_FLUSH_BUFFERS   0x09
#define IRP_MJ_QUERY_VOLUME_INFORMATION   0x0a
#define IRP_MJ_SET_VOLUME_INFORMATION   0x0b
#define IRP_MJ_DIRECTORY_CONTROL   0x0c
#define IRP_MJ_FILE_SYSTEM_CONTROL   0x0d
#define IRP_MJ_DEVICE_CONTROL   0x0e
#define IRP_MJ_INTERNAL_DEVICE_CONTROL   0x0f
#define IRP_MJ_SHUTDOWN   0x10
#define IRP_MJ_LOCK_CONTROL   0x11
#define IRP_MJ_CLEANUP   0x12
#define IRP_MJ_CREATE_MAILSLOT   0x13
#define IRP_MJ_QUERY_SECURITY   0x14
#define IRP_MJ_SET_SECURITY   0x15
#define IRP_MJ_POWER   0x16
#define IRP_MJ_SYSTEM_CONTROL   0x17
#define IRP_MJ_DEVICE_CHANGE   0x18
#define IRP_MJ_QUERY_QUOTA   0x19
#define IRP_MJ_SET_QUOTA   0x1a
#define IRP_MJ_PNP   0x1b
#define IRP_MJ_PNP_POWER   IRP_MJ_PNP
#define IRP_MJ_MAXIMUM_FUNCTION   0x1b
#define IRP_MJ_SCSI   IRP_MJ_INTERNAL_DEVICE_CONTROL
#define IRP_MN_QUERY_DIRECTORY   0x01
#define IRP_MN_NOTIFY_CHANGE_DIRECTORY   0x02
#define IRP_MN_USER_FS_REQUEST   0x00
#define IRP_MN_MOUNT_VOLUME   0x01
#define IRP_MN_VERIFY_VOLUME   0x02
#define IRP_MN_LOAD_FILE_SYSTEM   0x03
#define IRP_MN_TRACK_LINK   0x04
#define IRP_MN_KERNEL_CALL   0x04
#define IRP_MN_LOCK   0x01
#define IRP_MN_UNLOCK_SINGLE   0x02
#define IRP_MN_UNLOCK_ALL   0x03
#define IRP_MN_UNLOCK_ALL_BY_KEY   0x04
#define IRP_MN_NORMAL   0x00
#define IRP_MN_DPC   0x01
#define IRP_MN_MDL   0x02
#define IRP_MN_COMPLETE   0x04
#define IRP_MN_COMPRESSED   0x08
#define IRP_MN_MDL_DPC   (IRP_MN_MDL | IRP_MN_DPC)
#define IRP_MN_COMPLETE_MDL   (IRP_MN_COMPLETE | IRP_MN_MDL)
#define IRP_MN_COMPLETE_MDL_DPC   (IRP_MN_COMPLETE_MDL | IRP_MN_DPC)
#define IRP_MN_SCSI_CLASS   0x01
#define IRP_MN_START_DEVICE   0x00
#define IRP_MN_QUERY_REMOVE_DEVICE   0x01
#define IRP_MN_REMOVE_DEVICE   0x02
#define IRP_MN_CANCEL_REMOVE_DEVICE   0x03
#define IRP_MN_STOP_DEVICE   0x04
#define IRP_MN_QUERY_STOP_DEVICE   0x05
#define IRP_MN_CANCEL_STOP_DEVICE   0x06
#define IRP_MN_QUERY_DEVICE_RELATIONS   0x07
#define IRP_MN_QUERY_INTERFACE   0x08
#define IRP_MN_QUERY_CAPABILITIES   0x09
#define IRP_MN_QUERY_RESOURCES   0x0A
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS   0x0B
#define IRP_MN_QUERY_DEVICE_TEXT   0x0C
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS   0x0D
#define IRP_MN_READ_CONFIG   0x0F
#define IRP_MN_WRITE_CONFIG   0x10
#define IRP_MN_EJECT   0x11
#define IRP_MN_SET_LOCK   0x12
#define IRP_MN_QUERY_ID   0x13
#define IRP_MN_QUERY_PNP_DEVICE_STATE   0x14
#define IRP_MN_QUERY_BUS_INFORMATION   0x15
#define IRP_MN_DEVICE_USAGE_NOTIFICATION   0x16
#define IRP_MN_SURPRISE_REMOVAL   0x17
#define IRP_MN_QUERY_LEGACY_BUS_INFORMATION   0x18
#define IRP_MN_WAIT_WAKE   0x00
#define IRP_MN_POWER_SEQUENCE   0x01
#define IRP_MN_SET_POWER   0x02
#define IRP_MN_QUERY_POWER   0x03
#define IRP_MN_QUERY_ALL_DATA   0x00
#define IRP_MN_QUERY_SINGLE_INSTANCE   0x01
#define IRP_MN_CHANGE_SINGLE_INSTANCE   0x02
#define IRP_MN_CHANGE_SINGLE_ITEM   0x03
#define IRP_MN_ENABLE_EVENTS   0x04
#define IRP_MN_DISABLE_EVENTS   0x05
#define IRP_MN_ENABLE_COLLECTION   0x06
#define IRP_MN_DISABLE_COLLECTION   0x07
#define IRP_MN_REGINFO   0x08
#define IRP_MN_EXECUTE_METHOD   0x09
#define IRP_MN_SET_TRACE_NOTIFY   0x0A
#define IO_FORCE_ACCESS_CHECK   0x0001
#define IO_OPEN_PAGING_FILE   0x0002
#define IO_OPEN_TARGET_DIRECTORY   0x0004
#define IO_NO_PARAMETER_CHECKING   0x0100
#define IO_REPARSE   0x0
#define IO_REMOUNT   0x1
#define IO_CHECK_CREATE_PARAMETERS   0x0200
#define IO_ATTACH_DEVICE   0x0400
#define IO_ATTACH_DEVICE_API   0x80000000
#define IO_DUMP_MAX_MDL_PAGES   8
#define IO_DUMP_MEMORY_BLOCK_PAGES   8
#define IO_DUMP_COMMON_BUFFER_SIZE   0x2000
#define VPB_MOUNTED   0x00000001
#define VPB_LOCKED   0x00000002
#define VPB_PERSISTENT   0x00000004
#define VPB_REMOVE_PENDING   0x00000008
#define VPB_RAW_MOUNT   0x00000010
#define MAXIMUM_VOLUME_LABEL_LENGTH   (32 * sizeof(WCHAR))
#define DO_VERIFY_VOLUME   0x00000002
#define DO_BUFFERED_IO   0x00000004
#define DO_EXCLUSIVE   0x00000008
#define DO_DIRECT_IO   0x00000010
#define DO_MAP_IO_BUFFER   0x00000020
#define DO_DEVICE_HAS_NAME   0x00000040
#define DO_DEVICE_INITIALIZING   0x00000080
#define DO_SYSTEM_BOOT_PARTITION   0x00000100
#define DO_LONG_TERM_REQUESTS   0x00000200
#define DO_NEVER_LAST_DEVICE   0x00000400
#define DO_SHUTDOWN_REGISTERED   0x00000800
#define DO_BUS_ENUMERATED_DEVICE   0x00001000
#define DO_POWER_PAGABLE   0x00002000
#define DO_POWER_INRUSH   0x00004000
#define DO_POWER_NOOP   0x00008000
#define DO_LOW_PRIORITY_FILESYSTEM   0x00010000
#define DOE_UNLOAD_PENDING   0x00000001
#define DOE_DELETE_PENDING   0x00000002
#define DOE_REMOVE_PENDING   0x00000004
#define DOE_REMOVE_PROCESSED   0x00000008
#define DOE_START_PENDING   0x00000010
#define DRVO_UNLOAD_INVOKED   0x00000001
#define DRVO_LEGACY_DRIVER   0x00000002
#define DRVO_BUILTIN_DRIVER   0x00000004
#define DRVO_REINIT_REGISTERED   0x00000008
#define DRVO_INITIALIZED   0x00000010
#define DRVO_BOOTREINIT_REGISTERED   0x00000020
#define DRVO_LEGACY_RESOURCES   0x00000040
#define FO_FILE_OPEN   0x00000001
#define FO_SYNCHRONOUS_IO   0x00000002
#define FO_ALERTABLE_IO   0x00000004
#define FO_NO_INTERMEDIATE_BUFFERING   0x00000008
#define FO_WRITE_THROUGH   0x00000010
#define FO_SEQUENTIAL_ONLY   0x00000020
#define FO_CACHE_SUPPORTED   0x00000040
#define FO_NAMED_PIPE   0x00000080
#define FO_STREAM_FILE   0x00000100
#define FO_MAILSLOT   0x00000200
#define FO_GENERATE_AUDIT_ON_CLOSE   0x00000400
#define FO_DIRECT_DEVICE_OPEN   0x00000800
#define FO_FILE_MODIFIED   0x00001000
#define FO_FILE_SIZE_CHANGED   0x00002000
#define FO_CLEANUP_COMPLETE   0x00004000
#define FO_TEMPORARY_FILE   0x00008000
#define FO_DELETE_ON_CLOSE   0x00010000
#define FO_OPENED_CASE_SENSITIVE   0x00020000
#define FO_HANDLE_CREATED   0x00040000
#define FO_FILE_FAST_IO_READ   0x00080000
#define FO_RANDOM_ACCESS   0x00100000
#define FO_FILE_OPEN_CANCELLED   0x00200000
#define FO_VOLUME_OPEN   0x00400000
#define IRP_NOCACHE   0x00000001
#define IRP_PAGING_IO   0x00000002
#define IRP_MOUNT_COMPLETION   0x00000002
#define IRP_SYNCHRONOUS_API   0x00000004
#define IRP_ASSOCIATED_IRP   0x00000008
#define IRP_BUFFERED_IO   0x00000010
#define IRP_DEALLOCATE_BUFFER   0x00000020
#define IRP_INPUT_OPERATION   0x00000040
#define IRP_SYNCHRONOUS_PAGING_IO   0x00000040
#define IRP_CREATE_OPERATION   0x00000080
#define IRP_READ_OPERATION   0x00000100
#define IRP_WRITE_OPERATION   0x00000200
#define IRP_CLOSE_OPERATION   0x00000400
#define IRP_DEFER_IO_COMPLETION   0x00000800
#define IRP_OB_QUERY_NAME   0x00001000
#define IRP_HOLD_DEVICE_QUEUE   0x00002000
#define IRP_RETRY_IO_COMPLETION   0x00004000
#define IRP_QUOTA_CHARGED   0x01
#define IRP_ALLOCATED_MUST_SUCCEED   0x02
#define IRP_ALLOCATED_FIXED_SIZE   0x04
#define IRP_LOOKASIDE_ALLOCATION   0x08
#define SL_PENDING_RETURNED   0x01
#define SL_INVOKE_ON_CANCEL   0x20
#define SL_INVOKE_ON_SUCCESS   0x40
#define SL_INVOKE_ON_ERROR   0x80
#define SL_FORCE_ACCESS_CHECK   0x01
#define SL_OPEN_PAGING_FILE   0x02
#define SL_OPEN_TARGET_DIRECTORY   0x04
#define SL_CASE_SENSITIVE   0x80
#define SL_KEY_SPECIFIED   0x01
#define SL_OVERRIDE_VERIFY_VOLUME   0x02
#define SL_WRITE_THROUGH   0x04
#define SL_FT_SEQUENTIAL_WRITE   0x08
#define SL_FAIL_IMMEDIATELY   0x01
#define SL_EXCLUSIVE_LOCK   0x02
#define SL_RESTART_SCAN   0x01
#define SL_RETURN_SINGLE_ENTRY   0x02
#define SL_INDEX_SPECIFIED   0x04
#define SL_WATCH_TREE   0x01
#define SL_ALLOW_RAW_MOUNT   0x01
#define PNP_DEVICE_DISABLED   0x00000001
#define PNP_DEVICE_DONT_DISPLAY_IN_UI   0x00000002
#define PNP_DEVICE_FAILED   0x00000004
#define PNP_DEVICE_REMOVED   0x00000008
#define PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED   0x00000010
#define PNP_DEVICE_NOT_DISABLEABLE   0x00000020
#define POINTER_ALIGNMENT
#define IO_FILE_OBJECT_NON_PAGED_POOL_CHARGE   64
#define IO_FILE_OBJECT_PAGED_POOL_CHARGE   1024
#define IoAssignArcName(ArcName, DeviceName)
#define IoCallDriver(a, b)   IofCallDriver(a,b)
#define IoCompleteRequest(a, b)   IofCompleteRequest(a,b)
#define WDM_MAJORVERSION   0x01
#define WDM_MINORVERSION   0x10
#define IoDeassignArcName(ArcName)
#define IoGetCurrentIrpStackLocation(Irp)   ( (Irp)->Tail.Overlay.CurrentStackLocation )
#define IoGetFunctionCodeFromCtlCode(ControlCode)
#define IoGetNextIrpStackLocation(Irp)
#define IoInitializeDpcRequest(DeviceObject, DpcRoutine)
#define IoIsErrorUserInduced(Status)
#define IoIsFileOpenedExclusively(FileObject)
#define IoMarkIrpPending(Irp)
#define IoRequestDpc(DeviceObject, Irp, Context)
#define IoSetCancelRoutine(Irp, NewCancelRoutine)
#define IoSetCompletionRoutine(Irp, Routine, CompletionContext, Success, Error, Cancel)
#define IoSetNextIrpStackLocation(Irp)
#define IoCopyCurrentIrpStackLocationToNext(Irp)
#define IoSkipCurrentIrpStackLocation(Irp)
#define IoInitializeRemoveLock(Lock, Tag, Maxmin, HighWater)   IoInitializeRemoveLockEx (Lock, Tag, Maxmin, HighWater, sizeof (IO_REMOVE_LOCK))
#define IoAcquireRemoveLock(RemoveLock, Tag)   IoAcquireRemoveLockEx(RemoveLock, Tag, __FILE__, __LINE__, sizeof (IO_REMOVE_LOCK))
#define IoReleaseRemoveLock(RemoveLock, Tag)   IoReleaseRemoveLockEx(RemoveLock, Tag, sizeof (IO_REMOVE_LOCK))
#define IoReleaseRemoveLockAndWait(RemoveLock, Tag)   IoReleaseRemoveLockAndWaitEx(RemoveLock, Tag, sizeof (IO_REMOVE_LOCK))
#define IoSizeOfIrp(StackSize)   ((USHORT) (sizeof( IRP ) + ((StackSize) * (sizeof( IO_STACK_LOCATION )))))
#define _WMIKM_
#define WMIREG_FLAG_CALLBACK   0x80000000
#define WMIREG_FLAG_TRACE_PROVIDER   0x00010000
#define WMIREG_FLAG_TRACE_NOTIFY_MASK   0x00F00000
#define WMIREG_NOTIFY_DISK_IO   1 << 20
#define WMIREG_NOTIFY_TDI_IO   2 << 20
#define WMIREG_ACTION_REGISTER   1
#define WMIREG_ACTION_DEREGISTER   2
#define WMIREG_ACTION_REREGISTER   3
#define WMIREG_ACTION_UPDATE_GUIDS   4
#define WMIREG_ACTION_BLOCK_IRPS   5
#define WMIREGISTER   0
#define WMIUPDATE   1
#define IoWMIDeviceObjectToProviderId(DeviceObject)   ((ULONG)(DeviceObject))
#define IOVERIFIERINIT_PHASE0   0x00000001
#define IOVERIFIERINIT_EVERYTHING_TRACKED   0x00000002
#define IOVERIFIERINIT_ASYNCHRONOUSINIT   0x00000004
#define IOVERIFIERINIT_NO_REINIT   0x00000008
#define IOVERIFIERINIT_VERIFIER_DRIVER_LIST   0x00000010
#define IOVERIFIERINIT_RANDOMLY_CANCEL_IRPS   0x00000020

Typedefs

typedef VOID(* PSTALL_ROUTINE )(IN ULONG Delay)
typedef BOOLEAN(* PDUMP_DRIVER_OPEN )(IN LARGE_INTEGER PartitionOffset)
typedef NTSTATUS(* PDUMP_DRIVER_WRITE )(IN PLARGE_INTEGER DiskByteOffset, IN PMDL Mdl)
typedef VOID(* PDUMP_DRIVER_FINISH )(VOID)
typedef _INITIALIZATION_CONTEXT INITIALIZATION_CONTEXT
typedef _INITIALIZATION_CONTEXTPINITIALIZATION_CONTEXT
typedef NTSTATUS(* PIO_QUERY_DEVICE_ROUTINE )(IN PVOID Context, IN PUNICODE_STRING PathName, IN INTERFACE_TYPE BusType, IN ULONG BusNumber, IN PKEY_VALUE_FULL_INFORMATION *BusInformation, IN CONFIGURATION_TYPE ControllerType, IN ULONG ControllerNumber, IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation, IN CONFIGURATION_TYPE PeripheralType, IN ULONG PeripheralNumber, IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation)
typedef enum _IO_QUERY_DEVICE_DATA_FORMAT IO_QUERY_DEVICE_DATA_FORMAT
typedef enum _IO_QUERY_DEVICE_DATA_FORMATPIO_QUERY_DEVICE_DATA_FORMAT
typedef enum _CREATE_FILE_TYPE CREATE_FILE_TYPE
typedef _NAMED_PIPE_CREATE_PARAMETERS NAMED_PIPE_CREATE_PARAMETERS
typedef _NAMED_PIPE_CREATE_PARAMETERSPNAMED_PIPE_CREATE_PARAMETERS
typedef _MAILSLOT_CREATE_PARAMETERS MAILSLOT_CREATE_PARAMETERS
typedef _MAILSLOT_CREATE_PARAMETERSPMAILSLOT_CREATE_PARAMETERS
typedef * PDUMP_STACK_IMAGE
typedef * PDUMP_STACK_CONTEXT
typedef VOID(* PIO_DPC_ROUTINE )(IN PKDPC Dpc, IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp, IN PVOID Context)
typedef VOID(* PIO_TIMER_ROUTINE )(IN struct _DEVICE_OBJECT *DeviceObject, IN PVOID Context)
typedef NTSTATUS(* PDRIVER_INITIALIZE )(IN struct _DRIVER_OBJECT *DriverObject, IN PUNICODE_STRING RegistryPath)
typedef VOID(* PDRIVER_REINITIALIZE )(IN struct _DRIVER_OBJECT *DriverObject, IN PVOID Context, IN ULONG Count)
typedef VOID(* PDRIVER_CANCEL )(IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp)
typedef NTSTATUS(* PDRIVER_DISPATCH )(IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp)
typedef VOID(* PDRIVER_STARTIO )(IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp)
typedef VOID(* PDRIVER_UNLOAD )(IN struct _DRIVER_OBJECT *DriverObject)
typedef NTSTATUS(* PDRIVER_ADD_DEVICE )(IN struct _DRIVER_OBJECT *DriverObject, IN struct _DEVICE_OBJECT *PhysicalDeviceObject)
typedef VOID(* PDRIVER_FS_NOTIFICATION )(IN struct _DEVICE_OBJECT *DeviceObject, IN BOOLEAN FsActive)
typedef BOOLEAN(* PFAST_IO_CHECK_IF_POSSIBLE )(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, IN BOOLEAN CheckForReadOperation, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
typedef BOOLEAN(* PFAST_IO_READ )(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
typedef BOOLEAN(* PFAST_IO_WRITE )(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, IN PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
typedef BOOLEAN(* PFAST_IO_QUERY_BASIC_INFO )(IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, OUT PFILE_BASIC_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
typedef BOOLEAN(* PFAST_IO_QUERY_STANDARD_INFO )(IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, OUT PFILE_STANDARD_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
typedef BOOLEAN(* PFAST_IO_LOCK )(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, PEPROCESS ProcessId, ULONG Key, BOOLEAN FailImmediately, BOOLEAN ExclusiveLock, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
typedef BOOLEAN(* PFAST_IO_UNLOCK_SINGLE )(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, PEPROCESS ProcessId, ULONG Key, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
typedef BOOLEAN(* PFAST_IO_UNLOCK_ALL )(IN struct _FILE_OBJECT *FileObject, PEPROCESS ProcessId, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
typedef BOOLEAN(* PFAST_IO_UNLOCK_ALL_BY_KEY )(IN struct _FILE_OBJECT *FileObject, PVOID ProcessId, ULONG Key, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
typedef BOOLEAN(* PFAST_IO_DEVICE_CONTROL )(IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferLength, OUT PVOID OutputBuffer OPTIONAL, IN ULONG OutputBufferLength, IN ULONG IoControlCode, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
typedef VOID(* PFAST_IO_ACQUIRE_FILE )(IN struct _FILE_OBJECT *FileObject)
typedef VOID(* PFAST_IO_RELEASE_FILE )(IN struct _FILE_OBJECT *FileObject)
typedef VOID(* PFAST_IO_DETACH_DEVICE )(IN struct _DEVICE_OBJECT *SourceDevice, IN struct _DEVICE_OBJECT *TargetDevice)
typedef BOOLEAN(* PFAST_IO_QUERY_NETWORK_OPEN_INFO )(IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer, OUT struct _IO_STATUS_BLOCK *IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
typedef BOOLEAN(* PFAST_IO_MDL_READ )(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG LockKey, OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
typedef BOOLEAN(* PFAST_IO_MDL_READ_COMPLETE )(IN struct _FILE_OBJECT *FileObject, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject)
typedef BOOLEAN(* PFAST_IO_PREPARE_MDL_WRITE )(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG LockKey, OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
typedef BOOLEAN(* PFAST_IO_MDL_WRITE_COMPLETE )(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject)
typedef NTSTATUS(* PFAST_IO_ACQUIRE_FOR_MOD_WRITE )(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER EndingOffset, OUT struct _ERESOURCE **ResourceToRelease, IN struct _DEVICE_OBJECT *DeviceObject)
typedef NTSTATUS(* PFAST_IO_RELEASE_FOR_MOD_WRITE )(IN struct _FILE_OBJECT *FileObject, IN struct _ERESOURCE *ResourceToRelease, IN struct _DEVICE_OBJECT *DeviceObject)
typedef NTSTATUS(* PFAST_IO_ACQUIRE_FOR_CCFLUSH )(IN struct _FILE_OBJECT *FileObject, IN struct _DEVICE_OBJECT *DeviceObject)
typedef NTSTATUS(* PFAST_IO_RELEASE_FOR_CCFLUSH )(IN struct _FILE_OBJECT *FileObject, IN struct _DEVICE_OBJECT *DeviceObject)
typedef BOOLEAN(* PFAST_IO_READ_COMPRESSED )(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG LockKey, OUT PVOID Buffer, OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus, OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo, IN ULONG CompressedDataInfoLength, IN struct _DEVICE_OBJECT *DeviceObject)
typedef BOOLEAN(* PFAST_IO_WRITE_COMPRESSED )(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG LockKey, IN PVOID Buffer, OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus, IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo, IN ULONG CompressedDataInfoLength, IN struct _DEVICE_OBJECT *DeviceObject)
typedef BOOLEAN(* PFAST_IO_MDL_READ_COMPLETE_COMPRESSED )(IN struct _FILE_OBJECT *FileObject, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject)
typedef BOOLEAN(* PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED )(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject)
typedef BOOLEAN(* PFAST_IO_QUERY_OPEN )(IN struct _IRP *Irp, OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation, IN struct _DEVICE_OBJECT *DeviceObject)
typedef _FAST_IO_DISPATCH FAST_IO_DISPATCH
typedef _FAST_IO_DISPATCHPFAST_IO_DISPATCH
typedef enum _IO_ALLOCATION_ACTION IO_ALLOCATION_ACTION
typedef enum _IO_ALLOCATION_ACTIONPIO_ALLOCATION_ACTION
typedef IO_ALLOCATION_ACTION(* PDRIVER_CONTROL )(IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp, IN PVOID MapRegisterBase, IN PVOID Context)
typedef _IO_INTERRUPT_STRUCTURE IO_INTERRUPT_STRUCTURE
typedef _IO_INTERRUPT_STRUCTUREPIO_INTERRUPT_STRUCTURE
typedef _IO_SECURITY_CONTEXT IO_SECURITY_CONTEXT
typedef _IO_SECURITY_CONTEXTPIO_SECURITY_CONTEXT
typedef _IO_TIMER IO_TIMER
typedef _IO_TIMERPIO_TIMER
typedef _IO_CLIENT_EXTENSION IO_CLIENT_EXTENSION
typedef _IO_CLIENT_EXTENSIONPIO_CLIENT_EXTENSION
typedef _VPB VPB
typedef _VPBPVPB
typedef _ADAPTER_OBJECTPADAPTER_OBJECT
typedef _WAIT_CONTEXT_BLOCK WAIT_CONTEXT_BLOCK
typedef _WAIT_CONTEXT_BLOCKPWAIT_CONTEXT_BLOCK
typedef _CONTROLLER_OBJECT CONTROLLER_OBJECT
typedef _CONTROLLER_OBJECTPCONTROLLER_OBJECT
typedef _DEVICE_OBJECT DEVICE_OBJECT
typedef _DEVICE_OBJECTPDEVICE_OBJECT
typedef _DEVOBJ_EXTENSION DEVOBJ_EXTENSION
typedef _DEVOBJ_EXTENSIONPDEVOBJ_EXTENSION
typedef _DRIVER_EXTENSION DRIVER_EXTENSION
typedef _DRIVER_EXTENSIONPDRIVER_EXTENSION
typedef _DRIVER_OBJECT DRIVER_OBJECT
typedef _DRIVER_OBJECTPDRIVER_OBJECT
typedef _DEVICE_HANDLER_OBJECT DEVICE_HANDLER_OBJECT
typedef _DEVICE_HANDLER_OBJECTPDEVICE_HANDLER_OBJECT
typedef _SECTION_OBJECT_POINTERS SECTION_OBJECT_POINTERS
typedef SECTION_OBJECT_POINTERSPSECTION_OBJECT_POINTERS
typedef _IO_COMPLETION_CONTEXT IO_COMPLETION_CONTEXT
typedef _IO_COMPLETION_CONTEXTPIO_COMPLETION_CONTEXT
typedef _FILE_OBJECT FILE_OBJECT
typedef _FILE_OBJECTPFILE_OBJECT
typedef _IRP IRP
typedef _IRPPIRP
typedef NTSTATUS(* PIO_COMPLETION_ROUTINE )(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
typedef enum _DEVICE_RELATION_TYPE DEVICE_RELATION_TYPE
typedef enum _DEVICE_RELATION_TYPEPDEVICE_RELATION_TYPE
typedef _DEVICE_RELATIONS DEVICE_RELATIONS
typedef _DEVICE_RELATIONSPDEVICE_RELATIONS
typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE DEVICE_USAGE_NOTIFICATION_TYPE
typedef _INTERFACE INTERFACE
typedef _INTERFACEPINTERFACE
typedef _DEVICE_CAPABILITIES DEVICE_CAPABILITIES
typedef _DEVICE_CAPABILITIESPDEVICE_CAPABILITIES
typedef _POWER_SEQUENCE POWER_SEQUENCE
typedef _POWER_SEQUENCEPPOWER_SEQUENCE
typedef * PBUS_QUERY_ID_TYPE
typedef ULONG PNP_DEVICE_STATE
typedef ULONG * PPNP_DEVICE_STATE
typedef * PDEVICE_TEXT_TYPE
typedef _IO_STACK_LOCATION IO_STACK_LOCATION
typedef _IO_STACK_LOCATIONPIO_STACK_LOCATION
typedef _SHARE_ACCESS SHARE_ACCESS
typedef _SHARE_ACCESSPSHARE_ACCESS
typedef _CONFIGURATION_INFORMATION CONFIGURATION_INFORMATION
typedef _CONFIGURATION_INFORMATIONPCONFIGURATION_INFORMATION
typedef _BOOTDISK_INFORMATION BOOTDISK_INFORMATION
typedef _BOOTDISK_INFORMATIONPBOOTDISK_INFORMATION
typedef _IO_REMOVE_LOCK_TRACKING_BLOCKPIO_REMOVE_LOCK_TRACKING_BLOCK
typedef _IO_REMOVE_LOCK_COMMON_BLOCK IO_REMOVE_LOCK_COMMON_BLOCK
typedef _IO_REMOVE_LOCK_DBG_BLOCK IO_REMOVE_LOCK_DBG_BLOCK
typedef _IO_REMOVE_LOCK IO_REMOVE_LOCK
typedef _IO_REMOVE_LOCKPIO_REMOVE_LOCK
typedef BOOLEAN(* PIO_TRAVERSE_WORKER )(IN ULONG Level, IN PVOID DeviceNode, IN PDEVICE_OBJECT DeviceObject, IN PVOID Context)
typedef BOOLEAN(* PIO_LEVEL_END_WORKER )(IN ULONG Level, IN PVOID Context)
typedef enum tagWMIACTIONCODE WMIACTIONCODE
typedef NTSTATUS(* WMIENTRY )(IN WMIACTIONCODE ActionCode, IN PVOID DataPath, IN ULONG BufferSize, IN OUT PVOID Buffer)
typedef _IO_WORKITEMPIO_WORKITEM
typedef VOID(* PIO_WORKITEM_ROUTINE )(IN PDEVICE_OBJECT DeviceObject, IN PVOID Context)
typedef _BOOT_LOG_RECORD BOOT_LOG_RECORD
typedef _BOOT_LOG_RECORDPBOOT_LOG_RECORD

Enumerations

enum  _IO_QUERY_DEVICE_DATA_FORMAT { IoQueryDeviceIdentifier = 0, IoQueryDeviceConfigurationData, IoQueryDeviceComponentInformation, IoQueryDeviceMaxData }
enum  _CREATE_FILE_TYPE { CreateFileTypeNone, CreateFileTypeNamedPipe, CreateFileTypeMailslot }
enum  _IO_ALLOCATION_ACTION { KeepObject = 1, DeallocateObject, DeallocateObjectKeepRegisters }
enum  _DEVICE_RELATION_TYPE {
  BusRelations, EjectionRelations, PowerRelations, RemovalRelations,
  TargetDeviceRelation
}
enum  _DEVICE_USAGE_NOTIFICATION_TYPE { DeviceUsageTypeUndefined, DeviceUsageTypePaging, DeviceUsageTypeHibernation, DeviceUsageTypeDumpFile }
enum  BUS_QUERY_ID_TYPE {
  BusQueryDeviceID = 0, BusQueryHardwareIDs = 1, BusQueryCompatibleIDs = 2, BusQueryInstanceID = 3,
  BusQueryDeviceSerialNumber = 4
}
enum  DEVICE_TEXT_TYPE { DeviceTextDescription = 0, DeviceTextLocationInformation = 1 }
enum  tagWMIACTIONCODE {
  WmiGetAllData = IRP_MN_QUERY_ALL_DATA, WmiGetSingleInstance = IRP_MN_QUERY_SINGLE_INSTANCE, WmiChangeSingleInstance = IRP_MN_CHANGE_SINGLE_INSTANCE, WmiChangeSingleItem = IRP_MN_CHANGE_SINGLE_ITEM,
  WmiEnableEvents = IRP_MN_ENABLE_EVENTS, WmiDisableEvents = IRP_MN_DISABLE_EVENTS, WmiEnableCollection = IRP_MN_ENABLE_COLLECTION, WmiDisableCollection = IRP_MN_DISABLE_COLLECTION,
  WmiRegisterInfo = IRP_MN_REGINFO, WmiExecuteMethodCall = IRP_MN_EXECUTE_METHOD
}

Functions

NTSTATUS IoGetDumpStack (IN PWCHAR ModulePrefix, OUT PDUMP_STACK_CONTEXT *DumpStack, IN enum _DEVICE_USAGE_NOTIFICATION_TYPE UsageType, IN ULONG IgnoreDeviceUsageFailure)
NTSTATUS IoInitializeDumpStack (IN PDUMP_STACK_CONTEXT DumpStack, IN PUCHAR MessageBuffer OPTIONAL)
VOID IoGetDumpHiberRanges (IN PVOID HiberContext, IN PDUMP_STACK_CONTEXT DumpStack)
NTKERNELAPI BOOLEAN IoWriteCrashDump (IN ULONG BugCheckCode, IN ULONG_PTR BugCheckParameter1, IN ULONG_PTR BugCheckParameter2, IN ULONG_PTR BugCheckParameter3, IN ULONG_PTR BugCheckParameter4, IN PVOID Context)
VOID IoFreeDumpStack (IN PDUMP_STACK_CONTEXT DumpStack)
NTKERNELAPI VOID IoAcquireCancelSpinLock (OUT PKIRQL Irql)
NTKERNELAPI VOID IoAcquireVpbSpinLock (OUT PKIRQL Irql)
NTKERNELAPI NTSTATUS IoAllocateAdapterChannel (IN PADAPTER_OBJECT AdapterObject, IN PDEVICE_OBJECT DeviceObject, IN ULONG NumberOfMapRegisters, IN PDRIVER_CONTROL ExecutionRoutine, IN PVOID Context)
NTKERNELAPI VOID IoAllocateController (IN PCONTROLLER_OBJECT ControllerObject, IN PDEVICE_OBJECT DeviceObject, IN PDRIVER_CONTROL ExecutionRoutine, IN PVOID Context)
NTKERNELAPI NTSTATUS IoAllocateDriverObjectExtension (IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress, IN ULONG DriverObjectExtensionSize, OUT PVOID *DriverObjectExtension)
NTKERNELAPI PVOID IoAllocateErrorLogEntry (IN PVOID IoObject, IN UCHAR EntrySize)
NTKERNELAPI PIRP IoAllocateIrp (IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
NTKERNELAPI PMDL IoAllocateMdl (IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN OUT PIRP Irp OPTIONAL)
NTKERNELAPI NTSTATUS IoAssignResources (IN PUNICODE_STRING RegistryPath, IN PUNICODE_STRING DriverClassName OPTIONAL, IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources, IN OUT PCM_RESOURCE_LIST *AllocatedResources)
NTKERNELAPI NTSTATUS IoAsynchronousPageWrite (IN PFILE_OBJECT FileObject, IN PMDL MemoryDescriptorList, IN PLARGE_INTEGER StartingOffset, IN PIO_APC_ROUTINE ApcRoutine, IN PVOID ApcContext, OUT PIO_STATUS_BLOCK IoStatusBlock, OUT PIRP *Irp OPTIONAL)
NTKERNELAPI NTSTATUS IoAttachDevice (IN PDEVICE_OBJECT SourceDevice, IN PUNICODE_STRING TargetDevice, OUT PDEVICE_OBJECT *AttachedDevice)
NTKERNELAPI NTSTATUS IoAttachDeviceByPointer (IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
NTKERNELAPI PDEVICE_OBJECT IoAttachDeviceToDeviceStack (IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
NTKERNELAPI PIRP IoBuildAsynchronousFsdRequest (IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN OUT PVOID Buffer OPTIONAL, IN ULONG Length OPTIONAL, IN PLARGE_INTEGER StartingOffset OPTIONAL, IN PIO_STATUS_BLOCK IoStatusBlock OPTIONAL)
NTKERNELAPI PIRP IoBuildDeviceIoControlRequest (IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferLength, OUT PVOID OutputBuffer OPTIONAL, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, OUT PIO_STATUS_BLOCK IoStatusBlock)
NTKERNELAPI VOID IoBuildPartialMdl (IN PMDL SourceMdl, IN OUT PMDL TargetMdl, IN PVOID VirtualAddress, IN ULONG Length)
NTKERNELAPI NTSTATUS IoGetBootDiskInformation (IN OUT PBOOTDISK_INFORMATION BootDiskInformation, IN ULONG Size)
NTSTATUS IoBuildPoDeviceNotifyList (IN OUT PVOID Order)
NTSTATUS IoNotifyPowerOperationVetoed (IN POWER_ACTION VetoedPowerOperation, IN PDEVICE_OBJECT TargetedDeviceObject OPTIONAL, IN PDEVICE_OBJECT VetoingDeviceObject)
NTKERNELAPI PIRP IoBuildSynchronousFsdRequest (IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN OUT PVOID Buffer OPTIONAL, IN ULONG Length OPTIONAL, IN PLARGE_INTEGER StartingOffset OPTIONAL, IN PKEVENT Event, OUT PIO_STATUS_BLOCK IoStatusBlock)
NTKERNELAPI NTSTATUS FASTCALL IofCallDriver (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
NTKERNELAPI BOOLEAN IoCancelIrp (IN PIRP Irp)
NTKERNELAPI VOID IoCancelThreadIo (IN PETHREAD Thread)
NTKERNELAPI NTSTATUS IoCheckDesiredAccess (IN OUT PACCESS_MASK DesiredAccess, IN ACCESS_MASK GrantedAccess)
NTKERNELAPI NTSTATUS IoCheckEaBufferValidity (IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
NTKERNELAPI NTSTATUS IoCheckFunctionAccess (IN ACCESS_MASK GrantedAccess, IN UCHAR MajorFunction, IN UCHAR MinorFunction, IN ULONG IoControlCode, IN PVOID Arg1 OPTIONAL, IN PVOID Arg2 OPTIONAL)
NTKERNELAPI NTSTATUS IoCheckQuerySetFileInformation (IN FILE_INFORMATION_CLASS FileInformationClass, IN ULONG Length, IN BOOLEAN SetOperation)
NTKERNELAPI NTSTATUS IoCheckQuerySetVolumeInformation (IN FS_INFORMATION_CLASS FsInformationClass, IN ULONG Length, IN BOOLEAN SetOperation)
NTKERNELAPI NTSTATUS IoCheckQuotaBufferValidity (IN PFILE_QUOTA_INFORMATION QuotaBuffer, IN ULONG QuotaLength, OUT PULONG ErrorOffset)
NTKERNELAPI NTSTATUS IoCheckShareAccess (IN ACCESS_MASK DesiredAccess, IN ULONG DesiredShareAccess, IN OUT PFILE_OBJECT FileObject, IN OUT PSHARE_ACCESS ShareAccess, IN BOOLEAN Update)
NTKERNELAPI VOID FASTCALL IofCompleteRequest (IN PIRP Irp, IN CCHAR PriorityBoost)
NTKERNELAPI NTSTATUS IoConnectInterrupt (OUT PKINTERRUPT *InterruptObject, IN PKSERVICE_ROUTINE ServiceRoutine, IN PVOID ServiceContext, IN PKSPIN_LOCK SpinLock OPTIONAL, IN ULONG Vector, IN KIRQL Irql, IN KIRQL SynchronizeIrql, IN KINTERRUPT_MODE InterruptMode, IN BOOLEAN ShareVector, IN KAFFINITY ProcessorEnableMask, IN BOOLEAN FloatingSave)
NTKERNELAPI PCONTROLLER_OBJECT IoCreateController (IN ULONG Size)
NTKERNELAPI NTSTATUS IoCreateDevice (IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName OPTIONAL, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
NTKERNELAPI BOOLEAN IoIsWdmVersionAvailable (IN UCHAR MajorVersion, IN UCHAR MinorVersion)
NTKERNELAPI NTSTATUS IoCreateFile (OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG Disposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength, IN CREATE_FILE_TYPE CreateFileType, IN PVOID ExtraCreateParameters OPTIONAL, IN ULONG Options)
NTKERNELAPI PFILE_OBJECT IoCreateStreamFileObject (IN PFILE_OBJECT FileObject OPTIONAL, IN PDEVICE_OBJECT DeviceObject OPTIONAL)
NTKERNELAPI PFILE_OBJECT IoCreateStreamFileObjectLite (IN PFILE_OBJECT FileObject OPTIONAL, IN PDEVICE_OBJECT DeviceObject OPTIONAL)
NTKERNELAPI PKEVENT IoCreateNotificationEvent (IN PUNICODE_STRING EventName, OUT PHANDLE EventHandle)
NTKERNELAPI NTSTATUS IoCreateSymbolicLink (IN PUNICODE_STRING SymbolicLinkName, IN PUNICODE_STRING DeviceName)
NTKERNELAPI PKEVENT IoCreateSynchronizationEvent (IN PUNICODE_STRING EventName, OUT PHANDLE EventHandle)
NTKERNELAPI NTSTATUS IoCreateUnprotectedSymbolicLink (IN PUNICODE_STRING SymbolicLinkName, IN PUNICODE_STRING DeviceName)
NTKERNELAPI VOID IoDeleteController (IN PCONTROLLER_OBJECT ControllerObject)
NTKERNELAPI VOID IoDeleteDevice (IN PDEVICE_OBJECT DeviceObject)
NTKERNELAPI NTSTATUS IoDeleteSymbolicLink (IN PUNICODE_STRING SymbolicLinkName)
NTKERNELAPI VOID IoDetachDevice (IN OUT PDEVICE_OBJECT TargetDevice)
NTKERNELAPI VOID IoDisconnectInterrupt (IN PKINTERRUPT InterruptObject)
NTKERNELAPI VOID IoEnqueueIrp (IN PIRP Irp)
NTKERNELAPI BOOLEAN IoFastQueryNetworkAttributes (IN POBJECT_ATTRIBUTES ObjectAttributes, IN ACCESS_MASK DesiredAccess, IN ULONG OpenOptions, OUT PIO_STATUS_BLOCK IoStatus, OUT PFILE_NETWORK_OPEN_INFORMATION Buffer)
NTKERNELAPI VOID IoFreeController (IN PCONTROLLER_OBJECT ControllerObject)
NTKERNELAPI VOID IoFreeIrp (IN PIRP Irp)
NTKERNELAPI VOID IoFreeMdl (IN PMDL Mdl)
VOID IoFreePoDeviceNotifyList (IN OUT PVOID Order)
NTSTATUS IoGetLegacyVetoList (OUT PWSTR *VetoList OPTIONAL, OUT PPNP_VETO_TYPE VetoType)
NTKERNELAPI PDEVICE_OBJECT IoGetAttachedDevice (IN PDEVICE_OBJECT DeviceObject)
NTKERNELAPI PDEVICE_OBJECT IoGetAttachedDeviceReference (IN PDEVICE_OBJECT DeviceObject)
NTKERNELAPI PDEVICE_OBJECT IoGetBaseFileSystemDeviceObject (IN PFILE_OBJECT FileObject)
NTKERNELAPI PCONFIGURATION_INFORMATION IoGetConfigurationInformation (VOID)
NTKERNELAPI PDEVICE_OBJECT IoGetDeviceToVerify (IN PETHREAD Thread)
NTKERNELAPI PVOID IoGetDriverObjectExtension (IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
NTKERNELAPI PEPROCESS IoGetCurrentProcess (VOID)
NTKERNELAPI NTSTATUS IoGetDeviceObjectPointer (IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
NTKERNELAPI struct _DMA_ADAPTERIoGetDmaAdapter (IN PDEVICE_OBJECT PhysicalDeviceObject, OPTIONALIN struct _DEVICE_DESCRIPTION *DeviceDescription, IN OUT PULONG NumberOfMapRegisters)
NTKERNELAPI PGENERIC_MAPPING IoGetFileObjectGenericMapping (VOID)
NTKERNELAPI PVOID IoGetInitialStack (VOID)
NTKERNELAPI VOID IoGetStackLimits (OUT PULONG_PTR LowLimit, OUT PULONG_PTR HighLimit)
__inline ULONG_PTR IoGetRemainingStackSize (VOID)
NTKERNELAPI PDEVICE_OBJECT IoGetRelatedDeviceObject (IN PFILE_OBJECT FileObject)
NTKERNELAPI ULONG IoGetRequestorProcessId (IN PIRP Irp)
NTKERNELAPI PEPROCESS IoGetRequestorProcess (IN PIRP Irp)
NTKERNELAPI PIRP IoGetTopLevelIrp (VOID)
NTKERNELAPI VOID IoInitializeIrp (IN OUT PIRP Irp, IN USHORT PacketSize, IN CCHAR StackSize)
NTKERNELAPI NTSTATUS IoInitializeTimer (IN PDEVICE_OBJECT DeviceObject, IN PIO_TIMER_ROUTINE TimerRoutine, IN PVOID Context)
NTKERNELAPI VOID IoReuseIrp (IN OUT PIRP Irp, IN NTSTATUS Iostatus)
NTKERNELAPI VOID IoCancelFileOpen (IN PDEVICE_OBJECT DeviceObject, IN PFILE_OBJECT FileObject)
NTKERNELAPI BOOLEAN IoInitSystem (PLOADER_PARAMETER_BLOCK LoaderBlock)
NTKERNELAPI BOOLEAN IoIsOperationSynchronous (IN PIRP Irp)
NTKERNELAPI BOOLEAN IoIsSystemThread (IN PETHREAD Thread)
NTKERNELAPI BOOLEAN IoIsValidNameGraftingBuffer (IN PIRP Irp, IN PREPARSE_DATA_BUFFER ReparseBuffer)
NTKERNELAPI PIRP IoMakeAssociatedIrp (IN PIRP Irp, IN CCHAR StackSize)
NTKERNELAPI BOOLEAN IoPageFileCreated (IN HANDLE FileHandle)
NTKERNELAPI NTSTATUS IoPageRead (IN PFILE_OBJECT FileObject, IN PMDL MemoryDescriptorList, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, OUT PIO_STATUS_BLOCK IoStatusBlock)
NTKERNELAPI NTSTATUS IoQueryDeviceDescription (IN PINTERFACE_TYPE BusType OPTIONAL, IN PULONG BusNumber OPTIONAL, IN PCONFIGURATION_TYPE ControllerType OPTIONAL, IN PULONG ControllerNumber OPTIONAL, IN PCONFIGURATION_TYPE PeripheralType OPTIONAL, IN PULONG PeripheralNumber OPTIONAL, IN PIO_QUERY_DEVICE_ROUTINE CalloutRoutine, IN PVOID Context)
NTKERNELAPI NTSTATUS IoQueryFileInformation (IN PFILE_OBJECT FileObject, IN FILE_INFORMATION_CLASS FileInformationClass, IN ULONG Length, OUT PVOID FileInformation, OUT PULONG ReturnedLength)
NTKERNELAPI NTSTATUS IoQueryVolumeInformation (IN PFILE_OBJECT FileObject, IN FS_INFORMATION_CLASS FsInformationClass, IN ULONG Length, OUT PVOID FsInformation, OUT PULONG ReturnedLength)
NTKERNELAPI VOID IoQueueThreadIrp (IN PIRP Irp)
NTKERNELAPI VOID IoRaiseHardError (IN PIRP Irp, IN PVPB Vpb OPTIONAL, IN PDEVICE_OBJECT RealDeviceObject)
NTKERNELAPI BOOLEAN IoRaiseInformationalHardError (IN NTSTATUS ErrorStatus, IN PUNICODE_STRING String OPTIONAL, IN PKTHREAD Thread OPTIONAL)
NTKERNELAPI BOOLEAN IoSetThreadHardErrorMode (IN BOOLEAN EnableHardErrors)
NTKERNELAPI VOID IoRegisterBootDriverReinitialization (IN PDRIVER_OBJECT DriverObject, IN PDRIVER_REINITIALIZE DriverReinitializationRoutine, IN PVOID Context)
NTKERNELAPI VOID IoRegisterDriverReinitialization (IN PDRIVER_OBJECT DriverObject, IN PDRIVER_REINITIALIZE DriverReinitializationRoutine, IN PVOID Context)
NTKERNELAPI VOID IoRegisterFileSystem (IN OUT PDEVICE_OBJECT DeviceObject)
NTKERNELAPI NTSTATUS IoRegisterFsRegistrationChange (IN PDRIVER_OBJECT DriverObject, IN PDRIVER_FS_NOTIFICATION DriverNotificationRoutine)
NTKERNELAPI NTSTATUS IoRegisterShutdownNotification (IN PDEVICE_OBJECT DeviceObject)
NTKERNELAPI NTSTATUS IoRegisterLastChanceShutdownNotification (IN PDEVICE_OBJECT DeviceObject)
NTKERNELAPI VOID IoReleaseCancelSpinLock (IN KIRQL Irql)
NTKERNELAPI VOID IoReleaseVpbSpinLock (IN KIRQL Irql)
NTKERNELAPI VOID IoRemoveShareAccess (IN PFILE_OBJECT FileObject, IN OUT PSHARE_ACCESS ShareAccess)
NTKERNELAPI NTSTATUS IoReportHalResourceUsage (IN PUNICODE_STRING HalName, IN PCM_RESOURCE_LIST RawResourceList, IN PCM_RESOURCE_LIST TranslatedResourceList, IN ULONG ResourceListSize)
NTKERNELAPI NTSTATUS IoReportResourceUsage (IN PUNICODE_STRING DriverClassName OPTIONAL, IN PDRIVER_OBJECT DriverObject, IN PCM_RESOURCE_LIST DriverList OPTIONAL, IN ULONG DriverListSize OPTIONAL, IN PDEVICE_OBJECT DeviceObject, IN PCM_RESOURCE_LIST DeviceList OPTIONAL, IN ULONG DeviceListSize OPTIONAL, IN BOOLEAN OverrideConflict, OUT PBOOLEAN ConflictDetected)
NTKERNELAPI VOID IoSetDeviceToVerify (IN PETHREAD Thread, IN PDEVICE_OBJECT DeviceObject)
NTKERNELAPI VOID IoSetHardErrorOrVerifyDevice (IN PIRP Irp, IN PDEVICE_OBJECT DeviceObject)
NTKERNELAPI NTSTATUS IoSetInformation (IN PFILE_OBJECT FileObject, IN FILE_INFORMATION_CLASS FileInformationClass, IN ULONG Length, IN PVOID FileInformation)
NTKERNELAPI VOID IoSetShareAccess (IN ACCESS_MASK DesiredAccess, IN ULONG DesiredShareAccess, IN OUT PFILE_OBJECT FileObject, OUT PSHARE_ACCESS ShareAccess)
NTKERNELAPI VOID IoSetTopLevelIrp (IN PIRP Irp)
NTSYSAPI VOID NTAPI IoInitializeRemoveLockEx (IN PIO_REMOVE_LOCK Lock, IN ULONG AllocateTag, IN ULONG MaxLockedMinutes, IN ULONG HighWatermark, IN ULONG RemlockSize)
NTSYSAPI NTSTATUS NTAPI IoAcquireRemoveLockEx (IN PIO_REMOVE_LOCK RemoveLock, IN OPTIONAL PVOID Tag, IN PCSTR File, IN ULONG Line, IN ULONG RemlockSize)
NTSYSAPI VOID NTAPI IoReleaseRemoveLockEx (IN PIO_REMOVE_LOCK RemoveLock, IN PVOID Tag, IN ULONG RemlockSize)
NTSYSAPI VOID NTAPI IoReleaseRemoveLockAndWaitEx (IN PIO_REMOVE_LOCK RemoveLock, IN PVOID Tag, IN ULONG RemlockSize)
NTKERNELAPI VOID IoShutdownSystem (IN ULONG Phase)
NTKERNELAPI VOID IoStartNextPacket (IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN Cancelable)
NTKERNELAPI VOID IoStartNextPacketByKey (IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN Cancelable, IN ULONG Key)
NTKERNELAPI VOID IoStartPacket (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PULONG Key OPTIONAL, IN PDRIVER_CANCEL CancelFunction OPTIONAL)
NTKERNELAPI VOID IoStartTimer (IN PDEVICE_OBJECT DeviceObject)
NTKERNELAPI VOID IoStopTimer (IN PDEVICE_OBJECT DeviceObject)
NTKERNELAPI NTSTATUS IoSynchronousPageWrite (IN PFILE_OBJECT FileObject, IN PMDL MemoryDescriptorList, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, OUT PIO_STATUS_BLOCK IoStatusBlock)
NTKERNELAPI PEPROCESS IoThreadToProcess (IN PETHREAD Thread)
NTKERNELAPI VOID IoUnregisterFileSystem (IN OUT PDEVICE_OBJECT DeviceObject)
NTKERNELAPI VOID IoUnregisterFsRegistrationChange (IN PDRIVER_OBJECT DriverObject, IN PDRIVER_FS_NOTIFICATION DriverNotificationRoutine)
NTKERNELAPI VOID IoUnregisterShutdownNotification (IN PDEVICE_OBJECT DeviceObject)
NTKERNELAPI VOID IoUpdateShareAccess (IN PFILE_OBJECT FileObject, IN OUT PSHARE_ACCESS ShareAccess)
NTKERNELAPI NTSTATUS IoVerifyVolume (IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN AllowRawMount)
NTKERNELAPI VOID IoWriteErrorLogEntry (IN PVOID ElEntry)
VOID IoTraverseDeviceTree (IN BOOLEAN Inverted, IN LONG CurrentLevel, IN PIO_TRAVERSE_WORKER WorkerFunction, IN PIO_LEVEL_END_WORKER LevelEndFunction, IN PVOID Context)
NTKERNELAPI NTSTATUS IoCreateDriver (IN PUNICODE_STRING DriverName, OPTIONAL IN PDRIVER_INITIALIZE InitializationFunction)
NTKERNELAPI VOID IoDeleteDriver (IN PDRIVER_OBJECT DriverObject)
PIO_WORKITEM IoAllocateWorkItem (PDEVICE_OBJECT DeviceObject)
VOID IoFreeWorkItem (PIO_WORKITEM IoWorkItem)
VOID IoQueueWorkItem (IN PIO_WORKITEM IoWorkItem, IN PIO_WORKITEM_ROUTINE WorkerRoutine, IN WORK_QUEUE_TYPE QueueType, IN PVOID Context)
NTKERNELAPI NTSTATUS IoWMIRegistrationControl (IN PDEVICE_OBJECT DeviceObject, IN ULONG Action)
NTKERNELAPI NTSTATUS IoWMIAllocateInstanceIds (IN GUID *Guid, IN ULONG InstanceCount, OUT ULONG *FirstInstanceId)
NTKERNELAPI NTSTATUS IoWMISuggestInstanceName (IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, IN PUNICODE_STRING SymbolicLinkName OPTIONAL, IN BOOLEAN CombineNames, OUT PUNICODE_STRING SuggestedInstanceName)
NTKERNELAPI NTSTATUS IoWMIWriteEvent (IN PVOID WnodeEventItem)
NTKERNELAPI BOOLEAN WMIInitialize ()
NTSTATUS IoSetCrashDumpState (IN SYSTEM_CRASH_STATE_INFORMATION *dumpState)
NTKERNELAPI NTSTATUS IoGetCrashDumpInformation (OUT PSYSTEM_CRASH_DUMP_INFORMATION pCrashDumpInfo)
NTKERNELAPI NTSTATUS IoGetCrashDumpStateInformation (OUT PSYSTEM_CRASH_STATE_INFORMATION pCrashDumpState)
NTSTATUS IoGetRelatedTargetDevice (IN PFILE_OBJECT FileObject, OUT PDEVICE_OBJECT *DeviceObject)
NTKERNELAPI NTSTATUS IoSetDumpRange (IN PVOID DumpContext, IN PVOID StartVA, IN ULONG_PTR Pages, IN BOOLEAN IsPhysicalAddress)
NTKERNELAPI NTSTATUS IoFreeDumpRange (IN PVOID DumpContext, IN PVOID StartVA, IN ULONG_PTR Pages, IN BOOLEAN IsPhysicalAddress)
NTKERNELAPI NTSTATUS IoSetIoCompletion (IN PVOID IoCompletion, IN PVOID KeyContext, IN PVOID ApcContext, IN NTSTATUS IoStatus, IN ULONG_PTR IoStatusInformation, IN BOOLEAN Quota)
VOID IopCopyBootLogRegistryToFile (VOID)
VOID IopInitializeBootLogging (PLOADER_PARAMETER_BLOCK LoaderBlock, PCHAR HeaderString)
VOID IopBootLog (PUNICODE_STRING LogEntry, BOOLEAN Loaded)
NTSTATUS IopSetRegistryStringValue (IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN PUNICODE_STRING ValueData)
NTKERNELAPI NTSTATUS IoGetRequestorSessionId (IN PIRP Irp, OUT PULONG pSessionId)
VOID IovFreeIrp (IN PIRP Irp)
PIRP IovAllocateIrp (IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
VOID IoVerifierInit (IN ULONG VerifierFlags, IN ULONG InitFlags)
NTSTATUS FASTCALL IovCallDriver (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
VOID FASTCALL IovCompleteRequest (IN PIRP Irp, IN CCHAR PriorityBoost)
PIRP IovBuildAsynchronousFsdRequest (IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN OUT PVOID Buffer OPTIONAL, IN ULONG Length OPTIONAL, IN PLARGE_INTEGER StartingOffset OPTIONAL, IN PIO_STATUS_BLOCK IoStatusBlock OPTIONAL)
PIRP IovBuildDeviceIoControlRequest (IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferLength, OUT PVOID OutputBuffer OPTIONAL, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, OUT PIO_STATUS_BLOCK IoStatusBlock)
NTSTATUS IovInitializeTimer (IN PDEVICE_OBJECT DeviceObject, IN PIO_TIMER_ROUTINE TimerRoutine, IN PVOID Context)
NTKERNELAPI PVOID IoAllocateGenericErrorLogEntry (IN UCHAR EntrySize)
VOID IoRetryIrpCompletions (VOID)

Variables

KSPIN_LOCK IoStatisticsLock
ULONG IoReadOperationCount
ULONG IoWriteOperationCount
ULONG IoOtherOperationCount
LARGE_INTEGER IoReadTransferCount
LARGE_INTEGER IoWriteTransferCount
LARGE_INTEGER IoOtherTransferCount
BOOLEAN IoRemoteBootClient


Define Documentation

#define _WMIKM_
 

Definition at line 4422 of file io.h.

#define DO_BUFFERED_IO   0x00000004
 

Definition at line 1154 of file io.h.

Referenced by BuildQueryDirectoryIrp(), IoBuildAsynchronousFsdRequest(), IopSetEaOrQuotaInformationFile(), NtNotifyChangeDirectoryFile(), NtQueryEaFile(), NtQueryQuotaInformationFile(), NtReadFile(), NtReadFileScatter(), NtSetEaFile(), NtWriteFile(), NtWriteFileGather(), and VdmQueryDirectoryFile().

#define DO_BUS_ENUMERATED_DEVICE   0x00001000
 

Definition at line 1164 of file io.h.

Referenced by IopDestroyDeviceNode(), IopEliminateBogusConflict(), IopEnumerateDevice(), IopFindLegacyDeviceNode(), IopGetDevicePDO(), IopInitializeDeviceInstanceKey(), IopInitializePlugPlayServices(), IopQueryConflictFillString(), IopQueryResourceHandlerInterface(), IopRemoveLegacyDeviceNode(), and IoReportDetectedDevice().

#define DO_DEVICE_HAS_NAME   0x00000040
 

Definition at line 1158 of file io.h.

Referenced by IoCreateDevice(), IoDeleteDevice(), IopChangeDeviceObjectFromRegistryProperties(), and IopFindMountableDevice().

#define DO_DEVICE_INITIALIZING   0x00000080
 

Definition at line 1159 of file io.h.

Referenced by IoAttachDeviceToDeviceStack(), IoCreateDevice(), IopAllocateDeviceNode(), IopCallDriverAddDevice(), IopCheckDeviceAndDriver(), IopReadyDeviceObjects(), IoRegisterFileSystem(), and UdfMountVolume().

#define DO_DIRECT_IO   0x00000010
 

Definition at line 1156 of file io.h.

Referenced by BuildQueryDirectoryIrp(), IoBuildAsynchronousFsdRequest(), IopSetEaOrQuotaInformationFile(), NtNotifyChangeDirectoryFile(), NtQueryEaFile(), NtQueryQuotaInformationFile(), NtReadFile(), NtSetEaFile(), NtWriteFile(), and VdmQueryDirectoryFile().

#define DO_EXCLUSIVE   0x00000008
 

Definition at line 1155 of file io.h.

Referenced by IoCreateDevice(), IopChangeDeviceObjectFromRegistryProperties(), and IopCheckDeviceAndDriver().

#define DO_LONG_TERM_REQUESTS   0x00000200
 

Definition at line 1161 of file io.h.

#define DO_LOW_PRIORITY_FILESYSTEM   0x00010000
 

Definition at line 1168 of file io.h.

Referenced by IoRegisterFileSystem().

#define DO_MAP_IO_BUFFER   0x00000020
 

Definition at line 1157 of file io.h.

#define DO_NEVER_LAST_DEVICE   0x00000400
 

Definition at line 1162 of file io.h.

Referenced by IopDeleteFile().

#define DO_POWER_INRUSH   0x00004000
 

Definition at line 1166 of file io.h.

#define DO_POWER_NOOP   0x00008000
 

Definition at line 1167 of file io.h.

#define DO_POWER_PAGABLE   0x00002000
 

Definition at line 1165 of file io.h.

Referenced by IoBuildPoDeviceNotifyList().

#define DO_SHUTDOWN_REGISTERED   0x00000800
 

Definition at line 1163 of file io.h.

Referenced by IoDeleteDevice(), IoRegisterLastChanceShutdownNotification(), IoRegisterShutdownNotification(), and IoUnregisterShutdownNotification().

#define DO_SYSTEM_BOOT_PARTITION   0x00000100
 

Definition at line 1160 of file io.h.

Referenced by IopCompleteDumpInitialization(), IopConfigureCrashDump(), IopMarkBootPartition(), and IopMountVolume().

#define DO_VERIFY_VOLUME   0x00000002
 

Definition at line 1153 of file io.h.

Referenced by IopMountVolume(), IoVerifyVolume(), UdfDismountVolume(), UdfMountVolume(), UdfPerformVerify(), UdfVerifyFcbOperation(), UdfVerifyVcb(), and UdfVerifyVolume().

#define DOE_DELETE_PENDING   0x00000002
 

Definition at line 1221 of file io.h.

Referenced by IoAttachDeviceToDeviceStack(), IoDeleteDevice(), IoDetachDevice(), IopCheckDeviceAndDriver(), IopCompleteUnloadOrDelete(), IopDecrementDeviceObjectRef(), IopEnumerateDevice(), IoStartTimer(), and IovpCallDriver2().

#define DOE_REMOVE_PENDING   0x00000004
 

Definition at line 1222 of file io.h.

Referenced by IoAttachDeviceToDeviceStack(), IoDetachDevice(), IopCheckDeviceAndDriver(), IopCompleteUnloadOrDelete(), IopDecrementDeviceObjectRef(), IopDeleteLockedDeviceNode(), IopNotifyPnpWhenChainDereferenced(), and IoStartTimer().

#define DOE_REMOVE_PROCESSED   0x00000008
 

Definition at line 1223 of file io.h.

Referenced by IoAttachDeviceToDeviceStack(), IopCheckDeviceAndDriver(), IopCompleteUnloadOrDelete(), IopDeleteLockedDeviceNode(), IopNotifyPnpWhenChainDereferenced(), and IoStartTimer().

#define DOE_START_PENDING   0x00000010
 

Definition at line 1224 of file io.h.

Referenced by IoAttachDeviceToDeviceStack(), IopCheckDeviceAndDriver(), IopDeleteLockedDeviceNode(), IopDoDeferredSetInterfaceState(), IopInitializeDeviceInstanceKey(), IopProcessNewDeviceNode(), and IopProcessSetInterfaceState().

#define DOE_UNLOAD_PENDING   0x00000001
 

Definition at line 1220 of file io.h.

Referenced by IoAttachDeviceToDeviceStack(), IoDetachDevice(), IopCheckDeviceAndDriver(), IopCheckUnloadDriver(), IopCompleteUnloadOrDelete(), IopDecrementDeviceObjectRef(), IopResurrectDriver(), and IoStartTimer().

#define DRVO_BOOTREINIT_REGISTERED   0x00000020
 

Definition at line 1305 of file io.h.

Referenced by IopInitializeBootDrivers(), and IoRegisterBootDriverReinitialization().

#define DRVO_BUILTIN_DRIVER   0x00000004
 

Definition at line 1301 of file io.h.

Referenced by IoCreateDriver(), and IoReportDetectedDevice().

#define DRVO_INITIALIZED   0x00000010
 

Definition at line 1304 of file io.h.

Referenced by IopCallDriverAddDeviceQueryRoutine(), and IopReadyDeviceObjects().

#define DRVO_LEGACY_DRIVER   0x00000002
 

Definition at line 1300 of file io.h.

Referenced by IopInitializeBuiltinDriver(), IopIsLegacyDriver(), and IopLoadDriver().

#define DRVO_LEGACY_RESOURCES   0x00000040
 

Definition at line 1306 of file io.h.

Referenced by IopGetLegacyVetoListDrivers(), and IopLegacyResourceAllocation().

#define DRVO_REINIT_REGISTERED   0x00000008
 

Definition at line 1303 of file io.h.

Referenced by IoInitSystem(), IopCallDriverAddDeviceQueryRoutine(), IopInitializeBootDrivers(), IopInitializeBuiltinDriver(), IopLoadDriver(), IopLoadUnloadDriver(), and IoRegisterDriverReinitialization().

#define DRVO_UNLOAD_INVOKED   0x00000001
 

Definition at line 1299 of file io.h.

Referenced by IoCreateDevice(), IopCheckUnloadDriver(), IopCompleteUnloadOrDelete(), IopInitializeBootDrivers(), IopLoadDriver(), and IopResurrectDriver().

#define FO_ALERTABLE_IO   0x00000004
 

Definition at line 1492 of file io.h.

Referenced by BuildQueryDirectoryIrp(), IopGetModeInformation(), IopGetSetSecurityObject(), IopParseDevice(), IopQueryXxxInformation(), IopSetEaOrQuotaInformationFile(), IopSynchronousServiceTail(), IopXxxControlFile(), IoSetInformation(), NtFlushBuffersFile(), NtLockFile(), NtNotifyChangeDirectoryFile(), NtQueryEaFile(), NtQueryInformationFile(), NtQueryQuotaInformationFile(), NtQueryVolumeInformationFile(), NtReadFile(), NtReadFileScatter(), NtSetEaFile(), NtSetInformationFile(), NtSetVolumeInformationFile(), NtUnlockFile(), NtWriteFile(), and NtWriteFileGather().

#define FO_CACHE_SUPPORTED   0x00000040
 

Definition at line 1496 of file io.h.

Referenced by UdfCompleteFcbOpen().

#define FO_CLEANUP_COMPLETE   0x00004000
 

Definition at line 1504 of file io.h.

Referenced by FsRtlNotifyFullChangeDirectory(), FsRtlOplockFsctrl(), and UdfCommonCleanup().

#define FO_DELETE_ON_CLOSE   0x00010000
 

Definition at line 1506 of file io.h.

Referenced by IopGetModeInformation().

#define FO_DIRECT_DEVICE_OPEN   0x00000800
 

Definition at line 1501 of file io.h.

Referenced by IoCancelFileOpen(), IoGetBaseFileSystemDeviceObject(), IoGetRelatedDeviceObject(), IopCloseFile(), IopDeleteFile(), IopGetSetSecurityObject(), IopParseDevice(), IopXxxControlFile(), NtQueryInformationFile(), NtQueryVolumeInformationFile(), NtSetInformationFile(), and NtUnlockFile().

#define FO_FILE_FAST_IO_READ   0x00080000
 

Definition at line 1509 of file io.h.

Referenced by FsRtlCopyRead(), and FsRtlMdlReadDev().

#define FO_FILE_MODIFIED   0x00001000
 

Definition at line 1502 of file io.h.

Referenced by FsRtlCopyWrite(), and FsRtlPrepareMdlWriteDev().

#define FO_FILE_OPEN   0x00000001
 

Definition at line 1490 of file io.h.

#define FO_FILE_OPEN_CANCELLED   0x00200000
 

Definition at line 1511 of file io.h.

Referenced by IoCancelFileOpen(), and IopParseDevice().

#define FO_FILE_SIZE_CHANGED   0x00002000
 

Definition at line 1503 of file io.h.

Referenced by FsRtlCopyWrite(), and FsRtlPrepareMdlWriteDev().

#define FO_GENERATE_AUDIT_ON_CLOSE   0x00000400
 

Definition at line 1500 of file io.h.

#define FO_HANDLE_CREATED   0x00040000
 

Definition at line 1508 of file io.h.

Referenced by IoCancelFileOpen(), IoCreateFile(), IoCreateStreamFileObject(), IoCreateStreamFileObjectLite(), IopCloseFile(), and IopDeleteFile().

#define FO_MAILSLOT   0x00000200
 

Definition at line 1499 of file io.h.

Referenced by NtReadFile(), NtReadFileScatter(), NtWriteFile(), and NtWriteFileGather().

#define FO_NAMED_PIPE   0x00000080
 

Definition at line 1497 of file io.h.

Referenced by NtFlushBuffersFile(), NtReadFile(), NtReadFileScatter(), NtWriteFile(), and NtWriteFileGather().

#define FO_NO_INTERMEDIATE_BUFFERING   0x00000008
 

Definition at line 1493 of file io.h.

Referenced by IopGetModeInformation(), IopParseDevice(), IoSetInformation(), NtReadFile(), NtReadFileScatter(), NtSetInformationFile(), NtWriteFile(), NtWriteFileGather(), UdfCommonSetInfo(), and UdfCompleteFcbOpen().

#define FO_OPENED_CASE_SENSITIVE   0x00020000
 

Definition at line 1507 of file io.h.

Referenced by IopOpenLinkOrRenameTarget(), and IopParseDevice().

#define FO_RANDOM_ACCESS   0x00100000
 

Definition at line 1510 of file io.h.

Referenced by CcCopyRead(), CcFastCopyRead(), CcInitializeCacheMap(), CcMdlRead(), and IopParseDevice().

#define FO_SEQUENTIAL_ONLY   0x00000020
 

Definition at line 1495 of file io.h.

Referenced by CcInitializeCacheMap(), CcPerformReadAhead(), CcScheduleReadAhead(), IopGetModeInformation(), IopParseDevice(), IoSetInformation(), and NtSetInformationFile().

#define FO_STREAM_FILE   0x00000100
 

Definition at line 1498 of file io.h.

Referenced by IoCreateStreamFileObject(), IoCreateStreamFileObjectLite(), and IopGetSetSecurityObject().

#define FO_SYNCHRONOUS_IO   0x00000002
 

Definition at line 1491 of file io.h.

Referenced by BuildQueryDirectoryIrp(), IoIsOperationSynchronous(), IopAllocateIrpCleanup(), IopCloseFile(), IopCompleteRequest(), IopDeleteFile(), IopExceptionCleanup(), IopGetModeInformation(), IopGetSetSecurityObject(), IopParseDevice(), IopQueryName(), IopQueryXxxInformation(), IopSetEaOrQuotaInformationFile(), IopXxxControlFile(), IoSetInformation(), NtFlushBuffersFile(), NtLockFile(), NtNotifyChangeDirectoryFile(), NtQueryEaFile(), NtQueryInformationFile(), NtQueryQuotaInformationFile(), NtQueryVolumeInformationFile(), NtReadFile(), NtReadFileScatter(), NtSetEaFile(), NtSetInformationFile(), NtSetVolumeInformationFile(), NtUnlockFile(), NtWriteFile(), NtWriteFileGather(), and UdfCommonRead().

#define FO_TEMPORARY_FILE   0x00008000
 

Definition at line 1505 of file io.h.

Referenced by CcIsThereDirtyData(), and CcLazyWriteScan().

#define FO_VOLUME_OPEN   0x00400000
 

Definition at line 1512 of file io.h.

Referenced by IopParseDevice().

#define FO_WRITE_THROUGH   0x00000010
 

Definition at line 1494 of file io.h.

Referenced by CcCopyWrite(), CcFastCopyWrite(), CcMdlWriteComplete2(), CcZeroData(), FsRtlCopyWrite(), FsRtlMdlWriteCompleteDev(), FsRtlPrepareMdlWriteDev(), IopGetModeInformation(), IopParseDevice(), IoSetInformation(), NtSetInformationFile(), NtWriteFile(), and NtWriteFileGather().

#define IO_ATTACH_DEVICE   0x0400
 

Definition at line 256 of file io.h.

Referenced by IoCreateFile(), and IopCheckDeviceAndDriver().

#define IO_ATTACH_DEVICE_API   0x80000000
 

Definition at line 262 of file io.h.

Referenced by IoAttachDevice(), and IoCreateFile().

#define IO_CHECK_CREATE_PARAMETERS   0x0200
 

Definition at line 255 of file io.h.

Referenced by IoCreateFile().

#define IO_DUMP_COMMON_BUFFER_SIZE   0x2000
 

Definition at line 434 of file io.h.

Referenced by IopGetDumpStack().

#define IO_DUMP_MAX_MDL_PAGES   8
 

Definition at line 432 of file io.h.

#define IO_DUMP_MEMORY_BLOCK_PAGES   8
 

Definition at line 433 of file io.h.

Referenced by IopConfigureCrashDump().

#define IO_FILE_OBJECT_NON_PAGED_POOL_CHARGE   64
 

Definition at line 2615 of file io.h.

Referenced by IopCreateObjectTypes().

#define IO_FILE_OBJECT_PAGED_POOL_CHARGE   1024
 

Definition at line 2616 of file io.h.

Referenced by IopCreateObjectTypes().

#define IO_FORCE_ACCESS_CHECK   0x0001
 

Definition at line 233 of file io.h.

Referenced by IoFastQueryNetworkAttributes(), IopOpenLinkOrRenameTarget(), and IopParseDevice().

#define IO_NO_PARAMETER_CHECKING   0x0100
 

Definition at line 243 of file io.h.

Referenced by IoCreateFile(), IopOpenLinkOrRenameTarget(), and NtCreatePagingFile().

#define IO_OPEN_PAGING_FILE   0x0002
 

Definition at line 234 of file io.h.

Referenced by NtCreatePagingFile().

#define IO_OPEN_TARGET_DIRECTORY   0x0004
 

Definition at line 235 of file io.h.

Referenced by IopOpenLinkOrRenameTarget().

#define IO_REMOUNT   0x1
 

Definition at line 251 of file io.h.

Referenced by IopParseDevice(), and UdfPerformVerify().

#define IO_REPARSE   0x0
 

Definition at line 250 of file io.h.

Referenced by IopParseDevice().

#define IO_TYPE_ADAPTER   0x00000001
 

Definition at line 35 of file io.h.

#define IO_TYPE_CONTROLLER   0x00000002
 

Definition at line 36 of file io.h.

Referenced by IoCreateController().

#define IO_TYPE_DEVICE   0x00000003
 

Definition at line 37 of file io.h.

Referenced by IoAllocateErrorLogEntry(), IoCreateDevice(), IopDeviceObjectFromDeviceInstance(), IopGetSetSecurityObject(), and IovpValidateDeviceObject().

#define IO_TYPE_DEVICE_OBJECT_EXTENSION   0x0000000d
 

Definition at line 47 of file io.h.

Referenced by IoCreateDevice().

#define IO_TYPE_DRIVER   0x00000004
 

Definition at line 38 of file io.h.

Referenced by IoAllocateErrorLogEntry(), IoCreateDriver(), IopGetLegacyVetoListDrivers(), and IopLoadDriver().

#define IO_TYPE_ERROR_LOG   0x0000000b
 

Definition at line 45 of file io.h.

Referenced by IopAllocateErrorLogEntry().

#define IO_TYPE_ERROR_MESSAGE   0x0000000c
 

Definition at line 46 of file io.h.

Referenced by IopErrorLogThread().

#define IO_TYPE_FILE   0x00000005
 

Definition at line 39 of file io.h.

Referenced by IoCreateFile(), IoCreateStreamFileObject(), IoCreateStreamFileObjectLite(), and IopParseDevice().

#define IO_TYPE_IRP   0x00000006
 

Definition at line 40 of file io.h.

Referenced by IoCancelIrp(), IoInitializeIrp(), IopfCallDriver(), IopFreeIrp(), IovCallDriver(), IovCompleteRequest(), IovFreeIrpPrivate(), and IovSpecialIrpCallDriver().

#define IO_TYPE_MASTER_ADAPTER   0x00000007
 

Definition at line 41 of file io.h.

#define IO_TYPE_OPEN_PACKET   0x00000008
 

Definition at line 42 of file io.h.

Referenced by IoCreateFile(), IoFastQueryNetworkAttributes(), IopParseDevice(), IopParseFile(), NtDeleteFile(), NtQueryAttributesFile(), and NtQueryFullAttributesFile().

#define IO_TYPE_TIMER   0x00000009
 

Definition at line 43 of file io.h.

Referenced by IoInitializeTimer().

#define IO_TYPE_VPB   0x0000000a
 

Definition at line 44 of file io.h.

Referenced by IopCreateVpb(), UdfDismountVcb(), and UdfInvalidateVolumes().

#define IoAcquireRemoveLock RemoveLock,
Tag   )     IoAcquireRemoveLockEx(RemoveLock, Tag, __FILE__, __LINE__, sizeof (IO_REMOVE_LOCK))
 

Definition at line 4122 of file io.h.

#define IoAssignArcName ArcName,
DeviceName   ) 
 

Value:

( \ IoCreateSymbolicLink( (ArcName), (DeviceName) ) )

Definition at line 2725 of file io.h.

#define IoCallDriver a,
 )     IofCallDriver(a,b)
 

Definition at line 2865 of file io.h.

Referenced by CcSetValidData(), FsRecGetDeviceSectors(), FsRecGetDeviceSectorSize(), FsRecReadBlock(), FsRtlBalanceReads(), FsRtlGetFileSize(), FsRtlSetFileSize(), FsRtlSyncVolumes(), GetDeviceChangeInfo(), HalpEnableAutomaticDriveLetterAssignment(), HalpGetFullGeometry(), HalpIsOldStyleFloppy(), HalpNextMountLetter(), HalpQueryDriveLayout(), HalpQueryPartitionType(), HalpSetMountLetter(), IoAsynchronousPageWrite(), IoCancelFileOpen(), IoFreeDumpStack(), IoGetBootDiskInformation(), IoGetDmaAdapter(), IoPageRead(), IopAsynchronousCall(), IopCloseFile(), IopCreateArcNames(), IopDeleteFile(), IopEjectDevice(), IopFilterResourceRequirementsCall(), IopGetDumpStack(), IopGetFileName(), IopGetSetObjectId(), IopGetSetSecurityObject(), IopGetVolumeId(), IopInvalidateVolumesForDevice(), IopLoadFileSystemDriver(), IopMountVolume(), IopParseDevice(), IopQueryXxxInformation(), IopSetRemoteLink(), IopSynchronousCall(), IopSynchronousServiceTail(), IoSetInformation(), IoShutdownSystem(), IoSynchronousPageWrite(), IoVerifyVolume(), IovpThrowBogusSynchronousIrp(), MiCheckPageFilePath(), NtQueryInformationFile(), NtSetInformationFile(), RtlVolumeDeviceToDosName(), UdfCommonDevControl(), UdfCommonPnp(), UdfDvdReadStructure(), UdfDvdTransferKey(), UdfMultipleAsync(), UdfPerformDevIoCtrl(), UdfPnpCancelRemove(), UdfPnpQueryRemove(), UdfPnpRemove(), UdfPnpSurpriseRemove(), UdfReadSectors(), UdfSingleAsync(), VdmQueryDirectoryFile(), xHalExamineMBR(), xHalGetPartialGeometry(), xHalIoClearPartitionTable(), xHalIoReadPartitionTable(), xHalIoSetPartitionInformation(), and xHalIoWritePartitionTable().

#define IoCompleteRequest a,
 )     IofCompleteRequest(a,b)
 

Definition at line 2960 of file io.h.

Referenced by CdfsRecFsControl(), FatRecFsControl(), FsRecCleanupClose(), FsRecCreate(), FsRecFsControl(), FsVgaDeviceControl(), FsVgaOpenCloseDispatch(), IopInvalidDeviceRequest(), IopPnPCompleteRequest(), IopPowerDispatch(), IopRaiseHardError(), IopStartApcHardError(), IoRaiseHardError(), IoSetInformation(), IovpInternalCompleteAfterWait(), IovpSwapSurrogateIrp(), NtfsRecFsControl(), UdfCompleteRequest(), and UdfsRecFsControl().

#define IoCopyCurrentIrpStackLocationToNext Irp   ) 
 

Value:

{ \ PIO_STACK_LOCATION irpSp; \ PIO_STACK_LOCATION nextIrpSp; \ irpSp = IoGetCurrentIrpStackLocation( (Irp) ); \ nextIrpSp = IoGetNextIrpStackLocation( (Irp) ); \ RtlCopyMemory( nextIrpSp, irpSp, FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine)); \ nextIrpSp->Control = 0; }

Definition at line 4009 of file io.h.

Referenced by IovpExamineIrpStackForwarding(), UdfCommonDevControl(), UdfDvdReadStructure(), UdfDvdTransferKey(), UdfPnpQueryRemove(), UdfPnpRemove(), and UdfPnpSurpriseRemove().

#define IoDeassignArcName ArcName   ) 
 

Value:

( \ IoDeleteSymbolicLink( (ArcName) ) )

Definition at line 3110 of file io.h.

#define IoGetCurrentIrpStackLocation Irp   )     ( (Irp)->Tail.Overlay.CurrentStackLocation )
 

Definition at line 3252 of file io.h.

Referenced by CdfsRecFsControl(), FatRecFsControl(), FsRecCreate(), FsRecFsControl(), FsRtlCancelNotify(), FsRtlCheckLockForReadAccess(), FsRtlCheckLockForWriteAccess(), FsRtlCheckOplock(), FsRtlNotifyCompleteIrp(), FsRtlNotifyFullChangeDirectory(), FsRtlNotifyFullReportChange(), FsRtlOplockCleanup(), FsRtlOplockFsctrl(), FsRtlPrivateCheckWaitingLocks(), FsRtlPrivateFastUnlockAll(), FsRtlProcessFileLock(), FsRtlRemoveAndCompleteIrp(), FsRtlUninitializeOplock(), FsVgaDeviceControl(), IoepFindErrThread(), IoepNewErrThread(), IoIsOperationSynchronous(), IoIsValidNameGraftingBuffer(), IopDisassociateThreadIrp(), IopDriverCorrectnessPrintIrp(), IopInvalidDeviceRequest(), IopPnPDispatch(), IopPowerDispatch(), IopRaiseHardError(), IoRaiseHardError(), IovpCompleteRequest1(), IovpCompleteRequest3(), IovpCompleteRequest4(), IovpExamineIrpStackForwarding(), IovpInternalCompletionTrap(), IovpSessionDataAttachSurrogate(), IovpSwapSurrogateIrp(), NtfsRecFsControl(), UdfAddToWorkque(), UdfCommonCleanup(), UdfCommonClose(), UdfCommonCreate(), UdfCommonDevControl(), UdfCommonDirControl(), UdfCommonFsControl(), UdfCommonLockControl(), UdfCommonPnp(), UdfCommonQueryInfo(), UdfCommonQueryVolInfo(), UdfCommonRead(), UdfCommonSetInfo(), UdfCompleteMdl(), UdfCreateIrpContext(), UdfDismountVolume(), UdfDvdReadStructure(), UdfDvdTransferKey(), UdfFsdDispatch(), UdfFspDispatch(), UdfInvalidateVolumes(), UdfIsVolumeDirty(), UdfIsVolumeMounted(), UdfLockVolume(), UdfMountVolume(), UdfMultiAsyncCompletionRoutine(), UdfMultipleAsync(), UdfOplockRequest(), UdfPerformVerify(), UdfPrePostIrp(), UdfProcessException(), UdfsRecFsControl(), UdfUnlockVolume(), UdfUserFsctl(), and UdfVerifyVolume().

#define IoGetFunctionCodeFromCtlCode ControlCode   ) 
 

Value:

(\ ( ControlCode >> 2) & 0x00000FFF )

Definition at line 3338 of file io.h.

#define IoGetNextIrpStackLocation Irp   ) 
 

Value:

(\ (Irp)->Tail.Overlay.CurrentStackLocation - 1 )

Definition at line 3398 of file io.h.

Referenced by BuildQueryDirectoryIrp(), CcSetValidData(), FsRecGetDeviceSectors(), FsRecGetDeviceSectorSize(), FsRecReadBlock(), FsRtlGetFileSize(), FsRtlSetFileSize(), IoAsynchronousPageWrite(), IoBuildAsynchronousFsdRequest(), IoBuildDeviceIoControlRequest(), IoCancelFileOpen(), IoFreeDumpStack(), IoGetDmaAdapter(), IoPageRead(), IopAsynchronousCall(), IopCloseFile(), IopDeleteFile(), IopDriverCorrectnessPrintIrp(), IopEjectDevice(), IopfCallDriver(), IopFilterResourceRequirementsCall(), IopGetDumpStack(), IopGetFileName(), IopGetSetObjectId(), IopGetSetSecurityObject(), IopGetVolumeId(), IopInvalidateVolumesForDevice(), IopLoadFileSystemDriver(), IopMountVolume(), IopOpenLinkOrRenameTarget(), IopParseDevice(), IopQueryXxxInformation(), IopSetEaOrQuotaInformationFile(), IopSetRemoteLink(), IopSynchronousCall(), IopXxxControlFile(), IoSetInformation(), IoSynchronousPageWrite(), IoVerifyVolume(), IovpCallDriver1(), IovpCompleteRequest2(), IovpCompleteRequest3(), IovpExamineIrpStackForwarding(), IovpInternalCompleteAfterWait(), IovpInternalDeferredCompletion(), IovpSessionDataAttachSurrogate(), IovpSessionDataDeterminePolicy(), IovpSwapSurrogateIrp(), IovpThrowBogusSynchronousIrp(), IovSpecialIrpCallDriver(), MiCheckPageFilePath(), NtFlushBuffersFile(), NtLockFile(), NtNotifyChangeDirectoryFile(), NtQueryEaFile(), NtQueryInformationFile(), NtQueryQuotaInformationFile(), NtQueryVolumeInformationFile(), NtReadFile(), NtReadFileScatter(), NtSetEaFile(), NtSetInformationFile(), NtSetVolumeInformationFile(), NtUnlockFile(), NtWriteFile(), NtWriteFileGather(), UdfMultipleAsync(), UdfPerformDevIoCtrl(), UdfReadSectors(), UdfSingleAsync(), VdmQueryDirectoryFile(), xHalExamineMBR(), xHalIoClearPartitionTable(), xHalIoReadPartitionTable(), xHalIoSetPartitionInformation(), and xHalIoWritePartitionTable().

#define IoInitializeDpcRequest DeviceObject,
DpcRoutine   ) 
 

Value:

(\ KeInitializeDpc( &(DeviceObject)->Dpc, \ (PKDEFERRED_ROUTINE) (DpcRoutine), \ (DeviceObject) ) )

Definition at line 3457 of file io.h.

#define IoInitializeRemoveLock Lock,
Tag,
Maxmin,
HighWater   )     IoInitializeRemoveLockEx (Lock, Tag, Maxmin, HighWater, sizeof (IO_REMOVE_LOCK))
 

Definition at line 4101 of file io.h.

#define IoIsErrorUserInduced Status   ) 
 

Value:

((BOOLEAN) \ (((Status) == STATUS_DEVICE_NOT_READY) || \ ((Status) == STATUS_IO_TIMEOUT) || \ ((Status) == STATUS_MEDIA_WRITE_PROTECTED) || \ ((Status) == STATUS_NO_MEDIA_IN_DEVICE) || \ ((Status) == STATUS_VERIFY_REQUIRED) || \ ((Status) == STATUS_UNRECOGNIZED_MEDIA) || \ ((Status) == STATUS_WRONG_VOLUME)))

Definition at line 3528 of file io.h.

Referenced by IopMountVolume(), UdfCommonRead(), UdfPerformVerify(), and UdfProcessException().

#define IoIsFileOpenedExclusively FileObject   ) 
 

Value:

(\ (BOOLEAN) !((FileObject)->SharedRead || (FileObject)->SharedWrite || (FileObject)->SharedDelete))

Definition at line 3563 of file io.h.

#define IoMarkIrpPending Irp   ) 
 

Value:

Definition at line 3620 of file io.h.

Referenced by FsRtlAcknowledgeOplockBreak(), FsRtlCancelNotify(), FsRtlNotifyCompleteIrp(), FsRtlNotifyFullChangeDirectory(), FsRtlPrivateLock(), FsRtlRequestExclusiveOplock(), FsRtlRequestOplockII(), FsRtlWaitOnIrp(), IovpCompleteRequest1(), IovpCompleteRequest4(), IovpInternalCompletionTrap(), IovpSessionDataFinalizeSurrogate(), UdfDevCtrlCompletionRoutine(), UdfMultiAsyncCompletionRoutine(), UdfPrePostIrp(), UdfProcessException(), and UdfSingleAsyncCompletionRoutine().

#define IoReleaseRemoveLock RemoveLock,
Tag   )     IoReleaseRemoveLockEx(RemoveLock, Tag, sizeof (IO_REMOVE_LOCK))
 

Definition at line 4171 of file io.h.

#define IoReleaseRemoveLockAndWait RemoveLock,
Tag   )     IoReleaseRemoveLockAndWaitEx(RemoveLock, Tag, sizeof (IO_REMOVE_LOCK))
 

Definition at line 4207 of file io.h.

#define IoRequestDpc DeviceObject,
Irp,
Context   ) 
 

Value:

( \ KeInsertQueueDpc( &(DeviceObject)->Dpc, (Irp), (Context) ) )

Definition at line 3838 of file io.h.

#define IoSetCancelRoutine Irp,
NewCancelRoutine   ) 
 

Value:

( \ (PDRIVER_CANCEL) InterlockedExchangePointer( (PVOID *) &(Irp)->CancelRoutine, (PVOID) (NewCancelRoutine) ) )

Definition at line 3867 of file io.h.

Referenced by FsRtlAcknowledgeOplockBreak(), FsRtlCancelExclusiveIrp(), FsRtlCancelNotify(), FsRtlCancelOplockIIIrp(), FsRtlCancelWaitIrp(), FsRtlNotifySetCancelRoutine(), FsRtlOplockBreakToII(), FsRtlOplockBreakToNone(), FsRtlOplockCleanup(), FsRtlPrivateCheckWaitingLocks(), FsRtlPrivateFastUnlockAll(), FsRtlPrivateLock(), FsRtlRemoveAndCompleteIrp(), FsRtlRemoveAndCompleteWaitIrp(), FsRtlRequestExclusiveOplock(), FsRtlRequestOplockII(), FsRtlUninitializeFileLock(), FsRtlUninitializeOplock(), and FsRtlWaitOnIrp().

#define IoSetCompletionRoutine Irp,
Routine,
CompletionContext,
Success,
Error,
Cancel   ) 
 

Value:

{ \ PIO_STACK_LOCATION irpSp; \ ASSERT( (Success) | (Error) | (Cancel) ? (Routine) != NULL : TRUE ); \ irpSp = IoGetNextIrpStackLocation( (Irp) ); \ irpSp->CompletionRoutine = (Routine); \ irpSp->Context = (CompletionContext); \ irpSp->Control = 0; \ if ((Success)) { irpSp->Control = SL_INVOKE_ON_SUCCESS; } \ if ((Error)) { irpSp->Control |= SL_INVOKE_ON_ERROR; } \ if ((Cancel)) { irpSp->Control |= SL_INVOKE_ON_CANCEL; } }

Definition at line 3913 of file io.h.

Referenced by IopAsynchronousCall(), IopEjectDevice(), IovpCompleteRequest2(), IovpExamineIrpStackForwarding(), UdfCommonDevControl(), UdfDvdReadStructure(), UdfDvdTransferKey(), UdfMultipleAsync(), UdfPnpQueryRemove(), UdfPnpRemove(), UdfPnpSurpriseRemove(), and UdfSingleAsync().

#define IoSetNextIrpStackLocation Irp   ) 
 

Value:

{ \ (Irp)->CurrentLocation--; \ (Irp)->Tail.Overlay.CurrentStackLocation--; }

Definition at line 3977 of file io.h.

Referenced by IopParseDevice(), IoSetInformation(), IovpCallDriver1(), IovpExamineIrpStackForwarding(), IovpSwapSurrogateIrp(), and UdfMultipleAsync().

#define IoSizeOfIrp StackSize   )     ((USHORT) (sizeof( IRP ) + ((StackSize) * (sizeof( IO_STACK_LOCATION )))))
 

Definition at line 4269 of file io.h.

Referenced by IoMakeAssociatedIrp(), IopAllocateIrpMustSucceed(), IopAllocateIrpPrivate(), IoReuseIrp(), IovAllocateIrp(), IovpAllocateIrp1(), IovpProtectedIrpAllocate(), and IovpSwapSurrogateIrp().

#define IoSkipCurrentIrpStackLocation Irp   ) 
 

Value:

(Irp)->CurrentLocation++; \ (Irp)->Tail.Overlay.CurrentStackLocation++;

Definition at line 4044 of file io.h.

Referenced by IovpCallDriver1(), UdfCommonPnp(), and UdfPnpCancelRemove().

#define IOVERIFIERINIT_ASYNCHRONOUSINIT   0x00000004
 

Definition at line 4698 of file io.h.

Referenced by IovpDoAssertIrps().

#define IOVERIFIERINIT_EVERYTHING_TRACKED   0x00000002
 

Definition at line 4697 of file io.h.

Referenced by IovpDoAssertIrps(), IovpInitIrpTracking(), and MiInitializeDriverVerifierList().

#define IOVERIFIERINIT_NO_REINIT   0x00000008
 

Definition at line 4699 of file io.h.

Referenced by IovpDoAssertIrps(), and IovpInitIrpTracking().

#define IOVERIFIERINIT_PHASE0   0x00000001
 

Definition at line 4696 of file io.h.

Referenced by IoVerifierInit(), and MiInitializeDriverVerifierList().

#define IOVERIFIERINIT_RANDOMLY_CANCEL_IRPS   0x00000020
 

Definition at line 4701 of file io.h.

Referenced by IovpCallDriver1().

#define IOVERIFIERINIT_VERIFIER_DRIVER_LIST   0x00000010
 

Definition at line 4700 of file io.h.

Referenced by IoVerifierInit(), IovpIsInterestingDriver(), and MiInitializeDriverVerifierList().

#define IoWMIDeviceObjectToProviderId DeviceObject   )     ((ULONG)(DeviceObject))
 

Definition at line 4560 of file io.h.

#define IRP_ALLOCATED_FIXED_SIZE   0x04
 

Definition at line 1576 of file io.h.

Referenced by IoMakeAssociatedIrp(), IopAllocateIrpPrivate(), and IopFreeIrp().

#define IRP_ALLOCATED_MUST_SUCCEED   0x02
 

Definition at line 1575 of file io.h.

Referenced by IoMakeAssociatedIrp(), IopAllocateIrpMustSucceed(), IopAllocateIrpPrivate(), IopFreeIrp(), and IovAllocateIrp().

#define IRP_ASSOCIATED_IRP   0x00000008
 

Definition at line 1553 of file io.h.

Referenced by IoMakeAssociatedIrp().

#define IRP_BUFFERED_IO   0x00000010
 

Definition at line 1554 of file io.h.

Referenced by BuildQueryDirectoryIrp(), FsRtlNotifyCompleteIrp(), IoBuildAsynchronousFsdRequest(), IoBuildDeviceIoControlRequest(), IopCompleteRequest(), IopGetFileName(), IopParseDevice(), IopQueryXxxInformation(), IopSetEaOrQuotaInformationFile(), IopXxxControlFile(), IoSetInformation(), NtNotifyChangeDirectoryFile(), NtQueryEaFile(), NtQueryInformationFile(), NtQueryQuotaInformationFile(), NtQueryVolumeInformationFile(), NtReadFile(), NtSetEaFile(), NtSetInformationFile(), NtSetVolumeInformationFile(), and NtWriteFile().

#define IRP_CLOSE_OPERATION   0x00000400
 

Definition at line 1561 of file io.h.

Referenced by IoCancelFileOpen(), IopCloseFile(), and IopDeleteFile().

#define IRP_CREATE_OPERATION   0x00000080
 

Definition at line 1558 of file io.h.

Referenced by IopCompleteRequest(), IopDropIrp(), IopParseDevice(), and IoRetryIrpCompletions().

#define IRP_DEALLOCATE_BUFFER   0x00000020
 

Definition at line 1555 of file io.h.

Referenced by BuildQueryDirectoryIrp(), FsRtlNotifyCompleteIrp(), IoBuildAsynchronousFsdRequest(), IoBuildDeviceIoControlRequest(), IopCompleteRequest(), IopDropIrp(), IopParseDevice(), IopSetEaOrQuotaInformationFile(), IopXxxControlFile(), IovpSessionDataFinalizeSurrogate(), NtNotifyChangeDirectoryFile(), NtQueryEaFile(), NtQueryInformationFile(), NtQueryQuotaInformationFile(), NtQueryVolumeInformationFile(), NtReadFile(), NtSetEaFile(), NtSetInformationFile(), NtSetVolumeInformationFile(), and NtWriteFile().

#define IRP_DEFER_IO_COMPLETION   0x00000800
 

Definition at line 1564 of file io.h.

Referenced by BuildQueryDirectoryIrp(), IopParseDevice(), IopXxxControlFile(), NtQueryInformationFile(), NtQueryVolumeInformationFile(), NtReadFile(), NtReadFileScatter(), NtSetInformationFile(), NtWriteFile(), and NtWriteFileGather().

#define IRP_HOLD_DEVICE_QUEUE   0x00002000
 

Definition at line 1566 of file io.h.

#define IRP_INPUT_OPERATION   0x00000040
 

Definition at line 1556 of file io.h.

Referenced by BuildQueryDirectoryIrp(), FsRtlNotifyCompleteIrp(), FsRtlOplockFsctrl(), IoBuildAsynchronousFsdRequest(), IoBuildDeviceIoControlRequest(), IoPageRead(), IopCompleteRequest(), IopRaiseHardError(), IopXxxControlFile(), IoRaiseHardError(), NtNotifyChangeDirectoryFile(), NtQueryEaFile(), NtQueryInformationFile(), NtQueryQuotaInformationFile(), NtQueryVolumeInformationFile(), NtReadFile(), and UdfCompleteRequest().

#define IRP_LOOKASIDE_ALLOCATION   0x08
 

Definition at line 1577 of file io.h.

Referenced by IopAllocateIrpPrivate(), and IopFreeIrp().

#define IRP_MJ_CLEANUP   0x12
 

Definition at line 73 of file io.h.

Referenced by DriverEntry(), FsRtlCheckOplock(), IoCancelFileOpen(), IopCloseFile(), IoRaiseHardError(), UdfCreateIrpContext(), UdfFsdDispatch(), and UdfFspDispatch().

#define IRP_MJ_CLOSE   0x02
 

Definition at line 57 of file io.h.

Referenced by DriverEntry(), IoCancelFileOpen(), IoCheckFunctionAccess(), IopDeleteFile(), UdfCreateIrpContext(), UdfFsdDispatch(), UdfFspDispatch(), and UdfInitializeStackIrpContext().

#define IRP_MJ_CREATE   0x00
 

Definition at line 55 of file io.h.

Referenced by DriverEntry(), FsRtlCheckOplock(), FsRtlOplockBreakToII(), FsRtlOplockBreakToNone(), FsRtlOplockFsctrl(), IoCheckFunctionAccess(), IopParseDevice(), IovpSessionDataDeterminePolicy(), UdfCreateIrpContext(), UdfFsdDispatch(), UdfFspDispatch(), UdfOplockComplete(), UdfPerformVerify(), and UdfPrePostIrp().

#define IRP_MJ_CREATE_MAILSLOT   0x13
 

Definition at line 74 of file io.h.

Referenced by IopParseDevice().

#define IRP_MJ_CREATE_NAMED_PIPE   0x01
 

Definition at line 56 of file io.h.

Referenced by IopParseDevice().

#define IRP_MJ_DEVICE_CHANGE   0x18
 

Definition at line 79 of file io.h.

#define IRP_MJ_DEVICE_CONTROL   0x0e
 

Definition at line 69 of file io.h.

Referenced by DriverEntry(), IoBuildDeviceIoControlRequest(), IoCheckFunctionAccess(), IopLoadFileSystemDriver(), IopXxxControlFile(), IovpAssertIrpStackDownward(), UdfFsdDispatch(), and UdfFspDispatch().

#define IRP_MJ_DIRECTORY_CONTROL   0x0c
 

Definition at line 67 of file io.h.

Referenced by BuildQueryDirectoryIrp(), IoCheckFunctionAccess(), NtNotifyChangeDirectoryFile(), UdfFsdDispatch(), UdfFspDispatch(), UdfPrePostIrp(), and VdmQueryDirectoryFile().

#define IRP_MJ_FILE_SYSTEM_CONTROL   0x0d
 

Definition at line 68 of file io.h.

Referenced by DriverEntry(), FsRtlCheckOplock(), IoCheckFunctionAccess(), IopGetSetObjectId(), IopInvalidateVolumesForDevice(), IopLoadFileSystemDriver(), IopMountVolume(), IopRaiseHardError(), IopSetRemoteLink(), IopXxxControlFile(), IoVerifyVolume(), UdfCreateIrpContext(), UdfFsdDispatch(), UdfFspDispatch(), and UdfPerformVerify().

#define IRP_MJ_FLUSH_BUFFERS   0x09
 

Definition at line 64 of file io.h.

Referenced by FsRtlCheckOplock(), IoBuildAsynchronousFsdRequest(), IoCheckFunctionAccess(), and NtFlushBuffersFile().

#define IRP_MJ_INTERNAL_DEVICE_CONTROL   0x0f
 

Definition at line 70 of file io.h.

Referenced by IoBuildDeviceIoControlRequest(), IoCheckFunctionAccess(), IopDriverCorrectnessPrintIrpStack(), and IovpAssertIrpStackDownward().

#define IRP_MJ_LOCK_CONTROL   0x11
 

Definition at line 72 of file io.h.

Referenced by FsRtlCheckOplock(), FsRtlProcessFileLock(), IoCheckFunctionAccess(), IopCloseFile(), NtLockFile(), NtUnlockFile(), UdfFsdDispatch(), and UdfFspDispatch().

#define IRP_MJ_MAXIMUM_FUNCTION   0x1b
 

Definition at line 84 of file io.h.

Referenced by IoCreateDriver(), and IopLoadDriver().

#define IRP_MJ_PNP   0x1b
 

Definition at line 82 of file io.h.

Referenced by IoBuildAsynchronousFsdRequest(), IoFreeDumpStack(), IoGetDmaAdapter(), IopDriverCorrectnessPrintIrpStack(), IopEjectDevice(), IopEnumerateDevice(), IopFilterResourceRequirementsCall(), IopGetDumpStack(), IopGetRelatedTargetDevice(), IopPnPDriverEntry(), IopProcessNewDeviceNode(), IopQueryCompatibleIds(), IopQueryDeviceCapabilities(), IopQueryDeviceId(), IopQueryDeviceRelations(), IopQueryDeviceResources(), IopQueryDeviceSerialNumber(), IopQueryDeviceState(), IopQueryDockRemovalInterface(), IopQueryLegacyBusInformation(), IopQueryPnpBusInformation(), IopQueryReconfiguration(), IopQueryResourceHandlerInterface(), IopQueryUniqueId(), IopRemoveDevice(), IopStartDevice(), IovpAssertDoAdvanceStatus(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), IovpAssertNewRequest(), IovpCallDriver1(), IovpCompleteRequest3(), IovpIsSystemRestrictedIrp(), IovpThrowChaffAtStartedPdoStack(), MiCheckPageFilePath(), UdfFsdDispatch(), and UdfFspDispatch().

#define IRP_MJ_PNP_POWER   IRP_MJ_PNP
 

Definition at line 83 of file io.h.

#define IRP_MJ_POWER   0x16
 

Definition at line 77 of file io.h.

Referenced by IoBuildAsynchronousFsdRequest(), IopDriverCorrectnessPrintIrpStack(), IopInvalidDeviceRequest(), IopPnPDriverEntry(), IovpAssertDoAdvanceStatus(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), IovpAssertNewRequest(), IovpExamineIrpStackForwarding(), IovpIsSystemRestrictedIrp(), and IovpThrowChaffAtStartedPdoStack().

#define IRP_MJ_QUERY_EA   0x07
 

Definition at line 62 of file io.h.

Referenced by IoCheckFunctionAccess(), and NtQueryEaFile().

#define IRP_MJ_QUERY_INFORMATION   0x05
 

Definition at line 60 of file io.h.

Referenced by FsRtlGetFileSize(), IoCheckFunctionAccess(), IopGetFileName(), IopQueryXxxInformation(), NtQueryInformationFile(), UdfFsdDispatch(), and UdfFspDispatch().

#define IRP_MJ_QUERY_QUOTA   0x19
 

Definition at line 80 of file io.h.

Referenced by NtQueryQuotaInformationFile().

#define IRP_MJ_QUERY_SECURITY   0x14
 

Definition at line 75 of file io.h.

Referenced by IoCheckFunctionAccess(), and IopGetSetSecurityObject().

#define IRP_MJ_QUERY_VOLUME_INFORMATION   0x0a
 

Definition at line 65 of file io.h.

Referenced by IoCheckFunctionAccess(), IopGetVolumeId(), IopQueryXxxInformation(), NtQueryVolumeInformationFile(), UdfFsdDispatch(), and UdfFspDispatch().

#define IRP_MJ_READ   0x03
 

Definition at line 58 of file io.h.

Referenced by FsRecReadBlock(), FsRtlCheckOplock(), IoBuildAsynchronousFsdRequest(), IoCheckFunctionAccess(), IoPageRead(), IopCreateArcNames(), IovpAssertIrpStackDownward(), NtReadFile(), NtReadFileScatter(), UdfFsdDispatch(), UdfFspDispatch(), UdfMultipleAsync(), UdfPrePostIrp(), UdfReadSectors(), UdfSingleAsync(), xHalExamineMBR(), xHalIoClearPartitionTable(), xHalIoReadPartitionTable(), xHalIoSetPartitionInformation(), and xHalIoWritePartitionTable().

#define IRP_MJ_SCSI   IRP_MJ_INTERNAL_DEVICE_CONTROL
 

Definition at line 90 of file io.h.

Referenced by IovpSessionDataAttachSurrogate(), and IovpSessionDataDeterminePolicy().

#define IRP_MJ_SET_EA   0x08
 

Definition at line 63 of file io.h.

Referenced by IoCheckFunctionAccess(), IopSetEaOrQuotaInformationFile(), and NtSetEaFile().

#define IRP_MJ_SET_INFORMATION   0x06
 

Definition at line 61 of file io.h.

Referenced by CcSetValidData(), FsRtlCheckOplock(), FsRtlSetFileSize(), IoCheckFunctionAccess(), IoSetInformation(), NtSetInformationFile(), UdfFsdDispatch(), and UdfFspDispatch().

#define IRP_MJ_SET_QUOTA   0x1a
 

Definition at line 81 of file io.h.

Referenced by IopSetEaOrQuotaInformationFile().

#define IRP_MJ_SET_SECURITY   0x15
 

Definition at line 76 of file io.h.

Referenced by IoCheckFunctionAccess(), and IopGetSetSecurityObject().

#define IRP_MJ_SET_VOLUME_INFORMATION   0x0b
 

Definition at line 66 of file io.h.

Referenced by IoCheckFunctionAccess(), and NtSetVolumeInformationFile().

#define IRP_MJ_SHUTDOWN   0x10
 

Definition at line 71 of file io.h.

Referenced by IoBuildAsynchronousFsdRequest(), IoShutdownSystem(), and UdfCreateIrpContext().

#define IRP_MJ_SYSTEM_CONTROL   0x17
 

Definition at line 78 of file io.h.

Referenced by IopDriverCorrectnessPrintIrpStack(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), IovpAssertNewRequest(), and IovpThrowChaffAtStartedPdoStack().

#define IRP_MJ_WRITE   0x04
 

Definition at line 59 of file io.h.

Referenced by FsRtlCheckOplock(), IoAsynchronousPageWrite(), IoBuildAsynchronousFsdRequest(), IoCheckFunctionAccess(), IoSynchronousPageWrite(), IovpAssertIrpStackDownward(), NtWriteFile(), NtWriteFileGather(), xHalIoClearPartitionTable(), xHalIoSetPartitionInformation(), and xHalIoWritePartitionTable().

#define IRP_MN_CANCEL_REMOVE_DEVICE   0x03
 

Definition at line 163 of file io.h.

Referenced by IopDeleteLockedDeviceNodes(), IopDisableDevice(), IopLockMountedDeviceForRemove(), IopPnPDispatch(), IopRemoveDevice(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), IovpIsSystemRestrictedIrp(), and UdfCommonPnp().

#define IRP_MN_CANCEL_STOP_DEVICE   0x06
 

Definition at line 166 of file io.h.

Referenced by IopPnPDispatch(), IopQueryReconfiguration(), IopRebalance(), IopTestForReconfiguration(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), and IovpIsSystemRestrictedIrp().

#define IRP_MN_CHANGE_SINGLE_INSTANCE   0x02
 

Definition at line 204 of file io.h.

#define IRP_MN_CHANGE_SINGLE_ITEM   0x03
 

Definition at line 205 of file io.h.

#define IRP_MN_COMPLETE   0x04
 

Definition at line 141 of file io.h.

Referenced by UdfFsdDispatch().

#define IRP_MN_COMPLETE_MDL   (IRP_MN_COMPLETE | IRP_MN_MDL)
 

Definition at line 145 of file io.h.

#define IRP_MN_COMPLETE_MDL_DPC   (IRP_MN_COMPLETE_MDL | IRP_MN_DPC)
 

Definition at line 146 of file io.h.

#define IRP_MN_COMPRESSED   0x08
 

Definition at line 142 of file io.h.

#define IRP_MN_DEVICE_USAGE_NOTIFICATION   0x16
 

Definition at line 183 of file io.h.

Referenced by IoFreeDumpStack(), IopDriverCorrectnessPrintIrpStack(), IopGetDumpStack(), IopPnPDispatch(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), IovpIsSystemRestrictedIrp(), and MiCheckPageFilePath().

#define IRP_MN_DISABLE_COLLECTION   0x07
 

Definition at line 209 of file io.h.

#define IRP_MN_DISABLE_EVENTS   0x05
 

Definition at line 207 of file io.h.

#define IRP_MN_DPC   0x01
 

Definition at line 139 of file io.h.

#define IRP_MN_EJECT   0x11
 

Definition at line 178 of file io.h.

Referenced by IopEjectDevice(), IopRemoveDevice(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), and IovpIsSystemRestrictedIrp().

#define IRP_MN_ENABLE_COLLECTION   0x06
 

Definition at line 208 of file io.h.

#define IRP_MN_ENABLE_EVENTS   0x04
 

Definition at line 206 of file io.h.

#define IRP_MN_EXECUTE_METHOD   0x09
 

Definition at line 211 of file io.h.

#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS   0x0D
 

Definition at line 174 of file io.h.

Referenced by IopFilterResourceRequirementsCall(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), IovpAssertNewRequest(), and IovpIsSystemRestrictedIrp().

#define IRP_MN_KERNEL_CALL   0x04
 

Definition at line 117 of file io.h.

Referenced by IopGetSetObjectId(), and IopSetRemoteLink().

#define IRP_MN_LOAD_FILE_SYSTEM   0x03
 

Definition at line 115 of file io.h.

Referenced by CdfsRecFsControl(), FatRecFsControl(), IopLoadFileSystemDriver(), NtfsRecFsControl(), and UdfsRecFsControl().

#define IRP_MN_LOCK   0x01
 

Definition at line 123 of file io.h.

Referenced by FsRtlProcessFileLock(), and NtLockFile().

#define IRP_MN_MDL   0x02
 

Definition at line 140 of file io.h.

Referenced by UdfCommonRead(), and UdfPrePostIrp().

#define IRP_MN_MDL_DPC   (IRP_MN_MDL | IRP_MN_DPC)
 

Definition at line 144 of file io.h.

#define IRP_MN_MOUNT_VOLUME   0x01
 

Definition at line 113 of file io.h.

Referenced by CdfsRecFsControl(), FatRecFsControl(), FsRecFsControl(), IopMountVolume(), IopRaiseHardError(), NtfsRecFsControl(), UdfCommonFsControl(), UdfCreateIrpContext(), UdfPerformVerify(), and UdfsRecFsControl().

#define IRP_MN_NORMAL   0x00
 

Definition at line 138 of file io.h.

#define IRP_MN_NOTIFY_CHANGE_DIRECTORY   0x02
 

Definition at line 104 of file io.h.

Referenced by NtNotifyChangeDirectoryFile(), and UdfCommonDirControl().

#define IRP_MN_POWER_SEQUENCE   0x01
 

Definition at line 193 of file io.h.

Referenced by IopPowerDispatch(), and IovpIsSystemRestrictedIrp().

#define IRP_MN_QUERY_ALL_DATA   0x00
 

Definition at line 202 of file io.h.

#define IRP_MN_QUERY_BUS_INFORMATION   0x15
 

Definition at line 182 of file io.h.

Referenced by IopDriverCorrectnessPrintIrpStack(), IopPnPDispatch(), IopQueryPnpBusInformation(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), and IovpIsSystemRestrictedIrp().

#define IRP_MN_QUERY_CAPABILITIES   0x09
 

Definition at line 170 of file io.h.

Referenced by IopPnPDispatch(), IopQueryDeviceCapabilities(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), IovpAssertNewRequest(), and IovpIsSystemRestrictedIrp().

#define IRP_MN_QUERY_DEVICE_RELATIONS   0x07
 

Definition at line 168 of file io.h.

Referenced by IopDeviceRelationsComplete(), IopDriverCorrectnessPrintIrpStack(), IopGetRelatedTargetDevice(), IopPnPDispatch(), IopQueryDeviceRelations(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), IovpAssertNewRequest(), IovpIsSystemRestrictedIrp(), and IovpThrowChaffAtStartedPdoStack().

#define IRP_MN_QUERY_DEVICE_TEXT   0x0C
 

Definition at line 173 of file io.h.

Referenced by IopDriverCorrectnessPrintIrpStack(), IopProcessNewDeviceNode(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), IovpIsSystemRestrictedIrp(), and IovpThrowChaffAtStartedPdoStack().

#define IRP_MN_QUERY_DIRECTORY   0x01
 

Definition at line 103 of file io.h.

Referenced by BuildQueryDirectoryIrp(), NtQueryDirectoryFile(), UdfCommonDirControl(), UdfPrePostIrp(), and VdmQueryDirectoryFile().

#define IRP_MN_QUERY_ID   0x13
 

Definition at line 180 of file io.h.

Referenced by IopDriverCorrectnessPrintIrpStack(), IopPnPDispatch(), IopQueryCompatibleIds(), IopQueryDeviceId(), IopQueryDeviceSerialNumber(), IopQueryUniqueId(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), IovpIsSystemRestrictedIrp(), and IovpThrowChaffAtStartedPdoStack().

#define IRP_MN_QUERY_INTERFACE   0x08
 

Definition at line 169 of file io.h.

Referenced by IoGetDmaAdapter(), IopDriverCorrectnessPrintIrpStack(), IopPnPDispatch(), IopQueryDockRemovalInterface(), IopQueryResourceHandlerInterface(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), IovpIsSystemRestrictedIrp(), and IovpThrowChaffAtStartedPdoStack().

#define IRP_MN_QUERY_LEGACY_BUS_INFORMATION   0x18
 

Definition at line 186 of file io.h.

Referenced by IopDriverCorrectnessPrintIrpStack(), IopQueryLegacyBusInformation(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), and IovpIsSystemRestrictedIrp().

#define IRP_MN_QUERY_PNP_DEVICE_STATE   0x14
 

Definition at line 181 of file io.h.

Referenced by IopQueryDeviceState(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), and IovpIsSystemRestrictedIrp().

#define IRP_MN_QUERY_POWER   0x03
 

Definition at line 195 of file io.h.

Referenced by IopPowerDispatch(), and IovpIsSystemRestrictedIrp().

#define IRP_MN_QUERY_REMOVE_DEVICE   0x01
 

Definition at line 161 of file io.h.

Referenced by IopDeleteLockedDeviceNode(), IopDeleteLockedDeviceNodes(), IopDisableDevice(), IopLockMountedDeviceForRemove(), IopPnPDispatch(), IopRemoveDevice(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), IovpIsSystemRestrictedIrp(), and UdfCommonPnp().

#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS   0x0B
 

Definition at line 172 of file io.h.

Referenced by IopPnPDispatch(), IopProcessNewDeviceNode(), IopQueryDeviceResources(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), and IovpIsSystemRestrictedIrp().

#define IRP_MN_QUERY_RESOURCES   0x0A
 

Definition at line 171 of file io.h.

Referenced by IopPnPDispatch(), IopQueryDeviceResources(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), and IovpIsSystemRestrictedIrp().

#define IRP_MN_QUERY_SINGLE_INSTANCE   0x01
 

Definition at line 203 of file io.h.

#define IRP_MN_QUERY_STOP_DEVICE   0x05
 

Definition at line 165 of file io.h.

Referenced by IopPnPDispatch(), IopQueryReconfiguration(), IopTestForReconfiguration(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), and IovpIsSystemRestrictedIrp().

#define IRP_MN_READ_CONFIG   0x0F
 

Definition at line 176 of file io.h.

Referenced by IopDriverCorrectnessPrintIrpStack(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), and IovpIsSystemRestrictedIrp().

#define IRP_MN_REGINFO   0x08
 

Definition at line 210 of file io.h.

#define IRP_MN_REMOVE_DEVICE   0x02
 

Definition at line 162 of file io.h.

Referenced by IopDeleteLockedDeviceNode(), IopDeleteLockedDeviceNodes(), IopDisableDevice(), IopLockMountedDeviceForRemove(), IopPnPDispatch(), IopProcessNewDeviceNode(), IopRemoveDevice(), IopUnlockMountedDeviceForRemove(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), IovpCallDriver1(), IovpCompleteRequest3(), IovpIsSystemRestrictedIrp(), and UdfCommonPnp().

#define IRP_MN_SCSI_CLASS   0x01
 

Definition at line 154 of file io.h.

Referenced by IopDriverCorrectnessPrintIrpStack().

#define IRP_MN_SET_LOCK   0x12
 

Definition at line 179 of file io.h.

Referenced by IopDriverCorrectnessPrintIrpStack(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), and IovpIsSystemRestrictedIrp().

#define IRP_MN_SET_POWER   0x02
 

Definition at line 194 of file io.h.

Referenced by IopPowerDispatch(), and IovpIsSystemRestrictedIrp().

#define IRP_MN_SET_TRACE_NOTIFY   0x0A
 

Definition at line 220 of file io.h.

#define IRP_MN_START_DEVICE   0x00
 

Definition at line 160 of file io.h.

Referenced by IopDeviceStartComplete(), IopPnPDispatch(), IopStartDevice(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), and IovpIsSystemRestrictedIrp().

#define IRP_MN_STOP_DEVICE   0x04
 

Definition at line 164 of file io.h.

Referenced by IopPnPDispatch(), IopQueryReconfiguration(), IopRebalance(), IopTestForReconfiguration(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), and IovpIsSystemRestrictedIrp().

#define IRP_MN_SURPRISE_REMOVAL   0x17
 

Definition at line 184 of file io.h.

Referenced by IopDeleteLockedDeviceNode(), IopDeleteLockedDeviceNodes(), IopLockMountedDeviceForRemove(), IopRemoveDevice(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), IovpIsSystemRestrictedIrp(), and UdfCommonPnp().

#define IRP_MN_TRACK_LINK   0x04
 

Definition at line 116 of file io.h.

#define IRP_MN_UNLOCK_ALL   0x03
 

Definition at line 125 of file io.h.

Referenced by FsRtlProcessFileLock(), and IopCloseFile().

#define IRP_MN_UNLOCK_ALL_BY_KEY   0x04
 

Definition at line 126 of file io.h.

Referenced by FsRtlProcessFileLock().

#define IRP_MN_UNLOCK_SINGLE   0x02
 

Definition at line 124 of file io.h.

Referenced by FsRtlProcessFileLock(), and NtUnlockFile().

#define IRP_MN_USER_FS_REQUEST   0x00
 

Definition at line 112 of file io.h.

Referenced by UdfCommonFsControl(), and UdfCreateIrpContext().

#define IRP_MN_VERIFY_VOLUME   0x02
 

Definition at line 114 of file io.h.

Referenced by IoVerifyVolume(), UdfCommonFsControl(), and UdfPerformVerify().

#define IRP_MN_WAIT_WAKE   0x00
 

Definition at line 192 of file io.h.

Referenced by IopPowerDispatch(), and IovpIsSystemRestrictedIrp().

#define IRP_MN_WRITE_CONFIG   0x10
 

Definition at line 177 of file io.h.

Referenced by IopDriverCorrectnessPrintIrpStack(), IovpAssertIrpStackDownward(), IovpAssertIrpStackUpward(), and IovpIsSystemRestrictedIrp().

#define IRP_MOUNT_COMPLETION   0x00000002
 

Definition at line 1551 of file io.h.

Referenced by IopMountVolume(), and IoVerifyVolume().

#define IRP_NOCACHE   0x00000001
 

Definition at line 1549 of file io.h.

Referenced by IoAsynchronousPageWrite(), IoPageRead(), IoRaiseHardError(), IoSynchronousPageWrite(), NtReadFile(), NtReadFileScatter(), NtWriteFile(), NtWriteFileGather(), and UdfCommonRead().

#define IRP_OB_QUERY_NAME   0x00001000
 

Definition at line 1565 of file io.h.

Referenced by IopCompleteRequest(), and IopGetFileName().

#define IRP_PAGING_IO   0x00000002
 

Definition at line 1550 of file io.h.

Referenced by CcSetValidData(), FsRtlCheckOplock(), FsRtlGetFileSize(), FsRtlSetFileSize(), IoAsynchronousPageWrite(), IoIsOperationSynchronous(), IoPageRead(), IoRaiseHardError(), IoSynchronousPageWrite(), IovpCallDriver1(), and UdfCommonRead().

#define IRP_QUOTA_CHARGED   0x01
 

Definition at line 1574 of file io.h.

Referenced by IopAllocateIrpPrivate(), IopFreeIrp(), IovAllocateIrp(), IovpInitializeIrp(), and IovpSessionDataAttachSurrogate().

#define IRP_READ_OPERATION   0x00000100
 

Definition at line 1559 of file io.h.

Referenced by IopCompleteRequest(), NtReadFile(), and NtReadFileScatter().

#define IRP_RETRY_IO_COMPLETION   0x00004000
 

Definition at line 1567 of file io.h.

Referenced by IopCompleteRequest(), and IoRetryIrpCompletions().

#define IRP_SYNCHRONOUS_API   0x00000004
 

Definition at line 1552 of file io.h.

Referenced by IoCancelFileOpen(), IoIsOperationSynchronous(), IopCloseFile(), IopCompleteRequest(), IopDeleteFile(), IopDropIrp(), IopGetFileName(), IopGetSetObjectId(), IopGetSetSecurityObject(), IopGetVolumeId(), IopParseDevice(), IopQueryXxxInformation(), IopSetEaOrQuotaInformationFile(), IopSetRemoteLink(), IoSetInformation(), MiCheckPageFilePath(), NtFlushBuffersFile(), NtQueryEaFile(), NtQueryInformationFile(), NtQueryQuotaInformationFile(), NtQueryVolumeInformationFile(), NtSetEaFile(), NtSetInformationFile(), NtSetVolumeInformationFile(), NtUnlockFile(), and VdmQueryDirectoryFile().

#define IRP_SYNCHRONOUS_PAGING_IO   0x00000040
 

Definition at line 1557 of file io.h.

Referenced by CcSetValidData(), FsRtlGetFileSize(), FsRtlSetFileSize(), IoIsOperationSynchronous(), IoPageRead(), IopMountVolume(), IoRaiseHardError(), IoSynchronousPageWrite(), and IoVerifyVolume().

#define IRP_WRITE_OPERATION   0x00000200
 

Definition at line 1560 of file io.h.

Referenced by IopCompleteRequest(), NtWriteFile(), and NtWriteFileGather().

#define MAXIMUM_VOLUME_LABEL_LENGTH   (32 * sizeof(WCHAR))
 

Definition at line 1065 of file io.h.

Referenced by IopRaiseHardError(), UdfUpdateVolumeLabel(), and UdfVerifyVolume().

#define PNP_DEVICE_DISABLED   0x00000001
 

Definition at line 2001 of file io.h.

Referenced by IopQueryDeviceState().

#define PNP_DEVICE_DONT_DISPLAY_IN_UI   0x00000002
 

Definition at line 2002 of file io.h.

Referenced by IopQueryDeviceState().

#define PNP_DEVICE_FAILED   0x00000004
 

Definition at line 2003 of file io.h.

Referenced by IopQueryDeviceState().

#define PNP_DEVICE_NOT_DISABLEABLE   0x00000020
 

Definition at line 2006 of file io.h.

Referenced by IopQueryDeviceState().

#define PNP_DEVICE_REMOVED   0x00000008
 

Definition at line 2004 of file io.h.

Referenced by IopQueryDeviceState().

#define PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED   0x00000010
 

Definition at line 2005 of file io.h.

Referenced by IopQueryDeviceState().

#define POINTER_ALIGNMENT
 

Definition at line 2024 of file io.h.

#define SL_ALLOW_RAW_MOUNT   0x01
 

Definition at line 1912 of file io.h.

Referenced by IoVerifyVolume(), and UdfVerifyVolume().

#define SL_CASE_SENSITIVE   0x80
 

Definition at line 1867 of file io.h.

Referenced by IopParseDevice(), and UdfCommonCreate().

#define SL_EXCLUSIVE_LOCK   0x02
 

Definition at line 1890 of file io.h.

Referenced by FsRtlPrivateCheckWaitingLocks(), FsRtlProcessFileLock(), and NtLockFile().

#define SL_FAIL_IMMEDIATELY   0x01
 

Definition at line 1889 of file io.h.

Referenced by FsRtlProcessFileLock(), and NtLockFile().

#define SL_FORCE_ACCESS_CHECK   0x01
 

Definition at line 1863 of file io.h.

#define SL_FT_SEQUENTIAL_WRITE   0x08
 

Definition at line 1876 of file io.h.

#define SL_INDEX_SPECIFIED   0x04
 

Definition at line 1898 of file io.h.

Referenced by NtQueryEaFile(), NtQueryQuotaInformationFile(), UdfInitializeEnumeration(), and VdmQueryDirectoryFile().

#define SL_INVOKE_ON_CANCEL   0x20
 

Definition at line 1846 of file io.h.

#define SL_INVOKE_ON_ERROR   0x80
 

Definition at line 1848 of file io.h.

#define SL_INVOKE_ON_SUCCESS   0x40
 

Definition at line 1847 of file io.h.

#define SL_KEY_SPECIFIED   0x01
 

Definition at line 1873 of file io.h.

#define SL_OPEN_PAGING_FILE   0x02
 

Definition at line 1864 of file io.h.

Referenced by UdfCommonCreate().

#define SL_OPEN_TARGET_DIRECTORY   0x04
 

Definition at line 1865 of file io.h.

Referenced by UdfCommonCreate().

#define SL_OVERRIDE_VERIFY_VOLUME   0x02
 

Definition at line 1874 of file io.h.

Referenced by FsRecGetDeviceSectors(), FsRecGetDeviceSectorSize(), FsRecReadBlock(), UdfPerformDevIoCtrl(), UdfReadSectors(), xHalExamineMBR(), xHalIoClearPartitionTable(), xHalIoReadPartitionTable(), xHalIoSetPartitionInformation(), and xHalIoWritePartitionTable().

#define SL_PENDING_RETURNED   0x01
 

Definition at line 1845 of file io.h.

Referenced by FsRtlNotifyCompleteIrp(), and IovpCompleteRequest4().

#define SL_RESTART_SCAN   0x01
 

Definition at line 1896 of file io.h.

Referenced by BuildQueryDirectoryIrp(), NtQueryEaFile(), NtQueryQuotaInformationFile(), and UdfInitializeEnumeration().

#define SL_RETURN_SINGLE_ENTRY   0x02
 

Definition at line 1897 of file io.h.

Referenced by BuildQueryDirectoryIrp(), NtQueryEaFile(), NtQueryQuotaInformationFile(), and UdfInitializeEnumeration().

#define SL_WATCH_TREE   0x01
 

Definition at line 1904 of file io.h.

Referenced by NtNotifyChangeDirectoryFile(), and UdfNotifyChangeDirectory().

#define SL_WRITE_THROUGH   0x04
 

Definition at line 1875 of file io.h.

Referenced by NtWriteFile(), and NtWriteFileGather().

#define VPB_LOCKED   0x00000002
 

Definition at line 1055 of file io.h.

Referenced by IopCheckVpbMounted(), and IopDeleteDevice().

#define VPB_MOUNTED   0x00000001
 

Definition at line 1054 of file io.h.

Referenced by IopAsynchronousCall(), IopCheckVpbMounted(), IopDeleteDevice(), IopGetMountFlag(), IopLockMountedDeviceForRemove(), IopMountVolume(), IopRaiseHardError(), IoVerifyVolume(), OpenDeviceReparseIndex(), and UdfDismountVcb().

#define VPB_PERSISTENT   0x00000004
 

Definition at line 1056 of file io.h.

Referenced by IopDereferenceVpbAndFree().

#define VPB_RAW_MOUNT   0x00000010
 

Definition at line 1058 of file io.h.

Referenced by IopMountVolume().

#define VPB_REMOVE_PENDING   0x00000008
 

Definition at line 1057 of file io.h.

Referenced by IopLockMountedDeviceForRemove(), IopMountVolume(), IopUnlockMountedDeviceForRemove(), UdfDismountVcb(), and UdfInvalidateVolumes().

#define WDM_MAJORVERSION   0x01
 

Definition at line 3003 of file io.h.

Referenced by IoIsWdmVersionAvailable().

#define WDM_MINORVERSION   0x10
 

Definition at line 3004 of file io.h.

Referenced by IoIsWdmVersionAvailable().

#define WMIREG_ACTION_BLOCK_IRPS   5
 

Definition at line 4523 of file io.h.

#define WMIREG_ACTION_DEREGISTER   2
 

Definition at line 4520 of file io.h.

#define WMIREG_ACTION_REGISTER   1
 

Definition at line 4519 of file io.h.

#define WMIREG_ACTION_REREGISTER   3
 

Definition at line 4521 of file io.h.

#define WMIREG_ACTION_UPDATE_GUIDS   4
 

Definition at line 4522 of file io.h.

#define WMIREG_FLAG_CALLBACK   0x80000000
 

Definition at line 4454 of file io.h.

#define WMIREG_FLAG_TRACE_NOTIFY_MASK   0x00F00000
 

Definition at line 4465 of file io.h.

#define WMIREG_FLAG_TRACE_PROVIDER   0x00010000
 

Definition at line 4460 of file io.h.

#define WMIREG_NOTIFY_DISK_IO   1 << 20
 

Definition at line 4470 of file io.h.

#define WMIREG_NOTIFY_TDI_IO   2 << 20
 

Definition at line 4471 of file io.h.

#define WMIREGISTER   0
 

Definition at line 4529 of file io.h.

#define WMIUPDATE   1
 

Definition at line 4530 of file io.h.


Typedef Documentation

typedef struct _BOOT_LOG_RECORD BOOT_LOG_RECORD
 

Referenced by IopInitializeBootLogging().

typedef struct _BOOTDISK_INFORMATION BOOTDISK_INFORMATION
 

typedef struct _CONFIGURATION_INFORMATION CONFIGURATION_INFORMATION
 

typedef struct _CONTROLLER_OBJECT CONTROLLER_OBJECT
 

Referenced by IoCreateController().

typedef enum _CREATE_FILE_TYPE CREATE_FILE_TYPE
 

typedef struct _DEVICE_CAPABILITIES DEVICE_CAPABILITIES
 

Referenced by IopDeviceCapabilitiesToRegistry(), IopQueryDeviceCapabilities(), and IovpAssertNewRequest().

typedef struct _DEVICE_HANDLER_OBJECT DEVICE_HANDLER_OBJECT
 

typedef struct _DEVICE_OBJECT DEVICE_OBJECT
 

Referenced by IoCreateDevice(), and UdfMountVolume().

typedef enum _DEVICE_RELATION_TYPE DEVICE_RELATION_TYPE
 

Referenced by IovpThrowChaffAtStartedPdoStack().

typedef struct _DEVICE_RELATIONS DEVICE_RELATIONS
 

typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE DEVICE_USAGE_NOTIFICATION_TYPE
 

typedef struct _DEVOBJ_EXTENSION DEVOBJ_EXTENSION
 

typedef struct _DRIVER_EXTENSION DRIVER_EXTENSION
 

Referenced by IopLoadDriver().

typedef struct _DRIVER_OBJECT DRIVER_OBJECT
 

Referenced by IopLoadDriver().

typedef struct _FAST_IO_DISPATCH FAST_IO_DISPATCH
 

Referenced by FsRtlMdlRead(), and UdfInitializeGlobalData().

typedef struct _FILE_OBJECT FILE_OBJECT
 

Referenced by IoCreateStreamFileObject(), IoCreateStreamFileObjectLite(), and IopParseDevice().

typedef struct _INITIALIZATION_CONTEXT INITIALIZATION_CONTEXT
 

Referenced by IopGetDumpStack().

typedef struct _INTERFACE INTERFACE
 

Referenced by IovpThrowChaffAtStartedPdoStack().

typedef enum _IO_ALLOCATION_ACTION IO_ALLOCATION_ACTION
 

Referenced by IoAllocateController(), and IoFreeController().

typedef struct _IO_CLIENT_EXTENSION IO_CLIENT_EXTENSION
 

Referenced by IoAllocateDriverObjectExtension().

typedef struct _IO_COMPLETION_CONTEXT IO_COMPLETION_CONTEXT
 

typedef struct _IO_INTERRUPT_STRUCTURE IO_INTERRUPT_STRUCTURE
 

typedef enum _IO_QUERY_DEVICE_DATA_FORMAT IO_QUERY_DEVICE_DATA_FORMAT
 

typedef struct _IO_REMOVE_LOCK IO_REMOVE_LOCK
 

typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK IO_REMOVE_LOCK_COMMON_BLOCK
 

typedef struct _IO_REMOVE_LOCK_DBG_BLOCK IO_REMOVE_LOCK_DBG_BLOCK
 

typedef struct _IO_SECURITY_CONTEXT IO_SECURITY_CONTEXT
 

typedef struct _IO_STACK_LOCATION IO_STACK_LOCATION
 

Referenced by IopDriverCorrectnessPrintIrp(), IopGetDumpStack(), IopProcessNewDeviceNode(), and IovpSessionDataAttachSurrogate().

typedef struct _IO_TIMER IO_TIMER
 

Referenced by IoInitializeTimer(), and IopTimerDispatch().

typedef struct _IRP IRP
 

Referenced by NtRemoveIoCompletion().

typedef struct _MAILSLOT_CREATE_PARAMETERS MAILSLOT_CREATE_PARAMETERS
 

Referenced by NtCreateMailslotFile().

typedef struct _NAMED_PIPE_CREATE_PARAMETERS NAMED_PIPE_CREATE_PARAMETERS
 

Referenced by NtCreateNamedPipeFile().

typedef struct _ADAPTER_OBJECT* PADAPTER_OBJECT
 

Definition at line 1115 of file io.h.

typedef struct _BOOT_LOG_RECORD * PBOOT_LOG_RECORD
 

typedef struct _BOOTDISK_INFORMATION * PBOOTDISK_INFORMATION
 

typedef * PBUS_QUERY_ID_TYPE
 

typedef struct _CONFIGURATION_INFORMATION * PCONFIGURATION_INFORMATION
 

Referenced by NtQuerySystemInformation(), and xHalIoAssignDriveLetters().

typedef struct _CONTROLLER_OBJECT * PCONTROLLER_OBJECT
 

typedef struct _DEVICE_CAPABILITIES * PDEVICE_CAPABILITIES
 

Referenced by IovpAssertNewRequest().

typedef struct _DEVICE_HANDLER_OBJECT * PDEVICE_HANDLER_OBJECT
 

typedef struct _DEVICE_OBJECT* PDEVICE_OBJECT
 

Definition at line 1213 of file io.h.

Referenced by IopCompressRelationList(), IopGetRootDevices(), IopInitializeDeviceInstanceKey(), and IopQueryRebalance().

typedef enum _DEVICE_RELATION_TYPE * PDEVICE_RELATION_TYPE
 

typedef struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
 

Referenced by IovpThrowChaffAtStartedPdoStack().

typedef * PDEVICE_TEXT_TYPE
 

typedef struct _DEVOBJ_EXTENSION * PDEVOBJ_EXTENSION
 

Referenced by IopCompleteUnloadOrDelete().

typedef NTSTATUS(* PDRIVER_ADD_DEVICE)(IN struct _DRIVER_OBJECT *DriverObject, IN struct _DEVICE_OBJECT *PhysicalDeviceObject)
 

Definition at line 590 of file io.h.

Referenced by IopCallDriverAddDevice(), IopPnPDriverEntry(), and IopStartDriverDevices().

typedef VOID(* PDRIVER_CANCEL)(IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp)
 

Definition at line 547 of file io.h.

Referenced by FsRtlNotifySetCancelRoutine(), IoCancelIrp(), IopParseDevice(), IopXxxControlFile(), IoStartPacket(), NtReadFile(), NtReadFileScatter(), NtWriteFile(), and NtWriteFileGather().

typedef IO_ALLOCATION_ACTION(* PDRIVER_CONTROL)(IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp, IN PVOID MapRegisterBase, IN PVOID Context)
 

Definition at line 992 of file io.h.

typedef NTSTATUS(* PDRIVER_DISPATCH)(IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp)
 

Definition at line 558 of file io.h.

Referenced by IovSpecialIrpCallDriver().

typedef struct _DRIVER_EXTENSION * PDRIVER_EXTENSION
 

Referenced by IopLoadDriver().

typedef VOID(* PDRIVER_FS_NOTIFICATION)(IN struct _DEVICE_OBJECT *DeviceObject, IN BOOLEAN FsActive)
 

Definition at line 603 of file io.h.

typedef NTSTATUS(* PDRIVER_INITIALIZE)(IN struct _DRIVER_OBJECT *DriverObject, IN PUNICODE_STRING RegistryPath)
 

Definition at line 522 of file io.h.

Referenced by IoInitializeDumpStack(), IopInitializeBootDrivers(), IopLoadBootFilterDriver(), IopLoadDriver(), and NtSetSystemInformation().

typedef struct _DRIVER_OBJECT* PDRIVER_OBJECT
 

Definition at line 1417 of file io.h.

typedef VOID(* PDRIVER_REINITIALIZE)(IN struct _DRIVER_OBJECT *DriverObject, IN PVOID Context, IN ULONG Count)
 

Definition at line 534 of file io.h.

typedef VOID(* PDRIVER_STARTIO)(IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp)
 

Definition at line 569 of file io.h.

typedef VOID(* PDRIVER_UNLOAD)(IN struct _DRIVER_OBJECT *DriverObject)
 

Definition at line 580 of file io.h.

Referenced by NtUnloadDriver().

typedef VOID(* PDUMP_DRIVER_FINISH)(VOID)
 

Definition at line 301 of file io.h.

Referenced by IoWriteCrashDump().

typedef BOOLEAN(* PDUMP_DRIVER_OPEN)(IN LARGE_INTEGER PartitionOffset)
 

Definition at line 287 of file io.h.

typedef NTSTATUS(* PDUMP_DRIVER_WRITE)(IN PLARGE_INTEGER DiskByteOffset, IN PMDL Mdl)
 

Definition at line 293 of file io.h.

Referenced by IoWriteCrashDump().

typedef * PDUMP_STACK_CONTEXT
 

Referenced by IopGetDumpControlBlockCheck(), IopGetDumpStack(), and IoWriteCrashDump().

typedef * PDUMP_STACK_IMAGE
 

Referenced by IoFreeDumpStack(), IoGetDumpHiberRanges(), IoInitializeDumpStack(), IopGetDumpControlBlockCheck(), and IopLoadDumpDriver().

typedef VOID(* PFAST_IO_ACQUIRE_FILE)(IN struct _FILE_OBJECT *FileObject)
 

Definition at line 754 of file io.h.

typedef NTSTATUS(* PFAST_IO_ACQUIRE_FOR_CCFLUSH)(IN struct _FILE_OBJECT *FileObject, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 868 of file io.h.

typedef NTSTATUS(* PFAST_IO_ACQUIRE_FOR_MOD_WRITE)(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER EndingOffset, OUT struct _ERESOURCE **ResourceToRelease, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 846 of file io.h.

typedef BOOLEAN(* PFAST_IO_CHECK_IF_POSSIBLE)(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, IN BOOLEAN CheckForReadOperation, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 618 of file io.h.

typedef VOID(* PFAST_IO_DETACH_DEVICE)(IN struct _DEVICE_OBJECT *SourceDevice, IN struct _DEVICE_OBJECT *TargetDevice)
 

Definition at line 772 of file io.h.

typedef BOOLEAN(* PFAST_IO_DEVICE_CONTROL)(IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferLength, OUT PVOID OutputBuffer OPTIONAL, IN ULONG OutputBufferLength, IN ULONG IoControlCode, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 734 of file io.h.

typedef struct _FAST_IO_DISPATCH * PFAST_IO_DISPATCH
 

Referenced by FsRtlCopyRead().

typedef BOOLEAN(* PFAST_IO_LOCK)(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, PEPROCESS ProcessId, ULONG Key, BOOLEAN FailImmediately, BOOLEAN ExclusiveLock, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 685 of file io.h.

typedef BOOLEAN(* PFAST_IO_MDL_READ)(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG LockKey, OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 800 of file io.h.

typedef BOOLEAN(* PFAST_IO_MDL_READ_COMPLETE)(IN struct _FILE_OBJECT *FileObject, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 812 of file io.h.

typedef BOOLEAN(* PFAST_IO_MDL_READ_COMPLETE_COMPRESSED)(IN struct _FILE_OBJECT *FileObject, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 912 of file io.h.

typedef BOOLEAN(* PFAST_IO_MDL_WRITE_COMPLETE)(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 832 of file io.h.

typedef BOOLEAN(* PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 920 of file io.h.

typedef BOOLEAN(* PFAST_IO_PREPARE_MDL_WRITE)(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG LockKey, OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 820 of file io.h.

typedef BOOLEAN(* PFAST_IO_QUERY_BASIC_INFO)(IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, OUT PFILE_BASIC_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 661 of file io.h.

typedef BOOLEAN(* PFAST_IO_QUERY_NETWORK_OPEN_INFO)(IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer, OUT struct _IO_STATUS_BLOCK *IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 786 of file io.h.

typedef BOOLEAN(* PFAST_IO_QUERY_OPEN)(IN struct _IRP *Irp, OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 929 of file io.h.

typedef BOOLEAN(* PFAST_IO_QUERY_STANDARD_INFO)(IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, OUT PFILE_STANDARD_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 671 of file io.h.

typedef BOOLEAN(* PFAST_IO_READ)(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 631 of file io.h.

typedef BOOLEAN(* PFAST_IO_READ_COMPRESSED)(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG LockKey, OUT PVOID Buffer, OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus, OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo, IN ULONG CompressedDataInfoLength, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 882 of file io.h.

typedef VOID(* PFAST_IO_RELEASE_FILE)(IN struct _FILE_OBJECT *FileObject)
 

Definition at line 760 of file io.h.

typedef NTSTATUS(* PFAST_IO_RELEASE_FOR_CCFLUSH)(IN struct _FILE_OBJECT *FileObject, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 875 of file io.h.

typedef NTSTATUS(* PFAST_IO_RELEASE_FOR_MOD_WRITE)(IN struct _FILE_OBJECT *FileObject, IN struct _ERESOURCE *ResourceToRelease, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 855 of file io.h.

typedef BOOLEAN(* PFAST_IO_UNLOCK_ALL)(IN struct _FILE_OBJECT *FileObject, PEPROCESS ProcessId, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 711 of file io.h.

typedef BOOLEAN(* PFAST_IO_UNLOCK_ALL_BY_KEY)(IN struct _FILE_OBJECT *FileObject, PVOID ProcessId, ULONG Key, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 720 of file io.h.

typedef BOOLEAN(* PFAST_IO_UNLOCK_SINGLE)(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, PEPROCESS ProcessId, ULONG Key, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 699 of file io.h.

typedef BOOLEAN(* PFAST_IO_WRITE)(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, IN PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 644 of file io.h.

typedef BOOLEAN(* PFAST_IO_WRITE_COMPRESSED)(IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG LockKey, IN PVOID Buffer, OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus, IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo, IN ULONG CompressedDataInfoLength, IN struct _DEVICE_OBJECT *DeviceObject)
 

Definition at line 897 of file io.h.

typedef struct _FILE_OBJECT* PFILE_OBJECT
 

Definition at line 1543 of file io.h.

typedef struct _INITIALIZATION_CONTEXT * PINITIALIZATION_CONTEXT
 

Referenced by IopGetDumpStack().

typedef struct _INTERFACE * PINTERFACE
 

Referenced by IopDestroyDeviceNode().

typedef enum _IO_ALLOCATION_ACTION * PIO_ALLOCATION_ACTION
 

typedef struct _IO_CLIENT_EXTENSION * PIO_CLIENT_EXTENSION
 

typedef struct _IO_COMPLETION_CONTEXT * PIO_COMPLETION_CONTEXT
 

typedef NTSTATUS(* PIO_COMPLETION_ROUTINE)(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
 

Definition at line 1835 of file io.h.

Referenced by UdfMultipleAsync(), and UdfSingleAsync().

typedef VOID(* PIO_DPC_ROUTINE)(IN PKDPC Dpc, IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp, IN PVOID Context)
 

Definition at line 498 of file io.h.

typedef struct _IO_INTERRUPT_STRUCTURE * PIO_INTERRUPT_STRUCTURE
 

typedef BOOLEAN(* PIO_LEVEL_END_WORKER)(IN ULONG Level, IN PVOID Context)
 

Definition at line 4387 of file io.h.

typedef enum _IO_QUERY_DEVICE_DATA_FORMAT * PIO_QUERY_DEVICE_DATA_FORMAT
 

typedef NTSTATUS(* PIO_QUERY_DEVICE_ROUTINE)(IN PVOID Context, IN PUNICODE_STRING PathName, IN INTERFACE_TYPE BusType, IN ULONG BusNumber, IN PKEY_VALUE_FULL_INFORMATION *BusInformation, IN CONFIGURATION_TYPE ControllerType, IN ULONG ControllerNumber, IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation, IN CONFIGURATION_TYPE PeripheralType, IN ULONG PeripheralNumber, IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation)
 

Definition at line 336 of file io.h.

typedef struct _IO_REMOVE_LOCK * PIO_REMOVE_LOCK
 

typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK* PIO_REMOVE_LOCK_TRACKING_BLOCK
 

Definition at line 4071 of file io.h.

typedef struct _IO_SECURITY_CONTEXT * PIO_SECURITY_CONTEXT
 

typedef struct _IO_STACK_LOCATION * PIO_STACK_LOCATION
 

Referenced by CcSetValidData().

typedef struct _IO_TIMER * PIO_TIMER
 

Referenced by IopTimerDispatch().

typedef VOID(* PIO_TIMER_ROUTINE)(IN struct _DEVICE_OBJECT *DeviceObject, IN PVOID Context)
 

Definition at line 511 of file io.h.

typedef BOOLEAN(* PIO_TRAVERSE_WORKER)(IN ULONG Level, IN PVOID DeviceNode, IN PDEVICE_OBJECT DeviceObject, IN PVOID Context)
 

Definition at line 4380 of file io.h.

typedef struct _IO_WORKITEM* PIO_WORKITEM
 

Definition at line 4477 of file io.h.

typedef VOID(* PIO_WORKITEM_ROUTINE)(IN PDEVICE_OBJECT DeviceObject, IN PVOID Context)
 

Definition at line 4481 of file io.h.

typedef struct _IRP * PIRP
 

typedef struct _MAILSLOT_CREATE_PARAMETERS * PMAILSLOT_CREATE_PARAMETERS
 

typedef struct _NAMED_PIPE_CREATE_PARAMETERS * PNAMED_PIPE_CREATE_PARAMETERS
 

typedef ULONG PNP_DEVICE_STATE
 

Definition at line 1999 of file io.h.

Referenced by IopQueryDeviceState().

typedef struct _POWER_SEQUENCE POWER_SEQUENCE
 

typedef ULONG * PPNP_DEVICE_STATE
 

Definition at line 1999 of file io.h.

typedef struct _POWER_SEQUENCE * PPOWER_SEQUENCE
 

typedef SECTION_OBJECT_POINTERS* PSECTION_OBJECT_POINTERS
 

Definition at line 1475 of file io.h.

typedef struct _SHARE_ACCESS * PSHARE_ACCESS
 

typedef VOID(* PSTALL_ROUTINE)(IN ULONG Delay)
 

Definition at line 277 of file io.h.

typedef struct _VPB * PVPB
 

typedef struct _WAIT_CONTEXT_BLOCK * PWAIT_CONTEXT_BLOCK
 

typedef struct _SECTION_OBJECT_POINTERS SECTION_OBJECT_POINTERS
 

typedef struct _SHARE_ACCESS SHARE_ACCESS
 

typedef struct _VPB VPB
 

Referenced by IopCreateVpb(), UdfDismountVcb(), and UdfInvalidateVolumes().

typedef struct _WAIT_CONTEXT_BLOCK WAIT_CONTEXT_BLOCK
 

typedef enum tagWMIACTIONCODE WMIACTIONCODE
 

typedef NTSTATUS(* WMIENTRY)(IN WMIACTIONCODE ActionCode, IN PVOID DataPath, IN ULONG BufferSize, IN OUT PVOID Buffer)
 

Definition at line 4447 of file io.h.


Enumeration Type Documentation

enum _CREATE_FILE_TYPE
 

Enumeration values:
CreateFileTypeNone 
CreateFileTypeNamedPipe 
CreateFileTypeMailslot 

Definition at line 367 of file io.h.

enum _DEVICE_RELATION_TYPE
 

Enumeration values:
BusRelations 
EjectionRelations 
PowerRelations 
RemovalRelations 
TargetDeviceRelation 

Definition at line 1918 of file io.h.

enum _DEVICE_USAGE_NOTIFICATION_TYPE
 

Enumeration values:
DeviceUsageTypeUndefined 
DeviceUsageTypePaging 
DeviceUsageTypeHibernation 
DeviceUsageTypeDumpFile 

Definition at line 1931 of file io.h.

enum _IO_ALLOCATION_ACTION
 

Enumeration values:
KeepObject 
DeallocateObject 
DeallocateObjectKeepRegisters 

Definition at line 980 of file io.h.

enum _IO_QUERY_DEVICE_DATA_FORMAT
 

Enumeration values:
IoQueryDeviceIdentifier 
IoQueryDeviceConfigurationData 
IoQueryDeviceComponentInformation 
IoQueryDeviceMaxData 

Definition at line 355 of file io.h.

enum BUS_QUERY_ID_TYPE
 

Enumeration values:
BusQueryDeviceID 
BusQueryHardwareIDs 
BusQueryCompatibleIDs 
BusQueryInstanceID 
BusQueryDeviceSerialNumber 

Definition at line 1991 of file io.h.

Referenced by IovpThrowChaffAtStartedPdoStack().

01991 { 01992 BusQueryDeviceID = 0, // <Enumerator><Enumerator-specific device id> 01993 BusQueryHardwareIDs = 1, // Hardware ids 01994 BusQueryCompatibleIDs = 2, // compatible device ids 01995 BusQueryInstanceID = 3, // persistent id for this instance of the device 01996 BusQueryDeviceSerialNumber = 4 // serial number for this device 01997 } BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE;

enum DEVICE_TEXT_TYPE
 

Enumeration values:
DeviceTextDescription 
DeviceTextLocationInformation 

Definition at line 2008 of file io.h.

Referenced by IovpThrowChaffAtStartedPdoStack().

02008 { 02009 DeviceTextDescription = 0, // DeviceDesc property 02010 DeviceTextLocationInformation = 1 // DeviceLocation property 02011 } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE;

enum tagWMIACTIONCODE
 

Enumeration values:
WmiGetAllData 
WmiGetSingleInstance 
WmiChangeSingleInstance 
WmiChangeSingleItem 
WmiEnableEvents 
WmiDisableEvents 
WmiEnableCollection 
WmiDisableCollection 
WmiRegisterInfo 
WmiExecuteMethodCall 

Definition at line 4428 of file io.h.


Function Documentation

NTKERNELAPI VOID IoAcquireCancelSpinLock OUT PKIRQL  Irql  ) 
 

Definition at line 100 of file iosubs.c.

References IopCancelSpinLock.

Referenced by FsRtlAcknowledgeOplockBreak(), FsRtlNotifySetCancelRoutine(), FsRtlOplockBreakToII(), FsRtlOplockBreakToNone(), FsRtlOplockCleanup(), FsRtlRemoveAndCompleteIrp(), FsRtlRemoveAndCompleteWaitIrp(), FsRtlRequestExclusiveOplock(), FsRtlRequestOplockII(), FsRtlUninitializeFileLock(), FsRtlUninitializeOplock(), FsRtlWaitOnIrp(), IoCancelIrp(), IoStartNextPacket(), IoStartNextPacketByKey(), and IoStartPacket().

00106 : 00107 00108 This routine is invoked to acquire the cancel spin lock. This spin lock 00109 must be acquired before setting the address of a cancel routine in an 00110 IRP. 00111 00112 Arguments: 00113 00114 Irql - Address of a variable to receive the old IRQL. 00115 00116 Return Value: 00117 00118 None. 00119 00120 --*/ 00121 00122 { 00123 KIRQL oldIrql; 00124 00125 // 00126 // Simply acquire the cancel spin lock and return. 00127 // 00128 00129 ExAcquireSpinLock( &IopCancelSpinLock, &oldIrql ); 00130 *Irql = oldIrql; 00131 }

NTSYSAPI NTSTATUS NTAPI IoAcquireRemoveLockEx IN PIO_REMOVE_LOCK  RemoveLock,
IN OPTIONAL PVOID  Tag,
IN PCSTR  File,
IN ULONG  Line,
IN ULONG  RemlockSize
 

Definition at line 114 of file io/remlock.c.

References ASSERTMSG, CHECKEDSIZE, Dbg, ExAllocatePoolWithTag, FALSE, _IO_REMOVE_LOCK_TRACKING_BLOCK::File, File, FREESIZE, IO_REMOVE_LOCK_TRACKING_BLOCK, KeQueryTickCount(), KeSetEvent(), _IO_REMOVE_LOCK_TRACKING_BLOCK::Line, _IO_REMOVE_LOCK_TRACKING_BLOCK::Link, Lock, NonPagedPool, NTSTATUS(), NULL, PIO_PRIVATE_REMOVE_LOCK, _IO_REMOVE_LOCK_TRACKING_BLOCK::Tag, and _IO_REMOVE_LOCK_TRACKING_BLOCK::TimeLocked.

00124 : 00125 00126 This routine is called to acquire the remove lock for a device object. 00127 While the lock is held, the caller can assume that no pending pnp REMOVE 00128 requests will be completed. 00129 00130 The lock should be acquired immediately upon entering a dispatch routine. 00131 It should also be acquired before creating any new reference to the 00132 device object if there's a chance of releasing the reference before the 00133 new one is done. 00134 00135 Arguments: 00136 00137 RemoveLock - A pointer to an initialized REMOVE_LOCK structure. 00138 00139 Tag - Used for tracking lock allocation and release. If an irp is 00140 specified when acquiring the lock then the same Tag must be 00141 used to release the lock before the Tag is completed. 00142 00143 File - set to __FILE__ as the location in the code where the lock was taken. 00144 00145 Line - set to __LINE__. 00146 00147 Return Value: 00148 00149 Returns whether or not the remove lock was obtained. 00150 If successful the caller should continue with work calling 00151 IoReleaseRemoveLock when finished. 00152 00153 If not successful the lock was not obtained. The caller should abort the 00154 work but not call IoReleaseRemoveLock. 00155 00156 --*/ 00157 00158 { 00159 PIO_PRIVATE_REMOVE_LOCK Lock = (PIO_PRIVATE_REMOVE_LOCK) PublicLock; 00160 LONG lockValue; 00161 NTSTATUS status; 00162 00163 PIO_REMOVE_LOCK_TRACKING_BLOCK trackingBlock; 00164 00165 // 00166 // Grab the remove lock 00167 // 00168 00169 lockValue = InterlockedIncrement(&Lock->Common.IoCount); 00170 00171 ASSERTMSG("IoAcquireRemoveLock - lock value was negative : ", 00172 (lockValue > 0)); 00173 00174 if (! Lock->Common.Removed) { 00175 00176 switch (RemlockSize) { 00177 case CHECKEDSIZE: 00178 00179 ASSERTMSG("RemoveLock increased to meet LockHighWatermark", 00180 ((0 == Lock->Dbg.HighWatermark) || 00181 (lockValue <= Lock->Dbg.HighWatermark))); 00182 00183 trackingBlock = ExAllocatePoolWithTag( 00184 NonPagedPool, 00185 sizeof(IO_REMOVE_LOCK_TRACKING_BLOCK), 00186 Lock->Dbg.AllocateTag); 00187 00188 if (NULL == trackingBlock) { 00189 00190 // ASSERTMSG ("insufficient resources", FALSE); 00191 InterlockedIncrement (& Lock->Dbg.LowMemoryCount); 00192 // 00193 // Let the acquire go through but without adding the 00194 // tracking block. 00195 // When we are later releasing the lock, but the tracking 00196 // block does not exist, deduct from this value to see if the 00197 // release was still valuable. 00198 // 00199 00200 } else { 00201 00202 KIRQL oldIrql; 00203 00204 RtlZeroMemory (trackingBlock, 00205 sizeof (IO_REMOVE_LOCK_TRACKING_BLOCK)); 00206 00207 trackingBlock->Tag = Tag; 00208 trackingBlock->File = File; 00209 trackingBlock->Line = Line; 00210 00211 KeQueryTickCount(&trackingBlock->TimeLocked); 00212 00213 ExAcquireSpinLock (&Lock->Dbg.Spin, &oldIrql); 00214 trackingBlock->Link = Lock->Dbg.Blocks; 00215 Lock->Dbg.Blocks = trackingBlock; 00216 ExReleaseSpinLock(&Lock->Dbg.Spin, oldIrql); 00217 } 00218 break; 00219 00220 case FREESIZE: 00221 break; 00222 00223 default: 00224 break; 00225 } 00226 00227 status = STATUS_SUCCESS; 00228 00229 } else { 00230 00231 if (0 == InterlockedDecrement (&Lock->Common.IoCount)) { 00232 KeSetEvent (&Lock->Common.RemoveEvent, 0, FALSE); 00233 } 00234 status = STATUS_DELETE_PENDING; 00235 } 00236 00237 return status; 00238 }

NTKERNELAPI VOID IoAcquireVpbSpinLock OUT PKIRQL  Irql  ) 
 

Definition at line 134 of file iosubs.c.

References IopVpbSpinLock.

Referenced by IopLockMountedDeviceForRemove(), IopUnlockMountedDeviceForRemove(), UdfCheckForDismount(), UdfDismountVcb(), and UdfInvalidateVolumes().

00140 : 00141 00142 This routine is invoked to acquire the Volume Parameter Block (VPB) spin 00143 lock. This spin lock must be acquired before accessing the mount flag, 00144 reference count, and device object fields of a VPB. 00145 00146 Arguments: 00147 00148 Irql - Address of a variable to receive the old IRQL. 00149 00150 Return Value: 00151 00152 None. 00153 00154 --*/ 00155 00156 { 00157 KIRQL oldIrql; 00158 00159 // 00160 // Simply acquire the IopLoadFileSystemDriverVPB spin lock and return. 00161 // 00162 00163 ExAcquireSpinLock( &IopVpbSpinLock, &oldIrql ); 00164 *Irql = oldIrql; 00165 }

NTKERNELAPI NTSTATUS IoAllocateAdapterChannel IN PADAPTER_OBJECT  AdapterObject,
IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  NumberOfMapRegisters,
IN PDRIVER_CONTROL  ExecutionRoutine,
IN PVOID  Context
 

Definition at line 169 of file iosubs.c.

References _WAIT_CONTEXT_BLOCK::CurrentIrp, _WAIT_CONTEXT_BLOCK::DeviceContext, _WAIT_CONTEXT_BLOCK::DeviceObject, and HalAllocateAdapterChannel().

00179 : 00180 00181 This routine allocates the adapter channel specified by the adapter object. 00182 This is accomplished by calling HalAllocateAdapterChannel which does all of 00183 the work. 00184 00185 Arguments: 00186 00187 AdapterObject - Pointer to the adapter control object to allocate to the 00188 driver. 00189 00190 DeviceObject - Pointer to the driver's device object that represents the 00191 device allocating the adapter. 00192 00193 NumberOfMapRegisters - The number of map registers that are to be allocated 00194 from the channel, if any. 00195 00196 ExecutionRoutine - The address of the driver's execution routine that is 00197 invoked once the adapter channel (and possibly map registers) have been 00198 allocated. 00199 00200 Context - An untyped longword context parameter passed to the driver's 00201 execution routine. 00202 00203 Return Value: 00204 00205 Returns STATUS_SUCESS unless too many map registers are requested. 00206 00207 Notes: 00208 00209 Note that this routine MUST be invoked at DISPATCH_LEVEL or above. 00210 00211 --*/ 00212 00213 { 00214 #if !defined(NO_LEGACY_DRIVERS) 00215 PWAIT_CONTEXT_BLOCK wcb; 00216 00217 wcb = &DeviceObject->Queue.Wcb; 00218 00219 wcb->DeviceObject = DeviceObject; 00220 wcb->CurrentIrp = DeviceObject->CurrentIrp; 00221 wcb->DeviceContext = Context; 00222 00223 return( HalAllocateAdapterChannel( AdapterObject, 00224 wcb, 00225 NumberOfMapRegisters, 00226 ExecutionRoutine ) ); 00227 #else 00228 return( (*((PDMA_ADAPTER)AdapterObject)->DmaOperations-> 00229 AllocateAdapterChannel)( (PDMA_ADAPTER)AdapterObject, 00230 DeviceObject, 00231 NumberOfMapRegisters, 00232 ExecutionRoutine, 00233 Context) ); 00234 00235 #endif // NO_LEGACY_DRIVERS 00236 }

NTKERNELAPI VOID IoAllocateController IN PCONTROLLER_OBJECT  ControllerObject,
IN PDEVICE_OBJECT  DeviceObject,
IN PDRIVER_CONTROL  ExecutionRoutine,
IN PVOID  Context
 

Definition at line 240 of file iosubs.c.

References DeallocateObject, IO_ALLOCATION_ACTION, IoFreeController(), and KeInsertDeviceQueue().

00249 : 00250 00251 This routine allocates the controller specified by the controller object. 00252 This is accomplished by placing the device object of the driver that wants 00253 to allocate the controller on the controller's queue. If the queue is 00254 already "busy", then the controller has already been allocated, so the 00255 device object is simply placed onto the queue and waits until the controller 00256 becomes free. 00257 00258 Once the controller becomes free (or if it already is), then the driver's 00259 execution routine is invoked. 00260 00261 Arguments: 00262 00263 ControllerObject - Pointer to the controller object to allocate to the 00264 driver. 00265 00266 DeviceObject - Pointer to the driver's device object that represents the 00267 device allocating the controller. 00268 00269 ExecutionRoutine - The address of the driver's execution routine that is 00270 invoked once the controller has been allocated. 00271 00272 Context - An untyped longword context parameter passed to the driver's 00273 execution routine. 00274 00275 Return Value: 00276 00277 None. 00278 00279 Notes: 00280 00281 Note that this routine MUST be invoked at DISPATCH_LEVEL or above. 00282 00283 --*/ 00284 00285 { 00286 IO_ALLOCATION_ACTION action; 00287 00288 // 00289 // Initialize the device object's wait context block in case this device 00290 // must wait before being able to allocate the controller. 00291 // 00292 00293 DeviceObject->Queue.Wcb.DeviceRoutine = ExecutionRoutine; 00294 DeviceObject->Queue.Wcb.DeviceContext = Context; 00295 00296 // 00297 // Allocate the controller object for this particular device. If the 00298 // controller cannot be allocated because it has already been allocated 00299 // to another device, then return to the caller now; otherwise, 00300 // continue. 00301 // 00302 00303 if (!KeInsertDeviceQueue( &ControllerObject->DeviceWaitQueue, 00304 &DeviceObject->Queue.Wcb.WaitQueueEntry )) { 00305 00306 // 00307 // The controller was not busy so it has been allocated. Simply 00308 // invoke the driver's execution routine now. 00309 // 00310 00311 action = ExecutionRoutine( DeviceObject, 00312 DeviceObject->CurrentIrp, 00313 0, 00314 Context ); 00315 00316 // 00317 // If the driver would like to have the controller deallocated, 00318 // then deallocate it now. 00319 // 00320 00321 if (action == DeallocateObject) { 00322 IoFreeController( ControllerObject ); 00323 } 00324 } 00325 }

NTKERNELAPI NTSTATUS IoAllocateDriverObjectExtension IN PDRIVER_OBJECT  DriverObject,
IN PVOID  ClientIdentificationAddress,
IN ULONG  DriverObjectExtensionSize,
OUT PVOID *  DriverObjectExtension
 

Definition at line 328 of file iosubs.c.

References _IO_CLIENT_EXTENSION::ClientIdentificationAddress, ExAllocatePoolWithTag, ExFreePool(), extension, FALSE, IO_CLIENT_EXTENSION, IopDatabaseLock, _IO_CLIENT_EXTENSION::NextExtension, NonPagedPool, NULL, and TRUE.

00337 : 00338 This routine allocates per driver storage for helper or class drivers 00339 which may support several different mini-drivers. The storage is tagged 00340 with a client identification address which is used to retrieve a pointer 00341 to the storage. The client id must be unique. 00342 00343 The allocated storage is freed when the driver object is deleted. 00344 00345 Arguments: 00346 00347 DriverObject - The driver object to which the extension is to be 00348 associated. 00349 00350 ClientIdentificationAddress - Unique identifier used to retrieve the 00351 extension. 00352 00353 DriverObjectExtensionSize - Specifies the size in bytes of the extension. 00354 00355 DriverObjectExtension - Returns a pointer to the allocated extension. 00356 00357 Return Value: 00358 00359 Returns the status of the operation. Failure cases are 00360 STATUS_INSUFFICIENT_RESOURCES and STATUS_OBJECT_NAME_COLLISION. 00361 00362 --*/ 00363 00364 { 00365 KIRQL irql; 00366 BOOLEAN inserted = FALSE; 00367 PIO_CLIENT_EXTENSION extension; 00368 PIO_CLIENT_EXTENSION newExtension; 00369 00370 *DriverObjectExtension = NULL; 00371 00372 newExtension = ExAllocatePoolWithTag( NonPagedPool, 00373 DriverObjectExtensionSize + 00374 sizeof( IO_CLIENT_EXTENSION ), 00375 'virD'); 00376 00377 if (newExtension == NULL) { 00378 return(STATUS_INSUFFICIENT_RESOURCES); 00379 } 00380 00381 RtlZeroMemory( newExtension, 00382 DriverObjectExtensionSize + 00383 sizeof( IO_CLIENT_EXTENSION ) 00384 ); 00385 00386 newExtension->ClientIdentificationAddress = ClientIdentificationAddress; 00387 00388 ExAcquireFastLock( &IopDatabaseLock, &irql ); 00389 extension = DriverObject->DriverExtension->ClientDriverExtension; 00390 while (extension != NULL) { 00391 00392 if (extension->ClientIdentificationAddress == ClientIdentificationAddress) { 00393 break; 00394 } 00395 00396 extension = extension->NextExtension; 00397 } 00398 00399 if (extension == NULL) { 00400 00401 // 00402 // The client id does not exist. Insert the new extension in the 00403 // list. 00404 // 00405 00406 newExtension->NextExtension = 00407 DriverObject->DriverExtension->ClientDriverExtension; 00408 DriverObject->DriverExtension->ClientDriverExtension = newExtension; 00409 inserted = TRUE; 00410 } 00411 00412 ExReleaseFastLock( &IopDatabaseLock, irql ); 00413 00414 if (!inserted) { 00415 ExFreePool( newExtension ); 00416 return(STATUS_OBJECT_NAME_COLLISION); 00417 } 00418 00419 // 00420 // Return a pointer to the client's data area. 00421 // 00422 00423 *DriverObjectExtension = newExtension + 1; 00424 return(STATUS_SUCCESS); 00425 }

NTKERNELAPI PVOID IoAllocateErrorLogEntry IN PVOID  IoObject,
IN UCHAR  EntrySize
 

Definition at line 428 of file iosubs.c.

References _DEVICE_OBJECT::DriverObject, IO_TYPE_DEVICE, IO_TYPE_DRIVER, IopAllocateErrorLogEntry(), NULL, and _DEVICE_OBJECT::Type.

Referenced by CcLogError(), DriverEntry(), FsVgaLogError(), IopDisassociateThreadIrp(), IopLogErrorEvent(), and UserLogError().

00435 : 00436 00437 This routine allocates and initializes an error log entry buffer and returns 00438 a pointer to the data entry portion of the buffer. 00439 00440 Arguments: 00441 00442 IoObject - Pointer to driver's device object or driver object. 00443 00444 EntrySize - Size of entry to be allocated, in bytes. The maximum size is 00445 specified by ERROR_LOG_MAXIMUM_SIZE. 00446 00447 Return Value: 00448 00449 Pointer to the body of the allocated error log entry, or NULL, if there are 00450 no free entries in the system. 00451 00452 Note: 00453 00454 This routine assumes that the caller wants an error log entry within the 00455 bounds of the maximum size. 00456 00457 --*/ 00458 00459 { 00460 PDEVICE_OBJECT deviceObject; 00461 PDRIVER_OBJECT driverObject; 00462 00463 // 00464 // Make sure that a I/O object pointer was passed in. 00465 // 00466 00467 if (IoObject == NULL) { 00468 return(NULL); 00469 } 00470 00471 // 00472 // Assume for a moment this is a device object. 00473 // 00474 00475 deviceObject = IoObject; 00476 00477 // 00478 // Determine if this is a driver object or device object or if we 00479 // are allocating a generic error log entry. This is determined 00480 // from the Type field of the object passed in. 00481 // 00482 00483 if (deviceObject->Type == IO_TYPE_DEVICE) { 00484 00485 driverObject = deviceObject->DriverObject; 00486 00487 } else if (deviceObject->Type == IO_TYPE_DRIVER) { 00488 00489 driverObject = (PDRIVER_OBJECT) IoObject; 00490 deviceObject = NULL; 00491 00492 } else { 00493 00494 return(NULL); 00495 00496 } 00497 00498 return (IopAllocateErrorLogEntry( 00499 deviceObject, 00500 driverObject, 00501 EntrySize)); 00502 00503 }

NTKERNELAPI PVOID IoAllocateGenericErrorLogEntry IN UCHAR  EntrySize  ) 
 

Definition at line 506 of file iosubs.c.

References IopAllocateErrorLogEntry(), and NULL.

00512 : 00513 00514 This routine allocates and initializes an error log entry buffer and returns 00515 a pointer to the data entry portion of the buffer. It's expected to be 00516 called from inside the kernel where there may not be a driver object 00517 or a device object. 00518 00519 Arguments: 00520 00521 00522 EntrySize - Size of entry to be allocated, in bytes. The maximum size is 00523 specified by ERROR_LOG_MAXIMUM_SIZE. 00524 00525 Return Value: 00526 00527 Pointer to the body of the allocated error log entry, or NULL, if there are 00528 no free entries in the system. 00529 00530 Note: 00531 00532 This routine assumes that the caller wants an error log entry within the 00533 bounds of the maximum size. 00534 00535 --*/ 00536 00537 { 00538 return(IopAllocateErrorLogEntry(NULL, NULL, EntrySize)); 00539 }

NTKERNELAPI PIRP IoAllocateIrp IN CCHAR  StackSize,
IN BOOLEAN  ChargeQuota
 

Definition at line 652 of file iosubs.c.

References pIoAllocateIrp.

Referenced by BuildQueryDirectoryIrp(), CcSetValidData(), FsRtlGetFileSize(), FsRtlSetFileSize(), IoAsynchronousPageWrite(), IoBuildAsynchronousFsdRequest(), IoBuildDeviceIoControlRequest(), IoPageRead(), IopAllocateIrpMustSucceed(), IopAsynchronousCall(), IopDeleteFile(), IopEjectDevice(), IopFilterResourceRequirementsCall(), IopGetFileName(), IopGetSetSecurityObject(), IopQueryXxxInformation(), IopSetEaOrQuotaInformationFile(), IopSynchronousCall(), IoSetInformation(), IoSynchronousPageWrite(), IoVerifyVolume(), IovpThrowBogusSynchronousIrp(), MiCheckPageFilePath(), NtFlushBuffersFile(), NtLockFile(), NtNotifyChangeDirectoryFile(), NtQueryEaFile(), NtQueryInformationFile(), NtQueryQuotaInformationFile(), NtQueryVolumeInformationFile(), NtSetEaFile(), NtSetInformationFile(), NtSetVolumeInformationFile(), NtUnlockFile(), and VdmQueryDirectoryFile().

00656 { 00657 return (pIoAllocateIrp(StackSize, ChargeQuota)); 00658 }

NTKERNELAPI PMDL IoAllocateMdl IN PVOID  VirtualAddress,
IN ULONG  Length,
IN BOOLEAN  SecondaryBuffer,
IN BOOLEAN  ChargeQuota,
IN OUT PIRP Irp  OPTIONAL
 

Definition at line 805 of file iosubs.c.

References ASSERT, COMPUTE_PAGES_SPANNED, ExAllocateFromPPNPagedLookasideList(), ExAllocatePoolWithTag, IOP_FIXED_SIZE_MDL_PFNS, Irp, KernelMode, LookasideMdlList, MDL_ALLOCATED_FIXED_SIZE, MDL_ALLOCATED_MUST_SUCCEED, _IRP::MdlAddress, _MDL::MdlFlags, MmInitializeMdl, _MDL::Next, NonPagedPool, NonPagedPoolMustSucceed, NULL, and USHORT.

Referenced by BuildQueryDirectoryIrp(), CcMdlRead(), CcPrepareMdlWrite(), CcZeroData(), IoBuildAsynchronousFsdRequest(), IoBuildDeviceIoControlRequest(), IopSetEaOrQuotaInformationFile(), IopXxxControlFile(), NtNotifyChangeDirectoryFile(), NtQueryEaFile(), NtQueryQuotaInformationFile(), NtReadFile(), NtReadFileScatter(), NtSetEaFile(), NtWriteFile(), NtWriteFileGather(), UdfCreateUserMdl(), UdfMultipleAsync(), UdfPrepareBuffers(), and VdmQueryDirectoryFile().

00815 : 00816 00817 This routine allocates a Memory Descriptor List (MDL) large enough to map 00818 the buffer specified by the VirtualAddress and Length parameters. If the 00819 routine is given a pointer to an Irp, then it will chain the MDL to the 00820 IRP in the appropriate way. 00821 00822 If this routine is not given a pointer to an Irp it is up to the caller to 00823 set the MDL address in the IRP that the MDL is being allocated for. 00824 00825 Note that the header information of the MDL will also be initialized. 00826 00827 Arguments: 00828 00829 VirtualAddress - Starting virtual address of the buffer to be mapped. 00830 00831 Length - Length, in bytes, of the buffer to be mapped. 00832 00833 SecondaryBuffer - Indicates whether this is a chained buffer. 00834 00835 ChargeQuota - Indicates whether quota should be charged if MDL allocated. 00836 00837 N.B. This parameter is ignored. 00838 00839 Irp - Optional pointer to IRP that MDL is being allocated for. 00840 00841 Return Value: 00842 00843 A pointer to the allocated MDL, or NULL if one could not be allocated. 00844 Note that if no MDL could be allocated because there was not enough quota, 00845 then it is up to the caller to catch the raised exception. 00846 00847 --*/ 00848 00849 { 00850 ULONG allocateSize; 00851 USHORT fixedSize; 00852 PMDL mdl; 00853 USHORT mustSucceed; 00854 ULONG size; 00855 PMDL tmpMdlPtr; 00856 00857 ASSERT(Length); 00858 00859 // 00860 // If the requested length is greater than 2Gb, then we're not going 00861 // to be able to map the memory, so fail the request. 00862 // 00863 00864 if (Length & 0x80000000) { 00865 return NULL; 00866 } 00867 00868 // 00869 // Allocate an MDL from the lookaside list or pool as appropriate. 00870 // 00871 00872 mdl = NULL; 00873 fixedSize = 0; 00874 mustSucceed = 0; 00875 size = COMPUTE_PAGES_SPANNED(VirtualAddress, Length); 00876 if (size > IOP_FIXED_SIZE_MDL_PFNS) { 00877 allocateSize = sizeof(MDL) + (sizeof(PFN_NUMBER) * size); 00878 if (allocateSize > MAXUSHORT) { 00879 return NULL; 00880 } 00881 00882 } else { 00883 fixedSize = MDL_ALLOCATED_FIXED_SIZE; 00884 allocateSize = sizeof(MDL) + (sizeof(PFN_NUMBER) * IOP_FIXED_SIZE_MDL_PFNS); 00885 mdl = (PMDL)ExAllocateFromPPNPagedLookasideList(LookasideMdlList); 00886 } 00887 00888 if (!mdl) { 00889 mdl = ExAllocatePoolWithTag(NonPagedPool, allocateSize, ' ldM'); 00890 if (!mdl) { 00891 if (KeGetPreviousMode() == KernelMode) { 00892 mustSucceed = MDL_ALLOCATED_MUST_SUCCEED; 00893 mdl = ExAllocatePoolWithTag(NonPagedPoolMustSucceed, 00894 allocateSize, 00895 ' ldM' ); 00896 } 00897 00898 if (!mdl) { 00899 return NULL; 00900 } 00901 } 00902 } 00903 00904 // 00905 // Now fill in the header of the MDL. 00906 // 00907 00908 MmInitializeMdl(mdl, VirtualAddress, Length); 00909 mdl->MdlFlags |= (fixedSize | mustSucceed); 00910 00911 // 00912 // Finally, if an IRP was specified, store the address of the MDL 00913 // based on whether or not this is a secondary buffer. 00914 // 00915 00916 if (Irp) { 00917 if (!SecondaryBuffer) { 00918 Irp->MdlAddress = mdl; 00919 00920 } else { 00921 tmpMdlPtr = Irp->MdlAddress; 00922 while (tmpMdlPtr->Next != NULL) { 00923 tmpMdlPtr = tmpMdlPtr->Next; 00924 } 00925 00926 tmpMdlPtr->Next = mdl; 00927 } 00928 } 00929 00930 return mdl; 00931 }

PIO_WORKITEM IoAllocateWorkItem PDEVICE_OBJECT  DeviceObject  ) 
 

Definition at line 891 of file io/misc.c.

References _IO_WORKITEM::DeviceObject, ExAllocatePool, ExInitializeWorkItem, IO_WORKITEM, IopProcessWorkItem(), NonPagedPool, NULL, and _IO_WORKITEM::WorkItem.

00894 { 00895 PIO_WORKITEM ioWorkItem; 00896 PWORK_QUEUE_ITEM exWorkItem; 00897 00898 // 00899 // Allocate a new workitem structure. 00900 // 00901 00902 ioWorkItem = ExAllocatePool( NonPagedPool, sizeof( IO_WORKITEM )); 00903 if (ioWorkItem != NULL) { 00904 00905 // 00906 // Initialize the invariant portions of both ioWorkItem and 00907 // exWorkItem. 00908 // 00909 00910 #if DBG 00911 ioWorkItem->Size = sizeof( IO_WORKITEM ); 00912 #endif 00913 00914 ioWorkItem->DeviceObject = DeviceObject; 00915 00916 exWorkItem = &ioWorkItem->WorkItem; 00917 ExInitializeWorkItem( exWorkItem, IopProcessWorkItem, ioWorkItem ); 00918 } 00919 00920 return ioWorkItem; 00921 }

NTKERNELAPI NTSTATUS IoAssignResources IN PUNICODE_STRING  RegistryPath,
IN PUNICODE_STRING DriverClassName  OPTIONAL,
IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT DeviceObject  OPTIONAL,
IN PIO_RESOURCE_REQUIREMENTS_LIST  RequestedResources,
IN OUT PCM_RESOURCE_LIST *  AllocatedResources
 

Definition at line 394 of file assign.c.

References ArbiterRequestLegacyAssigned, DNF_LEGACY_RESOURCE_DEVICENODE, IopLegacyResourceAllocation(), KeBugCheckEx(), NULL, and PNP_ERR_INVALID_PDO.

00404 : 00405 00406 This routine takes an input request of RequestedResources, and returned 00407 allocated resources in pAllocatedResources. The allocated resources are 00408 automatically recorded in the registry under the ResourceMap for the 00409 DriverClassName/DriverObject/DeviceObject requestor. 00410 00411 Arguments: 00412 00413 RegistryPath 00414 For a simple driver, this would be the value passed to the drivers 00415 initialization function. For drivers call IoAssignResources with 00416 multiple DeviceObjects are responsible for passing in a unique 00417 RegistryPath for each object. 00418 00419 The registry path is checked for: 00420 RegitryPath: 00421 AssignedSystemResources. 00422 00423 AssignSystemResources is of type REG_RESOURCE_REQUIREMENTS_LIST 00424 00425 If present, IoAssignResources will attempt to use these settings to 00426 satisify the requested resources. If the listed settings do 00427 not conform to the resource requirements, then IoAssignResources 00428 will fail. 00429 00430 Note: IoAssignResources may store other internal binary information 00431 in the supplied RegisteryPath. 00432 00433 DriverObject: 00434 The driver object of the caller. 00435 00436 DeviceObject: 00437 If non-null, then requested resoruce list refers to this device. 00438 If null, the requested resource list refers to the driver. 00439 00440 DriverClassName 00441 Used to partition allocated resources into different device classes. 00442 00443 RequestedResources 00444 A list of resources to allocate. 00445 00446 Allocated resources may be appended or freed by re-invoking 00447 IoAssignResources with the same RegistryPath, DriverObject and 00448 DeviceObject. (editing requirements on a resource list by using 00449 sucessive calls is not preferred driver behaviour). 00450 00451 AllocatedResources 00452 Returns the allocated resources for the requested resource list. 00453 00454 Note that the driver is responsible for passing in a pointer to 00455 an uninitialized pointer. IoAssignResources will initialize the 00456 pointer to point to the allocated CM_RESOURCE_LIST. The driver 00457 is responisble for returning the memory back to pool when it is 00458 done with them structure. 00459 00460 Return Value: 00461 00462 The status returned is the final completion status of the operation. 00463 00464 --*/ 00465 { 00466 if (DeviceObject) { 00467 00468 if ( DeviceObject->DeviceObjectExtension->DeviceNode && 00469 !(((PDEVICE_NODE)DeviceObject->DeviceObjectExtension->DeviceNode)->Flags & DNF_LEGACY_RESOURCE_DEVICENODE)) { 00470 00471 KeBugCheckEx(PNP_DETECTED_FATAL_ERROR, PNP_ERR_INVALID_PDO, (ULONG_PTR)DeviceObject, 0, 0); 00472 00473 } 00474 00475 } 00476 00477 if (RequestedResources) { 00478 00479 if (RequestedResources->AlternativeLists == 0 || 00480 RequestedResources->List[0].Count == 0) { 00481 00482 RequestedResources = NULL; 00483 00484 } 00485 } 00486 00487 if (pAllocatedResources) { 00488 00489 *pAllocatedResources = NULL; 00490 00491 } 00492 00493 return IopLegacyResourceAllocation ( ArbiterRequestLegacyAssigned, 00494 DriverObject, 00495 DeviceObject, 00496 RequestedResources, 00497 pAllocatedResources); 00498 } #if 0

NTKERNELAPI NTSTATUS IoAsynchronousPageWrite IN PFILE_OBJECT  FileObject,
IN PMDL  MemoryDescriptorList,
IN PLARGE_INTEGER  StartingOffset,
IN PIO_APC_ROUTINE  ApcRoutine,
IN PVOID  ApcContext,
OUT PIO_STATUS_BLOCK  IoStatusBlock,
OUT PIRP *Irp  OPTIONAL
 

Definition at line 934 of file iosubs.c.

References FALSE, _IO_STACK_LOCATION::FileObject, _IRP::Flags, IoAllocateIrp(), IoCallDriver, IoGetNextIrpStackLocation, IoGetRelatedDeviceObject(), Irp, IRP_MJ_WRITE, IRP_NOCACHE, IRP_PAGING_IO, KernelMode, _IO_STACK_LOCATION::MajorFunction, _IRP::MdlAddress, NT_ERROR, NTSTATUS(), _IRP::Overlay, _IO_STACK_LOCATION::Parameters, PsGetCurrentThread, _IRP::RequestorMode, _DEVICE_OBJECT::StackSize, _IRP::Tail, _IRP::UserBuffer, and _IRP::UserIosb.

Referenced by MiGatherMappedPages(), MiGatherPagefilePages(), and MiMappedPageWriter().

00946 : 00947 00948 This routine provides a special, fast interface for the Modified Page Writer 00949 (MPW) to write pages to the disk quickly and with very little overhead. All 00950 of the special handling for this request is recognized by setting the 00951 IRP_PAGING_IO flag in the IRP flags word. 00952 00953 Arguments: 00954 00955 FileObject - A pointer to a referenced file object describing which file 00956 the write should be performed on. 00957 00958 MemoryDescriptorList - An MDL which describes the physical pages that the 00959 pages should be written to the disk. All of the pages have been locked 00960 in memory. The MDL also describes the length of the write operation. 00961 00962 StartingOffset - Pointer to the offset in the file from which the write 00963 should take place. 00964 00965 ApcRoutine - The address of a kernel APC routine which should be executed 00966 after the write operation has completed. 00967 00968 ApcContext - A context parameter which should be supplied to the kernel APC 00969 routine when it executes. 00970 00971 IoStatusBlock - A pointer to the I/O status block in which the final status 00972 and information should be stored. 00973 00974 Irp - If specified, allows the caller to squirrel away a pointer to the Irp. 00975 00976 Return Value: 00977 00978 The function value is the final status of the queue request to the I/O 00979 system subcomponents. 00980 00981 00982 --*/ 00983 00984 { 00985 PIRP irp; 00986 PIO_STACK_LOCATION irpSp; 00987 PDEVICE_OBJECT deviceObject; 00988 NTSTATUS status; 00989 00990 // 00991 // Begin by getting a pointer to the device object that the file resides 00992 // on. 00993 // 00994 00995 deviceObject = IoGetRelatedDeviceObject( FileObject ); 00996 00997 // 00998 // Allocate an I/O Request Packet (IRP) for this out-page operation. 00999 // 01000 01001 irp = IoAllocateIrp( deviceObject->StackSize, FALSE ); 01002 if (!irp) { 01003 return STATUS_INSUFFICIENT_RESOURCES; 01004 } 01005 01006 // 01007 // If specified, let the caller know what Irp is responsible for this 01008 // transfer. While this is mainly for debugging purposes, it is 01009 // absolutely essential to debug certain types of problems, and is 01010 // very cheap, thus is included in the FREE build as well. 01011 // 01012 01013 if (ARGUMENT_PRESENT(Irp)) { 01014 *Irp = irp; 01015 } 01016 01017 // 01018 // Get a pointer to the first stack location in the packet. This location 01019 // will be used to pass the function codes and parameters to the first 01020 // driver. 01021 // 01022 01023 irpSp = IoGetNextIrpStackLocation( irp ); 01024 01025 // 01026 // Fill in the IRP according to this request. 01027 // 01028 01029 irp->MdlAddress = MemoryDescriptorList; 01030 irp->Flags = IRP_PAGING_IO | IRP_NOCACHE; 01031 irp->Tail.Overlay.Thread = PsGetCurrentThread(); 01032 irp->Tail.Overlay.OriginalFileObject = FileObject; 01033 irp->UserBuffer = (PVOID) ((PCHAR) MemoryDescriptorList->StartVa + MemoryDescriptorList->ByteOffset); 01034 irp->RequestorMode = KernelMode; 01035 irp->UserIosb = IoStatusBlock; 01036 irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine; 01037 irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext; 01038 01039 // 01040 // Fill in the normal write parameters. 01041 // 01042 01043 irpSp->MajorFunction = IRP_MJ_WRITE; 01044 irpSp->Parameters.Write.Length = MemoryDescriptorList->ByteCount; 01045 irpSp->Parameters.Write.ByteOffset = *StartingOffset; 01046 irpSp->FileObject = FileObject; 01047 01048 // 01049 // Queue the packet to the appropriate driver based on whether or not there 01050 // is a VPB associated with the device. 01051 // 01052 01053 status = IoCallDriver( deviceObject, irp ); 01054 01055 if (NT_ERROR( status )) { 01056 IoStatusBlock->Status = status; 01057 IoStatusBlock->Information = 0; 01058 ApcRoutine( ApcContext, IoStatusBlock, 0 ); 01059 status = STATUS_PENDING; 01060 } 01061 01062 return status; 01063 }

NTKERNELAPI NTSTATUS IoAttachDevice IN PDEVICE_OBJECT  SourceDevice,
IN PUNICODE_STRING  TargetDevice,
OUT PDEVICE_OBJECT AttachedDevice
 

Definition at line 1067 of file iosubs.c.

References IO_ATTACH_DEVICE_API, IoAttachDeviceToDeviceStack(), IoFileObjectType, IoGetRelatedDeviceObject(), KernelMode, NT_SUCCESS, NTSTATUS(), NULL, ObDereferenceObject, ObReferenceObjectByHandle(), PAGED_CODE, VOID(), and ZwOpenFile().

01075 : 01076 01077 This routine "attaches" a device to another device. That is, it associates 01078 the source device to a target device which enables the I/O system to ensure 01079 that the target device a) exists, and b) cannot be unloaded until the source 01080 device has detached. Also, requests bound for the target device are given 01081 to the source device first, where applicable. 01082 01083 Arguments: 01084 01085 SourceDevice - Pointer to device object to be attached to the target. 01086 01087 TargetDevice - Supplies the name of the target device to which the attach 01088 is to occur. 01089 01090 AttachedDevice - Returns a pointer to the device to which the attach 01091 occurred. This is the device object that the source driver should 01092 use to communicate with the target driver. 01093 01094 Return Value: 01095 01096 The function value is the final status of the operation. 01097 01098 --*/ 01099 01100 { 01101 NTSTATUS status; 01102 PDEVICE_OBJECT targetDevice; 01103 PFILE_OBJECT fileObject; 01104 OBJECT_ATTRIBUTES objectAttributes; 01105 HANDLE fileHandle; 01106 IO_STATUS_BLOCK ioStatus; 01107 01108 PAGED_CODE(); 01109 01110 // 01111 // Attempt to open the target device for attach access. This ensures that 01112 // the device itself will be opened, with all of the special considerations 01113 // thereof. 01114 // 01115 01116 InitializeObjectAttributes( &objectAttributes, 01117 TargetDevice, 01118 0, 01119 (HANDLE) NULL, 01120 (PSECURITY_DESCRIPTOR) NULL ); 01121 01122 status = ZwOpenFile( &fileHandle, 01123 FILE_READ_ATTRIBUTES, 01124 &objectAttributes, 01125 &ioStatus, 01126 0, 01127 FILE_NON_DIRECTORY_FILE | IO_ATTACH_DEVICE_API ); 01128 01129 if (NT_SUCCESS( status )) { 01130 01131 // 01132 // The open operation was successful. Dereference the file handle 01133 // and obtain a pointer to the device object for the handle. 01134 // 01135 01136 status = ObReferenceObjectByHandle( fileHandle, 01137 0, 01138 IoFileObjectType, 01139 KernelMode, 01140 (PVOID *) &fileObject, 01141 NULL ); 01142 if (NT_SUCCESS( status )) { 01143 01144 // 01145 // Get a pointer to the device object for this file, and close 01146 // the handle. 01147 // 01148 01149 targetDevice = IoGetRelatedDeviceObject( fileObject ); 01150 (VOID) ZwClose( fileHandle ); 01151 01152 } else { 01153 01154 return status; 01155 } 01156 01157 } else { 01158 01159 return status; 01160 01161 } 01162 01163 // 01164 // Set the attached device pointer so that the driver being attached to 01165 // cannot unload until the detach occurs, and so that attempts to open the 01166 // device object go through the attached driver. Note that the reference 01167 // count is not incremented since exclusive drivers can only be opened once 01168 // and this would count as an open. At that point, both device objects 01169 // would become useless. 01170 // 01171 01172 *AttachedDevice = IoAttachDeviceToDeviceStack( SourceDevice, targetDevice ); 01173 if(!*AttachedDevice) { 01174 status = STATUS_NO_SUCH_DEVICE; 01175 } 01176 01177 // 01178 // Finally, dereference the file object. This decrements the reference 01179 // count for the target device so that when the detach occurs the device 01180 // can go away if necessary. 01181 // 01182 01183 ObDereferenceObject( fileObject ); 01184 01185 // 01186 // Return the final status of the operation. 01187 // 01188 01189 return status; 01190 }

NTKERNELAPI NTSTATUS IoAttachDeviceByPointer IN PDEVICE_OBJECT  SourceDevice,
IN PDEVICE_OBJECT  TargetDevice
 

Definition at line 1193 of file iosubs.c.

References IoAttachDeviceToDeviceStack(), NTSTATUS(), and NULL.

01200 : 01201 01202 This routine attaches the source device object to the target device 01203 object. 01204 01205 Arguments: 01206 01207 SourceDevice - Specifies the device object that is to be attached to 01208 the target device. 01209 01210 TargetDevice - Specifies the device object to which the attachment is 01211 to take place. 01212 01213 Return Value: 01214 01215 The function value is the final status of the attach operation. 01216 01217 Note: 01218 01219 THIS FUNCTION IS OBSOLETE!!! see IoAttachDeviceToDeviceStack 01220 01221 --*/ 01222 01223 { 01224 PDEVICE_OBJECT deviceObject; 01225 NTSTATUS status; 01226 01227 // 01228 // Get a pointer to the topmost device object in the stack of devices, 01229 // beginning with the TargetDevice. 01230 // 01231 01232 deviceObject = IoAttachDeviceToDeviceStack( SourceDevice, TargetDevice ); 01233 if( deviceObject == NULL ){ 01234 status = STATUS_NO_SUCH_DEVICE; 01235 } else { 01236 status = STATUS_SUCCESS; 01237 } 01238 01239 return status; 01240 }

NTKERNELAPI PDEVICE_OBJECT IoAttachDeviceToDeviceStack IN PDEVICE_OBJECT  SourceDevice,
IN PDEVICE_OBJECT  TargetDevice
 

Definition at line 1243 of file iosubs.c.

References _DEVICE_OBJECT::AlignmentRequirement, ASSERT, _DEVICE_OBJECT::AttachedDevice, _DEVOBJ_EXTENSION::AttachedTo, _DEVICE_OBJECT::DeviceObjectExtension, DO_DEVICE_INITIALIZING, DOE_DELETE_PENDING, DOE_REMOVE_PENDING, DOE_REMOVE_PROCESSED, DOE_START_PENDING, DOE_UNLOAD_PENDING, _DEVOBJ_EXTENSION::ExtensionFlags, _DEVICE_OBJECT::Flags, IoGetAttachedDevice(), IopDatabaseLock, IOV_ATTACH_DEVICE_TO_DEVICE_STACK, NULL, _DEVICE_OBJECT::SectorSize, _DEVICE_OBJECT::Spare1, and _DEVICE_OBJECT::StackSize.

Referenced by IoAttachDevice(), and IoAttachDeviceByPointer().

01250 : 01251 01252 This routine attaches the source device object to the target device 01253 object and returns a pointer to the actual device attached to, if 01254 successful. 01255 01256 Arguments: 01257 01258 SourceDevice - Specifies the device object that is to be attached to 01259 the target device. 01260 01261 TargetDevice - Specifies the device object to which the attachment is 01262 to occur. 01263 01264 Return Value: 01265 01266 If successful, this function returns a pointer to the device object to 01267 which the attachment actually occurred. 01268 01269 If unsuccessful, this function returns NULL. (This could happen if the 01270 device currently at the top of the attachment chain is being unloaded, 01271 deleted or initialized.) 01272 01273 --*/ 01274 01275 { 01276 PDEVICE_OBJECT deviceObject; 01277 PDEVOBJ_EXTENSION sourceExtension; 01278 KIRQL irql; 01279 01280 // 01281 // Retrieve a pointer to the source device object's extension outside 01282 // of the IopDatabaseLock, since it isn't protected by that. 01283 // 01284 01285 sourceExtension = SourceDevice->DeviceObjectExtension; 01286 01287 // 01288 // Get a pointer to the topmost device object in the stack of devices, 01289 // beginning with the TargetDevice, and attach to it. 01290 // 01291 01292 ExAcquireFastLock( &IopDatabaseLock, &irql ); 01293 01294 // 01295 // Tell the Special IRP code the stack has changed. Code that will reexamine 01296 // the stack takes the database lock, so we can place the call here. This 01297 // also allows us to assert correct behavoir *before* the stack is built up. 01298 // 01299 01300 IOV_ATTACH_DEVICE_TO_DEVICE_STACK(SourceDevice, TargetDevice); 01301 01302 deviceObject = IoGetAttachedDevice( TargetDevice ); 01303 01304 // 01305 // Make sure that the SourceDevice object isn't already attached to 01306 // something else, this is now illegal. 01307 // 01308 01309 ASSERT( sourceExtension->AttachedTo == NULL ); 01310 01311 // 01312 // Now attach to the device, provided that it is not being unloaded, 01313 // deleted or initializing. 01314 // 01315 01316 if (deviceObject->Flags & DO_DEVICE_INITIALIZING || 01317 deviceObject->DeviceObjectExtension->ExtensionFlags & 01318 (DOE_UNLOAD_PENDING | DOE_DELETE_PENDING | DOE_REMOVE_PENDING | DOE_REMOVE_PROCESSED)) { 01319 01320 // 01321 // The device currently at the top of the attachment chain is being 01322 // unloaded, deleted or initialized. 01323 // 01324 01325 deviceObject = (PDEVICE_OBJECT) NULL; 01326 01327 } else { 01328 01329 // 01330 // Perform the attachment. First update the device previously at the 01331 // top of the attachment chain. 01332 // 01333 deviceObject->AttachedDevice = SourceDevice; 01334 deviceObject->Spare1++; 01335 01336 // 01337 // Now update the new top-of-attachment-chain. 01338 // 01339 01340 SourceDevice->StackSize = (UCHAR) (deviceObject->StackSize + 1); 01341 SourceDevice->AlignmentRequirement = deviceObject->AlignmentRequirement; 01342 SourceDevice->SectorSize = deviceObject->SectorSize; 01343 01344 if (deviceObject->DeviceObjectExtension->ExtensionFlags & DOE_START_PENDING) { 01345 SourceDevice->DeviceObjectExtension->ExtensionFlags |= DOE_START_PENDING; 01346 } 01347 01348 // 01349 // Attachment chain is doubly-linked. 01350 // 01351 01352 sourceExtension->AttachedTo = deviceObject; 01353 } 01354 ExReleaseFastLock( &IopDatabaseLock, irql ); 01355 01356 return deviceObject; 01357 }

NTKERNELAPI PIRP IoBuildAsynchronousFsdRequest IN ULONG  MajorFunction,
IN PDEVICE_OBJECT  DeviceObject,
IN OUT PVOID Buffer  OPTIONAL,
IN ULONG Length  OPTIONAL,
IN PLARGE_INTEGER StartingOffset  OPTIONAL,
IN PIO_STATUS_BLOCK IoStatusBlock  OPTIONAL
 

Definition at line 1360 of file iosubs.c.

References _IRP::AssociatedIrp, Buffer, DO_BUFFERED_IO, DO_DIRECT_IO, ExAllocatePoolWithTag, EXCEPTION_EXECUTE_HANDLER, FALSE, _IRP::Flags, IoAllocateIrp(), IoAllocateMdl(), IoFreeIrp(), IoFreeMdl(), IoGetNextIrpStackLocation, IoReadAccess, IoWriteAccess, IRP_BUFFERED_IO, IRP_DEALLOCATE_BUFFER, IRP_INPUT_OPERATION, IRP_MJ_FLUSH_BUFFERS, IRP_MJ_PNP, IRP_MJ_POWER, IRP_MJ_READ, IRP_MJ_SHUTDOWN, IRP_MJ_WRITE, KernelMode, LOCK_OPERATION, _IO_STACK_LOCATION::MajorFunction, _IRP::MdlAddress, MmProbeAndLockPages(), NonPagedPoolCacheAligned, NULL, _IO_STACK_LOCATION::Parameters, PsGetCurrentThread, _IRP::Tail, _IRP::UserBuffer, and _IRP::UserIosb.

Referenced by IoBuildSynchronousFsdRequest(), and IovBuildAsynchronousFsdRequest().

01371 : 01372 01373 This routine builds an I/O Request Packet (IRP) suitable for a File System 01374 Driver (FSD) to use in requesting an I/O operation from a device driver. 01375 The request must be one of the following request codes: 01376 01377 IRP_MJ_READ 01378 IRP_MJ_WRITE 01379 IRP_MJ_FLUSH_BUFFERS 01380 IRP_MJ_SHUTDOWN 01381 IRP_MJ_POWER 01382 01383 This routine provides a simple, fast interface to the device driver w/o 01384 having to put the knowledge of how to build an IRP into all of the FSDs 01385 (and device drivers) in the system. 01386 01387 Arguments: 01388 01389 MajorFunction - Function to be performed; see previous list. 01390 01391 DeviceObject - Pointer to device object on which the I/O will be performed. 01392 01393 Buffer - Pointer to buffer to get data from or write data into. This 01394 parameter is required for read/write, but not for flush or shutdown 01395 functions. 01396 01397 Length - Length of buffer in bytes. This parameter is required for 01398 read/write, but not for flush or shutdown functions. 01399 01400 StartingOffset - Pointer to the offset on the disk to read/write from/to. 01401 This parameter is required for read/write, but not for flush or 01402 shutdown functions. 01403 01404 IoStatusBlock - Pointer to the I/O status block for completion status 01405 information. This parameter is optional since most asynchronous FSD 01406 requests will be synchronized by using completion routines, and so the 01407 I/O status block will not be written. 01408 01409 Return Value: 01410 01411 The function value is a pointer to the IRP representing the specified 01412 request. 01413 01414 --*/ 01415 01416 { 01417 PIRP irp; 01418 PIO_STACK_LOCATION irpSp; 01419 01420 // 01421 // Begin by allocating the IRP for this request. Do not charge quota to 01422 // the current process for this IRP. 01423 // 01424 01425 irp = IoAllocateIrp( DeviceObject->StackSize, FALSE ); 01426 if (!irp) { 01427 return irp; 01428 } 01429 01430 // 01431 // Set current thread for IoSetHardErrorOrVerifyDevice. 01432 // 01433 01434 irp->Tail.Overlay.Thread = PsGetCurrentThread(); 01435 01436 // 01437 // Get a pointer to the stack location of the first driver which will be 01438 // invoked. This is where the function codes and the parameters are set. 01439 // 01440 01441 irpSp = IoGetNextIrpStackLocation( irp ); 01442 01443 // 01444 // Set the major function code. 01445 // 01446 01447 irpSp->MajorFunction = (UCHAR) MajorFunction; 01448 01449 if (MajorFunction != IRP_MJ_FLUSH_BUFFERS && 01450 MajorFunction != IRP_MJ_SHUTDOWN && 01451 MajorFunction != IRP_MJ_PNP && 01452 MajorFunction != IRP_MJ_POWER) { 01453 01454 // 01455 // Now allocate a buffer or lock the pages of the caller's buffer into 01456 // memory based on whether the target device performs direct or buffered 01457 // I/O operations. 01458 // 01459 01460 if (DeviceObject->Flags & DO_BUFFERED_IO) { 01461 01462 // 01463 // The target device supports buffered I/O operations. Allocate a 01464 // system buffer and, if this is a write, fill it in. Otherwise, 01465 // the copy will be done into the caller's buffer in the completion 01466 // code. Also note that the system buffer should be deallocated on 01467 // completion. Also, set the parameters based on whether this is a 01468 // read or a write operation. 01469 // 01470 01471 irp->AssociatedIrp.SystemBuffer = ExAllocatePoolWithTag( NonPagedPoolCacheAligned, 01472 Length, 01473 ' oI' ); 01474 if (irp->AssociatedIrp.SystemBuffer == NULL) { 01475 IoFreeIrp( irp ); 01476 return (PIRP) NULL; 01477 } 01478 01479 if (MajorFunction == IRP_MJ_WRITE) { 01480 RtlCopyMemory( irp->AssociatedIrp.SystemBuffer, Buffer, Length ); 01481 irp->Flags = IRP_BUFFERED_IO | IRP_DEALLOCATE_BUFFER; 01482 } else { 01483 irp->Flags = IRP_BUFFERED_IO | IRP_DEALLOCATE_BUFFER | IRP_INPUT_OPERATION; 01484 irp->UserBuffer = Buffer; 01485 } 01486 01487 } else if (DeviceObject->Flags & DO_DIRECT_IO) { 01488 01489 // 01490 // The target device supports direct I/O operations. Allocate 01491 // an MDL large enough to map the buffer and lock the pages into 01492 // memory. 01493 // 01494 01495 irp->MdlAddress = IoAllocateMdl( Buffer, 01496 Length, 01497 FALSE, 01498 FALSE, 01499 (PIRP) NULL ); 01500 if (irp->MdlAddress == NULL) { 01501 IoFreeIrp( irp ); 01502 return (PIRP) NULL; 01503 } 01504 01505 try { 01506 MmProbeAndLockPages( irp->MdlAddress, 01507 KernelMode, 01508 (LOCK_OPERATION) (MajorFunction == IRP_MJ_READ ? IoWriteAccess : IoReadAccess) ); 01509 } except(EXCEPTION_EXECUTE_HANDLER) { 01510 if (irp->MdlAddress != NULL) { 01511 IoFreeMdl( irp->MdlAddress ); 01512 } 01513 IoFreeIrp( irp ); 01514 return (PIRP) NULL; 01515 } 01516 01517 } else { 01518 01519 // 01520 // The operation is neither buffered nor direct. Simply pass the 01521 // address of the buffer in the packet to the driver. 01522 // 01523 01524 irp->UserBuffer = Buffer; 01525 } 01526 01527 // 01528 // Set the parameters according to whether this is a read or a write 01529 // operation. Notice that these parameters must be set even if the 01530 // driver has not specified buffered or direct I/O. 01531 // 01532 01533 if (MajorFunction == IRP_MJ_WRITE) { 01534 irpSp->Parameters.Write.Length = Length; 01535 irpSp->Parameters.Write.ByteOffset = *StartingOffset; 01536 } else { 01537 irpSp->Parameters.Read.Length = Length; 01538 irpSp->Parameters.Read.ByteOffset = *StartingOffset; 01539 } 01540 } 01541 01542 // 01543 // Finally, set the address of the I/O status block and return a pointer 01544 // to the IRP. 01545 // 01546 01547 irp->UserIosb = IoStatusBlock; 01548 return irp; 01549 }

NTKERNELAPI PIRP IoBuildDeviceIoControlRequest IN ULONG  IoControlCode,
IN PDEVICE_OBJECT  DeviceObject,
IN PVOID InputBuffer  OPTIONAL,
IN ULONG  InputBufferLength,
OUT PVOID OutputBuffer  OPTIONAL,
IN ULONG  OutputBufferLength,
IN BOOLEAN  InternalDeviceIoControl,
IN PKEVENT  Event,
OUT PIO_STATUS_BLOCK  IoStatusBlock
 

Definition at line 1552 of file iosubs.c.

References _IRP::AssociatedIrp, Event(), ExAllocatePoolWithTag, EXCEPTION_EXECUTE_HANDLER, ExFreePool(), FALSE, _IRP::Flags, IoAllocateIrp(), IoAllocateMdl(), IoFreeIrp(), IoFreeMdl(), IoGetNextIrpStackLocation, IopQueueThreadIrp, IoReadAccess, IoWriteAccess, IRP_BUFFERED_IO, IRP_DEALLOCATE_BUFFER, IRP_INPUT_OPERATION, IRP_MJ_DEVICE_CONTROL, IRP_MJ_INTERNAL_DEVICE_CONTROL, KernelMode, LOCK_OPERATION, _IO_STACK_LOCATION::MajorFunction, _IRP::MdlAddress, MmProbeAndLockPages(), NonPagedPoolCacheAligned, NULL, _IO_STACK_LOCATION::Parameters, PsGetCurrentThread, _IRP::Tail, _IRP::UserBuffer, _IRP::UserEvent, and _IRP::UserIosb.

Referenced by FsRecGetDeviceSectors(), FsRecGetDeviceSectorSize(), FsRtlBalanceReads(), FsRtlSyncVolumes(), GetDeviceChangeInfo(), HalpEnableAutomaticDriveLetterAssignment(), HalpGetFullGeometry(), HalpIsOldStyleFloppy(), HalpNextMountLetter(), HalpQueryDriveLayout(), HalpQueryPartitionType(), HalpSetMountLetter(), IoFreeDumpStack(), IoGetBootDiskInformation(), IopCreateArcNames(), IopGetDumpStack(), IopGetSetObjectId(), IopGetVolumeId(), IopInvalidateVolumesForDevice(), IopLoadFileSystemDriver(), IopSetRemoteLink(), IovBuildDeviceIoControlRequest(), RtlVolumeDeviceToDosName(), UdfPerformDevIoCtrl(), and xHalGetPartialGeometry().

01566 : 01567 01568 This routine builds an I/O Request Packet (IRP) that can be used to 01569 perform a synchronous internal or normal device I/O control function. 01570 01571 Arguments: 01572 01573 IoControlCode - Specifies the device I/O control code that is to be 01574 performed by the target device driver. 01575 01576 DeviceObject - Specifies the target device on which the I/O control 01577 function is to be performed. 01578 01579 InputBuffer - Optional pointer to an input buffer that is to be passed 01580 to the device driver. 01581 01582 InputBufferLength - Length of the InputBuffer in bytes. If the Input- 01583 Buffer parameter is not passed, this parameter must be zero. 01584 01585 OutputBuffer - Optional pointer to an output buffer that is to be passed 01586 to the device driver. 01587 01588 OutputBufferLength - Length of the OutputBuffer in bytes. If the 01589 OutputBuffer parameter is not passed, this parameter must be zero. 01590 01591 InternalDeviceIoControl - A BOOLEAN parameter that specifies whether 01592 the packet that gets generated should have a major function code 01593 of IRP_MJ_INTERNAL_DEVICE_CONTROL (the parameter is TRUE), or 01594 IRP_MJ_DEVICE_CONTROL (the parameter is FALSE). 01595 01596 Event - Supplies a pointer to a kernel event that is to be set to the 01597 Signaled state when the I/O operation is complete. Note that the 01598 Event must already be set to the Not-Signaled state. 01599 01600 IoStatusBlock - Supplies a pointer to an I/O status block that is to 01601 be filled in with the final status of the operation once it 01602 completes. 01603 01604 Return Value: 01605 01606 The function value is a pointer to the generated IRP suitable for calling 01607 the target device driver. 01608 01609 --*/ 01610 01611 { 01612 PIRP irp; 01613 PIO_STACK_LOCATION irpSp; 01614 ULONG method; 01615 01616 // 01617 // Begin by allocating the IRP for this request. Do not charge quota to 01618 // the current process for this IRP. 01619 // 01620 01621 irp = IoAllocateIrp( DeviceObject->StackSize, FALSE ); 01622 if (!irp) { 01623 return irp; 01624 } 01625 01626 // 01627 // Get a pointer to the stack location of the first driver which will be 01628 // invoked. This is where the function codes and the parameters are set. 01629 // 01630 01631 irpSp = IoGetNextIrpStackLocation( irp ); 01632 01633 // 01634 // Set the major function code based on the type of device I/O control 01635 // function the caller has specified. 01636 // 01637 01638 if (InternalDeviceIoControl) { 01639 irpSp->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL; 01640 } else { 01641 irpSp->MajorFunction = IRP_MJ_DEVICE_CONTROL; 01642 } 01643 01644 // 01645 // Copy the caller's parameters to the service-specific portion of the 01646 // IRP for those parameters that are the same for all four methods. 01647 // 01648 01649 irpSp->Parameters.DeviceIoControl.OutputBufferLength = OutputBufferLength; 01650 irpSp->Parameters.DeviceIoControl.InputBufferLength = InputBufferLength; 01651 irpSp->Parameters.DeviceIoControl.IoControlCode = IoControlCode; 01652 01653 // 01654 // Get the method bits from the I/O control code to determine how the 01655 // buffers are to be passed to the driver. 01656 // 01657 01658 method = IoControlCode & 3; 01659 01660 // 01661 // Based on the method that the buffers are being passed, either allocate 01662 // buffers or build MDLs or do nothing. 01663 // 01664 01665 switch ( method ) { 01666 01667 case 0: 01668 01669 // 01670 // For this case, allocate a buffer that is large enough to contain 01671 // both the input and the output buffers. Copy the input buffer 01672 // to the allocated buffer and set the appropriate IRP fields. 01673 // 01674 01675 if (InputBufferLength != 0 || OutputBufferLength != 0) { 01676 irp->AssociatedIrp.SystemBuffer = ExAllocatePoolWithTag( NonPagedPoolCacheAligned, 01677 InputBufferLength > OutputBufferLength ? InputBufferLength : OutputBufferLength, 01678 ' oI' ); 01679 if (irp->AssociatedIrp.SystemBuffer == NULL) { 01680 IoFreeIrp( irp ); 01681 return (PIRP) NULL; 01682 } 01683 if (ARGUMENT_PRESENT( InputBuffer )) { 01684 RtlCopyMemory( irp->AssociatedIrp.SystemBuffer, 01685 InputBuffer, 01686 InputBufferLength ); 01687 } 01688 irp->Flags = IRP_BUFFERED_IO | IRP_DEALLOCATE_BUFFER; 01689 irp->UserBuffer = OutputBuffer; 01690 if (ARGUMENT_PRESENT( OutputBuffer )) { 01691 irp->Flags |= IRP_INPUT_OPERATION; 01692 } 01693 } else { 01694 irp->Flags = 0; 01695 irp->UserBuffer = (PVOID) NULL; 01696 } 01697 01698 break; 01699 01700 case 1: 01701 case 2: 01702 01703 // 01704 // For these two cases, allocate a buffer that is large enough to 01705 // contain the input buffer, if any, and copy the information to 01706 // the allocated buffer. Then build an MDL for either read or write 01707 // access, depending on the method, for the output buffer. Note 01708 // that an output buffer must have been specified. 01709 // 01710 01711 if (ARGUMENT_PRESENT( InputBuffer )) { 01712 irp->AssociatedIrp.SystemBuffer = ExAllocatePoolWithTag( NonPagedPoolCacheAligned, 01713 InputBufferLength, 01714 ' oI' ); 01715 if (irp->AssociatedIrp.SystemBuffer == NULL) { 01716 IoFreeIrp( irp ); 01717 return (PIRP) NULL; 01718 } 01719 RtlCopyMemory( irp->AssociatedIrp.SystemBuffer, 01720 InputBuffer, 01721 InputBufferLength ); 01722 irp->Flags = IRP_BUFFERED_IO | IRP_DEALLOCATE_BUFFER; 01723 } else { 01724 irp->Flags = 0; 01725 } 01726 01727 if (ARGUMENT_PRESENT( OutputBuffer )) { 01728 irp->MdlAddress = IoAllocateMdl( OutputBuffer, 01729 OutputBufferLength, 01730 FALSE, 01731 FALSE, 01732 (PIRP) NULL ); 01733 if (irp->MdlAddress == NULL) { 01734 if (ARGUMENT_PRESENT( InputBuffer )) { 01735 ExFreePool( irp->AssociatedIrp.SystemBuffer ); 01736 } 01737 IoFreeIrp( irp ); 01738 return (PIRP) NULL; 01739 } 01740 01741 try { 01742 01743 MmProbeAndLockPages( irp->MdlAddress, 01744 KernelMode, 01745 (LOCK_OPERATION) ((method == 1) ? IoReadAccess : IoWriteAccess) ); 01746 01747 } except (EXCEPTION_EXECUTE_HANDLER) { 01748 01749 if (irp->MdlAddress != NULL) { 01750 IoFreeMdl( irp->MdlAddress ); 01751 } 01752 01753 if (ARGUMENT_PRESENT( InputBuffer )) { 01754 ExFreePool( irp->AssociatedIrp.SystemBuffer ); 01755 } 01756 01757 IoFreeIrp( irp ); 01758 return (PIRP) NULL; 01759 } 01760 } 01761 01762 break; 01763 01764 case 3: 01765 01766 // 01767 // For this case, do nothing. Everything is up to the driver. 01768 // Simply give the driver a copy of the caller's parameters and 01769 // let the driver do everything itself. 01770 // 01771 01772 irp->UserBuffer = OutputBuffer; 01773 irpSp->Parameters.DeviceIoControl.Type3InputBuffer = InputBuffer; 01774 } 01775 01776 // 01777 // Finally, set the address of the I/O status block and the address of 01778 // the kernel event object. Note that I/O completion will not attempt 01779 // to dereference the event since there is no file object associated 01780 // with this operation. 01781 // 01782 01783 irp->UserIosb = IoStatusBlock; 01784 irp->UserEvent = Event; 01785 01786 // 01787 // Also set the address of the current thread in the packet so the 01788 // completion code will have a context to execute in. The IRP also 01789 // needs to be queued to the thread since the caller is going to set 01790 // the file object pointer. 01791 // 01792 01793 irp->Tail.Overlay.Thread = PsGetCurrentThread(); 01794 IopQueueThreadIrp( irp ); 01795 01796 // 01797 // Simply return a pointer to the packet. 01798 // 01799 01800 return irp; 01801 }

NTKERNELAPI VOID IoBuildPartialMdl IN PMDL  SourceMdl,
IN OUT PMDL  TargetMdl,
IN PVOID  VirtualAddress,
IN ULONG  Length
 

Definition at line 1804 of file iosubs.c.

References BYTE_OFFSET, COMPUTE_PAGES_SPANNED, KeBugCheck(), MDL_ALLOCATED_FIXED_SIZE, MDL_ALLOCATED_MUST_SUCCEED, MDL_IO_PAGE_READ, MDL_MAPPED_TO_SYSTEM_VA, MDL_PARENT_MAPPED_SYSTEM_VA, MDL_PARTIAL, MDL_SOURCE_IS_NONPAGED_POOL, MmGetMdlBaseVa, MmGetMdlByteCount, MmGetMdlByteOffset, MmGetMdlPfnArray, PAGE_ALIGN, and PAGE_SHIFT.

Referenced by UdfMultipleAsync().

01813 : 01814 01815 This routine maps a portion of a buffer as described by an MDL. The 01816 portion of the buffer to be mapped is specified via a virtual address 01817 and an optional length. If the length is not supplied, then the 01818 remainder of the buffer is mapped. 01819 01820 Arguments: 01821 01822 SourceMdl - MDL for the current buffer. 01823 01824 TargetMdl - MDL to map the specified portion of the buffer. 01825 01826 VirtualAddress - Base of the buffer to begin mapping. 01827 01828 Length - Length of buffer to be mapped; if zero, remainder. 01829 01830 Return Value: 01831 01832 None. 01833 01834 Notes: 01835 01836 This routine assumes that the target MDL is large enough to map the 01837 desired portion of the buffer. If the target is not large enough 01838 then an exception will be raised. 01839 01840 It is also assumed that the remaining length of the buffer to be mapped 01841 is non-zero. 01842 01843 --*/ 01844 01845 { 01846 ULONG_PTR baseVa; 01847 ULONG offset; 01848 ULONG newLength; 01849 ULONG pageOffset; 01850 PPFN_NUMBER basePointer; 01851 PPFN_NUMBER copyPointer; 01852 01853 // 01854 // Calculate the base address of the buffer that the source Mdl maps. 01855 // Then, determine the length of the buffer to be mapped, if not 01856 // specified. 01857 // 01858 01859 baseVa = (ULONG_PTR) MmGetMdlBaseVa( SourceMdl ); 01860 offset = (ULONG) ((ULONG_PTR)VirtualAddress - baseVa) - MmGetMdlByteOffset(SourceMdl); 01861 01862 if (Length == 0) { 01863 newLength = MmGetMdlByteCount( SourceMdl ) - offset; 01864 } else { 01865 newLength = Length; 01866 //if (newLength > (MmGetMdlByteCount(SourceMdl) - offset)) { 01867 // KeBugCheck( TARGET_MDL_TOO_SMALL ); 01868 //} 01869 } 01870 01871 // 01872 // Initialize the target MDL header. Note that the original size of 01873 // the MDL structure itself is left unchanged. 01874 // 01875 01876 //ASSERT ((SourceMdl->MdlFlags & MDL_PARTIAL) == 0); 01877 TargetMdl->Process = SourceMdl->Process; 01878 01879 TargetMdl->StartVa = (PVOID) PAGE_ALIGN( VirtualAddress ); 01880 pageOffset = ((ULONG)((ULONG_PTR) TargetMdl->StartVa - (ULONG_PTR) SourceMdl->StartVa)) >> PAGE_SHIFT; 01881 01882 01883 TargetMdl->ByteCount = newLength; 01884 TargetMdl->ByteOffset = BYTE_OFFSET( VirtualAddress ); 01885 newLength = COMPUTE_PAGES_SPANNED( VirtualAddress, newLength ); 01886 if (((TargetMdl->Size - sizeof( MDL )) / sizeof (PFN_NUMBER)) < newLength ) { 01887 KeBugCheck( TARGET_MDL_TOO_SMALL ); 01888 } 01889 01890 // 01891 // Set the MdlFlags in the target MDL. Clear all flags but 01892 // carry across the allocation information, page read and the 01893 // system mapped info. 01894 // 01895 01896 TargetMdl->MdlFlags &= (MDL_ALLOCATED_FIXED_SIZE | MDL_ALLOCATED_MUST_SUCCEED); 01897 TargetMdl->MdlFlags |= SourceMdl->MdlFlags & (MDL_SOURCE_IS_NONPAGED_POOL | 01898 MDL_MAPPED_TO_SYSTEM_VA | 01899 MDL_IO_PAGE_READ); 01900 TargetMdl->MdlFlags |= MDL_PARTIAL; 01901 01902 #if DBG 01903 if (TargetMdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA) { 01904 TargetMdl->MdlFlags |= MDL_PARENT_MAPPED_SYSTEM_VA; 01905 } 01906 #endif //DBG 01907 01908 // 01909 // Preserved the mapped system address. 01910 // 01911 01912 TargetMdl->MappedSystemVa = (PUCHAR)SourceMdl->MappedSystemVa + offset; 01913 01914 // 01915 // Determine the base address of the first PFN in the source MDL that 01916 // needs to be copied to the target. Then, copy as many PFNs as are 01917 // needed. 01918 // 01919 01920 basePointer = MmGetMdlPfnArray(SourceMdl); 01921 basePointer += pageOffset; 01922 copyPointer = MmGetMdlPfnArray(TargetMdl); 01923 01924 while (newLength > 0) { 01925 *copyPointer = *basePointer; 01926 copyPointer++; 01927 basePointer++; 01928 newLength--; 01929 } 01930 }

NTSTATUS IoBuildPoDeviceNotifyList IN OUT PVOID  Order  ) 
 

NTKERNELAPI PIRP IoBuildSynchronousFsdRequest IN ULONG  MajorFunction,
IN PDEVICE_OBJECT  DeviceObject,
IN OUT PVOID Buffer  OPTIONAL,
IN ULONG Length  OPTIONAL,
IN PLARGE_INTEGER StartingOffset  OPTIONAL,
IN PKEVENT  Event,
OUT PIO_STATUS_BLOCK  IoStatusBlock
 

Definition at line 1933 of file iosubs.c.

References Buffer, Event(), IoBuildAsynchronousFsdRequest(), IopQueueThreadIrp, NULL, and _IRP::UserEvent.

Referenced by FsRecReadBlock(), IoGetDmaAdapter(), IopCreateArcNames(), IoShutdownSystem(), UdfReadSectors(), xHalExamineMBR(), xHalIoClearPartitionTable(), xHalIoReadPartitionTable(), xHalIoSetPartitionInformation(), and xHalIoWritePartitionTable().

01945 : 01946 01947 This routine builds an I/O Request Packet (IRP) suitable for a File System 01948 Driver (FSD) to use in requesting an I/O operation from a device driver. 01949 The request must be one of the following request codes: 01950 01951 IRP_MJ_READ 01952 IRP_MJ_WRITE 01953 IRP_MJ_FLUSH_BUFFERS 01954 IRP_MJ_SHUTDOWN 01955 01956 This routine provides a simple, fast interface to the device driver w/o 01957 having to put the knowledge of how to build an IRP into all of the FSDs 01958 (and device drivers) in the system. 01959 01960 The IRP created by this function causes the I/O system to complete the 01961 request by setting the specified event to the Signaled state. 01962 01963 Arguments: 01964 01965 MajorFunction - Function to be performed; see previous list. 01966 01967 DeviceObject - Pointer to device object on which the I/O will be performed. 01968 01969 Buffer - Pointer to buffer to get data from or write data into. This 01970 parameter is required for read/write, but not for flush or shutdown 01971 functions. 01972 01973 Length - Length of buffer in bytes. This parameter is required for 01974 read/write, but not for flush or shutdown functions. 01975 01976 StartingOffset - Pointer to the offset on the disk to read/write from/to. 01977 This parameter is required for read/write, but not for flush or 01978 shutdown functions. 01979 01980 Event - Pointer to a kernel event structure for synchronization. The event 01981 will be set to the Signaled state when the I/O has completed. 01982 01983 IoStatusBlock - Pointer to I/O status block for completion status info. 01984 01985 Return Value: 01986 01987 The function value is a pointer to the IRP representing the specified 01988 request. 01989 01990 --*/ 01991 01992 { 01993 PIRP irp; 01994 01995 // 01996 // Do all of the real work in real IRP build routine. 01997 // 01998 01999 irp = IoBuildAsynchronousFsdRequest( MajorFunction, 02000 DeviceObject, 02001 Buffer, 02002 Length, 02003 StartingOffset, 02004 IoStatusBlock ); 02005 if (irp == NULL) { 02006 return irp; 02007 } 02008 02009 // 02010 // Now fill in the event to the completion code will do the right thing. 02011 // Notice that because there is no FileObject, the I/O completion code 02012 // will not attempt to dereference the event. 02013 // 02014 02015 irp->UserEvent = Event; 02016 02017 // 02018 // There will be a file object associated w/this packet, so it must be 02019 // queued to the thread. 02020 // 02021 02022 IopQueueThreadIrp( irp ); 02023 return irp; 02024 }

NTKERNELAPI VOID IoCancelFileOpen IN PDEVICE_OBJECT  DeviceObject,
IN PFILE_OBJECT  FileObject
 

Definition at line 12535 of file iosubs.c.

References APC_LEVEL, ASSERT, _IRP::AssociatedIrp, Executive, ExInterlockedAddUlong(), FALSE, _IO_STACK_LOCATION::FileObject, _IRP::Flags, FO_DIRECT_DEVICE_OPEN, FO_FILE_OPEN_CANCELLED, FO_HANDLE_CREATED, IoCallDriver, IoFreeIrp(), IoGetNextIrpStackLocation, IopAllocateIrpMustSucceed(), IopDequeueThreadIrp, IopQueueThreadIrp, IopVpbSpinLock, IoReuseIrp(), _IRP::IoStatus, IRP_CLOSE_OPERATION, IRP_MJ_CLEANUP, IRP_MJ_CLOSE, IRP_SYNCHRONOUS_API, KeClearEvent, KeInitializeEvent, KeLowerIrql(), KeRaiseIrql(), KernelMode, KeWaitForSingleObject(), _IO_STACK_LOCATION::MajorFunction, NTSTATUS(), NULL, _IRP::Overlay, PsGetCurrentThread, _VPB::ReferenceCount, _IRP::RequestorMode, _IRP::Tail, _IRP::UserEvent, _IRP::UserIosb, UserRequest, and VOID().

12541 : 12542 12543 This routine is invoked by a filter driver to send a close to the 12544 next filesystem driver below. It's needed as part of the file open 12545 process. The filter driver forwards the open to the FSD and the FSD 12546 returns success. The filter driver then examines some stuff and 12547 decides that the open has to be failed. In this case it has to send 12548 a close to the FSD. 12549 12550 We can safely assume a thread context because it has to be called only 12551 in the context of file open. If the file object already has a handle 12552 then the owner of the handle can then simply close the handle to the 12553 file object and we will close the file. 12554 12555 This code is extracted from IopCloseFile and IopDeleteFile. So it is 12556 duplication of code but it prevents duplication elsewhere in other FSDs. 12557 12558 Arguments: 12559 12560 FileObject - Points to the file that needs to be closed. 12561 12562 DeviceObject - Points to the device object of the filesystem driver below 12563 the filter driver. 12564 12565 Return Value: 12566 12567 None 12568 12569 --*/ 12570 12571 { 12572 PIRP irp; 12573 PIO_STACK_LOCATION irpSp; 12574 PFAST_IO_DISPATCH fastIoDispatch; 12575 NTSTATUS status; 12576 KEVENT event; 12577 KIRQL irql; 12578 IO_STATUS_BLOCK ioStatusBlock; 12579 PVPB vpb; 12580 BOOLEAN referenceCountDecremented; 12581 12582 12583 // 12584 // Cannot call this function if a handle has already been created 12585 // for this file. 12586 // 12587 ASSERT(!(FileObject->Flags & FO_HANDLE_CREATED)); 12588 12589 // 12590 // Initialize the local event that will be used to synchronize access 12591 // to the driver completing this I/O operation. 12592 // 12593 12594 KeInitializeEvent( &event, SynchronizationEvent, FALSE ); 12595 12596 // 12597 // Reset the event in the file object. 12598 // 12599 12600 KeClearEvent( &FileObject->Event ); 12601 12602 // 12603 // Allocate and initialize the I/O Request Packet (IRP) for this 12604 // operation. 12605 // 12606 12607 irp = IopAllocateIrpMustSucceed( DeviceObject->StackSize ); 12608 irp->Tail.Overlay.OriginalFileObject = FileObject; 12609 irp->Tail.Overlay.Thread = PsGetCurrentThread(); 12610 irp->RequestorMode = KernelMode; 12611 12612 // 12613 // Fill in the service independent parameters in the IRP. 12614 // 12615 12616 irp->UserEvent = &event; 12617 irp->UserIosb = &irp->IoStatus; 12618 irp->Overlay.AsynchronousParameters.UserApcRoutine = (PIO_APC_ROUTINE) NULL; 12619 irp->Flags = IRP_SYNCHRONOUS_API | IRP_CLOSE_OPERATION; 12620 12621 // 12622 // Get a pointer to the stack location for the first driver. This will 12623 // be used to pass the original function codes and parameters. No 12624 // function-specific parameters are required for this operation. 12625 // 12626 12627 irpSp = IoGetNextIrpStackLocation( irp ); 12628 irpSp->MajorFunction = IRP_MJ_CLEANUP; 12629 irpSp->FileObject = FileObject; 12630 12631 // 12632 // Insert the packet at the head of the IRP list for the thread. 12633 // 12634 12635 IopQueueThreadIrp( irp ); 12636 12637 // 12638 // Invoke the driver at its appropriate dispatch entry with the IRP. 12639 // 12640 12641 status = IoCallDriver( DeviceObject, irp ); 12642 12643 // 12644 // If no error was incurred, wait for the I/O operation to complete. 12645 // 12646 12647 if (status == STATUS_PENDING) { 12648 (VOID) KeWaitForSingleObject( &event, 12649 UserRequest, 12650 KernelMode, 12651 FALSE, 12652 (PLARGE_INTEGER) NULL ); 12653 } 12654 12655 // 12656 // The following code tears down the IRP by hand since it may not 12657 // be possible for it to be completed (either because this code was 12658 // invoked as APC_LEVEL in the first place - or because the reference 12659 // count on the object cannot be incremented due to this routine 12660 // being invoked by the delete file procedure below). Cleanup IRPs 12661 // therefore use close semantics (the close operation flag is set 12662 // in the IRP) so that the I/O complete request routine itself sets 12663 // the event to the Signaled state. 12664 // 12665 12666 KeRaiseIrql( APC_LEVEL, &irql ); 12667 IopDequeueThreadIrp( irp ); 12668 KeLowerIrql( irql ); 12669 12670 // 12671 // Reuse the IRP for the next operation. 12672 // 12673 12674 IoReuseIrp( irp , STATUS_SUCCESS); 12675 12676 // 12677 // Reset the event in the file object. 12678 // 12679 12680 KeClearEvent( &FileObject->Event ); 12681 KeClearEvent(&event); 12682 12683 // 12684 // Get a pointer to the stack location for the first driver. This is 12685 // where the function codes and parameters are placed. 12686 // 12687 12688 irpSp = IoGetNextIrpStackLocation( irp ); 12689 12690 // 12691 // Fill in the IRP, indicating that this file object is being deleted. 12692 // 12693 12694 irpSp->MajorFunction = IRP_MJ_CLOSE; 12695 irpSp->FileObject = FileObject; 12696 irp->UserIosb = &ioStatusBlock; 12697 irp->UserEvent = &event; 12698 irp->Tail.Overlay.OriginalFileObject = FileObject; 12699 irp->Tail.Overlay.Thread = PsGetCurrentThread(); 12700 irp->AssociatedIrp.SystemBuffer = (PVOID) NULL; 12701 irp->Flags = IRP_CLOSE_OPERATION | IRP_SYNCHRONOUS_API; 12702 12703 // 12704 // Place this packet in the thread's I/O pending queue. 12705 // 12706 12707 IopQueueThreadIrp( irp ); 12708 12709 // 12710 // Decrement the reference count on the VPB, if necessary. We 12711 // have to do this BEFORE handing the Irp to the file system 12712 // because of a trick the file systems play with close, and 12713 // believe me, you really don't want to know what it is. 12714 // 12715 // Since there is not a error path here (close cannot fail), 12716 // and the file system is the only ome who can actually synchronize 12717 // with the actual completion of close processing, the file system 12718 // is the one responsible for Vpb deletion. 12719 // 12720 12721 vpb = FileObject->Vpb; 12722 12723 if (vpb && !(FileObject->Flags & FO_DIRECT_DEVICE_OPEN)) { 12724 ExInterlockedAddUlong( &vpb->ReferenceCount, 12725 0xffffffff, 12726 &IopVpbSpinLock ); 12727 FileObject->Flags |= FO_FILE_OPEN_CANCELLED; 12728 } 12729 12730 // 12731 // Give the device driver the packet. If this request does not work, 12732 // there is nothing that can be done about it. This is unfortunate 12733 // because the driver may have had problems that it was about to 12734 // report about other operations (e.g., write behind failures, etc.) 12735 // that it can no longer report. The reason is that this routine 12736 // is really initially invoked by NtClose, which has already closed 12737 // the caller's handle, and that's what the return status from close 12738 // indicates: the handle has successfully been closed. 12739 // 12740 12741 status = IoCallDriver( DeviceObject, irp ); 12742 12743 if (status == STATUS_PENDING) { 12744 (VOID) KeWaitForSingleObject( &event, 12745 Executive, 12746 KernelMode, 12747 FALSE, 12748 (PLARGE_INTEGER) NULL ); 12749 } 12750 12751 // 12752 // Perform any completion operations that need to be performed on 12753 // the IRP that was used for this request. This is done here as 12754 // as opposed to in normal completion code because there is a race 12755 // condition between when this routine executes if it was invoked 12756 // from a special kernel APC (e.g., some IRP was just completed and 12757 // dereferenced this file object for the last time), and when the 12758 // special kernel APC because of this packet's completion executing. 12759 // 12760 // This problem is solved by not having to queue a special kernel 12761 // APC routine for completion of this packet. Rather, it is treated 12762 // much like a synchronous paging I/O operation, except that the 12763 // packet is not even freed during I/O completion. This is because 12764 // the packet is still in this thread's queue, and there is no way 12765 // to get it out except at APC_LEVEL. Unfortunately, the part of 12766 // I/O completion that needs to dequeue the packet is running at 12767 // DISPATCH_LEVEL. 12768 // 12769 // Hence, the packet must be removed from the queue (synchronized, 12770 // of course), and then it must be freed. 12771 // 12772 12773 KeRaiseIrql( APC_LEVEL, &irql ); 12774 IopDequeueThreadIrp( irp ); 12775 KeLowerIrql( irql ); 12776 12777 IoFreeIrp( irp ); 12778 12779 }

NTKERNELAPI BOOLEAN IoCancelIrp IN PIRP  Irp  ) 
 

Definition at line 2149 of file iosubs.c.

References ASSERT, _IRP::Cancel, _IRP::CancelIrql, _IRP::CancelRoutine, _IRP::CurrentLocation, FALSE, IO_TYPE_IRP, IoAcquireCancelSpinLock(), IopVerifierOn, IoReleaseCancelSpinLock(), IOV_CANCEL_IRP, Irp, KeBugCheckEx(), NULL, PDRIVER_CANCEL, _IRP::StackCount, _IRP::Tail, TRUE, and _IRP::Type.

Referenced by IoCancelThreadIo(), IopCancelAlertedRequest(), IopProcessRelation(), IovpCancelIrp(), and NtCancelIoFile().

02155 : 02156 02157 This routine is invoked to cancel an individual I/O Request Packet. 02158 It acquires the cancel spin lock, sets the cancel flag in the IRP, and 02159 then invokes the cancel routine specified by the appropriate field in 02160 the IRP, if a routine was specified. It is expected that the cancel 02161 routine will relaease the cancel spinlock. If there is no cancel routine, 02162 then the cancel spin lock is released. 02163 02164 Arguments: 02165 02166 Irp - Supplies a pointer to the IRP to be cancelled. 02167 02168 Return Value: 02169 02170 The function value is TRUE if the IRP was in a cancelable state (it 02171 had a cancel routine), else FALSE is returned. 02172 02173 Notes: 02174 02175 It is assumed that the caller has taken the necessary action to ensure 02176 that the packet cannot be fully completed before invoking this routine. 02177 02178 --*/ 02179 02180 { 02181 PDRIVER_CANCEL cancelRoutine; 02182 KIRQL irql; 02183 BOOLEAN returnValue; 02184 02185 02186 ASSERT( Irp->Type == IO_TYPE_IRP ); 02187 02188 if (IopVerifierOn) { 02189 if (IOV_CANCEL_IRP(Irp, &returnValue)) { 02190 return returnValue; 02191 } 02192 } 02193 02194 // 02195 // Acquire the cancel spin lock. 02196 // 02197 02198 IoAcquireCancelSpinLock( &irql ); 02199 02200 // 02201 // Set the cancel flag in the IRP. 02202 // 02203 02204 Irp->Cancel = TRUE; 02205 02206 // 02207 // Obtain the address of the cancel routine, and if one was specified, 02208 // invoke it. 02209 // 02210 02211 cancelRoutine = (PDRIVER_CANCEL) InterlockedExchangePointer( (PVOID *) &Irp->CancelRoutine, 02212 NULL ); 02213 02214 if (cancelRoutine) { 02215 if (Irp->CurrentLocation > (CCHAR) (Irp->StackCount + 1)) { 02216 KeBugCheckEx( CANCEL_STATE_IN_COMPLETED_IRP, (ULONG_PTR) Irp, 0, 0, 0 ); 02217 } 02218 Irp->CancelIrql = irql; 02219 02220 cancelRoutine( Irp->Tail.Overlay.CurrentStackLocation->DeviceObject, 02221 Irp ); 02222 // 02223 // The cancel spinlock should have been released by the cancel routine. 02224 // 02225 02226 return(TRUE); 02227 02228 } else { 02229 02230 // 02231 // There was no cancel routine, so release the cancel spinlock and 02232 // return indicating the Irp was not currently cancelable. 02233 // 02234 02235 IoReleaseCancelSpinLock( irql ); 02236 02237 return(FALSE); 02238 } 02239 }

NTKERNELAPI VOID IoCancelThreadIo IN PETHREAD  Thread  ) 
 

Definition at line 2242 of file iosubs.c.

References APC_LEVEL, FALSE, IoCancelIrp(), IopDisassociateThreadIrp(), _ETHREAD::IrpList, KeDelayExecutionThread(), KeLowerIrql(), KeRaiseIrql(), KernelMode, PAGED_CODE, and PsGetCurrentThread.

Referenced by PspExitThread().

02248 : 02249 02250 This routine cancels all of the I/O operations for the specified thread. 02251 This is accomplished by walking the list of IRPs in the thread IRP list 02252 and canceling each one individually. No other I/O operations can be 02253 started for the thread since this routine has control of the thread itself. 02254 02255 Arguments: 02256 02257 Tcb - Pointer to the Thread Control Block for the thread. 02258 02259 Return Value: 02260 02261 None. 02262 02263 --*/ 02264 02265 { 02266 PLIST_ENTRY header; 02267 PLIST_ENTRY entry; 02268 KIRQL irql; 02269 PETHREAD thread; 02270 PIRP irp; 02271 ULONG count; 02272 LARGE_INTEGER interval; 02273 02274 PAGED_CODE(); 02275 02276 DBG_UNREFERENCED_PARAMETER( Thread ); 02277 02278 thread = PsGetCurrentThread(); 02279 02280 // 02281 // Raise the IRQL so that the IrpList cannot be modified by a completion 02282 // APC. 02283 // 02284 02285 KeRaiseIrql( APC_LEVEL, &irql ); 02286 02287 header = &thread->IrpList; 02288 entry = thread->IrpList.Flink; 02289 02290 // 02291 // Walk the list of pending IRPs, canceling each of them. 02292 // 02293 02294 while (header != entry) { 02295 irp = CONTAINING_RECORD( entry, IRP, ThreadListEntry ); 02296 IoCancelIrp( irp ); 02297 entry = entry->Flink; 02298 } 02299 02300 // 02301 // Wait for the requests to complete. Note that waiting may eventually 02302 // timeout, in which case more work must be done. 02303 // 02304 02305 count = 0; 02306 interval.QuadPart = -10 * 1000 * 100; 02307 02308 while (!IsListEmpty( &Thread->IrpList )) { 02309 02310 // 02311 // Lower the IRQL so that the thread APC can fire which will complete 02312 // the requests. Delay execution for a time and let the request 02313 // finish. The delay time is 100ms. 02314 // 02315 02316 KeLowerIrql( irql ); 02317 KeDelayExecutionThread( KernelMode, FALSE, &interval ); 02318 02319 if (count++ > 3000) { 02320 02321 // 02322 // This I/O request has timed out, as it has not been completed 02323 // for a full 5 minutes. Attempt to remove the packet's association 02324 // with this thread. Note that by not resetting the count, the 02325 // next time through the loop the next packet, if there is one, 02326 // which has also timed out, will be dealt with, although it 02327 // will be given another 100ms to complete. 02328 // 02329 02330 IopDisassociateThreadIrp(); 02331 } 02332 02333 KeRaiseIrql( APC_LEVEL, &irql ); 02334 } 02335 02336 KeLowerIrql( irql ); 02337 }

NTKERNELAPI NTSTATUS IoCheckDesiredAccess IN OUT PACCESS_MASK  DesiredAccess,
IN ACCESS_MASK  GrantedAccess
 

Definition at line 2340 of file iosubs.c.

References _OBJECT_TYPE_INITIALIZER::GenericMapping, IoFileObjectType, PAGED_CODE, RtlMapGenericMask(), SeComputeDeniedAccesses, and _OBJECT_TYPE::TypeInfo.

02347 : 02348 02349 This routine is invoked to determine whether or not the granted access 02350 to a file allows the access specified by a desired access. 02351 02352 Arguments: 02353 02354 DesiredAccess - Pointer to a variable containing the access desired to 02355 the file. 02356 02357 GrantedAccess - Access currently granted to the file. 02358 02359 Return Value: 02360 02361 The final status of the access check is the function value. If the 02362 accessor has the access to the file, then STATUS_SUCCESS is returned; 02363 otherwise, STATUS_ACCESS_DENIED is returned. 02364 02365 Also, the DesiredAccess is returned with no generic mapping. 02366 02367 --*/ 02368 02369 { 02370 PAGED_CODE(); 02371 02372 // 02373 // Convert the desired access to a non-generic access mask. 02374 // 02375 02376 RtlMapGenericMask( DesiredAccess, 02377 &IoFileObjectType->TypeInfo.GenericMapping ); 02378 02379 // 02380 // Determine whether the desired access to the file is allowed, given 02381 // the current granted access. 02382 // 02383 02384 if (!SeComputeDeniedAccesses( GrantedAccess, *DesiredAccess )) { 02385 return STATUS_SUCCESS; 02386 } else { 02387 return STATUS_ACCESS_DENIED; 02388 } 02389 }

NTKERNELAPI NTSTATUS IoCheckEaBufferValidity IN PFILE_FULL_EA_INFORMATION  EaBuffer,
IN ULONG  EaLength,
OUT PULONG  ErrorOffset
 

Definition at line 2392 of file iosubs.c.

References ALIGN_LONG, GET_OFFSET_LENGTH, and PAGED_CODE.

Referenced by IoCreateFile(), IopSetEaOrQuotaInformationFile(), and NtSetEaFile().

02400 : 02401 02402 This routine checks the validity of the specified EA buffer to guarantee 02403 that its format is proper, no fields hang over, that it is not recursive, 02404 etc. 02405 02406 Arguments: 02407 02408 EaBuffer - Pointer to the buffer containing the EAs to be checked. 02409 02410 EaLength - Specifies the length of EaBuffer. 02411 02412 ErrorOffset - A variable to receive the offset of the offending entry 02413 in the EA buffer if an error is incurred. This variable is only 02414 valid if an error occurs. 02415 02416 Return Value: 02417 02418 The function value is STATUS_SUCCESS if the EA buffer contains a valid, 02419 properly formed list, otherwise STATUS_EA_LIST_INCONSISTENT. 02420 02421 --*/ 02422 02423 #define ALIGN_LONG( Address ) ( (ULONG) ((Address + 3) & ~3) ) 02424 02425 #define GET_OFFSET_LENGTH( CurrentEa, EaBase ) ( \ 02426 (ULONG) ((PCHAR) CurrentEa - (PCHAR) EaBase) ) 02427 02428 { 02429 LONG tempLength; 02430 ULONG entrySize; 02431 PFILE_FULL_EA_INFORMATION eas; 02432 02433 PAGED_CODE(); 02434 02435 // 02436 // Walk the buffer and ensure that its format is valid. That is, ensure 02437 // that it does not walk off the end of the buffer, is not recursive, 02438 // etc. 02439 // 02440 02441 eas = EaBuffer; 02442 tempLength = EaLength; 02443 02444 for (;;) { 02445 02446 // 02447 // Get the size of the current entry in the buffer. The minimum 02448 // size of the entry is the fixed size part of the structure plus 02449 // the length of the name, a single termination character byte which 02450 // must be present (a 0), plus the length of the value. If this 02451 // is not the last entry, then there will also be pad bytes to get 02452 // to the next longword boundary. 02453 // 02454 02455 // 02456 // Start by checking that the fixed size lies within the stated length. 02457 // 02458 02459 if (tempLength < FIELD_OFFSET( FILE_FULL_EA_INFORMATION, EaName[0])) { 02460 02461 *ErrorOffset = GET_OFFSET_LENGTH( eas, EaBuffer ); 02462 return STATUS_EA_LIST_INCONSISTENT; 02463 } 02464 02465 entrySize = FIELD_OFFSET( FILE_FULL_EA_INFORMATION, EaName[0] ) + 02466 eas->EaNameLength + 1 + eas->EaValueLength; 02467 02468 // 02469 // Confirm that the full length lies within the stated buffer length. 02470 // 02471 02472 if ((ULONG) tempLength < entrySize) { 02473 02474 *ErrorOffset = GET_OFFSET_LENGTH( eas, EaBuffer ); 02475 return STATUS_EA_LIST_INCONSISTENT; 02476 } 02477 02478 // 02479 // Confirm that there is a NULL terminator after the name. 02480 // 02481 02482 if (eas->EaName[eas->EaNameLength] != '\0') { 02483 02484 *ErrorOffset = GET_OFFSET_LENGTH( eas, EaBuffer ); 02485 return STATUS_EA_LIST_INCONSISTENT; 02486 } 02487 02488 if (eas->NextEntryOffset) { 02489 02490 // 02491 // There is another entry in the buffer and it must be longword 02492 // aligned. Ensure that the offset indicates that it is. If it 02493 // isn't, return invalid parameter. 02494 // 02495 02496 if (ALIGN_LONG( entrySize ) != eas->NextEntryOffset || 02497 (LONG) eas->NextEntryOffset < 0) { 02498 *ErrorOffset = GET_OFFSET_LENGTH( eas, EaBuffer ); 02499 return STATUS_EA_LIST_INCONSISTENT; 02500 02501 } else { 02502 02503 // 02504 // There is another entry in the buffer, so account for the 02505 // size of the current entry in the length and get a pointer 02506 // to the next entry. 02507 // 02508 02509 tempLength -= eas->NextEntryOffset; 02510 if (tempLength < 0) { 02511 *ErrorOffset = GET_OFFSET_LENGTH( eas, EaBuffer ); 02512 return STATUS_EA_LIST_INCONSISTENT; 02513 } 02514 eas = (PFILE_FULL_EA_INFORMATION) ((PCHAR) eas + eas->NextEntryOffset); 02515 02516 } 02517 02518 } else { 02519 02520 // 02521 // There are no other entries in the buffer. Simply account for 02522 // the overall buffer length according to the size of the current 02523 // entry and exit the loop. 02524 // 02525 02526 tempLength -= entrySize; 02527 break; 02528 02529 } 02530 } 02531 02532 // 02533 // All of the entries in the buffer have been processed. Check to see 02534 // whether the overall buffer length went negative. If so, return an 02535 // error. 02536 // 02537 02538 if (tempLength < 0) { 02539 *ErrorOffset = GET_OFFSET_LENGTH( eas, EaBuffer ); 02540 return STATUS_EA_LIST_INCONSISTENT; 02541 } 02542 02543 return STATUS_SUCCESS; 02544 }

NTKERNELAPI NTSTATUS IoCheckFunctionAccess IN ACCESS_MASK  GrantedAccess,
IN UCHAR  MajorFunction,
IN UCHAR  MinorFunction,
IN ULONG  IoControlCode,
IN PVOID Arg1  OPTIONAL,
IN PVOID Arg2  OPTIONAL
 

Definition at line 2547 of file iosubs.c.

References IopQueryFsOperationAccess, IopQueryOperationAccess, IopSetFsOperationAccess, IopSetOperationAccess, IRP_MJ_CLOSE, IRP_MJ_CREATE, IRP_MJ_DEVICE_CONTROL, IRP_MJ_DIRECTORY_CONTROL, IRP_MJ_FILE_SYSTEM_CONTROL, IRP_MJ_FLUSH_BUFFERS, IRP_MJ_INTERNAL_DEVICE_CONTROL, IRP_MJ_LOCK_CONTROL, IRP_MJ_QUERY_EA, IRP_MJ_QUERY_INFORMATION, IRP_MJ_QUERY_SECURITY, IRP_MJ_QUERY_VOLUME_INFORMATION, IRP_MJ_READ, IRP_MJ_SET_EA, IRP_MJ_SET_INFORMATION, IRP_MJ_SET_SECURITY, IRP_MJ_SET_VOLUME_INFORMATION, IRP_MJ_WRITE, NTSTATUS(), PAGED_CODE, SeComputeDeniedAccesses, SeComputeGrantedAccesses, SeQuerySecurityAccessMask(), and SeSetSecurityAccessMask().

02558 : 02559 02560 This routine checks the parameters and access for the function and 02561 parameters specified by the input parameters against the current access 02562 to the file as described by the GrantedAccess mask parameter. If the 02563 caller has the access to the file, then a successful status code is 02564 returned. Otherwise, an error status code is returned as the function 02565 value. 02566 02567 Arguments: 02568 02569 GrantedAccess - Access granted to the file for the caller. 02570 02571 MajorFunction - Major function code for the operation being performed. 02572 02573 MinorFunction - Minor function code for the operation being performed. 02574 02575 IoControlCode - I/O function control code for a device or file system I/O 02576 code. Used only for those two function types. 02577 02578 Arg1 - Optional argument that depends on the major function. Its 02579 FileInformationClass if the major function code indicates a query or set 02580 file information function is being performed. It points to Security Info 02581 if major function code is IRP_MJ_*_SECURITY. 02582 02583 Arg2 - Optional second argument that depends on the major function. Currently its 02584 FsInformationClass.This parameter MUST be supplied if the major function 02585 code indicates that a query or set file system information function is 02586 being performed. 02587 02588 Return Value: 02589 02590 The final status of the access check is the function value. If the 02591 accessor has the access to the file, then STATUS_SUCCESS is returned; 02592 otherwise, STATUS_ACCESS_DENIED is returned. 02593 02594 Note: 02595 02596 The GrantedAccess mask may not contain any generic mappings. That is, 02597 the IoCheckDesiredAccess function must have been previously invoked to 02598 return a full mask. 02599 02600 --*/ 02601 02602 { 02603 NTSTATUS status = STATUS_SUCCESS; 02604 PFILE_INFORMATION_CLASS FileInformationClass; 02605 PFS_INFORMATION_CLASS FsInformationClass; 02606 SECURITY_INFORMATION SecurityInformation; 02607 ACCESS_MASK DesiredAccess; 02608 02609 UNREFERENCED_PARAMETER( MinorFunction ); 02610 02611 PAGED_CODE(); 02612 02613 // 02614 // Determine the major function being performed. If the function code 02615 // is invalid, then return an error. 02616 // 02617 02618 FileInformationClass = (PFILE_INFORMATION_CLASS)Arg1; 02619 FsInformationClass = (PFS_INFORMATION_CLASS)Arg2; 02620 02621 switch( MajorFunction ) { 02622 02623 case IRP_MJ_CREATE: 02624 case IRP_MJ_CLOSE: 02625 02626 break; 02627 02628 case IRP_MJ_READ: 02629 02630 if (SeComputeDeniedAccesses( GrantedAccess, FILE_READ_DATA )) { 02631 status = STATUS_ACCESS_DENIED; 02632 } 02633 break; 02634 02635 case IRP_MJ_WRITE: 02636 02637 if (!SeComputeGrantedAccesses( GrantedAccess, FILE_WRITE_DATA | FILE_APPEND_DATA )) { 02638 status = STATUS_ACCESS_DENIED; 02639 } 02640 break; 02641 02642 case IRP_MJ_QUERY_INFORMATION: 02643 02644 if (IopQueryOperationAccess[*FileInformationClass] != 0) { 02645 if (SeComputeDeniedAccesses( GrantedAccess, IopQueryOperationAccess[*FileInformationClass] )) { 02646 status = STATUS_ACCESS_DENIED; 02647 } 02648 } 02649 break; 02650 02651 case IRP_MJ_SET_INFORMATION: 02652 02653 if (IopSetOperationAccess[*FileInformationClass] != 0) { 02654 if (SeComputeDeniedAccesses( GrantedAccess, IopSetOperationAccess[*FileInformationClass] )) { 02655 status = STATUS_ACCESS_DENIED; 02656 } 02657 } 02658 break; 02659 02660 case IRP_MJ_QUERY_EA: 02661 02662 if (SeComputeDeniedAccesses( GrantedAccess, FILE_READ_EA )) { 02663 status = STATUS_ACCESS_DENIED; 02664 } 02665 break; 02666 02667 case IRP_MJ_SET_EA: 02668 02669 if (SeComputeDeniedAccesses( GrantedAccess, FILE_WRITE_EA )) { 02670 status = STATUS_ACCESS_DENIED; 02671 } 02672 break; 02673 02674 case IRP_MJ_FLUSH_BUFFERS: 02675 02676 if (SeComputeDeniedAccesses( GrantedAccess, FILE_WRITE_DATA )) { 02677 status = STATUS_ACCESS_DENIED; 02678 } 02679 break; 02680 02681 case IRP_MJ_QUERY_VOLUME_INFORMATION: 02682 02683 if (SeComputeDeniedAccesses( GrantedAccess, IopQueryFsOperationAccess[*FsInformationClass] )) { 02684 status = STATUS_ACCESS_DENIED; 02685 } 02686 break; 02687 02688 case IRP_MJ_SET_VOLUME_INFORMATION: 02689 02690 if (SeComputeDeniedAccesses( GrantedAccess, IopSetFsOperationAccess[*FsInformationClass] )) { 02691 status = STATUS_ACCESS_DENIED; 02692 } 02693 break; 02694 02695 case IRP_MJ_DIRECTORY_CONTROL: 02696 02697 if (SeComputeDeniedAccesses( GrantedAccess, FILE_LIST_DIRECTORY )) { 02698 status = STATUS_ACCESS_DENIED; 02699 } 02700 break; 02701 02702 case IRP_MJ_FILE_SYSTEM_CONTROL: 02703 case IRP_MJ_DEVICE_CONTROL: 02704 case IRP_MJ_INTERNAL_DEVICE_CONTROL: 02705 02706 { 02707 ULONG accessMode = (IoControlCode >> 14) & 3; 02708 02709 if (accessMode != FILE_ANY_ACCESS) { 02710 02711 // 02712 // This I/O control requires that the caller have read, write, 02713 // or read/write access to the object. If this is not the case, 02714 // then cleanup and return an appropriate error status code. 02715 // 02716 02717 if (!(SeComputeGrantedAccesses( GrantedAccess, accessMode ))) { 02718 status = STATUS_ACCESS_DENIED; 02719 } 02720 } 02721 02722 } 02723 break; 02724 02725 case IRP_MJ_LOCK_CONTROL: 02726 02727 if (!SeComputeGrantedAccesses( GrantedAccess, FILE_READ_DATA | FILE_WRITE_DATA )) { 02728 status = STATUS_ACCESS_DENIED; 02729 } 02730 break; 02731 02732 case IRP_MJ_SET_SECURITY: 02733 02734 SecurityInformation = *((PSECURITY_INFORMATION)Arg1); 02735 SeSetSecurityAccessMask(SecurityInformation, &DesiredAccess); 02736 02737 if (SeComputeDeniedAccesses( GrantedAccess, DesiredAccess )) { 02738 status = STATUS_ACCESS_DENIED; 02739 } 02740 break; 02741 02742 case IRP_MJ_QUERY_SECURITY: 02743 02744 SecurityInformation = *((PSECURITY_INFORMATION)Arg1); 02745 SeQuerySecurityAccessMask(SecurityInformation, &DesiredAccess); 02746 02747 if (SeComputeDeniedAccesses( GrantedAccess, DesiredAccess )) { 02748 status = STATUS_ACCESS_DENIED; 02749 } 02750 break; 02751 default: 02752 02753 status = STATUS_INVALID_DEVICE_REQUEST; 02754 } 02755 return status; 02756 }

NTKERNELAPI NTSTATUS IoCheckQuerySetFileInformation IN FILE_INFORMATION_CLASS  FileInformationClass,
IN ULONG  Length,
IN BOOLEAN  SetOperation
 

Definition at line 2760 of file iosubs.c.

References IopQueryOperationLength, and IopSetOperationLength.

02768 : 02769 02770 This routine checks the validity of the parameters for either a query or a 02771 set file information operation. It is used primarily by network servers 02772 running in kernel mode since no such parameter validity checking is done 02773 in the normal path. 02774 02775 Arguments: 02776 02777 FileInformationClass - Specifies the information class to check checked. 02778 02779 Length - Specifies the length of the buffer supplied. 02780 02781 SetOperation - Specifies that the operation was a set file information as 02782 opposed to a query operation. 02783 02784 Return Value: 02785 02786 The function value is STATUS_SUCCESS if the parameters were valid, 02787 otherwise an appropriate error is returned. 02788 02789 --*/ 02790 02791 { 02792 PCHAR operationLength; 02793 02794 // 02795 // The file information class itself must be w/in the valid range of file 02796 // information classes, otherwise this is an invalid information class. 02797 // 02798 02799 if ((ULONG) FileInformationClass >= FileMaximumInformation) { 02800 return STATUS_INVALID_INFO_CLASS; 02801 } 02802 02803 // 02804 // Determine whether this is a query or a set operation and act accordingly. 02805 // 02806 02807 operationLength = SetOperation ? IopSetOperationLength : IopQueryOperationLength; 02808 02809 if (!operationLength[FileInformationClass]) { 02810 return STATUS_INVALID_INFO_CLASS; 02811 } 02812 if (Length < (ULONG) operationLength[FileInformationClass]) { 02813 return STATUS_INFO_LENGTH_MISMATCH; 02814 } 02815 02816 return STATUS_SUCCESS; 02817 } NTKERNELAPI

NTKERNELAPI NTSTATUS IoCheckQuerySetVolumeInformation IN FS_INFORMATION_CLASS  FsInformationClass,
IN ULONG  Length,
IN BOOLEAN  SetOperation
 

Definition at line 2820 of file iosubs.c.

References IopQueryFsOperationLength, and IopSetFsOperationLength.

02828 : 02829 02830 This routine checks the validity of the parameters for either a query or a 02831 set volume information operation. It is used primarily by network servers 02832 running in kernel mode since no such parameter validity checking is done 02833 in the normal path. 02834 02835 Arguments: 02836 02837 FsInformationClass - Specifies the information class to check. 02838 02839 Length - Specifies the length of the buffer supplied. 02840 02841 SetOperation - Specifies that the operation was a set volume information as 02842 opposed to a query operation. 02843 02844 Return Value: 02845 02846 The function value is STATUS_SUCCESS if the parameters were valid, 02847 otherwise an appropriate error is returned. 02848 02849 --*/ 02850 02851 { 02852 PCHAR operationLength; 02853 02854 operationLength = SetOperation ? IopSetFsOperationLength : IopQueryFsOperationLength; 02855 02856 // 02857 // The volume information class itself must be w/in the valid range of file 02858 // information classes, otherwise this is an invalid information class. 02859 // 02860 if ((ULONG) FsInformationClass >= FileFsMaximumInformation || 02861 operationLength[ FsInformationClass ] == 0 ) { 02862 02863 return STATUS_INVALID_INFO_CLASS; 02864 } 02865 02866 if (Length < (ULONG) operationLength[FsInformationClass]) { 02867 return STATUS_INFO_LENGTH_MISMATCH; 02868 } 02869 02870 return STATUS_SUCCESS; 02871 }

NTKERNELAPI NTSTATUS IoCheckQuotaBufferValidity IN PFILE_QUOTA_INFORMATION  QuotaBuffer,
IN ULONG  QuotaLength,
OUT PULONG  ErrorOffset
 

Definition at line 2874 of file iosubs.c.

References GET_OFFSET_LENGTH, PAGED_CODE, REQUIRED_QUOTA_ALIGNMENT, RtlLengthSid(), and RtlValidSid().

Referenced by IopSetEaOrQuotaInformationFile().

02882 : 02883 02884 This routine checks the validity of the specified quota buffer to guarantee 02885 that its format is proper, no fields hang over, that it is not recursive, 02886 etc. 02887 02888 Arguments: 02889 02890 QuotaBuffer - Pointer to the buffer containing the quota entries to be 02891 checked. 02892 02893 QuotaLength - Specifies the length of the QuotaBuffer. 02894 02895 ErrorOffset - A variable to receive the offset of the offending entry in 02896 the quota buffer if an error is incurred. This variable is only valid 02897 if an error occurs. 02898 02899 Return Value: 02900 02901 The function value is STATUS_SUCCESS if the quota buffer contains a valid, 02902 properly formed list, otherwise STATUS_QUOTA_LIST_INCONSISTENT. 02903 02904 --*/ 02905 02906 #if defined(_X86_) 02907 #define REQUIRED_QUOTA_ALIGNMENT sizeof( ULONG ) 02908 #else 02909 #define REQUIRED_QUOTA_ALIGNMENT sizeof( ULONGLONG ) 02910 #endif 02911 02912 #define ALIGN_QUAD( Address ) ( (ULONG) ((Address + 7) & ~7) ) 02913 02914 #define GET_OFFSET_LENGTH( CurrentEntry, QuotaBase ) (\ 02915 (ULONG) ((PCHAR) CurrentEntry - (PCHAR) QuotaBase) ) 02916 02917 { 02918 LONG tempLength; 02919 ULONG entrySize; 02920 PFILE_QUOTA_INFORMATION quotas; 02921 02922 PAGED_CODE(); 02923 02924 // 02925 // Walk the buffer and ensure that its format is valid. That is, ensure 02926 // that it does not walk off the end of the buffer, is not recursive, 02927 // etc. 02928 // 02929 02930 quotas = QuotaBuffer; 02931 tempLength = QuotaLength; 02932 02933 // 02934 // Ensure the buffer has the correct alignment. 02935 // 02936 02937 if ((ULONG_PTR) quotas & (REQUIRED_QUOTA_ALIGNMENT - 1)) { 02938 *ErrorOffset = 0; 02939 return STATUS_DATATYPE_MISALIGNMENT; 02940 } 02941 02942 for (;;) { 02943 02944 ULONG sidLength; 02945 02946 // 02947 // Get the size of the current entry in the buffer. The minimum size 02948 // of the entry is the fixed size part of the structure plus the actual 02949 // length of the SID. If this is not the last entry, then there will 02950 // also be pad bytes to get to the next longword boundary. Likewise, 02951 // ensure that the SID itself is valid. 02952 // 02953 02954 if (tempLength < FIELD_OFFSET( FILE_QUOTA_INFORMATION, Sid ) || 02955 !RtlValidSid( &quotas->Sid )) { 02956 goto error_exit; 02957 } 02958 02959 sidLength = RtlLengthSid( (&quotas->Sid) ); 02960 entrySize = FIELD_OFFSET( FILE_QUOTA_INFORMATION, Sid ) + sidLength; 02961 02962 // 02963 // Confirm that the full length lies within the stated buffer length. 02964 // 02965 02966 if ((ULONG) tempLength < entrySize || 02967 quotas->SidLength != sidLength) { 02968 goto error_exit; 02969 } 02970 02971 if (quotas->NextEntryOffset) { 02972 02973 // 02974 // There is another entry in the buffer and it must be longword 02975 // aligned. Ensure that the offset indicates that it is. If it 02976 // is not, return error status code. 02977 // 02978 02979 if (entrySize > quotas->NextEntryOffset || 02980 quotas->NextEntryOffset & (REQUIRED_QUOTA_ALIGNMENT - 1) || 02981 (LONG) quotas->NextEntryOffset < 0) { 02982 goto error_exit; 02983 02984 } else { 02985 02986 // 02987 // There is another entry in the buffer, so account for the size 02988 // of the current entry in the length and get a pointer to the 02989 // next entry. 02990 // 02991 02992 tempLength -= quotas->NextEntryOffset; 02993 if (tempLength < 0) { 02994 goto error_exit; 02995 } 02996 quotas = (PFILE_QUOTA_INFORMATION) ((PCHAR) quotas + quotas->NextEntryOffset); 02997 } 02998 02999 } else { 03000 03001 // 03002 // There are no more entries in the buffer. Simply account for the 03003 // overall buffer length according to the size of the current 03004 // entry and exit the loop. 03005 // 03006 03007 tempLength -= entrySize; 03008 break; 03009 } 03010 } 03011 03012 // 03013 // All of the entries in the buffer have been processed. Check to see 03014 // whether the overall buffer length went negative. If so, return an 03015 // error. 03016 // 03017 03018 if (tempLength < 0) { 03019 goto error_exit; 03020 } 03021 03022 return STATUS_SUCCESS; 03023 03024 error_exit: 03025 03026 *ErrorOffset = GET_OFFSET_LENGTH( quotas, QuotaBuffer ); 03027 return STATUS_QUOTA_LIST_INCONSISTENT; 03028 03029 }

NTKERNELAPI NTSTATUS IoCheckShareAccess IN ACCESS_MASK  DesiredAccess,
IN ULONG  DesiredShareAccess,
IN OUT PFILE_OBJECT  FileObject,
IN OUT PSHARE_ACCESS  ShareAccess,
IN BOOLEAN  Update
 

Definition at line 3032 of file iosubs.c.

References PAGED_CODE.

Referenced by UdfCompleteFcbOpen().

03042 : 03043 03044 This routine is invoked to determine whether or not a new accessor to 03045 a file actually has shared access to it. The check is made according 03046 to: 03047 03048 1) How the file is currently opened. 03049 03050 2) What types of shared accesses are currently specified. 03051 03052 3) The desired and shared accesses that the new open is requesting. 03053 03054 If the open should succeed, then the access information about how the 03055 file is currently opened is updated, according to the Update parameter. 03056 03057 Arguments: 03058 03059 DesiredAccess - Desired access of current open request. 03060 03061 DesiredShareAccess - Shared access requested by current open request. 03062 03063 FileObject - Pointer to the file object of the current open request. 03064 03065 ShareAccess - Pointer to the share access structure that describes how 03066 the file is currently being accessed. 03067 03068 Update - Specifies whether or not the share access information for the 03069 file is to be updated. 03070 03071 Return Value: 03072 03073 The final status of the access check is the function value. If the 03074 accessor has access to the file, STATUS_SUCCESS is returned. Otherwise, 03075 STATUS_SHARING_VIOLATION is returned. 03076 03077 Note: 03078 03079 Note that the ShareAccess parameter must be locked against other accesses 03080 from other threads while this routine is executing. Otherwise the counts 03081 will be out-of-synch. 03082 03083 --*/ 03084 03085 { 03086 ULONG ocount; 03087 03088 PAGED_CODE(); 03089 03090 // 03091 // Set the access type in the file object for the current accessor. 03092 // Note that reading and writing attributes are not included in the 03093 // access check. 03094 // 03095 03096 FileObject->ReadAccess = (BOOLEAN) ((DesiredAccess & (FILE_EXECUTE 03097 | FILE_READ_DATA)) != 0); 03098 FileObject->WriteAccess = (BOOLEAN) ((DesiredAccess & (FILE_WRITE_DATA 03099 | FILE_APPEND_DATA)) != 0); 03100 FileObject->DeleteAccess = (BOOLEAN) ((DesiredAccess & DELETE) != 0); 03101 03102 // 03103 // There is no more work to do unless the user specified one of the 03104 // sharing modes above. 03105 // 03106 03107 if (FileObject->ReadAccess || 03108 FileObject->WriteAccess || 03109 FileObject->DeleteAccess) { 03110 03111 FileObject->SharedRead = (BOOLEAN) ((DesiredShareAccess & FILE_SHARE_READ) != 0); 03112 FileObject->SharedWrite = (BOOLEAN) ((DesiredShareAccess & FILE_SHARE_WRITE) != 0); 03113 FileObject->SharedDelete = (BOOLEAN) ((DesiredShareAccess & FILE_SHARE_DELETE) != 0); 03114 03115 // 03116 // Now check to see whether or not the desired accesses are compatible 03117 // with the way that the file is currently open. 03118 // 03119 03120 ocount = ShareAccess->OpenCount; 03121 03122 if ( (FileObject->ReadAccess && (ShareAccess->SharedRead < ocount)) 03123 || 03124 (FileObject->WriteAccess && (ShareAccess->SharedWrite < ocount)) 03125 || 03126 (FileObject->DeleteAccess && (ShareAccess->SharedDelete < ocount)) 03127 || 03128 ((ShareAccess->Readers != 0) && !FileObject->SharedRead) 03129 || 03130 ((ShareAccess->Writers != 0) && !FileObject->SharedWrite) 03131 || 03132 ((ShareAccess->Deleters != 0) && !FileObject->SharedDelete) 03133 ) { 03134 03135 // 03136 // The check failed. Simply return to the caller indicating that the 03137 // current open cannot access the file. 03138 // 03139 03140 return STATUS_SHARING_VIOLATION; 03141 03142 // 03143 // The check was successful. Update the counter information in the 03144 // shared access structure for this open request if the caller 03145 // specified that it should be updated. 03146 // 03147 03148 } else if (Update) { 03149 03150 ShareAccess->OpenCount++; 03151 03152 ShareAccess->Readers += FileObject->ReadAccess; 03153 ShareAccess->Writers += FileObject->WriteAccess; 03154 ShareAccess->Deleters += FileObject->DeleteAccess; 03155 03156 ShareAccess->SharedRead += FileObject->SharedRead; 03157 ShareAccess->SharedWrite += FileObject->SharedWrite; 03158 ShareAccess->SharedDelete += FileObject->SharedDelete; 03159 } 03160 } 03161 return STATUS_SUCCESS; 03162 }

NTKERNELAPI NTSTATUS IoConnectInterrupt OUT PKINTERRUPT InterruptObject,
IN PKSERVICE_ROUTINE  ServiceRoutine,
IN PVOID  ServiceContext,
IN PKSPIN_LOCK SpinLock  OPTIONAL,
IN ULONG  Vector,
IN KIRQL  Irql,
IN KIRQL  SynchronizeIrql,
IN KINTERRUPT_MODE  InterruptMode,
IN BOOLEAN  ShareVector,
IN KAFFINITY  ProcessorEnableMask,
IN BOOLEAN  FloatingSave
 

Definition at line 3665 of file iosubs.c.

References ExAllocatePoolWithTag, ExFreePool(), FALSE, _IO_INTERRUPT_STRUCTURE::InterruptArray, InterruptObject, _IO_INTERRUPT_STRUCTURE::InterruptObject, IoDisconnectInterrupt(), KeActiveProcessors, KeConnectInterrupt(), KeInitializeInterrupt(), NonPagedPool, NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, _IO_INTERRUPT_STRUCTURE::SpinLock, and TRUE.

03681 : 03682 03683 This routine allocates, initializes, and connects interrupt objects for 03684 all of the processors specified in the processor enable mask. 03685 03686 Arguments: 03687 03688 InterruptObject - Address of a variable to receive a pointer to the first 03689 interrupt object allocated and initialized. 03690 03691 ServiceRoutine - Address of the interrupt service routine (ISR) that should 03692 be executed when the interrupt occurs. 03693 03694 ServiceContext - Supplies a pointer to the context information required 03695 by the ISR. 03696 03697 SpinLock - Supplies a pointer to a spin lock to be used when synchronizing 03698 with the ISR. 03699 03700 Vector - Supplies the vector upon which the interrupt occurs. 03701 03702 Irql - Supplies the IRQL upon which the interrupt occurs. 03703 03704 SynchronizeIrql - The request priority that the interrupt should be 03705 synchronized with. 03706 03707 InterruptMode - Specifies the interrupt mode of the device. 03708 03709 ShareVector - Supplies a boolean value that specifies whether the 03710 vector can be shared with other interrupt objects or not. If FALSE 03711 then the vector may not be shared, if TRUE it may be. 03712 Latched. 03713 03714 ProcessorEnableMask - Specifies a bit-vector for each processor on which 03715 the interrupt is to be connected. A value of one in the bit position 03716 cooresponding to the processor number indicates that the interrupt 03717 should be allowed on that processor. At least one bit must be set. 03718 03719 FloatingSave - A BOOLEAN that specifies whether or not the machine's 03720 floating point state should be saved before invoking the ISR. 03721 03722 Return Value: 03723 03724 The function value is the final function status. The three status values 03725 that this routine can itself return are: 03726 03727 STATUS_SUCCESS - Everything worked successfully. 03728 STATUS_INVALID_PARAMETER - No processors were specified. 03729 STATUS_INSUFFICIENT_RESOURCES - There was not enough nonpaged pool. 03730 03731 --*/ 03732 03733 { 03734 CCHAR count; 03735 BOOLEAN builtinUsed; 03736 PKINTERRUPT interruptObject; 03737 ULONG processorMask; 03738 NTSTATUS status; 03739 PIO_INTERRUPT_STRUCTURE interruptStructure; 03740 PKSPIN_LOCK spinLock; 03741 03742 PAGED_CODE(); 03743 03744 // 03745 // Initialize the return pointer and assume success. 03746 // 03747 03748 *InterruptObject = (PKINTERRUPT) NULL; 03749 status = STATUS_SUCCESS; 03750 03751 // 03752 // Determine how much memory is to be allocated based on how many 03753 // processors this system may have and how many bits are set in the 03754 // processor enable mask. 03755 // 03756 03757 processorMask = ProcessorEnableMask & KeActiveProcessors; 03758 count = 0; 03759 03760 while (processorMask) { 03761 if (processorMask & 1) { 03762 count++; 03763 } 03764 processorMask >>= 1; 03765 } 03766 03767 // 03768 // If any interrupt objects are to be allocated and initialized, allocate 03769 // the memory now. 03770 // 03771 03772 if (count) { 03773 interruptStructure = ExAllocatePoolWithTag( NonPagedPool, 03774 ((count - 1) * sizeof( KINTERRUPT )) + 03775 sizeof( IO_INTERRUPT_STRUCTURE ), 03776 'nioI' ); 03777 if (interruptStructure == NULL) { 03778 status = STATUS_INSUFFICIENT_RESOURCES; 03779 } 03780 } else { 03781 status = STATUS_INVALID_PARAMETER; 03782 } 03783 03784 // 03785 // If the caller specified a spin lock to be used for the interrupt object, 03786 // use it. Otherwise, provide one by using the one in the structure that 03787 // was just allocated. 03788 // 03789 03790 if (ARGUMENT_PRESENT( SpinLock )) { 03791 spinLock = SpinLock; 03792 } else { 03793 spinLock = &interruptStructure->SpinLock; 03794 } 03795 03796 // 03797 // If the pool allocation was successful, initialize and connect the 03798 // interrupt objects to the appropriate processors. 03799 // 03800 03801 if (NT_SUCCESS( status )) { 03802 03803 // 03804 // Return the address of the first interrupt object in case an 03805 // interrupt is pending for the device when it is initially connected 03806 // and the driver must synchronize its execution with the ISR. 03807 // 03808 03809 *InterruptObject = &interruptStructure->InterruptObject; 03810 03811 // 03812 // Begin by getting a pointer to the start of the memory to be used 03813 // for interrupt objects other than the builtin object. 03814 // 03815 03816 interruptObject = (PKINTERRUPT) (interruptStructure + 1); 03817 builtinUsed = FALSE; 03818 processorMask = ProcessorEnableMask & KeActiveProcessors; 03819 03820 // 03821 // Now zero the interrupt structure itself so that if something goes 03822 // wrong it can be backed out. 03823 // 03824 03825 RtlZeroMemory( interruptStructure, sizeof( IO_INTERRUPT_STRUCTURE ) ); 03826 03827 // 03828 // For each entry in the processor enable mask that is set, connect 03829 // and initialize an interrupt object. The first bit that is set 03830 // uses the builtin interrupt object, and all others use the pointers 03831 // that follow it. 03832 // 03833 03834 for (count = 0; processorMask; count++, processorMask >>= 1) { 03835 if (processorMask & 1) { 03836 KeInitializeInterrupt( builtinUsed ? 03837 interruptObject : 03838 &interruptStructure->InterruptObject, 03839 ServiceRoutine, 03840 ServiceContext, 03841 spinLock, 03842 Vector, 03843 Irql, 03844 SynchronizeIrql, 03845 InterruptMode, 03846 ShareVector, 03847 count, 03848 FloatingSave ); 03849 03850 if (!KeConnectInterrupt( builtinUsed ? 03851 interruptObject : 03852 &interruptStructure->InterruptObject )) { 03853 03854 // 03855 // An error occurred while attempting to connect the 03856 // interrupt. This means that the driver either specified 03857 // the wrong type of interrupt mode, or attempted to connect 03858 // to some processor that didn't exist, or whatever. In 03859 // any case, the problem turns out to be an invalid 03860 // parameter was specified. Simply back everything out 03861 // and return an error status. 03862 // 03863 // Note that if the builtin entry was used, then the entire 03864 // structure needs to be walked as there are entries that 03865 // were successfully connected. Otherwise, the first 03866 // attempt to connect failed, so simply free everything 03867 // in-line. 03868 // 03869 03870 if (builtinUsed) { 03871 IoDisconnectInterrupt( &interruptStructure->InterruptObject ); 03872 } else { 03873 ExFreePool( interruptStructure ); 03874 } 03875 status = STATUS_INVALID_PARAMETER; 03876 break; 03877 } 03878 03879 03880 // 03881 // If the builtin entry has been used, then the interrupt 03882 // object just connected was one of the pointers, so fill 03883 // it in with the address of the memory actually used. 03884 // 03885 03886 if (builtinUsed) { 03887 interruptStructure->InterruptArray[count] = interruptObject++; 03888 03889 } else { 03890 03891 // 03892 // Otherwise, the builtin entry was used, so indicate 03893 // that it is no longer valid to use and start using 03894 // the pointers instead. 03895 // 03896 03897 builtinUsed = TRUE; 03898 } 03899 03900 } 03901 } 03902 } 03903 03904 // 03905 // Finally, reset the address of the interrupt object if the function 03906 // failed and return the final status of the operation. 03907 // 03908 03909 if (!NT_SUCCESS( status )) { 03910 *InterruptObject = (PKINTERRUPT) NULL; 03911 } 03912 03913 return status; 03914 }

NTKERNELAPI PCONTROLLER_OBJECT IoCreateController IN ULONG  Size  ) 
 

Definition at line 3917 of file iosubs.c.

References CONTROLLER_OBJECT, IO_TYPE_CONTROLLER, IoControllerObjectType, KeInitializeDeviceQueue(), KernelMode, NT_SUCCESS, NtClose(), NTSTATUS(), NULL, ObCreateObject(), ObInsertObject(), PAGED_CODE, Size, USHORT, and VOID().

03923 : 03924 03925 This routine creates a controller object that can be used to synchronize 03926 access to a physical device controller from two or more devices. 03927 03928 Arguments: 03929 03930 Size - Size of the adapter extension in bytes. 03931 03932 Return Value: 03933 03934 A pointer to the controller object that was created or a NULL pointer. 03935 03936 --*/ 03937 03938 { 03939 OBJECT_ATTRIBUTES objectAttributes; 03940 PCONTROLLER_OBJECT controllerObject; 03941 HANDLE handle; 03942 NTSTATUS status; 03943 03944 PAGED_CODE(); 03945 03946 // 03947 // Initialize the object attributes structure in preparation for creating 03948 // the controller object. 03949 // 03950 03951 InitializeObjectAttributes( &objectAttributes, 03952 (PUNICODE_STRING) NULL, 03953 0, 03954 (HANDLE) NULL, 03955 (PSECURITY_DESCRIPTOR) NULL ); 03956 03957 // 03958 // Create the controller object itself. 03959 // 03960 03961 status = ObCreateObject( KernelMode, 03962 IoControllerObjectType, 03963 &objectAttributes, 03964 KernelMode, 03965 (PVOID) NULL, 03966 (ULONG) sizeof( CONTROLLER_OBJECT ) + Size, 03967 0, 03968 0, 03969 (PVOID *) &controllerObject ); 03970 if (NT_SUCCESS( status )) { 03971 03972 // 03973 // Insert the controller object into the table. 03974 // 03975 03976 status = ObInsertObject( controllerObject, 03977 NULL, 03978 FILE_READ_DATA | FILE_WRITE_DATA, 03979 1, 03980 (PVOID *) &controllerObject, 03981 &handle ); 03982 03983 // 03984 // If the insert operation fails, set return value to NULL. 03985 // 03986 03987 if (!NT_SUCCESS( status )) { 03988 controllerObject = (PCONTROLLER_OBJECT) NULL; 03989 } else { 03990 03991 // 03992 // The insert completed successfully. Close the handle so that if 03993 // the driver is unloaded, the controller object can go away. 03994 // 03995 03996 (VOID) NtClose( handle ); 03997 03998 // 03999 // Zero the memory for the controller object. 04000 // 04001 04002 RtlZeroMemory( controllerObject, sizeof( CONTROLLER_OBJECT ) + Size ); 04003 04004 // 04005 // Set the type and size of this controller object. 04006 // 04007 04008 controllerObject->Type = IO_TYPE_CONTROLLER; 04009 controllerObject->Size = (USHORT) (sizeof( CONTROLLER_OBJECT ) + Size); 04010 controllerObject->ControllerExtension = (PVOID) (controllerObject + 1); 04011 04012 // 04013 // Finally, initialize the controller's device queue. 04014 // 04015 04016 KeInitializeDeviceQueue( &controllerObject->DeviceWaitQueue ); 04017 } 04018 } else { 04019 controllerObject = (PCONTROLLER_OBJECT) NULL; 04020 } 04021 04022 return controllerObject; 04023 }

NTKERNELAPI NTSTATUS IoCreateDevice IN PDRIVER_OBJECT  DriverObject,
IN ULONG  DeviceExtensionSize,
IN PUNICODE_STRING DeviceName  OPTIONAL,
IN DEVICE_TYPE  DeviceType,
IN ULONG  DeviceCharacteristics,
IN BOOLEAN  Exclusive,
OUT PDEVICE_OBJECT DeviceObject
 

Definition at line 4073 of file iosubs.c.

References _DEVICE_OBJECT::AlignmentRequirement, ASSERT, CHAR, _DEVICE_OBJECT::Characteristics, DEVICE_OBJECT, _DEVICE_OBJECT::DeviceExtension, _DEVICE_OBJECT::DeviceLock, _DEVOBJ_EXTENSION::DeviceObject, _DEVICE_OBJECT::DeviceObjectExtension, _DEVICE_OBJECT::DeviceQueue, _DEVICE_OBJECT::DeviceType, DO_DEVICE_HAS_NAME, DO_DEVICE_INITIALIZING, DO_EXCLUSIVE, DRVO_UNLOAD_INVOKED, ExFreePool(), FALSE, _DEVICE_OBJECT::Flags, IO_TYPE_DEVICE, IO_TYPE_DEVICE_OBJECT_EXTENSION, IoDeviceObjectType, IopCreateDefaultDeviceSecurityDescriptor(), IopCreateVpb(), IopInsertRemoveDevice(), IopUniqueDeviceObjectNumber, KeInitializeDeviceQueue(), KeInitializeEvent, KernelMode, L, NT_SUCCESS, NtClose(), NTSTATUS(), NULL, ObCreateObject(), ObInsertObject(), ObReferenceObject, PAGED_CODE, PoInitializeDeviceObject(), PoVolumeDevice(), _DEVICE_OBJECT::Queue, RtlInitUnicodeString(), _DEVICE_OBJECT::SectorSize, _DEVOBJ_EXTENSION::Size, _DEVICE_OBJECT::Size, _DEVICE_OBJECT::StackSize, TRUE, _DEVOBJ_EXTENSION::Type, _DEVICE_OBJECT::Type, USHORT, and VOID().

Referenced by DriverEntry(), FsRecCreateAndRegisterDO(), IopFindLegacyDeviceNode(), IopInitializeDeviceInstanceKey(), IopInitializePlugPlayServices(), IoReportDetectedDevice(), and UdfMountVolume().

04085 : 04086 04087 This routine creates a device object and links it into the I/O database. 04088 04089 Arguments: 04090 04091 DriverObject - A pointer to the driver object for this device. 04092 04093 DeviceExtensionSize - Size, in bytes, of extension to device object; 04094 i.e., the size of the driver-specific data for this device object. 04095 04096 DeviceName - Optional name that should be associated with this device. 04097 If the DeviceCharacteristics has the FILE_AUTOGENERATED_DEVICE_NAME 04098 flag set, this parameter is ignored. 04099 04100 DeviceType - The type of device that the device object should represent. 04101 04102 DeviceCharacteristics - The characteristics for the device. 04103 04104 Exclusive - Indicates that the device object should be created with using 04105 the exclusive object attribute. 04106 04107 NOTE: This flag should not be used for WDM drivers. Since only the 04108 PDO is named, it is the only device object in a devnode attachment 04109 stack that is openable. However, since this device object is created 04110 by the underlying bus driver (which has no knowledge about what type 04111 of device this is), there is no way to know whether this flag should 04112 be set. Therefore, this parameter should always be FALSE for WDM 04113 drivers. Drivers attached to the PDO (e.g., the function driver) must 04114 enforce any exclusivity rules. 04115 04116 DeviceObject - Pointer to the device object pointer we will return. 04117 04118 Return Value: 04119 04120 The function value is the final status of the operation. 04121 04122 04123 --*/ 04124 04125 { 04126 OBJECT_ATTRIBUTES objectAttributes; 04127 PDEVICE_OBJECT deviceObject; 04128 PDEVOBJ_EXTENSION deviceObjectExt; 04129 HANDLE handle; 04130 BOOLEAN deviceHasName; 04131 CHAR localSecurityDescriptor[SECURITY_DESCRIPTOR_MIN_LENGTH]; 04132 PSECURITY_DESCRIPTOR securityDescriptor; 04133 PACL acl; 04134 PACE_HEADER ace; 04135 PSID sid; 04136 PACCESS_MASK mask; 04137 ULONG i; 04138 ULONG RoundedSize; 04139 NTSTATUS status; 04140 USHORT sectorSize = 0; 04141 LONG nextUniqueDeviceObjectNumber; 04142 UNICODE_STRING autoGeneratedDeviceName; 04143 BOOLEAN retryWithNewName = FALSE; 04144 WCHAR deviceNameBuffer[17]; // "\Device\xxxxxxxx" 04145 04146 PAGED_CODE(); 04147 04148 acl = NULL; 04149 04150 // 04151 // Enclose the creation of the device object in a do/while, in the rare 04152 // event where we have to retry because some other driver is using our 04153 // naming scheme for auto-generated device object names. 04154 // 04155 04156 do { 04157 04158 if (DeviceCharacteristics & FILE_AUTOGENERATED_DEVICE_NAME) { 04159 04160 // 04161 // The caller has requested that we automatically generate a device 04162 // object name. Retrieve the next available number to use for this 04163 // purpose, and create a name of the form "\Device<n>", where <n> 04164 // is the (8 hexadecimal digit) character representation of the unique 04165 // number we retrieve. 04166 // 04167 04168 nextUniqueDeviceObjectNumber = InterlockedIncrement( &IopUniqueDeviceObjectNumber ); 04169 swprintf( deviceNameBuffer, L"\\Device\\%08lx", nextUniqueDeviceObjectNumber ); 04170 04171 if (retryWithNewName) { 04172 04173 // 04174 // We've already done this once (hence, the unicode device name string 04175 // is all set up, as is all the security information). Thus, we can 04176 // skip down to where we re-attempt the creation of the device object 04177 // using our new name. 04178 // 04179 04180 retryWithNewName = FALSE; 04181 goto attemptDeviceObjectCreation; 04182 04183 } else { 04184 04185 // 04186 // Set the DeviceName parameter to point to our unicode string, just as 04187 // if the caller had specified it (note, we explicitly ignore anything 04188 // the caller passes us for device name if the FILE_AUTOGENERATED_DEVICE_NAME 04189 // characteristic is specified. 04190 // 04191 04192 RtlInitUnicodeString( &autoGeneratedDeviceName, deviceNameBuffer ); 04193 DeviceName = &autoGeneratedDeviceName; 04194 } 04195 } 04196 04197 // 04198 // Remember whether or not this device was created with a name so that 04199 // it can be deallocated later. 04200 // 04201 04202 deviceHasName = (BOOLEAN) (ARGUMENT_PRESENT( DeviceName ) ? TRUE : FALSE); 04203 04204 // 04205 // Detmermine whether or not this device needs to have a security descriptor 04206 // placed on it that allows read/write access, or whether the system default 04207 // should be used. Disks, virtual disks, and file systems simply use the 04208 // system default descriptor. All others allow read/write access. 04209 // 04210 // NOTE: This routine assumes that it is in the system's security context. 04211 // In particular, it assumes that the Default DACL is the system's 04212 // Default DACL. If this assumption changes in future releases, 04213 // then use of the Default DACL below should be reviewed for 04214 // appropriateness. 04215 // 04216 04217 // 04218 // If the device is a pnp device then wait until it registers a device 04219 // class before doing the default setup. 04220 // 04221 04222 securityDescriptor = IopCreateDefaultDeviceSecurityDescriptor( 04223 DeviceType, 04224 DeviceCharacteristics, 04225 deviceHasName, 04226 localSecurityDescriptor, 04227 &acl, 04228 NULL); 04229 04230 switch ( DeviceType ) { 04231 04232 case FILE_DEVICE_DISK_FILE_SYSTEM: 04233 04234 sectorSize = 512; 04235 break; 04236 04237 case FILE_DEVICE_CD_ROM_FILE_SYSTEM: 04238 04239 sectorSize = 2048; 04240 break; 04241 04242 case FILE_DEVICE_DISK: 04243 case FILE_DEVICE_VIRTUAL_DISK: 04244 04245 sectorSize = 512; 04246 break; 04247 } 04248 04249 attemptDeviceObjectCreation: 04250 // 04251 // Initialize the object attributes structure in preparation for creating 04252 // device object. Note that the device may be created as an exclusive 04253 // device so that only one open can be done to it at a time. This saves 04254 // single user devices from having drivers that implement special code to 04255 // make sure that only one connection is ever valid at any given time. 04256 // 04257 04258 InitializeObjectAttributes( &objectAttributes, 04259 DeviceName, 04260 0, 04261 (HANDLE) NULL, 04262 securityDescriptor ); 04263 04264 04265 if (Exclusive) { 04266 objectAttributes.Attributes |= OBJ_EXCLUSIVE; 04267 } else { 04268 objectAttributes.Attributes |= 0; 04269 } 04270 04271 if (deviceHasName) { 04272 objectAttributes.Attributes |= OBJ_PERMANENT; 04273 } 04274 04275 // 04276 // Create the device object itself. 04277 // 04278 04279 RoundedSize = (sizeof( DEVICE_OBJECT ) + DeviceExtensionSize) 04280 % sizeof (LONGLONG); 04281 if (RoundedSize) { 04282 RoundedSize = sizeof (LONGLONG) - RoundedSize; 04283 } 04284 04285 RoundedSize += DeviceExtensionSize; 04286 04287 status = ObCreateObject( KernelMode, 04288 IoDeviceObjectType, 04289 &objectAttributes, 04290 KernelMode, 04291 (PVOID) NULL, 04292 (ULONG) sizeof( DEVICE_OBJECT ) + sizeof ( DEVOBJ_EXTENSION ) + 04293 RoundedSize, 04294 0, 04295 0, 04296 (PVOID *) &deviceObject ); 04297 04298 if ((status == STATUS_OBJECT_NAME_COLLISION) && 04299 (DeviceCharacteristics & FILE_AUTOGENERATED_DEVICE_NAME)) { 04300 04301 // 04302 // Some other driver is using our naming scheme, and we've picked a 04303 // device name already in use. Try again, with a new number. 04304 // 04305 04306 retryWithNewName = TRUE; 04307 } 04308 04309 } while (retryWithNewName); 04310 04311 if (!NT_SUCCESS( status )) { 04312 04313 // 04314 // Creating the device object was not successful. Clean everything 04315 // up and indicate that the object was not created. 04316 // 04317 04318 deviceObject = (PDEVICE_OBJECT) NULL; 04319 04320 } else { 04321 04322 // 04323 // The device was successfully created. Initialize the object so 04324 // that it can be inserted into the object table. Begin by zeroing 04325 // the memory for the device object. 04326 // 04327 04328 RtlZeroMemory( deviceObject, 04329 sizeof( DEVICE_OBJECT ) + sizeof ( DEVOBJ_EXTENSION ) + 04330 RoundedSize ); 04331 04332 // 04333 // Fill in deviceObject & deviceObjectExtension cross pointers 04334 // 04335 04336 deviceObjectExt = (PDEVOBJ_EXTENSION) (((PCHAR) deviceObject) + 04337 sizeof (DEVICE_OBJECT) + RoundedSize); 04338 04339 deviceObjectExt->DeviceObject = deviceObject; 04340 deviceObject->DeviceObjectExtension = deviceObjectExt; 04341 04342 // 04343 // Initialize deviceObjectExt 04344 // Note: the size of a Device Object Extension is initialized specifically 04345 // to ZERO so no driver will depend on it. 04346 // 04347 04348 deviceObjectExt->Type = IO_TYPE_DEVICE_OBJECT_EXTENSION; 04349 deviceObjectExt->Size = 0; 04350 04351 PoInitializeDeviceObject(deviceObjectExt); 04352 04353 // 04354 // Set the type and size of this device object. 04355 // 04356 04357 deviceObject->Type = IO_TYPE_DEVICE; 04358 deviceObject->Size = (USHORT) (sizeof( DEVICE_OBJECT ) + DeviceExtensionSize); 04359 04360 // 04361 // Set the device type field in the object so that later code can 04362 // check the type. Likewise, set the device characteristics. 04363 // 04364 04365 deviceObject->DeviceType = DeviceType; 04366 deviceObject->Characteristics = DeviceCharacteristics; 04367 04368 // 04369 // If this device is either a tape or a disk, allocate a Volume 04370 // Parameter Block (VPB) which indicates that the volume has 04371 // never been mounted, and set the device object's VPB pointer to 04372 // it. 04373 // 04374 04375 if ((DeviceType == FILE_DEVICE_DISK) || 04376 (DeviceType == FILE_DEVICE_TAPE) || 04377 (DeviceType == FILE_DEVICE_CD_ROM) || 04378 (DeviceType == FILE_DEVICE_VIRTUAL_DISK)) { 04379 04380 IopCreateVpb (deviceObject); 04381 KeInitializeEvent( &deviceObject->DeviceLock, 04382 SynchronizationEvent, 04383 TRUE ); 04384 } 04385 04386 // 04387 // Initialize the remainder of the device object. 04388 // 04389 deviceObject->AlignmentRequirement = HalGetDmaAlignmentRequirement() - 1; 04390 deviceObject->SectorSize = sectorSize; 04391 deviceObject->Flags = DO_DEVICE_INITIALIZING; 04392 04393 if (Exclusive) { 04394 deviceObject->Flags |= DO_EXCLUSIVE; 04395 } 04396 if (deviceHasName) { 04397 deviceObject->Flags |= DO_DEVICE_HAS_NAME; 04398 } 04399 04400 if(DeviceExtensionSize) { 04401 deviceObject->DeviceExtension = deviceObject + 1; 04402 } else { 04403 deviceObject->DeviceExtension = NULL; 04404 } 04405 04406 deviceObject->StackSize = 1; 04407 switch ( DeviceType ) { 04408 04409 case FILE_DEVICE_CD_ROM_FILE_SYSTEM: 04410 case FILE_DEVICE_DISK_FILE_SYSTEM: 04411 case FILE_DEVICE_FILE_SYSTEM: 04412 case FILE_DEVICE_NETWORK_FILE_SYSTEM: 04413 case FILE_DEVICE_TAPE_FILE_SYSTEM: 04414 04415 // 04416 // This device represents a file system of some sort. Simply 04417 // initialize the queue list head in the device object. 04418 // 04419 04420 InitializeListHead( &deviceObject->Queue.ListEntry ); 04421 break; 04422 04423 default: 04424 04425 // 04426 // This is a real device of some sort. Allocate a spin lock 04427 // and initialize the device queue object in the device object. 04428 // 04429 04430 KeInitializeDeviceQueue( &deviceObject->DeviceQueue ); 04431 break; 04432 } 04433 04434 // 04435 // Insert the device object into the table. 04436 // 04437 04438 status = ObInsertObject( deviceObject, 04439 NULL, 04440 FILE_READ_DATA | FILE_WRITE_DATA, 04441 1, 04442 (PVOID *) &deviceObject, 04443 &handle ); 04444 04445 if (NT_SUCCESS( status )) { 04446 04447 // 04448 // Reference the driver object. When the device object goes 04449 // away the reference will be removed. This prevents the 04450 // driver object and driver image from going away while the 04451 // device object is in the pending delete state. 04452 // 04453 04454 ObReferenceObject( DriverObject ); 04455 04456 ASSERT((DriverObject->Flags & DRVO_UNLOAD_INVOKED) == 0); 04457 04458 // 04459 // The insert completed successfully. Link the device object 04460 // and driver objects together. Close the handle so that if 04461 // the driver is unloaded, the device object can go away. 04462 // 04463 04464 deviceObject->DriverObject = DriverObject; 04465 04466 IopInsertRemoveDevice( DriverObject, deviceObject, TRUE ); 04467 if (deviceObject->Vpb) { 04468 PoVolumeDevice(deviceObject); 04469 } 04470 04471 (VOID) NtClose( handle ); 04472 04473 } else { 04474 04475 // 04476 // The insert operation failed. Fortunately it dropped the 04477 // reference count on the device - since that was the last one 04478 // all the cleanup should be done for us. 04479 // 04480 04481 // 04482 // indicate that no device object was created. 04483 // 04484 04485 deviceObject = (PDEVICE_OBJECT) NULL; 04486 } 04487 } 04488 04489 // 04490 // Free the DACL if we allocated it... 04491 // 04492 04493 if (acl != NULL) { 04494 ExFreePool( acl ); 04495 } 04496 04497 *DeviceObject = deviceObject; 04498 return status; 04499 }

NTKERNELAPI NTSTATUS IoCreateDriver IN PUNICODE_STRING  DriverName,
OPTIONAL IN PDRIVER_INITIALIZE  InitializationFunction
 

NTKERNELAPI NTSTATUS IoCreateFile OUT PHANDLE  FileHandle,
IN ACCESS_MASK  DesiredAccess,
IN POBJECT_ATTRIBUTES  ObjectAttributes,
OUT PIO_STATUS_BLOCK  IoStatusBlock,
IN PLARGE_INTEGER AllocationSize  OPTIONAL,
IN ULONG  FileAttributes,
IN ULONG  ShareAccess,
IN ULONG  Disposition,
IN ULONG  CreateOptions,
IN PVOID EaBuffer  OPTIONAL,
IN ULONG  EaLength,
IN CREATE_FILE_TYPE  CreateFileType,
IN PVOID ExtraCreateParameters  OPTIONAL,
IN ULONG  Options
 

Definition at line 4502 of file iosubs.c.

References _OPEN_PACKET::AllocationSize, ASSERT, _NAMED_PIPE_CREATE_PARAMETERS::CompletionMode, _OPEN_PACKET::CreateFileType, CreateFileTypeMailslot, CreateFileTypeNamedPipe, CreateFileTypeNone, _OPEN_PACKET::CreateOptions, _OPEN_PACKET::DeleteOnly, _FILE_OBJECT::DeviceObject, _OPEN_PACKET::Disposition, _OPEN_PACKET::EaBuffer, _OPEN_PACKET::EaLength, ExAllocatePoolWithQuotaTag, ExAllocatePoolWithTag, EXCEPTION_EXECUTE_HANDLER, ExFreePool(), ExRaiseStatus(), _OPEN_PACKET::ExtraCreateParameters, FALSE, FileAttributes, _OPEN_PACKET::FileAttributes, _FILE_OBJECT::FileName, _OPEN_PACKET::FileObject, _OPEN_PACKET::FinalStatus, _FILE_OBJECT::Flags, FO_HANDLE_CREATED, _OPEN_PACKET::Information, IO_ATTACH_DEVICE, IO_ATTACH_DEVICE_API, IO_CHECK_CREATE_PARAMETERS, IO_NO_PARAMETER_CHECKING, IO_TYPE_FILE, IO_TYPE_OPEN_PACKET, IoCheckEaBufferValidity(), IopUpdateOtherOperationCount(), KernelMode, KPROCESSOR_MODE, L, _NAMED_PIPE_CREATE_PARAMETERS::NamedPipeType, NonPagedPool, NT_SUCCESS, NT_WARNING, NTSTATUS(), NULL, ObDereferenceObject, ObjectAttributes, ObOpenObjectByName(), OPEN_PACKET_PATTERN, _OPEN_PACKET::Options, _OPEN_PACKET::Override, PAGED_CODE, _OPEN_PACKET::ParseCheck, ProbeAndWriteHandle, ProbeForRead, ProbeForWriteIoStatus, _OPEN_PACKET::QueryOnly, _NAMED_PIPE_CREATE_PARAMETERS::ReadMode, _OPEN_PACKET::RelatedFileObject, _OPEN_PACKET::ShareAccess, _OPEN_PACKET::Size, _OPEN_PACKET::Type, _FILE_OBJECT::Type, and USHORT.

Referenced by IopOpenLinkOrRenameTarget(), NtCreateFile(), NtCreateMailslotFile(), NtCreateNamedPipeFile(), NtCreatePagingFile(), and NtOpenFile().

04521 : 04522 04523 This is the common routine for both NtCreateFile and NtOpenFile to allow 04524 a user to create or open a file. This procedure is also used internally 04525 by kernel mode components, such as the network server, to perform the 04526 same type of operation, but allows kernel mode code to force checking 04527 arguments and access to the file, rather than bypassing these checks 04528 because the code is running in kernel mode. 04529 04530 Arguments: 04531 04532 FileHandle - A pointer to a variable to receive the handle to the open 04533 file. 04534 04535 DesiredAccess - Supplies the types of access that the caller would like 04536 to the file. 04537 04538 ObjectAttributes - Supplies the attributes to be used for the file object 04539 (name, SECURITY_DESCRIPTOR, etc.) 04540 04541 IoStatusBlock - Specifies the address of the caller's I/O status block. 04542 04543 AllocationSize - Initial size that should be allocated to the file. 04544 This parameter only has an affect if the file is created. Further, 04545 if not specified, then it is taken to mean zero. 04546 04547 FileAttributes - Specifies the attributes that should be set on the file, 04548 if it is created. 04549 04550 ShareAccess - Supplies the types of share access that the caller would 04551 like to the file. 04552 04553 Disposition - Supplies the method for handling the create/open. 04554 04555 CreateOptions - Caller options for how to perform the create/open. 04556 04557 EaBuffer - Optionally specifies a set of EAs to be applied to the file 04558 if it is created. 04559 04560 EaLength - Supplies the length of the EaBuffer. 04561 04562 CreateFileType - The type of file to create. 04563 04564 ExtraCreateParameters - Optionally specifies a pointer to extra create 04565 parameters. The format of the parameters depends on the value of 04566 CreateFileType. 04567 04568 Options - Specifies the options that are to be used during generation 04569 of the create IRP. 04570 04571 Return Value: 04572 04573 The function value is the final status of the create/open operation. 04574 04575 Warning: 04576 04577 If a pointer to ExtraCreateParameters is passed the data must be 04578 readable from kernel mode. 04579 04580 04581 --*/ 04582 04583 { 04584 KPROCESSOR_MODE requestorMode; 04585 NTSTATUS status; 04586 HANDLE handle; 04587 OPEN_PACKET openPacket; 04588 BOOLEAN SuccessfulIoParse; 04589 LARGE_INTEGER initialAllocationSize; 04590 04591 PAGED_CODE(); 04592 04593 // 04594 // Get the previous mode; i.e., the mode of the caller. 04595 // 04596 04597 requestorMode = KeGetPreviousMode(); 04598 04599 if (Options & IO_NO_PARAMETER_CHECKING) { 04600 requestorMode = KernelMode; 04601 } 04602 04603 if (requestorMode != KernelMode || Options & IO_CHECK_CREATE_PARAMETERS) { 04604 04605 // 04606 // Check for any invalid parameters. 04607 // 04608 04609 if ( 04610 04611 // 04612 // Check that no invalid file attributes flags were specified. 04613 // 04614 04615 // (FileAttributes & ~FILE_ATTRIBUTE_VALID_SET_FLAGS) 04616 (FileAttributes & ~FILE_ATTRIBUTE_VALID_FLAGS) 04617 04618 || 04619 04620 // 04621 // Check that no invalid share access flags were specified. 04622 // 04623 04624 (ShareAccess & ~FILE_SHARE_VALID_FLAGS) 04625 04626 || 04627 04628 // 04629 // Ensure that the disposition value is in range. 04630 // 04631 04632 (Disposition > FILE_MAXIMUM_DISPOSITION) 04633 04634 || 04635 04636 // 04637 // Check that no invalid create options were specified. 04638 // 04639 04640 (CreateOptions & ~FILE_VALID_OPTION_FLAGS) 04641 04642 || 04643 04644 // 04645 // If the caller specified synchronous I/O, then ensure that 04646 // (s)he also asked for synchronize desired access to the 04647 // file. 04648 // 04649 04650 (CreateOptions & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT) && 04651 (!(DesiredAccess & SYNCHRONIZE))) 04652 04653 || 04654 04655 // 04656 // Also, if the caller specified that the file is to be deleted 04657 // on close, then ensure that delete is specified as one of the 04658 // desired accesses requested. 04659 // 04660 04661 (CreateOptions & FILE_DELETE_ON_CLOSE && 04662 (!(DesiredAccess & DELETE))) 04663 04664 || 04665 04666 // 04667 // Likewise, ensure that if one of the synchronous I/O modes 04668 // is specified that the other one is not specified as well. 04669 // 04670 04671 ((CreateOptions & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT)) == 04672 (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT)) 04673 04674 || 04675 04676 // 04677 // If this create or open is for a directory operation, check 04678 // that all of the other flags, dispositions, and desired 04679 // access parameters were also specified correctly. 04680 // 04681 // These are as follows: 04682 // 04683 // o No other flags other than the synchronous I/O flags, 04684 // write-through, or open by file ID are set. 04685 // 04686 // o The disposition value is one of create, open, or 04687 // open-if. 04688 // 04689 // o No non-directory accesses have been specified. 04690 // 04691 04692 ((CreateOptions & FILE_DIRECTORY_FILE) 04693 && !(CreateOptions & FILE_NON_DIRECTORY_FILE) 04694 && ((CreateOptions & ~(FILE_DIRECTORY_FILE | 04695 FILE_SYNCHRONOUS_IO_ALERT | 04696 FILE_SYNCHRONOUS_IO_NONALERT | 04697 FILE_WRITE_THROUGH | 04698 FILE_COMPLETE_IF_OPLOCKED | 04699 FILE_OPEN_FOR_BACKUP_INTENT | 04700 FILE_DELETE_ON_CLOSE | 04701 FILE_OPEN_FOR_FREE_SPACE_QUERY | 04702 FILE_OPEN_BY_FILE_ID | 04703 FILE_OPEN_REPARSE_POINT)) 04704 || ((Disposition != FILE_CREATE) 04705 && (Disposition != FILE_OPEN) 04706 && (Disposition != FILE_OPEN_IF)) 04707 ) 04708 ) 04709 04710 || 04711 04712 // 04713 // FILE_COMPLETE_IF_OPLOCK and FILE_RESERVE_OPFILTER are 04714 // incompatible options. 04715 // 04716 04717 ((CreateOptions & FILE_COMPLETE_IF_OPLOCKED) && 04718 (CreateOptions & FILE_RESERVE_OPFILTER)) 04719 04720 || 04721 04722 // 04723 // Finally, if the no intermediate buffering option was 04724 // specified, ensure that the caller did not also request 04725 // append access to the file. 04726 // 04727 04728 (CreateOptions & FILE_NO_INTERMEDIATE_BUFFERING && 04729 (DesiredAccess & FILE_APPEND_DATA)) ) { 04730 04731 return STATUS_INVALID_PARAMETER; 04732 } 04733 04734 // 04735 // Check the file type specific creation parameters. 04736 // 04737 04738 if (CreateFileType == CreateFileTypeNone) { 04739 04740 NOTHING; 04741 04742 } else if (CreateFileType == CreateFileTypeNamedPipe) { 04743 04744 if (!ARGUMENT_PRESENT( ExtraCreateParameters ) ) { 04745 04746 return STATUS_INVALID_PARAMETER; 04747 04748 } else { 04749 04750 PNAMED_PIPE_CREATE_PARAMETERS NamedPipeCreateParameters; 04751 04752 NamedPipeCreateParameters = ExtraCreateParameters; 04753 04754 // 04755 // Check the parameters for creating a named pipe to 04756 // ensure that no invalid parameters were passed. 04757 // 04758 04759 if ( 04760 04761 // 04762 // Check the NamedPipeType field to ensure that it 04763 // is within range. 04764 // 04765 04766 (NamedPipeCreateParameters->NamedPipeType > 04767 FILE_PIPE_MESSAGE_TYPE) 04768 04769 || 04770 04771 // 04772 // Check the ReadMode field to ensure that it is 04773 // within range. 04774 // 04775 04776 (NamedPipeCreateParameters->ReadMode > 04777 FILE_PIPE_MESSAGE_MODE) 04778 04779 || 04780 04781 // 04782 // Check the CompletionMode field to ensure that 04783 // it is within range. 04784 // 04785 04786 (NamedPipeCreateParameters->CompletionMode > 04787 FILE_PIPE_COMPLETE_OPERATION) 04788 04789 || 04790 04791 // 04792 // Check the ShareAccess parameter to ensure that 04793 // it does not specify shared delete access. The 04794 // Named Pipe File System itself will need to ensure 04795 // that at least one of SHARE_READ or SHARE_WRITE 04796 // is specified if the first instance of the pipe 04797 // is being created. 04798 // 04799 04800 (ShareAccess & FILE_SHARE_DELETE) 04801 04802 || 04803 04804 // 04805 // Check the Disposition parameter to ensure that 04806 // is does not specify anything other than create, 04807 // open, or open if. 04808 // 04809 04810 (Disposition < FILE_OPEN || Disposition > FILE_OPEN_IF) 04811 04812 || 04813 04814 // 04815 // Finally, check the CreateOptions parameter to 04816 // ensure that it does not contain any invalid 04817 // options for named pipes. 04818 // 04819 04820 (CreateOptions & ~FILE_VALID_PIPE_OPTION_FLAGS)) { 04821 return STATUS_INVALID_PARAMETER; 04822 } 04823 04824 } 04825 04826 } else if (CreateFileType == CreateFileTypeMailslot) { 04827 04828 if (!ARGUMENT_PRESENT( ExtraCreateParameters ) ) { 04829 04830 return STATUS_INVALID_PARAMETER; 04831 04832 } else { 04833 04834 PMAILSLOT_CREATE_PARAMETERS mailslotCreateParameters; 04835 04836 mailslotCreateParameters = ExtraCreateParameters; 04837 04838 // 04839 // Check the parameters for creating a mailslot to ensure 04840 // that no invalid parameters were passed. 04841 // 04842 04843 if ( 04844 04845 // 04846 // Check the ShareAccess parameter to ensure that 04847 // it does not specify shared delete access. 04848 // 04849 04850 (ShareAccess & FILE_SHARE_DELETE) 04851 04852 || 04853 04854 // 04855 // Check the ShareAccess parameter to ensure that 04856 // shared write access is specified. 04857 // 04858 04859 !(ShareAccess & ~FILE_SHARE_WRITE) 04860 04861 || 04862 04863 // 04864 // Check the Disposition parameter to ensure that 04865 // it specifies that the file is to be created. 04866 // 04867 04868 (Disposition != FILE_CREATE) 04869 04870 || 04871 04872 // 04873 // Check the CreateOptions parameter to ensure that 04874 // it does not contain any options that are invalid 04875 // for mailslots. 04876 // 04877 04878 (CreateOptions & ~FILE_VALID_MAILSLOT_OPTION_FLAGS)) { 04879 return STATUS_INVALID_PARAMETER; 04880 } 04881 } 04882 } 04883 } 04884 04885 if (requestorMode != KernelMode) { 04886 04887 // 04888 // The caller's access mode is not kernel so probe each of the 04889 // arguments and capture them as necessary. If any failures occur, 04890 // the condition handler will be invoked to handle them. It will 04891 // simply cleanup and return an access violation status code back 04892 // to the system service dispatcher. 04893 // 04894 04895 openPacket.EaBuffer = (PFILE_FULL_EA_INFORMATION) NULL; 04896 04897 try { 04898 04899 // 04900 // The FileHandle parameter must be writeable by the caller. 04901 // Probe it for a write operation. 04902 // 04903 04904 ProbeAndWriteHandle( FileHandle, 0L ); 04905 04906 // 04907 // The IoStatusBlock parameter must be writeable by the caller. 04908 // 04909 04910 ProbeForWriteIoStatus( IoStatusBlock ); 04911 04912 // 04913 // The AllocationSize parameter must be readable by the caller 04914 // if it is present. If so, probe and capture it. 04915 // 04916 04917 if (ARGUMENT_PRESENT( AllocationSize )) { 04918 ProbeForRead( AllocationSize, 04919 sizeof( LARGE_INTEGER ), 04920 sizeof( ULONG ) ); 04921 initialAllocationSize = *AllocationSize; 04922 } else { 04923 initialAllocationSize.QuadPart = 0; 04924 } 04925 04926 } except(EXCEPTION_EXECUTE_HANDLER) { 04927 04928 // 04929 // An exception was incurred while attempting to access the 04930 // caller's parameters. Simply return the reason for the 04931 // exception as the service status. 04932 // 04933 04934 return GetExceptionCode(); 04935 } 04936 04937 // 04938 // Finally, if an EaBuffer was specified, ensure that it is readable 04939 // from the caller's mode and capture it. 04940 // 04941 04942 if (ARGUMENT_PRESENT( EaBuffer ) && EaLength) { 04943 04944 ULONG errorOffset; 04945 04946 try { 04947 04948 ProbeForRead( EaBuffer, EaLength, sizeof( ULONG ) ); 04949 openPacket.EaBuffer = ExAllocatePoolWithQuotaTag( NonPagedPool, 04950 EaLength, 04951 'aEoI' ); 04952 openPacket.EaLength = EaLength; 04953 RtlCopyMemory( openPacket.EaBuffer, EaBuffer, EaLength ); 04954 04955 // 04956 // Walk the buffer and ensure that its format is valid. Note 04957 // that has been probed. 04958 // 04959 04960 status = IoCheckEaBufferValidity( openPacket.EaBuffer, 04961 EaLength, 04962 &errorOffset ); 04963 04964 if (!NT_SUCCESS( status )) { 04965 IoStatusBlock->Status = status; 04966 IoStatusBlock->Information = errorOffset; 04967 ExRaiseStatus( status ); 04968 } 04969 04970 } except(EXCEPTION_EXECUTE_HANDLER) { 04971 04972 // 04973 // An exception was incurred while attempting to access the 04974 // caller's parameters. Check to see whether or not an EA 04975 // buffer was allocated and deallocate if so. 04976 // 04977 04978 if (openPacket.EaBuffer != NULL) { 04979 ExFreePool( openPacket.EaBuffer ); 04980 } 04981 04982 return GetExceptionCode(); 04983 04984 } 04985 04986 } else { 04987 04988 // 04989 // No EAs were specified. 04990 // 04991 04992 openPacket.EaBuffer = (PVOID) NULL; 04993 openPacket.EaLength = 0L; 04994 } 04995 04996 } else { 04997 04998 // 04999 // The caller's mode is kernel. Copy the input parameters to their 05000 // expected locations for later use. Also, put move attach device 05001 // flag where it belongs. 05002 // 05003 05004 if (CreateOptions & IO_ATTACH_DEVICE_API) { 05005 Options |= IO_ATTACH_DEVICE; 05006 CreateOptions &= ~IO_ATTACH_DEVICE_API; 05007 05008 } 05009 05010 if (ARGUMENT_PRESENT( AllocationSize )) { 05011 initialAllocationSize = *AllocationSize; 05012 } else { 05013 initialAllocationSize.QuadPart = 0; 05014 } 05015 05016 if (ARGUMENT_PRESENT( EaBuffer ) && EaLength) { 05017 05018 ULONG errorOffset; 05019 05020 openPacket.EaBuffer = ExAllocatePoolWithTag( NonPagedPool, 05021 EaLength, 05022 'aEoI' ); 05023 if (!openPacket.EaBuffer) { 05024 return STATUS_INSUFFICIENT_RESOURCES; 05025 } 05026 openPacket.EaLength = EaLength; 05027 RtlCopyMemory( openPacket.EaBuffer, EaBuffer, EaLength ); 05028 05029 // 05030 // Walk the buffer and ensure that its format is valid. Note 05031 // that has been probed. 05032 // 05033 05034 status = IoCheckEaBufferValidity( openPacket.EaBuffer, 05035 EaLength, 05036 &errorOffset ); 05037 05038 if (!NT_SUCCESS( status )) { 05039 ExFreePool(openPacket.EaBuffer); 05040 IoStatusBlock->Status = status; 05041 IoStatusBlock->Information = errorOffset; 05042 return status; 05043 } 05044 05045 } else { 05046 openPacket.EaBuffer = (PVOID) NULL; 05047 openPacket.EaLength = 0L; 05048 } 05049 } 05050 05051 // 05052 // Now fill in an Open Packet (OP) to be used in calling the device object 05053 // parse routine. This packet will allow information to be passed between 05054 // this routine and the parse routine so that a common context may be kept. 05055 // For most services this would be done with an I/O Request Packet (IRP), 05056 // but this cannot be done here because the number of stack entries which 05057 // need to be allocated in the IRP is not yet known. 05058 // 05059 05060 openPacket.Type = IO_TYPE_OPEN_PACKET; 05061 openPacket.Size = sizeof( OPEN_PACKET ); 05062 openPacket.ParseCheck = 0L; 05063 openPacket.AllocationSize = initialAllocationSize; 05064 openPacket.CreateOptions = CreateOptions; 05065 openPacket.FileAttributes = (USHORT) FileAttributes; 05066 openPacket.ShareAccess = (USHORT) ShareAccess; 05067 openPacket.Disposition = Disposition; 05068 openPacket.Override = FALSE; 05069 openPacket.QueryOnly = FALSE; 05070 openPacket.DeleteOnly = FALSE; 05071 openPacket.Options = Options; 05072 openPacket.RelatedFileObject = (PFILE_OBJECT) NULL; 05073 openPacket.CreateFileType = CreateFileType; 05074 openPacket.ExtraCreateParameters = ExtraCreateParameters; 05075 05076 // 05077 // Assume that the operation is going to be successful. 05078 // 05079 05080 openPacket.FinalStatus = STATUS_SUCCESS; 05081 05082 // 05083 // Zero the file object field in the OP so the parse routine knows that 05084 // this is the first time through. For reparse operations it will continue 05085 // to use the same file object that it allocated the first time. 05086 // 05087 05088 openPacket.FileObject = (PFILE_OBJECT) NULL; 05089 05090 // 05091 // Update the open count for this process. 05092 // 05093 05094 IopUpdateOtherOperationCount(); 05095 05096 // 05097 // Attempt to open the file object by name. This will yield the handle 05098 // that the user is to use as his handle to the file in all subsequent 05099 // calls, if it works. 05100 // 05101 // This call performs a whole lot of the work for actually getting every- 05102 // thing set up for the I/O system. The object manager will take the name 05103 // of the file and will translate it until it reaches a device object (or 05104 // it fails). If the former, then it will invoke the parse routine set up 05105 // by the I/O system for device objects. This routine will actually end 05106 // up creating the file object, allocating an IRP, filling it in, and then 05107 // invoking the driver's dispatch routine with the packet. 05108 // 05109 05110 status = ObOpenObjectByName( ObjectAttributes, 05111 (POBJECT_TYPE) NULL, 05112 requestorMode, 05113 NULL, 05114 DesiredAccess, 05115 &openPacket, 05116 &handle ); 05117 05118 // 05119 // If an EA buffer was allocated, deallocate it now before attempting to 05120 // determine whether or not the operation was successful so that it can be 05121 // done in one place rather than in two places. 05122 // 05123 05124 if (openPacket.EaBuffer) { 05125 ExFreePool( openPacket.EaBuffer ); 05126 } 05127 05128 // 05129 // Check the status of the open. If it was not successful, cleanup and 05130 // get out. Notice that it is also possible, because this code does not 05131 // explicitly request that a particular type of object (because the Object 05132 // Manager does not check when a parse routine is present and because the 05133 // name first refers to a device object and then a file object), a check 05134 // must be made here to ensure that what was returned was really a file 05135 // object. The check is to see whether the device object parse routine 05136 // believes that it successfully returned a pointer to a file object. If 05137 // it does, then OK; otherwise, something went wrong somewhere. 05138 // 05139 05140 SuccessfulIoParse = (BOOLEAN) (openPacket.ParseCheck == OPEN_PACKET_PATTERN); 05141 05142 if (!NT_SUCCESS( status ) || !SuccessfulIoParse) { 05143 05144 if (NT_SUCCESS( status )) { 05145 05146 // 05147 // The operation was successful as far as the object system is 05148 // concerned, but the I/O system device parse routine was never 05149 // successfully completed so this operation has actually completed 05150 // with an error because of an object mismatch. Therefore, this is 05151 // the wrong type of object so dereference whatever was actually 05152 // referenced by closing the handle that was created for it. 05153 // We have to do a ZwClose as this handle can be a kernel handle if 05154 // IoCreateFile was called by a driver. 05155 // 05156 05157 ZwClose( handle ); 05158 status = STATUS_OBJECT_TYPE_MISMATCH; 05159 } 05160 05161 // 05162 // If the final status according to the device parse routine 05163 // indicates that the operation was not successful, then use that 05164 // routine's final status because it is more descriptive than the 05165 // status which was returned by the object manager. 05166 // 05167 05168 if (!NT_SUCCESS( openPacket.FinalStatus )) { 05169 status = openPacket.FinalStatus; 05170 05171 if (NT_WARNING( status )) { 05172 05173 try { 05174 05175 IoStatusBlock->Status = openPacket.FinalStatus; 05176 IoStatusBlock->Information = openPacket.Information; 05177 05178 } except(EXCEPTION_EXECUTE_HANDLER) { 05179 05180 status = GetExceptionCode(); 05181 05182 } 05183 05184 } 05185 05186 } else if (openPacket.FileObject != NULL && !SuccessfulIoParse) { 05187 05188 // 05189 // Otherwise, one of two things occurred: 05190 // 05191 // 1) The parse routine was invoked at least once and a 05192 // reparse was performed but the parse routine did not 05193 // actually complete. 05194 // 05195 // 2) The parse routine was successful so everything worked 05196 // but the object manager incurred an error after the 05197 // parse routine completed. 05198 // 05199 // For case #1, there is an outstanding file object that still 05200 // exists. This must be cleaned up. 05201 // 05202 // For case #2, nothing must be done as the object manager has 05203 // already dereferenced the file object. Note that this code is 05204 // not invoked if the parse routine completed with a successful 05205 // status return (SuccessfulIoParse is TRUE). 05206 // 05207 05208 if (openPacket.FileObject->FileName.Length != 0) { 05209 ExFreePool( openPacket.FileObject->FileName.Buffer ); 05210 } 05211 openPacket.FileObject->DeviceObject = (PDEVICE_OBJECT) NULL; 05212 ObDereferenceObject( openPacket.FileObject ); 05213 } 05214 05215 // 05216 // When an NTFS file junction or an NTFS directory junction is traversed 05217 // OBJ_MAX_REPARSE_ATTEMPTS namy times, the object manager gives up and 05218 // returns the code STATUS_OBJECT_NAME_NOT_FOUND. 05219 // 05220 // This can happen in the following cases: 05221 // 05222 // 1) One encounters a legal chain of directory junctions that happen 05223 // to be longer than the value of the above constant. 05224 // 05225 // 2) One encounters a self-referential file or directory junction that 05226 // is, in effect, a tight name cycle. 05227 // 05228 // 3) One encounters a name cycle composed of several NTFS junctions. 05229 // 05230 // To improve on this return code see if openPacket.Information is 05231 // the trace of an NTFS name junction. 05232 // 05233 05234 if ((status == STATUS_OBJECT_NAME_NOT_FOUND) && 05235 (openPacket.Information == IO_REPARSE_TAG_MOUNT_POINT)) { 05236 05237 status = STATUS_REPARSE_POINT_NOT_RESOLVED; 05238 } 05239 05240 } else { 05241 05242 // 05243 // At this point, the open/create operation has been successfully 05244 // completed. There is a handle to the file object, which has been 05245 // created, and the file object has been signaled. 05246 // 05247 // The remaining work to be done is to complete the operation. This is 05248 // performed as follows: 05249 // 05250 // 1. The file object has been signaled, so no work needs to be done 05251 // for it. 05252 // 05253 // 2. The file handle is returned to the user. 05254 // 05255 // 3. The I/O status block is written with the final status. 05256 // 05257 05258 openPacket.FileObject->Flags |= FO_HANDLE_CREATED; 05259 05260 ASSERT( openPacket.FileObject->Type == IO_TYPE_FILE ); 05261 05262 try { 05263 05264 // 05265 // Return the file handle. 05266 // 05267 05268 *FileHandle = handle; 05269 05270 // 05271 // Write the I/O status into the caller's buffer. 05272 // 05273 05274 IoStatusBlock->Information = openPacket.Information; 05275 IoStatusBlock->Status = openPacket.FinalStatus; 05276 status = openPacket.FinalStatus; 05277 05278 } except(EXCEPTION_EXECUTE_HANDLER) { 05279 05280 status = GetExceptionCode(); 05281 05282 } 05283 05284 } 05285 05286 // 05287 // If the parse routine successfully created a file object then 05288 // derefence it here. 05289 // 05290 05291 if (SuccessfulIoParse && openPacket.FileObject != NULL) { 05292 ObDereferenceObject( openPacket.FileObject ); 05293 } 05294 05295 return status; 05296 }

NTKERNELAPI PKEVENT IoCreateNotificationEvent IN PUNICODE_STRING  EventName,
OUT PHANDLE  EventHandle
 

Definition at line 5299 of file iosubs.c.

References EventHandle, EventName, ExEventObjectType, KernelMode, NT_SUCCESS, NTSTATUS(), NULL, ObDereferenceObject, ObReferenceObjectByHandle(), PAGED_CODE, TRUE, and VOID().

05306 : 05307 05308 This routine creates a named notification event for use in notifying 05309 different system components or drivers that an event occurred. 05310 05311 Arguments: 05312 05313 EventName - Supplies the full name of the event. 05314 05315 EventHandle - Supplies a location to return a handle to the event. 05316 05317 Return Value: 05318 05319 The function value is a pointer to the created/opened event, or NULL if 05320 the event could not be created/opened. 05321 05322 --*/ 05323 05324 { 05325 OBJECT_ATTRIBUTES objectAttributes; 05326 NTSTATUS status; 05327 HANDLE eventHandle; 05328 PKEVENT eventObject; 05329 05330 PAGED_CODE(); 05331 05332 // 05333 // Begin by initializing the object attributes. 05334 // 05335 05336 InitializeObjectAttributes( &objectAttributes, 05337 EventName, 05338 OBJ_OPENIF, 05339 (HANDLE) NULL, 05340 (PSECURITY_DESCRIPTOR) NULL ); 05341 05342 // 05343 // Now create or open the event. 05344 // 05345 05346 status = ZwCreateEvent( &eventHandle, 05347 EVENT_ALL_ACCESS, 05348 &objectAttributes, 05349 NotificationEvent, 05350 TRUE ); 05351 if (!NT_SUCCESS( status )) { 05352 return (PKEVENT) NULL; 05353 } 05354 05355 // 05356 // Reference the object by its handle to get a pointer that can be returned 05357 // to the caller. 05358 // 05359 05360 (VOID) ObReferenceObjectByHandle( eventHandle, 05361 0, 05362 ExEventObjectType, 05363 KernelMode, 05364 (PVOID *) &eventObject, 05365 NULL ); 05366 ObDereferenceObject( eventObject ); 05367 05368 // 05369 // Return the handle and the pointer to the event. 05370 // 05371 05372 *EventHandle = eventHandle; 05373 05374 return eventObject; 05375 }

NTKERNELAPI PFILE_OBJECT IoCreateStreamFileObject IN PFILE_OBJECT FileObject  OPTIONAL,
IN PDEVICE_OBJECT DeviceObject  OPTIONAL
 

Definition at line 5378 of file iosubs.c.

References ASSERT, ExInterlockedAddUlong(), ExRaiseStatus(), FALSE, FILE_OBJECT, FO_HANDLE_CREATED, FO_STREAM_FILE, IO_TYPE_FILE, IoFileObjectType, IopDatabaseLock, IopDecrementDeviceObjectRef(), IopVpbSpinLock, KeInitializeEvent, KernelMode, NT_SUCCESS, NtClose(), NTSTATUS(), NULL, ObCreateObject(), ObInsertObject(), and PAGED_CODE.

Referenced by UdfCreateInternalStream().

05385 : 05386 05387 This routine is invoked to create a new file object that represents an 05388 alternate data stream for an existing file object. The input file object 05389 represents the file object that already exists for a file, and the newly 05390 created stream file object is used to access other parts of the file 05391 other than the data. Some uses of stream file objects are the EAs or 05392 the SECURITY_DESCRIPTORs on the file. The stream file object allows 05393 the file system to cache these parts of the file just as if they were 05394 an entire to themselves. 05395 05396 It is also possible to use stream file objects to represent virtual 05397 volume files. This allows various parts of the on-disk structure to 05398 be viewed as a virtual file and therefore be cached using the same logic 05399 in the file system. For this case, the device object pointer is used 05400 to create the file object. 05401 05402 Arguments: 05403 05404 FileObject - Pointer to the file object to which the new stream file 05405 is related. This pointer is optional. 05406 05407 DeviceObject - Pointer to the device object on which the stream file 05408 is to be opened. This pointer is not optional if the FileObject 05409 pointer is not specified. 05410 05411 Return Value: 05412 05413 The function value is a pointer to the newly created stream file object. 05414 05415 --*/ 05416 05417 { 05418 PFILE_OBJECT newFileObject; 05419 OBJECT_ATTRIBUTES objectAttributes; 05420 HANDLE handle; 05421 NTSTATUS status; 05422 05423 PAGED_CODE(); 05424 05425 // 05426 // Begin by getting the device object from either the file object or 05427 // the device object parameter. 05428 // 05429 05430 if (ARGUMENT_PRESENT( FileObject )) { 05431 DeviceObject = FileObject->DeviceObject; 05432 } 05433 05434 // 05435 // Increment the reference count for the target device object. Note 05436 // that no check is made to determine whether or not the device driver 05437 // is attempting to unload since this is an implicit open of a pseudo- 05438 // file that is being made, not a real file open request. In essence, 05439 // no new file is really being opened. 05440 // 05441 05442 ExInterlockedAddUlong( &DeviceObject->ReferenceCount, 1, &IopDatabaseLock ); 05443 05444 // 05445 // Initialize the object attributes that will be used to create the file 05446 // object. 05447 // 05448 05449 InitializeObjectAttributes( &objectAttributes, 05450 (PUNICODE_STRING) NULL, 05451 0, 05452 (HANDLE) NULL, 05453 (PSECURITY_DESCRIPTOR) NULL ); 05454 05455 // 05456 // Create the new file object. 05457 // 05458 05459 status = ObCreateObject( KernelMode, 05460 IoFileObjectType, 05461 &objectAttributes, 05462 0, 05463 (PVOID) NULL, 05464 (ULONG) sizeof( FILE_OBJECT ), 05465 (ULONG) sizeof( FILE_OBJECT ), 05466 0, 05467 (PVOID *) &newFileObject ); 05468 05469 if (!NT_SUCCESS( status )) { 05470 IopDecrementDeviceObjectRef( DeviceObject, FALSE ); 05471 ExRaiseStatus( status ); 05472 } 05473 05474 // 05475 // Initialize the common fields of the file object. 05476 // 05477 05478 RtlZeroMemory( newFileObject, sizeof( FILE_OBJECT ) ); 05479 newFileObject->Type = IO_TYPE_FILE; 05480 newFileObject->Size = sizeof( FILE_OBJECT ); 05481 newFileObject->DeviceObject = DeviceObject; 05482 newFileObject->Flags = FO_STREAM_FILE; 05483 KeInitializeEvent( &newFileObject->Event, SynchronizationEvent, FALSE ); 05484 05485 // 05486 // Insert the device object into the table. Note that this is done w/a 05487 // pointer bias so that the object cannot go away if some random user 05488 // application closes the handle before this code is finished w/it. 05489 // 05490 05491 status = ObInsertObject( newFileObject, 05492 NULL, 05493 FILE_READ_DATA, 05494 1, 05495 (PVOID *) &newFileObject, 05496 &handle ); 05497 05498 if (!NT_SUCCESS( status )) { 05499 ExRaiseStatus( status ); 05500 } 05501 05502 // 05503 // The insert completed successfully. Update the bookkeeping so that the 05504 // fact that there is a handle is reflected. 05505 // 05506 05507 newFileObject->Flags |= FO_HANDLE_CREATED; 05508 ASSERT( newFileObject->Type == IO_TYPE_FILE ); 05509 05510 // 05511 // Synchronize here with the file system to make sure that 05512 // volumes don't go away while en route to the FS. 05513 // 05514 05515 if (DeviceObject->Vpb) { 05516 05517 ExInterlockedAddUlong( &DeviceObject->Vpb->ReferenceCount, 05518 1, 05519 &IopVpbSpinLock ); 05520 } 05521 05522 // 05523 // Finally, close the handle to the file. and clear the forward cluster 05524 // 05525 05526 status = NtClose( handle ); 05527 05528 ASSERT( NT_SUCCESS( status ) ); 05529 05530 return newFileObject; 05531 }

NTKERNELAPI PFILE_OBJECT IoCreateStreamFileObjectLite IN PFILE_OBJECT FileObject  OPTIONAL,
IN PDEVICE_OBJECT DeviceObject  OPTIONAL
 

Definition at line 5535 of file iosubs.c.

References ASSERT, ExInterlockedAddUlong(), ExRaiseStatus(), FALSE, FILE_OBJECT, FO_HANDLE_CREATED, FO_STREAM_FILE, IO_TYPE_FILE, IoFileObjectType, IopDatabaseLock, IopDecrementDeviceObjectRef(), IopVpbSpinLock, KeInitializeEvent, KernelMode, NT_SUCCESS, NTSTATUS(), NULL, ObCreateObject(), ObFreeObjectCreateInfoBuffer(), OBJECT_TO_OBJECT_HEADER, and PAGED_CODE.

Referenced by IopInvalidateVolumesForDevice().

05542 : 05543 05544 This routine is invoked to create a new file object that represents an 05545 alternate data stream for an existing file object. The input file object 05546 represents the file object that already exists for a file, and the newly 05547 created stream file object is used to access other parts of the file 05548 other than the data. Some uses of stream file objects are the EAs or 05549 the SECURITY_DESCRIPTORs on the file. The stream file object allows 05550 the file system to cache these parts of the file just as if they were 05551 an entire to themselves. 05552 05553 It is also possible to use stream file objects to represent virtual 05554 volume files. This allows various parts of the on-disk structure to 05555 be viewed as a virtual file and therefore be cached using the same logic 05556 in the file system. For this case, the device object pointer is used 05557 to create the file object. 05558 05559 This call differs from IoCreateStreamFileObject in that it performs no 05560 handle management and does not result in a call to the file system 05561 cleanup entry. 05562 05563 Arguments: 05564 05565 FileObject - Pointer to the file object to which the new stream file 05566 is related. This pointer is optional. 05567 05568 DeviceObject - Pointer to the device object on which the stream file 05569 is to be opened. This pointer is not optional if the FileObject 05570 pointer is not specified. 05571 05572 Return Value: 05573 05574 The function value is a pointer to the newly created stream file object. 05575 05576 --*/ 05577 05578 { 05579 PFILE_OBJECT newFileObject; 05580 OBJECT_ATTRIBUTES objectAttributes; 05581 HANDLE handle; 05582 NTSTATUS status; 05583 05584 PAGED_CODE(); 05585 05586 // 05587 // Begin by getting the device object from either the file object or 05588 // the device object parameter. 05589 // 05590 05591 if (ARGUMENT_PRESENT( FileObject )) { 05592 DeviceObject = FileObject->DeviceObject; 05593 } 05594 05595 // 05596 // if the driver has been marked for an unload or deleted operation, and 05597 // the reference count goes to zero, then the driver may need to be 05598 // unloaded or deleted at this point. 05599 // file that is being made, not a real file open request. In essence, 05600 // no new file is really being opened. 05601 // 05602 05603 ExInterlockedAddUlong( &DeviceObject->ReferenceCount, 1, &IopDatabaseLock ); 05604 05605 // 05606 // Initialize the object attributes that will be used to create the file 05607 // object. 05608 // 05609 05610 InitializeObjectAttributes( &objectAttributes, 05611 (PUNICODE_STRING) NULL, 05612 0, 05613 (HANDLE) NULL, 05614 (PSECURITY_DESCRIPTOR) NULL ); 05615 05616 // 05617 // Create the new file object. 05618 // 05619 05620 status = ObCreateObject( KernelMode, 05621 IoFileObjectType, 05622 &objectAttributes, 05623 0, 05624 (PVOID) NULL, 05625 (ULONG) sizeof( FILE_OBJECT ), 05626 (ULONG) sizeof( FILE_OBJECT ), 05627 0, 05628 (PVOID *) &newFileObject ); 05629 05630 if (!NT_SUCCESS( status )) { 05631 IopDecrementDeviceObjectRef( DeviceObject, FALSE ); 05632 ExRaiseStatus( status ); 05633 } 05634 05635 // 05636 // Initialize the common fields of the file object. 05637 // 05638 05639 RtlZeroMemory( newFileObject, sizeof( FILE_OBJECT ) ); 05640 newFileObject->Type = IO_TYPE_FILE; 05641 newFileObject->Size = sizeof( FILE_OBJECT ); 05642 newFileObject->DeviceObject = DeviceObject; 05643 newFileObject->Flags = FO_STREAM_FILE; 05644 KeInitializeEvent( &newFileObject->Event, SynchronizationEvent, FALSE ); 05645 05646 // 05647 // Clean up from the creation. 05648 // 05649 05650 ObFreeObjectCreateInfoBuffer(OBJECT_TO_OBJECT_HEADER(newFileObject)->ObjectCreateInfo); 05651 OBJECT_TO_OBJECT_HEADER(newFileObject)->ObjectCreateInfo = NULL; 05652 05653 newFileObject->Flags |= FO_HANDLE_CREATED; 05654 ASSERT( newFileObject->Type == IO_TYPE_FILE ); 05655 05656 // 05657 // Synchronize here with the file system to make sure that 05658 // volumes don't go away while en route to the FS. 05659 // 05660 05661 if (DeviceObject->Vpb) { 05662 05663 ExInterlockedAddUlong( &DeviceObject->Vpb->ReferenceCount, 05664 1, 05665 &IopVpbSpinLock ); 05666 } 05667 05668 return newFileObject; 05669 }

NTKERNELAPI NTSTATUS IoCreateSymbolicLink IN PUNICODE_STRING  SymbolicLinkName,
IN PUNICODE_STRING  DeviceName
 

Definition at line 5675 of file iosubs.c.

References NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, and SePublicDefaultUnrestrictedSd.

Referenced by FsRtlpSetSymbolicLink(), HalpNextDriveLetter(), IopAssignNetworkDriveLetter(), IopCreateArcNames(), IopProcessSetInterfaceState(), and xHalIoAssignDriveLetters().

05682 : 05683 05684 This routine is invoked to assign a symbolic link name to a device. 05685 05686 Arguments: 05687 05688 SymbolicLinkName - Supplies the symbolic link name as a Unicode string. 05689 05690 DeviceName - Supplies the name to which the symbolic link name refers. 05691 05692 Return Value: 05693 05694 The function value is the final status of the operation. 05695 05696 --*/ 05697 05698 { 05699 OBJECT_ATTRIBUTES objectAttributes; 05700 HANDLE linkHandle; 05701 NTSTATUS status; 05702 05703 PAGED_CODE(); 05704 05705 // 05706 // Begin by initializing the object attributes for the symbolic link. 05707 // 05708 05709 InitializeObjectAttributes( &objectAttributes, 05710 SymbolicLinkName, 05711 OBJ_PERMANENT | OBJ_CASE_INSENSITIVE, 05712 (HANDLE) NULL, 05713 SePublicDefaultUnrestrictedSd ); 05714 05715 // 05716 // Note that the following assignment can fail (because it is not system 05717 // initialization time and therefore the \ARCname directory does not 05718 // exist - if this is really a call to IoAssignArcName), but that is fine. 05719 // 05720 05721 status = ZwCreateSymbolicLinkObject( &linkHandle, 05722 SYMBOLIC_LINK_ALL_ACCESS, 05723 &objectAttributes, 05724 DeviceName ); 05725 if (NT_SUCCESS( status )) { 05726 ZwClose( linkHandle ); 05727 } 05728 05729 return status; 05730 }

NTKERNELAPI PKEVENT IoCreateSynchronizationEvent IN PUNICODE_STRING  EventName,
OUT PHANDLE  EventHandle
 

Definition at line 5733 of file iosubs.c.

References EventHandle, EventName, ExEventObjectType, KernelMode, NT_SUCCESS, NTSTATUS(), NULL, ObDereferenceObject, ObReferenceObjectByHandle(), PAGED_CODE, TRUE, and VOID().

05740 : 05741 05742 This routine creates a named synchronization event for use in serialization 05743 of access to hardware between two otherwise non-related drivers. The event 05744 is created if it does not already exist, otherwise it is simply opened. 05745 05746 Arguments: 05747 05748 EventName - Supplies the full name of the event. 05749 05750 EventHandle - Supplies a location to return a handle to the event. 05751 05752 Return Value: 05753 05754 The function value is a pointer to the created/opened event, or NULL if 05755 the event could not be created/opened. 05756 05757 --*/ 05758 05759 { 05760 OBJECT_ATTRIBUTES objectAttributes; 05761 NTSTATUS status; 05762 HANDLE eventHandle; 05763 PKEVENT eventObject; 05764 05765 PAGED_CODE(); 05766 05767 // 05768 // Begin by initializing the object attributes. 05769 // 05770 05771 InitializeObjectAttributes( &objectAttributes, 05772 EventName, 05773 OBJ_OPENIF, 05774 (HANDLE) NULL, 05775 (PSECURITY_DESCRIPTOR) NULL ); 05776 05777 // 05778 // Now create or open the event. 05779 // 05780 05781 status = ZwCreateEvent( &eventHandle, 05782 EVENT_ALL_ACCESS, 05783 &objectAttributes, 05784 SynchronizationEvent, 05785 TRUE ); 05786 if (!NT_SUCCESS( status )) { 05787 return (PKEVENT) NULL; 05788 } 05789 05790 // 05791 // Reference the object by its handle to get a pointer that can be returned 05792 // to the caller. 05793 // 05794 05795 (VOID) ObReferenceObjectByHandle( eventHandle, 05796 0, 05797 ExEventObjectType, 05798 KernelMode, 05799 (PVOID *) &eventObject, 05800 NULL ); 05801 ObDereferenceObject( eventObject ); 05802 05803 // 05804 // Return the handle and the pointer to the event. 05805 // 05806 05807 *EventHandle = eventHandle; 05808 05809 return eventObject; 05810 }

NTKERNELAPI NTSTATUS IoCreateUnprotectedSymbolicLink IN PUNICODE_STRING  SymbolicLinkName,
IN PUNICODE_STRING  DeviceName
 

Definition at line 5813 of file iosubs.c.

References NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, RtlCreateSecurityDescriptor(), RtlSetDaclSecurityDescriptor(), and TRUE.

05820 : 05821 05822 This routine is invoked to assign an unprotected symbolic link name to 05823 a device. That is, a symbolic link that can be dynamically reassigned 05824 without any special authorization. 05825 05826 05827 NOTE: This routine will NOT over-ride inheritable protection that 05828 the symbolic link might pick up. It simply prevents the caller's 05829 default token protection from being assigned. 05830 05831 05832 Arguments: 05833 05834 SymbolicLinkName - Supplies the symbolic link name as a Unicode string. 05835 05836 DeviceName - Supplies the name to which the symbolic link name refers. 05837 05838 Return Value: 05839 05840 The function value is the final status of the operation. 05841 05842 --*/ 05843 05844 { 05845 OBJECT_ATTRIBUTES objectAttributes; 05846 HANDLE linkHandle; 05847 NTSTATUS status; 05848 SECURITY_DESCRIPTOR securityDescriptor; 05849 05850 PAGED_CODE(); 05851 05852 // 05853 // Create a security descriptor that has all access. 05854 // 05855 05856 status = RtlCreateSecurityDescriptor( &securityDescriptor, 05857 SECURITY_DESCRIPTOR_REVISION1 ); 05858 if (!NT_SUCCESS( status )) { 05859 return status; 05860 } 05861 05862 status = RtlSetDaclSecurityDescriptor ( &securityDescriptor, 05863 TRUE, 05864 NULL, 05865 TRUE ); //does not over-ride inheritable protection 05866 if (!NT_SUCCESS( status )) { 05867 return status; 05868 } 05869 05870 // 05871 // Initialize the object attributes for the symbolic link. 05872 // 05873 05874 InitializeObjectAttributes( &objectAttributes, 05875 SymbolicLinkName, 05876 OBJ_PERMANENT | OBJ_CASE_INSENSITIVE, 05877 (HANDLE) NULL, 05878 &securityDescriptor ); 05879 05880 // 05881 // Note that the following assignment can fail (because it is not system 05882 // initialization time and therefore the \ARCname directory does not 05883 // exist - if this is really a call to IoAssignArcName), but that is fine. 05884 // 05885 05886 status = ZwCreateSymbolicLinkObject( &linkHandle, 05887 SYMBOLIC_LINK_ALL_ACCESS, 05888 &objectAttributes, 05889 DeviceName ); 05890 if (NT_SUCCESS( status )) { 05891 ZwClose( linkHandle ); 05892 } 05893 05894 return status; 05895 }

NTKERNELAPI VOID IoDeleteController IN PCONTROLLER_OBJECT  ControllerObject  ) 
 

Definition at line 5898 of file iosubs.c.

References ObDereferenceObject, and PAGED_CODE.

05904 : 05905 05906 This routine deletes the specified controller object from the system 05907 so that it may no longer be referenced from a driver. It is invoked 05908 when either the driver is being unloaded from the system, or the driver's 05909 initialization routine failed to properly initialize the device or a 05910 fatal driver initialization error was encountered. 05911 05912 Arguments: 05913 05914 ControllerObject - Pointer to the controller object that is to be 05915 deleted. 05916 05917 Return Value: 05918 05919 None. 05920 05921 --*/ 05922 05923 { 05924 PAGED_CODE(); 05925 05926 // 05927 // The controller was created as a temporary object, and all of the 05928 // handles for the object have already been closed. At this point, 05929 // simply dereferencing the object will cause it to be deleted. 05930 // 05931 05932 ObDereferenceObject( ControllerObject ); 05933 }

NTKERNELAPI VOID IoDeleteDevice IN PDEVICE_OBJECT  DeviceObject  ) 
 

Definition at line 5951 of file iosubs.c.

References DO_DEVICE_HAS_NAME, DO_SHUTDOWN_REGISTERED, DOE_DELETE_PENDING, ExFreePool(), IopCompleteUnloadOrDelete(), IopDatabaseLock, IopRemoveTimerFromTimerList(), IoUnregisterShutdownNotification(), IOV_DELETE_DEVICE, ObMakeTemporaryObject(), and PoRunDownDeviceObject().

Referenced by DriverEntry(), FsRecUnload(), IopDeleteLegacyKey(), IopDriverLoadingFailed(), IopFindLegacyDeviceNode(), IopInitializeDeviceInstanceKey(), IopInitializePlugPlayServices(), IopRemoveLegacyDeviceNode(), IoReportDetectedDevice(), UdfDeleteVcb(), and UdfMountVolume().

05957 : 05958 05959 This routine deletes the specified device object from the system so that 05960 it may no longer be referenced. It is invoked when either the device 05961 driver is being unloaded from the system, or the driver's initialization 05962 routine failed to properly initialize the device or a fatal driver 05963 initialization error was encountered, or when the device is being removed 05964 from the system. 05965 05966 Arguments: 05967 05968 DeviceObject - Pointer to the device object that is to be deleted. 05969 05970 Return Value: 05971 05972 None. 05973 05974 --*/ 05975 05976 { 05977 KIRQL irql; 05978 05979 IOV_DELETE_DEVICE(DeviceObject); 05980 05981 // 05982 // Check to see whether or not the device has registered a shutdown 05983 // handler if necessary, and if so, unregister it. 05984 // 05985 05986 if (DeviceObject->Flags & DO_SHUTDOWN_REGISTERED) { 05987 IoUnregisterShutdownNotification( DeviceObject ); 05988 } 05989 05990 // 05991 // Release the pool that was allocated to contain the timer dispatch 05992 // routine and its associated context if there was one. 05993 // 05994 05995 if (DeviceObject->Timer) { 05996 PIO_TIMER timer; 05997 05998 timer = DeviceObject->Timer; 05999 IopRemoveTimerFromTimerList(timer); 06000 ExFreePool( timer ); 06001 } 06002 06003 // 06004 // If this device has a name, then mark the 06005 // object as temporary so that when it is dereferenced it will be 06006 // deleted. 06007 // 06008 06009 if (DeviceObject->Flags & DO_DEVICE_HAS_NAME) { 06010 ObMakeTemporaryObject( DeviceObject ); 06011 } 06012 06013 // 06014 // PoRunDownDeviceObject will clean up any power management 06015 // structures attached to the device object. 06016 // 06017 06018 PoRunDownDeviceObject(DeviceObject); 06019 06020 // 06021 // Mark the device object as deleted. 06022 // 06023 06024 ExAcquireSpinLock( &IopDatabaseLock, &irql ); 06025 06026 DeviceObject->DeviceObjectExtension->ExtensionFlags |= DOE_DELETE_PENDING; 06027 06028 if (!DeviceObject->ReferenceCount) { 06029 IopCompleteUnloadOrDelete( DeviceObject, irql ); 06030 } else { 06031 ExReleaseSpinLock( &IopDatabaseLock, irql ); 06032 } 06033 }

NTKERNELAPI VOID IoDeleteDriver IN PDRIVER_OBJECT  DriverObject  ) 
 

Definition at line 1264 of file pnpioapi.c.

References ObDereferenceObject.

Referenced by IopInitializePlugPlayServices().

01269 : 01270 01271 This routine deletes a driver object created explicitly through 01272 IoCreateDriver. 01273 01274 Parameters: 01275 01276 DriverObject - Supplies a pointer to the driver object to be deleted. 01277 01278 ReturnValue: 01279 01280 Status code that indicates whether or not the function was successful. 01281 01282 Notes: 01283 01284 --*/ 01285 { 01286 01287 ObDereferenceObject(DriverObject); 01288 }

NTKERNELAPI NTSTATUS IoDeleteSymbolicLink IN PUNICODE_STRING  SymbolicLinkName  ) 
 

Definition at line 6227 of file iosubs.c.

References ExVerifySuite(), IopDeleteSessionSymLinks(), NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, and TRUE.

Referenced by FsRtlpSetSymbolicLink(), and IopProcessSetInterfaceState().

06233 : 06234 06235 This routine is invoked to remove a symbolic link from the system. This 06236 generally occurs whenever a driver that has assigned a symbolic link needs 06237 to exit. It can also be used when a driver no longer needs to redirect 06238 a name. 06239 06240 Arguments: 06241 06242 SymbolicLinkName - Provides the Unicode name string to be deassigned. 06243 06244 Return Values: 06245 06246 None. 06247 06248 --*/ 06249 06250 { 06251 OBJECT_ATTRIBUTES objectAttributes; 06252 HANDLE linkHandle; 06253 NTSTATUS status; 06254 06255 PAGED_CODE(); 06256 06257 // 06258 // Begin by initializing the object attributes for the symbolic link. 06259 // 06260 06261 InitializeObjectAttributes( &objectAttributes, 06262 SymbolicLinkName, 06263 OBJ_CASE_INSENSITIVE, 06264 (HANDLE) NULL, 06265 (PSECURITY_DESCRIPTOR) NULL ); 06266 06267 // 06268 // Open the symbolic link itself so that it can be marked temporary and 06269 // closed. 06270 // 06271 06272 status = ZwOpenSymbolicLinkObject( &linkHandle, 06273 DELETE, 06274 &objectAttributes ); 06275 if (NT_SUCCESS( status )) { 06276 06277 // 06278 // The symbolic link was successfully opened. Attempt to make it a 06279 // temporary object, and then close the handle. This will cause the 06280 // object to go away. 06281 // 06282 06283 status = ZwMakeTemporaryObject( linkHandle ); 06284 if (NT_SUCCESS( status )) { 06285 ZwClose( linkHandle ); 06286 } 06287 06288 if (ExVerifySuite(TerminalServer) == TRUE) { 06289 IopDeleteSessionSymLinks( SymbolicLinkName ); 06290 } 06291 } 06292 06293 06294 return status; 06295 }

NTKERNELAPI VOID IoDetachDevice IN OUT PDEVICE_OBJECT  TargetDevice  ) 
 

Definition at line 6298 of file iosubs.c.

References ASSERT, _DEVICE_OBJECT::AttachedDevice, _DEVOBJ_EXTENSION::AttachedTo, _DEVICE_OBJECT::DeviceObjectExtension, DOE_DELETE_PENDING, DOE_REMOVE_PENDING, DOE_UNLOAD_PENDING, IopCompleteUnloadOrDelete(), IopDatabaseLock, IOV_DETACH_DEVICE, and NULL.

06304 : 06305 06306 This routine detaches the device object which is currently attached to the 06307 target device. 06308 06309 Arguments: 06310 06311 TargetDevice - Pointer to device object to be detached from. 06312 06313 Return Value: 06314 06315 None. 06316 06317 06318 --*/ 06319 06320 { 06321 KIRQL irql; 06322 PDEVICE_OBJECT detachingDevice; 06323 PDEVOBJ_EXTENSION detachingExtension; 06324 06325 // 06326 // Detach the device object attached to the target device. This also 06327 // includes decrementing the reference count for the device. Note that 06328 // if the driver has been marked for an unload operation, and the 06329 // reference count goes to zero, then the driver may need to be unloaded 06330 // at this point. 06331 // 06332 06333 ExAcquireSpinLock( &IopDatabaseLock, &irql ); 06334 06335 // 06336 // Tell the Special IRP code the stack has changed. Code that will reexamine 06337 // the stack takes the database lock, so we can place the call here. This 06338 // also allows us to assert correct behavoir *before* the stack is torn 06339 // down. 06340 // 06341 IOV_DETACH_DEVICE(TargetDevice); 06342 06343 detachingDevice = TargetDevice->AttachedDevice; 06344 detachingExtension = detachingDevice->DeviceObjectExtension; 06345 ASSERT( detachingExtension->AttachedTo == TargetDevice ); 06346 06347 // 06348 // Unlink the device from the doubly-linked attachment chain. 06349 // 06350 06351 detachingExtension->AttachedTo = NULL; 06352 TargetDevice->AttachedDevice = NULL; 06353 06354 if (TargetDevice->DeviceObjectExtension->ExtensionFlags & 06355 (DOE_UNLOAD_PENDING | DOE_DELETE_PENDING | DOE_REMOVE_PENDING) && 06356 !TargetDevice->ReferenceCount) { 06357 IopCompleteUnloadOrDelete( TargetDevice, irql ); 06358 } else { 06359 ExReleaseSpinLock( &IopDatabaseLock, irql ); 06360 } 06361 }

NTKERNELAPI VOID IoDisconnectInterrupt IN PKINTERRUPT  InterruptObject  ) 
 

Definition at line 6364 of file iosubs.c.

References ExFreePool(), _IO_INTERRUPT_STRUCTURE::InterruptArray, InterruptObject, _IO_INTERRUPT_STRUCTURE::InterruptObject, KeDisconnectInterrupt(), MAXIMUM_PROCESSORS, NULL, and PAGED_CODE.

Referenced by IoConnectInterrupt().

06370 : 06371 06372 This routine disconnects all of the interrupt objects that were 06373 initialized and connected by the IoConnectInterrupt routine. Note 06374 that no interrupt objects directly connected using the kernel 06375 services may be input to this routine. 06376 06377 Arguments: 06378 06379 InterruptObject - Supplies a pointer to the interrupt object allocated 06380 by the IoConnectInterrupt routine. 06381 06382 Return Value: 06383 06384 None. 06385 06386 --*/ 06387 06388 { 06389 PIO_INTERRUPT_STRUCTURE interruptStructure; 06390 ULONG i; 06391 06392 PAGED_CODE(); 06393 06394 // 06395 // Obtain a pointer to the builtin interrupt object in the I/O interrupt 06396 // structure. 06397 // 06398 06399 interruptStructure = CONTAINING_RECORD( InterruptObject, 06400 IO_INTERRUPT_STRUCTURE, 06401 InterruptObject ); 06402 06403 // 06404 // The builtin interrupt object is always used, so simply disconnect 06405 // it. 06406 // 06407 06408 KeDisconnectInterrupt( &interruptStructure->InterruptObject ); 06409 06410 // 06411 // Now loop through each of the interrupt objects pointed to by the 06412 // structure and disconnect each. 06413 // 06414 06415 for (i = 0; i < MAXIMUM_PROCESSORS; i++) { 06416 if (interruptStructure->InterruptArray[i] != NULL) { 06417 KeDisconnectInterrupt( interruptStructure->InterruptArray[i] ); 06418 } 06419 } 06420 06421 // 06422 // Finally, deallocate the memory associated with the entire structure. 06423 // 06424 06425 ExFreePool( interruptStructure ); 06426 }

NTKERNELAPI VOID IoEnqueueIrp IN PIRP  Irp  ) 
 

Definition at line 6429 of file iosubs.c.

References IopQueueThreadIrp, Irp, and PAGED_CODE.

06435 : 06436 06437 This routine enqueues the specified I/O Request Packet (IRP) to the thread's 06438 IRP pending queue. The thread that the IRP is queued to is specified by 06439 the IRP's Thread field. 06440 06441 Arguments: 06442 06443 Irp - Supplies a pointer to the IRP to be enqueued. 06444 06445 Return Value: 06446 06447 None. 06448 06449 --*/ 06450 06451 { 06452 PAGED_CODE(); 06453 06454 // 06455 // Simply enqueue the IRP to the thread's IRP queue. 06456 // 06457 06458 IopQueueThreadIrp( Irp ); 06459 return; 06460 }

NTKERNELAPI BOOLEAN IoFastQueryNetworkAttributes IN POBJECT_ATTRIBUTES  ObjectAttributes,
IN ACCESS_MASK  DesiredAccess,
IN ULONG  OpenOptions,
OUT PIO_STATUS_BLOCK  IoStatus,
OUT PFILE_NETWORK_OPEN_INFORMATION  Buffer
 

Definition at line 6463 of file iosubs.c.

References Buffer, _OPEN_PACKET::CreateOptions, _OPEN_PACKET::Disposition, _OPEN_PACKET::FinalStatus, _OPEN_PACKET::FullAttributes, _OPEN_PACKET::Information, IO_FORCE_ACCESS_CHECK, IO_TYPE_OPEN_PACKET, KernelMode, _OPEN_PACKET::LocalFileObject, _OPEN_PACKET::NetworkInformation, NTSTATUS(), NULL, ObjectAttributes, ObOpenObjectByName(), OPEN_PACKET, OPEN_PACKET_PATTERN, _OPEN_PACKET::Options, _OPEN_PACKET::ParseCheck, _OPEN_PACKET::QueryOnly, _OPEN_PACKET::ShareAccess, _OPEN_PACKET::Size, TRUE, and _OPEN_PACKET::Type.

06473 : 06474 06475 This routine attempts to perform a fast I/O call to obtain the network 06476 attributes for a file. This involves a specialized interface between 06477 this function and the I/O system's device parse method. This allows the 06478 parse method to have the file system pseudo-open the file, obtain the 06479 appropriate attributes for the file, and return them to the caller w/as 06480 little overhead as possbile from either the Object Manager or the I/O 06481 system itself. 06482 06483 Arguments: 06484 06485 ObjectAttributes - Supplies the attributes to be used for opening the 06486 file (e.g., the file's name, etc). 06487 06488 DesiredAccess - Supplies the type(s) of access that the caller would like 06489 to the file. 06490 06491 OpenOptions - Supplies standard NtOpenFile open options. 06492 06493 IoStatus - Supplies a pointer to a variable to receive the final status 06494 of the operation. 06495 06496 Buffer - Supplies an output buffer to receive the network attributes for 06497 the specified file. 06498 06499 Return Value: 06500 06501 The final function value indicates whether or not the fast path could 06502 be taken successfully. 06503 06504 --*/ 06505 06506 { 06507 HANDLE handle; 06508 NTSTATUS status; 06509 OPEN_PACKET openPacket; 06510 DUMMY_FILE_OBJECT localFileObject; 06511 06512 // 06513 // Build a parse open packet that tells the parse method to open the 06514 // file and query its network attributes using the fast path, if it 06515 // exists for this file. 06516 // 06517 06518 RtlZeroMemory( &openPacket, sizeof( OPEN_PACKET ) ); 06519 06520 openPacket.Type = IO_TYPE_OPEN_PACKET; 06521 openPacket.Size = sizeof( OPEN_PACKET ); 06522 openPacket.ShareAccess = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; 06523 openPacket.Disposition = FILE_OPEN; 06524 openPacket.CreateOptions = OpenOptions | FILE_OPEN_REPARSE_POINT; 06525 openPacket.Options = IO_FORCE_ACCESS_CHECK; 06526 openPacket.NetworkInformation = Buffer; 06527 openPacket.QueryOnly = TRUE; 06528 openPacket.FullAttributes = TRUE; 06529 openPacket.LocalFileObject = &localFileObject; 06530 06531 // 06532 // Open the object by its name. Because of the special QueryOnly flag set 06533 // in the open packet, the parse routine will open the file using the fast 06534 // path open and perform the query, effectively closing it as well. 06535 // 06536 06537 status = ObOpenObjectByName( ObjectAttributes, 06538 (POBJECT_TYPE) NULL, 06539 KernelMode, 06540 NULL, 06541 DesiredAccess, 06542 &openPacket, 06543 &handle ); 06544 06545 // 06546 // The opeation is successful if the parse check field of the open packet 06547 // indicates that the parse routine was actually invoked, and the final 06548 // status field of the packet is set to success. The QueryOnly field is 06549 // set to whether or not the fast path was invoked. 06550 // 06551 06552 if (openPacket.ParseCheck != OPEN_PACKET_PATTERN) { 06553 06554 // 06555 // The parse routine was not invoked properly so the operation did 06556 // not work at all. 06557 // 06558 06559 IoStatus->Status = status; 06560 } else { 06561 06562 // 06563 // The fast path routine was successfully invoked so return the 06564 // final status of the operation. 06565 // 06566 06567 IoStatus->Status = openPacket.FinalStatus; 06568 IoStatus->Information = openPacket.Information; 06569 } 06570 return TRUE; 06571 }

NTKERNELAPI NTSTATUS FASTCALL IofCallDriver IN PDEVICE_OBJECT  DeviceObject,
IN OUT PIRP  Irp
 

Definition at line 2135 of file iosubs.c.

References Irp, and pIofCallDriver.

Referenced by IoCallDriver().

02139 { 02140 // 02141 // This routine will either jump immediately to IopfCallDriver, or rather 02142 // IovCallDriver. 02143 // 02144 return pIofCallDriver(DeviceObject, Irp); 02145 }

NTKERNELAPI VOID FASTCALL IofCompleteRequest IN PIRP  Irp,
IN CCHAR  PriorityBoost
 

Definition at line 3166 of file iosubs.c.

References Irp, pIofCompleteRequest, and PriorityBoost.

Referenced by IoCompleteRequest().

03170 { 03171 // 03172 // This routine will either jump immediately to IopfCompleteRequest, or 03173 // rather IovCompleteRequest. 03174 // 03175 pIofCompleteRequest(Irp, PriorityBoost); 03176 }

NTKERNELAPI VOID IoFreeController IN PCONTROLLER_OBJECT  ControllerObject  ) 
 

Definition at line 6574 of file iosubs.c.

References _DEVICE_OBJECT::CurrentIrp, DeallocateObject, IO_ALLOCATION_ACTION, KeRemoveDeviceQueue(), NULL, and _DEVICE_OBJECT::Queue.

Referenced by IoAllocateController().

06580 : 06581 06582 This routine is invoked to deallocate the specified controller object. 06583 No checks are made to ensure that the controller is really allocated 06584 to a device object. However, if it is not, then kernel will bugcheck. 06585 06586 If another device is waiting in the queue to allocate the controller 06587 object it will be pulled from the queue and its execution routine will 06588 be invoked. 06589 06590 Arguments: 06591 06592 ControllerObject - Pointer to the controller object to be deallocated. 06593 06594 Return Value: 06595 06596 None. 06597 06598 --*/ 06599 06600 { 06601 PKDEVICE_QUEUE_ENTRY packet; 06602 PDEVICE_OBJECT deviceObject; 06603 IO_ALLOCATION_ACTION action; 06604 06605 // 06606 // Simply remove the next entry from the controller's device wait queue. 06607 // If one was successfully removed, invoke its execution routine. 06608 // 06609 06610 packet = KeRemoveDeviceQueue( &ControllerObject->DeviceWaitQueue ); 06611 if (packet != NULL) { 06612 deviceObject = CONTAINING_RECORD( packet, 06613 DEVICE_OBJECT, 06614 Queue.Wcb.WaitQueueEntry ); 06615 action = deviceObject->Queue.Wcb.DeviceRoutine( deviceObject, 06616 deviceObject->CurrentIrp, 06617 0, 06618 deviceObject->Queue.Wcb.DeviceContext ); 06619 06620 // 06621 // If the execution routine wants the controller to be deallocate 06622 // now, deallocate it. 06623 // 06624 06625 if (action == DeallocateObject) { 06626 IoFreeController( ControllerObject ); 06627 } 06628 } 06629 }

NTKERNELAPI NTSTATUS IoFreeDumpRange IN PVOID  DumpContext,
IN PVOID  StartVA,
IN ULONG_PTR  Pages,
IN BOOLEAN  IsPhysicalAddress
 

Definition at line 2400 of file dumpctl.c.

References ASSERT, IoDebugPrint, IopRemovePageFromPageMap(), MmGetPhysicalAddress(), MmIsAddressValid(), PAGE_SHIFT, and PAGE_SIZE.

Referenced by MmSetKernelDumpRange().

02408 : 02409 02410 This routine excludes this range of memory in the dump. 02411 02412 Arguments: 02413 02414 DumpContext - dump context 02415 02416 StartVa - Starting VA 02417 02418 Pages - The number of pages to include 02419 02420 IsPhysicalAddress - true if direct physical address translation 02421 02422 Return Value: 02423 02424 STATUS_SUCCESS - On success. 02425 02426 NTSTATUS - Error. 02427 02428 --*/ 02429 { 02430 PCHAR Va; 02431 PRTL_BITMAP pBitMapHeader; 02432 PHYSICAL_ADDRESS phyAddr; 02433 PSUMMARY_DUMP_HEADER pHeader; 02434 02435 // 02436 // Round to page size. 02437 // 02438 02439 Va = StartVa; 02440 pHeader = (PSUMMARY_DUMP_HEADER)DumpContext; 02441 pBitMapHeader = (PRTL_BITMAP)(pHeader + 1); 02442 02443 // 02444 // Win64 can have really large page addresses. This dump code does 02445 // not handle that yet. Note that before this assert is removed 02446 // the casts of Pages to ULONG must be removed. 02447 // 02448 02449 ASSERT (Pages <= MAXULONG); 02450 02451 if (IsPhysicalAddress) { 02452 02453 phyAddr = MmGetPhysicalAddress(Va); 02454 02455 IopRemovePageFromPageMap (pHeader->BitmapSize, 02456 pBitMapHeader, 02457 (ULONG)(phyAddr.QuadPart >> PAGE_SHIFT), 02458 (ULONG) Pages 02459 ); 02460 } else { 02461 02462 while (Pages) { 02463 02464 // 02465 // Only do a translation for valid pages. 02466 // 02467 02468 if ( MmIsAddressValid (Va) ) { 02469 phyAddr = MmGetPhysicalAddress (Va); 02470 02471 IoDebugPrint((3,"IoFreeDumpRange:Va: %x Pages: %x IsPhysical: %x phyAddr %I64x\n", 02472 StartVa,Pages,IsPhysicalAddress, phyAddr.QuadPart)); 02473 02474 IopRemovePageFromPageMap (pHeader->BitmapSize, 02475 pBitMapHeader, 02476 (ULONG)(phyAddr.QuadPart >> PAGE_SHIFT), 02477 1); 02478 02479 } 02480 02481 Va += PAGE_SIZE; 02482 Pages--; 02483 } 02484 } 02485 02486 return STATUS_SUCCESS; 02487 }

VOID IoFreeDumpStack IN PDUMP_STACK_CONTEXT  DumpStack  ) 
 

Definition at line 1300 of file dumpctl.c.

References _INITIALIZATION_CONTEXT::AdapterObject, ASSERT, _INITIALIZATION_CONTEXT::CommonBuffer, DeviceUsageTypeUndefined, Event(), Executive, ExFreePool(), FALSE, _IO_STACK_LOCATION::FileObject, HalFreeCommonBuffer(), IoBuildDeviceIoControlRequest(), IoCallDriver, IoGetNextIrpStackLocation, IoGetRelatedDeviceObject(), IopSynchronousCall(), Irp, IRP_MJ_PNP, IRP_MN_DEVICE_USAGE_NOTIFICATION, KeInitializeEvent, KernelMode, KeWaitForSingleObject(), _IO_STACK_LOCATION::MajorFunction, _IO_STACK_LOCATION::MinorFunction, MmFreeContiguousMemory(), MmUnloadSystemImage(), NTSTATUS(), NULL, ObDereferenceObject, PAGED_CODE, _IO_STACK_LOCATION::Parameters, PDUMP_STACK_IMAGE, _INITIALIZATION_CONTEXT::PhysicalAddress, Status, and VOID().

Referenced by IopFreeDCB(), and IopGetDumpStack().

01305 : 01306 01307 Free the dump driver stack referenced by DumpStack 01308 01309 Arguments: 01310 01311 DumpStack - Dump driver stack being initialized 01312 01313 Return Value: 01314 01315 None 01316 01317 --*/ 01318 { 01319 PINITIALIZATION_CONTEXT DumpInit; 01320 PDUMP_STACK_IMAGE DumpImage; 01321 PDEVICE_OBJECT DeviceObject; 01322 PIO_STACK_LOCATION IrpSp; 01323 IO_STATUS_BLOCK IoStatus; 01324 PIRP Irp; 01325 KEVENT Event; 01326 NTSTATUS Status; 01327 ULONG i; 01328 PFILE_OBJECT FileObject; 01329 IO_STACK_LOCATION irpSp; 01330 ULONG information; 01331 01332 PAGED_CODE(); 01333 DumpInit = &DumpStack->Init; 01334 01335 // 01336 // Release the claim to this file as a specific device usage path. 01337 // 01338 01339 FileObject = DumpStack->FileObject; 01340 if (FileObject) { 01341 DeviceObject = IoGetRelatedDeviceObject (FileObject); 01342 01343 RtlZeroMemory (&irpSp, sizeof (IO_STACK_LOCATION)); 01344 01345 irpSp.MajorFunction = IRP_MJ_PNP; 01346 irpSp.MinorFunction = IRP_MN_DEVICE_USAGE_NOTIFICATION; 01347 irpSp.Parameters.UsageNotification.Type = DumpStack->UsageType; 01348 irpSp.Parameters.UsageNotification.InPath = FALSE; 01349 irpSp.FileObject = FileObject; 01350 01351 if (DeviceUsageTypeUndefined != DumpStack->UsageType) { 01352 Status = IopSynchronousCall (DeviceObject, &irpSp, (VOID **) &information); 01353 ASSERT (0 == information); 01354 } else { 01355 Status = STATUS_SUCCESS; 01356 } 01357 } 01358 01359 // 01360 // Free any common buffers which where allocated 01361 // 01362 01363 for (i=0; i < 2; i++) { 01364 if (DumpInit->CommonBuffer[i]) { 01365 if (DumpInit->AdapterObject) { 01366 01367 #if !defined(NO_LEGACY_DRIVERS) 01368 HalFreeCommonBuffer ( 01369 DumpInit->AdapterObject, 01370 ((PDUMP_POINTERS)DumpStack->DumpPointers)->CommonBufferSize, 01371 DumpInit->PhysicalAddress[i], 01372 DumpInit->CommonBuffer[i], 01373 FALSE 01374 ); 01375 #else 01376 (*((PDMA_ADAPTER)DumpInit->AdapterObject)->DmaOperations-> 01377 FreeCommonBuffer )( 01378 (PDMA_ADAPTER)DumpInit->AdapterObject, 01379 ((PDUMP_POINTERS)DumpStack->DumpPointers)->CommonBufferSize, 01380 DumpInit->PhysicalAddress[i], 01381 DumpInit->CommonBuffer[i], 01382 FALSE 01383 ); 01384 01385 #endif // NO_LEGACY_DRIVERS 01386 01387 01388 } else { 01389 MmFreeContiguousMemory (DumpInit->CommonBuffer[i]); 01390 } 01391 } 01392 DumpInit->CommonBuffer[i] = NULL; 01393 } 01394 01395 // 01396 // Unload the dump drivers 01397 // 01398 01399 while (!IsListEmpty(&DumpStack->DriverList)) { 01400 DumpImage = CONTAINING_RECORD(DumpStack->DriverList.Blink, DUMP_STACK_IMAGE, Link); 01401 RemoveEntryList (&DumpImage->Link); 01402 MmUnloadSystemImage (DumpImage->Image); 01403 ExFreePool (DumpImage); 01404 } 01405 01406 // 01407 // Inform the driver stack that the dump registartion is over 01408 // 01409 01410 if (DumpStack->FileObject) { 01411 DeviceObject = IoGetRelatedDeviceObject ((PFILE_OBJECT) DumpStack->FileObject); 01412 01413 KeInitializeEvent( &Event, NotificationEvent, FALSE ); 01414 Irp = IoBuildDeviceIoControlRequest( 01415 IOCTL_SCSI_FREE_DUMP_POINTERS, 01416 DeviceObject, 01417 DumpStack->DumpPointers, 01418 sizeof (DUMP_POINTERS), 01419 NULL, 01420 0, 01421 FALSE, 01422 &Event, 01423 &IoStatus 01424 ); 01425 01426 IrpSp = IoGetNextIrpStackLocation (Irp); 01427 IrpSp->FileObject = DumpStack->FileObject; 01428 01429 Status = IoCallDriver( DeviceObject, Irp ); 01430 01431 if (Status == STATUS_PENDING) { 01432 KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); 01433 Status = IoStatus.Status; 01434 } 01435 ObDereferenceObject( DumpStack->FileObject ); 01436 } 01437 // 01438 // Free the target address if it exists 01439 // 01440 if (DumpStack->Init.TargetAddress) { 01441 ExFreePool( DumpStack->Init.TargetAddress); 01442 } 01443 // 01444 // Free the dump stack context 01445 // 01446 01447 ExFreePool (DumpStack); 01448 }

NTKERNELAPI VOID IoFreeIrp IN PIRP  Irp  ) 
 

Definition at line 6632 of file iosubs.c.

References Irp, and pIoFreeIrp.

Referenced by IoBuildAsynchronousFsdRequest(), IoBuildDeviceIoControlRequest(), IoCancelFileOpen(), IopCloseFile(), IopCompletePageWrite(), IopCompleteRequest(), IopDeleteFile(), IopDeleteIoCompletion(), IopDeviceEjectComplete(), IopDeviceRelationsComplete(), IopDeviceStartComplete(), IopDropIrp(), IopExceptionCleanup(), IopFreeIrpAndMdls(), IopParseDevice(), IopUserCompletion(), IopUserRundown(), NtRemoveIoCompletion(), UdfFinishBuffers(), UdfMultiAsyncCompletionRoutine(), UdfMultiSyncCompletionRoutine(), and VdmQueryDirectoryFile().

06635 { 06636 pIoFreeIrp(Irp); 06637 }

NTKERNELAPI VOID IoFreeMdl IN PMDL  Mdl  ) 
 

Definition at line 6744 of file iosubs.c.

References ExFreePool(), ExFreeToPPNPagedLookasideList(), LookasideMdlList, MDL_ALLOCATED_FIXED_SIZE, MDL_ALLOCATED_MUST_SUCCEED, and MmPrepareMdlForReuse.

Referenced by CcMdlRead(), CcMdlReadComplete2(), CcMdlWriteComplete2(), CcPrepareMdlWrite(), CcZeroData(), IoBuildAsynchronousFsdRequest(), IoBuildDeviceIoControlRequest(), IopCompleteRequest(), IopDropIrp(), IopExceptionCleanup(), IopFreeIrpAndMdls(), UdfCreateUserMdl(), UdfFinishBuffers(), UdfMultiAsyncCompletionRoutine(), UdfMultiSyncCompletionRoutine(), and VdmQueryDirectoryFile().

06750 : 06751 06752 This routine frees a Memory Descriptor List (MDL). It only frees the 06753 specified MDL; any chained MDLs must be freed explicitly through another 06754 call to this routine. 06755 06756 Arguments: 06757 06758 Mdl - Pointer to the Memory Descriptor List to be freed. 06759 06760 Return Value: 06761 06762 None. 06763 06764 --*/ 06765 06766 { 06767 PNPAGED_LOOKASIDE_LIST lookasideList; 06768 06769 // 06770 // Tell memory management that this MDL will be re-used. This will 06771 // cause MM to unmap any pages that have been mapped for this MDL if 06772 // it is a partial MDL. 06773 // 06774 06775 MmPrepareMdlForReuse(Mdl); 06776 if (((Mdl->MdlFlags & MDL_ALLOCATED_FIXED_SIZE) == 0) || 06777 ((Mdl->MdlFlags & MDL_ALLOCATED_MUST_SUCCEED) != 0)) { 06778 ExFreePool(Mdl); 06779 06780 } else { 06781 ExFreeToPPNPagedLookasideList(LookasideMdlList, Mdl); 06782 } 06783 }

VOID IoFreePoDeviceNotifyList IN OUT PVOID  Order  ) 
 

VOID IoFreeWorkItem PIO_WORKITEM  IoWorkItem  ) 
 

Definition at line 924 of file io/misc.c.

References ASSERT, and ExFreePool().

00930 : 00931 00932 This function is the "wrapper" routine for IoQueueWorkItem. It calls 00933 the original worker function, then dereferences the device object to 00934 (possibly) allow the driver object to go away. 00935 00936 Arguments: 00937 00938 Parameter - Supplies a pointer to an IO_WORKITEM for us to process. 00939 00940 Return Value: 00941 00942 None 00943 00944 --*/ 00945 00946 { 00947 ASSERT( IoWorkItem->Size == sizeof( IO_WORKITEM )); 00948 00949 ExFreePool( IoWorkItem ); 00950 }

NTKERNELAPI PDEVICE_OBJECT IoGetAttachedDevice IN PDEVICE_OBJECT  DeviceObject  ) 
 

Definition at line 6786 of file iosubs.c.

References _DEVICE_OBJECT::AttachedDevice.

Referenced by IoAttachDeviceToDeviceStack(), IoBuildPoDeviceNotifyList(), IoGetAttachedDeviceReference(), IoGetRelatedDeviceObject(), IopAsynchronousCall(), IopCallDriverAddDevice(), IopCloseFile(), IopDeleteFile(), IopEjectDevice(), IopFilterResourceRequirementsCall(), IopGetSetSecurityObject(), IopParseDevice(), IopSynchronousCall(), IopXxxControlFile(), IoShutdownSystem(), NtQueryInformationFile(), NtSetInformationFile(), and NtUnlockFile().

06792 : 06793 06794 This routine returns the highest level device object associated with 06795 the specified device. 06796 06797 N.B. Caller must own the IopDatabaseLock. External callers of this 06798 function must ensure nobody is attaching or detaching from the stack. 06799 If they cannot, they *must* use IoGetAttachedDeviceReference. 06800 06801 Arguments: 06802 06803 DeviceObject - Supplies a pointer to the device for which the attached 06804 device is to be returned. 06805 06806 Return Value: 06807 06808 The function value is the highest level device attached to the specified 06809 device. If no devices are attached, then the pointer to the device 06810 object itself is returned. 06811 06812 --*/ 06813 06814 { 06815 // 06816 // Loop through all of the device object's attached to the specified 06817 // device. When the last device object is found that is not attached 06818 // to, return it. 06819 // 06820 06821 while (DeviceObject->AttachedDevice) { 06822 DeviceObject = DeviceObject->AttachedDevice; 06823 } 06824 06825 return DeviceObject; 06826 }

NTKERNELAPI PDEVICE_OBJECT IoGetAttachedDeviceReference IN PDEVICE_OBJECT  DeviceObject  ) 
 

Definition at line 6829 of file iosubs.c.

References IoGetAttachedDevice(), IopDatabaseLock, and ObReferenceObject.

Referenced by HalpIsOldStyleFloppy(), HalpQueryDriveLayout(), HalpQueryPartitionType(), IoGetDmaAdapter(), and IovpThrowBogusSynchronousIrp().

06834 : 06835 06836 This routine synchronizes with the Io database and returns a refernce 06837 to the highest level device object associated withthe specified device. 06838 06839 Arguments: 06840 06841 DeviceObject - Supplies a pointer to the device for which the attached 06842 device is to be returned. 06843 06844 Return Value: 06845 06846 The function value is a reference to the highest level device attached 06847 to the specified device. If no devices are attached, then the pointer 06848 to the device object itself is returned. 06849 06850 --*/ 06851 { 06852 KIRQL irql; 06853 06854 ExAcquireFastLock( &IopDatabaseLock, &irql ); 06855 DeviceObject = IoGetAttachedDevice (DeviceObject); 06856 ObReferenceObject (DeviceObject); 06857 ExReleaseFastLock( &IopDatabaseLock, irql ); 06858 return DeviceObject; 06859 }

NTKERNELAPI PDEVICE_OBJECT IoGetBaseFileSystemDeviceObject IN PFILE_OBJECT  FileObject  ) 
 

Definition at line 6862 of file iosubs.c.

References ASSERT, _VPB::DeviceObject, FO_DIRECT_DEVICE_OPEN, NULL, and _DEVICE_OBJECT::Vpb.

Referenced by FsRtlAcquireFileExclusive(), FsRtlAcquireFileForCcFlush(), FsRtlAcquireFileForModWrite(), FsRtlMdlRead(), FsRtlMdlReadComplete(), FsRtlMdlWriteComplete(), FsRtlPrepareMdlWrite(), FsRtlReleaseFile(), FsRtlReleaseFileForCcFlush(), and FsRtlReleaseFileForModWrite().

06868 : 06869 06870 This routine returns the base (lowest-level) file system volume device 06871 object associated with a file. I.e., it locates the file system w/o 06872 walking the attached device object list. 06873 06874 Arguments: 06875 06876 FileObject - Supplies a pointer to the file object for which the base 06877 file system device object is to be returned. 06878 06879 Return Value: 06880 06881 The function value is the lowest level volume device object associated 06882 w/the file. 06883 06884 --*/ 06885 06886 { 06887 PDEVICE_OBJECT deviceObject; 06888 06889 // 06890 // If the file object has a mounted Vpb, use its DeviceObject. 06891 // 06892 06893 if (FileObject->Vpb != NULL && FileObject->Vpb->DeviceObject != NULL) { 06894 deviceObject = FileObject->Vpb->DeviceObject; 06895 06896 // 06897 // Otherwise, if the real device has a VPB that indicates that it is 06898 // mounted, then use the file system device object associated with the 06899 // VPB. 06900 // 06901 06902 } else if (!(FileObject->Flags & FO_DIRECT_DEVICE_OPEN) && 06903 FileObject->DeviceObject->Vpb != NULL && 06904 FileObject->DeviceObject->Vpb->DeviceObject != NULL) { 06905 06906 deviceObject = FileObject->DeviceObject->Vpb->DeviceObject; 06907 06908 // 06909 // Otherwise, just return the real device object. 06910 // 06911 06912 } else { 06913 06914 deviceObject = FileObject->DeviceObject; 06915 } 06916 06917 ASSERT( deviceObject != NULL ); 06918 06919 // 06920 // Simply return the resultant file object. 06921 // 06922 06923 return deviceObject; 06924 }

NTKERNELAPI NTSTATUS IoGetBootDiskInformation IN OUT PBOOTDISK_INFORMATION  BootDiskInformation,
IN ULONG  Size
 

Definition at line 11641 of file iosubs.c.

References _LOADER_PARAMETER_BLOCK::ArcBootDeviceName, _LOADER_PARAMETER_BLOCK::ArcDiskInformation, _LOADER_PARAMETER_BLOCK::ArcHalDeviceName, _ARC_DISK_SIGNATURE::ArcName, _CONFIGURATION_INFORMATION::DiskCount, _ARC_DISK_INFORMATION::DiskSignatures, ExFreePool(), FALSE, IoBuildDeviceIoControlRequest(), IoCallDriver, IoGetConfigurationInformation(), IoGetDeviceObjectPointer(), IopLoaderBlock, IoReadPartitionTable(), KeInitializeEvent, KernelMode, KeWaitForSingleObject(), NT_SUCCESS, NTSTATUS(), NULL, ObDereferenceObject, RtlAnsiStringToUnicodeString(), RtlEqualString(), RtlFreeUnicodeString(), RtlInitAnsiString(), _ARC_DISK_SIGNATURE::Signature, Size, sprintf(), Suspended, TRUE, and _ARC_DISK_SIGNATURE::ValidPartitionTable.

11648 : 11649 11650 This routine provides the caller with the signature and offset of 11651 the boot disk and system disk. This information is obtained from the 11652 loader block. The callers have to be boot drivers which have registered 11653 for a callback once all disk devices have been started 11654 Arguments: 11655 11656 BootDiskInformation - Supplies a pointer to the structure allocated by the 11657 caller for requested information. 11658 Size - Size of the BootDiskInformation structure. 11659 11660 Return Value: 11661 11662 STATUS_SUCCESS - successful. 11663 STATUS_TOO_LATE - indicates that the Loader Block has already been freed 11664 STATUS_INVALID_PARAMETER - size allocated for boot disk information 11665 is insufficient. 11666 11667 --*/ 11668 11669 { 11670 PLOADER_PARAMETER_BLOCK LoaderBlock = NULL; 11671 STRING arcBootDeviceString; 11672 UCHAR deviceNameBuffer[128]; 11673 STRING deviceNameString; 11674 UNICODE_STRING deviceNameUnicodeString; 11675 PDEVICE_OBJECT deviceObject; 11676 UCHAR arcNameBuffer[128]; 11677 STRING arcNameString; 11678 UNICODE_STRING arcNameUnicodeString; 11679 PFILE_OBJECT fileObject; 11680 NTSTATUS status; 11681 IO_STATUS_BLOCK ioStatusBlock; 11682 DISK_GEOMETRY diskGeometry; 11683 PDRIVE_LAYOUT_INFORMATION driveLayout; 11684 PLIST_ENTRY listEntry; 11685 PARC_DISK_SIGNATURE diskBlock; 11686 ULONG diskNumber; 11687 ULONG partitionNumber; 11688 PCHAR arcName; 11689 PULONG buffer; 11690 PIRP irp; 11691 KEVENT event; 11692 LARGE_INTEGER offset; 11693 ULONG checkSum; 11694 ULONG i; 11695 BOOLEAN singleBiosDiskFound; 11696 BOOLEAN bootDiskFound = FALSE; 11697 BOOLEAN systemDiskFound = FALSE; 11698 PARC_DISK_INFORMATION arcInformation; 11699 ULONG totalDriverDisksFound = IoGetConfigurationInformation()->DiskCount; 11700 STRING arcSystemDeviceString; 11701 STRING osLoaderPathString; 11702 UNICODE_STRING osLoaderPathUnicodeString; 11703 PARTITION_INFORMATION PartitionInfo; 11704 11705 if (IopLoaderBlock == NULL) { 11706 return STATUS_TOO_LATE; 11707 } 11708 11709 if (Size < sizeof(BOOTDISK_INFORMATION)) { 11710 return STATUS_INVALID_PARAMETER; 11711 } 11712 11713 LoaderBlock = (PLOADER_PARAMETER_BLOCK)IopLoaderBlock; 11714 arcInformation = LoaderBlock->ArcDiskInformation; 11715 11716 // 11717 // If a single bios disk was found if there is only a 11718 // single entry on the disk signature list. 11719 // 11720 singleBiosDiskFound = (arcInformation->DiskSignatures.Flink->Flink == 11721 &arcInformation->DiskSignatures) ? (TRUE) : (FALSE); 11722 11723 // 11724 // Get ARC boot device name from loader block. 11725 // 11726 11727 RtlInitAnsiString( &arcBootDeviceString, 11728 LoaderBlock->ArcBootDeviceName ); 11729 // 11730 // Get ARC system device name from loader block. 11731 // 11732 11733 RtlInitAnsiString( &arcSystemDeviceString, 11734 LoaderBlock->ArcHalDeviceName ); 11735 // 11736 // For each disk, get its drive layout and check to see if the 11737 // signature is among the list of signatures in the loader block. 11738 // If yes, check to see if the disk contains the boot or system 11739 // partitions. If yes, fill up the requested structure. 11740 // 11741 11742 for (diskNumber = 0; 11743 diskNumber < totalDriverDisksFound; 11744 diskNumber++) { 11745 11746 // 11747 // Construct the NT name for a disk and obtain a reference. 11748 // 11749 11750 sprintf( deviceNameBuffer, 11751 "\\Device\\Harddisk%d\\Partition0", 11752 diskNumber ); 11753 RtlInitAnsiString( &deviceNameString, deviceNameBuffer ); 11754 status = RtlAnsiStringToUnicodeString( &deviceNameUnicodeString, 11755 &deviceNameString, 11756 TRUE ); 11757 if (!NT_SUCCESS( status )) { 11758 continue; 11759 } 11760 11761 status = IoGetDeviceObjectPointer( &deviceNameUnicodeString, 11762 FILE_READ_ATTRIBUTES, 11763 &fileObject, 11764 &deviceObject ); 11765 RtlFreeUnicodeString( &deviceNameUnicodeString ); 11766 11767 if (!NT_SUCCESS( status )) { 11768 continue; 11769 } 11770 11771 // 11772 // Create IRP for get drive geometry device control. 11773 // 11774 11775 irp = IoBuildDeviceIoControlRequest( IOCTL_DISK_GET_DRIVE_GEOMETRY, 11776 deviceObject, 11777 NULL, 11778 0, 11779 &diskGeometry, 11780 sizeof(DISK_GEOMETRY), 11781 FALSE, 11782 &event, 11783 &ioStatusBlock ); 11784 if (!irp) { 11785 ObDereferenceObject( fileObject ); 11786 continue; 11787 } 11788 11789 KeInitializeEvent( &event, 11790 NotificationEvent, 11791 FALSE ); 11792 status = IoCallDriver( deviceObject, 11793 irp ); 11794 11795 if (status == STATUS_PENDING) { 11796 KeWaitForSingleObject( &event, 11797 Suspended, 11798 KernelMode, 11799 FALSE, 11800 NULL ); 11801 status = ioStatusBlock.Status; 11802 } 11803 11804 if (!NT_SUCCESS( status )) { 11805 ObDereferenceObject( fileObject ); 11806 continue; 11807 } 11808 11809 // 11810 // Get partition information for this disk. 11811 // 11812 11813 status = IoReadPartitionTable( deviceObject, 11814 diskGeometry.BytesPerSector, 11815 TRUE, 11816 &driveLayout ); 11817 11818 ObDereferenceObject( fileObject ); 11819 11820 if (!NT_SUCCESS( status )) { 11821 continue; 11822 } 11823 11824 // 11825 // Make sure sector size is at least 512 bytes. 11826 // 11827 11828 if (diskGeometry.BytesPerSector < 512) { 11829 diskGeometry.BytesPerSector = 512; 11830 } 11831 11832 // 11833 // For each ARC disk information record in the loader block 11834 // match the disk signature and checksum to determine its ARC 11835 // name and construct the NT ARC names symbolic links. 11836 // 11837 11838 for (listEntry = arcInformation->DiskSignatures.Flink; 11839 listEntry != &arcInformation->DiskSignatures; 11840 listEntry = listEntry->Flink) { 11841 11842 // 11843 // Get next record and compare disk signatures. 11844 // 11845 11846 diskBlock = CONTAINING_RECORD( listEntry, 11847 ARC_DISK_SIGNATURE, 11848 ListEntry ); 11849 11850 // 11851 // Compare disk signatures. 11852 // 11853 // Or if there is only a single disk drive from 11854 // both the bios and driver viewpoints then 11855 // assign an arc name to that drive. 11856 // 11857 11858 if ((singleBiosDiskFound && (totalDriverDisksFound == 1)) || 11859 (diskBlock->Signature == driveLayout->Signature && 11860 diskBlock->ValidPartitionTable)) { 11861 11862 // 11863 // Create unicode device name for physical disk. 11864 // 11865 11866 sprintf( deviceNameBuffer, 11867 "\\Device\\Harddisk%d\\Partition0", 11868 diskNumber ); 11869 RtlInitAnsiString( &deviceNameString, deviceNameBuffer ); 11870 status = RtlAnsiStringToUnicodeString( &deviceNameUnicodeString, 11871 &deviceNameString, 11872 TRUE ); 11873 if (!NT_SUCCESS( status )) { 11874 continue; 11875 } 11876 11877 // 11878 // Create unicode ARC name for this partition. 11879 // 11880 11881 arcName = diskBlock->ArcName; 11882 sprintf( arcNameBuffer, 11883 "\\ArcName\\%s", 11884 arcName ); 11885 RtlInitAnsiString( &arcNameString, arcNameBuffer ); 11886 status = RtlAnsiStringToUnicodeString( &arcNameUnicodeString, 11887 &arcNameString, 11888 TRUE ); 11889 if (!NT_SUCCESS( status )) { 11890 continue; 11891 } 11892 11893 // 11894 // Create an ARC name for every partition on this disk. 11895 // 11896 11897 for (partitionNumber = 0; 11898 partitionNumber < driveLayout->PartitionCount; 11899 partitionNumber++) { 11900 11901 // 11902 // Create unicode NT device name. 11903 // 11904 11905 sprintf( deviceNameBuffer, 11906 "\\Device\\Harddisk%d\\Partition%d", 11907 diskNumber, 11908 partitionNumber+1 ); 11909 RtlInitAnsiString( &deviceNameString, deviceNameBuffer ); 11910 status = RtlAnsiStringToUnicodeString( 11911 &deviceNameUnicodeString, 11912 &deviceNameString, 11913 TRUE ); 11914 if (!NT_SUCCESS( status )) { 11915 continue; 11916 } 11917 11918 // 11919 // Create unicode ARC name for this partition and 11920 // check to see if this is the boot disk. 11921 // 11922 11923 sprintf( arcNameBuffer, 11924 "%spartition(%d)", 11925 arcName, 11926 partitionNumber+1 ); 11927 RtlInitAnsiString( &arcNameString, arcNameBuffer ); 11928 if (RtlEqualString( &arcNameString, 11929 &arcBootDeviceString, 11930 TRUE )) { 11931 BootDiskInformation->BootDeviceSignature = 11932 driveLayout->Signature; 11933 // 11934 // Get Partition Information for the offset of the 11935 // partition within the disk 11936 // 11937 status = IoGetDeviceObjectPointer( 11938 &deviceNameUnicodeString, 11939 FILE_READ_ATTRIBUTES, 11940 &fileObject, 11941 &deviceObject ); 11942 RtlFreeUnicodeString( &deviceNameUnicodeString ); 11943 11944 if (!NT_SUCCESS( status )) { 11945 continue; 11946 } 11947 11948 // 11949 // Create IRP for get drive geometry device control. 11950 // 11951 11952 irp = IoBuildDeviceIoControlRequest( 11953 IOCTL_DISK_GET_PARTITION_INFO, 11954 deviceObject, 11955 NULL, 11956 0, 11957 &PartitionInfo, 11958 sizeof(PARTITION_INFORMATION), 11959 FALSE, 11960 &event, 11961 &ioStatusBlock ); 11962 if (!irp) { 11963 ObDereferenceObject( fileObject ); 11964 continue; 11965 } 11966 11967 KeInitializeEvent( &event, 11968 NotificationEvent, 11969 FALSE ); 11970 status = IoCallDriver( deviceObject, 11971 irp ); 11972 11973 if (status == STATUS_PENDING) { 11974 KeWaitForSingleObject( &event, 11975 Suspended, 11976 KernelMode, 11977 FALSE, 11978 NULL ); 11979 status = ioStatusBlock.Status; 11980 } 11981 11982 if (!NT_SUCCESS( status )) { 11983 ObDereferenceObject( fileObject ); 11984 continue; 11985 } 11986 BootDiskInformation->BootPartitionOffset = 11987 PartitionInfo.StartingOffset.QuadPart; 11988 bootDiskFound = TRUE; 11989 } 11990 11991 // 11992 // See if this is the system partition. 11993 // 11994 if (RtlEqualString( &arcNameString, 11995 &arcSystemDeviceString, 11996 TRUE )) { 11997 BootDiskInformation->SystemDeviceSignature = 11998 driveLayout->Signature; 11999 // 12000 // Get Partition Information for the offset of the 12001 // partition within the disk 12002 // 12003 status = IoGetDeviceObjectPointer( 12004 &deviceNameUnicodeString, 12005 FILE_READ_ATTRIBUTES, 12006 &fileObject, 12007 &deviceObject ); 12008 RtlFreeUnicodeString( &deviceNameUnicodeString ); 12009 12010 if (!NT_SUCCESS( status )) { 12011 continue; 12012 } 12013 12014 // 12015 // Create IRP for get drive geometry device control. 12016 // 12017 12018 irp = IoBuildDeviceIoControlRequest( 12019 IOCTL_DISK_GET_PARTITION_INFO, 12020 deviceObject, 12021 NULL, 12022 0, 12023 &PartitionInfo, 12024 sizeof(PARTITION_INFORMATION), 12025 FALSE, 12026 &event, 12027 &ioStatusBlock ); 12028 if (!irp) { 12029 ObDereferenceObject( fileObject ); 12030 continue; 12031 } 12032 12033 KeInitializeEvent( &event, 12034 NotificationEvent, 12035 FALSE ); 12036 status = IoCallDriver( deviceObject, 12037 irp ); 12038 12039 if (status == STATUS_PENDING) { 12040 KeWaitForSingleObject( &event, 12041 Suspended, 12042 KernelMode, 12043 FALSE, 12044 NULL ); 12045 status = ioStatusBlock.Status; 12046 } 12047 12048 if (!NT_SUCCESS( status )) { 12049 ObDereferenceObject( fileObject ); 12050 continue; 12051 } 12052 BootDiskInformation->SystemPartitionOffset = 12053 PartitionInfo.StartingOffset.QuadPart; 12054 systemDiskFound = TRUE; 12055 } 12056 } 12057 } 12058 } 12059 ExFreePool( driveLayout ); 12060 } 12061 return STATUS_SUCCESS; 12062 }

NTKERNELAPI PCONFIGURATION_INFORMATION IoGetConfigurationInformation VOID   ) 
 

Definition at line 6927 of file iosubs.c.

References ConfigurationInformation, and PAGED_CODE.

Referenced by IoGetBootDiskInformation(), IopCreateArcNames(), NtQuerySystemInformation(), and xHalIoAssignDriveLetters().

06931 : 06932 06933 This routine returns a pointer to the system's device configuration 06934 information structure so that drivers and the system can determine how 06935 many different types of devices exist in the system. 06936 06937 Arguments: 06938 06939 None. 06940 06941 Return Value: 06942 06943 The function value is a pointer to the configuration information 06944 structure. 06945 06946 --*/ 06947 06948 { 06949 PAGED_CODE(); 06950 06951 // 06952 // Simply return a pointer to the built-in configuration information 06953 // structure. 06954 // 06955 06956 return (&ConfigurationInformation); 06957 }

NTKERNELAPI NTSTATUS IoGetCrashDumpInformation OUT PSYSTEM_CRASH_DUMP_INFORMATION  pCrashDumpInfo  ) 
 

Definition at line 2217 of file dumpctl.c.

References IopDumpControlBlock, and NULL.

Referenced by NtQuerySystemInformation().

02223 : 02224 02225 This function checks to see if an open crash dump section exists and 02226 if so creates a handle to the section and returns that value 02227 in the CrashDumpInformation structure. 02228 02229 02230 Arguments: 02231 02232 CrashInfo - Supplies a pointer to the crash dump information 02233 structure. 02234 02235 Return Value: 02236 02237 Status of the operation. A handle value of zero indicates no 02238 crash dump was located. 02239 02240 --*/ 02241 { 02242 02243 if (!IopDumpControlBlock) { 02244 return STATUS_NOT_FOUND; 02245 } 02246 02247 // 02248 // NB: The section object is for direct dump support, which has been 02249 // removed. 02250 // 02251 02252 pCrashDumpInfo->hDumpSection = NULL; 02253 return STATUS_SUCCESS; 02254 }

NTKERNELAPI NTSTATUS IoGetCrashDumpStateInformation OUT PSYSTEM_CRASH_STATE_INFORMATION  pCrashDumpState  ) 
 

Definition at line 2260 of file dumpctl.c.

References FALSE.

Referenced by NtQuerySystemInformation().

02266 : 02267 02268 This routine returns sets the state variable for direct dump (fast dump) 02269 02270 02271 Arguments: 02272 02273 CrashInfo - Supplies a pointer to the crash dump state information 02274 structure. 02275 02276 Return Value: 02277 02278 Status of the operation. A handle value of zero indicates no 02279 crash dump was located. 02280 02281 --*/ 02282 02283 { 02284 pCrashDumpState->ValidDirectDump = FALSE; 02285 02286 return STATUS_SUCCESS; 02287 }

NTKERNELAPI PEPROCESS IoGetCurrentProcess VOID   ) 
 

Definition at line 6960 of file iosubs.c.

References PsGetCurrentProcess.

Referenced by IopStartNetworkForRemoteBoot().

06964 : 06965 06966 This routine returns a pointer to the current process. It is actually 06967 a jacket routine for the PS version of the same function since device 06968 drivers using the ntddk header file cannot see into a thread object. 06969 06970 Arguments: 06971 06972 None. 06973 06974 Return Value: 06975 06976 The function value is a pointer to the current process. 06977 06978 Note: 06979 06980 Note that this function cannot be paged because it is invoked at raised 06981 IRQL in debug builds, which is the only time that the PAGED_CODE macro 06982 actually does anything. Therefore, it is impossible to find code that 06983 invokes this function at raised IRQL in a normal system w/o simply running 06984 into the "proper conditions". This is too risky to actually page this 06985 routine, so it is left nonpaged. 06986 06987 --*/ 06988 06989 { 06990 // 06991 // Simply return a pointer to the current process. 06992 // 06993 06994 return PsGetCurrentProcess(); 06995 }

NTKERNELAPI NTSTATUS IoGetDeviceObjectPointer IN PUNICODE_STRING  ObjectName,
IN ACCESS_MASK  DesiredAccess,
OUT PFILE_OBJECT FileObject,
OUT PDEVICE_OBJECT DeviceObject
 

Definition at line 6998 of file iosubs.c.

References IoFileObjectType, IoGetRelatedDeviceObject(), KernelMode, NT_SUCCESS, NTSTATUS(), NULL, ObReferenceObjectByHandle(), PAGED_CODE, VOID(), and ZwOpenFile().

Referenced by DeviceClassCDROMNotify(), GetDeviceChangeInfo(), HalpEnableAutomaticDriveLetterAssignment(), HalpIsOldStyleFloppy(), HalpNextMountLetter(), HalpQueryDriveLayout(), HalpQueryPartitionType(), HalpSetMountLetter(), IoGetBootDiskInformation(), IopCreateArcNames(), and OpenDeviceReparseIndex().

07007 : 07008 07009 This routine returns a pointer to the device object specified by the 07010 object name. It also returns a pointer to the referenced file object 07011 that has been opened to the device that ensures that the device cannot 07012 go away. 07013 07014 To close access to the device, the caller should dereference the file 07015 object pointer. 07016 07017 Arguments: 07018 07019 ObjectName - Name of the device object for which a pointer is to be 07020 returned. 07021 07022 DesiredAccess - Access desired to the target device object. 07023 07024 FileObject - Supplies the address of a variable to receive a pointer 07025 to the file object for the device. 07026 07027 DeviceObject - Supplies the address of a variable to receive a pointer 07028 to the device object for the specified device. 07029 07030 Return Value: 07031 07032 The function value is a referenced pointer to the specified device 07033 object, if the device exists. Otherwise, NULL is returned. 07034 07035 --*/ 07036 07037 { 07038 PFILE_OBJECT fileObject; 07039 OBJECT_ATTRIBUTES objectAttributes; 07040 HANDLE fileHandle; 07041 IO_STATUS_BLOCK ioStatus; 07042 NTSTATUS status; 07043 07044 PAGED_CODE(); 07045 07046 // 07047 // Initialize the object attributes to open the device. 07048 // 07049 07050 InitializeObjectAttributes( &objectAttributes, 07051 ObjectName, 07052 0, 07053 (HANDLE) NULL, 07054 (PSECURITY_DESCRIPTOR) NULL ); 07055 07056 status = ZwOpenFile( &fileHandle, 07057 DesiredAccess, 07058 &objectAttributes, 07059 &ioStatus, 07060 0, 07061 FILE_NON_DIRECTORY_FILE ); 07062 07063 if (NT_SUCCESS( status )) { 07064 07065 // 07066 // The open operation was successful. Dereference the file handle 07067 // and obtain a pointer to the device object for the handle. 07068 // 07069 07070 status = ObReferenceObjectByHandle( fileHandle, 07071 0, 07072 IoFileObjectType, 07073 KernelMode, 07074 (PVOID *) &fileObject, 07075 NULL ); 07076 if (NT_SUCCESS( status )) { 07077 07078 *FileObject = fileObject; 07079 07080 // 07081 // Get a pointer to the device object for this file. 07082 // 07083 *DeviceObject = IoGetRelatedDeviceObject( fileObject ); 07084 } 07085 07086 (VOID) ZwClose( fileHandle ); 07087 } 07088 07089 return status; 07090 }

NTKERNELAPI PDEVICE_OBJECT IoGetDeviceToVerify IN PETHREAD  Thread  ) 
 

Definition at line 7093 of file iosubs.c.

Referenced by UdfProcessException().

07099 : 07100 07101 This routine returns a pointer to the device object that is to be verified. 07102 The pointer is set in the thread object by a device driver when the disk 07103 or CD-ROM media appears to have changed since the last access to the device. 07104 07105 Arguments: 07106 07107 Thread - Pointer to the thread whose field is to be queried. 07108 07109 Return Value: 07110 07111 The function value is a pointer to the device to be verified, or NULL. 07112 07113 Note: 07114 07115 This function cannot be made a macro, since fields in the thread object 07116 move from release to release, so this must remain a full function. 07117 07118 07119 --*/ 07120 07121 { 07122 // 07123 // Simply return the device to be verified. 07124 // 07125 07126 return Thread->DeviceToVerify; 07127 }

NTKERNELAPI struct _DMA_ADAPTER* IoGetDmaAdapter IN PDEVICE_OBJECT  PhysicalDeviceObject,
OPTIONALIN struct _DEVICE_DESCRIPTION DeviceDescription,
IN OUT PULONG  NumberOfMapRegisters
 

NTKERNELAPI PVOID IoGetDriverObjectExtension IN PDRIVER_OBJECT  DriverObject,
IN PVOID  ClientIdentificationAddress
 

Definition at line 7131 of file iosubs.c.

References extension, IopDatabaseLock, and NULL.

07137 : 07138 07139 This routine returns a pointer to the client driver object extension. 07140 This extension was allocated using IoAllocateDriverObjectExtension. If 07141 an extension with the create Id does not exist for the specified driver 07142 object then NULL is returned. 07143 07144 Arguments: 07145 07146 DriverObject - Pointer to driver object owning the extension. 07147 07148 ClientIdentificationAddress - Supplies the unique identifier which was 07149 used to create the extension. 07150 07151 Return Value: 07152 07153 The function value is a pointer to the client driver object extension, 07154 or NULL. 07155 07156 --*/ 07157 07158 { 07159 KIRQL irql; 07160 PIO_CLIENT_EXTENSION extension; 07161 07162 ExAcquireFastLock( &IopDatabaseLock, &irql ); 07163 extension = DriverObject->DriverExtension->ClientDriverExtension; 07164 while (extension != NULL) { 07165 07166 if (extension->ClientIdentificationAddress == ClientIdentificationAddress) { 07167 break; 07168 } 07169 07170 extension = extension->NextExtension; 07171 } 07172 07173 ExReleaseFastLock( &IopDatabaseLock, irql ); 07174 07175 if (extension == NULL) { 07176 return NULL; 07177 } 07178 07179 return extension + 1; 07180 }

VOID IoGetDumpHiberRanges IN PVOID  HiberContext,
IN PDUMP_STACK_CONTEXT  DumpStack
 

Definition at line 1233 of file dumpctl.c.

References PDUMP_STACK_IMAGE, PO_MEM_CL_OR_NCHK, and PoSetHiberRange().

01239 : 01240 01241 Adds the dump driver stack storage to the hibernate range list, 01242 to inform the hibernate procedure which pages need cloned, 01243 discarded or not checksumed as they are in use by the dump 01244 stack. 01245 01246 Arguments: 01247 01248 HiberContext - Pointer to the hiber context structure 01249 01250 DumpStack - Dump driver stack being initialized 01251 01252 Return Value: 01253 01254 None 01255 01256 --*/ 01257 { 01258 PDUMP_POINTERS DumpPointers; 01259 PDUMP_STACK_IMAGE DumpImage; 01260 PLIST_ENTRY Link; 01261 01262 DumpPointers = DumpStack->DumpPointers; 01263 01264 // 01265 // Report the common buffer 01266 // 01267 01268 if (DumpPointers->CommonBufferVa) { 01269 PoSetHiberRange ( 01270 HiberContext, 01271 PO_MEM_CL_OR_NCHK, 01272 DumpPointers->CommonBufferVa, 01273 DumpPointers->CommonBufferSize, 01274 'fubc' 01275 ); 01276 } 01277 01278 // 01279 // Dump the entire image of the dump drivers 01280 // 01281 01282 for (Link = DumpStack->DriverList.Flink; 01283 Link != &DumpStack->DriverList; 01284 Link = Link->Flink) { 01285 01286 DumpImage = CONTAINING_RECORD(Link, DUMP_STACK_IMAGE, Link); 01287 01288 PoSetHiberRange ( 01289 HiberContext, 01290 PO_MEM_CL_OR_NCHK, 01291 DumpImage->ImageBase, 01292 DumpImage->SizeOfImage, 01293 'gmID' 01294 ); 01295 } 01296 }

NTSTATUS IoGetDumpStack IN PWCHAR  ModulePrefix,
OUT PDUMP_STACK_CONTEXT DumpStack,
IN enum _DEVICE_USAGE_NOTIFICATION_TYPE  UsageType,
IN ULONG  IgnoreDeviceUsageFailure
 

NTKERNELAPI PGENERIC_MAPPING IoGetFileObjectGenericMapping VOID   ) 
 

Definition at line 7183 of file iosubs.c.

References IopFileMapping.

07189 : 07190 07191 This routine returns a pointer to the generic mapping for a file object. 07192 07193 Arguments: 07194 07195 None. 07196 07197 Return Value: 07198 07199 A pointer to the generic mapping for a file object. 07200 07201 --*/ 07202 07203 { 07204 // 07205 // Simply return a pointer to the generic mapping for a file object. 07206 // 07207 07208 return &IopFileMapping; 07209 }

NTKERNELAPI PVOID IoGetInitialStack VOID   ) 
 

Definition at line 7212 of file iosubs.c.

References PsGetCurrentThread.

07218 : 07219 07220 This routine returns the base initial address of the current thread's 07221 stack. 07222 07223 Arguments: 07224 07225 None. 07226 07227 Return Value: 07228 07229 The base initial address of the current thread's stack. 07230 07231 Note: 07232 07233 This function cannot be made a macro, since fields in the thread object 07234 move from release to release, so this must remain a full function. 07235 07236 --*/ 07237 07238 { 07239 // 07240 // Simply return the initial stack for this thread. 07241 // 07242 07243 return PsGetCurrentThread()->Tcb.InitialStack; 07244 }

NTSTATUS IoGetLegacyVetoList OUT PWSTR *VetoList  OPTIONAL,
OUT PPNP_VETO_TYPE  VetoType
 

Definition at line 9712 of file pnpioapi.c.

References ASSERT, ExFreePool(), FALSE, IopAcquireEnumerationLock, IopAppendLegacyVeto(), IopGetLegacyVetoListDeviceNode(), IopGetLegacyVetoListDrivers(), IopReleaseEnumerationLock, IopRootDeviceNode, L, NT_SUCCESS, NTSTATUS(), NULL, PnPInitialized, RtlInitUnicodeString(), Status, IO_GET_LEGACY_VETO_LIST_CONTEXT::Status, IO_GET_LEGACY_VETO_LIST_CONTEXT::VetoList, IO_GET_LEGACY_VETO_LIST_CONTEXT::VetoListLength, and IO_GET_LEGACY_VETO_LIST_CONTEXT::VetoType.

Referenced by ExpQueryLegacyDriverInformation().

09718 : 09719 09720 This routine is used by PNP and PO to determine whether legacy drivers and 09721 devices are installed in the system. This routine is conceptually a 09722 QUERY_REMOVE_DEVICE and QUERY_POWER-like interface for legacy drivers 09723 and devices. 09724 09725 Parameters: 09726 09727 VetoList - A pointer to a PWSTR. (Optional) If specified, 09728 IoGetLegacyVetoList will allocate a veto list, and return a 09729 pointer to the veto list in VetoList. 09730 09731 VetoType - A pointer to a PNP_VETO_TYPE. If no legacy drivers 09732 or devices are found in the system, VetoType is assigned 09733 PNP_VetoTypeUnknown. If one or more legacy drivers are installed, 09734 VetoType is assigned PNP_VetoLegacyDriver. If one or more 09735 legacy devices are installed, VetoType is assigned 09736 PNP_VetoLegacyDevice. VetoType is assigned independent of 09737 whether a VetoList is created. 09738 09739 ReturnValue: 09740 09741 An NTSTATUS value indicating whether the IoGetLegacyVetoList() operation 09742 was successful. 09743 09744 --*/ 09745 { 09746 NTSTATUS Status; 09747 IO_GET_LEGACY_VETO_LIST_CONTEXT Context; 09748 UNICODE_STRING UnicodeString; 09749 09750 // 09751 // Initialize the veto list. 09752 // 09753 09754 if (VetoList != NULL) { 09755 *VetoList = NULL; 09756 } 09757 09758 // 09759 // Initialize the veto type. 09760 // 09761 09762 ASSERT(VetoType != NULL); 09763 09764 *VetoType = PNP_VetoTypeUnknown; 09765 09766 // 09767 // Initialize the status. 09768 // 09769 09770 Status = STATUS_SUCCESS; 09771 09772 if (PnPInitialized == FALSE) { 09773 09774 // 09775 // Can't touch anything, but nothing is really started either. 09776 // 09777 return Status; 09778 } 09779 09780 // 09781 // Initialize our local context. 09782 // 09783 09784 Context.VetoList = VetoList; 09785 Context.VetoListLength = 0; 09786 Context.VetoType = VetoType; 09787 Context.Status = &Status; 09788 09789 // 09790 // Enumerate all driver objects. This process can: (1) modify 09791 // the veto list, (2) modify the veto type and/or (3) modify the 09792 // status. 09793 // 09794 09795 IopGetLegacyVetoListDrivers(&Context); 09796 09797 // 09798 // If the driver enumeration process was successful and no legacy 09799 // drivers were detected, enumerate all device nodes. The same 09800 // context values as above may be modified during device enumeration. 09801 // 09802 09803 if (NT_SUCCESS(Status)) { 09804 09805 if (*VetoType == PNP_VetoTypeUnknown) { 09806 09807 IopAcquireEnumerationLock(NULL); 09808 09809 IopGetLegacyVetoListDeviceNode( 09810 IopRootDeviceNode, 09811 &Context 09812 ); 09813 09814 IopReleaseEnumerationLock(NULL); 09815 09816 } 09817 09818 } 09819 09820 // 09821 // If the previous operation(s) was/were successful, and the caller 09822 // provided a veto list pointer and we have constructed a veto 09823 // list, terminate the veto list with an empty string, i.e. MULTI_SZ. 09824 // 09825 09826 if (NT_SUCCESS(Status)) { 09827 09828 if (*VetoType != PNP_VetoTypeUnknown) { 09829 09830 if (VetoList != NULL) { 09831 09832 RtlInitUnicodeString( 09833 &UnicodeString, 09834 L"" 09835 ); 09836 09837 IopAppendLegacyVeto( 09838 &Context, 09839 &UnicodeString 09840 ); 09841 09842 } 09843 09844 } 09845 09846 } 09847 09848 // 09849 // If a previous operation was unsuccessful, free any veto list we may have 09850 // allocated along the way. 09851 // 09852 09853 if (!NT_SUCCESS(Status)) { 09854 09855 if (VetoList != NULL && *VetoList != NULL) { 09856 ExFreePool(*VetoList); 09857 *VetoList = NULL; 09858 } 09859 09860 } 09861 09862 return Status; 09863 }

NTKERNELAPI PDEVICE_OBJECT IoGetRelatedDeviceObject IN PFILE_OBJECT  FileObject  ) 
 

Definition at line 7247 of file iosubs.c.

References ASSERT, _DEVICE_OBJECT::AttachedDevice, _VPB::DeviceObject, FO_DIRECT_DEVICE_OPEN, IoGetAttachedDevice(), NULL, and _DEVICE_OBJECT::Vpb.

Referenced by BuildQueryDirectoryIrp(), CcMdlReadComplete(), CcMdlWriteComplete(), CcSetValidData(), CcZeroData(), FsRtlCopyRead(), FsRtlCopyWrite(), FsRtlGetFileSize(), FsRtlMdlRead(), FsRtlMdlReadComplete(), FsRtlMdlReadDev(), FsRtlMdlWriteComplete(), FsRtlPrepareMdlWrite(), FsRtlPrepareMdlWriteDev(), FsRtlSetFileSize(), IoAsynchronousPageWrite(), IoAttachDevice(), IoFreeDumpStack(), IoGetDeviceObjectPointer(), IoPageRead(), IopCloseFile(), IopDeleteFile(), IopGetDumpStack(), IopGetFileName(), IopGetRelatedTargetDevice(), IopGetSetObjectId(), IopGetSetSecurityObject(), IopGetVolumeId(), IopIsSameMachine(), IopOpenLinkOrRenameTarget(), IopParseDevice(), IopParseFile(), IopQueryXxxInformation(), IopSetEaOrQuotaInformationFile(), IopSetRemoteLink(), IopXxxControlFile(), IoSetInformation(), IoSynchronousPageWrite(), MiCheckPageFilePath(), NtCreatePagingFile(), NtFlushBuffersFile(), NtLockFile(), NtNotifyChangeDirectoryFile(), NtQueryEaFile(), NtQueryInformationFile(), NtQueryQuotaInformationFile(), NtQueryVolumeInformationFile(), NtReadFile(), NtReadFileScatter(), NtSetEaFile(), NtSetInformationFile(), NtSetVolumeInformationFile(), NtUnlockFile(), NtWriteFile(), NtWriteFileGather(), RemoteConnect(), and VdmQueryDirectoryFile().

07253 : 07254 07255 This routine returns a pointer to the actual device object than an I/O 07256 Request Packet (IRP) should be given to based on the specified file 07257 object. 07258 07259 N.B. - Callers of this function must ensure no device object is 07260 attaching or detaching from this stack for the duration of this call. 07261 This is because the database lock is *not* held! 07262 07263 Arguments: 07264 07265 FileObject - Pointer to the file object representing the open file. 07266 07267 Return Value: 07268 07269 The return value is a pointer to the device object for the driver to 07270 whom the request is to be given. 07271 07272 --*/ 07273 07274 { 07275 PDEVICE_OBJECT deviceObject; 07276 07277 // 07278 // If the file object was taken out against the mounted file system, it 07279 // will have a Vpb. Traverse it to get to the DeviceObject. Note that in 07280 // this case we should never follow FileObject->DeviceObject, as that 07281 // mapping may be invalid after a forced dismount. 07282 // 07283 07284 if (FileObject->Vpb != NULL && FileObject->Vpb->DeviceObject != NULL) { 07285 07286 ASSERT(!(FileObject->Flags & FO_DIRECT_DEVICE_OPEN)); 07287 deviceObject = FileObject->Vpb->DeviceObject; 07288 07289 07290 // 07291 // If a driver opened a disk device using direct device open and 07292 // later on it uses IoGetRelatedTargetDeviceObject to find the 07293 // device object it wants to send an IRP then it should not get the 07294 // filesystem device object. This is so that if the device object is in the 07295 // process of being mounted then vpb is not stable. 07296 // 07297 07298 } else if (!(FileObject->Flags & FO_DIRECT_DEVICE_OPEN) && 07299 FileObject->DeviceObject->Vpb != NULL && 07300 FileObject->DeviceObject->Vpb->DeviceObject != NULL) { 07301 07302 deviceObject = FileObject->DeviceObject->Vpb->DeviceObject; 07303 07304 // 07305 // This is a direct open against the device stack (and there is no mounted 07306 // file system to strain the IRPs through). 07307 // 07308 07309 } else { 07310 07311 deviceObject = FileObject->DeviceObject; 07312 } 07313 07314 ASSERT( deviceObject != NULL ); 07315 07316 // 07317 // Check to see whether or not the device has any associated devices. 07318 // If so, return the highest level device; otherwise, return a pointer 07319 // to the device object itself. 07320 // 07321 07322 if (deviceObject->AttachedDevice != NULL) { 07323 deviceObject = IoGetAttachedDevice( deviceObject ); 07324 } 07325 07326 return deviceObject; 07327 }

NTSTATUS IoGetRelatedTargetDevice IN PFILE_OBJECT  FileObject,
OUT PDEVICE_OBJECT DeviceObject
 

Definition at line 8120 of file pnpioapi.c.

References IopGetRelatedTargetDevice(), NT_SUCCESS, NTSTATUS(), NULL, and _DEVICE_NODE::PhysicalDeviceObject.

Referenced by FsRtlNotifyVolumeEvent(), and NtSetVolumeInformationFile().

08127 : 08128 08129 IoGetRelatedTargetDevice retrieves the device object associated with 08130 the specified file object and then sends a query device relations irp 08131 to that device object. 08132 08133 NOTE: The PDO associated with the returned device node has been referenced, 08134 and must be dereferenced when no longer needed. 08135 08136 Arguments: 08137 08138 FileObject - Specifies the file object that is associated with the device 08139 object that will receive the query device relations irp. 08140 08141 DeviceObject - Returns the related target device object. 08142 08143 ReturnValue 08144 08145 Returns an NTSTATUS value. 08146 08147 --*/ 08148 08149 { 08150 NTSTATUS status; 08151 PDEVICE_NODE deviceNode = NULL; 08152 08153 status = IopGetRelatedTargetDevice( FileObject, &deviceNode ); 08154 if (NT_SUCCESS(status) && deviceNode != NULL) { 08155 *DeviceObject = deviceNode->PhysicalDeviceObject; 08156 } 08157 return status; 08158 }

__inline ULONG_PTR IoGetRemainingStackSize VOID   ) 
 

Definition at line 3363 of file io.h.

References IoGetStackLimits().

03366 { 03367 ULONG_PTR Top; 03368 ULONG_PTR Bottom; 03369 03370 IoGetStackLimits( &Bottom, &Top ); 03371 return((ULONG_PTR)(&Top) - Bottom ); 03372 }

NTKERNELAPI PEPROCESS IoGetRequestorProcess IN PIRP  Irp  ) 
 

Definition at line 7374 of file iosubs.c.

References Irp, NULL, _IRP::Tail, and THREAD_TO_PROCESS.

Referenced by FsRtlCheckLockForReadAccess(), FsRtlCheckLockForWriteAccess(), FsRtlPrivateCheckWaitingLocks(), FsRtlPrivateFastUnlockAll(), FsRtlProcessFileLock(), IoGetRequestorProcessId(), and UdfCommonCleanup().

07380 : 07381 07382 This routine returns a pointer to the process that originally 07383 requested the specified I/O operation. 07384 07385 Arguments: 07386 07387 Irp - Pointer to the I/O Request Packet. 07388 07389 Return Value: 07390 07391 The function value is a pointer to the original requesting process. 07392 07393 07394 --*/ 07395 07396 { 07397 // 07398 // Return the address of the process that requested the I/O operation. 07399 // 07400 07401 if (Irp->Tail.Overlay.Thread) { 07402 return THREAD_TO_PROCESS( Irp->Tail.Overlay.Thread ); 07403 } else { 07404 return NULL; 07405 } 07406 }

NTKERNELAPI ULONG IoGetRequestorProcessId IN PIRP  Irp  ) 
 

Definition at line 7330 of file iosubs.c.

References IoGetRequestorProcess(), Irp, NULL, and _EPROCESS::UniqueProcessId.

07336 : 07337 07338 This routine returns a 32-bit value that is unique to the process that 07339 originally requested the specified I/O operation. 07340 07341 Arguments: 07342 07343 Irp - Pointer to the I/O Request Packet. 07344 07345 Return Value: 07346 07347 The function value is the 32-bit process ID. 07348 07349 07350 --*/ 07351 07352 { 07353 PEPROCESS process; 07354 07355 process = IoGetRequestorProcess( Irp ); 07356 if (process != NULL) { 07357 07358 // 07359 // UniqueProcessId is a kernel-mode handle, safe to truncate to ULONG. 07360 // 07361 07362 return HandleToUlong( process->UniqueProcessId ); 07363 } else { 07364 07365 // 07366 // Return a PID of zero if there is no process associated with the IRP. 07367 // 07368 07369 return 0; 07370 } 07371 }

NTKERNELAPI NTSTATUS IoGetRequestorSessionId IN PIRP  Irp,
OUT PULONG  pSessionId
 

Definition at line 12301 of file iosubs.c.

References Irp, _EPROCESS::SessionId, _IRP::Tail, and THREAD_TO_PROCESS.

12308 : 12309 12310 This routine returns the session ID for process that originally 12311 requested the specified I/O operation. 12312 12313 Arguments: 12314 12315 Irp - Pointer to the I/O Request Packet. 12316 12317 pSessionId - Pointer to the session Id which is set upon successful return. 12318 12319 Return Value: 12320 12321 Returns STATUS_SUCCESS if the session ID was available, otherwise 12322 STATUS_UNSUCCESSFUL. 12323 12324 --*/ 12325 12326 { 12327 PEPROCESS Process; 12328 12329 // 12330 // Get the address of the process that requested the I/O operation. 12331 // 12332 12333 if (Irp->Tail.Overlay.Thread) { 12334 Process = THREAD_TO_PROCESS( Irp->Tail.Overlay.Thread ); 12335 *pSessionId = Process->SessionId; 12336 return(STATUS_SUCCESS); 12337 } 12338 12339 *pSessionId = (ULONG) -1; 12340 return(STATUS_UNSUCCESSFUL); 12341 }

NTKERNELAPI VOID IoGetStackLimits OUT PULONG_PTR  LowLimit,
OUT PULONG_PTR  HighLimit
 

Referenced by IoGetRemainingStackSize(), and UdfSetThreadContext().

NTKERNELAPI PIRP IoGetTopLevelIrp VOID   ) 
 

Definition at line 7409 of file iosubs.c.

References PsGetCurrentThread.

Referenced by UdfAcquireForCache(), UdfFsdDispatch(), UdfReleaseFromCache(), and UdfSetThreadContext().

07415 : 07416 07417 This routine returns the contents of the TopLevelIrp field of the current 07418 thread. 07419 07420 Arguments: 07421 07422 None. 07423 07424 Return Value: 07425 07426 The final function value is the contents of the TopLevelIrp field. 07427 07428 Note: 07429 07430 This function cannot be made a macro, since fields in the thread object 07431 move from release to release, so this must remain a full function. 07432 07433 --*/ 07434 07435 { 07436 // 07437 // Simply return the TopLevelIrp field of the thread. 07438 // 07439 07440 return (PIRP) (PsGetCurrentThread()->TopLevelIrp); 07441 }

NTSTATUS IoInitializeDumpStack IN PDUMP_STACK_CONTEXT  DumpStack,
IN PUCHAR MessageBuffer  OPTIONAL
 

Definition at line 1142 of file dumpctl.c.

References InbvDisplayString(), IoDebugPrint, NT_SUCCESS, NTSTATUS(), NULL, _INITIALIZATION_CONTEXT::OpenRoutine, PDRIVER_INITIALIZE, PDUMP_STACK_IMAGE, and Status.

Referenced by IoWriteCrashDump().

01148 : 01149 01150 Initialize the dump driver stack referenced by DumpStack to perform IO. 01151 01152 Arguments: 01153 01154 DumpStack - Dump driver stack being initialized 01155 01156 Return Value: 01157 01158 Status 01159 01160 --*/ 01161 { 01162 01163 PINITIALIZATION_CONTEXT DumpInit; 01164 PLIST_ENTRY Link; 01165 ULONG Check; 01166 NTSTATUS Status; 01167 PDRIVER_INITIALIZE DriverInit; 01168 PDUMP_STACK_IMAGE DumpImage; 01169 01170 01171 DumpInit = &DumpStack->Init; 01172 01173 // 01174 // Verify checksum on DumpStack structure 01175 // 01176 01177 // BUGBUG: later 01178 01179 // 01180 // Initializes the dump drivers 01181 // 01182 01183 for (Link = DumpStack->DriverList.Flink; 01184 Link != &DumpStack->DriverList; 01185 Link = Link->Flink) { 01186 01187 DumpImage = CONTAINING_RECORD(Link, DUMP_STACK_IMAGE, Link); 01188 01189 // 01190 // Call this driver's driver init. Only the first driver gets the 01191 // dump initialization context 01192 // 01193 01194 DriverInit = DumpImage->Image->EntryPoint; 01195 Status = DriverInit (NULL, (PUNICODE_STRING) DumpInit); 01196 DumpInit = NULL; 01197 01198 if (!NT_SUCCESS(Status)) { 01199 IoDebugPrint ((0, 01200 "IODUMP: Unable to initialize driver; error = %x\n", 01201 Status 01202 )); 01203 return Status; 01204 } 01205 } 01206 01207 DumpInit = &DumpStack->Init; 01208 01209 // 01210 // Display string we are starting 01211 // 01212 01213 if (MessageBuffer) { 01214 InbvDisplayString (MessageBuffer); 01215 } 01216 01217 // 01218 // Open the partition from which the system was booted. 01219 // This returns TRUE if the disk w/the appropriate signature was found, 01220 // otherwise a NULL, in which case there is no way to continue. 01221 // 01222 01223 if (!DumpInit->OpenRoutine (DumpStack->PartitionOffset)) { 01224 IoDebugPrint (( 0, "IODUMP: Could not find/open partition offset\n" )); 01225 return STATUS_UNSUCCESSFUL; 01226 } 01227 01228 return STATUS_SUCCESS; 01229 }

NTKERNELAPI VOID IoInitializeIrp IN OUT PIRP  Irp,
IN USHORT  PacketSize,
IN CCHAR  StackSize
 

Definition at line 7444 of file iosubs.c.

References _IRP::ApcEnvironment, _IRP::CurrentLocation, IO_TYPE_IRP, IOV_INITIALIZE_IRP, Irp, KeGetCurrentApcEnvironment, _IRP::Size, _IRP::StackCount, _IRP::Tail, _IRP::Type, and USHORT.

Referenced by IopAllocateIrpMustSucceed().

07452 : 07453 07454 Initializes an IRP. 07455 07456 Arguments: 07457 07458 Irp - a pointer to the IRP to initialize. 07459 07460 PacketSize - length, in bytes, of the IRP. 07461 07462 StackSize - Number of stack locations in the IRP. 07463 07464 Return Value: 07465 07466 None. 07467 07468 --*/ 07469 07470 { 07471 IOV_INITIALIZE_IRP(Irp, PacketSize, StackSize); 07472 07473 // 07474 // Begin by zeroing the entire packet. 07475 // 07476 07477 RtlZeroMemory( Irp, PacketSize ); 07478 07479 // 07480 // Initialize the remainder of the packet by setting the appropriate fields 07481 // and setting up the I/O stack locations in the packet. 07482 // 07483 07484 Irp->Type = (CSHORT) IO_TYPE_IRP; 07485 Irp->Size = (USHORT) PacketSize; 07486 Irp->StackCount = (CCHAR) StackSize; 07487 Irp->CurrentLocation = (CCHAR) (StackSize + 1); 07488 Irp->ApcEnvironment = KeGetCurrentApcEnvironment(); 07489 InitializeListHead (&(Irp)->ThreadListEntry); 07490 Irp->Tail.Overlay.CurrentStackLocation = 07491 ((PIO_STACK_LOCATION) ((UCHAR *) (Irp) + 07492 sizeof( IRP ) + 07493 ( (StackSize) * sizeof( IO_STACK_LOCATION )))); 07494 }

NTSYSAPI VOID NTAPI IoInitializeRemoveLockEx IN PIO_REMOVE_LOCK  Lock,
IN ULONG  AllocateTag,
IN ULONG  MaxLockedMinutes,
IN ULONG  HighWatermark,
IN ULONG  RemlockSize
 

Definition at line 61 of file io/remlock.c.

References CHECKEDSIZE, FALSE, FREESIZE, IO_REMOVE_LOCK_SIG, KeInitializeEvent, KeInitializeSpinLock(), Lock, MinutesToTicks, NULL, PAGED_CODE, and PIO_PRIVATE_REMOVE_LOCK.

00070 : 00071 00072 This routine is called to initialize the remove lock for a device object. 00073 00074 --*/ 00075 { 00076 PIO_PRIVATE_REMOVE_LOCK Lock = (PIO_PRIVATE_REMOVE_LOCK) PublicLock; 00077 00078 PAGED_CODE (); 00079 00080 if (Lock) { 00081 00082 switch (RemlockSize) { 00083 00084 case CHECKEDSIZE: 00085 Lock->Dbg.Signature = IO_REMOVE_LOCK_SIG; 00086 Lock->Dbg.HighWatermark = HighWatermark; 00087 Lock->Dbg.MaxLockedTicks = MinutesToTicks (MaxLockedMinutes); 00088 Lock->Dbg.AllocateTag = AllocateTag; 00089 KeInitializeSpinLock (&Lock->Dbg.Spin); 00090 Lock->Dbg.LowMemoryCount = 0; 00091 Lock->Dbg.Blocks = NULL; 00092 00093 // 00094 // fall through 00095 // 00096 case FREESIZE: 00097 Lock->Common.Removed = FALSE; 00098 Lock->Common.IoCount = 1; 00099 KeInitializeEvent(&Lock->Common.RemoveEvent, 00100 SynchronizationEvent, 00101 FALSE); 00102 break; 00103 00104 default: 00105 break; 00106 } 00107 } 00108 }

NTKERNELAPI NTSTATUS IoInitializeTimer IN PDEVICE_OBJECT  DeviceObject,
IN PIO_TIMER_ROUTINE  TimerRoutine,
IN PVOID  Context
 

Definition at line 7543 of file iosubs.c.

References _IO_TIMER::Context, _IO_TIMER::DeviceObject, ExAllocatePoolWithTag, ExInterlockedInsertTailList(), IO_TIMER, IO_TYPE_TIMER, IopTimerLock, IopTimerQueueHead, NonPagedPool, PAGED_CODE, _DEVICE_OBJECT::Timer, _IO_TIMER::TimerList, _IO_TIMER::TimerRoutine, and _IO_TIMER::Type.

Referenced by IovInitializeTimer().

07551 : 07552 07553 This routine is used by drivers to initialize a timer entry for a device 07554 object. 07555 07556 Arguments: 07557 07558 DeviceObject - Pointer to device object to be used. 07559 07560 TimerRoutine - Driver routine to be executed when timer expires. 07561 07562 Context - Context parameter that is passed to the driver routine. 07563 07564 Return Value: 07565 07566 The function value indicates whether or not the timer was initialized. 07567 07568 --*/ 07569 07570 { 07571 PIO_TIMER timer; 07572 07573 PAGED_CODE(); 07574 07575 // 07576 // Begin by getting the address of the timer to be used. If no timer has 07577 // been allocated, allocate one and initialize it. 07578 // 07579 07580 timer = DeviceObject->Timer; 07581 if (!timer) { 07582 timer = ExAllocatePoolWithTag( NonPagedPool, sizeof( IO_TIMER ), 'iToI' ); 07583 if (!timer) { 07584 return STATUS_INSUFFICIENT_RESOURCES; 07585 } 07586 07587 // 07588 // Initialize the timer entry so that it is suitable for being placed 07589 // into the I/O system's timer queue. 07590 // 07591 07592 RtlZeroMemory( timer, sizeof( IO_TIMER ) ); 07593 timer->Type = IO_TYPE_TIMER; 07594 timer->DeviceObject = DeviceObject; 07595 DeviceObject->Timer = timer; 07596 } 07597 07598 // 07599 // Set the address of the driver's timer routine and the context parameter 07600 // passed to it and insert it onto the timer queue. Note that the timer 07601 // enable flag is not set, so this routine will not actually be invoked 07602 // yet. 07603 // 07604 07605 timer->TimerRoutine = TimerRoutine; 07606 timer->Context = Context; 07607 07608 ExInterlockedInsertTailList( &IopTimerQueueHead, 07609 &timer->TimerList, 07610 &IopTimerLock ); 07611 return STATUS_SUCCESS; 07612 }

NTKERNELAPI BOOLEAN IoInitSystem PLOADER_PARAMETER_BLOCK  LoaderBlock  ) 
 

Definition at line 270 of file ioinit.c.

References ASSERT, _DEVICE_NODE::Child, CmRegistryMachineSystemCurrentControlSetServicesEventLog, _REINIT_PACKET::Context, _DRIVER_EXTENSION::Count, DbgPrint, DEFAULT_LARGE_IRP_LOCATIONS, DEFAULT_LOOKASIDE_IRP_LIMIT, DNF_HAL_NODE, DNF_LEGACY_DRIVER, DNF_STARTED, _DRIVER_OBJECT::DriverExtension, _REINIT_PACKET::DriverObject, _REINIT_PACKET::DriverReinitializationRoutine, DRVO_REINIT_REGISTERED, _LINK_TRACKING_PACKET::Event, ExAllocatePoolWithTag, ExEventObjectType, ExFreePool(), ExInitializeNPagedLookasideList(), ExInitializeResource, ExInitializeWorkItem, ExInterlockedRemoveHeadList(), _IOP_HARD_ERROR_QUEUE::ExWorkItem, FALSE, _DEVICE_NODE::Flags, _DRIVER_OBJECT::Flags, HalInitPnpDriver, Index, IoAssignDriveLetters(), IOP_FIXED_SIZE_MDL_PFNS, IOP_MINI_COMPLETION_PACKET, IopAddRemoteBootValuesToRegistry(), IopBootDriverReinitializeQueueHead, IopCancelSpinLock, IopCdRomFileSystemQueueHead, IopCompletionLock, IopCompletionLookasideList, IopCreateObjectTypes(), IopCreateRootDirectories(), IopCurrentHardError, IopDatabaseLock, IopDatabaseResource, IopDiskFileSystemQueueHead, IopDriverReinitializeQueueHead, IopErrorLogAllocationLock, IopErrorLogDisabledThisBoot, IopErrorLogListHead, IopErrorLogLock, IopFreeGroupTree(), IopFsNotifyChangeQueueHead, IopGroupListHead, IopHardError, IopHardErrorThread(), IopInitHalDeviceNode, IopInitializeBootDrivers(), IopInitializePlugPlayServices(), IopInitializeResourceMap(), IopInitializeSystemDrivers(), IopLargeIrpLookasideList, IopLargeIrpStackLocations, IopLinkTrackingPacket, IopLinkTrackingPortObject, IopLinkTrackingServiceEvent, IopLoaderBlock, IopLookasideIrpLimit, IopMdlLookasideList, IopNetworkFileSystemQueueHead, IopNotifyLastChanceShutdownQueueHead, IopNotifyShutdownQueueHead, IopProfileChangeSemaphore, IopProtectSystemPartition(), IopQueryFsOperationAccess, IopQueryFsOperationLength, IopQueryOperationAccess, IopQueryOperationLength, IopReassignSystemRoot(), IopRegistrySemaphore, IopRootDeviceNode, IopSecurityResource, IopSetFsOperationAccess, IopSetFsOperationLength, IopSetIoRoutines(), IopSetOperationAccess, IopSetOperationLength, IopSmallIrpLookasideList, IopStartNetworkForRemoteBoot(), IopTapeFileSystemQueueHead, IopTimer, IopTimerDispatch(), IopTimerDpc, IopTimerLock, IopTimerQueueHead, IopUniqueDeviceObjectNumber, IopVpbSpinLock, IoRemoteBootClient, IoStatisticsLock, KeBugCheckEx(), KeInitializeDpc(), KeInitializeEvent, KeInitializeSemaphore(), KeInitializeSpinLock(), KeInitializeTimerEx(), KeNumberProcessors, KernelMode, KeSetTimerEx(), KiProcessorBlock, _NPAGED_LOOKASIDE_LIST::L, L, LookasideCompletionList, LookasideLargeIrpList, LookasideMdlList, LookasideSmallIrpList, MM_SYSTEMSIZE, MmIsThisAnNtAsSystem(), MmLargeSystem, MmMediumSystem, MmQuerySystemSize(), MmSmallSystem, NonPagedPool, NPAGED_LOOKASIDE_LIST, NT_SUCCESS, NtCreateEvent(), NtGlobalFlag, NtQueryValueKey(), NTSTATUS(), NtSystemRoot, NULL, ObReferenceObjectByHandle(), PoInitDriverServices(), PsLocateSystemDll(), RtlAllocateStringRoutine, RtlAnsiStringToUnicodeString(), RtlInitUnicodeString(), RtlUnicodeStringToAnsiString(), _DEVICE_NODE::Sibling, _IOP_HARD_ERROR_QUEUE::ThreadStarted, TRUE, USHORT, VOID(), WMIInitialize(), _IOP_HARD_ERROR_QUEUE::WorkQueue, _IOP_HARD_ERROR_QUEUE::WorkQueueSemaphore, and _IOP_HARD_ERROR_QUEUE::WorkQueueSpinLock.

00276 : 00277 00278 This routine initializes the I/O system. 00279 00280 Arguments: 00281 00282 LoaderBlock - Supplies a pointer to the loader parameter block that was 00283 created by the OS Loader. 00284 00285 Return Value: 00286 00287 The function value is a BOOLEAN indicating whether or not the I/O system 00288 was successfully initialized. 00289 00290 --*/ 00291 00292 { 00293 PDRIVER_OBJECT driverObject; 00294 PDRIVER_OBJECT *nextDriverObject; 00295 STRING ntDeviceName; 00296 UCHAR deviceNameBuffer[256]; 00297 ULONG largePacketSize; 00298 ULONG smallPacketSize; 00299 ULONG mdlPacketSize; 00300 ULONG numberOfPackets; 00301 ULONG poolSize; 00302 PLIST_ENTRY entry; 00303 PREINIT_PACKET reinitEntry; 00304 LARGE_INTEGER deltaTime; 00305 MM_SYSTEMSIZE systemSize; 00306 USHORT completionZoneSize; 00307 USHORT largeIrpZoneSize; 00308 USHORT smallIrpZoneSize; 00309 USHORT mdlZoneSize; 00310 ULONG oldNtGlobalFlag; 00311 NTSTATUS status; 00312 ANSI_STRING ansiString; 00313 UNICODE_STRING eventName; 00314 UNICODE_STRING startTypeName; 00315 OBJECT_ATTRIBUTES objectAttributes; 00316 HANDLE handle; 00317 PDEVICE_NODE deviceNode; 00318 PNPAGED_LOOKASIDE_LIST lookaside; 00319 ULONG Index; 00320 PKPRCB prcb; 00321 ULONG len; 00322 PKEY_VALUE_PARTIAL_INFORMATION value; 00323 UCHAR valueBuffer[32]; 00324 00325 ASSERT( IopQueryOperationLength[FileMaximumInformation] == 0xff ); 00326 ASSERT( IopSetOperationLength[FileMaximumInformation] == 0xff ); 00327 ASSERT( IopQueryOperationAccess[FileMaximumInformation] == 0xffffffff ); 00328 ASSERT( IopSetOperationAccess[FileMaximumInformation] == 0xffffffff ); 00329 00330 ASSERT( IopQueryFsOperationLength[FileFsMaximumInformation] == 0xff ); 00331 ASSERT( IopSetFsOperationLength[FileFsMaximumInformation] == 0xff ); 00332 ASSERT( IopQueryFsOperationAccess[FileFsMaximumInformation] == 0xffffffff ); 00333 ASSERT( IopSetFsOperationAccess[FileFsMaximumInformation] == 0xffffffff ); 00334 00335 // 00336 // Initialize the I/O database resource, lock, and the file system and 00337 // network file system queue headers. Also allocate the cancel spin 00338 // lock. 00339 // 00340 00341 ntDeviceName.Buffer = deviceNameBuffer; 00342 ntDeviceName.MaximumLength = sizeof(deviceNameBuffer); 00343 ntDeviceName.Length = 0; 00344 00345 ExInitializeResource( &IopDatabaseResource ); 00346 ExInitializeResource( &IopSecurityResource ); 00347 KeInitializeSpinLock( &IopDatabaseLock ); 00348 InitializeListHead( &IopDiskFileSystemQueueHead ); 00349 InitializeListHead( &IopCdRomFileSystemQueueHead ); 00350 InitializeListHead( &IopTapeFileSystemQueueHead ); 00351 InitializeListHead( &IopNetworkFileSystemQueueHead ); 00352 InitializeListHead( &IopBootDriverReinitializeQueueHead ); 00353 InitializeListHead( &IopDriverReinitializeQueueHead ); 00354 InitializeListHead( &IopNotifyShutdownQueueHead ); 00355 InitializeListHead( &IopNotifyLastChanceShutdownQueueHead ); 00356 InitializeListHead( &IopFsNotifyChangeQueueHead ); 00357 KeInitializeSpinLock( &IopCancelSpinLock ); 00358 KeInitializeSpinLock( &IopVpbSpinLock ); 00359 KeInitializeSpinLock( &IoStatisticsLock ); 00360 00361 IopSetIoRoutines(); 00362 // 00363 // Initialize the unique device object number counter used by IoCreateDevice 00364 // when automatically generating a device object name. 00365 // 00366 IopUniqueDeviceObjectNumber = 0; 00367 00368 // 00369 // Initialize the large I/O Request Packet (IRP) lookaside list head and the 00370 // mutex which guards the list. 00371 // 00372 00373 if (!IopLargeIrpStackLocations) { 00374 IopLargeIrpStackLocations = DEFAULT_LARGE_IRP_LOCATIONS; 00375 } 00376 00377 systemSize = MmQuerySystemSize(); 00378 00379 switch ( systemSize ) { 00380 00381 case MmSmallSystem : 00382 completionZoneSize = 6; 00383 smallIrpZoneSize = 6; 00384 largeIrpZoneSize = 8; 00385 mdlZoneSize = 16; 00386 IopLookasideIrpLimit = DEFAULT_LOOKASIDE_IRP_LIMIT; 00387 break; 00388 00389 case MmMediumSystem : 00390 completionZoneSize = 24; 00391 smallIrpZoneSize = 24; 00392 largeIrpZoneSize = 32; 00393 mdlZoneSize = 90; 00394 IopLookasideIrpLimit = DEFAULT_LOOKASIDE_IRP_LIMIT * 2; 00395 break; 00396 00397 case MmLargeSystem : 00398 if (MmIsThisAnNtAsSystem()) { 00399 completionZoneSize = 96; 00400 smallIrpZoneSize = 96; 00401 largeIrpZoneSize = 128; 00402 mdlZoneSize = 256; 00403 IopLookasideIrpLimit = DEFAULT_LOOKASIDE_IRP_LIMIT * 4; 00404 00405 } else { 00406 completionZoneSize = 32; 00407 smallIrpZoneSize = 32; 00408 largeIrpZoneSize = 64; 00409 mdlZoneSize = 128; 00410 IopLookasideIrpLimit = DEFAULT_LOOKASIDE_IRP_LIMIT * 3; 00411 } 00412 00413 break; 00414 } 00415 00416 // 00417 // Initialize the system I/O completion lookaside list. 00418 // 00419 00420 ExInitializeNPagedLookasideList( &IopCompletionLookasideList, 00421 NULL, 00422 NULL, 00423 0, 00424 sizeof(IOP_MINI_COMPLETION_PACKET), 00425 ' pcI', 00426 completionZoneSize ); 00427 00428 // 00429 // Initialize the system large IRP lookaside list. 00430 // 00431 00432 largePacketSize = (ULONG) (sizeof( IRP ) + (IopLargeIrpStackLocations * sizeof( IO_STACK_LOCATION ))); 00433 ExInitializeNPagedLookasideList( &IopLargeIrpLookasideList, 00434 NULL, 00435 NULL, 00436 0, 00437 largePacketSize, 00438 'lprI', 00439 largeIrpZoneSize ); 00440 00441 // 00442 // Initialize the system small IRP lookaside list. 00443 // 00444 00445 smallPacketSize = (ULONG) (sizeof( IRP ) + sizeof( IO_STACK_LOCATION )); 00446 ExInitializeNPagedLookasideList( &IopSmallIrpLookasideList, 00447 NULL, 00448 NULL, 00449 0, 00450 smallPacketSize, 00451 'sprI', 00452 smallIrpZoneSize ); 00453 00454 // 00455 // Initialize the system MDL lookaside list. 00456 // 00457 00458 mdlPacketSize = (ULONG) (sizeof( MDL ) + (IOP_FIXED_SIZE_MDL_PFNS * sizeof( PFN_NUMBER ))); 00459 ExInitializeNPagedLookasideList( &IopMdlLookasideList, 00460 NULL, 00461 NULL, 00462 0, 00463 mdlPacketSize, 00464 ' ldM', 00465 mdlZoneSize ); 00466 00467 // 00468 // Initialize the per processor nonpaged lookaside lists and descriptors. 00469 // 00470 00471 for (Index = 0; Index < (ULONG)KeNumberProcessors; Index += 1) { 00472 prcb = KiProcessorBlock[Index]; 00473 00474 // 00475 // Initialize the I/O completion per processor lookaside pointers 00476 // 00477 00478 prcb->PPLookasideList[LookasideCompletionList].L = &IopCompletionLookasideList; 00479 lookaside = (PNPAGED_LOOKASIDE_LIST)ExAllocatePoolWithTag( NonPagedPool, 00480 sizeof(NPAGED_LOOKASIDE_LIST), 00481 'PpcI'); 00482 00483 if (lookaside != NULL) { 00484 ExInitializeNPagedLookasideList( lookaside, 00485 NULL, 00486 NULL, 00487 0, 00488 sizeof(IOP_MINI_COMPLETION_PACKET), 00489 'PpcI', 00490 completionZoneSize ); 00491 00492 } else { 00493 lookaside = &IopCompletionLookasideList; 00494 } 00495 00496 prcb->PPLookasideList[LookasideCompletionList].P = lookaside; 00497 00498 // 00499 // Initialize the large IRP per processor lookaside pointers. 00500 // 00501 00502 prcb->PPLookasideList[LookasideLargeIrpList].L = &IopLargeIrpLookasideList; 00503 lookaside = (PNPAGED_LOOKASIDE_LIST)ExAllocatePoolWithTag( NonPagedPool, 00504 sizeof(NPAGED_LOOKASIDE_LIST), 00505 'LprI'); 00506 00507 if (lookaside != NULL) { 00508 ExInitializeNPagedLookasideList( lookaside, 00509 NULL, 00510 NULL, 00511 0, 00512 largePacketSize, 00513 'LprI', 00514 largeIrpZoneSize ); 00515 00516 } else { 00517 lookaside = &IopLargeIrpLookasideList; 00518 } 00519 00520 prcb->PPLookasideList[LookasideLargeIrpList].P = lookaside; 00521 00522 // 00523 // Initialize the small IRP per processor lookaside pointers. 00524 // 00525 00526 prcb->PPLookasideList[LookasideSmallIrpList].L = &IopSmallIrpLookasideList; 00527 lookaside = (PNPAGED_LOOKASIDE_LIST)ExAllocatePoolWithTag( NonPagedPool, 00528 sizeof(NPAGED_LOOKASIDE_LIST), 00529 'SprI'); 00530 00531 if (lookaside != NULL) { 00532 ExInitializeNPagedLookasideList( lookaside, 00533 NULL, 00534 NULL, 00535 0, 00536 smallPacketSize, 00537 'SprI', 00538 smallIrpZoneSize); 00539 00540 } else { 00541 lookaside = &IopSmallIrpLookasideList; 00542 } 00543 00544 prcb->PPLookasideList[LookasideSmallIrpList].P = lookaside; 00545 00546 // 00547 // Initialize the MDL per processor lookaside list pointers. 00548 // 00549 00550 prcb->PPLookasideList[LookasideMdlList].L = &IopMdlLookasideList; 00551 lookaside = (PNPAGED_LOOKASIDE_LIST)ExAllocatePoolWithTag( NonPagedPool, 00552 sizeof(NPAGED_LOOKASIDE_LIST), 00553 'PldM'); 00554 00555 if (lookaside != NULL) { 00556 ExInitializeNPagedLookasideList( lookaside, 00557 NULL, 00558 NULL, 00559 0, 00560 mdlPacketSize, 00561 'PldM', 00562 mdlZoneSize ); 00563 00564 } else { 00565 lookaside = &IopMdlLookasideList; 00566 } 00567 00568 prcb->PPLookasideList[LookasideMdlList].P = lookaside; 00569 } 00570 00571 // 00572 // Initialize the I/O completion spin lock. 00573 // 00574 00575 KeInitializeSpinLock( &IopCompletionLock ); 00576 00577 // 00578 // Initalize the error log spin locks and log list. 00579 // 00580 00581 KeInitializeSpinLock( &IopErrorLogLock ); 00582 KeInitializeSpinLock( &IopErrorLogAllocationLock ); 00583 InitializeListHead( &IopErrorLogListHead ); 00584 00585 // 00586 // Determine if the Error Log service will ever run this boot. 00587 // 00588 InitializeObjectAttributes (&objectAttributes, 00589 &CmRegistryMachineSystemCurrentControlSetServicesEventLog, 00590 OBJ_CASE_INSENSITIVE, 00591 (HANDLE) NULL, 00592 (PSECURITY_DESCRIPTOR) NULL ); 00593 00594 status = ZwOpenKey(&handle, 00595 KEY_READ, 00596 &objectAttributes 00597 ); 00598 00599 if (NT_SUCCESS (status)) { 00600 RtlInitUnicodeString (&startTypeName, L"Start"); 00601 value = (PKEY_VALUE_PARTIAL_INFORMATION) valueBuffer; 00602 status = NtQueryValueKey (handle, 00603 &startTypeName, 00604 KeyValuePartialInformation, 00605 valueBuffer, 00606 sizeof (valueBuffer), 00607 &len); 00608 00609 if (NT_SUCCESS (status) && (value->Type == REG_DWORD)) { 00610 if (SERVICE_DISABLED == (*(PULONG) (value->Data))) { 00611 // 00612 // We are disabled for this boot. 00613 // 00614 IopErrorLogDisabledThisBoot = TRUE; 00615 } else { 00616 IopErrorLogDisabledThisBoot = FALSE; 00617 } 00618 } else { 00619 // 00620 // Didn't find the value so we are not enabled. 00621 // 00622 IopErrorLogDisabledThisBoot = TRUE; 00623 } 00624 } else { 00625 // 00626 // Didn't find the key so we are not enabled 00627 // 00628 IopErrorLogDisabledThisBoot = TRUE; 00629 } 00630 00631 // 00632 // Initialize the registry access semaphore. 00633 // 00634 00635 KeInitializeSemaphore( &IopRegistrySemaphore, 1, 1 ); 00636 00637 // 00638 // Initialize the timer database and start the timer DPC routine firing 00639 // so that drivers can use it during initialization. 00640 // 00641 00642 deltaTime.QuadPart = - 10 * 1000 * 1000; 00643 00644 KeInitializeSpinLock( &IopTimerLock ); 00645 InitializeListHead( &IopTimerQueueHead ); 00646 KeInitializeDpc( &IopTimerDpc, IopTimerDispatch, NULL ); 00647 KeInitializeTimerEx( &IopTimer, SynchronizationTimer ); 00648 (VOID) KeSetTimerEx( &IopTimer, deltaTime, 1000, &IopTimerDpc ); 00649 00650 // 00651 // Initialize the IopHardError structure used for informational pop-ups. 00652 // 00653 00654 ExInitializeWorkItem( &IopHardError.ExWorkItem, 00655 IopHardErrorThread, 00656 NULL ); 00657 00658 InitializeListHead( &IopHardError.WorkQueue ); 00659 00660 KeInitializeSpinLock( &IopHardError.WorkQueueSpinLock ); 00661 00662 KeInitializeSemaphore( &IopHardError.WorkQueueSemaphore, 00663 0, 00664 MAXLONG ); 00665 00666 IopHardError.ThreadStarted = FALSE; 00667 00668 IopCurrentHardError = NULL; 00669 00670 // 00671 // Create the link tracking named event. 00672 // 00673 00674 RtlInitUnicodeString( &eventName, L"\\Security\\TRKWKS_EVENT" ); 00675 InitializeObjectAttributes( &objectAttributes, 00676 &eventName, 00677 OBJ_PERMANENT, 00678 (HANDLE) NULL, 00679 (PSECURITY_DESCRIPTOR) NULL ); 00680 status = NtCreateEvent( &handle, 00681 EVENT_ALL_ACCESS, 00682 &objectAttributes, 00683 NotificationEvent, 00684 FALSE ); 00685 if (!NT_SUCCESS( status )) { 00686 #if DBG 00687 DbgPrint( "IOINIT: NtCreateEvent failed\n" ); 00688 #endif 00689 return FALSE; 00690 } 00691 00692 (VOID) ObReferenceObjectByHandle( handle, 00693 0, 00694 ExEventObjectType, 00695 KernelMode, 00696 (PVOID *) &IopLinkTrackingServiceEvent, 00697 NULL ); 00698 00699 KeInitializeEvent( &IopLinkTrackingPacket.Event, NotificationEvent, FALSE ); 00700 KeInitializeEvent(&IopLinkTrackingPortObject, SynchronizationEvent, TRUE ); 00701 00702 KeInitializeSemaphore(&IopProfileChangeSemaphore, 1, 1) ; 00703 00704 // 00705 // Create all of the objects for the I/O system. 00706 // 00707 00708 if (!IopCreateObjectTypes()) { 00709 #if DBG 00710 DbgPrint( "IOINIT: IopCreateObjectTypes failed\n" ); 00711 #endif 00712 return FALSE; 00713 } 00714 00715 // 00716 // Create the root directories for the I/O system. 00717 // 00718 00719 if (!IopCreateRootDirectories()) { 00720 #if DBG 00721 DbgPrint( "IOINIT: IopCreateRootDirectories failed\n" ); 00722 #endif 00723 return FALSE; 00724 } 00725 00726 // 00727 // Initialize the resource map 00728 // 00729 00730 IopInitializeResourceMap (LoaderBlock); 00731 00732 // 00733 // Initialize PlugPlay services phase 0 00734 // 00735 00736 status = IopInitializePlugPlayServices(LoaderBlock, 0); 00737 if (!NT_SUCCESS(status)) { 00738 return FALSE; 00739 } 00740 00741 // 00742 // Call Power manager to initialize for drivers 00743 // 00744 00745 PoInitDriverServices(0); 00746 00747 // 00748 // Call HAL to initialize PnP bus driver 00749 // 00750 00751 HalInitPnpDriver(); 00752 deviceNode = IopRootDeviceNode->Child; 00753 while (deviceNode) { 00754 if ((deviceNode->Flags & DNF_STARTED) && 00755 !(deviceNode->Flags & DNF_LEGACY_DRIVER)) { 00756 IopInitHalDeviceNode = deviceNode; 00757 deviceNode->Flags |= DNF_HAL_NODE; 00758 break; 00759 } 00760 deviceNode = deviceNode->Sibling; 00761 } 00762 00763 // 00764 // Call WMI to initialize it and allow it to create its driver object 00765 // Note that no calls to WMI can occur until it is initialized here. 00766 // 00767 00768 WMIInitialize(); 00769 00770 // 00771 // Save this for use during PnP enumeration -- we NULL it out later 00772 // before LoaderBlock is reused. 00773 // 00774 00775 IopLoaderBlock = (PVOID)LoaderBlock; 00776 00777 // 00778 // If this is a remote boot, we need to add a few values to the registry. 00779 // 00780 00781 if (IoRemoteBootClient) { 00782 status = IopAddRemoteBootValuesToRegistry(LoaderBlock); 00783 if (!NT_SUCCESS(status)) { 00784 KeBugCheckEx( NETWORK_BOOT_INITIALIZATION_FAILED, 00785 1, 00786 status, 00787 0, 00788 0 ); 00789 } 00790 } 00791 00792 // 00793 // Initialize PlugPlay services phase 1 to execute firmware mapper 00794 // 00795 00796 status = IopInitializePlugPlayServices(LoaderBlock, 1); 00797 if (!NT_SUCCESS(status)) { 00798 return FALSE; 00799 } 00800 00801 // 00802 // Initialize the drivers loaded by the boot loader (OSLOADER) 00803 // 00804 00805 nextDriverObject = &driverObject; 00806 if (!IopInitializeBootDrivers( LoaderBlock, 00807 nextDriverObject )) { 00808 #if DBG 00809 DbgPrint( "IOINIT: Initializing boot drivers failed\n" ); 00810 #endif // DBG 00811 return FALSE; 00812 } 00813 00814 // 00815 // Once we have initialized the boot drivers, we don't need the 00816 // copy of the pointer to the loader block any more. 00817 // 00818 00819 IopLoaderBlock = NULL; 00820 00821 // 00822 // If this is a remote boot, start the network and assign 00823 // C: to \Device\LanmanRedirector. 00824 // 00825 00826 if (IoRemoteBootClient) { 00827 status = IopStartNetworkForRemoteBoot(LoaderBlock); 00828 if (!NT_SUCCESS( status )) { 00829 KeBugCheckEx( NETWORK_BOOT_INITIALIZATION_FAILED, 00830 2, 00831 status, 00832 0, 00833 0 ); 00834 } 00835 } 00836 00837 // 00838 // Save the current value of the NT Global Flags and enable kernel debugger 00839 // symbol loading while drivers are being loaded so that systems can be 00840 // debugged regardless of whether they are free or checked builds. 00841 // 00842 00843 oldNtGlobalFlag = NtGlobalFlag; 00844 00845 if (!(NtGlobalFlag & FLG_ENABLE_KDEBUG_SYMBOL_LOAD)) { 00846 NtGlobalFlag |= FLG_ENABLE_KDEBUG_SYMBOL_LOAD; 00847 } 00848 00849 status = PsLocateSystemDll(); 00850 if (!NT_SUCCESS( status )) { 00851 return FALSE; 00852 } 00853 00854 // 00855 // Initialize the device drivers for the system. 00856 // 00857 00858 if (!IopInitializeSystemDrivers()) { 00859 #if DBG 00860 DbgPrint( "IOINIT: Initializing system drivers failed\n" ); 00861 #endif // DBG 00862 return FALSE; 00863 } 00864 00865 // 00866 // Free the memory allocated to contain the group dependency list. 00867 // 00868 00869 if (IopGroupListHead) { 00870 IopFreeGroupTree( IopGroupListHead ); 00871 } 00872 00873 // 00874 // Walk the list of drivers that have requested that they be called again 00875 // for reinitialization purposes. 00876 // 00877 00878 while (entry = ExInterlockedRemoveHeadList( &IopDriverReinitializeQueueHead, &IopDatabaseLock )) { 00879 reinitEntry = CONTAINING_RECORD( entry, REINIT_PACKET, ListEntry ); 00880 reinitEntry->DriverObject->DriverExtension->Count++; 00881 reinitEntry->DriverObject->Flags &= ~DRVO_REINIT_REGISTERED; 00882 reinitEntry->DriverReinitializationRoutine( reinitEntry->DriverObject, 00883 reinitEntry->Context, 00884 reinitEntry->DriverObject->DriverExtension->Count ); 00885 ExFreePool( reinitEntry ); 00886 } 00887 00888 // 00889 // Reassign \SystemRoot to NT device name path. 00890 // 00891 00892 if (!IopReassignSystemRoot( LoaderBlock, &ntDeviceName )) { 00893 return FALSE; 00894 } 00895 00896 // 00897 // Protect the system partition of an ARC system if necessary 00898 // 00899 00900 if (!IopProtectSystemPartition( LoaderBlock )) { 00901 return(FALSE); 00902 } 00903 00904 // 00905 // Assign DOS drive letters to disks and cdroms and define \SystemRoot. 00906 // 00907 00908 ansiString.MaximumLength = NtSystemRoot.MaximumLength / sizeof( WCHAR ); 00909 ansiString.Length = 0; 00910 ansiString.Buffer = (RtlAllocateStringRoutine)( ansiString.MaximumLength ); 00911 status = RtlUnicodeStringToAnsiString( &ansiString, 00912 &NtSystemRoot, 00913 FALSE 00914 ); 00915 if (!NT_SUCCESS( status )) { 00916 DbgPrint( "IOINIT: UnicodeToAnsi( %wZ ) failed - %x\n", &NtSystemRoot, status ); 00917 return(FALSE); 00918 } 00919 00920 IoAssignDriveLetters( LoaderBlock, 00921 &ntDeviceName, 00922 ansiString.Buffer, 00923 &ansiString ); 00924 00925 status = RtlAnsiStringToUnicodeString( &NtSystemRoot, 00926 &ansiString, 00927 FALSE 00928 ); 00929 if (!NT_SUCCESS( status )) { 00930 DbgPrint( "IOINIT: AnsiToUnicode( %Z ) failed - %x\n", &ansiString, status ); 00931 return(FALSE); 00932 } 00933 00934 // 00935 // Also restore the NT Global Flags to their original state. 00936 // 00937 00938 NtGlobalFlag = oldNtGlobalFlag; 00939 00940 // 00941 // Call Power manager to initialize for post-boot drivers 00942 // 00943 PoInitDriverServices(1); 00944 00945 // 00946 // Indicate that the I/O system successfully initialized itself. 00947 // 00948 00949 return TRUE; 00950 }

NTKERNELAPI BOOLEAN IoIsOperationSynchronous IN PIRP  Irp  ) 
 

Definition at line 7615 of file iosubs.c.

References FALSE, _IRP::Flags, FO_SYNCHRONOUS_IO, IoGetCurrentIrpStackLocation, Irp, IRP_PAGING_IO, IRP_SYNCHRONOUS_API, IRP_SYNCHRONOUS_PAGING_IO, and TRUE.

Referenced by FsRtlAcknowledgeOplockBreak(), and FsRtlOplockFsctrl().

07621 : 07622 07623 This routine determines whether an I/O operation is to be considered 07624 synchronous or an asynchronous, from the implementors point-of-view. 07625 Synchronous I/O is defined by how the file was opened, or the API being 07626 used to perform the operation, or by the type of paging I/O being 07627 performed, if the operation is paging I/O. 07628 07629 It is possible for asynchronous paging I/O to occur to a file that was 07630 opened for synchronous I/O. This occurs when the Modified Page Writer 07631 is doing I/O to a file that is mapped, when too many modified pages exist 07632 in the system. 07633 07634 Arguments: 07635 07636 Irp - Pointer to the I/O Request Packet (IRP) representing the operation 07637 to be performed. 07638 07639 Return Value: 07640 07641 A value of TRUE is returned if the operation is synchronous, otherwise 07642 FALSE is returned. 07643 07644 --*/ 07645 07646 { 07647 // 07648 // Determine whether this is a synchronous I/O operation. Synchronous I/O 07649 // is defined as an operation that is: 07650 // 07651 // A file opened for synchronous I/O 07652 // OR 07653 // A synchronous API operation 07654 // OR 07655 // A synchronous paging I/O operation 07656 // 07657 // AND this is NOT an asynchronous paging I/O operation occurring to some 07658 // file that was opened for either synchronous or asynchronous I/O. 07659 // 07660 07661 if ((IoGetCurrentIrpStackLocation( Irp )->FileObject->Flags & FO_SYNCHRONOUS_IO || 07662 Irp->Flags & IRP_SYNCHRONOUS_API || 07663 Irp->Flags & IRP_SYNCHRONOUS_PAGING_IO) && 07664 !(Irp->Flags & IRP_PAGING_IO && 07665 !(Irp->Flags & IRP_SYNCHRONOUS_PAGING_IO))) { 07666 return TRUE; 07667 } else { 07668 return FALSE; 07669 } 07670 }

NTKERNELAPI BOOLEAN IoIsSystemThread IN PETHREAD  Thread  ) 
 

Definition at line 7673 of file iosubs.c.

References IS_SYSTEM_THREAD.

07679 : 07680 07681 This routine returns a BOOLEAN indicating whether or not the specified 07682 thread is a system thread. 07683 07684 Arguments: 07685 07686 Thread - Pointer to the thread to be checked. 07687 07688 Return Value: 07689 07690 A value of TRUE is returned if the indicated thread is a system thread, 07691 else FALSE. 07692 07693 Note: 07694 07695 This function cannot be made a macro, since fields in the thread object 07696 move from release to release, so this must remain a full function. 07697 07698 --*/ 07699 07700 { 07701 return (BOOLEAN) IS_SYSTEM_THREAD(Thread); 07702 }

NTKERNELAPI BOOLEAN IoIsValidNameGraftingBuffer IN PIRP  Irp,
IN PREPARSE_DATA_BUFFER  ReparseBuffer
 

Definition at line 7705 of file iosubs.c.

References ASSERT, ExAllocatePoolWithTag, ExFreePool(), FALSE, IoGetCurrentIrpStackLocation, Irp, L, NonPagedPool, NT_SUCCESS, NtClose(), NTSTATUS(), NULL, _IO_STACK_LOCATION::Parameters, RtlInitUnicodeString(), TRUE, and USHORT.

07712 : 07713 07714 This routine returns a BOOLEAN indicating whether or not the specified 07715 buffer is a valid name grafting buffer. All internal validity checks are 07716 encapsulated in this routine. 07717 07718 Among the checks performed is whether the name lengths stored within the 07719 buffer in the private data section are compatible with the total size of 07720 the buffer that has been passed in. 07721 07722 Arguments: 07723 07724 Irp - Pointer to the I/O Request Packet (IRP) representing the operation 07725 to be performed. 07726 07727 Buffer - Pointer to a reparse data buffer that is supposed to contain 07728 a self-consistent set of names to perform name grafting. 07729 07730 Return Value: 07731 07732 A value of TRUE is returned if the buffer is correct for name grafting, 07733 else FALSE. 07734 07735 Note: 07736 07737 This function needs to be kept synchronized with the definition of 07738 REPARSE_DATA_BUFFER. 07739 07740 --*/ 07741 07742 { 07743 PIO_STACK_LOCATION thisStackPointer = NULL; 07744 UNICODE_STRING drivePath; 07745 07746 ASSERT( FIELD_OFFSET( REPARSE_DATA_BUFFER, SymbolicLinkReparseBuffer.PathBuffer[0] ) == 07747 FIELD_OFFSET( REPARSE_DATA_BUFFER, MountPointReparseBuffer.PathBuffer[0] ) ); 07748 ASSERT( ReparseBuffer->ReparseDataLength < MAXIMUM_REPARSE_DATA_BUFFER_SIZE ); 07749 07750 // 07751 // Determine whether we have the correct kind of reparse tag in the buffer. 07752 // 07753 07754 if (ReparseBuffer->ReparseTag != IO_REPARSE_TAG_MOUNT_POINT) { 07755 07756 // 07757 // The reparse tag is not an NT name grafting tag. 07758 // 07759 07760 return FALSE; 07761 } 07762 07763 // 07764 // Determine whether we have enough data for all the length fields. 07765 // 07766 07767 if (ReparseBuffer->ReparseDataLength < 07768 (FIELD_OFFSET(REPARSE_DATA_BUFFER, MountPointReparseBuffer.PathBuffer[0]) - REPARSE_DATA_BUFFER_HEADER_SIZE)) { 07769 07770 // 07771 // The buffer is shorter than the minimum needed to express a pair of valid 07772 // names. 07773 // 07774 07775 return FALSE; 07776 } 07777 07778 // 07779 // Get the address of the current stack location. 07780 // 07781 07782 thisStackPointer = IoGetCurrentIrpStackLocation( Irp ); 07783 07784 // 07785 // Determine whether the data lengths returned are consistent with the buffer in 07786 // which they are retrieved. 07787 // 07788 // This check is meaningful only when the buffer has been allocated. When this routine 07789 // is used when a name grafting is being set there is no allocated output buffer. 07790 // 07791 07792 if ((thisStackPointer->Parameters.FileSystemControl.OutputBufferLength > 0) && 07793 (thisStackPointer->Parameters.FileSystemControl.OutputBufferLength < 07794 (ULONG)(FIELD_OFFSET(REPARSE_DATA_BUFFER, MountPointReparseBuffer.PathBuffer[0]) + 07795 ReparseBuffer->MountPointReparseBuffer.SubstituteNameLength + 07796 ReparseBuffer->MountPointReparseBuffer.PrintNameLength + 07797 2 * sizeof( UNICODE_NULL )))) { 07798 07799 // 07800 // The length of the appropriate buffer header, plus the lengths of the substitute 07801 // and print names are longer than the length of the buffer passed in. 07802 // Thus, this data is not self-consistent. 07803 // 07804 // Note that it is only the I/O subsystem that needs to check for this internal 07805 // consistency in the buffer as it will do a blind data copy using these lengths 07806 // when transmogrifying the names. The file system returning the buffer only needs 07807 // to ascertain that the total syze of the data retrieved does not exceed the size 07808 // of the output buffer. 07809 // 07810 07811 return FALSE; 07812 } 07813 07814 // 07815 // Now we determine whether the names were placed according to the reparse point 07816 // specification. 07817 // 07818 07819 // 07820 // Determine whether the SubstituteNameOffset is zero. 07821 // 07822 07823 if (ReparseBuffer->MountPointReparseBuffer.SubstituteNameOffset != 0) { 07824 07825 // 07826 // Incorrect offset for the substitute name. 07827 // 07828 07829 return FALSE; 07830 } 07831 07832 // 07833 // Determine whether PrintNameOffset is correct. 07834 // 07835 07836 if (ReparseBuffer->MountPointReparseBuffer.PrintNameOffset != 07837 (ReparseBuffer->MountPointReparseBuffer.SubstituteNameLength + sizeof( UNICODE_NULL )) ) { 07838 07839 // 07840 // Incorrect offset for the print name. 07841 // 07842 07843 return FALSE; 07844 } 07845 07846 // 07847 // Determine whether ReparseDataLength is correct for name grafting operations. 07848 // We require a buffer of type REPARSE_DATA_BUFFER. 07849 // 07850 07851 if (ReparseBuffer->ReparseDataLength != 07852 (FIELD_OFFSET(REPARSE_DATA_BUFFER, MountPointReparseBuffer.PathBuffer[0]) - REPARSE_DATA_BUFFER_HEADER_SIZE) + 07853 ReparseBuffer->MountPointReparseBuffer.SubstituteNameLength + 07854 ReparseBuffer->MountPointReparseBuffer.PrintNameLength + 07855 2 * sizeof( UNICODE_NULL )) { 07856 07857 // 07858 // Incorrect length of the reparse data. 07859 // 07860 07861 return FALSE; 07862 } 07863 07864 // 07865 // Determine that the substitute name is not a UNC name. 07866 // This assumes that ReparseBuffer->MountPointReparseBuffer.SubstituteNameOffset is zero (0). 07867 // 07868 07869 { 07870 // 07871 // This conditional is a transcription of part of the code of RtlDetermineDosPathNameType_U 07872 // present in ntos\dll\curdir.c 07873 // 07874 // The only two legal names that can begin with \\ are: \\. and \\? 07875 // All other names that begin with \\ are disallowed. 07876 // 07877 07878 if ((ReparseBuffer->MountPointReparseBuffer.SubstituteNameLength > 6) && 07879 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[0] == L'\\') && 07880 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[1] == L'\\') && 07881 !((ReparseBuffer->MountPointReparseBuffer.PathBuffer[2] == L'.') || 07882 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[2] == L'?'))) { 07883 07884 // 07885 // The name is not one we want to deal with. 07886 // 07887 07888 return FALSE; 07889 } 07890 07891 // 07892 // When RtlDosPathNameToNtPathName_U is used, the UNC names are returned with a prefix 07893 // of the form \??\UNC\ 07894 // 07895 07896 if ((ReparseBuffer->MountPointReparseBuffer.SubstituteNameLength > 16) && 07897 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[0] == L'\\') && 07898 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[1] == L'?') && 07899 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[2] == L'?') && 07900 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[3] == L'\\') && 07901 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[4] == L'U') && 07902 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[5] == L'N') && 07903 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[6] == L'C') && 07904 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[7] == L'\\')) { 07905 07906 // 07907 // The name is not one we want to deal with. 07908 // 07909 07910 return FALSE; 07911 } 07912 07913 // 07914 // See whether there is a drive letter that is mapped at the beginning of the name. 07915 // If the drive letter is C, then the prefix has the form \??\C: 07916 // Note that we skip the offset 4 on purpose. 07917 // 07918 07919 if ((ReparseBuffer->MountPointReparseBuffer.SubstituteNameLength > 12) && 07920 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[0] == L'\\') && 07921 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[1] == L'?') && 07922 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[2] == L'?') && 07923 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[3] == L'\\') && 07924 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[5] == L':')) { 07925 07926 NTSTATUS status; 07927 UNICODE_STRING linkValue; 07928 OBJECT_ATTRIBUTES objectAttributes; 07929 HANDLE linkHandle; 07930 PWCHAR linkValueBuffer = NULL; // MAX_PATH is 260 07931 WCHAR pathNameValue[sizeof(L"\\??\\C:\0")]; 07932 07933 RtlCopyMemory( &pathNameValue, L"\\??\\C:\0", sizeof(L"\\??\\C:\0") ); 07934 07935 RtlInitUnicodeString( &drivePath, pathNameValue ); 07936 07937 // 07938 // Place the appropriate drive letter in the buffer overwriting offset 4. 07939 // 07940 07941 drivePath.Buffer[4] = ReparseBuffer->MountPointReparseBuffer.PathBuffer[4]; 07942 07943 InitializeObjectAttributes( &objectAttributes, 07944 &drivePath, 07945 OBJ_CASE_INSENSITIVE, 07946 (HANDLE) NULL, 07947 (PSECURITY_DESCRIPTOR) NULL ); 07948 07949 status = ZwOpenSymbolicLinkObject( &linkHandle, 07950 SYMBOLIC_LINK_QUERY, 07951 &objectAttributes ); 07952 07953 #if DBG 07954 // DbgPrint( "IO Name grafting drivePath: %Z ZwOpenSymbolicLinkObject status %x\n", &drivePath, status ); 07955 #endif // DBG 07956 07957 if ( NT_SUCCESS( status ) ) { 07958 07959 // 07960 // Now query the link and see if there is a redirection 07961 // 07962 07963 linkValueBuffer = ExAllocatePoolWithTag( NonPagedPool, 07964 2 * 260, 07965 ' oI' ); 07966 if ( !linkValueBuffer ) { 07967 07968 // 07969 // Insufficient resources. Return FALSE. 07970 // 07971 07972 NtClose( linkHandle ); 07973 return FALSE; 07974 } 07975 07976 linkValue.Buffer = linkValueBuffer; 07977 linkValue.Length = 0; 07978 linkValue.MaximumLength = (USHORT)(2 * 260); 07979 07980 status = ZwQuerySymbolicLinkObject( linkHandle, 07981 &linkValue, 07982 NULL ); 07983 NtClose( linkHandle ); 07984 07985 #if DBG 07986 // DbgPrint( "IO Name grafting linkValue: %Z ZwQuerySymbolicLinkObject status %x\n", &linkValue, status ); 07987 #endif // DBG 07988 07989 if ( NT_SUCCESS( status ) ) { 07990 07991 // 07992 // The link is a re-directed drive when it has the prefix 07993 // \Device\LanmanRedirector\ 07994 // 07995 07996 if ((linkValue.Buffer[ 0] == L'\\') && 07997 (linkValue.Buffer[ 1] == L'D') && 07998 (linkValue.Buffer[ 2] == L'e') && 07999 (linkValue.Buffer[ 3] == L'v') && 08000 (linkValue.Buffer[ 4] == L'i') && 08001 (linkValue.Buffer[ 5] == L'c') && 08002 (linkValue.Buffer[ 6] == L'e') && 08003 (linkValue.Buffer[ 7] == L'\\') && 08004 (linkValue.Buffer[ 8] == L'L') && 08005 (linkValue.Buffer[ 9] == L'a') && 08006 (linkValue.Buffer[10] == L'n') && 08007 (linkValue.Buffer[14] == L'R') && 08008 (linkValue.Buffer[15] == L'e') && 08009 (linkValue.Buffer[16] == L'd') && 08010 (linkValue.Buffer[17] == L'i') && 08011 (linkValue.Buffer[18] == L'r') && 08012 (linkValue.Buffer[23] == L'r') & 08013 (linkValue.Buffer[24] == L'\\')) { 08014 08015 // 08016 // Free the buffer. 08017 // 08018 08019 ExFreePool( linkValueBuffer ); 08020 08021 return FALSE; 08022 } 08023 08024 // 08025 // Fix for penetration bug. May be relaxed in the future 03/99. 08026 // Exploit the fact that we have queried the symbolic link. 08027 // Want only to allow links to volumes that have the prefix 08028 // \Device\Harddisk 08029 // 08030 08031 if (!((linkValue.Buffer[ 0] == L'\\') && 08032 (linkValue.Buffer[ 1] == L'D') && 08033 (linkValue.Buffer[ 2] == L'e') && 08034 (linkValue.Buffer[ 3] == L'v') && 08035 (linkValue.Buffer[ 4] == L'i') && 08036 (linkValue.Buffer[ 5] == L'c') && 08037 (linkValue.Buffer[ 6] == L'e') && 08038 (linkValue.Buffer[ 7] == L'\\') && 08039 (linkValue.Buffer[ 8] == L'H') && 08040 (linkValue.Buffer[ 9] == L'a') && 08041 (linkValue.Buffer[10] == L'r') && 08042 (linkValue.Buffer[11] == L'd') && 08043 (linkValue.Buffer[12] == L'd') && 08044 (linkValue.Buffer[13] == L'i') && 08045 (linkValue.Buffer[14] == L's') && 08046 (linkValue.Buffer[15] == L'k'))) { 08047 08048 // 08049 // Free the buffer. 08050 // 08051 08052 ExFreePool( linkValueBuffer ); 08053 08054 return FALSE; 08055 } 08056 } 08057 08058 // 08059 // Free the buffer. 08060 // 08061 08062 ExFreePool( linkValueBuffer ); 08063 } 08064 } 08065 } 08066 08067 // 08068 // Fix for penetration bug. May be relaxed in the future 03/99. 08069 // Determine that we either have an NT file name or a volume mount point target name. 08070 // 08071 // This closes the door of having an arbitrary device name that, with the help of the 08072 // server, can be used to bypass access checks to the underlying device. 08073 // 08074 08075 { 08076 UNICODE_STRING volumeName; 08077 08078 if ( 08079 // 08080 // The shortest valid name is one of the kind \??\C: whose length is 12 when 08081 // in Unicode. All names used by volume mount points are longer. 08082 // 08083 08084 ReparseBuffer->MountPointReparseBuffer.SubstituteNameLength < 12 ) { 08085 08086 return FALSE; 08087 } 08088 08089 // 08090 // The name has at least 6 Unicode characters. 08091 // 08092 // We have verified above that MountPointReparseBuffer.SubstituteNameOffset 08093 // is zero. 08094 // 08095 08096 volumeName.Length = 08097 volumeName.MaximumLength = ReparseBuffer->MountPointReparseBuffer.SubstituteNameLength; 08098 volumeName.Buffer = (PWSTR) ReparseBuffer->MountPointReparseBuffer.PathBuffer; 08099 08100 // 08101 // When we do not have a name that begins with a drive letter and it is not 08102 // a valid volume mount point name then we return false. 08103 // 08104 08105 if ( !((ReparseBuffer->MountPointReparseBuffer.PathBuffer[0] == L'\\') && 08106 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[1] == L'?') && 08107 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[2] == L'?') && 08108 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[3] == L'\\') && 08109 // 08110 // Notice that we skip index 4, where the drive letter is to be. 08111 // 08112 (ReparseBuffer->MountPointReparseBuffer.PathBuffer[5] == L':')) 08113 08114 && 08115 08116 !MOUNTMGR_IS_VOLUME_NAME( &volumeName ) ) { 08117 08118 return FALSE; 08119 } 08120 } 08121 08122 // 08123 // Otherwise return TRUE. 08124 // 08125 08126 return TRUE; 08127 }

NTKERNELAPI BOOLEAN IoIsWdmVersionAvailable IN UCHAR  MajorVersion,
IN UCHAR  MinorVersion
 

Definition at line 8275 of file pnpioapi.c.

References WDM_MAJORVERSION, and WDM_MINORVERSION.

08282 : 08283 08284 This routine reports whether WDM functionality is available that 08285 is greater than or equal to the specified major and minor version. 08286 08287 Parameters: 08288 08289 MajorVersion - Supplies the WDM major version that is required. 08290 08291 MinorVersion - Supplies the WDM minor version that is required. 08292 08293 Return Value: 08294 08295 If WDM support is available at _at least_ the requested level, the 08296 return value is TRUE, otherwise it is FALSE. 08297 08298 --*/ 08299 08300 { 08301 return ((MajorVersion < WDM_MAJORVERSION) || 08302 ((MajorVersion == WDM_MAJORVERSION) && (MinorVersion <= WDM_MINORVERSION))); 08303 }

NTKERNELAPI PIRP IoMakeAssociatedIrp IN PIRP  Irp,
IN CCHAR  StackSize
 

Definition at line 8338 of file iosubs.c.

References _GENERAL_LOOKASIDE::AllocateMisses, _IRP::AllocationFlags, _IRP::AssociatedIrp, ExAllocatePoolWithTag, ExInterlockedPopEntrySList(), _IRP::Flags, IopInitializeIrp, IopLargeIrpStackLocations, IoSizeOfIrp, Irp, IRP_ALLOCATED_FIXED_SIZE, IRP_ALLOCATED_MUST_SUCCEED, IRP_ASSOCIATED_IRP, KeGetCurrentPrcb, KernelMode, _NPAGED_LOOKASIDE_LIST::L, _GENERAL_LOOKASIDE::ListHead, _NPAGED_LOOKASIDE_LIST::Lock, LookasideLargeIrpList, LookasideSmallIrpList, NonPagedPool, NonPagedPoolMustSucceed, NULL, PP_NPAGED_LOOKASIDE_NUMBER, _IRP::Tail, _GENERAL_LOOKASIDE::TotalAllocates, and USHORT.

Referenced by UdfMultipleAsync().

08345 : 08346 08347 This routine allocates an I/O Request Packet from the system nonpaged pool 08348 and makes it an associated IRP to the specified IRP. The packet will be 08349 allocated to contain StackSize stack locations. The IRP iwll also be 08350 initialized. 08351 08352 Note that it is up to the caller to have set the number of associated IRPs 08353 in the master packet before calling this routine for the first time. The 08354 count should be set in the master packet in: AssociatedIrp.IrpCount. 08355 08356 Arguments: 08357 08358 Irp - Pointer to master IRP to be associated with. 08359 08360 StackSize - Specifies the maximum number of stack locations required. 08361 08362 Return Value: 08363 08364 The function value is the address of the associated IRP or NULL, if the 08365 IRP could be allocated. 08366 08367 --*/ 08368 08369 { 08370 USHORT allocateSize; 08371 UCHAR fixedSize; 08372 PIRP associatedIrp; 08373 PNPAGED_LOOKASIDE_LIST lookasideList; 08374 UCHAR mustSucceed; 08375 PP_NPAGED_LOOKASIDE_NUMBER number; 08376 USHORT packetSize; 08377 PKPRCB prcb; 08378 08379 // 08380 // If the size of the packet required is less than or equal to those on 08381 // the lookaside lists, then attempt to allocate the packet from the 08382 // lookaside lists. 08383 // 08384 08385 associatedIrp = NULL; 08386 fixedSize = 0; 08387 mustSucceed = 0; 08388 packetSize = IoSizeOfIrp(StackSize); 08389 allocateSize = packetSize; 08390 if (StackSize <= (CCHAR)IopLargeIrpStackLocations) { 08391 fixedSize = IRP_ALLOCATED_FIXED_SIZE; 08392 number = LookasideSmallIrpList; 08393 if (StackSize != 1) { 08394 allocateSize = IoSizeOfIrp((CCHAR)IopLargeIrpStackLocations); 08395 number = LookasideLargeIrpList; 08396 } 08397 08398 prcb = KeGetCurrentPrcb(); 08399 lookasideList = prcb->PPLookasideList[number].P; 08400 lookasideList->L.TotalAllocates += 1; 08401 associatedIrp = (PIRP)ExInterlockedPopEntrySList(&lookasideList->L.ListHead, 08402 &lookasideList->Lock); 08403 08404 if (associatedIrp == NULL) { 08405 lookasideList->L.AllocateMisses += 1; 08406 lookasideList = prcb->PPLookasideList[number].L; 08407 lookasideList->L.TotalAllocates += 1; 08408 associatedIrp = (PIRP)ExInterlockedPopEntrySList(&lookasideList->L.ListHead, 08409 &lookasideList->Lock); 08410 } 08411 } 08412 08413 // 08414 // If an IRP was not allocated from the lookaside list, then allocate 08415 // the packet from nonpaged pool. 08416 // 08417 08418 if (!associatedIrp) { 08419 if (fixedSize != 0) { 08420 lookasideList->L.AllocateMisses += 1; 08421 } 08422 08423 // 08424 // There are no free packets on the lookaside list, or the packet is 08425 // too large to be allocated from one of the lists, so it must be 08426 // allocated from general non-paged pool. 08427 // 08428 08429 associatedIrp = ExAllocatePoolWithTag(NonPagedPool, allocateSize, ' prI'); 08430 if (!associatedIrp) { 08431 if (KeGetPreviousMode() == KernelMode) { 08432 mustSucceed = IRP_ALLOCATED_MUST_SUCCEED; 08433 associatedIrp = ExAllocatePoolWithTag(NonPagedPoolMustSucceed, 08434 allocateSize, 08435 ' prI' ); 08436 } 08437 08438 if (!associatedIrp) { 08439 return NULL; 08440 } 08441 } 08442 08443 } 08444 08445 // 08446 // Initialize the packet. 08447 // 08448 08449 IopInitializeIrp(associatedIrp, packetSize, StackSize); 08450 associatedIrp->Flags |= IRP_ASSOCIATED_IRP; 08451 associatedIrp->AllocationFlags |= (fixedSize | mustSucceed); 08452 08453 // 08454 // Set the thread ID to be that of the master. 08455 // 08456 08457 associatedIrp->Tail.Overlay.Thread = Irp->Tail.Overlay.Thread; 08458 08459 // 08460 // Now make the association between this packet and the master. 08461 // 08462 08463 associatedIrp->AssociatedIrp.MasterIrp = Irp; 08464 return associatedIrp; 08465 }

NTSTATUS IoNotifyPowerOperationVetoed IN POWER_ACTION  VetoedPowerOperation,
IN PDEVICE_OBJECT TargetedDeviceObject  OPTIONAL,
IN PDEVICE_OBJECT  VetoingDeviceObject
 

Definition at line 9171 of file pnpioapi.c.

References _DEVOBJ_EXTENSION::DeviceNode, _DEVICE_OBJECT::DeviceObjectExtension, _DEVICE_NODE::InstancePath, IopRootDeviceNode, NULL, PAGED_CODE, _DEVICE_NODE::PhysicalDeviceObject, and PpSetPowerVetoEvent().

09179 { 09180 PDEVICE_NODE deviceNode, vetoingDeviceNode; 09181 PDEVICE_OBJECT deviceObject; 09182 09183 PAGED_CODE(); 09184 09185 // 09186 // We have to types of power events, system wide (standby) and device 09187 // targetted (warm eject). Rather than have two different veto mechanisms, 09188 // we just retarget the operation against the root device if none is 09189 // specified (hey, someone's gotta represent the system, right?). 09190 // 09191 if (TargetedDeviceObject) { 09192 09193 deviceObject = TargetedDeviceObject; 09194 09195 } else { 09196 09197 deviceObject = IopRootDeviceNode->PhysicalDeviceObject; 09198 } 09199 09200 deviceNode = (PDEVICE_NODE)deviceObject->DeviceObjectExtension->DeviceNode; 09201 if (!deviceNode) { 09202 return STATUS_INVALID_PARAMETER_2; 09203 } 09204 09205 vetoingDeviceNode = (PDEVICE_NODE)VetoingDeviceObject->DeviceObjectExtension->DeviceNode; 09206 if (!vetoingDeviceNode) { 09207 return STATUS_INVALID_PARAMETER_3; 09208 } 09209 09210 return PpSetPowerVetoEvent( 09211 VetoedPowerOperation, 09212 NULL, 09213 NULL, 09214 deviceObject, 09215 PNP_VetoDevice, 09216 &vetoingDeviceNode->InstancePath 09217 ); 09218 }

NTKERNELAPI BOOLEAN IoPageFileCreated IN HANDLE  FileHandle  ) 
 

Definition at line 8468 of file iosubs.c.

References IopConfigureCrashDump(), NTSTATUS(), and PAGED_CODE.

Referenced by NtCreatePagingFile().

08474 : 08475 08476 This routine is invoked by the Memory Manager when a new page file is 08477 created. The purpose is to lookup the paging file to determine whether 08478 or not it was created on the boot device. If so, and taking crash dumps 08479 is enabled, then the retrieval pointers are queried from the file system 08480 for the file so that they can then be used later in writing the crash 08481 dump to the paging file. 08482 08483 The Memory Manager will continue to invoke this function for each paging 08484 file created in the system until the one for the boot device is encountered. 08485 08486 Arguments: 08487 08488 FileHandle - Handle to the paging file just created. 08489 08490 Return Value: 08491 08492 A value of TRUE is returned if this paging file resides on the system's 08493 boot device, otherwise FALSE. 08494 08495 --*/ 08496 08497 { 08498 PFILE_OBJECT fileObject; 08499 PDEVICE_OBJECT deviceObject; 08500 NTSTATUS status; 08501 BOOLEAN result; 08502 08503 PAGED_CODE(); 08504 08505 return IopConfigureCrashDump( FileHandle ); 08506 }

NTKERNELAPI NTSTATUS IoPageRead IN PFILE_OBJECT  FileObject,
IN PMDL  MemoryDescriptorList,
IN PLARGE_INTEGER  StartingOffset,
IN PKEVENT  Event,
OUT PIO_STATUS_BLOCK  IoStatusBlock
 

Definition at line 8509 of file iosubs.c.

References CcMissCounter, Event(), FALSE, _IO_STACK_LOCATION::FileObject, _IRP::Flags, IoAllocateIrp(), IoCallDriver, IoGetNextIrpStackLocation, IoGetRelatedDeviceObject(), IRP_INPUT_OPERATION, IRP_MJ_READ, IRP_NOCACHE, IRP_PAGING_IO, IRP_SYNCHRONOUS_PAGING_IO, KernelMode, _IO_STACK_LOCATION::MajorFunction, _IRP::MdlAddress, MmIsRecursiveIoFault, PAGE_SHIFT, PAGE_SIZE, _IO_STACK_LOCATION::Parameters, PsGetCurrentThread, _IRP::RequestorMode, _DEVICE_OBJECT::StackSize, _IRP::Tail, _IRP::UserBuffer, _IRP::UserEvent, and _IRP::UserIosb.

Referenced by MiCheckForCrashDump(), MiCreateImageFileMap(), MiDispatchFault(), and MiMakeOutswappedPageResident().

08519 : 08520 08521 This routine provides a special, fast interface for the Pager to read pages 08522 in from the disk quickly and with very little overhead. All of the special 08523 handling for this request is recognized by setting the IRP_PAGING_IO flag 08524 in the IRP flags word. In-page operations are detected by using the IRP 08525 flag IRP_INPUT_OPERATION. 08526 08527 Arguments: 08528 08529 FileObject - A pointer to a referenced file object describing which file 08530 the read should be performed from. 08531 08532 MemoryDescriptorList - An MDL which describes the physical pages that the 08533 pages should be read into from the disk. All of the pages have been 08534 locked in memory. The MDL also describes the length of the read 08535 operation. 08536 08537 StartingOffset - Pointer to the offset in the file from which the read 08538 should take place. 08539 08540 Event - A pointer to a kernel event structure to be used for synchronization 08541 purposes. The event will be set to the Signaled state once the in-page 08542 operation completes. 08543 08544 IoStatusBlock - A pointer to the I/O status block in which the final status 08545 and information should be stored. 08546 08547 Return Value: 08548 08549 The function value is the final status of the queue request to the I/O 08550 system subcomponents. 08551 08552 Notes: 08553 08554 This routine is invoked at APC_LEVEL; this level is honored throughout the 08555 execution of the entire I/O request, including completion. 08556 08557 --*/ 08558 08559 { 08560 PIRP irp; 08561 PIO_STACK_LOCATION irpSp; 08562 PDEVICE_OBJECT deviceObject; 08563 08564 // 08565 // Increment performance counter. The Cache Manager I/Os always are 08566 // "recursive". 08567 // 08568 08569 if (MmIsRecursiveIoFault()) { 08570 *CcMissCounter += (MemoryDescriptorList->ByteCount + PAGE_SIZE - 1) >> PAGE_SHIFT; 08571 } 08572 08573 // 08574 // Begin by getting a pointer to the device object that the file resides 08575 // on. 08576 // 08577 08578 deviceObject = IoGetRelatedDeviceObject( FileObject ); 08579 08580 // 08581 // Allocate an I/O Request Packet (IRP) for this in-page operation. 08582 // 08583 08584 irp = IoAllocateIrp( deviceObject->StackSize, FALSE ); 08585 if (!irp) { 08586 return STATUS_INSUFFICIENT_RESOURCES; 08587 } 08588 08589 // 08590 // Get a pointer to the first stack location in the packet. This location 08591 // will be used to pass the function codes and parameters to the first 08592 // driver. 08593 // 08594 08595 irpSp = IoGetNextIrpStackLocation( irp ); 08596 08597 // 08598 // Fill in the IRP according to this request. 08599 // 08600 08601 irp->MdlAddress = MemoryDescriptorList; 08602 irp->Flags = IRP_PAGING_IO | IRP_NOCACHE | IRP_SYNCHRONOUS_PAGING_IO | IRP_INPUT_OPERATION; 08603 irp->RequestorMode = KernelMode; 08604 irp->UserIosb = IoStatusBlock; 08605 irp->UserEvent = Event; 08606 irp->UserBuffer = (PVOID) ((PCHAR) MemoryDescriptorList->StartVa + MemoryDescriptorList->ByteOffset); 08607 irp->Tail.Overlay.OriginalFileObject = FileObject; 08608 irp->Tail.Overlay.Thread = PsGetCurrentThread(); 08609 08610 // 08611 // Fill in the normal read parameters. 08612 // 08613 08614 irpSp->MajorFunction = IRP_MJ_READ; 08615 irpSp->FileObject = FileObject; 08616 irpSp->Parameters.Read.Length = MemoryDescriptorList->ByteCount; 08617 irpSp->Parameters.Read.ByteOffset = *StartingOffset; 08618 08619 // 08620 // Queue the packet to the appropriate driver based on whether or not there 08621 // is a VPB associated with the device. 08622 // 08623 08624 return IoCallDriver( deviceObject, irp ); 08625 }

VOID IopBootLog PUNICODE_STRING  LogEntry,
BOOLEAN  Loaded
 

Definition at line 9046 of file internal.c.

References BootLogRecord, CmRegistryMachineSystemCurrentControlSetControlBootLog, ExAcquireResourceExclusive, ExReleaseResource, _BOOT_LOG_RECORD::FileLogging, IopBootLogToFile(), IopOpenRegistryKey(), IopSetRegistryStringValue(), KeyName, L, _BOOT_LOG_RECORD::LoadedString, _BOOT_LOG_RECORD::NextKey, _BOOT_LOG_RECORD::NotLoadedString, NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, _BOOT_LOG_RECORD::Resource, RtlAppendUnicodeStringToString(), RtlCopyUnicodeString(), RtlCreateUnicodeString(), RtlFreeUnicodeString(), RtlInitUnicodeString(), Space, Status, TRUE, and ValueName.

Referenced by IopCallDriverAddDevice(), IopInitializeBootLogging(), and IopLoadDriver().

09052 : 09053 09054 Create and write out a log entry. Before NtInitializeRegistry is called, log entries are spooled 09055 into the registry. When NtInitalizeRegistry is called by the session manager, the 09056 log file is created if necessary and truncated. Log entries in the registry are 09057 then copied into the log file and the registry entries are deleted. 09058 09059 Arguments: 09060 09061 LogEntry - the text to log. 09062 Loaded - indicates whether to prepend the "Loaded" string or the "Not Loaded" string. 09063 09064 Return Value: 09065 09066 VOID 09067 09068 09069 --*/ 09070 { 09071 WCHAR NameBuffer[BOOTLOG_STRSIZE]; 09072 UNICODE_STRING KeyName; 09073 UNICODE_STRING ValueName; 09074 UNICODE_STRING CrLf; 09075 UNICODE_STRING Space; 09076 NTSTATUS Status; 09077 09078 WCHAR MessageBuffer[BOOTLOG_STRSIZE]; 09079 UNICODE_STRING MessageString = { 09080 0, 09081 BOOTLOG_STRSIZE, 09082 &MessageBuffer[0] 09083 }; 09084 09085 PAGED_CODE(); 09086 09087 if (BootLogRecord == NULL) { 09088 return; 09089 } 09090 09091 ExAcquireResourceExclusive(&BootLogRecord->Resource, TRUE); 09092 09093 if (Loaded) { 09094 RtlCopyUnicodeString(&MessageString, &BootLogRecord->LoadedString); 09095 } else { 09096 RtlCopyUnicodeString(&MessageString, &BootLogRecord->NotLoadedString); 09097 } 09098 09099 // add a space after the message prefix 09100 09101 RtlInitUnicodeString(&Space, L" "); 09102 09103 RtlAppendUnicodeStringToString(&MessageString, &Space); 09104 09105 RtlAppendUnicodeStringToString(&MessageString, LogEntry); 09106 09107 // add a CR LF 09108 09109 RtlInitUnicodeString(&CrLf, L"\r\n"); 09110 RtlAppendUnicodeStringToString(&MessageString, &CrLf); 09111 09112 swprintf(NameBuffer, L"%d", BootLogRecord->NextKey++); 09113 09114 RtlCreateUnicodeString(&KeyName, NameBuffer); 09115 RtlInitUnicodeString(&ValueName, L""); 09116 09117 if (!BootLogRecord->FileLogging) { 09118 HANDLE hLogKey, hBootKey; 09119 09120 Status = IopOpenRegistryKey ( 09121 &hBootKey, 09122 NULL, 09123 &CmRegistryMachineSystemCurrentControlSetControlBootLog, 09124 KEY_ALL_ACCESS, 09125 TRUE 09126 ); 09127 09128 if (NT_SUCCESS(Status)) { 09129 Status = IopOpenRegistryKey ( 09130 &hLogKey, 09131 hBootKey, 09132 &KeyName, 09133 KEY_ALL_ACCESS, 09134 TRUE 09135 ); 09136 if (NT_SUCCESS(Status)) { 09137 Status = IopSetRegistryStringValue( 09138 hLogKey, 09139 &ValueName, 09140 &MessageString 09141 ); 09142 ZwClose(hLogKey); 09143 } 09144 ZwClose(hBootKey); 09145 } 09146 09147 } else { 09148 IopBootLogToFile( &MessageString ); 09149 } 09150 09151 RtlFreeUnicodeString(&KeyName); 09152 09153 ExReleaseResource(&BootLogRecord->Resource); 09154 }

VOID IopCopyBootLogRegistryToFile VOID   ) 
 

Definition at line 9157 of file internal.c.

References BootLogRecord, CHAR, CmRegistryMachineSystemCurrentControlSetControlBootLog, ExAcquireResourceExclusive, ExFreePool(), ExReleaseResource, ExSystemTimeToLocalTime(), FALSE, _BOOT_LOG_RECORD::FileLogging, _BOOT_LOG_RECORD::HeaderString, Index, IopBootLogToFile(), IopGetRegistryValue(), IopOpenRegistryKey(), KeBootTime, KeyName, L, _BOOT_LOG_RECORD::NextKey, NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, _BOOT_LOG_RECORD::Resource, RtlAnsiStringToUnicodeString(), RtlCreateUnicodeString(), RtlFreeUnicodeString(), RtlInitAnsiString(), RtlInitUnicodeString(), RtlTimeToTimeFields(), sprintf(), Status, TimeFields, and TRUE.

09162 : 09163 09164 Copy the text in the registry entries into the log file and delete the registry entries. Set the 09165 flag that indicates direct logging to the log file. 09166 09167 Arguments: 09168 09169 NONE 09170 09171 Return Value: 09172 09173 VOID 09174 09175 09176 --*/ 09177 { 09178 UNICODE_STRING KeyName; 09179 WCHAR NameBuffer[BOOTLOG_STRSIZE]; 09180 NTSTATUS Status; 09181 HANDLE hLogKey, hBootKey; 09182 ULONG Index; 09183 PKEY_VALUE_FULL_INFORMATION Information; 09184 IO_STATUS_BLOCK IoStatus; 09185 LARGE_INTEGER LocalTime; 09186 TIME_FIELDS TimeFields; 09187 CHAR AnsiTimeBuffer[256]; 09188 ANSI_STRING AnsiTimeString; 09189 UNICODE_STRING UnicodeTimeString; 09190 UNICODE_STRING LogString; 09191 09192 PAGED_CODE(); 09193 09194 if (BootLogRecord == NULL) { 09195 return; 09196 } 09197 09198 ExAcquireResourceExclusive(&BootLogRecord->Resource, TRUE); 09199 09200 IopBootLogToFile(&BootLogRecord->HeaderString); 09201 09202 ExSystemTimeToLocalTime(&KeBootTime, &LocalTime); 09203 09204 RtlTimeToTimeFields(&LocalTime, &TimeFields); 09205 09206 sprintf( 09207 AnsiTimeBuffer, 09208 "%2d %2d %4d %02d:%02d:%02d.%03d\r\n", 09209 TimeFields.Month, 09210 TimeFields.Day, 09211 TimeFields.Year, 09212 TimeFields.Hour, 09213 TimeFields.Minute, 09214 TimeFields.Second, 09215 TimeFields.Milliseconds 09216 ); 09217 09218 RtlInitAnsiString(&AnsiTimeString, AnsiTimeBuffer); 09219 09220 RtlAnsiStringToUnicodeString(&UnicodeTimeString, &AnsiTimeString, TRUE); 09221 09222 IopBootLogToFile(&UnicodeTimeString); 09223 09224 RtlFreeUnicodeString(&UnicodeTimeString); 09225 09226 // 09227 // Read all of the strings in the registry and write them to the log file. 09228 // Delete the registry keys when done. 09229 // 09230 09231 Status = IopOpenRegistryKey ( 09232 &hBootKey, 09233 NULL, 09234 &CmRegistryMachineSystemCurrentControlSetControlBootLog, 09235 KEY_ALL_ACCESS, 09236 FALSE 09237 ); 09238 09239 if (NT_SUCCESS(Status)) { 09240 for (Index = 0; Index < BootLogRecord->NextKey; Index++) { 09241 swprintf(NameBuffer, L"%d", Index); 09242 09243 RtlCreateUnicodeString(&KeyName, NameBuffer); 09244 09245 Status = IopOpenRegistryKey ( 09246 &hLogKey, 09247 hBootKey, 09248 &KeyName, 09249 KEY_ALL_ACCESS, 09250 FALSE 09251 ); 09252 09253 if (NT_SUCCESS(Status)) { 09254 Status = IopGetRegistryValue( 09255 hLogKey, 09256 L"", 09257 &Information 09258 ); 09259 09260 if (NT_SUCCESS(Status)){ 09261 RtlInitUnicodeString(&LogString, (PWSTR) ((PUCHAR)Information + Information->DataOffset)); 09262 IopBootLogToFile(&LogString); 09263 } 09264 ExFreePool(Information); 09265 ZwDeleteKey(hLogKey); 09266 ZwClose(hLogKey); 09267 } 09268 } 09269 ZwDeleteKey(hBootKey); 09270 ZwClose(hBootKey); 09271 09272 // 09273 // Write directly to the file from now on. 09274 // 09275 09276 BootLogRecord->FileLogging = TRUE; 09277 } 09278 09279 ExReleaseResource(&BootLogRecord->Resource); 09280 }

VOID IopInitializeBootLogging PLOADER_PARAMETER_BLOCK  LoaderBlock,
PCHAR  HeaderString
 

Definition at line 8928 of file internal.c.

References BOOT_LOG_RECORD, BootLogRecord, ExAcquireResourceExclusive, ExAcquireResourceShared, ExAllocatePool, ExInitializeResource, ExReleaseResource, _BOOT_LOG_RECORD::HeaderString, IopBootLog(), _BOOT_LOG_RECORD::LoadedString, _LOADER_PARAMETER_BLOCK::LoadOrderListHead, NonPagedPool, _BOOT_LOG_RECORD::NotLoadedString, NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, PsLoadedModuleList, PsLoadedModuleResource, _BOOT_LOG_RECORD::Resource, RtlAnsiStringToUnicodeString(), RtlCreateUnicodeStringFromAsciiz(), RtlFindMessage(), Status, strlen(), and TRUE.

08934 : 08935 08936 Initializes strings for boot logging. 08937 08938 Arguments: 08939 08940 LoaderBlock - the loader parameter block 08941 08942 Return Value: 08943 08944 VOID 08945 08946 --*/ 08947 { 08948 PLDR_DATA_TABLE_ENTRY DataTableEntry; 08949 PMESSAGE_RESOURCE_ENTRY MessageEntry; 08950 ULONG MsgId = 0; 08951 ANSI_STRING AnsiString; 08952 NTSTATUS Status; 08953 PLIST_ENTRY nextEntry; 08954 PLDR_DATA_TABLE_ENTRY driverEntry; 08955 08956 08957 PAGED_CODE(); 08958 08959 if (BootLogRecord != NULL) { 08960 return; 08961 } 08962 08963 BootLogRecord = (PBOOT_LOG_RECORD) ExAllocatePool(NonPagedPool, sizeof(BOOT_LOG_RECORD)); 08964 08965 if (BootLogRecord == NULL) { 08966 return; 08967 } 08968 08969 RtlZeroMemory(BootLogRecord, sizeof(BOOT_LOG_RECORD)); 08970 08971 ExInitializeResource(&BootLogRecord->Resource); 08972 08973 ExAcquireResourceExclusive(&BootLogRecord->Resource, TRUE); 08974 08975 DataTableEntry = CONTAINING_RECORD(LoaderBlock->LoadOrderListHead.Flink, 08976 LDR_DATA_TABLE_ENTRY, 08977 InLoadOrderLinks); 08978 08979 Status = RtlFindMessage (DataTableEntry->DllBase, 11, 0, BOOTLOG_LOADED, &MessageEntry); 08980 08981 if (NT_SUCCESS( Status )) { 08982 AnsiString.Buffer = MessageEntry->Text; 08983 AnsiString.Length = strlen(MessageEntry->Text); 08984 AnsiString.MaximumLength = AnsiString.Length + 1; 08985 08986 RtlAnsiStringToUnicodeString(&BootLogRecord->LoadedString, &AnsiString, TRUE); 08987 08988 // whack the crlf at the end of the string 08989 08990 if (BootLogRecord->LoadedString.Length > 2 * sizeof(WCHAR)) { 08991 BootLogRecord->LoadedString.Length -= 2 * sizeof(WCHAR); 08992 BootLogRecord->LoadedString.Buffer[BootLogRecord->LoadedString.Length / sizeof(WCHAR)] = UNICODE_NULL; 08993 } 08994 } 08995 08996 Status = RtlFindMessage (DataTableEntry->DllBase, 11, 0, BOOTLOG_NOT_LOADED, &MessageEntry); 08997 08998 if (NT_SUCCESS( Status )) { 08999 AnsiString.Buffer = MessageEntry->Text; 09000 AnsiString.Length = strlen(MessageEntry->Text); 09001 AnsiString.MaximumLength = AnsiString.Length + 1; 09002 09003 RtlAnsiStringToUnicodeString(&BootLogRecord->NotLoadedString, &AnsiString, TRUE); 09004 09005 // whack the crlf at the end of the string 09006 09007 if (BootLogRecord->NotLoadedString.Length > 2 * sizeof(WCHAR)) { 09008 BootLogRecord->NotLoadedString.Length -= 2 * sizeof(WCHAR); 09009 BootLogRecord->NotLoadedString.Buffer[BootLogRecord->NotLoadedString.Length / sizeof(WCHAR)] = UNICODE_NULL; 09010 } 09011 } 09012 09013 // The header string (copied from DebugString in Phase1Initialization) appears to have a leading null byte 09014 09015 HeaderString++; 09016 09017 RtlCreateUnicodeStringFromAsciiz(&BootLogRecord->HeaderString, HeaderString); 09018 09019 // Log the drivers loaded by the boot loader 09020 09021 ExAcquireResourceShared( &PsLoadedModuleResource, TRUE ); 09022 nextEntry = PsLoadedModuleList.Flink; 09023 while (nextEntry != &PsLoadedModuleList) { 09024 09025 // 09026 // Look at the next boot driver in the list. 09027 // 09028 09029 driverEntry = CONTAINING_RECORD( nextEntry, 09030 LDR_DATA_TABLE_ENTRY, 09031 InLoadOrderLinks ); 09032 09033 if (driverEntry->Flags & LDRP_ENTRY_PROCESSED){ 09034 IopBootLog(&driverEntry->FullDllName, TRUE); 09035 } 09036 09037 nextEntry = nextEntry->Flink; 09038 } 09039 09040 ExReleaseResource( &PsLoadedModuleResource ); 09041 09042 ExReleaseResource(&BootLogRecord->Resource); 09043 }

NTSTATUS IopSetRegistryStringValue IN HANDLE  KeyHandle,
IN PUNICODE_STRING  ValueName,
IN PUNICODE_STRING  ValueData
 

Definition at line 5714 of file pnpioapi.c.

References ASSERT, IopAllocateUnicodeString(), IopFreeAllocatedUnicodeString(), NT_SUCCESS, NTSTATUS(), PAGED_CODE, and ValueName.

05722 : 05723 05724 Sets a value key in the registry to a specific value of string (REG_SZ) type. 05725 05726 Parameters: 05727 05728 KeyHandle - A handle to the key under which the value is stored. 05729 05730 ValueName - Supplies a pointer to the name of the value key 05731 05732 ValueData - Supplies a pointer to the string to be stored in the key. The data 05733 will automatically be null terminated for storage in the registry. 05734 05735 Return Value: 05736 05737 Status code that indicates whether or not the function was successful. 05738 05739 --*/ 05740 05741 { 05742 NTSTATUS status; 05743 05744 PAGED_CODE(); 05745 05746 ASSERT(ValueName); 05747 ASSERT(ValueData); 05748 ASSERT(ValueName->Buffer); 05749 ASSERT(ValueData->Buffer); 05750 05751 // 05752 // Null terminate the string 05753 // 05754 05755 if ((ValueData->MaximumLength - ValueData->Length) >= sizeof(UNICODE_NULL)) { 05756 05757 // 05758 // There is room in the buffer so just append a null 05759 // 05760 05761 ValueData->Buffer[(ValueData->Length / sizeof(WCHAR))] = UNICODE_NULL; 05762 05763 // 05764 // Set the registry value 05765 // 05766 05767 status = ZwSetValueKey(KeyHandle, 05768 ValueName, 05769 0, 05770 REG_SZ, 05771 (PVOID) ValueData->Buffer, 05772 ValueData->Length + sizeof(UNICODE_NULL) 05773 ); 05774 05775 } else { 05776 05777 UNICODE_STRING tempString; 05778 05779 // 05780 // There is no room so allocate a new buffer and so we need to build 05781 // a new string with room 05782 // 05783 05784 status = IopAllocateUnicodeString(&tempString, ValueData->Length); 05785 05786 if (!NT_SUCCESS(status)) { 05787 goto clean0; 05788 } 05789 05790 // 05791 // Copy the input string to the output string 05792 // 05793 05794 tempString.Length = ValueData->Length; 05795 RtlCopyMemory(tempString.Buffer, ValueData->Buffer, ValueData->Length); 05796 05797 // 05798 // Add the null termination 05799 // 05800 05801 tempString.Buffer[tempString.Length / sizeof(WCHAR)] = UNICODE_NULL; 05802 05803 // 05804 // Set the registry value 05805 // 05806 05807 status = ZwSetValueKey(KeyHandle, 05808 ValueName, 05809 0, 05810 REG_SZ, 05811 (PVOID) tempString.Buffer, 05812 tempString.Length + sizeof(UNICODE_NULL) 05813 ); 05814 05815 // 05816 // Free the temporary string 05817 // 05818 05819 IopFreeAllocatedUnicodeString(&tempString); 05820 05821 } 05822 05823 clean0: 05824 return status; 05825 05826 }

NTKERNELAPI NTSTATUS IoQueryDeviceDescription IN PINTERFACE_TYPE BusType  OPTIONAL,
IN PULONG BusNumber  OPTIONAL,
IN PCONFIGURATION_TYPE ControllerType  OPTIONAL,
IN PULONG ControllerNumber  OPTIONAL,
IN PCONFIGURATION_TYPE PeripheralType  OPTIONAL,
IN PULONG PeripheralNumber  OPTIONAL,
IN PIO_QUERY_DEVICE_ROUTINE  CalloutRoutine,
IN PVOID  Context
 

Definition at line 70 of file io/query.c.

References ASSERT, _IO_QUERY_DESC::BusNumber, BusNumber, _IO_QUERY_DESC::BusType, _IO_QUERY_DESC::CalloutRoutine, CmRegistryMachineHardwareDescriptionSystemName, _IO_QUERY_DESC::Context, _IO_QUERY_DESC::ControllerNumber, _IO_QUERY_DESC::ControllerType, ControllerType, ExAllocatePoolWithTag, ExFreePool(), FALSE, IopOpenRegistryKey(), NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, PagedPool, _IO_QUERY_DESC::PeripheralNumber, _IO_QUERY_DESC::PeripheralType, PeripheralType, pIoQueryBusDescription(), RtlAppendUnicodeStringToString(), TRUE, and UNICODE_REGISTRY_PATH_LENGTH.

Referenced by FsVgaConfiguration(), MapperCallback(), and MapperProcessFirmwareTree().

00083 : 00084 00085 00086 Arguments: 00087 00088 BusType - Supplies an optional bus type being searched for in the 00089 description tree. Valid types are Mca, Isa, Eisa ... If no bus type 00090 is specified, the system information (i.e. machine BIOS) is returned. 00091 00092 BusNumber - Supplies an optional value determining which bus should be 00093 queried. 00094 00095 ControllerType - Supplies an optional controller type being searched for. 00096 If no Controller type is specified, only the Bus information is 00097 returned. 00098 00099 ControllerNumber - Supplies an optional value determining which 00100 controller should be queried. 00101 00102 PeripheralType - Supplies an optional peripheral type being searched for. 00103 If no Controller type is specified, only the Bus information and the 00104 controller information are returned. 00105 00106 PeripheralNumber - Supplies an optional value determining which 00107 peripheral should be queried. 00108 00109 CalloutRoutine - Supplies a pointer to a routine that gets called 00110 for each successful match of PeripheralType. 00111 00112 Context - Supplies a context value that is passed back to the callback 00113 routine. 00114 00115 Return Value: 00116 00117 The status returned is the final completion status of the operation. 00118 00119 Notes: 00120 00121 --*/ 00122 00123 { 00124 00125 #define UNICODE_NUM_LENGTH 14 00126 #define UNICODE_REGISTRY_PATH_LENGTH 1024 00127 00128 IO_QUERY_DESC queryDesc; 00129 00130 NTSTATUS status; 00131 UNICODE_STRING registryPathName; 00132 HANDLE rootHandle; 00133 ULONG busNumber = (ULONG) -1; 00134 00135 00136 PAGED_CODE(); 00137 00138 ASSERT( CalloutRoutine != NULL ); 00139 00140 // 00141 // Check if we need to return the machine information 00142 // 00143 00144 if (!ARGUMENT_PRESENT( BusType )) { 00145 return STATUS_NOT_IMPLEMENTED; 00146 } 00147 00148 queryDesc.BusType = BusType; 00149 queryDesc.BusNumber = BusNumber; 00150 queryDesc.ControllerType = ControllerType; 00151 queryDesc.ControllerNumber = ControllerNumber; 00152 queryDesc.PeripheralType = PeripheralType; 00153 queryDesc.PeripheralNumber = PeripheralNumber; 00154 queryDesc.CalloutRoutine = CalloutRoutine; 00155 queryDesc.Context = Context; 00156 00157 00158 // 00159 // Set up a string with the pathname to the hardware description 00160 // portion of the registry. 00161 // 00162 00163 registryPathName.Length = 0; 00164 registryPathName.MaximumLength = UNICODE_REGISTRY_PATH_LENGTH * 00165 sizeof(WCHAR); 00166 00167 registryPathName.Buffer = ExAllocatePoolWithTag( PagedPool, 00168 UNICODE_REGISTRY_PATH_LENGTH, 00169 'mNoI' ); 00170 00171 if (!registryPathName.Buffer) { 00172 00173 return STATUS_INSUFFICIENT_RESOURCES; 00174 00175 } 00176 00177 RtlAppendUnicodeStringToString( &registryPathName, 00178 &CmRegistryMachineHardwareDescriptionSystemName ); 00179 00180 00181 // 00182 // Open a handle to the root path we have. 00183 // 00184 00185 status = IopOpenRegistryKey( &rootHandle, 00186 (HANDLE) NULL, 00187 &registryPathName, 00188 KEY_READ, 00189 FALSE ); 00190 00191 if (NT_SUCCESS( status )) { 00192 00193 status = pIoQueryBusDescription(&queryDesc, 00194 registryPathName, 00195 rootHandle, 00196 &busNumber, 00197 TRUE ); 00198 00199 ZwClose( rootHandle ); 00200 00201 } 00202 00203 ExFreePool( registryPathName.Buffer ); 00204 00205 // 00206 // For compatibility with old version of the function. 00207 // 00208 00209 if (status == STATUS_NO_MORE_ENTRIES) { 00210 00211 return STATUS_OBJECT_NAME_NOT_FOUND; 00212 00213 00214 } else { 00215 00216 return status; 00217 00218 } 00219 }

NTKERNELAPI NTSTATUS IoQueryFileInformation IN PFILE_OBJECT  FileObject,
IN FILE_INFORMATION_CLASS  FileInformationClass,
IN ULONG  Length,
OUT PVOID  FileInformation,
OUT PULONG  ReturnedLength
 

Definition at line 8628 of file iosubs.c.

References IopQueryXxxInformation(), PAGED_CODE, and TRUE.

Referenced by IopParseDevice(), and IopQueryName().

08638 : 08639 08640 This routine returns the requested information about a specified file. 08641 The information returned is determined by the FileInformationClass that 08642 is specified, and it is placed into the caller's FileInformation buffer. 08643 08644 Arguments: 08645 08646 FileObject - Supplies a pointer to the file object about which the requested 08647 information is returned. 08648 08649 FileInformationClass - Specifies the type of information which should be 08650 returned about the file. 08651 08652 Length - Supplies the length, in bytes, of the FileInformation buffer. 08653 08654 FileInformation - Supplies a buffer to receive the requested information 08655 returned about the file. This buffer must not be pageable and must 08656 reside in system space. 08657 08658 ReturnedLength - Supplies a variable that is to receive the length of the 08659 information written to the FileInformation buffer. 08660 08661 Return Value: 08662 08663 The status returned is the final completion status of the operation. 08664 08665 --*/ 08666 08667 { 08668 PAGED_CODE(); 08669 08670 // 08671 // Simply invoke the common routine to perform the query operation. 08672 // 08673 08674 return IopQueryXxxInformation( FileObject, 08675 FileInformationClass, 08676 Length, 08677 FileInformation, 08678 ReturnedLength, 08679 TRUE ); 08680 }

NTKERNELAPI NTSTATUS IoQueryVolumeInformation IN PFILE_OBJECT  FileObject,
IN FS_INFORMATION_CLASS  FsInformationClass,
IN ULONG  Length,
OUT PVOID  FsInformation,
OUT PULONG  ReturnedLength
 

Definition at line 8683 of file iosubs.c.

References FALSE, IopQueryXxxInformation(), and PAGED_CODE.

Referenced by MiAttemptPageFileExtension(), and NtCreatePagingFile().

08693 : 08694 08695 This routine returns the requested information about a specified volume. 08696 The information returned is determined by the FsInformationClass that 08697 is specified, and it is placed into the caller's FsInformation buffer. 08698 08699 Arguments: 08700 08701 FileObject - Supplies a pointer to the file object about which the requested 08702 information is returned. 08703 08704 FsInformationClass - Specifies the type of information which should be 08705 returned about the volume. 08706 08707 Length - Supplies the length of the FsInformation buffer in bytes. 08708 08709 FsInformation - Supplies a buffer to receive the requested information 08710 returned about the file. This buffer must not be pageable and must 08711 reside in system space. 08712 08713 ReturnedLength - Supplies a variable that is to receive the length of the 08714 information written to the FsInformation buffer. 08715 08716 Return Value: 08717 08718 The status returned is the final completion status of the operation. 08719 08720 --*/ 08721 08722 { 08723 PAGED_CODE(); 08724 08725 // 08726 // Simply invoke the common routine to perform the query operation. 08727 // 08728 08729 return IopQueryXxxInformation( FileObject, 08730 FsInformationClass, 08731 Length, 08732 FsInformation, 08733 ReturnedLength, 08734 FALSE ); 08735 }

NTKERNELAPI VOID IoQueueThreadIrp IN PIRP  Irp  ) 
 

Definition at line 8738 of file iosubs.c.

References IopQueueThreadIrp, and Irp.

Referenced by MiCheckPageFilePath().

08744 : 08745 08746 This routine queues the specified I/O Request Packet (IRP) to the current 08747 thread's IRP pending queue. This queue locates all of the outstanding 08748 I/O requests for the thread. 08749 08750 Arguments: 08751 08752 Irp - Pointer to the I/O Request Packet (IRP) to be queued. 08753 08754 Return Value: 08755 08756 None. 08757 08758 --*/ 08759 08760 { 08761 // 08762 // Simply queue the packet using the internal queueing routine. 08763 // 08764 08765 IopQueueThreadIrp( Irp ); 08766 }

VOID IoQueueWorkItem IN PIO_WORKITEM  IoWorkItem,
IN PIO_WORKITEM_ROUTINE  WorkerRoutine,
IN WORK_QUEUE_TYPE  QueueType,
IN PVOID  Context
 

Definition at line 953 of file io/misc.c.

References ASSERT, DISPATCH_LEVEL, ExQueueWorkItem(), and ObReferenceObject.

00961 : 00962 00963 This function inserts a work item into a work queue that is processed 00964 by a worker thread of the corresponding type. It effectively 00965 "wraps" ExQueueWorkItem, ensuring that the device object is referenced 00966 for the duration of the call. 00967 00968 Arguments: 00969 00970 IoWorkItem - Supplies a pointer to the work item to add the the queue. 00971 This structure must have been allocated via IoAllocateWorkItem(). 00972 00973 WorkerRoutine - Supplies a pointer to the routine that is to be called 00974 in system thread context. 00975 00976 QueueType - Specifies the type of work queue that the work item 00977 should be placed in. 00978 00979 Context - Supplies the context parameter for the callback routine. 00980 00981 Return Value: 00982 00983 None 00984 00985 --*/ 00986 00987 { 00988 PWORK_QUEUE_ITEM exWorkItem; 00989 00990 ASSERT( KeGetCurrentIrql() <= DISPATCH_LEVEL ); 00991 ASSERT( IoWorkItem->Size == sizeof( IO_WORKITEM )); 00992 00993 // 00994 // Keep a reference on the device object so it doesn't go away. 00995 // 00996 00997 ObReferenceObject( IoWorkItem->DeviceObject ); 00998 00999 // 01000 // Initialize the fields in IoWorkItem 01001 // 01002 01003 IoWorkItem->Routine = WorkerRoutine; 01004 IoWorkItem->Context = Context; 01005 01006 // 01007 // Get a pointer to the ExWorkItem, queue it, and return. 01008 // IopProcessWorkItem() will perform the dereference. 01009 // 01010 01011 exWorkItem = &IoWorkItem->WorkItem; 01012 ExQueueWorkItem( exWorkItem, QueueType ); 01013 }

NTKERNELAPI VOID IoRaiseHardError IN PIRP  Irp,
IN PVPB Vpb  OPTIONAL,
IN PDEVICE_OBJECT  RealDeviceObject
 

Definition at line 8769 of file iosubs.c.

References _IRP::ApcEnvironment, CriticalWorkQueue, ExAllocatePoolWithTag, ExInitializeWorkItem, ExQueueWorkItem(), _IRP::Flags, IO_DISK_INCREMENT, IoCompleteRequest, IoGetCurrentIrpStackLocation, IopAbortRequest(), IopDeallocateApc(), IopRaiseHardError(), IopStartApcHardError(), _IRP::IoStatus, Irp, _IOP_APC_HARD_ERROR_PACKET::Irp, IRP_INPUT_OPERATION, IRP_MJ_CLEANUP, IRP_NOCACHE, IRP_PAGING_IO, IRP_SYNCHRONOUS_PAGING_IO, _IOP_APC_HARD_ERROR_PACKET::Item, KeInitializeApc(), KeInsertQueueApc(), KernelMode, _IO_STACK_LOCATION::MajorFunction, NonPagedPool, NULL, _IOP_APC_HARD_ERROR_PACKET::RealDeviceObject, _IRP::Tail, VOID(), and _IOP_APC_HARD_ERROR_PACKET::Vpb.

Referenced by UdfProcessException().

08777 : 08778 08779 This routine pops up a hard error in the context of the thread that 08780 originally requested the I/O operation specified by the input IRP. This 08781 is done by queueing a kernel APC to the original thread, passing it a 08782 pointer to the device objects and the IRP. Once the pop up is performed, 08783 the routine either completes the I/O request then, or it calls the driver 08784 back with the same IRP. 08785 08786 If the original request was an IoPageRead, then it was at APC level and 08787 we have to create a thread to "hold" this pop-up. Note that we have to 08788 queue to an ExWorker thread to create the thread since this can only be 08789 done from the system process. 08790 08791 Arguments: 08792 08793 Irp - A pointer to the I/O Request Packet (IRP) for the request that 08794 failed. 08795 08796 Vpb - This is the volume parameter block of the offending media. If the 08797 media not yet mounted, this parameter should be absent. 08798 08799 RealDeviceObject - A pointer to the device object that represents the 08800 device that the file system believes it has mounted. This is 08801 generally the "real" device object in the VPB, but may, in fact, 08802 be a device object attached to the physical device. 08803 08804 Return Value: 08805 08806 None. 08807 08808 --*/ 08809 08810 { 08811 PIO_STACK_LOCATION IrpSp; 08812 08813 // 08814 // If pop-ups are disabled for the requesting thread, just complete the 08815 // request. 08816 // 08817 08818 if (Irp->Tail.Overlay.Thread->HardErrorsAreDisabled) { 08819 08820 // 08821 // An error was incurred, so zero out the information field before 08822 // completing the request if this was an input operation. Otherwise, 08823 // IopCompleteRequest will try to copy to the user's buffer. 08824 // 08825 08826 if (Irp->Flags & IRP_INPUT_OPERATION) { 08827 Irp->IoStatus.Information = 0; 08828 } 08829 08830 IoCompleteRequest( Irp, IO_DISK_INCREMENT ); 08831 08832 return; 08833 } 08834 08835 // 08836 // If this Irp resulted from a call to IoPageRead(), the caller must 08837 // have been at APC level, so don't try enqueing an APC. 08838 // 08839 // Also if this is a cleanup Irp, force this pop-up to go to the new 08840 // thread so that it cannot be disabled. 08841 // 08842 08843 IrpSp = IoGetCurrentIrpStackLocation(Irp); 08844 08845 if ((Irp->Flags == (IRP_PAGING_IO | 08846 IRP_NOCACHE | 08847 IRP_SYNCHRONOUS_PAGING_IO | 08848 IRP_INPUT_OPERATION)) || 08849 (IrpSp->MajorFunction == IRP_MJ_CLEANUP)) { 08850 08851 PIOP_APC_HARD_ERROR_PACKET packet; 08852 08853 packet = ExAllocatePoolWithTag( NonPagedPool, 08854 sizeof( IOP_APC_HARD_ERROR_PACKET ), 08855 'rEoI' ); 08856 08857 if ( packet == NULL ) { 08858 08859 IoCompleteRequest( Irp, IO_DISK_INCREMENT ); 08860 return; 08861 } 08862 08863 ExInitializeWorkItem( &packet->Item, IopStartApcHardError, packet ); 08864 packet->Irp = Irp; 08865 packet->Vpb = Vpb; 08866 packet->RealDeviceObject = RealDeviceObject; 08867 08868 ExQueueWorkItem( &packet->Item, CriticalWorkQueue ); 08869 08870 } else { 08871 08872 PKAPC apc; 08873 08874 // 08875 // Begin by allocating and initializing an APC that can be sent to the 08876 // target thread. 08877 // 08878 08879 apc = ExAllocatePoolWithTag( NonPagedPool, sizeof( KAPC ), 'CPAK' ); 08880 08881 // 08882 // If we could not get the pool, we have no choice but to just complete 08883 // the Irp, thereby passing the error onto the caller. 08884 // 08885 08886 if ( apc == NULL ) { 08887 08888 IoCompleteRequest( Irp, IO_DISK_INCREMENT ); 08889 return; 08890 } 08891 08892 KeInitializeApc( apc, 08893 &Irp->Tail.Overlay.Thread->Tcb, 08894 Irp->ApcEnvironment, 08895 IopDeallocateApc, 08896 IopAbortRequest, 08897 IopRaiseHardError, 08898 KernelMode, 08899 Irp ); 08900 08901 (VOID) KeInsertQueueApc( apc, 08902 Vpb, 08903 RealDeviceObject, 08904 0 ); 08905 } 08906 }

NTKERNELAPI BOOLEAN IoRaiseInformationalHardError IN NTSTATUS  ErrorStatus,
IN PUNICODE_STRING String  OPTIONAL,
IN PKTHREAD Thread  OPTIONAL
 

Definition at line 8909 of file iosubs.c.

References ArePacketsEquivalent, CurrentApcEnvironment, DelayedWorkQueue, _IOP_HARD_ERROR_PACKET::ErrorStatus, ExAllocatePoolWithTag, ExFreePool(), ExQueueWorkItem(), _IOP_HARD_ERROR_QUEUE::ExWorkItem, FALSE, IOP_HARD_ERROR_PACKET, IOP_MAXIMUM_OUTSTANDING_HARD_ERRORS, IopCurrentHardError, IopDeallocateApc(), IopHardError, IopRaiseInformationalHardError(), KeInitializeApc(), KeInsertQueueApc(), KeReadStateSemaphore(), KeReleaseSemaphore(), KernelMode, L, NonPagedPool, NULL, _IOP_HARD_ERROR_QUEUE::NumPendingApcPopups, PsGetCurrentThread, String, _IOP_HARD_ERROR_PACKET::String, _IOP_HARD_ERROR_QUEUE::ThreadStarted, TRUE, VOID(), _IOP_HARD_ERROR_QUEUE::WorkQueue, _IOP_HARD_ERROR_PACKET::WorkQueueLinks, _IOP_HARD_ERROR_QUEUE::WorkQueueSemaphore, and _IOP_HARD_ERROR_QUEUE::WorkQueueSpinLock.

Referenced by CcWriteBehind(), IoepHandleErrCase(), IoPnPDeliverServicePowerNotification(), MiCauseOverCommitPopup(), and MiWriteComplete().

08916 : 08917 08918 This routine pops up a hard error in the hard error popup thread. The 08919 routine returns immediately, enqueuing the actual pop-up to a worker 08920 thread. The hard error that is raised is informational in the sense that 08921 only the OK button is displayed. 08922 08923 Arguments: 08924 08925 ErrorStatus - The error condition. 08926 08927 String - Depending on the error, a string may have to be enqueued. 08928 08929 Thread - If present, enqueue an APC to this thread rather than using 08930 the hard error thread. 08931 08932 Return Value: 08933 08934 BOOLEAN - TRUE if we decided to dispatch a pop-up. FALSE if we decided 08935 not to because: 08936 08937 - pop-ups are disabled in the requested thread, or 08938 08939 - a pool allocation failed, or 08940 08941 - an equivalent pop-up is currently pending a user response (i.e. 08942 waiting for the user to press <OK>) or in the queue, or 08943 08944 - too many pop-ups have already been queued. 08945 08946 --*/ 08947 08948 // 08949 // This macro compares two pop-ups to see if they are content equivalent. 08950 // 08951 08952 #define ArePacketsEquivalent(P1,P2) ( \ 08953 (P1->ErrorStatus == P2->ErrorStatus) && \ 08954 ((!P1->String.Buffer && !P2->String.Buffer) || \ 08955 ((P1->String.Length == P2->String.Length) && \ 08956 (RtlEqualMemory(P1->String.Buffer, \ 08957 P2->String.Buffer, \ 08958 P1->String.Length)))) \ 08959 ) 08960 08961 { 08962 KIRQL oldIrql; 08963 PVOID stringBuffer; 08964 PLIST_ENTRY links; 08965 08966 PIOP_HARD_ERROR_PACKET hardErrorPacket; 08967 08968 // 08969 // If pop-ups are disabled for the requesting thread, just return. 08970 // 08971 08972 if (ARGUMENT_PRESENT(Thread) ? 08973 CONTAINING_RECORD(Thread, ETHREAD, Tcb)->HardErrorsAreDisabled : 08974 PsGetCurrentThread()->HardErrorsAreDisabled) { 08975 08976 return FALSE; 08977 } 08978 08979 // 08980 // If this is one of those special error popup codes that CSRSS expects 08981 // to be called with a correct set of arguments, disallow from a driver 08982 // 08983 if ( ErrorStatus == STATUS_VDM_HARD_ERROR || 08984 ErrorStatus == STATUS_UNHANDLED_EXCEPTION || 08985 ErrorStatus == STATUS_SERVICE_NOTIFICATION ) { 08986 return FALSE; 08987 } 08988 08989 // 08990 // If this request is going to be sent to the hard error thread, and 08991 // there are more than 25 entries already in the queue, don't 08992 // add any more. We'll do another safe check later on. 08993 // 08994 08995 if ( !ARGUMENT_PRESENT( Thread ) && 08996 (KeReadStateSemaphore( &IopHardError.WorkQueueSemaphore ) >= 08997 IOP_MAXIMUM_OUTSTANDING_HARD_ERRORS) ) { 08998 08999 return FALSE; 09000 } else { 09001 if (IopHardError.NumPendingApcPopups > IOP_MAXIMUM_OUTSTANDING_HARD_ERRORS) { 09002 return FALSE; 09003 } 09004 } 09005 09006 // 09007 // Allocate the packet, and a buffer for the string if present. 09008 // 09009 09010 hardErrorPacket = ExAllocatePoolWithTag( NonPagedPool, 09011 sizeof(IOP_HARD_ERROR_PACKET), 09012 'rEoI'); 09013 09014 if (!hardErrorPacket) { return FALSE; } 09015 09016 // 09017 // Zero out the packet and fill the NT_STATUS we will pop up. 09018 // 09019 09020 RtlZeroMemory( hardErrorPacket, sizeof(IOP_HARD_ERROR_PACKET) ); 09021 09022 hardErrorPacket->ErrorStatus = ErrorStatus; 09023 09024 // 09025 // If there is a string, copy it. 09026 // 09027 09028 if ( ARGUMENT_PRESENT( String ) && String->Length ) { 09029 09030 stringBuffer = ExAllocatePoolWithTag( NonPagedPool, 09031 String->Length, 09032 'rEoI' ); 09033 09034 if (!stringBuffer) { 09035 ExFreePool( hardErrorPacket ); 09036 return FALSE; 09037 } 09038 09039 hardErrorPacket->String.Length = String->Length; 09040 hardErrorPacket->String.MaximumLength = String->Length; 09041 09042 hardErrorPacket->String.Buffer = stringBuffer; 09043 09044 RtlCopyMemory( stringBuffer, String->Buffer, String->Length ); 09045 } 09046 09047 // 09048 // If there is an Thread, enqueue an APC for ourself, otherwise send 09049 // it off to the to the hard error thread. 09050 // 09051 09052 if ( ARGUMENT_PRESENT( Thread ) ) { 09053 09054 PKAPC apc; 09055 09056 // 09057 // Begin by allocating and initializing an APC that can be sent to the 09058 // target thread. 09059 // 09060 09061 apc = ExAllocatePoolWithTag( NonPagedPool, sizeof( KAPC ), 'CPAK' ); 09062 09063 // 09064 // If we could not get the pool, we have no choice but to just 09065 // free the packet and return. 09066 // 09067 09068 if ( apc == NULL ) { 09069 09070 if ( hardErrorPacket->String.Buffer ) { 09071 ExFreePool( hardErrorPacket->String.Buffer ); 09072 } 09073 09074 ExFreePool( hardErrorPacket ); 09075 09076 return FALSE; 09077 } 09078 09079 InterlockedIncrement(&IopHardError.NumPendingApcPopups); 09080 KeInitializeApc( apc, 09081 Thread, 09082 CurrentApcEnvironment, 09083 IopDeallocateApc, 09084 NULL, 09085 IopRaiseInformationalHardError, 09086 KernelMode, 09087 hardErrorPacket ); 09088 09089 (VOID) KeInsertQueueApc( apc, NULL, NULL, 0 ); 09090 09091 } else { 09092 09093 // 09094 // Get exclusive access to the work queue. 09095 // 09096 09097 ExAcquireSpinLock( &IopHardError.WorkQueueSpinLock, &oldIrql ); 09098 09099 // 09100 // Check the Signal state again, if OK, go ahead and enqueue. 09101 // 09102 09103 if ( KeReadStateSemaphore( &IopHardError.WorkQueueSemaphore ) >= 09104 IOP_MAXIMUM_OUTSTANDING_HARD_ERRORS ) { 09105 09106 ExReleaseSpinLock( &IopHardError.WorkQueueSpinLock, oldIrql ); 09107 09108 if ( hardErrorPacket->String.Buffer ) { 09109 ExFreePool( hardErrorPacket->String.Buffer ); 09110 } 09111 ExFreePool( hardErrorPacket ); 09112 return FALSE; 09113 } 09114 09115 // 09116 // If there is a pop-up currently up, check for a match 09117 // 09118 09119 if (IopCurrentHardError && 09120 ArePacketsEquivalent( hardErrorPacket, IopCurrentHardError )) { 09121 09122 ExReleaseSpinLock( &IopHardError.WorkQueueSpinLock, oldIrql ); 09123 09124 if ( hardErrorPacket->String.Buffer ) { 09125 ExFreePool( hardErrorPacket->String.Buffer ); 09126 } 09127 ExFreePool( hardErrorPacket ); 09128 return FALSE; 09129 } 09130 09131 // 09132 // Run down the list of queued pop-ups looking for a match. 09133 // 09134 09135 links = IopHardError.WorkQueue.Flink; 09136 09137 while (links != &IopHardError.WorkQueue) { 09138 09139 PIOP_HARD_ERROR_PACKET queueHardErrorPacket; 09140 09141 queueHardErrorPacket = CONTAINING_RECORD( links, 09142 IOP_HARD_ERROR_PACKET, 09143 WorkQueueLinks ); 09144 09145 if (ArePacketsEquivalent( hardErrorPacket, 09146 queueHardErrorPacket )) { 09147 09148 ExReleaseSpinLock( &IopHardError.WorkQueueSpinLock, oldIrql ); 09149 09150 if ( hardErrorPacket->String.Buffer ) { 09151 ExFreePool( hardErrorPacket->String.Buffer ); 09152 } 09153 ExFreePool( hardErrorPacket ); 09154 return FALSE; 09155 } 09156 09157 links = links->Flink; 09158 } 09159 09160 // 09161 // Enqueue this packet. 09162 // 09163 09164 InsertTailList( &IopHardError.WorkQueue, 09165 &hardErrorPacket->WorkQueueLinks ); 09166 09167 // 09168 // Bump the count on the semaphore so that the hard error thread 09169 // will know that an entry has been placed in the queue. 09170 // 09171 09172 (VOID) KeReleaseSemaphore( &IopHardError.WorkQueueSemaphore, 09173 0, 09174 1L, 09175 FALSE ); 09176 09177 // 09178 // If we are not currently running in an ExWorkerThread, queue 09179 // a work item. 09180 // 09181 09182 if ( !IopHardError.ThreadStarted ) { 09183 IopHardError.ThreadStarted = TRUE; 09184 ExQueueWorkItem( &IopHardError.ExWorkItem, DelayedWorkQueue ); 09185 } 09186 09187 // 09188 // Finally, release the spinlockevent, allowing access to the work queue again. 09189 // The combination of releasing both the event and the semaphore will 09190 // enable the thread to wake up and obtain the entry. 09191 // 09192 09193 ExReleaseSpinLock( &IopHardError.WorkQueueSpinLock, oldIrql ); 09194 } 09195 09196 return TRUE; 09197 }

NTKERNELAPI VOID IoRegisterBootDriverReinitialization IN PDRIVER_OBJECT  DriverObject,
IN PDRIVER_REINITIALIZE  DriverReinitializationRoutine,
IN PVOID  Context
 

Definition at line 9200 of file iosubs.c.

References _REINIT_PACKET::Context, _REINIT_PACKET::DriverObject, _REINIT_PACKET::DriverReinitializationRoutine, DRVO_BOOTREINIT_REGISTERED, ExAllocatePoolWithTag, ExInterlockedInsertTailList(), IopBootDriverReinitializeQueueHead, IopDatabaseLock, _REINIT_PACKET::ListEntry, NonPagedPool, and PAGED_CODE.

09208 : 09209 09210 This routine is invoked by boot drivers during their initialization or 09211 during their reinitialization to register with the I/O system to be 09212 called again once all devices have been enumerated and started. 09213 Note that it is possible for this to occur during a normally running 09214 system, if the driver is loaded dynamically, so all references to the 09215 reinitialization queue must be synchronized. 09216 09217 Arguments: 09218 09219 DriverObject - Pointer to the driver's driver object. 09220 09221 DriverReinitializationRoutine - The address of the reinitialization 09222 routine that is to be invoked. 09223 09224 Context - Pointer to the context that is passed to the driver's 09225 reinitialization routine. 09226 09227 Return Value: 09228 09229 None. 09230 09231 --*/ 09232 09233 { 09234 PREINIT_PACKET reinitEntry; 09235 09236 PAGED_CODE(); 09237 09238 // 09239 // Allocate a reinitialization entry to be inserted onto the list. Note 09240 // that if the entry cannot be allocated, then the request is simply 09241 // dropped on the floor. 09242 // 09243 09244 reinitEntry = ExAllocatePoolWithTag( NonPagedPool, 09245 sizeof( REINIT_PACKET ), 09246 'iRoI' ); 09247 if (!reinitEntry) { 09248 return; 09249 } 09250 09251 DriverObject->Flags |= DRVO_BOOTREINIT_REGISTERED; 09252 reinitEntry->DriverObject = DriverObject; 09253 reinitEntry->DriverReinitializationRoutine = DriverReinitializationRoutine; 09254 reinitEntry->Context = Context; 09255 09256 ExInterlockedInsertTailList( &IopBootDriverReinitializeQueueHead, 09257 &reinitEntry->ListEntry, 09258 &IopDatabaseLock ); 09259 }

NTKERNELAPI VOID IoRegisterDriverReinitialization IN PDRIVER_OBJECT  DriverObject,
IN PDRIVER_REINITIALIZE  DriverReinitializationRoutine,
IN PVOID  Context
 

Definition at line 9262 of file iosubs.c.

References _REINIT_PACKET::Context, _REINIT_PACKET::DriverObject, _REINIT_PACKET::DriverReinitializationRoutine, DRVO_REINIT_REGISTERED, ExAllocatePoolWithTag, ExInterlockedInsertTailList(), IopDatabaseLock, IopDriverReinitializeQueueHead, _REINIT_PACKET::ListEntry, NonPagedPool, and PAGED_CODE.

09270 : 09271 09272 This routine is invoked by drivers during their initialization or during 09273 their reinitialization to register with the I/O system to be called again 09274 before I/O system initialization is complete. Note that it is possible 09275 for this to occur during a normally running system, if the driver is 09276 loaded dynamically, so all references to the reinitialization queue must 09277 be synchronized. 09278 09279 Arguments: 09280 09281 DriverObject - Pointer to the driver's driver object. 09282 09283 DriverReinitializationRoutine - The address of the reinitialization 09284 routine that is to be invoked. 09285 09286 Context - Pointer to the context that is passed to the driver's 09287 reinitialization routine. 09288 09289 Return Value: 09290 09291 None. 09292 09293 --*/ 09294 09295 { 09296 PREINIT_PACKET reinitEntry; 09297 09298 PAGED_CODE(); 09299 09300 // 09301 // Allocate a reinitialization entry to be inserted onto the list. Note 09302 // that if the entry cannot be allocated, then the request is simply 09303 // dropped on the floor. 09304 // 09305 09306 reinitEntry = ExAllocatePoolWithTag( NonPagedPool, 09307 sizeof( REINIT_PACKET ), 09308 'iRoI' ); 09309 if (!reinitEntry) { 09310 return; 09311 } 09312 09313 DriverObject->Flags |= DRVO_REINIT_REGISTERED; 09314 reinitEntry->DriverObject = DriverObject; 09315 reinitEntry->DriverReinitializationRoutine = DriverReinitializationRoutine; 09316 reinitEntry->Context = Context; 09317 09318 ExInterlockedInsertTailList( &IopDriverReinitializeQueueHead, 09319 &reinitEntry->ListEntry, 09320 &IopDatabaseLock ); 09321 }

NTKERNELAPI VOID IoRegisterFileSystem IN OUT PDEVICE_OBJECT  DeviceObject  ) 
 

Definition at line 9324 of file iosubs.c.

References DO_DEVICE_INITIALIZING, DO_LOW_PRIORITY_FILESYSTEM, ExAcquireResourceExclusive, ExInterlockedAddUlong(), ExReleaseResource, IopCdRomFileSystemQueueHead, IopDatabaseLock, IopDatabaseResource, IopDiskFileSystemQueueHead, IopFsNotifyChangeQueueHead, IopNetworkFileSystemQueueHead, IopTapeFileSystemQueueHead, _NOTIFICATION_PACKET::NotificationRoutine, NULL, PAGED_CODE, TRUE, and VOID().

Referenced by FsRecCreateAndRegisterDO().

09330 : 09331 09332 This routine inserts the device object for the file system which the device 09333 object represents into the list of file systems in the system. 09334 09335 Arguments: 09336 09337 DeviceObject - Pointer to device object for the file system. 09338 09339 Return Value: 09340 09341 None. 09342 09343 09344 --*/ 09345 09346 { 09347 PNOTIFICATION_PACKET nPacket; 09348 PLIST_ENTRY listHead = NULL; 09349 PLIST_ENTRY entry; 09350 09351 PAGED_CODE(); 09352 09353 // 09354 // Allocate the I/O database resource for a write operation. 09355 // 09356 09357 (VOID) ExAcquireResourceExclusive( &IopDatabaseResource, TRUE ); 09358 09359 // 09360 // Insert the device object into the appropriate file system queue based on 09361 // the driver type in the device object. Notice that if the device type is 09362 // unrecognized, the file system is simply not registered. 09363 // 09364 09365 if (DeviceObject->DeviceType == FILE_DEVICE_NETWORK_FILE_SYSTEM) { 09366 listHead = &IopNetworkFileSystemQueueHead; 09367 } else if (DeviceObject->DeviceType == FILE_DEVICE_CD_ROM_FILE_SYSTEM) { 09368 listHead = &IopCdRomFileSystemQueueHead; 09369 } else if (DeviceObject->DeviceType == FILE_DEVICE_DISK_FILE_SYSTEM) { 09370 listHead = &IopDiskFileSystemQueueHead; 09371 } else if (DeviceObject->DeviceType == FILE_DEVICE_TAPE_FILE_SYSTEM) { 09372 listHead = &IopTapeFileSystemQueueHead; 09373 } 09374 09375 // 09376 // Low priority filesystems are inserted one-from-back on the queue (ahead of 09377 // raw, behind everything else), as opposed to on the front. 09378 // 09379 09380 if (listHead != NULL) { 09381 if (DeviceObject->Flags & DO_LOW_PRIORITY_FILESYSTEM ) { 09382 InsertTailList( listHead->Blink, 09383 &DeviceObject->Queue.ListEntry ); 09384 } else { 09385 InsertHeadList( listHead, 09386 &DeviceObject->Queue.ListEntry ); 09387 } 09388 } 09389 09390 // 09391 // Ensure that this file system's device is operable. 09392 // 09393 09394 DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; 09395 09396 // 09397 // Notify all of the registered drivers that this file system has been 09398 // registered as an active file system of some type. 09399 // 09400 09401 entry = IopFsNotifyChangeQueueHead.Flink; 09402 while (entry != &IopFsNotifyChangeQueueHead) { 09403 nPacket = CONTAINING_RECORD( entry, NOTIFICATION_PACKET, ListEntry ); 09404 entry = entry->Flink; 09405 nPacket->NotificationRoutine( DeviceObject, TRUE ); 09406 } 09407 09408 // 09409 // Release the I/O database resource. 09410 // 09411 09412 ExReleaseResource( &IopDatabaseResource ); 09413 09414 // 09415 // Increment the number of reasons that this driver cannot be unloaded. 09416 // 09417 09418 ExInterlockedAddUlong( &DeviceObject->ReferenceCount, 1, &IopDatabaseLock ); 09419 }

NTKERNELAPI NTSTATUS IoRegisterFsRegistrationChange IN PDRIVER_OBJECT  DriverObject,
IN PDRIVER_FS_NOTIFICATION  DriverNotificationRoutine
 

Definition at line 9422 of file iosubs.c.

References _NOTIFICATION_PACKET::DriverObject, ExAcquireResourceExclusive, ExAllocatePoolWithTag, ExReleaseResource, IopDatabaseResource, IopFsNotifyChangeQueueHead, _NOTIFICATION_PACKET::ListEntry, _NOTIFICATION_PACKET::NotificationRoutine, ObReferenceObject, PAGED_CODE, PagedPool, and TRUE.

09429 : 09430 09431 This routine registers the specified driver's notification routine to be 09432 invoked whenever a file system registers or unregisters itself as an active 09433 file system in the system. 09434 09435 Arguments: 09436 09437 DriverObject - Pointer to the driver object for the driver. 09438 09439 DriverNotificationRoutine - Address of routine to invoke when a file system 09440 registers or unregisters itself. 09441 09442 Return Value: 09443 09444 The return status is the final value of the function. 09445 09446 --*/ 09447 09448 { 09449 PNOTIFICATION_PACKET nPacket; 09450 09451 PAGED_CODE(); 09452 09453 // 09454 // Begin by attempting to allocate storage for the shutdown packet. If 09455 // one cannot be allocated, simply return an appropriate error. 09456 // 09457 09458 nPacket = ExAllocatePoolWithTag( PagedPool, 09459 sizeof( NOTIFICATION_PACKET ), 09460 'sFoI' ); 09461 if (!nPacket) { 09462 return STATUS_INSUFFICIENT_RESOURCES; 09463 } 09464 09465 // 09466 // Initialize the notification packet and insert it onto the tail of the 09467 // list. 09468 // 09469 09470 nPacket->DriverObject = DriverObject; 09471 nPacket->NotificationRoutine = DriverNotificationRoutine; 09472 09473 ExAcquireResourceExclusive( &IopDatabaseResource, TRUE ); 09474 InsertTailList( &IopFsNotifyChangeQueueHead, &nPacket->ListEntry ); 09475 ExReleaseResource( &IopDatabaseResource ); 09476 09477 // 09478 // Increment the number of reasons that this driver cannot be unloaded. 09479 // 09480 09481 ObReferenceObject( DriverObject ); 09482 09483 return STATUS_SUCCESS; 09484 }

NTKERNELAPI NTSTATUS IoRegisterLastChanceShutdownNotification IN PDEVICE_OBJECT  DeviceObject  ) 
 

Definition at line 9487 of file iosubs.c.

References _SHUTDOWN_PACKET::DeviceObject, DO_SHUTDOWN_REGISTERED, ExAllocatePoolWithTag, ExInterlockedInsertHeadList(), IopDatabaseLock, IopNotifyLastChanceShutdownQueueHead, _SHUTDOWN_PACKET::ListEntry, NonPagedPool, and PAGED_CODE.

09493 : 09494 09495 This routine allows a driver to register that it would like to have its 09496 shutdown routine invoked at very late in system shutdown. This gives 09497 the driver an opportunity to get control just before the system is fully 09498 shutdown. 09499 09500 Arguments: 09501 09502 DeviceObject - Pointer to the driver's device object. 09503 09504 Return Value: 09505 09506 None. 09507 09508 --*/ 09509 09510 { 09511 PSHUTDOWN_PACKET shutdown; 09512 09513 PAGED_CODE(); 09514 09515 // 09516 // Begin by attempting to allocate storage for the shutdown packet. If 09517 // one cannot be allocated, simply return an appropriate error. 09518 // 09519 09520 shutdown = ExAllocatePoolWithTag( NonPagedPool, 09521 sizeof( SHUTDOWN_PACKET ), 09522 'hSoI' ); 09523 if (!shutdown) { 09524 return STATUS_INSUFFICIENT_RESOURCES; 09525 } 09526 09527 // 09528 // Initialize the shutdown packet and insert it onto the head of the list. 09529 // Note that this is done because some drivers have dependencies on LIFO 09530 // notification ordering. 09531 // 09532 09533 shutdown->DeviceObject = DeviceObject; 09534 09535 ExInterlockedInsertHeadList( &IopNotifyLastChanceShutdownQueueHead, 09536 &shutdown->ListEntry, 09537 &IopDatabaseLock ); 09538 09539 // 09540 // Do the bookkeeping to indicate that this driver has successfully 09541 // registered a shutdown notification routine. 09542 // 09543 09544 DeviceObject->Flags |= DO_SHUTDOWN_REGISTERED; 09545 09546 return STATUS_SUCCESS; 09547 }

NTKERNELAPI NTSTATUS IoRegisterShutdownNotification IN PDEVICE_OBJECT  DeviceObject  ) 
 

Definition at line 9550 of file iosubs.c.

References _SHUTDOWN_PACKET::DeviceObject, DO_SHUTDOWN_REGISTERED, ExAllocatePoolWithTag, ExInterlockedInsertHeadList(), IopDatabaseLock, IopNotifyShutdownQueueHead, _SHUTDOWN_PACKET::ListEntry, NonPagedPool, and PAGED_CODE.

09556 : 09557 09558 This routine allows a driver to register that it would like to have its 09559 shutdown routine invoked when the system is being shutdown. This gives 09560 the driver an opportunity to get control just before the system is fully 09561 shutdown. 09562 09563 Arguments: 09564 09565 DeviceObject - Pointer to the driver's device object. 09566 09567 Return Value: 09568 09569 None. 09570 09571 --*/ 09572 09573 { 09574 PSHUTDOWN_PACKET shutdown; 09575 09576 PAGED_CODE(); 09577 09578 // 09579 // Begin by attempting to allocate storage for the shutdown packet. If 09580 // one cannot be allocated, simply return an appropriate error. 09581 // 09582 09583 shutdown = ExAllocatePoolWithTag( NonPagedPool, 09584 sizeof( SHUTDOWN_PACKET ), 09585 'hSoI' ); 09586 if (!shutdown) { 09587 return STATUS_INSUFFICIENT_RESOURCES; 09588 } 09589 09590 // 09591 // Initialize the shutdown packet and insert it onto the head of the list. 09592 // Note that this is done because some drivers have dependencies on LIFO 09593 // notification ordering. 09594 // 09595 09596 shutdown->DeviceObject = DeviceObject; 09597 09598 ExInterlockedInsertHeadList( &IopNotifyShutdownQueueHead, 09599 &shutdown->ListEntry, 09600 &IopDatabaseLock ); 09601 09602 // 09603 // Do the bookkeeping to indicate that this driver has successfully 09604 // registered a shutdown notification routine. 09605 // 09606 09607 DeviceObject->Flags |= DO_SHUTDOWN_REGISTERED; 09608 09609 return STATUS_SUCCESS; 09610 }

NTKERNELAPI VOID IoReleaseCancelSpinLock IN KIRQL  Irql  ) 
 

Definition at line 9613 of file iosubs.c.

References IopCancelSpinLock.

Referenced by FsRtlAcknowledgeOplockBreak(), FsRtlCancelExclusiveIrp(), FsRtlCancelNotify(), FsRtlCancelOplockIIIrp(), FsRtlCancelWaitIrp(), FsRtlNotifySetCancelRoutine(), FsRtlOplockBreakToII(), FsRtlOplockBreakToNone(), FsRtlOplockCleanup(), FsRtlPrivateCancelFileLockIrp(), FsRtlRemoveAndCompleteIrp(), FsRtlRemoveAndCompleteWaitIrp(), FsRtlRequestExclusiveOplock(), FsRtlRequestOplockII(), FsRtlUninitializeFileLock(), FsRtlUninitializeOplock(), FsRtlWaitOnIrp(), IoCancelIrp(), IoStartNextPacket(), IoStartNextPacketByKey(), and IoStartPacket().

09619 : 09620 09621 This routine is invoked to release the cancel spin lock. This spin lock 09622 must be acquired before setting the address of a cancel routine in an 09623 IRP and released after the cancel routine has been set. 09624 09625 Arguments: 09626 09627 Irql - Supplies the IRQL value returned from acquiring the spin lock. 09628 09629 Return Value: 09630 09631 None. 09632 09633 --*/ 09634 09635 { 09636 // 09637 // Simply release the cancel spin lock. 09638 // 09639 09640 ExReleaseSpinLock( &IopCancelSpinLock, Irql ); 09641 }

NTSYSAPI VOID NTAPI IoReleaseRemoveLockAndWaitEx IN PIO_REMOVE_LOCK  RemoveLock,
IN PVOID  Tag,
IN ULONG  RemlockSize
 

Definition at line 394 of file io/remlock.c.

References ASSERT, CHECKEDSIZE, Executive, ExFreePool(), FALSE, FREESIZE, KernelMode, KeWaitForSingleObject(), Lock, NULL, PAGED_CODE, PIO_PRIVATE_REMOVE_LOCK, and TRUE.

00402 : 00403 00404 This routine is called when the client would like to delete the remove- 00405 locked resource. 00406 This routine will block until all the remove locks have completed. 00407 00408 This routine MUST be called after acquiring once more the lock. 00409 00410 Arguments: 00411 00412 RemoveLock - 00413 00414 Return Value: 00415 00416 none 00417 00418 --*/ 00419 { 00420 PIO_PRIVATE_REMOVE_LOCK Lock = (PIO_PRIVATE_REMOVE_LOCK) PublicLock; 00421 LONG ioCount; 00422 00423 PAGED_CODE (); 00424 00425 Lock->Common.Removed = TRUE; 00426 00427 ioCount = InterlockedDecrement (&Lock->Common.IoCount); 00428 ASSERT (0 < ioCount); 00429 00430 if (0 < InterlockedDecrement (&Lock->Common.IoCount)) { 00431 KeWaitForSingleObject (&Lock->Common.RemoveEvent, 00432 Executive, 00433 KernelMode, 00434 FALSE, 00435 NULL); 00436 } 00437 00438 switch (RemlockSize) { 00439 case CHECKEDSIZE: 00440 00441 ASSERT (Lock->Dbg.Blocks); 00442 if (Tag != Lock->Dbg.Blocks->Tag) { 00443 KdPrint (("IoRelaseRemoveLockAndWait last tag invalid %x %x\n", 00444 Tag, 00445 Lock->Dbg.Blocks->Tag)); 00446 00447 ASSERT (Tag != Lock->Dbg.Blocks->Tag); 00448 } 00449 00450 ExFreePool (Lock->Dbg.Blocks); 00451 break; 00452 00453 case FREESIZE: 00454 break; 00455 00456 default: 00457 break; 00458 00459 } 00460 }

NTSYSAPI VOID NTAPI IoReleaseRemoveLockEx IN PIO_REMOVE_LOCK  RemoveLock,
IN PVOID  Tag,
IN ULONG  RemlockSize
 

Definition at line 244 of file io/remlock.c.

References ASSERT, CHECKEDSIZE, ExFreePool(), FALSE, _IO_REMOVE_LOCK_TRACKING_BLOCK::File, FREESIZE, IO_NO_INCREMENT, KeQueryTickCount(), KeSetEvent(), _IO_REMOVE_LOCK_TRACKING_BLOCK::Line, _IO_REMOVE_LOCK_TRACKING_BLOCK::Link, Lock, NULL, PIO_PRIVATE_REMOVE_LOCK, _IO_REMOVE_LOCK_TRACKING_BLOCK::Tag, _IO_REMOVE_LOCK_TRACKING_BLOCK::TimeLocked, and TRUE.

00252 : 00253 00254 This routine is called to release the remove lock on the device object. It 00255 must be called when finished using a previously locked reference to the 00256 device object. If an Tag was specified when acquiring the lock then the 00257 same Tag must be specified when releasing the lock. 00258 00259 When the lock count reduces to zero, this routine will signal the waiting 00260 event to release the waiting thread deleting the device object protected 00261 by this lock. 00262 00263 Arguments: 00264 00265 DeviceObject - the device object to lock 00266 00267 Tag - The tag (if any) specified when acquiring the lock. This is used 00268 for lock tracking purposes 00269 00270 Return Value: 00271 00272 none 00273 00274 --*/ 00275 00276 { 00277 PIO_PRIVATE_REMOVE_LOCK Lock = (PIO_PRIVATE_REMOVE_LOCK) PublicLock; 00278 LONG lockValue; 00279 KIRQL oldIrql; 00280 LARGE_INTEGER ticks; 00281 LONGLONG difference; 00282 BOOLEAN found; 00283 00284 PIO_REMOVE_LOCK_TRACKING_BLOCK last; 00285 PIO_REMOVE_LOCK_TRACKING_BLOCK current; 00286 00287 switch (RemlockSize) { 00288 case CHECKEDSIZE: 00289 00290 // 00291 // Check the tick count and make sure this thing hasn't been locked 00292 // for more than MaxLockedMinutes. 00293 // 00294 00295 found = FALSE; 00296 ExAcquireSpinLock(&Lock->Dbg.Spin, &oldIrql); 00297 last = (Lock->Dbg.Blocks); 00298 current = last; 00299 00300 KeQueryTickCount((&ticks)); 00301 00302 while (NULL != current) { 00303 00304 if (Lock->Dbg.MaxLockedTicks) { 00305 difference = ticks.QuadPart - current->TimeLocked.QuadPart; 00306 00307 if (Lock->Dbg.MaxLockedTicks < difference) { 00308 00309 KdPrint(("IoReleaseRemoveLock: Lock %#08lx (tag %#08lx) " 00310 "locked for %I64d ticks - TOO LONG\n", 00311 Lock, 00312 current->Tag, 00313 difference)); 00314 00315 KdPrint(("IoReleaseRemoveLock: Lock acquired in file " 00316 "%s on line %d\n", 00317 current->File, 00318 current->Line)); 00319 ASSERT(FALSE); 00320 } 00321 } 00322 00323 if ((!found) && (current->Tag == Tag)) { 00324 found = TRUE; 00325 if (current == Lock->Dbg.Blocks) { 00326 Lock->Dbg.Blocks = current->Link; 00327 ExFreePool (current); 00328 current = Lock->Dbg.Blocks; 00329 } else { 00330 last->Link = current->Link; 00331 ExFreePool (current); 00332 current = last->Link; 00333 } 00334 continue; 00335 } 00336 00337 last = current; 00338 current = current->Link; 00339 } 00340 00341 ExReleaseSpinLock(&Lock->Dbg.Spin, oldIrql); 00342 00343 if (!found) { 00344 // 00345 // Check to see if we have any credits in our Low Memory Count. 00346 // In this fassion we can tell if we have acquired any locks without 00347 // the memory for adding tracking blocks. 00348 // 00349 if (InterlockedDecrement (& Lock->Dbg.LowMemoryCount) < 0) { 00350 // 00351 // We have just released a lock that neither had a corresponding 00352 // tracking block, nor a credit in LowMemoryCount. 00353 // 00354 InterlockedIncrement (& Lock->Dbg.LowMemoryCount); 00355 KdPrint (("IoReleaseRemoveLock: Couldn't find Tag %#08lx " 00356 "in the lock tracking list\n", 00357 Tag)); 00358 ASSERT(FALSE); 00359 } 00360 } 00361 break; 00362 00363 case FREESIZE: 00364 break; 00365 00366 default: 00367 break; 00368 } 00369 00370 lockValue = InterlockedDecrement(&Lock->Common.IoCount); 00371 00372 ASSERT(0 <= lockValue); 00373 00374 if (0 == lockValue) { 00375 00376 ASSERT (Lock->Common.Removed); 00377 00378 // 00379 // The device needs to be removed. Signal the remove event 00380 // that it's safe to go ahead. 00381 // 00382 00383 KeSetEvent(&Lock->Common.RemoveEvent, 00384 IO_NO_INCREMENT, 00385 FALSE); 00386 } 00387 return; 00388 }

NTKERNELAPI VOID IoReleaseVpbSpinLock IN KIRQL  Irql  ) 
 

Definition at line 9644 of file iosubs.c.

References IopVpbSpinLock.

Referenced by IopLockMountedDeviceForRemove(), IopUnlockMountedDeviceForRemove(), UdfCheckForDismount(), UdfDismountVcb(), and UdfInvalidateVolumes().

09650 : 09651 09652 This routine is invoked to release the Volume Parameter Block (VPB) spin 09653 lock. This spin lock must be acquired before accessing the mount flag, 09654 reference count, and device object fields of a VPB. 09655 09656 Arguments: 09657 09658 Irql - Supplies the IRQL value returned from acquiring the spin lock. 09659 09660 Return Value: 09661 09662 None. 09663 09664 --*/ 09665 09666 { 09667 // 09668 // Simply release the VPB spin lock. 09669 // 09670 09671 ExReleaseSpinLock( &IopVpbSpinLock, Irql ); 09672 }

NTKERNELAPI VOID IoRemoveShareAccess IN PFILE_OBJECT  FileObject,
IN OUT PSHARE_ACCESS  ShareAccess
 

Definition at line 9675 of file iosubs.c.

References PAGED_CODE.

Referenced by UdfCommonCleanup().

09682 : 09683 09684 This routine is invoked to remove the access and share access information 09685 in a file system Share Access structure for a given open instance. 09686 09687 Arguments: 09688 09689 FileObject - Pointer to the file object of the current access being closed. 09690 09691 ShareAccess - Pointer to the share access structure that describes 09692 how the file is currently being accessed. 09693 09694 Return Value: 09695 09696 None. 09697 09698 --*/ 09699 09700 { 09701 PAGED_CODE(); 09702 09703 // 09704 // If this accessor wanted some type of access other than READ_ or 09705 // WRITE_ATTRIBUTES, then account for the fact that he has closed the 09706 // file. Otherwise, he hasn't been accounted for in the first place 09707 // so don't do anything. 09708 // 09709 09710 if (FileObject->ReadAccess || 09711 FileObject->WriteAccess || 09712 FileObject->DeleteAccess) { 09713 09714 // 09715 // Decrement the number of opens in the Share Access structure. 09716 // 09717 09718 ShareAccess->OpenCount--; 09719 09720 // 09721 // For each access type, decrement the appropriate count in the Share 09722 // Access structure. 09723 // 09724 09725 if (FileObject->ReadAccess) { 09726 ShareAccess->Readers--; 09727 } 09728 09729 if (FileObject->WriteAccess) { 09730 ShareAccess->Writers--; 09731 } 09732 09733 if (FileObject->DeleteAccess) { 09734 ShareAccess->Deleters--; 09735 } 09736 09737 // 09738 // For each shared access type, decrement the appropriate count in the 09739 // Share Access structure. 09740 // 09741 09742 if (FileObject->SharedRead) { 09743 ShareAccess->SharedRead--; 09744 } 09745 09746 if (FileObject->SharedWrite) { 09747 ShareAccess->SharedWrite--; 09748 } 09749 09750 if (FileObject->SharedDelete) { 09751 ShareAccess->SharedDelete--; 09752 } 09753 } 09754 }

NTKERNELAPI NTSTATUS IoReportHalResourceUsage IN PUNICODE_STRING  HalName,
IN PCM_RESOURCE_LIST  RawResourceList,
IN PCM_RESOURCE_LIST  TranslatedResourceList,
IN ULONG  ResourceListSize
 

Definition at line 193 of file report.c.

References CmRegistryMachineHardwareResourceMapName, ExAllocatePool, IopInitHalResources, IopOpenRegistryKey(), IopWriteResourceList(), IopWstrHal, IopWstrRaw, IopWstrTranslated, NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, PagedPool, RtlInitUnicodeString(), and TRUE.

00202 : 00203 00204 This routine is called by the HAL to report its resources. 00205 The Hal is the first component to report its resources, so we don't need 00206 to acquire the resourcemap semaphore, and we do not need to check for 00207 conflicts. 00208 00209 Arguments: 00210 00211 HalName - Name of the HAL reporting the resources. 00212 00213 RawResourceList - Pointer to the HAL's raw resource list. 00214 00215 TranslatedResourceList - Pointer to the HAL's translated resource list. 00216 00217 DriverListSize - Value determining the size of the HAL's resource list. 00218 00219 Return Value: 00220 00221 The status returned is the final completion status of the operation. 00222 00223 --*/ 00224 00225 { 00226 HANDLE keyHandle; 00227 UNICODE_STRING halString; 00228 UNICODE_STRING listString; 00229 NTSTATUS status; 00230 00231 PAGED_CODE(); 00232 00233 // 00234 // First open a handle to the RESOURCEMAP key. 00235 // 00236 00237 RtlInitUnicodeString( &halString, IopWstrHal ); 00238 00239 status = IopOpenRegistryKey( &keyHandle, 00240 (HANDLE) NULL, 00241 &CmRegistryMachineHardwareResourceMapName, 00242 KEY_READ | KEY_WRITE, 00243 TRUE ); 00244 00245 // 00246 // Write out the raw resource list 00247 // 00248 00249 if (NT_SUCCESS( status )) { 00250 00251 RtlInitUnicodeString( &listString, IopWstrRaw); 00252 00253 status = IopWriteResourceList( keyHandle, 00254 &halString, 00255 HalName, 00256 &listString, 00257 RawResourceList, 00258 ResourceListSize ); 00259 00260 // 00261 // If we successfully wrote out the raw resource list, write out 00262 // the translated resource list. 00263 // 00264 00265 if (NT_SUCCESS( status )) { 00266 00267 RtlInitUnicodeString( &listString, IopWstrTranslated); 00268 status = IopWriteResourceList( keyHandle, 00269 &halString, 00270 HalName, 00271 &listString, 00272 TranslatedResourceList, 00273 ResourceListSize ); 00274 00275 } 00276 ZwClose( keyHandle ); 00277 } 00278 00279 // 00280 // If every looks fine, we will make a copy of the Hal resources so will 00281 // can call Arbiters to reserve the resources after they initialized. 00282 // 00283 00284 if (NT_SUCCESS(status)) { 00285 IopInitHalResources = (PCM_RESOURCE_LIST) ExAllocatePool(PagedPool, ResourceListSize); 00286 if (IopInitHalResources) { 00287 RtlMoveMemory(IopInitHalResources, RawResourceList, ResourceListSize); 00288 } else { 00289 status = STATUS_INSUFFICIENT_RESOURCES; 00290 } 00291 } 00292 00293 return status; 00294 }

NTKERNELAPI NTSTATUS IoReportResourceUsage IN PUNICODE_STRING DriverClassName  OPTIONAL,
IN PDRIVER_OBJECT  DriverObject,
IN PCM_RESOURCE_LIST DriverList  OPTIONAL,
IN ULONG DriverListSize  OPTIONAL,
IN PDEVICE_OBJECT  DeviceObject,
IN PCM_RESOURCE_LIST DeviceList  OPTIONAL,
IN ULONG DeviceListSize  OPTIONAL,
IN BOOLEAN  OverrideConflict,
OUT PBOOLEAN  ConflictDetected
 

Definition at line 379 of file report.c.

References ArbiterRequestLegacyReported, DNF_LEGACY_RESOURCE_DEVICENODE, IoReportResourceUsageInternal(), KeBugCheckEx(), and PNP_ERR_INVALID_PDO.

Referenced by DriverEntry().

00393 : 00394 00395 This routine will automatically search through the configuration 00396 registry for resource conflicts between resources requested by a device 00397 and the resources already claimed by previously installed drivers. The 00398 contents of the DriverList and the DeviceList will be matched against 00399 all the other resource list stored in the registry to determine 00400 conflicts. 00401 00402 If not conflict was detected, or if the OverrideConflict flag is set, 00403 this routine will create appropriate entries in the system resource map 00404 (in the registry) that will contain the specified resource lists. 00405 00406 The function may be called more than once for a given device or driver. 00407 If a new resource list is given, the previous resource list stored in 00408 the registry will be replaced by the new list. 00409 00410 Arguments: 00411 00412 DriverClassName - Optional pointer to a UNICODE_STRING which describes 00413 the class of driver under which the driver information should be 00414 stored. A default type is used if none is given. 00415 00416 DriverObject - Pointer to the driver's driver object. 00417 00418 DriverList - Optional pointer to the driver's resource list. 00419 00420 DriverListSize - Optional value determining the size of the driver's 00421 resource list. 00422 00423 DeviceObject - Optional pointer to driver's device object. 00424 00425 DeviceList - Optional pointer to the device's resource list. 00426 00427 DriverListSize - Optional value determining the size of the driver's 00428 resource list. 00429 00430 OverrideConflict - Determines if the information should be reported 00431 in the configuration registry eventhough a conflict was found with 00432 another driver or device. 00433 00434 ConflictDetected - Supplies a pointer to a boolean that is set to TRUE 00435 if the resource list conflicts with an already existing resource 00436 list in the configuration registry. 00437 00438 Return Value: 00439 00440 The status returned is the final completion status of the operation. 00441 00442 --*/ 00443 00444 { 00445 if (DeviceObject) { 00446 00447 if ( DeviceObject->DeviceObjectExtension->DeviceNode && 00448 !(((PDEVICE_NODE)DeviceObject->DeviceObjectExtension->DeviceNode)->Flags & DNF_LEGACY_RESOURCE_DEVICENODE)) { 00449 00450 KeBugCheckEx(PNP_DETECTED_FATAL_ERROR, PNP_ERR_INVALID_PDO, (ULONG_PTR)DeviceObject, 0, 0); 00451 00452 } 00453 00454 } 00455 00456 return IoReportResourceUsageInternal( ArbiterRequestLegacyReported, 00457 DriverClassName, 00458 DriverObject, 00459 DriverList, 00460 DriverListSize, 00461 DeviceObject, 00462 DeviceList, 00463 DeviceListSize, 00464 OverrideConflict, 00465 ConflictDetected); 00466 }

VOID IoRetryIrpCompletions VOID   ) 
 

Definition at line 12782 of file iosubs.c.

References APC_LEVEL, ASSERT, _IRP::Flags, IopCompleteRequest(), IRP_CREATE_OPERATION, IRP_RETRY_IO_COMPLETION, _ETHREAD::IrpList, NULL, PsGetCurrentThread, and _IRP::Tail.

Referenced by MmAccessFault(), and MmCopyToCachedPage().

12787 : 12788 12789 This routine is called from Mm when a page fault has completed. It's 12790 called on the special occasion when a thread faults a page and then when 12791 it's waiting for the inpage to complete, an IopCompleteRequest APC fires 12792 and we fault the same page again (say if the user buffer falls on the 12793 same page). Note the fault during the APC may be referencing the same or 12794 a different user virtual address but this is irrelevant - the problem lies 12795 in the fact that both virtual address references are to the same physical 12796 page and thus result in a collided fault in the Mm. 12797 12798 Mm detects this case (to avoid deadlock) and returns STATUS_FAULT_COLLISION 12799 and the I/O manager bails out the APC after marking the Irp with the flag 12800 IRP_RETRY_IO_COMPLETION. Later on when Mm has decided the fault has 12801 progressed far enough to avoid deadlock, it calls back into this routine 12802 which calls IopCompleteRequest again. The code in IopCompleteRequest is 12803 written in a reentrant way so that the retry knows the completion is only 12804 partially processed so far. We can fault in two places in IopCompleteRequest 12805 and in both cases if we call IopCompleteRequest again they will now work. 12806 12807 This call must be called in the context of the thread that is faulting. 12808 This function should be called at APC_LEVEL. 12809 12810 Arguments: 12811 12812 None. 12813 12814 Return Value: 12815 12816 None. 12817 12818 --*/ 12819 { 12820 PLIST_ENTRY header; 12821 PLIST_ENTRY entry; 12822 KIRQL irql; 12823 PETHREAD thread; 12824 PIRP irp; 12825 PVOID saveAuxiliaryPointer = NULL; 12826 PFILE_OBJECT fileObject; 12827 12828 12829 thread = PsGetCurrentThread(); 12830 12831 ASSERT(KeGetCurrentIrql() == APC_LEVEL); 12832 12833 // 12834 // Raise the IRQL so that the IrpList cannot be modified by a completion 12835 // APC. 12836 // 12837 12838 header = &thread->IrpList; 12839 entry = thread->IrpList.Flink; 12840 12841 // 12842 // Walk the list of pending IRPs, completing each of them. 12843 // 12844 12845 while (header != entry) { 12846 12847 irp = CONTAINING_RECORD( entry, IRP, ThreadListEntry ); 12848 entry = entry->Flink; 12849 12850 if (irp->Flags & IRP_RETRY_IO_COMPLETION) { 12851 12852 ASSERT(!(irp->Flags & IRP_CREATE_OPERATION)); 12853 12854 irp->Flags &= ~IRP_RETRY_IO_COMPLETION; 12855 fileObject = irp->Tail.Overlay.OriginalFileObject; 12856 IopCompleteRequest( 12857 &irp->Tail.Apc, 12858 NULL, 12859 NULL, 12860 &fileObject, 12861 &saveAuxiliaryPointer); 12862 } 12863 } 12864 } }

NTKERNELAPI VOID IoReuseIrp IN OUT PIRP  Irp,
IN NTSTATUS  Iostatus
 

NTSTATUS IoSetCrashDumpState IN SYSTEM_CRASH_STATE_INFORMATION *  dumpState  ) 
 

Definition at line 4325 of file dumpctl.c.

References FALSE, IopCrashDumpStateChange, IopFreeDCB(), NTSTATUS(), and Status.

04331 : 04332 04333 Disable the current crash dump. Optionally, configure a new crash dump. 04334 04335 Arguments: 04336 04337 pDumpState - If ValidDirectDump = TRUE enable a new dump 04338 FALSE Disable crash dump 04339 04340 Return Value: 04341 04342 STATUS_SUCCESS - The operation was successful 04343 04344 W32ERROR - Otherwise 04345 04346 --*/ 04347 { 04348 NTSTATUS Status; 04349 ULONG crashConfigurationInProgress; 04350 04351 // 04352 // Check the sentinal 04353 // 04354 04355 crashConfigurationInProgress = InterlockedExchange(&IopCrashDumpStateChange,1); 04356 04357 if (crashConfigurationInProgress) { 04358 return STATUS_SUCCESS; 04359 } 04360 04361 // 04362 // If crash dumps disabled return success 04363 // 04364 04365 if (!pDumpState->ValidDirectDump) { 04366 IopFreeDCB(FALSE); 04367 Status = STATUS_SUCCESS; 04368 } else { 04369 Status = STATUS_INVALID_DEVICE_REQUEST; 04370 } 04371 04372 InterlockedExchange(&IopCrashDumpStateChange,0); 04373 04374 return Status; 04375 }

NTKERNELAPI VOID IoSetDeviceToVerify IN PETHREAD  Thread,
IN PDEVICE_OBJECT  DeviceObject
 

Definition at line 9757 of file iosubs.c.

Referenced by UdfProcessException().

09764 : 09765 09766 This routine sets the device to verify field in the thread object. This 09767 function is invoked by file systems to NULL this field, or to set it to 09768 predefined values. 09769 09770 Arguments: 09771 09772 Thread - Pointer to the thread whose field is to be set. 09773 09774 DeviceObject - Pointer to the device to be verified, or NULL, or ... 09775 09776 Return Value: 09777 09778 None. 09779 09780 Note: 09781 09782 This function cannot be made a macro, since fields in the thread object 09783 move from release to release, so this must remain a full function. 09784 09785 --*/ 09786 09787 { 09788 // 09789 // Simply set the device to be verified in the specified thread. 09790 // 09791 09792 Thread->DeviceToVerify = DeviceObject; 09793 }

NTKERNELAPI NTSTATUS IoSetDumpRange IN PVOID  DumpContext,
IN PVOID  StartVA,
IN ULONG_PTR  Pages,
IN BOOLEAN  IsPhysicalAddress
 

Definition at line 2291 of file dumpctl.c.

References ASSERT, FALSE, IopAddPageToPageMap(), MmGetPhysicalAddress(), MmIsAddressValid(), PAGE_SHIFT, PAGE_SIZE, and TRUE.

Referenced by IopCreateSummaryDump(), and MmSetKernelDumpRange().

02300 : 02301 02302 This routine includes this range of memory in the dump 02303 02304 Arguments: 02305 02306 DumpContext - dump context 02307 02308 StartVa - Starting VA 02309 02310 Pages - The number of pages to include 02311 02312 IsPhysicalAddress - true if direct physical address translation 02313 02314 Return Value: 02315 02316 STATUS_SUCCESS - On success. 02317 02318 NTSTATUS - Error. 02319 02320 --*/ 02321 { 02322 PCHAR Va; 02323 PRTL_BITMAP pBitMapHeader; 02324 PHYSICAL_ADDRESS phyAddr; 02325 PSUMMARY_DUMP_HEADER pHeader; 02326 BOOLEAN AllPagesSet; 02327 02328 02329 Va = StartVa; 02330 pHeader = (PSUMMARY_DUMP_HEADER) DumpContext; 02331 pBitMapHeader = (PRTL_BITMAP)(pHeader + 1); 02332 AllPagesSet = TRUE; 02333 02334 // 02335 // Win64 can have really large page addresses. This dump code does 02336 // not handle that yet. Note that before this assert is removed 02337 // the casts of Pages to ULONG must be removed. 02338 // 02339 02340 ASSERT(Pages <= MAXULONG); 02341 02342 // 02343 // IsPhysicalAddress indicates that the va is virtually / physically 02344 // contiguous. 02345 // 02346 02347 if (IsPhysicalAddress) { 02348 02349 phyAddr = MmGetPhysicalAddress (Va); 02350 IopAddPageToPageMap (pHeader->BitmapSize, 02351 pBitMapHeader, 02352 (ULONG)(phyAddr.QuadPart >> PAGE_SHIFT), 02353 (ULONG) Pages 02354 ); 02355 02356 } else { 02357 02358 // 02359 // Not physically contiguous. 02360 // 02361 02362 while (Pages) { 02363 02364 // 02365 // Only do a translation for valid pages. 02366 // 02367 02368 if ( MmIsAddressValid(Va) ) { 02369 02370 // 02371 // Get the physical mapping. Note: this does not require a lock 02372 // 02373 02374 phyAddr = MmGetPhysicalAddress (Va); 02375 02376 IopAddPageToPageMap (pHeader->BitmapSize, 02377 pBitMapHeader, 02378 (ULONG)(phyAddr.QuadPart >> PAGE_SHIFT), 02379 1); 02380 02381 if (phyAddr.QuadPart >> PAGE_SHIFT > pHeader->BitmapSize) { 02382 AllPagesSet = FALSE; 02383 } 02384 } 02385 02386 Va += PAGE_SIZE; 02387 Pages--; 02388 } 02389 } 02390 02391 if (AllPagesSet) { 02392 return STATUS_SUCCESS; 02393 } 02394 02395 return STATUS_INVALID_ADDRESS; 02396 }

NTKERNELAPI VOID IoSetHardErrorOrVerifyDevice IN PIRP  Irp,
IN PDEVICE_OBJECT  DeviceObject
 

Definition at line 9796 of file iosubs.c.

References ASSERT, Irp, NULL, and _IRP::Tail.

Referenced by UdfPerformVerify(), UdfVerifyFcbOperation(), and UdfVerifyVcb().

09803 : 09804 09805 This routine is invoked when a driver realizes that the media 09806 has possibly changed on a device, and it must be verified before 09807 continuing, or a hard error has occured. The device is stored 09808 in the thread local storage of the Irp's originating thread. 09809 09810 Arguments: 09811 09812 Irp - Pointer to an I/O Request Packet to get the thread. 09813 09814 DeviceObject - This is the device that needs to be verified. 09815 09816 Return Value: 09817 09818 None. 09819 09820 --*/ 09821 09822 { 09823 // 09824 // Store the address of the device object that needs verification in 09825 // the appropriate field of the thread pointed to by the specified I/O 09826 // Request Packet. 09827 // 09828 09829 ASSERT( Irp->Tail.Overlay.Thread != NULL ); 09830 09831 Irp->Tail.Overlay.Thread->DeviceToVerify = DeviceObject; 09832 }

NTKERNELAPI NTSTATUS IoSetInformation IN PFILE_OBJECT  FileObject,
IN FILE_INFORMATION_CLASS  FileInformationClass,
IN ULONG  Length,
IN PVOID  FileInformation
 

Definition at line 9835 of file iosubs.c.

References _IRP::AssociatedIrp, Executive, FALSE, _IO_STACK_LOCATION::FileObject, _IRP::Flags, FO_ALERTABLE_IO, FO_NO_INTERMEDIATE_BUFFERING, FO_SEQUENTIAL_ONLY, FO_SYNCHRONOUS_IO, FO_WRITE_THROUGH, IoAllocateIrp(), IoCallDriver, IoCompleteRequest, IoGetNextIrpStackLocation, IoGetRelatedDeviceObject(), IopAcquireFastLock, IopAcquireFileObjectLock(), IopAllocateIrpCleanup(), IopCancelAlertedRequest(), IopOpenLinkOrRenameTarget(), IopQueueThreadIrp, IopReleaseFileObjectLock, IoSetNextIrpStackLocation, _IRP::IoStatus, IRP_BUFFERED_IO, IRP_MJ_SET_INFORMATION, IRP_SYNCHRONOUS_API, KeClearEvent, KeInitializeEvent, KernelMode, KeWaitForSingleObject(), _IO_STACK_LOCATION::MajorFunction, NT_SUCCESS, NtClose(), NTSTATUS(), NULL, ObDereferenceObject, ObReferenceObject, PAGED_CODE, _IO_STACK_LOCATION::Parameters, PsGetCurrentThread, _IRP::RequestorMode, _DEVICE_OBJECT::StackSize, _IRP::Tail, TRUE, _IRP::UserEvent, _IRP::UserIosb, and VOID().

Referenced by MiAttemptPageFileExtension(), and MiAttemptPageFileReduction().

09844 : 09845 09846 This routine sets the requested information for the specified file. 09847 The information that is set is determined by the FileInformationClass 09848 paramter, and the information itself is passed in the FileInformation 09849 buffer. 09850 09851 Arguments: 09852 09853 FileObject - Supplies a pointer to the file object for the file that 09854 is to be changed. 09855 09856 FileInformationClass - Specifies the type of information that should 09857 be set on the file. 09858 09859 Length - Supplies the length of the FileInformation buffer in bytes. 09860 09861 FileInformation - A buffer containing the file information to set. This 09862 buffer must not be pageable and must reside in system space. 09863 09864 Return Value: 09865 09866 The status returned is the final completion status of the operation. 09867 09868 09869 --*/ 09870 09871 { 09872 PIRP irp; 09873 NTSTATUS status; 09874 PDEVICE_OBJECT deviceObject; 09875 KEVENT event; 09876 PIO_STACK_LOCATION irpSp; 09877 IO_STATUS_BLOCK localIoStatus; 09878 HANDLE targetHandle = NULL; 09879 BOOLEAN synchronousIo; 09880 09881 PAGED_CODE(); 09882 09883 // 09884 // Reference the file object here so that no special checks need be made 09885 // in I/O completion to determine whether or not to dereference the file 09886 // object. 09887 // 09888 09889 ObReferenceObject( FileObject ); 09890 09891 // 09892 // Make a special check here to determine whether this is a synchronous 09893 // I/O operation. If it is, then wait here until the file is owned by 09894 // the current thread. If this is not a (serialized) synchronous I/O 09895 // operation, then initialize the local event. 09896 // 09897 09898 if (FileObject->Flags & FO_SYNCHRONOUS_IO) { 09899 09900 BOOLEAN interrupted; 09901 09902 if (!IopAcquireFastLock( FileObject )) { 09903 status = IopAcquireFileObjectLock( FileObject, 09904 KernelMode, 09905 (BOOLEAN) ((FileObject->Flags & FO_ALERTABLE_IO) != 0), 09906 &interrupted ); 09907 if (interrupted) { 09908 ObDereferenceObject( FileObject ); 09909 return status; 09910 } 09911 } 09912 KeClearEvent( &FileObject->Event ); 09913 synchronousIo = TRUE; 09914 } else { 09915 KeInitializeEvent( &event, SynchronizationEvent, FALSE ); 09916 synchronousIo = FALSE; 09917 } 09918 09919 // 09920 // Get the address of the target device object. 09921 // 09922 09923 deviceObject = IoGetRelatedDeviceObject( FileObject ); 09924 09925 // 09926 // Allocate and initialize the I/O Request Packet (IRP) for this operation. 09927 // The allocation is performed with an exception handler in case there is 09928 // not enough memory to satisfy the request. 09929 // 09930 09931 irp = IoAllocateIrp( deviceObject->StackSize, TRUE ); 09932 if (!irp) { 09933 09934 // 09935 // An IRP could not be allocated. Cleanup and return an appropriate 09936 // error status code. 09937 // 09938 09939 IopAllocateIrpCleanup( FileObject, (PKEVENT) NULL ); 09940 09941 return STATUS_INSUFFICIENT_RESOURCES; 09942 } 09943 irp->Tail.Overlay.OriginalFileObject = FileObject; 09944 irp->Tail.Overlay.Thread = PsGetCurrentThread(); 09945 irp->RequestorMode = KernelMode; 09946 09947 // 09948 // Fill in the service independent parameters in the IRP. 09949 // 09950 09951 if (synchronousIo) { 09952 irp->UserEvent = (PKEVENT) NULL; 09953 } else { 09954 irp->UserEvent = &event; 09955 irp->Flags = IRP_SYNCHRONOUS_API; 09956 } 09957 irp->UserIosb = &localIoStatus; 09958 09959 // 09960 // Get a pointer to the stack location for the first driver. This will be 09961 // used to pass the original function codes and parameters. 09962 // 09963 09964 irpSp = IoGetNextIrpStackLocation( irp ); 09965 irpSp->MajorFunction = IRP_MJ_SET_INFORMATION; 09966 irpSp->FileObject = FileObject; 09967 09968 // 09969 // Set the system buffer address to the address of the caller's buffer and 09970 // set the flags so that the buffer is not deallocated. 09971 // 09972 09973 irp->AssociatedIrp.SystemBuffer = FileInformation; 09974 irp->Flags |= IRP_BUFFERED_IO; 09975 09976 // 09977 // Copy the caller's parameters to the service-specific portion of the IRP. 09978 // 09979 09980 irpSp->Parameters.SetFile.Length = Length; 09981 irpSp->Parameters.SetFile.FileInformationClass = FileInformationClass; 09982 09983 // 09984 // Insert the packet at the head of the IRP list for the thread. 09985 // 09986 09987 IopQueueThreadIrp( irp ); 09988 09989 // 09990 // Everything is now set to invoke the device driver with this request. 09991 // However, it is possible that the information that the caller wants to 09992 // set is device independent (I/O system dependent). If this is the case, 09993 // then the request can be satisfied here without having to have all of 09994 // the drivers implement the same code. Note that having the IRP is still 09995 // necessary since the I/O completion code requires it. 09996 // 09997 09998 if (FileInformationClass == FileModeInformation) { 09999 10000 PFILE_MODE_INFORMATION modeBuffer = FileInformation; 10001 10002 // 10003 // Set or clear the appropriate flags in the file object. 10004 // 10005 10006 if (!(FileObject->Flags & FO_NO_INTERMEDIATE_BUFFERING)) { 10007 if (modeBuffer->Mode & FILE_WRITE_THROUGH) { 10008 FileObject->Flags |= FO_WRITE_THROUGH; 10009 } else { 10010 FileObject->Flags &= ~FO_WRITE_THROUGH; 10011 } 10012 } 10013 10014 if (modeBuffer->Mode & FILE_SEQUENTIAL_ONLY) { 10015 FileObject->Flags |= FO_SEQUENTIAL_ONLY; 10016 } else { 10017 FileObject->Flags &= ~FO_SEQUENTIAL_ONLY; 10018 } 10019 10020 if (modeBuffer->Mode & FO_SYNCHRONOUS_IO) { 10021 if (modeBuffer->Mode & FILE_SYNCHRONOUS_IO_ALERT) { 10022 FileObject->Flags |= FO_ALERTABLE_IO; 10023 } else { 10024 FileObject->Flags &= ~FO_ALERTABLE_IO; 10025 } 10026 } 10027 10028 status = STATUS_SUCCESS; 10029 10030 // 10031 // Complete the I/O operation. 10032 // 10033 10034 irp->IoStatus.Status = status; 10035 irp->IoStatus.Information = 0; 10036 10037 IoSetNextIrpStackLocation( irp ); 10038 IoCompleteRequest( irp, 0 ); 10039 10040 } else if (FileInformationClass == FileRenameInformation || 10041 FileInformationClass == FileLinkInformation || 10042 FileInformationClass == FileMoveClusterInformation) { 10043 10044 // 10045 // Note that the following code assumes that a rename information 10046 // and a set link information structure look exactly the same. 10047 // 10048 10049 PFILE_RENAME_INFORMATION renameBuffer = FileInformation; 10050 10051 // 10052 // Copy the value of the replace BOOLEAN (or the ClusterCount field) 10053 // from the caller's buffer to the I/O stack location parameter 10054 // field where it is expected by file systems. 10055 // 10056 10057 if (FileInformationClass == FileMoveClusterInformation) { 10058 irpSp->Parameters.SetFile.ClusterCount = 10059 ((FILE_MOVE_CLUSTER_INFORMATION *) renameBuffer)->ClusterCount; 10060 } else { 10061 irpSp->Parameters.SetFile.ReplaceIfExists = renameBuffer->ReplaceIfExists; 10062 } 10063 10064 // 10065 // Check to see whether or not a fully qualified pathname was supplied. 10066 // If so, then more processing is required. 10067 // 10068 10069 if (renameBuffer->FileName[0] == (UCHAR) OBJ_NAME_PATH_SEPARATOR || 10070 renameBuffer->RootDirectory != NULL) { 10071 10072 // 10073 // A fully qualified file name was specified as the target of the 10074 // rename operation. Attempt to open the target file and ensure 10075 // that the replacement policy for the file is consistent with the 10076 // caller's request, and ensure that the file is on the same volume. 10077 // 10078 10079 status = IopOpenLinkOrRenameTarget( &targetHandle, 10080 irp, 10081 renameBuffer, 10082 FileObject ); 10083 if (!NT_SUCCESS( status )) { 10084 IoSetNextIrpStackLocation( irp ); 10085 IoCompleteRequest( irp, 2 ); 10086 10087 } else { 10088 10089 // 10090 // The fully qualified file name specifies a file on the same 10091 // volume and if it exists, then the caller specified that it 10092 // should be replaced. 10093 // 10094 10095 status = IoCallDriver( deviceObject, irp ); 10096 10097 } 10098 10099 } else { 10100 10101 // 10102 // This is a simple rename operation, so call the driver and let 10103 // it perform the rename operation within the same directory as 10104 // the source file. 10105 // 10106 10107 status = IoCallDriver( deviceObject, irp ); 10108 10109 } 10110 10111 } else { 10112 10113 // 10114 // This is not a request that can be performed here, so invoke the 10115 // driver at its appropriate dispatch entry with the IRP. 10116 // 10117 10118 status = IoCallDriver( deviceObject, irp ); 10119 10120 } 10121 10122 // 10123 // If this operation was a synchronous I/O operation, check the return 10124 // status to determine whether or not to wait on the file object. If 10125 // the file object is to be waited on, wait for the operation to complete 10126 // and obtain the final status from the file object itself. 10127 // 10128 10129 if (synchronousIo) { 10130 if (status == STATUS_PENDING) { 10131 status = KeWaitForSingleObject( &FileObject->Event, 10132 Executive, 10133 KernelMode, 10134 (BOOLEAN) ((FileObject->Flags & FO_ALERTABLE_IO) != 0), 10135 (PLARGE_INTEGER) NULL ); 10136 if (status == STATUS_ALERTED) { 10137 IopCancelAlertedRequest( &FileObject->Event, irp ); 10138 } 10139 status = localIoStatus.Status; 10140 } 10141 IopReleaseFileObjectLock( FileObject ); 10142 10143 } else { 10144 10145 // 10146 // This is a normal synchronous I/O operation, as opposed to a 10147 // serialized synchronous I/O operation. For this case, wait for 10148 // the local event and copy the final status information back to 10149 // the caller. 10150 // 10151 10152 if (status == STATUS_PENDING) { 10153 (VOID) KeWaitForSingleObject( &event, 10154 Executive, 10155 KernelMode, 10156 FALSE, 10157 (PLARGE_INTEGER) NULL ); 10158 status = localIoStatus.Status; 10159 } 10160 } 10161 10162 // 10163 // If a target handle was created because of a rename operation, close 10164 // the handle now. 10165 // 10166 10167 if (targetHandle != (HANDLE) NULL) { 10168 NtClose( targetHandle ); 10169 } 10170 10171 return status; 10172 }

NTKERNELAPI NTSTATUS IoSetIoCompletion IN PVOID  IoCompletion,
IN PVOID  KeyContext,
IN PVOID  ApcContext,
IN NTSTATUS  IoStatus,
IN ULONG_PTR  IoStatusInformation,
IN BOOLEAN  Quota
 

Definition at line 671 of file complete.c.

References _GENERAL_LOOKASIDE::AllocateMisses, _IOP_MINI_COMPLETION_PACKET::ApcContext, ExAllocatePoolWithQuotaTag, ExAllocatePoolWithTag, EXCEPTION_EXECUTE_HANDLER, ExInterlockedPopEntrySList(), FALSE, IopCompletionPacketMini, IopCompletionPacketQuota, _IOP_MINI_COMPLETION_PACKET::IoStatus, _IOP_MINI_COMPLETION_PACKET::IoStatusInformation, KeGetCurrentPrcb, KeInsertQueue(), _IOP_MINI_COMPLETION_PACKET::KeyContext, _NPAGED_LOOKASIDE_LIST::L, _IOP_MINI_COMPLETION_PACKET::ListEntry, _GENERAL_LOOKASIDE::ListHead, _NPAGED_LOOKASIDE_LIST::Lock, LookasideCompletionList, NonPagedPool, NTSTATUS(), NULL, _IOP_MINI_COMPLETION_PACKET::PacketType, PAGED_CODE, PNPAGED_LOOKASIDE_LIST, Status, and _GENERAL_LOOKASIDE::TotalAllocates.

Referenced by IopXxxControlFile(), NtLockFile(), NtSetInformationJobObject(), NtSetIoCompletion(), PsChangeJobMemoryUsage(), PsEnforceExecutionTimeLimits(), PspAddProcessToJob(), PspCreateThread(), PspExitProcess(), PspFoldProcessAccountingIntoJob(), and PsReportProcessMemoryLimitViolation().

00681 : 00682 00683 This function allows the caller to queue an Irp to an I/O completion 00684 port and specify all of the information that is returned out the other 00685 end using NtRemoveIoCompletion. 00686 00687 Arguments: 00688 00689 IoCompletion - Supplies a a pointer to the completion port that the caller 00690 intends to queue a completion packet to. 00691 00692 KeyContext - Supplies the key context that is returned during a call 00693 to NtRemoveIoCompletion. 00694 00695 ApcContext - Supplies the apc context that is returned during a call 00696 to NtRemoveIoCompletion. 00697 00698 IoStatus - Supplies the IoStatus->Status data that is returned during 00699 a call to NtRemoveIoCompletion. 00700 00701 IoStatusInformation - Supplies the IoStatus->Information data that 00702 is returned during a call to NtRemoveIoCompletion. 00703 00704 Return Value: 00705 00706 STATUS_SUCCESS is returned if the function is success. Otherwise, an 00707 error status is returned. 00708 00709 --*/ 00710 00711 { 00712 00713 PNPAGED_LOOKASIDE_LIST Lookaside; 00714 PIOP_MINI_COMPLETION_PACKET MiniPacket; 00715 ULONG PacketType; 00716 PKPRCB Prcb; 00717 NTSTATUS Status = STATUS_SUCCESS; 00718 00719 PAGED_CODE(); 00720 00721 // 00722 // Attempt to allocate the minpacket from the per processor lookaside list. 00723 // 00724 00725 PacketType = IopCompletionPacketMini; 00726 Prcb = KeGetCurrentPrcb(); 00727 Lookaside = Prcb->PPLookasideList[LookasideCompletionList].P; 00728 Lookaside->L.TotalAllocates += 1; 00729 MiniPacket = (PVOID)ExInterlockedPopEntrySList(&Lookaside->L.ListHead, 00730 &Lookaside->Lock); 00731 00732 // 00733 // If the per processor lookaside list allocation failed, then attempt to 00734 // allocate from the system lookaside list. 00735 // 00736 00737 if (MiniPacket == NULL) { 00738 Lookaside->L.AllocateMisses += 1; 00739 Lookaside = Prcb->PPLookasideList[LookasideCompletionList].L; 00740 Lookaside->L.TotalAllocates += 1; 00741 MiniPacket = (PVOID)ExInterlockedPopEntrySList(&Lookaside->L.ListHead, 00742 &Lookaside->Lock); 00743 } 00744 00745 // 00746 // If both lookaside allocation attempts failed, then attempt to allocate 00747 // from pool. 00748 // 00749 00750 if (MiniPacket == NULL) { 00751 Lookaside->L.AllocateMisses += 1; 00752 00753 // 00754 // If quota is specified, then allocate pool with quota charged. 00755 // Otherwise, allocate pool without quota. 00756 // 00757 00758 if (Quota != FALSE) { 00759 PacketType = IopCompletionPacketQuota; 00760 try { 00761 MiniPacket = ExAllocatePoolWithQuotaTag(NonPagedPool, 00762 sizeof(*MiniPacket), 00763 ' pcI'); 00764 00765 } except(EXCEPTION_EXECUTE_HANDLER) { 00766 NOTHING; 00767 } 00768 00769 } else { 00770 MiniPacket = ExAllocatePoolWithTag(NonPagedPool, 00771 sizeof(*MiniPacket), 00772 ' pcI'); 00773 } 00774 } 00775 00776 // 00777 // If a minipacket was successfully allocated, then initialize and 00778 // queue the packet to the specified I/O completion queue. 00779 // 00780 00781 if (MiniPacket != NULL) { 00782 MiniPacket->PacketType = PacketType; 00783 MiniPacket->KeyContext = KeyContext; 00784 MiniPacket->ApcContext = ApcContext; 00785 MiniPacket->IoStatus = IoStatus; 00786 MiniPacket->IoStatusInformation = IoStatusInformation; 00787 KeInsertQueue((PKQUEUE)IoCompletion, &MiniPacket->ListEntry); 00788 00789 } else { 00790 Status = STATUS_INSUFFICIENT_RESOURCES; 00791 } 00792 00793 return Status; 00794 }

NTKERNELAPI VOID IoSetShareAccess IN ACCESS_MASK  DesiredAccess,
IN ULONG  DesiredShareAccess,
IN OUT PFILE_OBJECT  FileObject,
OUT PSHARE_ACCESS  ShareAccess
 

Definition at line 10175 of file iosubs.c.

References PAGED_CODE.

Referenced by UdfCompleteFcbOpen().

10184 : 10185 10186 This routine is invoked to set the access and share access information 10187 in a file system Share Access structure for the first open. 10188 10189 Arguments: 10190 10191 DesiredAccess - Desired access of current open request. 10192 10193 DesiredShareAccess - Shared access requested by current open request. 10194 10195 FileObject - Pointer to the file object of the current open request. 10196 10197 ShareAccess - Pointer to the share access structure that describes 10198 how the file is currently being accessed. 10199 10200 Return Value: 10201 10202 None. 10203 10204 --*/ 10205 10206 { 10207 PAGED_CODE(); 10208 10209 // 10210 // Set the access type in the file object for the current accessor. 10211 // 10212 10213 FileObject->ReadAccess = (BOOLEAN) ((DesiredAccess & (FILE_EXECUTE 10214 | FILE_READ_DATA)) != 0); 10215 FileObject->WriteAccess = (BOOLEAN) ((DesiredAccess & (FILE_WRITE_DATA 10216 | FILE_APPEND_DATA)) != 0); 10217 FileObject->DeleteAccess = (BOOLEAN) ((DesiredAccess & DELETE) != 0); 10218 10219 // 10220 // Check to see whether the current file opener would like to read, 10221 // write, or delete the file. If so, account for it in the share access 10222 // structure; otherwise, skip it. 10223 // 10224 10225 if (FileObject->ReadAccess || 10226 FileObject->WriteAccess || 10227 FileObject->DeleteAccess) { 10228 10229 // 10230 // Only update the share modes if the user wants to read, write or 10231 // delete the file. 10232 // 10233 10234 FileObject->SharedRead = (BOOLEAN) ((DesiredShareAccess & FILE_SHARE_READ) != 0); 10235 FileObject->SharedWrite = (BOOLEAN) ((DesiredShareAccess & FILE_SHARE_WRITE) != 0); 10236 FileObject->SharedDelete = (BOOLEAN) ((DesiredShareAccess & FILE_SHARE_DELETE) != 0); 10237 10238 // 10239 // Set the Share Access structure open count. 10240 // 10241 10242 ShareAccess->OpenCount = 1; 10243 10244 // 10245 // Set the number of readers, writers, and deleters in the Share Access 10246 // structure. 10247 // 10248 10249 ShareAccess->Readers = FileObject->ReadAccess; 10250 ShareAccess->Writers = FileObject->WriteAccess; 10251 ShareAccess->Deleters = FileObject->DeleteAccess; 10252 10253 // 10254 // Set the number of shared readers, writers, and deleters in the Share 10255 // Access structure. 10256 // 10257 10258 ShareAccess->SharedRead = FileObject->SharedRead; 10259 ShareAccess->SharedWrite = FileObject->SharedWrite; 10260 ShareAccess->SharedDelete = FileObject->SharedDelete; 10261 10262 } else { 10263 10264 // 10265 // No read, write, or delete access has been requested. Simply zero 10266 // the appropriate fields in the structure so that the next accessor 10267 // sees a consistent state. 10268 // 10269 10270 ShareAccess->OpenCount = 0; 10271 ShareAccess->Readers = 0; 10272 ShareAccess->Writers = 0; 10273 ShareAccess->Deleters = 0; 10274 ShareAccess->SharedRead = 0; 10275 ShareAccess->SharedWrite = 0; 10276 ShareAccess->SharedDelete = 0; 10277 } 10278 }

NTKERNELAPI BOOLEAN IoSetThreadHardErrorMode IN BOOLEAN  EnableHardErrors  ) 
 

Definition at line 10281 of file iosubs.c.

References _ETHREAD::HardErrorsAreDisabled, and PsGetCurrentThread.

Referenced by CmpDoFileSetSize(), HvSyncHive(), and ObKillProcess().

10287 : 10288 10289 This routine either enables or disables hard errors for the current 10290 thread and returns the old state of the flag. 10291 10292 Arguments: 10293 10294 EnableHardErrors - Supplies a BOOLEAN value indicating whether or not 10295 hard errors are to be enabled for the current thread. 10296 10297 Return Value: 10298 10299 The final function value is the previous state of whether or not hard 10300 errors were enabled. 10301 10302 --*/ 10303 10304 { 10305 PETHREAD thread; 10306 BOOLEAN oldFlag; 10307 10308 // 10309 // Get a pointer to the current thread, capture the current state of 10310 // hard errors, and set the new state. 10311 // 10312 10313 thread = PsGetCurrentThread(); 10314 oldFlag = !thread->HardErrorsAreDisabled; 10315 thread->HardErrorsAreDisabled = !EnableHardErrors; 10316 10317 return oldFlag; 10318 }

NTKERNELAPI VOID IoSetTopLevelIrp IN PIRP  Irp  ) 
 

Definition at line 10321 of file iosubs.c.

References Irp, and PsGetCurrentThread.

Referenced by MiRemoveUnusedSegments(), MmCreateSection(), UdfAcquireForCache(), UdfReleaseFromCache(), UdfRestoreThreadContext(), and UdfSetThreadContext().

10327 : 10328 10329 This routine sets the top level IRP field in the current thread's thread 10330 object. This function is invoked by file systems to either set this field 10331 to the address of an I/O Request Packet (IRP) or to null it. 10332 10333 Arguments: 10334 10335 Irp - Pointer to the IRP to be stored in the top level IRP field. 10336 10337 Return Value: 10338 10339 None. 10340 10341 Note: 10342 10343 This function cannot be made a macro, since fields in the thread object 10344 move from release to release, so this must remain a full function. 10345 10346 --*/ 10347 10348 { 10349 // 10350 // Simply set the top level IRP field in the current thread's thread 10351 // object. 10352 // 10353 10354 (PIRP) (PsGetCurrentThread())->TopLevelIrp = Irp; 10355 return; 10356 }

NTKERNELAPI VOID IoShutdownSystem IN ULONG  Phase  ) 
 

Definition at line 10359 of file iosubs.c.

References _DEVICE_OBJECT::AttachedDevice, DbgPrint, _SHUTDOWN_PACKET::DeviceObject, ExAcquireResourceShared, Executive, ExFreePool(), ExInterlockedRemoveHeadList(), FALSE, IoBuildSynchronousFsdRequest(), IoCallDriver, IoGetAttachedDevice(), IopDatabaseLock, IopDatabaseResource, IopDiskFileSystemQueueHead, IopNotifyLastChanceShutdownQueueHead, IopNotifyShutdownQueueHead, IRP_MJ_SHUTDOWN, KeClearEvent, KeInitializeEvent, KernelMode, KeWaitForSingleObject(), NULL, PAGED_CODE, TRUE, and VOID().

10365 : 10366 10367 This routine shuts down the I/O portion of the system in preparation 10368 for a power-off or reboot. 10369 10370 Arguments: 10371 10372 RebootPending - Indicates whether a reboot is imminently pending. 10373 10374 Phase - Indicates which phase of shutdown is being performed. 10375 10376 Return Value: 10377 10378 None 10379 10380 --*/ 10381 10382 { 10383 PLIST_ENTRY entry; 10384 PSHUTDOWN_PACKET shutdown; 10385 PDEVICE_OBJECT deviceObject; 10386 PIRP irp; 10387 KEVENT event; 10388 IO_STATUS_BLOCK ioStatus; 10389 PVOID unlockHandle; 10390 10391 PAGED_CODE(); 10392 10393 // 10394 // Initialize the event used to synchronize the complete of all of the 10395 // shutdown routines. 10396 // 10397 10398 KeInitializeEvent( &event, NotificationEvent, FALSE ); 10399 10400 if (Phase == 0) { 10401 10402 // 10403 // Walk the list of the drivers in the system that have registered 10404 // themselves as wanting to know when the system is about to be 10405 // shutdown and invoke each. 10406 // 10407 10408 while ((entry = ExInterlockedRemoveHeadList( &IopNotifyShutdownQueueHead, &IopDatabaseLock )) != NULL) { 10409 shutdown = CONTAINING_RECORD( entry, SHUTDOWN_PACKET, ListEntry ); 10410 10411 // 10412 // Another driver has been found that has indicated that it requires 10413 // shutdown notification. Invoke the driver's shutdown entry point. 10414 // 10415 10416 deviceObject = IoGetAttachedDevice( shutdown->DeviceObject ); 10417 10418 irp = IoBuildSynchronousFsdRequest( IRP_MJ_SHUTDOWN, 10419 deviceObject, 10420 (PVOID) NULL, 10421 0, 10422 (PLARGE_INTEGER) NULL, 10423 &event, 10424 &ioStatus ); 10425 10426 if (IoCallDriver( deviceObject, irp ) == STATUS_PENDING) { 10427 #if DBG 10428 PUNICODE_STRING DeviceName = ObGetObjectName( shutdown->DeviceObject ); 10429 10430 DbgPrint( "IO: Waiting for shutdown of device object (%x) - %wZ\n", 10431 shutdown->DeviceObject, 10432 DeviceName 10433 ); 10434 #endif // DBG 10435 (VOID) KeWaitForSingleObject( &event, 10436 Executive, 10437 KernelMode, 10438 FALSE, 10439 (PLARGE_INTEGER) NULL ); 10440 } 10441 10442 ExFreePool( shutdown ); 10443 KeClearEvent( &event ); 10444 } 10445 10446 } else if (Phase == 1) { 10447 10448 #if defined(REMOTE_BOOT) 10449 // 10450 // If this is a remote boot client then allow the cache to close the database and 10451 // mark it clean. 10452 // 10453 10454 IopShutdownCsc(); 10455 #endif // defined(REMOTE_BOOT) 10456 10457 // Gain access to the file system header queues by acquiring the 10458 // database resource for shared access. 10459 // 10460 10461 ExAcquireResourceShared( &IopDatabaseResource, TRUE ); 10462 10463 // 10464 // Loop through each of the disk file systems, invoking each to shutdown 10465 // each of their mounted volumes. 10466 // 10467 10468 for (entry = IopDiskFileSystemQueueHead.Flink; 10469 entry != &IopDiskFileSystemQueueHead; 10470 entry = entry->Flink) { 10471 10472 deviceObject = CONTAINING_RECORD( entry, DEVICE_OBJECT, Queue.ListEntry ); 10473 if (deviceObject->AttachedDevice) { 10474 deviceObject = IoGetAttachedDevice( deviceObject ); 10475 } 10476 10477 // 10478 // Another file system has been found. Invoke this file system at 10479 // its shutdown entry point. 10480 // 10481 10482 irp = IoBuildSynchronousFsdRequest( IRP_MJ_SHUTDOWN, 10483 deviceObject, 10484 (PVOID) NULL, 10485 0, 10486 (PLARGE_INTEGER) NULL, 10487 &event, 10488 &ioStatus ); 10489 if (IoCallDriver( deviceObject, irp ) == STATUS_PENDING) { 10490 #if DBG 10491 PUNICODE_STRING DeviceName = ObGetObjectName( deviceObject ); 10492 10493 DbgPrint( "IO: Waiting for shutdown of device object (%x) - %wZ\n", 10494 deviceObject, 10495 DeviceName 10496 ); 10497 #endif // DBG 10498 (VOID) KeWaitForSingleObject( &event, 10499 Executive, 10500 KernelMode, 10501 FALSE, 10502 (PLARGE_INTEGER) NULL ); 10503 } 10504 10505 KeClearEvent( &event ); 10506 } 10507 10508 // 10509 // Walk the list of the drivers in the system that have registered 10510 // themselves as wanting to know at the last chance when the system 10511 // is about to be shutdown and invoke each. 10512 // 10513 10514 while ((entry = ExInterlockedRemoveHeadList( &IopNotifyLastChanceShutdownQueueHead, &IopDatabaseLock )) != NULL) { 10515 shutdown = CONTAINING_RECORD( entry, SHUTDOWN_PACKET, ListEntry ); 10516 10517 // 10518 // Another driver has been found that has indicated that it requires 10519 // shutdown notification. Invoke the driver's shutdown entry point. 10520 // 10521 10522 deviceObject = IoGetAttachedDevice( shutdown->DeviceObject ); 10523 10524 irp = IoBuildSynchronousFsdRequest( IRP_MJ_SHUTDOWN, 10525 deviceObject, 10526 (PVOID) NULL, 10527 0, 10528 (PLARGE_INTEGER) NULL, 10529 &event, 10530 &ioStatus ); 10531 10532 if (IoCallDriver( deviceObject, irp ) == STATUS_PENDING) { 10533 #if DBG 10534 PUNICODE_STRING DeviceName = ObGetObjectName( shutdown->DeviceObject ); 10535 10536 DbgPrint( "IO: Waiting for last chance shutdown of device object (%x) - %wZ\n", 10537 shutdown->DeviceObject, 10538 DeviceName 10539 ); 10540 #endif // DBG 10541 (VOID) KeWaitForSingleObject( &event, 10542 Executive, 10543 KernelMode, 10544 FALSE, 10545 (PLARGE_INTEGER) NULL ); 10546 } 10547 10548 ExFreePool( shutdown ); 10549 KeClearEvent( &event ); 10550 } 10551 10552 // 10553 // N.B. The system has stopped. The IopDatabaseResource lock is 10554 // not released so that no other mount operations can take place. 10555 // 10556 // ExReleaseResource( &IopDatabaseResource ); 10557 // 10558 } 10559 10560 return ; 10561 }

NTKERNELAPI VOID IoStartNextPacket IN PDEVICE_OBJECT  DeviceObject,
IN BOOLEAN  Cancelable
 

Definition at line 10564 of file iosubs.c.

References IoAcquireCancelSpinLock(), IoReleaseCancelSpinLock(), KeRemoveDeviceQueue(), and NULL.

10571 : 10572 10573 This routine is invoked to dequeue the next packet (IRP) from the 10574 specified device work queue and invoke the device driver's start I/O 10575 routine for it. If the Cancelable paramter is TRUE, then the update of 10576 current IRP is synchronized using the cancel spinlock. 10577 10578 Arguments: 10579 10580 DeviceObject - Pointer to device object itself. 10581 10582 Cancelable - Indicates that IRPs in the device queue may be cancelable. 10583 10584 Return Value: 10585 10586 None. 10587 10588 --*/ 10589 10590 { 10591 KIRQL cancelIrql; 10592 PIRP irp; 10593 PKDEVICE_QUEUE_ENTRY packet; 10594 10595 // 10596 // Begin by checking to see whether or not this driver's requests are 10597 // to be considered cancelable. If so, then acquire the cancel spinlock. 10598 // 10599 10600 if (Cancelable) { 10601 IoAcquireCancelSpinLock( &cancelIrql ); 10602 } 10603 10604 // 10605 // Clear the current IRP field before starting another request. 10606 // 10607 10608 DeviceObject->CurrentIrp = (PIRP) NULL; 10609 10610 // 10611 // Remove the next packet from the head of the queue. If a packet was 10612 // found, then process it. 10613 // 10614 10615 packet = KeRemoveDeviceQueue( &DeviceObject->DeviceQueue ); 10616 10617 if (packet) { 10618 irp = CONTAINING_RECORD( packet, IRP, Tail.Overlay.DeviceQueueEntry ); 10619 10620 // 10621 // A packet was located so make it the current packet for this 10622 // device. 10623 // 10624 10625 DeviceObject->CurrentIrp = irp; 10626 if (Cancelable) { 10627 IoReleaseCancelSpinLock( cancelIrql ); 10628 } 10629 10630 // 10631 // Invoke the driver's start I/O routine for this packet. 10632 // 10633 10634 DeviceObject->DriverObject->DriverStartIo( DeviceObject, irp ); 10635 } else { 10636 10637 // 10638 // No packet was found, so simply release the cancel spinlock if 10639 // it was acquired. 10640 // 10641 10642 if (Cancelable) { 10643 IoReleaseCancelSpinLock( cancelIrql ); 10644 } 10645 } 10646 }

NTKERNELAPI VOID IoStartNextPacketByKey IN PDEVICE_OBJECT  DeviceObject,
IN BOOLEAN  Cancelable,
IN ULONG  Key
 

Definition at line 10649 of file iosubs.c.

References IoAcquireCancelSpinLock(), IoReleaseCancelSpinLock(), KeRemoveByKeyDeviceQueue(), Key, and NULL.

10657 : 10658 10659 This routine is invoked to dequeue the next packet (IRP) from the 10660 specified device work queue by key and invoke the device driver's start 10661 I/O routine for it. If the Cancelable paramter is TRUE, then the 10662 update of current IRP is synchronized using the cancel spinlock. 10663 10664 Arguments: 10665 10666 DeviceObject - Pointer to device object itself. 10667 10668 Cancelable - Indicates that IRPs in the device queue may be cancelable. 10669 10670 Key - Specifics the Key used to remove the entry from the queue. 10671 10672 Return Value: 10673 10674 None. 10675 10676 --*/ 10677 10678 { 10679 KIRQL cancelIrql; 10680 PIRP irp; 10681 PKDEVICE_QUEUE_ENTRY packet; 10682 10683 // 10684 // Begin by determining whether or not requests for this device are to 10685 // be considered cancelable. If so, then acquire the cancel spinlock. 10686 // 10687 10688 if (Cancelable) { 10689 IoAcquireCancelSpinLock( &cancelIrql ); 10690 } 10691 10692 // 10693 // Clear the current IRP field before starting another request. 10694 // 10695 10696 DeviceObject->CurrentIrp = (PIRP) NULL; 10697 10698 // 10699 // Attempt to remove the indicated packet according to the key from the 10700 // device queue. If one is found, then process it. 10701 // 10702 10703 packet = KeRemoveByKeyDeviceQueue( &DeviceObject->DeviceQueue, Key ); 10704 10705 if (packet) { 10706 irp = CONTAINING_RECORD( packet, IRP, Tail.Overlay.DeviceQueueEntry ); 10707 10708 // 10709 // A packet was successfully located. Make it the current packet 10710 // and invoke the driver's start I/O routine for it. 10711 // 10712 10713 DeviceObject->CurrentIrp = irp; 10714 10715 if (Cancelable) { 10716 IoReleaseCancelSpinLock( cancelIrql ); 10717 } 10718 10719 DeviceObject->DriverObject->DriverStartIo( DeviceObject, irp ); 10720 10721 } else { 10722 10723 // 10724 // No packet was found, so release the cancel spinlock if it was 10725 // acquired. 10726 // 10727 10728 if (Cancelable) { 10729 IoReleaseCancelSpinLock( cancelIrql ); 10730 } 10731 } 10732 }

NTKERNELAPI VOID IoStartPacket IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PULONG Key  OPTIONAL,
IN PDRIVER_CANCEL CancelFunction  OPTIONAL
 

Definition at line 10735 of file iosubs.c.

References _IRP::Cancel, _IRP::CancelIrql, _IRP::CancelRoutine, DISPATCH_LEVEL, IoAcquireCancelSpinLock(), IoReleaseCancelSpinLock(), Irp, KeInsertByKeyDeviceQueue(), KeInsertDeviceQueue(), KeLowerIrql(), KeRaiseIrql(), Key, NULL, PDRIVER_CANCEL, and _IRP::Tail.

10744 : 10745 10746 This routine attempts to start the specified packet request (IRP) on the 10747 specified device. If the device is already busy, then the packet is 10748 simply queued to the device queue. If a non-NULL CancelFunction is 10749 supplied, it will be put in the IRP. If the IRP has been canceled, the 10750 CancelFunction will be called after the IRP has been inserted into the 10751 queue or made the current packet. 10752 10753 Arguments: 10754 10755 DeviceObject - Pointer to device object itself. 10756 10757 Irp - I/O Request Packet which should be started on the device. 10758 10759 Key - Key to be used in inserting packet into device queue; optional 10760 (if not specified, then packet is inserted at the tail). 10761 10762 CancelFunction - Pointer to an optional cancel routine. 10763 10764 Return Value: 10765 10766 None. 10767 10768 --*/ 10769 10770 { 10771 KIRQL oldIrql; 10772 KIRQL cancelIrql; 10773 BOOLEAN i; 10774 10775 // 10776 // Raise the IRQL of the processor to dispatch level for synchronization. 10777 // 10778 10779 KeRaiseIrql( DISPATCH_LEVEL, &oldIrql ); 10780 10781 // 10782 // If the driver has indicated that packets are cancelable, then acquire 10783 // the cancel spinlock and set the address of the cancel function to 10784 // indicate that the packet is not only cancelable, but indicates what 10785 // routine to invoke should it be cancelled. 10786 // 10787 10788 if (CancelFunction) { 10789 IoAcquireCancelSpinLock( &cancelIrql ); 10790 Irp->CancelRoutine = CancelFunction; 10791 } 10792 10793 // 10794 // If a key parameter was specified, then insert the request into the 10795 // work queue according to the key; otherwise, simply insert it at the 10796 // tail. 10797 // 10798 10799 if (Key) { 10800 i = KeInsertByKeyDeviceQueue( &DeviceObject->DeviceQueue, 10801 &Irp->Tail.Overlay.DeviceQueueEntry, 10802 *Key ); 10803 } else { 10804 i = KeInsertDeviceQueue( &DeviceObject->DeviceQueue, 10805 &Irp->Tail.Overlay.DeviceQueueEntry ); 10806 } 10807 10808 // 10809 // If the packet was not inserted into the queue, then this request is 10810 // now the current packet for this device. Indicate so by storing its 10811 // address in the current IRP field, and begin processing the request. 10812 // 10813 10814 if (!i) { 10815 10816 DeviceObject->CurrentIrp = Irp; 10817 10818 if (CancelFunction) { 10819 10820 IoReleaseCancelSpinLock( cancelIrql ); 10821 } 10822 10823 // 10824 // Invoke the driver's start I/O routine to get the request going on the device. 10825 // The StartIo routine should handle the cancellation. 10826 // 10827 10828 DeviceObject->DriverObject->DriverStartIo( DeviceObject, Irp ); 10829 10830 } else { 10831 10832 // 10833 // The packet was successfully inserted into the device's work queue. 10834 // Make one last check to determine whether or not the packet has 10835 // already been marked cancelled. If it has, then invoke the 10836 // driver's cancel routine now. Note that because the cancel 10837 // spinlock is currently being held, an attempt to cancel the request 10838 // from another processor at this point will simply wait until this 10839 // routine is finished, and then get it cancelled. 10840 // 10841 10842 if (CancelFunction) { 10843 if (Irp->Cancel) { 10844 Irp->CancelIrql = cancelIrql; 10845 Irp->CancelRoutine = (PDRIVER_CANCEL) NULL; 10846 CancelFunction( DeviceObject, Irp ); 10847 } else { 10848 IoReleaseCancelSpinLock( cancelIrql ); 10849 } 10850 } 10851 } 10852 10853 // 10854 // Restore the IRQL back to its value upon entry to this function before 10855 // returning to the caller. 10856 // 10857 10858 KeLowerIrql( oldIrql ); 10859 }

NTKERNELAPI VOID IoStartTimer IN PDEVICE_OBJECT  DeviceObject  ) 
 

Definition at line 10863 of file iosubs.c.

References DOE_DELETE_PENDING, DOE_REMOVE_PENDING, DOE_REMOVE_PROCESSED, DOE_UNLOAD_PENDING, IopTimerCount, IopTimerLock, _IO_TIMER::TimerFlag, and TRUE.

10869 : 10870 10871 This routine starts the timer associated with the specified device object. 10872 10873 Arguments: 10874 10875 DeviceObject - Device object associated with the timer to be started. 10876 10877 Return Value: 10878 10879 None. 10880 10881 --*/ 10882 10883 { 10884 PIO_TIMER timer; 10885 KIRQL irql; 10886 10887 // 10888 // Get the address of the timer. 10889 // 10890 10891 timer = DeviceObject->Timer; 10892 10893 // 10894 // If the driver is not being unloaded, then it is okay to start timers. 10895 // 10896 10897 if (!(DeviceObject->DeviceObjectExtension->ExtensionFlags & 10898 (DOE_UNLOAD_PENDING | DOE_DELETE_PENDING | DOE_REMOVE_PENDING | DOE_REMOVE_PROCESSED))) { 10899 10900 // 10901 // Likewise, check to see whether or not the timer is already 10902 // enabled. If so, then simply exit. Otherwise, enable the timer 10903 // by placing it into the I/O system timer queue. 10904 // 10905 10906 ExAcquireFastLock( &IopTimerLock, &irql ); 10907 if (!timer->TimerFlag) { 10908 timer->TimerFlag = TRUE; 10909 IopTimerCount++; 10910 } 10911 ExReleaseFastLock( &IopTimerLock, irql ); 10912 } 10913 }

NTKERNELAPI VOID IoStopTimer IN PDEVICE_OBJECT  DeviceObject  ) 
 

Definition at line 10916 of file iosubs.c.

References FALSE, IopTimerCount, IopTimerLock, and _IO_TIMER::TimerFlag.

10922 : 10923 10924 This routines stops the timer associated with the specified device object 10925 from invoking being invoked. 10926 10927 Arguments: 10928 10929 DeviceObject - Device object associated with the timer to be stopped. 10930 10931 Return Value: 10932 10933 None. 10934 10935 --*/ 10936 10937 { 10938 KIRQL irql; 10939 PIO_TIMER timer; 10940 10941 // 10942 // Obtain the I/O system timer queue lock, and disable the specified 10943 // timer. 10944 // 10945 10946 timer = DeviceObject->Timer; 10947 10948 ExAcquireFastLock( &IopTimerLock, &irql ); 10949 if (timer->TimerFlag) { 10950 timer->TimerFlag = FALSE; 10951 IopTimerCount--; 10952 } 10953 ExReleaseFastLock( &IopTimerLock, irql ); 10954 }

NTKERNELAPI NTSTATUS IoSynchronousPageWrite IN PFILE_OBJECT  FileObject,
IN PMDL  MemoryDescriptorList,
IN PLARGE_INTEGER  StartingOffset,
IN PKEVENT  Event,
OUT PIO_STATUS_BLOCK  IoStatusBlock
 

Definition at line 10957 of file iosubs.c.

References CcDataFlushes, CcDataPages, CcIsFileCached, Event(), FALSE, _IO_STACK_LOCATION::FileObject, _IRP::Flags, IoAllocateIrp(), IoCallDriver, IoGetNextIrpStackLocation, IoGetRelatedDeviceObject(), IRP_MJ_WRITE, IRP_NOCACHE, IRP_PAGING_IO, IRP_SYNCHRONOUS_PAGING_IO, KernelMode, _IO_STACK_LOCATION::MajorFunction, _IRP::MdlAddress, PAGE_SHIFT, PAGE_SIZE, _IO_STACK_LOCATION::Parameters, PsGetCurrentThread, _IRP::RequestorMode, _DEVICE_OBJECT::StackSize, _IRP::Tail, _IRP::UserBuffer, _IRP::UserEvent, and _IRP::UserIosb.

Referenced by CcZeroData(), MiCheckForCrashDump(), MiCleanSection(), MiFlushSectionInternal(), MiMappedPageWriter(), and MmShutdownSystem().

10967 : 10968 10969 This routine provides a special, fast interface for the Modified Page Writer 10970 (MPW) to write pages to the disk quickly and with very little overhead. All 10971 of the special handling for this request is recognized by setting the 10972 IRP_PAGING_IO flag in the IRP flags word. 10973 10974 Arguments: 10975 10976 FileObject - A pointer to a referenced file object describing which file 10977 the write should be performed on. 10978 10979 MemoryDescriptorList - An MDL which describes the physical pages that the 10980 pages should be written to the disk. All of the pages have been locked 10981 in memory. The MDL also describes the length of the write operation. 10982 10983 StartingOffset - Pointer to the offset in the file from which the write 10984 should take place. 10985 10986 Event - A pointer to a kernel event structure to be used for synchronization 10987 purposes. The event will be set to the Signlaged state once the pages 10988 have been written. 10989 10990 IoStatusBlock - A pointer to the I/O status block in which the final status 10991 and information should be stored. 10992 10993 Return Value: 10994 10995 The function value is the final status of the queue request to the I/O 10996 system subcomponents. 10997 10998 10999 --*/ 11000 11001 { 11002 PIRP irp; 11003 PIO_STACK_LOCATION irpSp; 11004 PDEVICE_OBJECT deviceObject; 11005 11006 // 11007 // Increment performance counters 11008 // 11009 11010 if (CcIsFileCached(FileObject)) { 11011 CcDataFlushes += 1; 11012 CcDataPages += (MemoryDescriptorList->ByteCount + PAGE_SIZE - 1) >> PAGE_SHIFT; 11013 } 11014 11015 // 11016 // Begin by getting a pointer to the device object that the file resides 11017 // on. 11018 // 11019 11020 deviceObject = IoGetRelatedDeviceObject( FileObject ); 11021 11022 // 11023 // Allocate an I/O Request Packet (IRP) for this out-page operation. 11024 // 11025 11026 irp = IoAllocateIrp( deviceObject->StackSize, FALSE ); 11027 if (!irp) { 11028 return STATUS_INSUFFICIENT_RESOURCES; 11029 } 11030 11031 // 11032 // Get a pointer to the first stack location in the packet. This location 11033 // will be used to pass the function codes and parameters to the first 11034 // driver. 11035 // 11036 11037 irpSp = IoGetNextIrpStackLocation( irp ); 11038 11039 // 11040 // Fill in the IRP according to this request. 11041 // 11042 11043 irp->MdlAddress = MemoryDescriptorList; 11044 irp->Flags = IRP_PAGING_IO | IRP_NOCACHE | IRP_SYNCHRONOUS_PAGING_IO; 11045 11046 irp->RequestorMode = KernelMode; 11047 irp->UserIosb = IoStatusBlock; 11048 irp->UserEvent = Event; 11049 irp->UserBuffer = (PVOID) ((PCHAR) MemoryDescriptorList->StartVa + MemoryDescriptorList->ByteOffset); 11050 irp->Tail.Overlay.OriginalFileObject = FileObject; 11051 irp->Tail.Overlay.Thread = PsGetCurrentThread(); 11052 11053 // 11054 // Fill in the normal write parameters. 11055 // 11056 11057 irpSp->MajorFunction = IRP_MJ_WRITE; 11058 irpSp->Parameters.Write.Length = MemoryDescriptorList->ByteCount; 11059 irpSp->Parameters.Write.ByteOffset = *StartingOffset; 11060 irpSp->FileObject = FileObject; 11061 11062 // 11063 // Queue the packet to the appropriate driver based on whether or not there 11064 // is a VPB associated with the device. 11065 // 11066 11067 return IoCallDriver( deviceObject, irp ); 11068 }

NTKERNELAPI PEPROCESS IoThreadToProcess IN PETHREAD  Thread  ) 
 

Definition at line 11071 of file iosubs.c.

References THREAD_TO_PROCESS.

11077 : 11078 11079 This routine returns a pointer to the process for the specified thread. 11080 11081 Arguments: 11082 11083 Thread - Thread whose process is to be returned. 11084 11085 Return Value: 11086 11087 A pointer to the thread's process. 11088 11089 Note: 11090 11091 This function cannot be made a macro, since fields in the thread object 11092 move from release to release, so this must remain a full function. 11093 11094 11095 --*/ 11096 11097 { 11098 // 11099 // Simply return the thread's process. 11100 // 11101 11102 return THREAD_TO_PROCESS( Thread ); 11103 }

VOID IoTraverseDeviceTree IN BOOLEAN  Inverted,
IN LONG  CurrentLevel,
IN PIO_TRAVERSE_WORKER  WorkerFunction,
IN PIO_LEVEL_END_WORKER  LevelEndFunction,
IN PVOID  Context
 

NTKERNELAPI VOID IoUnregisterFileSystem IN OUT PDEVICE_OBJECT  DeviceObject  ) 
 

Definition at line 11106 of file iosubs.c.

References ExAcquireResourceExclusive, ExInterlockedAddUlong(), ExReleaseResource, FALSE, IopDatabaseLock, IopDatabaseResource, IopFsNotifyChangeQueueHead, _NOTIFICATION_PACKET::NotificationRoutine, PAGED_CODE, TRUE, and VOID().

Referenced by FsRecLoadFileSystem().

11112 : 11113 11114 This routine removes the device object for the file system from the active 11115 list of file systems in the system. 11116 11117 Arguments: 11118 11119 DeviceObject - Pointer to device object for the file system. 11120 11121 Return Value: 11122 11123 None. 11124 11125 11126 --*/ 11127 11128 { 11129 PNOTIFICATION_PACKET nPacket; 11130 PLIST_ENTRY entry; 11131 11132 PAGED_CODE(); 11133 11134 // 11135 // Acquire the I/O database resource for a write operation. 11136 // 11137 11138 (VOID)ExAcquireResourceExclusive( &IopDatabaseResource, TRUE ); 11139 11140 // 11141 // Remove the device object from whatever queue it happens to be in at the 11142 // moment. There is no need to check here to determine if the device queue 11143 // is in a queue since it is assumed that the caller registered it as a 11144 // valid file system. 11145 // 11146 11147 RemoveEntryList( &DeviceObject->Queue.ListEntry ); 11148 11149 // 11150 // Notify all of the registered drivers that this file system has been 11151 // unregistered as an active file system of some type. 11152 // 11153 11154 entry = IopFsNotifyChangeQueueHead.Flink; 11155 while (entry != &IopFsNotifyChangeQueueHead) { 11156 nPacket = CONTAINING_RECORD( entry, NOTIFICATION_PACKET, ListEntry ); 11157 entry = entry->Flink; 11158 nPacket->NotificationRoutine( DeviceObject, FALSE ); 11159 } 11160 11161 // 11162 // Release the I/O database resource. 11163 // 11164 11165 ExReleaseResource( &IopDatabaseResource ); 11166 11167 // 11168 // Decrement the number of reasons that this driver cannot be unloaded. 11169 // 11170 11171 ExInterlockedAddUlong( &DeviceObject->ReferenceCount, 11172 0xffffffff, 11173 &IopDatabaseLock ); 11174 11175 }

NTKERNELAPI VOID IoUnregisterFsRegistrationChange IN PDRIVER_OBJECT  DriverObject,
IN PDRIVER_FS_NOTIFICATION  DriverNotificationRoutine
 

Definition at line 11178 of file iosubs.c.

References _NOTIFICATION_PACKET::DriverObject, ExAcquireResourceExclusive, ExFreePool(), ExReleaseResource, IopDatabaseResource, IopFsNotifyChangeQueueHead, _NOTIFICATION_PACKET::NotificationRoutine, ObDereferenceObject, PAGED_CODE, and TRUE.

11185 : 11186 11187 This routine unregisters the specified driver's notification routine from 11188 begin invoked whenever a file system registers or unregisters itself as an 11189 active file system in the system. 11190 11191 Arguments: 11192 11193 DriverObject - Pointer to the driver object for the driver. 11194 11195 DriverNotificationRoutine - Address of routine to unregister. 11196 11197 Return Value: 11198 11199 None. 11200 11201 --*/ 11202 11203 { 11204 PNOTIFICATION_PACKET nPacket; 11205 PLIST_ENTRY entry; 11206 11207 PAGED_CODE(); 11208 11209 // 11210 // Begin by acquiring the database resource exclusively. 11211 // 11212 11213 ExAcquireResourceExclusive( &IopDatabaseResource, TRUE ); 11214 11215 // 11216 // Walk the list of registered notification routines and unregister the 11217 // specified routine. 11218 // 11219 11220 for (entry = IopFsNotifyChangeQueueHead.Flink; 11221 entry != &IopFsNotifyChangeQueueHead; 11222 entry = entry->Flink) { 11223 nPacket = CONTAINING_RECORD( entry, NOTIFICATION_PACKET, ListEntry ); 11224 if (nPacket->DriverObject == DriverObject && 11225 nPacket->NotificationRoutine == DriverNotificationRoutine) { 11226 RemoveEntryList( entry ); 11227 ExFreePool( nPacket ); 11228 break; 11229 } 11230 } 11231 11232 ExReleaseResource( &IopDatabaseResource ); 11233 11234 ObDereferenceObject( DriverObject ); 11235 11236 }

NTKERNELAPI VOID IoUnregisterShutdownNotification IN PDEVICE_OBJECT  DeviceObject  ) 
 

Definition at line 11239 of file iosubs.c.

References _SHUTDOWN_PACKET::DeviceObject, DO_SHUTDOWN_REGISTERED, ExFreePool(), IopDatabaseLock, IopNotifyLastChanceShutdownQueueHead, IopNotifyShutdownQueueHead, IoUnregisterShutdownNotification(), MmUnlockPagableImageSection(), and PAGED_CODE.

Referenced by IoDeleteDevice(), and IoUnregisterShutdownNotification().

11245 : 11246 11247 This routine removes a registered driver from the shutdown notification 11248 queue. Henceforth, the driver will not be notified when the system is 11249 being shutdown. 11250 11251 Arguments: 11252 11253 DeviceObject - Pointer to the driver's device object. 11254 11255 Return Value: 11256 11257 None. 11258 11259 --*/ 11260 11261 { 11262 PLIST_ENTRY entry; 11263 PSHUTDOWN_PACKET shutdown; 11264 KIRQL irql; 11265 PVOID unlockHandle; 11266 11267 PAGED_CODE(); 11268 11269 // 11270 // Lock this code into memory for the duration of this function's execution. 11271 // 11272 11273 unlockHandle = MmLockPagableCodeSection( IoUnregisterShutdownNotification ); 11274 11275 // 11276 // Acquire the spinlock that protects the shutdown notification queue, and 11277 // walk the queue looking for the caller's entry. Once found, remove it 11278 // from the queue. It is an error to not find it, but it is ignored here. 11279 // 11280 11281 ExAcquireSpinLock( &IopDatabaseLock, &irql ); 11282 11283 for (entry = IopNotifyShutdownQueueHead.Flink; 11284 entry != &IopNotifyShutdownQueueHead; 11285 entry = entry->Flink) { 11286 11287 // 11288 // An entry has been located. If it is the one that is being searched 11289 // for, simply remove it from the list and deallocate it. 11290 // 11291 11292 shutdown = CONTAINING_RECORD( entry, SHUTDOWN_PACKET, ListEntry ); 11293 if (shutdown->DeviceObject == DeviceObject) { 11294 RemoveEntryList( entry ); 11295 entry = entry->Blink; 11296 ExFreePool( shutdown ); 11297 } 11298 } 11299 11300 for (entry = IopNotifyLastChanceShutdownQueueHead.Flink; 11301 entry != &IopNotifyLastChanceShutdownQueueHead; 11302 entry = entry->Flink) { 11303 11304 // 11305 // An entry has been located. If it is the one that is being searched 11306 // for, simply remove it from the list and deallocate it. 11307 // 11308 11309 shutdown = CONTAINING_RECORD( entry, SHUTDOWN_PACKET, ListEntry ); 11310 if (shutdown->DeviceObject == DeviceObject) { 11311 RemoveEntryList( entry ); 11312 entry = entry->Blink; 11313 ExFreePool( shutdown ); 11314 } 11315 } 11316 11317 // 11318 // Release the spinlock. 11319 // 11320 11321 ExReleaseSpinLock( &IopDatabaseLock, irql ); 11322 11323 MmUnlockPagableImageSection( unlockHandle ); 11324 11325 DeviceObject->Flags &= ~DO_SHUTDOWN_REGISTERED; 11326 11327 }

NTKERNELAPI VOID IoUpdateShareAccess IN PFILE_OBJECT  FileObject,
IN OUT PSHARE_ACCESS  ShareAccess
 

PIRP IovAllocateIrp IN CCHAR  StackSize,
IN BOOLEAN  ChargeQuota
 

Definition at line 353 of file ioverifier.c.

References _IRP::AllocationFlags, ExAllocatePoolWithTagPriority(), EXCEPTION_EXECUTE_HANDLER, HighPoolPrioritySpecialPoolOverrun, IopAllocateIrpPrivate(), IopInitializeIrp, IoSizeOfIrp, IovpVerifierFlags, IRP_ALLOCATED_MUST_SUCCEED, IRP_QUOTA_CHARGED, KernelMode, NonPagedPool, NonPagedPoolMustSucceed, NULL, SPECIALIRP_IO_ALLOCATE_IRP_1, SPECIALIRP_IO_ALLOCATE_IRP_2, and USHORT.

Referenced by IoVerifierInit().

00357 { 00358 USHORT allocateSize; 00359 UCHAR fixedSize; 00360 PIRP irp; 00361 UCHAR mustSucceed; 00362 USHORT packetSize; 00363 00364 #ifndef NO_SPECIAL_IRP 00365 // 00366 // Should we override normal lookaside caching so that we may catch 00367 // more bugs? 00368 // 00369 SPECIALIRP_IO_ALLOCATE_IRP_1(StackSize, ChargeQuota, &irp) ; 00370 00371 if (irp) { 00372 return irp ; 00373 } 00374 #endif 00375 00376 // 00377 // If special pool is not turned on lets just call the standard 00378 // irp allocator. 00379 // 00380 00381 if (!(IovpVerifierFlags & DRIVER_VERIFIER_SPECIAL_POOLING )) { 00382 irp = IopAllocateIrpPrivate(StackSize, ChargeQuota); 00383 return irp; 00384 } 00385 00386 00387 irp = NULL; 00388 fixedSize = 0; 00389 mustSucceed = 0; 00390 packetSize = IoSizeOfIrp(StackSize); 00391 allocateSize = packetSize; 00392 00393 // 00394 // There are no free packets on the lookaside list, or the packet is 00395 // too large to be allocated from one of the lists, so it must be 00396 // allocated from nonpaged pool. If quota is to be charged, charge it 00397 // against the current process. Otherwise, allocate the pool normally. 00398 // 00399 00400 if (ChargeQuota) { 00401 try { 00402 irp = ExAllocatePoolWithTagPriority( 00403 NonPagedPool, 00404 allocateSize, 00405 ' prI', 00406 HighPoolPrioritySpecialPoolOverrun); 00407 } except(EXCEPTION_EXECUTE_HANDLER) { 00408 NOTHING; 00409 } 00410 00411 } else { 00412 00413 // 00414 // Attempt to allocate the pool from non-paged pool. If this 00415 // fails, and the caller's previous mode was kernel then allocate 00416 // the pool as must succeed. 00417 // 00418 00419 irp = ExAllocatePoolWithTagPriority( 00420 NonPagedPool, 00421 allocateSize, 00422 ' prI', 00423 HighPoolPrioritySpecialPoolOverrun); 00424 if (!irp) { 00425 mustSucceed = IRP_ALLOCATED_MUST_SUCCEED; 00426 if (KeGetPreviousMode() == KernelMode ) { 00427 irp = ExAllocatePoolWithTagPriority( 00428 NonPagedPoolMustSucceed, 00429 allocateSize, 00430 ' prI', 00431 HighPoolPrioritySpecialPoolOverrun); 00432 } 00433 } 00434 } 00435 00436 if (!irp) { 00437 return NULL; 00438 } 00439 00440 // 00441 // Initialize the packet. 00442 // 00443 00444 IopInitializeIrp(irp, packetSize, StackSize); 00445 irp->AllocationFlags = mustSucceed; 00446 if (ChargeQuota) { 00447 irp->AllocationFlags |= IRP_QUOTA_CHARGED; 00448 } 00449 00450 SPECIALIRP_IO_ALLOCATE_IRP_2(irp) ; 00451 return irp; 00452 }

PIRP IovBuildAsynchronousFsdRequest IN ULONG  MajorFunction,
IN PDEVICE_OBJECT  DeviceObject,
IN OUT PVOID Buffer  OPTIONAL,
IN ULONG Length  OPTIONAL,
IN PLARGE_INTEGER StartingOffset  OPTIONAL,
IN PIO_STATUS_BLOCK IoStatusBlock  OPTIONAL
 

Definition at line 455 of file ioverifier.c.

References Buffer, EXCEPTION_EXECUTE_HANDLER, IO_BUILD_FSD_REQUEST_EXCEPTION, IoBuildAsynchronousFsdRequest(), Irp, and KeBugCheckEx().

00463 { 00464 PIRP Irp; 00465 00466 try { 00467 Irp = IoBuildAsynchronousFsdRequest( 00468 MajorFunction, 00469 DeviceObject, 00470 Buffer, 00471 Length, 00472 StartingOffset, 00473 IoStatusBlock 00474 ); 00475 } except(EXCEPTION_EXECUTE_HANDLER) { 00476 KeBugCheckEx(DRIVER_VERIFIER_IOMANAGER_VIOLATION, 00477 IO_BUILD_FSD_REQUEST_EXCEPTION, 00478 (ULONG_PTR)DeviceObject, 00479 (ULONG_PTR)MajorFunction, 00480 GetExceptionCode()); 00481 } 00482 return (Irp); 00483 }

PIRP IovBuildDeviceIoControlRequest IN ULONG  IoControlCode,
IN PDEVICE_OBJECT  DeviceObject,
IN PVOID InputBuffer  OPTIONAL,
IN ULONG  InputBufferLength,
OUT PVOID OutputBuffer  OPTIONAL,
IN ULONG  OutputBufferLength,
IN BOOLEAN  InternalDeviceIoControl,
IN PKEVENT  Event,
OUT PIO_STATUS_BLOCK  IoStatusBlock
 

Definition at line 486 of file ioverifier.c.

References Event(), EXCEPTION_EXECUTE_HANDLER, IO_BUILD_IOCTL_REQUEST_EXCEPTION, IoBuildDeviceIoControlRequest(), Irp, and KeBugCheckEx().

00497 { 00498 PIRP Irp; 00499 00500 try { 00501 Irp = IoBuildDeviceIoControlRequest( 00502 IoControlCode, 00503 DeviceObject, 00504 InputBuffer, 00505 InputBufferLength, 00506 OutputBuffer, 00507 OutputBufferLength, 00508 InternalDeviceIoControl, 00509 Event, 00510 IoStatusBlock 00511 ); 00512 } except(EXCEPTION_EXECUTE_HANDLER) { 00513 KeBugCheckEx(DRIVER_VERIFIER_IOMANAGER_VIOLATION, 00514 IO_BUILD_IOCTL_REQUEST_EXCEPTION, 00515 (ULONG_PTR)DeviceObject, 00516 (ULONG_PTR)IoControlCode, 00517 GetExceptionCode()); 00518 } 00519 00520 return (Irp); 00521 }

NTSTATUS FASTCALL IovCallDriver IN PDEVICE_OBJECT  DeviceObject,
IN OUT PIRP  Irp
 

Definition at line 248 of file ioverifier.c.

References IO_CALL_DRIVER_INVALID_DEVICE_OBJECT, IO_CALL_DRIVER_IRP_TYPE_INVALID, IO_CALL_DRIVER_IRQL_NOT_EQUAL, IO_TYPE_IRP, IopfCallDriver(), IopVerifierOn, IovpValidateDeviceObject(), IovpVerifierLevel, IovSpecialIrpCallDriver(), Irp, KeBugCheckEx(), NTSTATUS(), and _IRP::Type.

00252 { 00253 KIRQL saveIrql; 00254 NTSTATUS status; 00255 00256 00257 if (!IopVerifierOn) { 00258 status = IopfCallDriver(DeviceObject, Irp); 00259 return status; 00260 } 00261 00262 if (IovpVerifierLevel > 1) { 00263 status = IovSpecialIrpCallDriver(DeviceObject, Irp); 00264 return status; 00265 } 00266 if (Irp->Type != IO_TYPE_IRP) { 00267 KeBugCheckEx(DRIVER_VERIFIER_IOMANAGER_VIOLATION, 00268 IO_CALL_DRIVER_IRP_TYPE_INVALID, 00269 (ULONG_PTR)Irp, 00270 0, 00271 0); 00272 } 00273 if (!IovpValidateDeviceObject(DeviceObject)) { 00274 KeBugCheckEx(DRIVER_VERIFIER_IOMANAGER_VIOLATION, 00275 IO_CALL_DRIVER_INVALID_DEVICE_OBJECT, 00276 (ULONG_PTR)DeviceObject, 00277 0, 00278 0); 00279 } 00280 00281 saveIrql = KeGetCurrentIrql(); 00282 status = IopfCallDriver(DeviceObject, Irp); 00283 if (saveIrql != KeGetCurrentIrql()) { 00284 KeBugCheckEx(DRIVER_VERIFIER_IOMANAGER_VIOLATION, 00285 IO_CALL_DRIVER_IRQL_NOT_EQUAL, 00286 (ULONG_PTR)DeviceObject, 00287 saveIrql, 00288 KeGetCurrentIrql()); 00289 00290 } 00291 return status; 00292 }

VOID FASTCALL IovCompleteRequest IN PIRP  Irp,
IN CCHAR  PriorityBoost
 

Definition at line 297 of file ioverifier.c.

References _IRP::CancelRoutine, _IRP::CurrentLocation, DISPATCH_LEVEL, IO_COMPLETE_REQUEST_CANCEL_ROUTINE_SET, IO_COMPLETE_REQUEST_INVALID_IRQL, IO_COMPLETE_REQUEST_INVALID_STATUS, IO_TYPE_IRP, IopfCompleteRequest(), IopVerifierOn, _IRP::IoStatus, IovpVerifierLevel, IovSpecialIrpCompleteRequest(), Irp, KeBugCheckEx(), PriorityBoost, _IRP::StackCount, and _IRP::Type.

00301 { 00302 00303 if (!IopVerifierOn) { 00304 IopfCompleteRequest(Irp, PriorityBoost); 00305 return; 00306 } 00307 00308 if (IovpVerifierLevel > 1) { 00309 IovSpecialIrpCompleteRequest(Irp, PriorityBoost); 00310 return; 00311 } 00312 00313 if (Irp->CurrentLocation > (CCHAR) (Irp->StackCount + 1) || 00314 Irp->Type != IO_TYPE_IRP) { 00315 KeBugCheckEx( MULTIPLE_IRP_COMPLETE_REQUESTS, 00316 (ULONG_PTR) Irp, 00317 __LINE__, 00318 0, 00319 0); 00320 } 00321 00322 if (Irp->CancelRoutine) { 00323 KeBugCheckEx(DRIVER_VERIFIER_IOMANAGER_VIOLATION, 00324 IO_COMPLETE_REQUEST_CANCEL_ROUTINE_SET, 00325 (ULONG_PTR)Irp->CancelRoutine, 00326 (ULONG_PTR)Irp, 00327 0); 00328 } 00329 if (Irp->IoStatus.Status == STATUS_PENDING || Irp->IoStatus.Status == 0xffffffff) { 00330 KeBugCheckEx(DRIVER_VERIFIER_IOMANAGER_VIOLATION, 00331 IO_COMPLETE_REQUEST_INVALID_STATUS, 00332 Irp->IoStatus.Status, 00333 (ULONG_PTR)Irp, 00334 0); 00335 } 00336 if (KeGetCurrentIrql() > DISPATCH_LEVEL) { 00337 KeBugCheckEx(DRIVER_VERIFIER_IOMANAGER_VIOLATION, 00338 IO_COMPLETE_REQUEST_INVALID_IRQL, 00339 KeGetCurrentIrql(), 00340 (ULONG_PTR)Irp, 00341 0); 00342 00343 } 00344 IopfCompleteRequest(Irp, PriorityBoost); 00345 }

VOID IoVerifierInit IN ULONG  VerifierFlags,
IN ULONG  InitFlags
 

Definition at line 91 of file ioverifier.c.

References APC_LEVEL, ASSERT, DIAG_IGNORE_DRIVER_LIST, IopDcControlInitial, IopDcControlLock, IopDcControlOverride, IopDriverCorrectnessTakeLock(), IopVerifierOn, IovAllocateIrp(), IOVERIFIERINIT_PHASE0, IOVERIFIERINIT_VERIFIER_DRIVER_LIST, IoVerifierOnByDefault, IovFreeIrpPrivate(), IovpInitCalled, IovpInitIrpTracking(), IovpMaxSupportedVerifierLevel, IovpVerifierFlags, IovpVerifierLevel, IovSpecialIrpCallDriver(), IovSpecialIrpCompleteRequest(), KeInitializeSpinLock(), pIoAllocateIrp, pIofCallDriver, pIofCompleteRequest, pIoFreeIrp, and TRUE.

Referenced by IovpDoAssertIrps(), and MiInitializeDriverVerifierList().

00095 { 00096 PVOID sectionHeaderHandle; 00097 ULONG verifierLevel; 00098 00099 if (IoVerifierOnByDefault) { 00100 VerifierFlags |= DRIVER_VERIFIER_IO_CHECKING; 00101 } 00102 00103 if (!VerifierFlags) { 00104 return; 00105 } 00106 pIoAllocateIrp = IovAllocateIrp; 00107 00108 #ifndef NO_SPECIAL_IRP 00109 if (!(InitFlags & IOVERIFIERINIT_PHASE0)) { 00110 00111 // 00112 // Lock it down. 00113 // 00114 sectionHeaderHandle = MmLockPagableCodeSection(IopDriverCorrectnessTakeLock); 00115 00116 if (!sectionHeaderHandle) { 00117 00118 return; 00119 } 00120 } 00121 00122 // 00123 // Various initialization 00124 // 00125 if (IopDcControlOverride == (ULONG) -1) { 00126 00127 IopDcControlOverride = 0; 00128 } 00129 00130 if (IopDcControlInitial == (ULONG) -1) { 00131 00132 IopDcControlInitial = 0; 00133 if (!(InitFlags & IOVERIFIERINIT_VERIFIER_DRIVER_LIST)) { 00134 00135 IopDcControlInitial |= DIAG_IGNORE_DRIVER_LIST; 00136 } 00137 } 00138 00139 KeInitializeSpinLock(&IopDcControlLock) ; 00140 00141 #endif // NO_SPECIAL_IRP 00142 00143 if (!(VerifierFlags & DRIVER_VERIFIER_IO_CHECKING)) { 00144 00145 return; 00146 } 00147 00148 // 00149 // Determine the level of verification. Later we will modify the driver 00150 // verifier applet to pass in a level directly. 00151 // 00152 00153 #if !DBG 00154 if (IovpVerifierLevel > IovpMaxSupportedVerifierLevel) { 00155 IovpVerifierLevel = IovpMaxSupportedVerifierLevel; 00156 } 00157 #endif 00158 00159 verifierLevel = IovpVerifierLevel; 00160 00161 // 00162 // Enable and hook in the verifier. 00163 // 00164 IopVerifierOn = TRUE; 00165 IovpInitCalled = 1; 00166 IovpVerifierFlags = VerifierFlags; 00167 00168 if (verifierLevel > 1) { 00169 // 00170 // Initialize the special IRP code as appropriate. 00171 // 00172 #ifndef NO_SPECIAL_IRP 00173 IovpInitIrpTracking(verifierLevel, InitFlags); 00174 #endif // NO_SPECIAL_IRP 00175 InterlockedExchangePointer((PVOID *)&pIofCallDriver, (PVOID) IovSpecialIrpCallDriver); 00176 InterlockedExchangePointer((PVOID *)&pIofCompleteRequest, (PVOID) IovSpecialIrpCompleteRequest); 00177 InterlockedExchangePointer((PVOID *)&pIoFreeIrp, (PVOID) IovFreeIrpPrivate); 00178 } 00179 ASSERT(KeGetCurrentIrql() <= APC_LEVEL); 00180 }

NTKERNELAPI NTSTATUS IoVerifyVolume IN PDEVICE_OBJECT  DeviceObject,
IN BOOLEAN  AllowRawMount
 

Definition at line 11389 of file iosubs.c.

References ASSERT, _DEVICE_OBJECT::AttachedDevice, _VPB::DeviceObject, DO_VERIFY_VOLUME, Executive, FALSE, _IRP::Flags, _IO_STACK_LOCATION::Flags, IoAllocateIrp(), IoCallDriver, IoGetNextIrpStackLocation, IopCreateVpb(), IopMountVolume(), IRP_MJ_FILE_SYSTEM_CONTROL, IRP_MN_VERIFY_VOLUME, IRP_MOUNT_COMPLETION, IRP_SYNCHRONOUS_PAGING_IO, KeInitializeEvent, KernelMode, KeSetEvent(), KeWaitForSingleObject(), _IO_STACK_LOCATION::MajorFunction, _IO_STACK_LOCATION::MinorFunction, NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, _IO_STACK_LOCATION::Parameters, PoVolumeDevice(), PsGetCurrentThread, _IRP::RequestorMode, SL_ALLOW_RAW_MOUNT, _DEVICE_OBJECT::StackSize, _IRP::Tail, TRUE, _IRP::UserEvent, _IRP::UserIosb, VOID(), _DEVICE_OBJECT::Vpb, and VPB_MOUNTED.

Referenced by UdfPerformVerify().

11396 : 11397 11398 This routine is invoked to check a mounted volume on the specified device 11399 when it appears as if the media may have changed since it was last 11400 accessed. If the volume is not the same volume, and a new mount is not 11401 to be attempted, return the error. 11402 11403 If the verify fails, this routine is used to perform a new mount operation 11404 on the device. In this case, a "clean" VPB is allocated and a new mount 11405 operation is attempted. If no mount operation succeeds, then again the 11406 error handling described above occurs. 11407 11408 Arguments: 11409 11410 DeviceObject - Pointer to device object on which the volume is to be 11411 mounted. 11412 11413 AllowRawMount - Indicates that this verify is on behalf of a DASD open 11414 request, thus we want to allow a raw mount if the verify fails. 11415 11416 Return Value: 11417 11418 The function value is a successful status code if a volume was successfully 11419 mounted on the device. Otherwise, an error code is returned. 11420 11421 11422 --*/ 11423 11424 { 11425 NTSTATUS status; 11426 KEVENT event; 11427 PIRP irp; 11428 IO_STATUS_BLOCK ioStatus; 11429 PIO_STACK_LOCATION irpSp; 11430 BOOLEAN verifySkipped = FALSE; 11431 PDEVICE_OBJECT fsDeviceObject; 11432 11433 PAGED_CODE(); 11434 11435 // 11436 // Acquire the DeviceObject lock. Nothing in this routine can raise 11437 // so no try {} finally {} is required. 11438 // 11439 11440 status = KeWaitForSingleObject( &DeviceObject->DeviceLock, 11441 Executive, 11442 KernelMode, 11443 FALSE, 11444 (PLARGE_INTEGER) NULL ); 11445 11446 ASSERT( status == STATUS_SUCCESS ); 11447 11448 // 11449 // If this volume is not mounted by anyone, skip the verify operation, 11450 // but do the mount. 11451 // 11452 11453 if (!(DeviceObject->Vpb->Flags & VPB_MOUNTED)) { 11454 11455 verifySkipped = TRUE; 11456 11457 status = STATUS_SUCCESS; 11458 11459 } else { 11460 11461 // 11462 // This volume needs to be verified. Initialize the event to be 11463 // used while waiting for the operation to complete. 11464 // 11465 11466 KeInitializeEvent( &event, NotificationEvent, FALSE ); 11467 status = STATUS_UNSUCCESSFUL; 11468 11469 // 11470 // Allocate and initialize an IRP for this verify operation. Notice 11471 // that the flags for this operation appear the same as a page read 11472 // operation. This is because the completion code for both of the 11473 // operations is exactly the same logic. 11474 // 11475 11476 fsDeviceObject = DeviceObject->Vpb->DeviceObject; 11477 while (fsDeviceObject->AttachedDevice) { 11478 fsDeviceObject = fsDeviceObject->AttachedDevice; 11479 } 11480 irp = IoAllocateIrp( fsDeviceObject->StackSize, FALSE ); 11481 if (!irp) { 11482 11483 KeSetEvent( &DeviceObject->DeviceLock, 0, FALSE ); 11484 return STATUS_INSUFFICIENT_RESOURCES; 11485 } 11486 irp->Flags = IRP_MOUNT_COMPLETION | IRP_SYNCHRONOUS_PAGING_IO; 11487 irp->RequestorMode = KernelMode; 11488 irp->UserEvent = &event; 11489 irp->UserIosb = &ioStatus; 11490 irp->Tail.Overlay.Thread = PsGetCurrentThread(); 11491 irpSp = IoGetNextIrpStackLocation( irp ); 11492 irpSp->MajorFunction = IRP_MJ_FILE_SYSTEM_CONTROL; 11493 irpSp->MinorFunction = IRP_MN_VERIFY_VOLUME; 11494 irpSp->Flags = AllowRawMount ? SL_ALLOW_RAW_MOUNT : 0; 11495 irpSp->Parameters.VerifyVolume.Vpb = DeviceObject->Vpb; 11496 irpSp->Parameters.VerifyVolume.DeviceObject = DeviceObject->Vpb->DeviceObject; 11497 11498 status = IoCallDriver( fsDeviceObject, irp ); 11499 11500 // IopLoadFileSystemDriver 11501 // Wait for the I/O operation to complete. 11502 // 11503 11504 if (status == STATUS_PENDING) { 11505 (VOID) KeWaitForSingleObject( &event, 11506 Executive, 11507 KernelMode, 11508 FALSE, 11509 (PLARGE_INTEGER) NULL ); 11510 status = ioStatus.Status; 11511 } 11512 } 11513 11514 // 11515 // If the verify operation was skipped or unsuccessful perform a mount 11516 // operation. 11517 // 11518 11519 if ((status == STATUS_WRONG_VOLUME) || verifySkipped) { 11520 11521 // 11522 // A mount operation is to be attempted. Allocate a new VPB 11523 // for this device and attempt to mount it. Note that at this 11524 // point, allowing allocation of the VPB to fail is simply too 11525 // difficult to deal with, so if one cannot be allocated normally, 11526 // allocate one specifying that it must succeed. 11527 // 11528 11529 IopCreateVpb (DeviceObject); 11530 PoVolumeDevice (DeviceObject); 11531 11532 // 11533 // Now mount the volume. 11534 // 11535 11536 if (!NT_SUCCESS( IopMountVolume( DeviceObject, AllowRawMount, TRUE, FALSE ) )) { 11537 DeviceObject->Flags &= ~DO_VERIFY_VOLUME; 11538 } 11539 } 11540 11541 // 11542 // Release the device lock. 11543 // 11544 11545 KeSetEvent( &DeviceObject->DeviceLock, 0, FALSE ); 11546 11547 // 11548 // Return the status from the verify operation as the final status of 11549 // this function. 11550 // 11551 11552 return status; 11553 }

VOID IovFreeIrp IN PIRP  Irp  ) 
 

Definition at line 198 of file ioverifier.c.

References IovFreeIrpPrivate(), and Irp.

00201 { 00202 IovFreeIrpPrivate(Irp); 00203 }

NTSTATUS IovInitializeTimer IN PDEVICE_OBJECT  DeviceObject,
IN PIO_TIMER_ROUTINE  TimerRoutine,
IN PVOID  Context
 

Definition at line 524 of file ioverifier.c.

References IO_REINITIALIZING_TIMER_OBJECT, IoInitializeTimer(), KeBugCheckEx(), and NTSTATUS().

00529 { 00530 if (DeviceObject->Timer) { 00531 KeBugCheckEx(DRIVER_VERIFIER_IOMANAGER_VIOLATION, 00532 IO_REINITIALIZING_TIMER_OBJECT, 00533 (ULONG_PTR)DeviceObject, 00534 0, 00535 0); 00536 } 00537 return (IoInitializeTimer(DeviceObject, TimerRoutine, Context)); 00538 }

NTKERNELAPI NTSTATUS IoWMIAllocateInstanceIds IN GUID *  Guid,
IN ULONG  InstanceCount,
OUT ULONG *  FirstInstanceId
 

NTKERNELAPI NTSTATUS IoWMIRegistrationControl IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  Action
 

NTKERNELAPI NTSTATUS IoWMISuggestInstanceName IN PDEVICE_OBJECT PhysicalDeviceObject  OPTIONAL,
IN PUNICODE_STRING SymbolicLinkName  OPTIONAL,
IN BOOLEAN  CombineNames,
OUT PUNICODE_STRING  SuggestedInstanceName
 

NTKERNELAPI NTSTATUS IoWMIWriteEvent IN PVOID  WnodeEventItem  ) 
 

Referenced by IoepFireWMIEvent().

NTKERNELAPI BOOLEAN IoWriteCrashDump IN ULONG  BugCheckCode,
IN ULONG_PTR  BugCheckParameter1,
IN ULONG_PTR  BugCheckParameter2,
IN ULONG_PTR  BugCheckParameter3,
IN ULONG_PTR  BugCheckParameter4,
IN PVOID  Context
 

Definition at line 1519 of file dumpctl.c.

References ASSERT, _PHYSICAL_MEMORY_RUN::BasePage, BitMap, _DUMP_CONTROL_BLOCK::BuildNumber, _MDL::ByteCount, _MDL::ByteOffset, DCB_AUTO_REBOOT, DCB_DUMP_ENABLED, DCB_DUMP_HEADER_ENABLED, DCB_SUMMARY_DUMP_ENABLED, DCB_SUMMARY_ENABLED, DCB_TRIAGE_DUMP_ENABLED, _DUMP_CONTROL_BLOCK::DumpStack, EXCEPTION_NONCONTINUABLE, FALSE, _DUMP_CONTROL_BLOCK::FileDescriptorArray, _DUMP_CONTROL_BLOCK::Flags, HalRebootRoutine, _DUMP_CONTROL_BLOCK::HeaderPage, _DUMP_CONTROL_BLOCK::HeaderPfn, _DUMP_CONTROL_BLOCK::HeaderSize, InbvDisplayString(), IO_DUMP_MAXIMUM_TRANSFER_SIZE, IO_DUMP_MINIMUM_TRANSFER_SIZE, IoDebugPrint, IoInitializeDumpStack(), IopDumpControlBlock, IopDumpControlBlockChecksum, IopFinalCrashDumpStatus, IopGetDumpControlBlockCheck(), IopInitializeDumpSpaceAndType(), IopInitializeSummaryDump(), IopMapPhysicalMemory(), IopWriteSummaryDump(), IopWriteSummaryHeader(), IopWriteTriageDump(), KdGetDataBlock(), KeGetCurrentThread, KeReturnToFirmware(), _DUMP_CONTROL_BLOCK::MajorVersion, _MDL::MappedSystemVa, MDL_MAPPED_TO_SYSTEM_VA, MDL_PAGES_LOCKED, _MDL::MdlFlags, _DUMP_CONTROL_BLOCK::MemoryDescriptor, _DUMP_CONTROL_BLOCK::MinorVersion, MmCreateMdl(), MmGetMdlPfnArray, MmPfnDatabase, NT_SUCCESS, NTSTATUS(), NULL, _PHYSICAL_MEMORY_DESCRIPTOR::NumberOfPages, _PHYSICAL_MEMORY_DESCRIPTOR::NumberOfRuns, _DUMP_CONTROL_BLOCK::NumberProcessors, PAGE_ALIGN, PAGE_SIZE, PDUMP_DRIVER_FINISH, PDUMP_DRIVER_WRITE, PDUMP_STACK_CONTEXT, PHYSICAL_MEMORY_DESCRIPTOR, PsActiveProcessHead, PsLoadedModuleList, _PHYSICAL_MEMORY_DESCRIPTOR::Run, sprintf(), _MDL::StartVa, _DUMP_CONTROL_BLOCK::TriageDumpBuffer, _DUMP_CONTROL_BLOCK::TriageDumpBufferSize, _DUMP_CONTROL_BLOCK::TriageDumpFlags, TRUE, and _DUMP_CONTROL_BLOCK::VersionUser.

Referenced by KeBugCheckEx().

01530 : 01531 01532 This routine checks to see whether or not crash dumps are enabled and, if 01533 so, writes all of physical memory to the system disk's paging file. 01534 01535 Arguments: 01536 01537 BugCheckCode/ParameterN - Code and parameters w/which BugCheck was called. 01538 01539 Return Value: 01540 01541 None. 01542 01543 --*/ 01544 01545 { 01546 PDUMP_CONTROL_BLOCK dcb; 01547 PDUMP_STACK_CONTEXT dumpStack; 01548 PDUMP_DRIVER_WRITE write; 01549 PDUMP_DRIVER_FINISH finishUp; 01550 PDUMP_HEADER header; 01551 EXCEPTION_RECORD exception; 01552 PCONTEXT context = ContextSave; 01553 PULONG block; 01554 LARGE_INTEGER diskByteOffset; 01555 PPFN_NUMBER page; 01556 PFN_NUMBER localMdl[(sizeof( MDL )/sizeof(PFN_NUMBER)) + 17]; 01557 PMDL mdl; 01558 PLARGE_INTEGER mcb; 01559 ULONG_PTR memoryAddress; 01560 ULONG byteOffset; 01561 ULONG byteCount; 01562 ULONG bytesRemaining; 01563 NTSTATUS status; 01564 UCHAR messageBuffer[128]; 01565 PFN_NUMBER ActualPages; 01566 PSUMMARY_DUMP_HEADER pSummaryHeader; 01567 ULONG dwTransferSize; 01568 LARGE_INTEGER requiredDumpSpace; 01569 ULONG_PTR DirBasePage; 01570 01571 // 01572 // Begin by determining whether or not crash dumps are enabled. If not, 01573 // check to see whether or not auto-rebooting is enabled. If not, return 01574 // immediately since there is nothing to do. 01575 // 01576 01577 dcb = IopDumpControlBlock; 01578 if (!dcb) { 01579 return FALSE; 01580 } 01581 01582 if (dcb->Flags & DCB_DUMP_ENABLED || dcb->Flags & DCB_SUMMARY_ENABLED) { 01583 01584 IopFinalCrashDumpStatus = STATUS_PENDING; 01585 01586 // 01587 // A dump is to be written to the paging file. Ensure that all of the 01588 // descriptor data for what needs to be done is valid, otherwise it 01589 // could be that part of the reason for the bugcheck is that this data 01590 // was corrupted. Or, it could be that no paging file was found yet, 01591 // or any number of other situations. 01592 // 01593 01594 if (IopGetDumpControlBlockCheck(dcb) != IopDumpControlBlockChecksum) { 01595 IoDebugPrint (( 0, 01596 "CRASHDUMP: Disk dump routine returning due to DCB integrity error\n" 01597 " No dump will be created\n" )); 01598 IopFinalCrashDumpStatus = STATUS_UNSUCCESSFUL; 01599 return FALSE; 01600 } 01601 01602 // 01603 // Message that we are starting the crashdump 01604 // 01605 01606 dumpStack = dcb->DumpStack; 01607 sprintf( messageBuffer, "%Z\n", &dumpStack->InitMsg ); 01608 01609 // 01610 // Initialize the dump stack 01611 // 01612 01613 status = IoInitializeDumpStack (dumpStack, messageBuffer); 01614 if (!NT_SUCCESS( status )) { 01615 IopFinalCrashDumpStatus = STATUS_UNSUCCESSFUL; 01616 return FALSE; 01617 } 01618 01619 // 01620 // Record the dump driver's entry points. 01621 // 01622 01623 write = dumpStack->Init.WriteRoutine; 01624 finishUp = dumpStack->Init.FinishRoutine; 01625 01626 01627 dwTransferSize = dumpStack->Init.MaximumTransferSize; 01628 01629 if ( ( !dwTransferSize ) || ( dwTransferSize > IO_DUMP_MAXIMUM_TRANSFER_SIZE ) ) { 01630 dwTransferSize = IO_DUMP_MINIMUM_TRANSFER_SIZE; 01631 } 01632 01633 IoDebugPrint((2,"CRASHDUMP: Maximum Transfer Size = %x\n",dwTransferSize)); 01634 01635 01636 // 01637 // The boot partition was found, so put together a dump file header 01638 // and write it to the disk. 01639 // 01640 01641 block = dcb->HeaderPage; 01642 header = (PDUMP_HEADER) block; 01643 01644 RtlFillMemoryUlong( header, PAGE_SIZE, 'EGAP' ); 01645 header->ValidDump = 'PMUD'; 01646 header->BugCheckCode = BugCheckCode; 01647 header->BugCheckParameter1 = BugCheckParameter1; 01648 header->BugCheckParameter2 = BugCheckParameter2; 01649 header->BugCheckParameter3 = BugCheckParameter3; 01650 header->BugCheckParameter4 = BugCheckParameter4; 01651 #if defined (i386) 01652 // 01653 // Add the current page directory table page - don't use the directory 01654 // table base for the crashing process as we have switched cr3 on 01655 // stack overflow crashes, etc. 01656 // 01657 01658 _asm { 01659 mov eax, cr3 01660 mov DirBasePage, eax 01661 } 01662 header->DirectoryTableBase = DirBasePage; 01663 #else 01664 header->DirectoryTableBase = KeGetCurrentThread()->ApcState.Process->DirectoryTableBase[0]; 01665 #endif 01666 header->PfnDataBase = MmPfnDatabase; 01667 header->PsLoadedModuleList = &PsLoadedModuleList; 01668 header->PsActiveProcessHead = &PsActiveProcessHead; 01669 header->NumberProcessors = dcb->NumberProcessors; 01670 header->MajorVersion = dcb->MajorVersion; 01671 header->MinorVersion = dcb->MinorVersion; 01672 header->KdDebuggerDataBlock = KdGetDataBlock(); 01673 header->PaeEnabled = PaeEnabled (); 01674 01675 header->MachineImageType = CURRENT_IMAGE_TYPE (); 01676 01677 if (!(dcb->Flags & DCB_DUMP_ENABLED)) { 01678 dcb->MemoryDescriptor->NumberOfPages = 1; 01679 } 01680 01681 strcpy( header->VersionUser, dcb->VersionUser ); 01682 01683 RtlCopyMemory( &block[DH_PHYSICAL_MEMORY_BLOCK], 01684 dcb->MemoryDescriptor, 01685 sizeof( PHYSICAL_MEMORY_DESCRIPTOR ) + 01686 ((dcb->MemoryDescriptor->NumberOfRuns - 1) * 01687 sizeof( PHYSICAL_MEMORY_RUN )) ); 01688 01689 RtlCopyMemory( &block[DH_CONTEXT_RECORD], 01690 context, 01691 sizeof( CONTEXT ) ); 01692 01693 exception.ExceptionCode = STATUS_BREAKPOINT; 01694 exception.ExceptionRecord = (PEXCEPTION_RECORD) NULL; 01695 exception.NumberParameters = 0; 01696 exception.ExceptionFlags = EXCEPTION_NONCONTINUABLE; 01697 exception.ExceptionAddress = (PVOID) PROGRAM_COUNTER (context); 01698 01699 RtlCopyMemory( &block[DH_EXCEPTION_RECORD], 01700 &exception, 01701 sizeof( EXCEPTION_RECORD ) ); 01702 01703 // 01704 // Init dump type to FULL 01705 // 01706 01707 block[DH_DUMP_TYPE] = DUMP_TYPE_FULL; 01708 01709 // 01710 // Set the timestamp 01711 // 01712 #ifdef _WIN64 01713 RtlCopyMemory( &block[DH_CRASH_DUMP_TIMESTAMP], 01714 (PCHAR)( &SharedUserData->SystemLowTime), 01715 sizeof( LARGE_INTEGER) ); 01716 #else 01717 RtlCopyMemory( &block[DH_CRASH_DUMP_TIMESTAMP], 01718 (PCHAR)( &SharedUserData->SystemTime), 01719 sizeof( LARGE_INTEGER) ); 01720 #endif 01721 01722 // 01723 // Set the Required dump size in the dump header. In the case of 01724 // a summary dump the file allocation size can be significantly larger 01725 // then the amount of used space. 01726 // 01727 01728 RtlZeroMemory( &block[DH_REQUIRED_DUMP_SPACE], sizeof(LARGE_INTEGER)); 01729 01730 if (dcb->Flags & DCB_DUMP_ENABLED) { 01731 01732 // 01733 // If summary dump try to create the dump header 01734 // 01735 01736 if ( (dcb->Flags & DCB_SUMMARY_DUMP_ENABLED) ) { 01737 01738 // 01739 // Initialize the summary dump 01740 // 01741 01742 pSummaryHeader = IopInitializeSummaryDump(dcb); 01743 01744 if ( !pSummaryHeader ) { 01745 01746 // 01747 // No summary dump header so return. 01748 // 01749 01750 IoDebugPrint((1,"IoWriteCrashDump: Error Null summary dump header\n")); 01751 01752 IopFinalCrashDumpStatus = STATUS_UNSUCCESSFUL; 01753 01754 return FALSE; 01755 } 01756 } 01757 01758 IopInitializeDumpSpaceAndType (dcb, block, pSummaryHeader); 01759 } 01760 01761 // 01762 // All of the pieces of the header file have been generated. Before 01763 // mapping or writing anything to the disk, the I- & D-stream caches 01764 // must be flushed so that page color coherency is kept. Sweep both 01765 // caches now. 01766 // 01767 01768 KeSweepCurrentDcache(); 01769 KeSweepCurrentIcache(); 01770 01771 // 01772 // Create MDL for dump. 01773 // 01774 01775 mdl = (PMDL) &localMdl[0]; 01776 MmCreateMdl( mdl, NULL, PAGE_SIZE ); 01777 mdl->MdlFlags |= MDL_PAGES_LOCKED; 01778 01779 mcb = dcb->FileDescriptorArray; 01780 01781 page = MmGetMdlPfnArray(mdl); 01782 *page = dcb->HeaderPfn; 01783 mdl->MdlFlags |= MDL_MAPPED_TO_SYSTEM_VA; 01784 01785 bytesRemaining = PAGE_SIZE; 01786 memoryAddress = (ULONG_PTR) dcb->HeaderPage; 01787 01788 // 01789 // All of the pieces of the header file have been generated. Write 01790 // the header page to the paging file, using the appropriate drivers, 01791 // etc. 01792 // 01793 01794 IoDebugPrint((2,"IoWriteCrashDump: Writing dump header to disk\n")); 01795 01796 while (bytesRemaining) { 01797 01798 if (mcb[0].QuadPart <= bytesRemaining) { 01799 byteCount = mcb[0].LowPart; 01800 } else { 01801 byteCount = bytesRemaining; 01802 } 01803 01804 mdl->ByteCount = byteCount; 01805 mdl->ByteOffset = (ULONG)(memoryAddress & (PAGE_SIZE - 1)); 01806 mdl->MappedSystemVa = (PVOID) memoryAddress; 01807 mdl->StartVa = PAGE_ALIGN ((PVOID)memoryAddress); 01808 01809 // 01810 // Write to disk. 01811 // 01812 01813 if (!NT_SUCCESS( write( &mcb[1], mdl ) )) { 01814 IopFinalCrashDumpStatus = STATUS_UNSUCCESSFUL; 01815 return FALSE; 01816 } 01817 01818 // 01819 // Adjust bytes remaining. 01820 // 01821 01822 bytesRemaining -= byteCount; 01823 memoryAddress += byteCount; 01824 mcb[0].QuadPart = mcb[0].QuadPart - byteCount; 01825 mcb[1].QuadPart = mcb[1].QuadPart + byteCount; 01826 01827 if (!mcb[0].QuadPart) { 01828 mcb += 2; 01829 } 01830 } 01831 01832 IoDebugPrint((2,"IoWriteCrashDump: Header Page written\n")); 01833 01834 01835 // 01836 // If only requesting a header dump, we are now done. 01837 // 01838 01839 if (dcb->Flags & DCB_DUMP_HEADER_ENABLED) { 01840 IoDebugPrint((2,"IoWriteCrashDump: Only Dumping Dump Header\n")); 01841 goto FinishDump; 01842 } 01843 01844 // 01845 // The header page has been written. If this is a triage-dump, write 01846 // the dump information and bail. Otherwise, fall through and do the 01847 // full or summary dump. 01848 // 01849 01850 if (dcb->Flags & DCB_TRIAGE_DUMP_ENABLED) { 01851 status = IopWriteTriageDump (dcb->TriageDumpFlags, 01852 write, 01853 mcb, 01854 mdl, 01855 dwTransferSize, 01856 context, 01857 dcb->TriageDumpBuffer, 01858 dcb->TriageDumpBufferSize - PAGE_SIZE, 01859 dcb->BuildNumber, 01860 dcb->Flags 01861 ); 01862 01863 if (!NT_SUCCESS (status)) { 01864 IoDebugPrint((1, "IoWriteCrashDump: Failed to write triage-dump\n")); 01865 IopFinalCrashDumpStatus = STATUS_UNSUCCESSFUL; 01866 return FALSE; 01867 } 01868 01869 IoDebugPrint((1, "IoWriteCrashDump: Successfully wrote triage-dump\n")); 01870 goto FinishDump; 01871 } 01872 01873 // 01874 // The header page has been written to the paging file. If a full dump 01875 // of all of physical memory is to be written, write it now. 01876 // 01877 01878 if (dcb->Flags & DCB_DUMP_ENABLED) { 01879 01880 PFN_NUMBER pagesDoneSoFar = 0; 01881 ULONG currentPercentage = 0; 01882 ULONG maximumPercentage = 0; 01883 01884 01885 // 01886 // Actual Pages is the number of pages to dump. 01887 // 01888 01889 ActualPages = dcb->MemoryDescriptor->NumberOfPages; 01890 01891 if (dcb->Flags & DCB_SUMMARY_DUMP_ENABLED) { 01892 01893 PRTL_BITMAP PageMap; 01894 01895 ASSERT ( pSummaryHeader != NULL ); 01896 01897 PageMap = (PRTL_BITMAP)(pSummaryHeader + 1); 01898 ASSERT (PageMap != NULL); 01899 01900 // 01901 // At this point the dump header header has been sucessfully 01902 // written. Write the summary dump header. 01903 // 01904 01905 status = IopWriteSummaryHeader( 01906 pSummaryHeader, 01907 write, 01908 &mcb, 01909 mdl, 01910 dwTransferSize, 01911 (dcb->HeaderSize - PAGE_SIZE) 01912 ); 01913 01914 if (!NT_SUCCESS (status)) { 01915 IoDebugPrint((1,"IoWriteCrashDump: Error writing summary dump header\n")); 01916 IopFinalCrashDumpStatus = status; 01917 return FALSE; 01918 } 01919 01920 IoDebugPrint((2,"IoWriteCrashDump: Sucessfully wrote summary dump header\n")); 01921 01922 ActualPages = pSummaryHeader->Pages; 01923 01924 } 01925 01926 IoDebugPrint((2,"IoWriteCrashDump: Writing Memory Dump\n")); 01927 01928 // 01929 // Set the virtual file offset and initialize loop variables and 01930 // constants. 01931 // 01932 01933 memoryAddress = (ULONG_PTR)dcb->MemoryDescriptor->Run[0].BasePage * PAGE_SIZE; 01934 01935 if ( dcb->Flags & DCB_SUMMARY_DUMP_ENABLED ) { 01936 01937 PRTL_BITMAP BitMap; 01938 01939 BitMap = (PRTL_BITMAP)(pSummaryHeader+1); 01940 01941 status = IopWriteSummaryDump ( 01942 BitMap, 01943 write, 01944 &dumpStack->ProgMsg, 01945 messageBuffer, 01946 mcb, 01947 dwTransferSize 01948 ); 01949 01950 if (!NT_SUCCESS (status)) { 01951 IoDebugPrint((1, "IoWriteCrashDump: Failed to write triage-dump\n")); 01952 IopFinalCrashDumpStatus = STATUS_UNSUCCESSFUL; 01953 return FALSE; 01954 } 01955 01956 IoDebugPrint((1, "IoWriteCrashDump: Successfully wrote triage-dump\n")); 01957 goto FinishDump; 01958 } 01959 01960 // 01961 // Now loop, writing all of physical memory to the paging file. 01962 // 01963 01964 while (mcb[0].QuadPart) { 01965 01966 diskByteOffset = mcb[1]; 01967 01968 // 01969 // Calculate byte offset; 01970 // 01971 01972 byteOffset = (ULONG)(memoryAddress & (PAGE_SIZE - 1)); 01973 01974 if (dwTransferSize <= mcb[0].QuadPart) { 01975 byteCount = dwTransferSize - byteOffset; 01976 } else { 01977 byteCount = mcb[0].LowPart; 01978 } 01979 pagesDoneSoFar += byteCount / PAGE_SIZE; 01980 01981 currentPercentage = (ULONG)((pagesDoneSoFar * 100) / 01982 ActualPages); 01983 01984 if (currentPercentage > maximumPercentage) { 01985 01986 maximumPercentage = currentPercentage; 01987 // 01988 // Update message on screen. 01989 // 01990 01991 sprintf( messageBuffer, "%Z: %3d\r", &dumpStack->ProgMsg, maximumPercentage ); 01992 InbvDisplayString( messageBuffer ); 01993 01994 } 01995 01996 // 01997 // Map the physical memory and write it to the 01998 // current segment of the file. 01999 // 02000 02001 IopMapPhysicalMemory( mdl, 02002 memoryAddress, 02003 &dcb->MemoryDescriptor->Run[0], 02004 byteCount 02005 ); 02006 02007 02008 // 02009 // Write the next segment. 02010 // 02011 02012 if (!NT_SUCCESS( write( &diskByteOffset, mdl ) )) { 02013 IopFinalCrashDumpStatus = STATUS_UNSUCCESSFUL; 02014 return FALSE; 02015 } 02016 02017 // 02018 // Adjust pointers for next part. 02019 // 02020 02021 memoryAddress += byteCount; 02022 mcb[0].QuadPart = mcb[0].QuadPart - byteCount; 02023 mcb[1].QuadPart = mcb[1].QuadPart + byteCount; 02024 02025 if (!mcb[0].QuadPart) { 02026 mcb += 2; 02027 } 02028 02029 if (pagesDoneSoFar >= ActualPages) { 02030 break; 02031 02032 } 02033 02034 } 02035 02036 IoDebugPrint((2,"IoWriteCrashDump: memory dump written\n")); 02037 } 02038 02039 FinishDump: 02040 02041 sprintf( messageBuffer, "%Z", &dumpStack->DoneMsg ); 02042 InbvDisplayString( messageBuffer ); 02043 02044 // 02045 // Sweep the cache so the debugger will work. 02046 // 02047 02048 KeSweepCurrentDcache(); 02049 KeSweepCurrentIcache(); 02050 02051 // 02052 // Have the dump flush the adapter and disk caches. 02053 // 02054 02055 finishUp(); 02056 02057 // 02058 // Indicate to the debugger that the dump has been successfully 02059 // written. 02060 // 02061 02062 IopFinalCrashDumpStatus = STATUS_SUCCESS; 02063 } 02064 02065 // 02066 // Check to see whether or not auto-reboots are enabled and, if so, 02067 // reboot now. 02068 // 02069 02070 if (dcb->Flags & DCB_AUTO_REBOOT) { 02071 IoDebugPrint (( 0, "IODUMP: Autorebooting\n" )); 02072 KeReturnToFirmware( HalRebootRoutine ); 02073 } 02074 02075 return TRUE; 02076 }

NTKERNELAPI VOID IoWriteErrorLogEntry IN PVOID  ElEntry  ) 
 

NTKERNELAPI BOOLEAN WMIInitialize  ) 
 

Referenced by IoInitSystem().


Variable Documentation

ULONG IoOtherOperationCount
 

Definition at line 2595 of file io.h.

Referenced by IopUpdateOtherOperationCount(), and NtQuerySystemInformation().

LARGE_INTEGER IoOtherTransferCount
 

Definition at line 2598 of file io.h.

Referenced by IopUpdateOtherTransferCount(), and NtQuerySystemInformation().

ULONG IoReadOperationCount
 

Definition at line 2593 of file io.h.

Referenced by IopUpdateReadOperationCount(), and NtQuerySystemInformation().

LARGE_INTEGER IoReadTransferCount
 

Definition at line 2596 of file io.h.

Referenced by IopUpdateReadTransferCount(), and NtQuerySystemInformation().

BOOLEAN IoRemoteBootClient
 

Definition at line 4577 of file io.h.

Referenced by ExpWorkerThread(), IoInitSystem(), IopCreateArcNames(), IopInitializeBootDrivers(), IopProcessNewDeviceNode(), MiEnablePagingTheExecutive(), ObpProcessDosDeviceSymbolicLink(), and xHalIoAssignDriveLetters().

KSPIN_LOCK IoStatisticsLock
 

Definition at line 2592 of file io.h.

Referenced by IoInitSystem().

ULONG IoWriteOperationCount
 

Definition at line 2594 of file io.h.

Referenced by IopUpdateWriteOperationCount(), and NtQuerySystemInformation().

LARGE_INTEGER IoWriteTransferCount
 

Definition at line 2597 of file io.h.

Referenced by IopUpdateWriteTransferCount(), and NtQuerySystemInformation().


Generated on Sat May 15 19:44:17 2004 for test by doxygen 1.3.7