ReactOS  0.4.14-dev-604-gcfdd483
io.h File Reference
#include "ntdddisk.h"
#include "io_x.h"
Include dependency graph for io.h:

Go to the source code of this file.

Classes

struct  _FILE_OBJECT_EXTENSION
 
struct  _IOP_MINI_COMPLETION_PACKET
 
struct  _IO_UNLOAD_SAFE_COMPLETION_CONTEXT
 
struct  _IO_WORKITEM
 
struct  _IO_INTERRUPT
 
struct  _ERROR_LOG_ENTRY
 
struct  _EXTENDED_IO_REMOVE_LOCK
 
struct  _DUMMY_FILE_OBJECT
 
struct  _OPEN_PACKET
 
struct  _LOAD_UNLOAD_PARAMS
 
struct  _DRIVER_INFORMATION
 
struct  _BOOT_DRIVER_NODE
 
struct  _IO_BUS_TYPE_GUID_LIST
 
struct  _SHUTDOWN_ENTRY
 
struct  _FS_CHANGE_NOTIFY_ENTRY
 
struct  _DRIVER_REINIT_ITEM
 
struct  _DEVICETREE_TRAVERSE_CONTEXT
 
struct  _RESERVE_IRP_ALLOCATOR
 

Macros

#define _IO_DEBUG_   0x00
 
#define IO_IRP_DEBUG   0x01
 
#define IO_FILE_DEBUG   0x02
 
#define IO_API_DEBUG   0x04
 
#define IO_CTL_DEBUG   0x08
 
#define IOTRACE(x, fmt, ...)   DPRINT(fmt, ##__VA_ARGS__)
 
#define ENUM_ROOT   L"\\Registry\\Machine\\System\\CurrentControlSet\\Enum"
 
#define IO_METHOD_FROM_CTL_CODE(c)   (c & 0x00000003)
 
#define RD_NO_XIPROM_DESCRIPTOR   1
 
#define RD_NO_RAMDISK_DRIVER   2
 
#define RD_FSCTL_FAILED   3
 
#define RD_GUID_CONVERT_FAILED   4
 
#define RD_SYMLINK_CREATE_FAILED   5
 
#define IOP_MAX_REPARSE_TRAVERSAL   0x20
 
#define IOP_USE_TOP_LEVEL_DEVICE_HINT   0x01
 
#define IOP_CREATE_FILE_OBJECT_EXTENSION   0x02
 
#define IopAllocateMdlFromLookaside   ObpAllocateObjectCreateInfoBuffer
 
#define IopFreeMdlFromLookaside   ObpFreeCapturedAttributes
 
#define IsIrpSynchronous(Irp, FileObject)
 
#define IoGetDevObjExtension(DeviceObject)
 
#define IoGetDrvObjExtension(DriverObject)
 
#define IopDeviceNodeSetFlag(DeviceNode, Flag)   ((DeviceNode)->Flags |= (Flag))
 
#define IopDeviceNodeClearFlag(DeviceNode, Flag)   ((DeviceNode)->Flags &= ~(Flag))
 
#define IopDeviceNodeHasFlag(DeviceNode, Flag)   (((DeviceNode)->Flags & (Flag)) > 0)
 
#define IopDeviceNodeSetUserFlag(DeviceNode, UserFlag)   ((DeviceNode)->UserFlags |= (UserFlag))
 
#define IopDeviceNodeClearUserFlag(DeviceNode, UserFlag)   ((DeviceNode)->UserFlags &= ~(UserFlag))
 
#define IopDeviceNodeHasUserFlag(DeviceNode, UserFlag)   (((DeviceNode)->UserFlags & (UserFlag)) > 0)
 
#define IopDeviceNodeSetProblem(DeviceNode, Problem)   ((DeviceNode)->Problem |= (Problem))
 
#define IopDeviceNodeClearProblem(DeviceNode, Problem)   ((DeviceNode)->Problem &= ~(Problem))
 
#define IopDeviceNodeHasProblem(DeviceNode, Problem)   (((DeviceNode)->Problem & (Problem)) > 0)
 
#define IopInitDeviceTreeTraverseContext( _DeviceTreeTraverseContext, _DeviceNode, _Action, _Context)
 
#define IopIsValidPhysicalDeviceObject(PhysicalDeviceObject)
 

Typedefs

typedef struct _FILE_OBJECT_EXTENSION FILE_OBJECT_EXTENSION
 
typedef struct _FILE_OBJECT_EXTENSIONPFILE_OBJECT_EXTENSION
 
typedef enum _IOP_DEVICE_LIST_OPERATION IOP_DEVICE_LIST_OPERATION
 
typedef enum _IOP_DEVICE_LIST_OPERATIONPIOP_DEVICE_LIST_OPERATION
 
typedef enum _IOP_TRANSFER_TYPE IOP_TRANSFER_TYPE
 
typedef enum _IOP_TRANSFER_TYPEPIOP_TRANSFER_TYPE
 
typedef enum _COMPLETION_PACKET_TYPE COMPLETION_PACKET_TYPE
 
typedef enum _COMPLETION_PACKET_TYPEPCOMPLETION_PACKET_TYPE
 
typedef struct _IOP_MINI_COMPLETION_PACKET IOP_MINI_COMPLETION_PACKET
 
typedef struct _IOP_MINI_COMPLETION_PACKETPIOP_MINI_COMPLETION_PACKET
 
typedef struct _IO_UNLOAD_SAFE_COMPLETION_CONTEXT IO_UNLOAD_SAFE_COMPLETION_CONTEXT
 
typedef struct _IO_UNLOAD_SAFE_COMPLETION_CONTEXTPIO_UNLOAD_SAFE_COMPLETION_CONTEXT
 
typedef struct _IO_WORKITEM IO_WORKITEM
 
typedef struct _IO_INTERRUPT IO_INTERRUPT
 
typedef struct _IO_INTERRUPTPIO_INTERRUPT
 
typedef struct _ERROR_LOG_ENTRY ERROR_LOG_ENTRY
 
typedef struct _ERROR_LOG_ENTRYPERROR_LOG_ENTRY
 
typedef struct _EXTENDED_IO_REMOVE_LOCK EXTENDED_IO_REMOVE_LOCK
 
typedef struct _EXTENDED_IO_REMOVE_LOCKPEXTENDED_IO_REMOVE_LOCK
 
typedef struct _DUMMY_FILE_OBJECT DUMMY_FILE_OBJECT
 
typedef struct _DUMMY_FILE_OBJECTPDUMMY_FILE_OBJECT
 
typedef struct _OPEN_PACKET OPEN_PACKET
 
typedef struct _OPEN_PACKETPOPEN_PACKET
 
typedef struct _LOAD_UNLOAD_PARAMS LOAD_UNLOAD_PARAMS
 
typedef struct _LOAD_UNLOAD_PARAMSPLOAD_UNLOAD_PARAMS
 
typedef struct _DRIVER_INFORMATION DRIVER_INFORMATION
 
typedef struct _DRIVER_INFORMATIONPDRIVER_INFORMATION
 
typedef struct _BOOT_DRIVER_NODE BOOT_DRIVER_NODE
 
typedef struct _BOOT_DRIVER_NODEPBOOT_DRIVER_NODE
 
typedef struct _IO_BUS_TYPE_GUID_LIST IO_BUS_TYPE_GUID_LIST
 
typedef struct _IO_BUS_TYPE_GUID_LISTPIO_BUS_TYPE_GUID_LIST
 
typedef struct _SHUTDOWN_ENTRY SHUTDOWN_ENTRY
 
typedef struct _SHUTDOWN_ENTRYPSHUTDOWN_ENTRY
 
typedef struct _FS_CHANGE_NOTIFY_ENTRY FS_CHANGE_NOTIFY_ENTRY
 
typedef struct _FS_CHANGE_NOTIFY_ENTRYPFS_CHANGE_NOTIFY_ENTRY
 
typedef struct _DRIVER_REINIT_ITEM DRIVER_REINIT_ITEM
 
typedef struct _DRIVER_REINIT_ITEMPDRIVER_REINIT_ITEM
 
typedef NTSTATUS(* DEVICETREE_TRAVERSE_ROUTINE) (IN PDEVICE_NODE DeviceNode, IN PVOID Context)
 
typedef struct _DEVICETREE_TRAVERSE_CONTEXT DEVICETREE_TRAVERSE_CONTEXT
 
typedef struct _DEVICETREE_TRAVERSE_CONTEXTPDEVICETREE_TRAVERSE_CONTEXT
 
typedef struct _RESERVE_IRP_ALLOCATOR RESERVE_IRP_ALLOCATOR
 
typedef struct _RESERVE_IRP_ALLOCATORPRESERVE_IRP_ALLOCATOR
 
typedef enum _SECURITY_DESCRIPTOR_TYPE SECURITY_DESCRIPTOR_TYPE
 
typedef enum _SECURITY_DESCRIPTOR_TYPEPSECURITY_DESCRIPTOR_TYPE
 

Enumerations

enum  _IOP_DEVICE_LIST_OPERATION { IopRemove, IopAdd }
 
enum  _IOP_TRANSFER_TYPE { IopReadTransfer, IopWriteTransfer, IopOtherTransfer }
 
enum  _COMPLETION_PACKET_TYPE { IopCompletionPacketIrp, IopCompletionPacketMini, IopCompletionPacketQuota }
 
enum  _SECURITY_DESCRIPTOR_TYPE {
  RestrictedPublic = 1, UnrestrictedPublic, RestrictedPublicOpen, UnrestrictedPublicOpen,
  SystemDefault
}
 

Functions

ULONG NTAPI PnpDetermineResourceListSize (IN PCM_RESOURCE_LIST ResourceList)
 
NTSTATUS NTAPI IopAssignDeviceResources (IN PDEVICE_NODE DeviceNode)
 
NTSTATUS NTAPI IopFixupResourceListWithRequirements (IN PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList, OUT PCM_RESOURCE_LIST *ResourceList)
 
NTSTATUS NTAPI IopDetectResourceConflict (IN PCM_RESOURCE_LIST ResourceList, IN BOOLEAN Silent, OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
 
NTSTATUS NTAPI PipCallDriverAddDevice (IN PDEVICE_NODE DeviceNode, IN BOOLEAN LoadDriver, IN PDRIVER_OBJECT DriverObject)
 
INIT_FUNCTION NTSTATUS NTAPI IopInitializePlugPlayServices (VOID)
 
BOOLEAN NTAPI PpInitSystem (VOID)
 
VOID PnpInit2 (VOID)
 
VOID IopInitDriverImplementation (VOID)
 
VOID IopInitPnpNotificationImplementation (VOID)
 
VOID IopNotifyPlugPlayNotification (IN PDEVICE_OBJECT DeviceObject, IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory, IN LPCGUID Event, IN PVOID EventCategoryData1, IN PVOID EventCategoryData2)
 
NTSTATUS IopGetSystemPowerDeviceObject (IN PDEVICE_OBJECT *DeviceObject)
 
PDEVICE_NODE NTAPI PipAllocateDeviceNode (IN PDEVICE_OBJECT PhysicalDeviceObject)
 
NTSTATUS IopCreateDeviceNode (IN PDEVICE_NODE ParentNode, IN PDEVICE_OBJECT PhysicalDeviceObject, IN PUNICODE_STRING ServiceName, OUT PDEVICE_NODE *DeviceNode)
 
NTSTATUS IopFreeDeviceNode (IN PDEVICE_NODE DeviceNode)
 
NTSTATUS NTAPI IopQueryDeviceCapabilities (PDEVICE_NODE DeviceNode, PDEVICE_CAPABILITIES DeviceCaps)
 
NTSTATUS NTAPI IopSynchronousCall (IN PDEVICE_OBJECT DeviceObject, IN PIO_STACK_LOCATION IoStackLocation, OUT PVOID *Information)
 
NTSTATUS NTAPI IopInitiatePnpIrp (IN PDEVICE_OBJECT DeviceObject, IN PIO_STATUS_BLOCK IoStatusBlock, IN UCHAR MinorFunction, IN PIO_STACK_LOCATION Stack)
 
PDEVICE_NODE FASTCALL IopGetDeviceNode (IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS IopActionConfigureChildServices (IN PDEVICE_NODE DeviceNode, IN PVOID Context)
 
NTSTATUS IopActionInitChildServices (IN PDEVICE_NODE DeviceNode, IN PVOID Context)
 
NTSTATUS IopEnumerateDevice (IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS IoCreateDriverList (VOID)
 
NTSTATUS IoDestroyDriverList (VOID)
 
INIT_FUNCTION NTSTATUS IopInitPlugPlayEvents (VOID)
 
NTSTATUS IopQueueTargetDeviceEvent (const GUID *Guid, PUNICODE_STRING DeviceIds)
 
NTSTATUS IopInitializePnpServices (IN PDEVICE_NODE DeviceNode)
 
NTSTATUS NTAPI IopOpenRegistryKeyEx (PHANDLE KeyHandle, HANDLE ParentKey, PUNICODE_STRING Name, ACCESS_MASK DesiredAccess)
 
NTSTATUS NTAPI IopGetRegistryValue (IN HANDLE Handle, IN PWSTR ValueName, OUT PKEY_VALUE_FULL_INFORMATION *Information)
 
NTSTATUS NTAPI IopCreateRegistryKeyEx (OUT PHANDLE Handle, IN HANDLE BaseHandle OPTIONAL, IN PUNICODE_STRING KeyName, IN ACCESS_MASK DesiredAccess, IN ULONG CreateOptions, OUT PULONG Disposition OPTIONAL)
 
NTSTATUS IopTraverseDeviceTree (PDEVICETREE_TRAVERSE_CONTEXT Context)
 
INIT_FUNCTION NTSTATUS NTAPI IopUpdateRootKey (VOID)
 
INIT_FUNCTION NTSTATUS NTAPI PiInitCacheGroupInformation (VOID)
 
USHORT NTAPI PpInitGetGroupOrderIndex (IN HANDLE ServiceHandle)
 
USHORT NTAPI PipGetDriverTagPriority (IN HANDLE ServiceHandle)
 
NTSTATUS NTAPI PnpRegMultiSzToUnicodeStrings (IN PKEY_VALUE_FULL_INFORMATION KeyValueInformation, OUT PUNICODE_STRING *UnicodeStringList, OUT PULONG UnicodeStringCount)
 
BOOLEAN NTAPI PnpRegSzToString (IN PWCHAR RegSzData, IN ULONG RegSzLength, OUT PUSHORT StringLength OPTIONAL)
 
INIT_FUNCTION NTSTATUS NTAPI IopCreateArcNames (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
INIT_FUNCTION NTSTATUS NTAPI IopReassignSystemRoot (IN PLOADER_PARAMETER_BLOCK LoaderBlock, OUT PANSI_STRING NtBootPath)
 
INIT_FUNCTION BOOLEAN NTAPI IoInitSystem (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
BOOLEAN NTAPI IopVerifyDiskSignature (IN PDRIVE_LAYOUT_INFORMATION_EX DriveLayout, IN PARC_DISK_SIGNATURE ArcDiskSignature, OUT PULONG Signature)
 
BOOLEAN NTAPI IoInitializeCrashDump (IN HANDLE PageFileHandle)
 
VOID NTAPI IopReadyDeviceObjects (IN PDRIVER_OBJECT Driver)
 
NTSTATUS FASTCALL IopInitializeDevice (IN PDEVICE_NODE DeviceNode, IN PDRIVER_OBJECT DriverObject)
 
NTSTATUS IopStartDevice (IN PDEVICE_NODE DeviceNode)
 
NTSTATUS IopStopDevice (IN PDEVICE_NODE DeviceNode)
 
NTSTATUS IopRemoveDevice (IN PDEVICE_NODE DeviceNode)
 
PVPB NTAPI IopCheckVpbMounted (IN POPEN_PACKET OpenPacket, IN PDEVICE_OBJECT DeviceObject, IN PUNICODE_STRING RemainingName, OUT PNTSTATUS Status)
 
NTSTATUS NTAPI IopMountVolume (IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN AllowRawMount, IN BOOLEAN DeviceIsLocked, IN BOOLEAN Alertable, OUT PVPB *Vpb)
 
PVOID IoOpenSymlink (IN PVOID SymbolicLink)
 
PVOID IoOpenFileOnDevice (IN PVOID SymbolicLink, IN PWCHAR Name)
 
NTSTATUS NTAPI IopCreateVpb (IN PDEVICE_OBJECT DeviceObject)
 
VOID NTAPI IopDereferenceVpbAndFree (IN PVPB Vpb)
 
VOID NTAPI IoInitFileSystemImplementation (VOID)
 
VOID NTAPI IoInitVpbImplementation (VOID)
 
NTSTATUS NTAPI IopReferenceDeviceObject (IN PDEVICE_OBJECT DeviceObject)
 
VOID NTAPI IopDereferenceDeviceObject (IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN ForceUnload)
 
NTSTATUS NTAPI IoGetRelatedTargetDevice (IN PFILE_OBJECT FileObject, OUT PDEVICE_OBJECT *DeviceObject)
 
VOID NTAPI IopUnloadDevice (IN PDEVICE_OBJECT DeviceObject)
 
PDEVICE_OBJECT NTAPI IopGetDeviceAttachmentBase (IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS NTAPI IopCleanupFailedIrp (IN PFILE_OBJECT FileObject, IN PKEVENT EventObject, IN PVOID Buffer OPTIONAL)
 
VOID NTAPI IopAbortInterruptedIrp (IN PKEVENT EventObject, IN PIRP Irp)
 
PIRP NTAPI IopAllocateIrpMustSucceed (IN CCHAR StackSize)
 
BOOLEAN NTAPI IopInitializeReserveIrp (IN PRESERVE_IRP_ALLOCATOR ReserveIrpAllocator)
 
PIRP NTAPI IopAllocateReserveIrp (IN CCHAR StackSize)
 
VOID IoInitShutdownNotification (VOID)
 
VOID NTAPI IoShutdownSystem (IN ULONG Phase)
 
VOID NTAPI IopShutdownBaseFileSystems (IN PLIST_ENTRY ListHead)
 
INIT_FUNCTION VOID IopInitBootLog (IN BOOLEAN StartBootLog)
 
INIT_FUNCTION VOID IopStartBootLog (VOID)
 
VOID IopStopBootLog (VOID)
 
VOID IopBootLog (IN PUNICODE_STRING DriverName, IN BOOLEAN Success)
 
VOID IopSaveBootLogToFile (VOID)
 
VOID NTAPI IoCancelThreadIo (IN PETHREAD Thread)
 
VOID IoInitCancelHandling (VOID)
 
VOID NTAPI IopCompleteRequest (IN PKAPC Apc, IN PKNORMAL_ROUTINE *NormalRoutine, IN PVOID *NormalContext, IN PVOID *SystemArgument1, IN PVOID *SystemArgument2)
 
VOID NTAPI IopInitErrorLog (VOID)
 
VOID NTAPI IopLogWorker (IN PVOID Parameter)
 
BOOLEAN RawFsIsRawFileSystemDeviceObject (IN PDEVICE_OBJECT DeviceObject)
 
INIT_FUNCTION NTSTATUS NTAPI RawFsDriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
 
NTSTATUS NTAPI PnpRootDriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
 
NTSTATUS PnpRootCreateDevice (IN PUNICODE_STRING ServiceName, IN OPTIONAL PDRIVER_OBJECT DriverObject, OUT PDEVICE_OBJECT *PhysicalDeviceObject, OUT OPTIONAL PUNICODE_STRING FullInstancePath)
 
NTSTATUS PnpRootRegisterDevice (IN PDEVICE_OBJECT DeviceObject)
 
INIT_FUNCTION VOID FASTCALL IopInitializeBootDrivers (VOID)
 
INIT_FUNCTION VOID FASTCALL IopInitializeSystemDrivers (VOID)
 
NTSTATUS NTAPI IopCreateDriver (IN PUNICODE_STRING DriverName OPTIONAL, IN PDRIVER_INITIALIZE InitializationFunction, IN PUNICODE_STRING RegistryPath OPTIONAL, IN PCUNICODE_STRING ServiceName, IN PLDR_DATA_TABLE_ENTRY ModuleObject OPTIONAL, OUT PDRIVER_OBJECT *pDriverObject)
 
VOID NTAPI IopDeleteDriver (IN PVOID ObjectBody)
 
NTSTATUS FASTCALL IopGetDriverObject (OUT PDRIVER_OBJECT *DriverObject, IN PUNICODE_STRING ServiceName, IN BOOLEAN FileSystem)
 
NTSTATUS FASTCALL IopLoadServiceModule (IN PUNICODE_STRING ServiceName, OUT PLDR_DATA_TABLE_ENTRY *ModuleObject)
 
NTSTATUS NTAPI IopLoadUnloadDriver (_In_opt_ PCUNICODE_STRING RegistryPath, _Inout_ PDRIVER_OBJECT *DriverObject)
 
NTSTATUS FASTCALL IopInitializeDriverModule (IN PDEVICE_NODE DeviceNode, IN PLDR_DATA_TABLE_ENTRY ModuleObject, IN PUNICODE_STRING ServiceName, IN BOOLEAN FileSystemDriver, OUT PDRIVER_OBJECT *DriverObject)
 
NTSTATUS FASTCALL IopAttachFilterDrivers (IN PDEVICE_NODE DeviceNode, IN HANDLE EnumSubKey, IN HANDLE ClassKey, IN BOOLEAN Lower)
 
VOID NTAPI IopReinitializeDrivers (VOID)
 
VOID NTAPI IopReinitializeBootDrivers (VOID)
 
VOID NTAPI IopDeleteDevice (IN PVOID ObjectBody)
 
NTSTATUS NTAPI IopParseDevice (IN PVOID ParseObject, IN PVOID ObjectType, IN OUT PACCESS_STATE AccessState, IN KPROCESSOR_MODE AccessMode, IN ULONG Attributes, IN OUT PUNICODE_STRING CompleteName, IN OUT PUNICODE_STRING RemainingName, IN OUT PVOID Context, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL, OUT PVOID *Object)
 
NTSTATUS NTAPI IopParseFile (IN PVOID ParseObject, IN PVOID ObjectType, IN OUT PACCESS_STATE AccessState, IN KPROCESSOR_MODE AccessMode, IN ULONG Attributes, IN OUT PUNICODE_STRING CompleteName, IN OUT PUNICODE_STRING RemainingName, IN OUT PVOID Context OPTIONAL, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL, OUT PVOID *Object)
 
VOID NTAPI IopDeleteFile (IN PVOID ObjectBody)
 
NTSTATUS NTAPI IopGetSetSecurityObject (IN PVOID ObjectBody, IN SECURITY_OPERATION_CODE OperationCode, IN PSECURITY_INFORMATION SecurityInformation, IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor, IN OUT PULONG BufferLength, OUT PSECURITY_DESCRIPTOR *OldSecurityDescriptor, IN POOL_TYPE PoolType, IN OUT PGENERIC_MAPPING GenericMapping)
 
NTSTATUS NTAPI IopQueryName (IN PVOID ObjectBody, IN BOOLEAN HasName, OUT POBJECT_NAME_INFORMATION ObjectNameInfo, IN ULONG Length, OUT PULONG ReturnLength, IN KPROCESSOR_MODE PreviousMode)
 
NTSTATUS NTAPI IopQueryNameInternal (IN PVOID ObjectBody, IN BOOLEAN HasName, IN BOOLEAN QueryDosName, OUT POBJECT_NAME_INFORMATION ObjectNameInfo, IN ULONG Length, OUT PULONG ReturnLength, IN KPROCESSOR_MODE PreviousMode)
 
VOID NTAPI IopCloseFile (IN PEPROCESS Process OPTIONAL, IN PVOID Object, IN ACCESS_MASK GrantedAccess, IN ULONG ProcessHandleCount, IN ULONG SystemHandleCount)
 
NTSTATUS NTAPI IopAcquireFileObjectLock (_In_ PFILE_OBJECT FileObject, _In_ KPROCESSOR_MODE AccessMode, _In_ BOOLEAN Alertable, _Out_ PBOOLEAN LockFailed)
 
PVOID NTAPI IoGetFileObjectFilterContext (IN PFILE_OBJECT FileObject)
 
NTSTATUS NTAPI IoChangeFileObjectFilterContext (IN PFILE_OBJECT FileObject, IN PVOID FilterContext, IN BOOLEAN Define)
 
VOID NTAPI IopDoNameTransmogrify (IN PIRP Irp, IN PFILE_OBJECT FileObject, IN PREPARSE_DATA_BUFFER DataBuffer)
 
NTSTATUS NTAPI IoComputeDesiredAccessFileObject (IN PFILE_OBJECT FileObject, IN PACCESS_MASK DesiredAccess)
 
NTSTATUS NTAPI IopGetFileInformation (IN PFILE_OBJECT FileObject, IN ULONG Length, IN FILE_INFORMATION_CLASS FileInfoClass, OUT PVOID Buffer, OUT PULONG ReturnedLength)
 
BOOLEAN NTAPI IopVerifyDeviceObjectOnStack (IN PDEVICE_OBJECT BaseDeviceObject, IN PDEVICE_OBJECT TopDeviceObjectHint)
 
VOID FASTCALL IopInitTimerImplementation (VOID)
 
VOID NTAPI IopRemoveTimerFromTimerList (IN PIO_TIMER Timer)
 
VOID NTAPI IopDeleteIoCompletion (PVOID ObjectBody)
 
NTSTATUS NTAPI IoSetIoCompletion (IN PVOID IoCompletion, IN PVOID KeyContext, IN PVOID ApcContext, IN NTSTATUS IoStatus, IN ULONG_PTR IoStatusInformation, IN BOOLEAN Quota)
 
INIT_FUNCTION NTSTATUS NTAPI IopStartRamdisk (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
NTSTATUS NTAPI IopFetchConfigurationInformation (OUT PWSTR *SymbolicLinkList, IN GUID Guid, IN ULONG ExpectedInterfaces, IN PULONG Interfaces)
 
VOID NTAPI IopStoreSystemPartitionInformation (IN PUNICODE_STRING NtSystemPartitionDeviceName, IN PUNICODE_STRING OsLoaderPathName)
 

Variables

PIO_BUS_TYPE_GUID_LIST IopBusTypeGuidList
 
POBJECT_TYPE IoCompletionType
 
PDEVICE_NODE IopRootDeviceNode
 
KSPIN_LOCK IopDeviceTreeLock
 
ULONG IopTraceLevel
 
GENERAL_LOOKASIDE IopMdlLookasideList
 
GENERIC_MAPPING IopCompletionMapping
 
GENERIC_MAPPING IopFileMapping
 
POBJECT_TYPE _IoFileObjectType
 
HAL_DISPATCH _HalDispatchTable
 
LIST_ENTRY IopErrorLogListHead
 
ULONG IopNumTriageDumpDataBlocks
 
PVOID IopTriageDumpDataBlocks [64]
 
PIO_BUS_TYPE_GUID_LIST PnpBusTypeGuidList
 
PDRIVER_OBJECT IopRootDriverObject
 
KSPIN_LOCK IopDeviceActionLock
 
LIST_ENTRY IopDeviceActionRequestList
 
RESERVE_IRP_ALLOCATOR IopReserveIrpAllocator
 
BOOLEAN IoRemoteBootClient
 

Macro Definition Documentation

◆ _IO_DEBUG_

#define _IO_DEBUG_   0x00

Definition at line 14 of file io.h.

◆ ENUM_ROOT

#define ENUM_ROOT   L"\\Registry\\Machine\\System\\CurrentControlSet\\Enum"

Definition at line 53 of file io.h.

◆ IO_API_DEBUG

#define IO_API_DEBUG   0x04

Definition at line 21 of file io.h.

◆ IO_CTL_DEBUG

#define IO_CTL_DEBUG   0x08

Definition at line 22 of file io.h.

◆ IO_FILE_DEBUG

#define IO_FILE_DEBUG   0x02

Definition at line 20 of file io.h.

◆ IO_IRP_DEBUG

#define IO_IRP_DEBUG   0x01

Definition at line 19 of file io.h.

◆ IO_METHOD_FROM_CTL_CODE

#define IO_METHOD_FROM_CTL_CODE (   c)    (c & 0x00000003)

Definition at line 58 of file io.h.

◆ IoGetDevObjExtension

#define IoGetDevObjExtension (   DeviceObject)
Value:
(DeviceObject->DeviceObjectExtension)) \
struct _EXTENDED_DEVOBJ_EXTENSION * PEXTENDED_DEVOBJ_EXTENSION
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

Definition at line 125 of file io.h.

◆ IoGetDrvObjExtension

#define IoGetDrvObjExtension (   DriverObject)
Value:
PDRIVER_EXTENSION DriverExtension
Definition: iotypes.h:2174
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
struct _EXTENDED_DRIVER_EXTENSION * PEXTENDED_DRIVER_EXTENSION

Definition at line 132 of file io.h.

◆ IOP_CREATE_FILE_OBJECT_EXTENSION

#define IOP_CREATE_FILE_OBJECT_EXTENSION   0x02

Definition at line 93 of file io.h.

◆ IOP_MAX_REPARSE_TRAVERSAL

#define IOP_MAX_REPARSE_TRAVERSAL   0x20

Definition at line 87 of file io.h.

◆ IOP_USE_TOP_LEVEL_DEVICE_HINT

#define IOP_USE_TOP_LEVEL_DEVICE_HINT   0x01

Definition at line 92 of file io.h.

◆ IopAllocateMdlFromLookaside

#define IopAllocateMdlFromLookaside   ObpAllocateObjectCreateInfoBuffer

Definition at line 108 of file io.h.

◆ IopDeviceNodeClearFlag

#define IopDeviceNodeClearFlag (   DeviceNode,
  Flag 
)    ((DeviceNode)->Flags &= ~(Flag))

Definition at line 151 of file io.h.

◆ IopDeviceNodeClearProblem

#define IopDeviceNodeClearProblem (   DeviceNode,
  Problem 
)    ((DeviceNode)->Problem &= ~(Problem))

Definition at line 205 of file io.h.

◆ IopDeviceNodeClearUserFlag

#define IopDeviceNodeClearUserFlag (   DeviceNode,
  UserFlag 
)    ((DeviceNode)->UserFlags &= ~(UserFlag))

Definition at line 178 of file io.h.

◆ IopDeviceNodeHasFlag

#define IopDeviceNodeHasFlag (   DeviceNode,
  Flag 
)    (((DeviceNode)->Flags & (Flag)) > 0)

Definition at line 160 of file io.h.

◆ IopDeviceNodeHasProblem

#define IopDeviceNodeHasProblem (   DeviceNode,
  Problem 
)    (((DeviceNode)->Problem & (Problem)) > 0)

Definition at line 214 of file io.h.

◆ IopDeviceNodeHasUserFlag

#define IopDeviceNodeHasUserFlag (   DeviceNode,
  UserFlag 
)    (((DeviceNode)->UserFlags & (UserFlag)) > 0)

Definition at line 187 of file io.h.

◆ IopDeviceNodeSetFlag

#define IopDeviceNodeSetFlag (   DeviceNode,
  Flag 
)    ((DeviceNode)->Flags |= (Flag))

Definition at line 142 of file io.h.

◆ IopDeviceNodeSetProblem

#define IopDeviceNodeSetProblem (   DeviceNode,
  Problem 
)    ((DeviceNode)->Problem |= (Problem))

Definition at line 196 of file io.h.

◆ IopDeviceNodeSetUserFlag

#define IopDeviceNodeSetUserFlag (   DeviceNode,
  UserFlag 
)    ((DeviceNode)->UserFlags |= (UserFlag))

Definition at line 169 of file io.h.

◆ IopFreeMdlFromLookaside

#define IopFreeMdlFromLookaside   ObpFreeCapturedAttributes

Definition at line 110 of file io.h.

◆ IopInitDeviceTreeTraverseContext

#define IopInitDeviceTreeTraverseContext (   _DeviceTreeTraverseContext,
  _DeviceNode,
  _Action,
  _Context 
)
Value:
{ \
(_DeviceTreeTraverseContext)->FirstDeviceNode = \
(_DeviceNode); \
(_DeviceTreeTraverseContext)->Action = (_Action); \
(_DeviceTreeTraverseContext)->Context = (_Context); }
_In_ PLIST_ENTRY _In_ PSTRING _In_ USHORT _In_opt_ PSTRING _In_opt_ PSTRING _In_ ULONG _In_ ULONG Action
Definition: fsrtlfuncs.h:738

Definition at line 225 of file io.h.

◆ IopIsValidPhysicalDeviceObject

#define IopIsValidPhysicalDeviceObject (   PhysicalDeviceObject)
Value:
(((PEXTENDED_DEVOBJ_EXTENSION)PhysicalDeviceObject->DeviceObjectExtension)->DeviceNode) && \
struct _EXTENDED_DEVOBJ_EXTENSION * PEXTENDED_DEVOBJ_EXTENSION
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1122
Definition: Node.h:9
#define DNF_ENUMERATED
Definition: iotypes.h:170

Definition at line 238 of file io.h.

◆ IOTRACE

#define IOTRACE (   x,
  fmt,
  ... 
)    DPRINT(fmt, ##__VA_ARGS__)

Definition at line 47 of file io.h.

◆ IsIrpSynchronous

#define IsIrpSynchronous (   Irp,
  FileObject 
)
Value:
((Irp->Flags & IRP_SYNCHRONOUS_API) || \
(!(FileObject) ? \
FALSE : \
FileObject->Flags & FO_SYNCHRONOUS_IO)) \
_In_ PIRP Irp
Definition: csq.h:116
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1733
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define IRP_SYNCHRONOUS_API

Definition at line 116 of file io.h.

◆ RD_FSCTL_FAILED

#define RD_FSCTL_FAILED   3

Definition at line 74 of file io.h.

◆ RD_GUID_CONVERT_FAILED

#define RD_GUID_CONVERT_FAILED   4

Definition at line 78 of file io.h.

◆ RD_NO_RAMDISK_DRIVER

#define RD_NO_RAMDISK_DRIVER   2

Definition at line 70 of file io.h.

◆ RD_NO_XIPROM_DESCRIPTOR

#define RD_NO_XIPROM_DESCRIPTOR   1

Definition at line 66 of file io.h.

◆ RD_SYMLINK_CREATE_FAILED

#define RD_SYMLINK_CREATE_FAILED   5

Definition at line 82 of file io.h.

Typedef Documentation

◆ BOOT_DRIVER_NODE

◆ COMPLETION_PACKET_TYPE

◆ DEVICETREE_TRAVERSE_CONTEXT

◆ DEVICETREE_TRAVERSE_ROUTINE

typedef NTSTATUS(* DEVICETREE_TRAVERSE_ROUTINE) (IN PDEVICE_NODE DeviceNode, IN PVOID Context)

Definition at line 486 of file io.h.

◆ DRIVER_INFORMATION

◆ DRIVER_REINIT_ITEM

◆ DUMMY_FILE_OBJECT

◆ ERROR_LOG_ENTRY

◆ EXTENDED_IO_REMOVE_LOCK

◆ FILE_OBJECT_EXTENSION

◆ FS_CHANGE_NOTIFY_ENTRY

◆ IO_BUS_TYPE_GUID_LIST

◆ IO_INTERRUPT

◆ IO_UNLOAD_SAFE_COMPLETION_CONTEXT

◆ IO_WORKITEM

◆ IOP_DEVICE_LIST_OPERATION

◆ IOP_MINI_COMPLETION_PACKET

◆ IOP_TRANSFER_TYPE

◆ LOAD_UNLOAD_PARAMS

◆ OPEN_PACKET

◆ PBOOT_DRIVER_NODE

◆ PCOMPLETION_PACKET_TYPE

◆ PDEVICETREE_TRAVERSE_CONTEXT

◆ PDRIVER_INFORMATION

◆ PDRIVER_REINIT_ITEM

◆ PDUMMY_FILE_OBJECT

◆ PERROR_LOG_ENTRY

◆ PEXTENDED_IO_REMOVE_LOCK

◆ PFILE_OBJECT_EXTENSION

◆ PFS_CHANGE_NOTIFY_ENTRY

◆ PIO_BUS_TYPE_GUID_LIST

◆ PIO_INTERRUPT

◆ PIO_UNLOAD_SAFE_COMPLETION_CONTEXT

◆ PIOP_DEVICE_LIST_OPERATION

◆ PIOP_MINI_COMPLETION_PACKET

◆ PIOP_TRANSFER_TYPE

◆ PLOAD_UNLOAD_PARAMS

◆ POPEN_PACKET

◆ PRESERVE_IRP_ALLOCATOR

◆ PSECURITY_DESCRIPTOR_TYPE

◆ PSHUTDOWN_ENTRY

◆ RESERVE_IRP_ALLOCATOR

◆ SECURITY_DESCRIPTOR_TYPE

◆ SHUTDOWN_ENTRY

Enumeration Type Documentation

◆ _COMPLETION_PACKET_TYPE

Enumerator
IopCompletionPacketIrp 
IopCompletionPacketMini 
IopCompletionPacketQuota 

Definition at line 265 of file io.h.

266  {
enum _COMPLETION_PACKET_TYPE * PCOMPLETION_PACKET_TYPE
enum _COMPLETION_PACKET_TYPE COMPLETION_PACKET_TYPE

◆ _IOP_DEVICE_LIST_OPERATION

Enumerator
IopRemove 
IopAdd 

Definition at line 246 of file io.h.

247 {
248  IopRemove,
249  IopAdd
Definition: io.h:248
enum _IOP_DEVICE_LIST_OPERATION * PIOP_DEVICE_LIST_OPERATION
enum _IOP_DEVICE_LIST_OPERATION IOP_DEVICE_LIST_OPERATION
Definition: io.h:249

◆ _IOP_TRANSFER_TYPE

Enumerator
IopReadTransfer 
IopWriteTransfer 
IopOtherTransfer 

Definition at line 255 of file io.h.

256 {
enum _IOP_TRANSFER_TYPE IOP_TRANSFER_TYPE
enum _IOP_TRANSFER_TYPE * PIOP_TRANSFER_TYPE

◆ _SECURITY_DESCRIPTOR_TYPE

Enumerator
RestrictedPublic 
UnrestrictedPublic 
RestrictedPublicOpen 
UnrestrictedPublicOpen 
SystemDefault 

Definition at line 532 of file io.h.

533 {
534  RestrictedPublic = 1,
enum _SECURITY_DESCRIPTOR_TYPE * PSECURITY_DESCRIPTOR_TYPE
enum _SECURITY_DESCRIPTOR_TYPE SECURITY_DESCRIPTOR_TYPE

Function Documentation

◆ IoCancelThreadIo()

VOID NTAPI IoCancelThreadIo ( IN PETHREAD  Thread)

Definition at line 1146 of file irp.c.

1147 {
1148  KIRQL OldIrql;
1149  ULONG Retries = 3000;
1151  PLIST_ENTRY ListHead, NextEntry;
1152  PIRP Irp;
1153  PAGED_CODE();
1154 
1155  /* Windows isn't using given thread, but using current. */
1157 
1159  "%s - Canceling IRPs for Thread %p\n",
1160  __FUNCTION__,
1161  Thread);
1162 
1163  /* Raise to APC to protect the IrpList */
1165 
1166  /* Start by cancelling all the IRPs in the current thread queue. */
1167  ListHead = &Thread->IrpList;
1168  NextEntry = ListHead->Flink;
1169  while (ListHead != NextEntry)
1170  {
1171  /* Get the IRP */
1172  Irp = CONTAINING_RECORD(NextEntry, IRP, ThreadListEntry);
1173 
1174  /* Cancel it */
1175  IoCancelIrp(Irp);
1176 
1177  /* Move to the next entry */
1178  NextEntry = NextEntry->Flink;
1179  }
1180 
1181  /* Wait 100 milliseconds */
1182  Interval.QuadPart = -1000000;
1183 
1184  /* Wait till all the IRPs are completed or cancelled. */
1185  while (!IsListEmpty(&Thread->IrpList))
1186  {
1187  /* Now we can lower */
1189 
1190  /* Wait a short while and then look if all our IRPs were completed. */
1192 
1193  /*
1194  * Don't stay here forever if some broken driver doesn't complete
1195  * the IRP.
1196  */
1197  if (!(Retries--))
1198  {
1199  /* Print out a message and remove the IRP */
1200  DPRINT1("Broken driver did not complete!\n");
1202  }
1203 
1204  /* Raise the IRQL Again */
1206  }
1207 
1208  /* We're done, lower the IRQL */
1210 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
_In_ PIRP Irp
Definition: csq.h:116
IRP
Definition: iotypes.h:2463
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define PAGED_CODE()
Definition: video.h:57
UCHAR KIRQL
Definition: env_spec_w32.h:591
NTSTATUS NTAPI KeDelayExecutionThread(IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Interval OPTIONAL)
Definition: wait.c:283
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
DWORD Interval
Definition: netstat.c:33
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define IO_IRP_DEBUG
Definition: io.h:19
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define IOTRACE(x, fmt,...)
Definition: io.h:47
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Definition: typedefs.h:117
#define DPRINT1
Definition: precomp.h:8
BOOLEAN NTAPI IoCancelIrp(IN PIRP Irp)
Definition: irp.c:1101
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI IopDisassociateThreadIrp(VOID)
Definition: irp.c:115
#define __FUNCTION__
Definition: types.h:112
LIST_ENTRY IrpList
Definition: pstypes.h:1075
#define APC_LEVEL
Definition: env_spec_w32.h:695

Referenced by PspExitThread().

◆ IoChangeFileObjectFilterContext()

NTSTATUS NTAPI IoChangeFileObjectFilterContext ( IN PFILE_OBJECT  FileObject,
IN PVOID  FilterContext,
IN BOOLEAN  Define 
)

Definition at line 2510 of file file.c.

2513 {
2515  PFILE_OBJECT_EXTENSION FileObjectExtension;
2516 
2518  {
2519  return STATUS_INVALID_PARAMETER;
2520  }
2521 
2522  FileObjectExtension = FileObject->FileObjectExtension;
2523  if (Define)
2524  {
2525  /* If define, just set the new value if not value is set
2526  * Success will only contain old value. It is valid if it is NULL
2527  */
2529  }
2530  else
2531  {
2532  /* If not define, we want to reset filter context.
2533  * We will remove value (provided by the caller) and set NULL instead.
2534  * This will only success if caller provides correct previous value.
2535  * To catch whether it worked, we substract previous value to expect value:
2536  * If it matches (and thus, we reset), Success will contain 0
2537  * Otherwise, it will contain a non-zero value.
2538  */
2540  }
2541 
2542  /* If success isn't 0, it means we failed somewhere (set or unset) */
2543  if (Success != 0)
2544  {
2545  return STATUS_ALREADY_COMMITTED;
2546  }
2547 
2548  return STATUS_SUCCESS;
2549 }
_In_ PLIST_ENTRY _In_ PSTRING _In_ USHORT _In_opt_ PSTRING _In_opt_ PSTRING _In_ ULONG _In_ ULONG _In_opt_ PVOID _In_opt_ PVOID FilterContext
Definition: fsrtlfuncs.h:738
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define STATUS_ALREADY_COMMITTED
Definition: ntstatus.h:256
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
PVOID FilterContext
Definition: io.h:99
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define FO_FILE_OBJECT_HAS_EXTENSION
Definition: iotypes.h:144
return STATUS_SUCCESS
Definition: btrfs.c:2938
static ULONG_PTR
Definition: file.c:106

Referenced by FsRtlInsertPerFileObjectContext(), and FsRtlPTeardownPerFileObjectContexts().

◆ IoComputeDesiredAccessFileObject()

NTSTATUS NTAPI IoComputeDesiredAccessFileObject ( IN PFILE_OBJECT  FileObject,
IN PACCESS_MASK  DesiredAccess 
)

Definition at line 26 of file util.c.

28 {
29  /* Assume failure */
30  *DesiredAccess = 0;
31 
32  /* First check we really have a FileObject */
34  {
36  }
37 
38  /* Then compute desired access:
39  * Check if the handle has either FILE_WRITE_DATA or FILE_APPEND_DATA was
40  * granted. However, if this is a named pipe, make sure we don't ask for
41  * FILE_APPEND_DATA as it interferes with the FILE_CREATE_PIPE_INSTANCE
42  * access right!
43  */
45 
46  return STATUS_SUCCESS;
47 }
Type
Definition: Type.h:6
#define FILE_APPEND_DATA
Definition: nt_native.h:634
#define OBJECT_TO_OBJECT_HEADER(o)
Definition: obtypes.h:111
#define FO_NAMED_PIPE
Definition: iotypes.h:1739
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define STATUS_OBJECT_TYPE_MISMATCH
Definition: ntstatus.h:259
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by ObReferenceFileObjectForWrite().

◆ IoCreateDriverList()

NTSTATUS IoCreateDriverList ( VOID  )

◆ IoDestroyDriverList()

NTSTATUS IoDestroyDriverList ( VOID  )

◆ IoGetFileObjectFilterContext()

PVOID NTAPI IoGetFileObjectFilterContext ( IN PFILE_OBJECT  FileObject)

Definition at line 2495 of file file.c.

2496 {
2498  {
2499  PFILE_OBJECT_EXTENSION FileObjectExtension;
2500 
2501  FileObjectExtension = FileObject->FileObjectExtension;
2502  return FileObjectExtension->FilterContext;
2503  }
2504 
2505  return NULL;
2506 }
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
PVOID FilterContext
Definition: io.h:99
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define FO_FILE_OBJECT_HAS_EXTENSION
Definition: iotypes.h:144

Referenced by FsRtlInsertPerFileObjectContext(), FsRtlLookupPerFileObjectContext(), FsRtlPTeardownPerFileObjectContexts(), and FsRtlRemovePerFileObjectContext().

◆ IoGetRelatedTargetDevice()

NTSTATUS NTAPI IoGetRelatedTargetDevice ( IN PFILE_OBJECT  FileObject,
OUT PDEVICE_OBJECT DeviceObject 
)

Definition at line 1607 of file device.c.

1609 {
1610  NTSTATUS Status;
1612 
1613  /* Call the internal helper function */
1615  if (NT_SUCCESS(Status) && DeviceNode)
1616  {
1617  *DeviceObject = DeviceNode->PhysicalDeviceObject;
1618  }
1619  return Status;
1620 }
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Definition: Node.h:9
NTSTATUS NTAPI IopGetRelatedTargetDevice(IN PFILE_OBJECT FileObject, OUT PDEVICE_NODE *DeviceNode)
Definition: device.c:653
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

Referenced by FsRtlNotifyVolumeEvent(), IopNotifyPlugPlayNotification(), and NtSetVolumeInformationFile().

◆ IoInitCancelHandling()

VOID IoInitCancelHandling ( VOID  )

◆ IoInitFileSystemImplementation()

VOID NTAPI IoInitFileSystemImplementation ( VOID  )

◆ IoInitializeCrashDump()

BOOLEAN NTAPI IoInitializeCrashDump ( IN HANDLE  PageFileHandle)

Definition at line 656 of file iomgr.c.

657 {
659  return FALSE;
660 }
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by NtCreatePagingFile().

◆ IoInitShutdownNotification()

VOID IoInitShutdownNotification ( VOID  )

◆ IoInitSystem()

INIT_FUNCTION BOOLEAN NTAPI IoInitSystem ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 470 of file iomgr.c.

471 {
472  LARGE_INTEGER ExpireTime;
474  CHAR Buffer[256];
475  ANSI_STRING NtBootPath, RootString;
476 
477  /* Initialize empty NT Boot Path */
478  RtlInitEmptyAnsiString(&NtBootPath, Buffer, sizeof(Buffer));
479 
480  /* Initialize the lookaside lists */
482 
483  /* Initialize all locks and lists */
504 
505  /* Initialize the reserve IRP */
507  {
508  DPRINT1("IopInitializeReserveIrp failed!\n");
509  return FALSE;
510  }
511 
512  /* Initialize Timer List Lock */
514 
515  /* Initialize Timer List */
517 
518  /* Initialize the DPC/Timer which will call the other Timer Routines */
519  ExpireTime.QuadPart = -10000000;
522  KeSetTimerEx(&IopTimer, ExpireTime, 1000, &IopTimerDpc);
523 
524  /* Create Object Types */
525  if (!IopCreateObjectTypes())
526  {
527  DPRINT1("IopCreateObjectTypes failed!\n");
528  return FALSE;
529  }
530 
531  /* Create Object Directories */
533  {
534  DPRINT1("IopCreateRootDirectories failed!\n");
535  return FALSE;
536  }
537 
538  /* Initialize PnP manager */
540 
541  /* Initialize SHIM engine */
543 
544  /* Initialize WMI */
545  WmiInitialize();
546 
547  /* Initialize HAL Root Bus Driver */
549 
550  /* Make loader block available for the whole kernel */
551  IopLoaderBlock = LoaderBlock;
552 
553  /* Load boot start drivers */
555 
556  /* Call back drivers that asked for */
558 
559  /* Check if this was a ramdisk boot */
560  if (!_strnicmp(LoaderBlock->ArcBootDeviceName, "ramdisk(0)", 10))
561  {
562  /* Initialize the ramdisk driver */
563  IopStartRamdisk(LoaderBlock);
564  }
565 
566  /* No one should need loader block any longer */
568 
569  /* Create ARC names for boot devices */
570  Status = IopCreateArcNames(LoaderBlock);
571  if (!NT_SUCCESS(Status))
572  {
573  DPRINT1("IopCreateArcNames failed: %lx\n", Status);
574  return FALSE;
575  }
576 
577  /* Mark the system boot partition */
578  if (!IopMarkBootPartition(LoaderBlock))
579  {
580  DPRINT1("IopMarkBootPartition failed!\n");
581  return FALSE;
582  }
583 
584  /* Initialize PnP root relations */
586 
587 #if !defined(_WINKD_) && defined(KDBG)
588  /* Read KDB Data */
589  KdbInit();
590 
591  /* I/O is now setup for disk access, so phase 3 */
592  KdInitSystem(3, LoaderBlock);
593 #endif
594 
595  /* Load services for devices found by PnP manager */
597 
598  /* Load system start drivers */
601 
602  /* Reinitialize drivers that requested it */
604 
605  /* Convert SystemRoot from ARC to NT path */
606  Status = IopReassignSystemRoot(LoaderBlock, &NtBootPath);
607  if (!NT_SUCCESS(Status))
608  {
609  DPRINT1("IopReassignSystemRoot failed: %lx\n", Status);
610  return FALSE;
611  }
612 
613  /* Set the ANSI_STRING for the root path */
614  RootString.MaximumLength = NtSystemRoot.MaximumLength / sizeof(WCHAR);
615  RootString.Length = 0;
617  RootString.MaximumLength,
618  TAG_IO);
619 
620  /* Convert the path into the ANSI_STRING */
622  if (!NT_SUCCESS(Status))
623  {
624  DPRINT1("RtlUnicodeStringToAnsiString failed: %lx\n", Status);
625  return FALSE;
626  }
627 
628  /* Assign drive letters */
629  IoAssignDriveLetters(LoaderBlock,
630  &NtBootPath,
631  (PUCHAR)RootString.Buffer,
632  &RootString);
633 
634  /* Update system root */
636  if (!NT_SUCCESS(Status))
637  {
638  DPRINT1("RtlAnsiStringToUnicodeString failed: %lx\n", Status);
639  return FALSE;
640  }
641 
642  /* Load the System DLL and its Entrypoints */
644  if (!NT_SUCCESS(Status))
645  {
646  DPRINT1("PsLocateSystemDll failed: %lx\n", Status);
647  return FALSE;
648  }
649 
650  /* Return success */
651  return TRUE;
652 }
ERESOURCE IopDatabaseResource
Definition: volume.c:25
ERESOURCE IopSecurityResource
Definition: iomgr.c:60
LIST_ENTRY DriverBootReinitListHead
Definition: driver.c:26
#define TRUE
Definition: types.h:120
KSPIN_LOCK DriverBootReinitListLock
Definition: driver.c:27
PDEVICE_OBJECT PhysicalDeviceObject
Definition: iotypes.h:839
PDEVICE_NODE IopRootDeviceNode
Definition: pnpmgr.c:18
NTSTATUS IopInitializePnpServices(IN PDEVICE_NODE DeviceNode)
Definition: pnpmgr.c:3109
#define TAG_IO
Definition: tag.h:69
UNICODE_STRING NtSystemRoot
Definition: init.c:72
LIST_ENTRY IopCdRomFileSystemQueueHead
Definition: volume.c:27
KTIMER IopTimer
Definition: iotimer.c:23
VOID NTAPI IopReinitializeDrivers(VOID)
Definition: driver.c:1398
VOID FASTCALL IoAssignDriveLetters(IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, IN PSTRING NtDeviceName, OUT PUCHAR NtSystemPath, OUT PSTRING NtSystemPathString)
Definition: ntoskrnl.c:54
USHORT MaximumLength
Definition: env_spec_w32.h:370
unsigned char * PUCHAR
Definition: retypes.h:3
char CHAR
Definition: xmlstorage.h:175
LIST_ENTRY IopTimerQueueHead
Definition: iotimer.c:19
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI IopReinitializeBootDrivers(VOID)
Definition: driver.c:1434
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
RESERVE_IRP_ALLOCATOR IopReserveIrpAllocator
Definition: irp.c:19
BOOLEAN NTAPI KeSetTimerEx(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN LONG Period, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:294
INIT_FUNCTION NTSTATUS NTAPI PsLocateSystemDll(VOID)
Definition: psmgr.c:279
INIT_FUNCTION NTSTATUS NTAPI IopStartRamdisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: ramdisk.c:28
BOOLEAN PnpSystemInit
Definition: iomgr.c:17
INIT_FUNCTION NTSTATUS NTAPI ApphelpCacheInitialize(VOID)
Definition: apphelp.c:440
ERESOURCE IopDriverLoadResource
Definition: driver.c:19
_Check_return_ _CRTIMP int __cdecl _strnicmp(_In_reads_or_z_(_MaxCount) const char *_Str1, _In_reads_or_z_(_MaxCount) const char *_Str2, _In_ size_t _MaxCount)
INIT_FUNCTION NTSTATUS NTAPI IopInitializePlugPlayServices(VOID)
Definition: pnpinit.c:380
LIST_ENTRY IopTapeFileSystemQueueHead
Definition: volume.c:27
BOOLEAN NTAPI IopInitializeReserveIrp(IN PRESERVE_IRP_ALLOCATOR ReserveIrpAllocator)
Definition: irp.c:549
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
LIST_ENTRY IopNetworkFileSystemQueueHead
Definition: volume.c:26
BOOLEAN NTAPI WmiInitialize(VOID)
Definition: wmi.c:38
LIST_ENTRY DriverReinitListHead
Definition: driver.c:21
KGUARDED_MUTEX PnpNotifyListLock
Definition: pnpnotify.c:30
smooth NULL
Definition: ftsmooth.c:416
VOID INIT_FUNCTION NTAPI IopInitLookasideLists(VOID)
Definition: iomgr.c:99
INIT_FUNCTION VOID FASTCALL IopInitializeSystemDrivers(VOID)
Definition: driver.c:1135
Definition: bufpool.h:45
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
KDPC IopTimerDpc
Definition: iotimer.c:22
INIT_FUNCTION VOID FASTCALL IopInitializeBootDrivers(VOID)
Definition: driver.c:939
NTSTATUS IopEnumerateDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: pnpmgr.c:2670
LIST_ENTRY IopDiskFileSystemQueueHead
Definition: volume.c:26
BOOLEAN INIT_FUNCTION NTAPI IopMarkBootPartition(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: iomgr.c:400
USHORT MaximumLength
Definition: env_spec_w32.h:377
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
INIT_FUNCTION NTSTATUS NTAPI IopReassignSystemRoot(IN PLOADER_PARAMETER_BLOCK LoaderBlock, OUT PANSI_STRING NtBootPath)
Definition: arcname.c:836
LIST_ENTRY PnpNotifyListHead
Definition: pnpnotify.c:31
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
KSPIN_LOCK DriverReinitListLock
Definition: driver.c:22
PLOADER_PARAMETER_BLOCK IopLoaderBlock
Definition: iomgr.c:88
Status
Definition: gdiplustypes.h:24
KSPIN_LOCK IopLogListLock
Definition: error.c:31
KSPIN_LOCK IopTimerLock
Definition: iotimer.c:18
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:31
BOOLEAN NTAPI KdInitSystem(ULONG Reserved, PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: kdinit.c:169
BOOLEAN INIT_FUNCTION NTAPI IopCreateObjectTypes(VOID)
Definition: iomgr.c:246
VOID NTAPI IopTimerDispatch(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: iotimer.c:32
INIT_FUNCTION NTSTATUS NTAPI IopCreateArcNames(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: arcname.c:41
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
KSPIN_LOCK IoStatisticsLock
Definition: iomgr.c:45
#define DPRINT1
Definition: precomp.h:8
KSPIN_LOCK ShutdownListLock
Definition: device.c:22
BOOLEAN INIT_FUNCTION NTAPI IopCreateRootDirectories(VOID)
Definition: iomgr.c:335
LIST_ENTRY IopFsNotifyChangeQueueHead
Definition: volume.c:28
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711
LIST_ENTRY IopErrorLogListHead
Definition: error.c:30
LIST_ENTRY ShutdownListHead
Definition: device.c:21
#define HalInitPnpDriver
Definition: haltypes.h:289
LIST_ENTRY LastChanceShutdownListHead
Definition: device.c:21
VOID NTAPI KeInitializeTimerEx(OUT PKTIMER Timer, IN TIMER_TYPE Type)
Definition: timerobj.c:244
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by Phase1InitializationDiscard().

◆ IoInitVpbImplementation()

VOID NTAPI IoInitVpbImplementation ( VOID  )

◆ IoOpenFileOnDevice()

PVOID IoOpenFileOnDevice ( IN PVOID  SymbolicLink,
IN PWCHAR  Name 
)

◆ IoOpenSymlink()

PVOID IoOpenSymlink ( IN PVOID  SymbolicLink)

◆ IopAbortInterruptedIrp()

VOID NTAPI IopAbortInterruptedIrp ( IN PKEVENT  EventObject,
IN PIRP  Irp 
)

Definition at line 67 of file irp.c.

69 {
70  KIRQL OldIrql;
71  BOOLEAN CancelResult;
73  PAGED_CODE();
74 
75  /* Raise IRQL to APC */
77 
78  /* Check if nobody completed it yet */
79  if (!KeReadStateEvent(EventObject))
80  {
81  /* First, cancel it */
82  CancelResult = IoCancelIrp(Irp);
84 
85  /* Check if we cancelled it */
86  if (CancelResult)
87  {
88  /* Wait for the IRP to be cancelled */
89  Wait.QuadPart = -100000;
90  while (!KeReadStateEvent(EventObject))
91  {
92  /* Delay indefintely */
94  }
95  }
96  else
97  {
98  /* No cancellation done, so wait for the I/O system to kill it */
99  KeWaitForSingleObject(EventObject,
100  Executive,
101  KernelMode,
102  FALSE,
103  NULL);
104  }
105  }
106  else
107  {
108  /* We got preempted, so give up */
110  }
111 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define PAGED_CODE()
Definition: video.h:57
UCHAR KIRQL
Definition: env_spec_w32.h:591
NTSTATUS NTAPI KeDelayExecutionThread(IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Interval OPTIONAL)
Definition: wait.c:283
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
BOOLEAN NTAPI IoCancelIrp(IN PIRP Irp)
Definition: irp.c:1101
LONG NTAPI KeReadStateEvent(IN PKEVENT Event)
Definition: eventobj.c:120
#define APC_LEVEL
Definition: env_spec_w32.h:695
IN BOOLEAN Wait
Definition: fatprocs.h:1529

Referenced by IopFinalizeAsynchronousIo(), IopPerformSynchronousRequest(), IopQueryDeviceInformation(), IoSetInformation(), NtQueryInformationFile(), and NtSetInformationFile().

◆ IopAcquireFileObjectLock()

NTSTATUS NTAPI IopAcquireFileObjectLock ( _In_ PFILE_OBJECT  FileObject,
_In_ KPROCESSOR_MODE  AccessMode,
_In_ BOOLEAN  Alertable,
_Out_ PBOOLEAN  LockFailed 
)

Definition at line 2449 of file file.c.

2454 {
2455  NTSTATUS Status;
2456 
2457  PAGED_CODE();
2458 
2460 
2462  do
2463  {
2464  if (!InterlockedExchange((PLONG)&FileObject->Busy, TRUE))
2465  {
2466  break;
2467  }
2469  Executive,
2470  WaitMode,
2471  Alertable,
2472  NULL);
2473  } while (Status == STATUS_SUCCESS);
2474 
2476  if (Status == STATUS_SUCCESS)
2477  {
2479  *LockFailed = FALSE;
2480  }
2481  else
2482  {
2483  if (!FileObject->Busy && FileObject->Waiters)
2484  {
2486  }
2487  *LockFailed = TRUE;
2488  }
2489 
2490  return Status;
2491 }
_In_ PVOID _In_ BOOLEAN Alertable
Definition: exfuncs.h:452
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define PAGED_CODE()
Definition: video.h:57
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define InterlockedDecrement
Definition: armddk.h:52
#define InterlockedExchange
Definition: armddk.h:54
Status
Definition: gdiplustypes.h:24
#define InterlockedIncrement
Definition: armddk.h:53
#define ObReferenceObject
Definition: obfuncs.h:204
#define IO_NO_INCREMENT
Definition: iotypes.h:566
return STATUS_SUCCESS
Definition: btrfs.c:2938
signed int * PLONG
Definition: retypes.h:5

Referenced by IopLockFileObject().

◆ IopActionConfigureChildServices()

NTSTATUS IopActionConfigureChildServices ( IN PDEVICE_NODE  DeviceNode,
IN PVOID  Context 
)

◆ IopActionInitChildServices()

NTSTATUS IopActionInitChildServices ( IN PDEVICE_NODE  DeviceNode,
IN PVOID  Context 
)

Referenced by IopResetDevice().

◆ IopAllocateIrpMustSucceed()

PIRP NTAPI IopAllocateIrpMustSucceed ( IN CCHAR  StackSize)

Definition at line 716 of file irp.c.

717 {
718  LONG i;
719  PIRP Irp;
721 
722  /* Try to get an IRP */
724  if (Irp)
725  return Irp;
726 
727  /* If we fail, start looping till we may get one */
728  i = LONG_MAX;
729  do {
730  i--;
731 
732  /* First, sleep for 10ms */
733  Sleep.QuadPart = -10 * 1000 * 10;
735 
736  /* Then, retry allocation */
738  if (Irp)
739  return Irp;
740  } while (i > 0);
741 
742  return Irp;
743 }
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
_In_ PIRP Irp
Definition: csq.h:116
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
long LONG
Definition: pedump.c:60
NTSTATUS NTAPI KeDelayExecutionThread(IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Interval OPTIONAL)
Definition: wait.c:283
#define LONG_MAX
Definition: limits.h:43
_In_ USHORT _In_ CCHAR StackSize
Definition: iofuncs.h:1056
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615

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

◆ IopAllocateReserveIrp()

PIRP NTAPI IopAllocateReserveIrp ( IN CCHAR  StackSize)

Definition at line 573 of file irp.c.

574 {
575  /* If we need a stack size higher than what was allocated, then fail */
577  {
578  return NULL;
579  }
580 
581  /* Now, wait until the IRP becomes available and reserve it immediately */
583  {
585  Executive,
586  KernelMode,
587  FALSE,
588  NULL);
589  }
590 
591  /* It's ours! Initialize it */
593 
594  /* And return it to the caller */
596 }
RESERVE_IRP_ALLOCATOR IopReserveIrpAllocator
Definition: irp.c:19
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
VOID NTAPI IoInitializeIrp(IN PIRP Irp, IN USHORT PacketSize, IN CCHAR StackSize)
Definition: irp.c:1854
smooth NULL
Definition: ftsmooth.c:416
volatile LONG ReserveIrpInUse
Definition: io.h:524
_In_ USHORT _In_ CCHAR StackSize
Definition: iofuncs.h:1056
#define InterlockedExchange
Definition: armddk.h:54
#define IoSizeOfIrp(_StackSize)
KEVENT WaitEvent
Definition: io.h:525

Referenced by IoPageRead().

◆ IopAssignDeviceResources()

NTSTATUS NTAPI IopAssignDeviceResources ( IN PDEVICE_NODE  DeviceNode)

Definition at line 1060 of file pnpres.c.

1062 {
1063  NTSTATUS Status;
1064  ULONG ListSize;
1065 
1067 
1069  if (!NT_SUCCESS(Status))
1070  goto ByeBye;
1071 
1072  if (!DeviceNode->BootResources && !DeviceNode->ResourceRequirements)
1073  {
1076 
1077  /* No resource needed for this device */
1078  DeviceNode->ResourceList = NULL;
1079  DeviceNode->ResourceListTranslated = NULL;
1080 
1081  return STATUS_SUCCESS;
1082  }
1083 
1084  if (DeviceNode->BootResources)
1085  {
1086  ListSize = PnpDetermineResourceListSize(DeviceNode->BootResources);
1087 
1088  DeviceNode->ResourceList = ExAllocatePool(PagedPool, ListSize);
1089  if (!DeviceNode->ResourceList)
1090  {
1092  goto ByeBye;
1093  }
1094 
1095  RtlCopyMemory(DeviceNode->ResourceList, DeviceNode->BootResources, ListSize);
1096 
1098  if (!NT_SUCCESS(Status))
1099  {
1100  DPRINT1("Boot resources for %wZ cause a resource conflict!\n", &DeviceNode->InstancePath);
1101  ExFreePool(DeviceNode->ResourceList);
1102  DeviceNode->ResourceList = NULL;
1103  }
1104  }
1105  else
1106  {
1107  /* We'll make this from the requirements */
1108  DeviceNode->ResourceList = NULL;
1109  }
1110 
1111  /* No resources requirements */
1112  if (!DeviceNode->ResourceRequirements)
1113  goto Finish;
1114 
1115  /* Call HAL to fixup our resource requirements list */
1116  HalAdjustResourceList(&DeviceNode->ResourceRequirements);
1117 
1118  /* Add resource requirements that aren't in the list we already got */
1119  Status = IopFixupResourceListWithRequirements(DeviceNode->ResourceRequirements,
1120  &DeviceNode->ResourceList);
1121  if (!NT_SUCCESS(Status))
1122  {
1123  DPRINT1("Failed to fixup a resource list from supplied resources for %wZ\n", &DeviceNode->InstancePath);
1125  goto ByeBye;
1126  }
1127 
1128  /* IopFixupResourceListWithRequirements should NEVER give us a conflicting list */
1130 
1131 Finish:
1133  if (!NT_SUCCESS(Status))
1134  {
1136  DPRINT1("Failed to translate resources for %wZ\n", &DeviceNode->InstancePath);
1137  goto ByeBye;
1138  }
1139 
1141  if (!NT_SUCCESS(Status))
1142  goto ByeBye;
1143 
1145  if (!NT_SUCCESS(Status))
1146  goto ByeBye;
1147 
1149 
1151 
1152  return STATUS_SUCCESS;
1153 
1154 ByeBye:
1155  if (DeviceNode->ResourceList)
1156  {
1157  ExFreePool(DeviceNode->ResourceList);
1158  DeviceNode->ResourceList = NULL;
1159  }
1160 
1161  DeviceNode->ResourceListTranslated = NULL;
1162 
1164 
1165  return Status;
1166 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI IopDetectResourceConflict(IN PCM_RESOURCE_LIST ResourceList, IN BOOLEAN Silent, OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
Definition: pnpres.c:1200
#define DNF_NO_RESOURCE_REQUIRED
Definition: iotypes.h:174
#define DNF_RESOURCE_ASSIGNED
Definition: iotypes.h:176
static NTSTATUS IopFilterResourceRequirements(IN PDEVICE_NODE DeviceNode)
Definition: pnpres.c:734
ULONG NTAPI PnpDetermineResourceListSize(IN PCM_RESOURCE_LIST ResourceList)
Definition: pnpmgr.c:4083
#define IopDeviceNodeSetFlag(DeviceNode, Flag)
Definition: io.h:142
smooth NULL
Definition: ftsmooth.c:416
#define CM_PROB_NORMAL_CONFLICT
Definition: cfg.h:42
NTSTATUS NTAPI HalAdjustResourceList(IN PIO_RESOURCE_REQUIREMENTS_LIST *ResourceList)
Definition: bus.c:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CM_PROB_TRANSLATION_FAILED
Definition: cfg.h:63
Definition: Node.h:9
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static NTSTATUS IopUpdateControlKeyWithResources(IN PDEVICE_NODE DeviceNode)
Definition: pnpres.c:678
static NTSTATUS IopTranslateDeviceResources(IN PDEVICE_NODE DeviceNode)
Definition: pnpres.c:926
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
NTSTATUS IopUpdateResourceMapForPnPDevice(IN PDEVICE_NODE DeviceNode)
Definition: pnpres.c:919
Status
Definition: gdiplustypes.h:24
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define DNF_ASSIGNING_RESOURCES
Definition: iotypes.h:192
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define IopDeviceNodeClearFlag(DeviceNode, Flag)
Definition: io.h:151
#define STATUS_CONFLICTING_ADDRESSES
Definition: ntstatus.h:247
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
NTSTATUS NTAPI IopFixupResourceListWithRequirements(IN PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList, OUT PCM_RESOURCE_LIST *ResourceList)
Definition: pnpres.c:202

Referenced by IopStartDevice(), and IoReportDetectedDevice().

◆ IopAttachFilterDrivers()

NTSTATUS FASTCALL IopAttachFilterDrivers ( IN PDEVICE_NODE  DeviceNode,
IN HANDLE  EnumSubKey,
IN HANDLE  ClassKey,
IN BOOLEAN  Lower 
)

Referenced by PipCallDriverAddDevice().

◆ IopBootLog()

VOID IopBootLog ( IN PUNICODE_STRING  DriverName,
IN BOOLEAN  Success 
)

◆ IopCheckVpbMounted()

PVPB NTAPI IopCheckVpbMounted ( IN POPEN_PACKET  OpenPacket,
IN PDEVICE_OBJECT  DeviceObject,
IN PUNICODE_STRING  RemainingName,
OUT PNTSTATUS  Status 
)

Definition at line 81 of file volume.c.

85 {
87  KIRQL OldIrql;
88  PVPB Vpb = NULL;
89 
90  /* Lock the VPBs */
92 
93  /* Set VPB mount settings */
94  Raw = !RemainingName->Length && !OpenPacket->RelatedFileObject;
95  Alertable = (OpenPacket->CreateOptions & FILE_SYNCHRONOUS_IO_ALERT) ?
96  TRUE: FALSE;
97 
98  /* Start looping until the VPB is mounted */
99  while (!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
100  {
101  /* Release the lock */
103 
104  /* Mount the volume */
106  Raw,
107  FALSE,
108  Alertable,
109  &Vpb);
110 
111  /* Check if we failed or if we were alerted */
112  if (!(NT_SUCCESS(*Status)) ||
113  (*Status == STATUS_USER_APC) ||
114  (*Status == STATUS_ALERTED))
115  {
116  /* Dereference the device, since IopParseDevice referenced it */
118 
119  /* Check if it was a total failure */
120  if (!NT_SUCCESS(*Status)) return NULL;
121 
122  /* Otherwise we were alerted */
124  return NULL;
125  }
126  /*
127  * In case IopMountVolume returns a valid VPB
128  * Then, the volume is mounted, return it
129  */
130  else if (Vpb != NULL)
131  {
132  return Vpb;
133  }
134 
135  /* Re-acquire the lock */
137  }
138 
139  /* Make sure the VPB isn't locked */
140  Vpb = DeviceObject->Vpb;
141  if (Vpb->Flags & VPB_LOCKED)
142  {
143  /* We're locked, so fail */
145  Vpb = NULL;
146  }
147  else
148  {
149  /* Success! Reference the VPB */
150  Vpb->ReferenceCount++;
151  }
152 
153  /* Release the lock and return the VPB */
155  return Vpb;
156 }
_In_ PVOID _In_ BOOLEAN Alertable
Definition: exfuncs.h:452
#define TRUE
Definition: types.h:120
VOID NTAPI IopDereferenceDeviceObject(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN ForceUnload)
Definition: device.c:462
NTSTATUS NTAPI IopMountVolume(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN AllowRawMount, IN BOOLEAN DeviceIsLocked, IN BOOLEAN Alertable, OUT PVPB *Vpb)
Definition: volume.c:467
VOID NTAPI IoAcquireVpbSpinLock(OUT PKIRQL Irql)
Definition: volume.c:1209
#define STATUS_WRONG_VOLUME
Definition: udferr_usr.h:140
#define STATUS_ALERTED
Definition: ntstatus.h:80
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FILE_SYNCHRONOUS_IO_ALERT
Definition: from_kernel.h:30
#define VPB_LOCKED
Definition: iotypes.h:1765
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Status
Definition: gdiplustypes.h:24
#define STATUS_USER_APC
Definition: ntstatus.h:78
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
Definition: iotypes.h:166
Definition: sacdrv.h:278
#define VPB_MOUNTED
Definition: iotypes.h:1764
VOID NTAPI IoReleaseVpbSpinLock(IN KIRQL Irql)
Definition: volume.c:1220
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1664
_Inout_ PFCB _Inout_ PUNICODE_STRING RemainingName
Definition: cdprocs.h:806

Referenced by IopParseDevice().

◆ IopCleanupFailedIrp()

NTSTATUS NTAPI IopCleanupFailedIrp ( IN PFILE_OBJECT  FileObject,
IN PKEVENT  EventObject,
IN PVOID Buffer  OPTIONAL 
)

Definition at line 45 of file irp.c.

48 {
49  PAGED_CODE();
50 
51  /* Dereference the event */
52  if (EventObject) ObDereferenceObject(EventObject);
53 
54  /* Free a buffer, if any */
55  if (Buffer) ExFreePool(Buffer);
56 
57  /* If this was a file opened for synch I/O, then unlock it */
59 
60  /* Now dereference it and return */
63 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define PAGED_CODE()
Definition: video.h:57
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1733
Definition: bufpool.h:45
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
static __inline VOID IopUnlockFileObject(IN PFILE_OBJECT FileObject)
Definition: io_x.h:36
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by IopDeviceFsIoControl(), IopGetSetSecurityObject(), IopQueryDeviceInformation(), IoSetInformation(), NtFlushBuffersFile(), NtLockFile(), NtNotifyChangeDirectoryFile(), NtQueryDirectoryFile(), NtQueryInformationFile(), NtQueryVolumeInformationFile(), NtReadFile(), NtSetInformationFile(), NtSetVolumeInformationFile(), NtUnlockFile(), and NtWriteFile().

◆ IopCloseFile()

VOID NTAPI IopCloseFile ( IN PEPROCESS Process  OPTIONAL,
IN PVOID  Object,
IN ACCESS_MASK  GrantedAccess,
IN ULONG  ProcessHandleCount,
IN ULONG  SystemHandleCount 
)

Definition at line 2177 of file file.c.

2182 {
2183  PFILE_OBJECT FileObject = (PFILE_OBJECT)ObjectBody;
2184  KEVENT Event;
2185  PIRP Irp;
2186  PIO_STACK_LOCATION StackPtr;
2187  NTSTATUS Status;
2189  KIRQL OldIrql;
2191  IOTRACE(IO_FILE_DEBUG, "ObjectBody: %p\n", ObjectBody);
2192 
2193  /* If this isn't the last handle for the current process, quit */
2194  if (HandleCount != 1) return;
2195 
2196  /* Check if the file is locked and has more then one handle opened */
2197  if ((FileObject->LockOperation) && (SystemHandleCount != 1))
2198  {
2199  /* Check if this is a direct open or not */
2201  {
2202  /* Get the attached device */
2203  DeviceObject = IoGetAttachedDevice(FileObject->DeviceObject);
2204  }
2205  else
2206  {
2207  /* Get the FO's device */
2209  }
2210 
2211  /* Check if this is a sync FO and lock it */
2213  {
2215  }
2216 
2217  /* Go the FastIO path if possible, otherwise fall back to IRP */
2218  if (DeviceObject->DriverObject->FastIoDispatch == NULL ||
2219  DeviceObject->DriverObject->FastIoDispatch->FastIoUnlockAll == NULL ||
2220  !DeviceObject->DriverObject->FastIoDispatch->FastIoUnlockAll(FileObject, PsGetCurrentProcess(), &IoStatusBlock, DeviceObject))
2221  {
2222  /* Clear and set up Events */
2223  KeClearEvent(&FileObject->Event);
2225 
2226  /* Allocate an IRP */
2228 
2229  /* Set it up */
2230  Irp->UserEvent = &Event;
2231  Irp->UserIosb = &Irp->IoStatus;
2232  Irp->Tail.Overlay.Thread = PsGetCurrentThread();
2233  Irp->Tail.Overlay.OriginalFileObject = FileObject;
2234  Irp->RequestorMode = KernelMode;
2235  Irp->Flags = IRP_SYNCHRONOUS_API;
2236  Irp->Overlay.AsynchronousParameters.UserApcRoutine = NULL;
2238 
2239  /* Set up Stack Pointer Data */
2240  StackPtr = IoGetNextIrpStackLocation(Irp);
2241  StackPtr->MajorFunction = IRP_MJ_LOCK_CONTROL;
2242  StackPtr->MinorFunction = IRP_MN_UNLOCK_ALL;
2243  StackPtr->FileObject = FileObject;
2244 
2245  /* Queue the IRP */
2247 
2248  /* Call the FS Driver */
2250  if (Status == STATUS_PENDING)
2251  {
2252  /* Wait for completion */
2254  }
2255 
2256  /* IO will unqueue & free for us */
2257  }
2258 
2259  /* Release the lock if we were holding it */
2261  {
2263  }
2264  }
2265 
2266  /* Make sure this is the last handle */
2267  if (SystemHandleCount != 1) return;
2268 
2269  /* Check if this is a direct open or not */
2270  if (FileObject->Flags & FO_DIRECT_DEVICE_OPEN)
2271  {
2272  /* Get the attached device */
2273  DeviceObject = IoGetAttachedDevice(FileObject->DeviceObject);
2274  }
2275  else
2276  {
2277  /* Get the FO's device */
2279  }
2280 
2281  /* Set the handle created flag */
2282  FileObject->Flags |= FO_HANDLE_CREATED;
2283 
2284  /* Check if this is a sync FO and lock it */
2285  if (Process != NULL &&
2287  {
2289  }
2290 
2291  /* Clear and set up Events */
2292  KeClearEvent(&FileObject->Event);
2294 
2295  /* Allocate an IRP */
2297 
2298  /* Set it up */
2299  Irp->UserEvent = &Event;
2300  Irp->UserIosb = &Irp->IoStatus;
2301  Irp->Tail.Overlay.Thread = PsGetCurrentThread();
2302  Irp->Tail.Overlay.OriginalFileObject = FileObject;
2303  Irp->Overlay.AsynchronousParameters.UserApcRoutine = NULL;
2305 
2306  /* Set up Stack Pointer Data */
2307  StackPtr = IoGetNextIrpStackLocation(Irp);
2308  StackPtr->MajorFunction = IRP_MJ_CLEANUP;
2309  StackPtr->FileObject = FileObject;
2310 
2311  /* Queue the IRP */
2313 
2314  /* Update operation counts */
2316 
2317  /* Call the FS Driver */
2319  if (Status == STATUS_PENDING)
2320  {
2321  /* Wait for completion */
2323  }
2324 
2325  /* Unqueue the IRP */
2329 
2330  /* Free the IRP */
2331  IoFreeIrp(Irp);
2332 
2333  /* Release the lock if we were holding it */
2334  if (Process != NULL &&
2336  {
2338  }
2339 }
#define FO_HANDLE_CREATED
Definition: iotypes.h:1751
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define IRP_CLOSE_OPERATION
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
#define FO_DIRECT_DEVICE_OPEN
Definition: iotypes.h:1744
_In_ PIRP Irp
Definition: csq.h:116
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1733
#define IO_FILE_DEBUG
Definition: io.h:20
static __inline NTSTATUS IopLockFileObject(_In_ PFILE_OBJECT FileObject, _In_ KPROCESSOR_MODE WaitMode)
Definition: io_x.h:12
UCHAR KIRQL
Definition: env_spec_w32.h:591
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
#define PsGetCurrentProcess
Definition: psfuncs.h:17
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE VOID IopQueueIrpToThread(IN PIRP Irp)
Definition: io_x.h:49
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
PIRP NTAPI IopAllocateIrpMustSucceed(IN CCHAR StackSize)
Definition: irp.c:716
#define STATUS_PENDING
Definition: ntstatus.h:82
#define IRP_MN_UNLOCK_ALL
Definition: iotypes.h:4056
* PFILE_OBJECT
Definition: iotypes.h:1955
#define IOTRACE(x, fmt,...)
Definition: io.h:47
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
FORCEINLINE VOID IopUnQueueIrpFromThread(IN PIRP Irp)
Definition: io_x.h:65
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
PDEVICE_OBJECT NTAPI IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1385
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
static __inline VOID IopUnlockFileObject(IN PFILE_OBJECT FileObject)
Definition: io_x.h:36
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define IRP_MJ_CLEANUP
#define ObReferenceObject
Definition: obfuncs.h:204
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
static __inline VOID IopUpdateOperationCount(IN IOP_TRANSFER_TYPE Type)
Definition: io_x.h:77
#define IRP_SYNCHRONOUS_API
static VOID(WINAPI *pRtlFreeUnicodeString)(PUNICODE_STRING)
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
#define APC_LEVEL
Definition: env_spec_w32.h:695

Referenced by IopCreateObjectTypes(), and IopDeleteFile().

◆ IopCompleteRequest()

VOID NTAPI IopCompleteRequest ( IN PKAPC  Apc,
IN PKNORMAL_ROUTINE NormalRoutine,
IN PVOID NormalContext,
IN PVOID SystemArgument1,
IN PVOID SystemArgument2 
)

Definition at line 238 of file irp.c.

243 {
245  PIRP Irp;
246  PMDL Mdl, NextMdl;
247  PVOID Port = NULL, Key = NULL;
248  BOOLEAN SignaledCreateRequest = FALSE;
249 
250  /* Get data from the APC */
252  Irp = CONTAINING_RECORD(Apc, IRP, Tail.Apc);
254  "%s - Completing IRP %p for %p\n",
255  __FUNCTION__,
256  Irp,
257  FileObject);
258 
259  /* Sanity check */
260  ASSERT(Irp->IoStatus.Status != (NTSTATUS)0xFFFFFFFF);
261 
262  /* Check if we have a file object */
263  if (*SystemArgument2)
264  {
265  /* Check if we're reparsing */
266  if ((Irp->IoStatus.Status == STATUS_REPARSE) &&
267  (Irp->IoStatus.Information == IO_REPARSE_TAG_MOUNT_POINT))
268  {
269  PREPARSE_DATA_BUFFER ReparseData;
270 
271  ReparseData = (PREPARSE_DATA_BUFFER)*SystemArgument2;
272 
276 
277  IopDoNameTransmogrify(Irp, FileObject, ReparseData);
278  }
279  }
280 
281  /* Handle Buffered case first */
282  if (Irp->Flags & IRP_BUFFERED_IO)
283  {
284  /* Check if we have an input buffer and if we succeeded */
285  if ((Irp->Flags & IRP_INPUT_OPERATION) &&
286  (Irp->IoStatus.Status != STATUS_VERIFY_REQUIRED) &&
287  !(NT_ERROR(Irp->IoStatus.Status)))
288  {
289  _SEH2_TRY
290  {
291  /* Copy the buffer back to the user */
292  RtlCopyMemory(Irp->UserBuffer,
293  Irp->AssociatedIrp.SystemBuffer,
294  Irp->IoStatus.Information);
295  }
297  {
298  /* Fail the IRP */
299  Irp->IoStatus.Status = _SEH2_GetExceptionCode();
300  }
301  _SEH2_END;
302  }
303 
304  /* Also check if we should de-allocate it */
305  if (Irp->Flags & IRP_DEALLOCATE_BUFFER)
306  {
307  /* Deallocate it */
308  ExFreePool(Irp->AssociatedIrp.SystemBuffer);
309  }
310  }
311 
312  /* Now we got rid of these two... */
314 
315  /* Check if there's an MDL */
316  for (Mdl = Irp->MdlAddress; Mdl; Mdl = NextMdl)
317  {
318  /* Free it */
319  NextMdl = Mdl->Next;
320  IoFreeMdl(Mdl);
321  }
322 
323  /* No MDLs left */
324  Irp->MdlAddress = NULL;
325 
326  /*
327  * Check if either the request was completed without any errors
328  * (but warnings are OK!), or if it was completed with an error, but
329  * did return from a pending I/O Operation and is not synchronous.
330  */
331  if (!NT_ERROR(Irp->IoStatus.Status) ||
332  (Irp->PendingReturned &&
334  {
335  /* Get any information we need from the FO before we kill it */
336  if ((FileObject) && (FileObject->CompletionContext))
337  {
338  /* Save Completion Data */
339  Port = FileObject->CompletionContext->Port;
340  Key = FileObject->CompletionContext->Key;
341  }
342 
343  /* Check for UserIos */
344  if (Irp->UserIosb != NULL)
345  {
346  /* Use SEH to make sure we don't write somewhere invalid */
347  _SEH2_TRY
348  {
349  /* Save the IOSB Information */
350  *Irp->UserIosb = Irp->IoStatus;
351  }
353  {
354  /* Ignore any error */
355  }
356  _SEH2_END;
357  }
358 
359  /* Check if we have an event or a file object */
360  if (Irp->UserEvent)
361  {
362  /* At the very least, this is a PKEVENT, so signal it always */
363  KeSetEvent(Irp->UserEvent, 0, FALSE);
364 
365  /* Check if we also have a File Object */
366  if (FileObject)
367  {
368  /* Check if this is an Asynch API */
369  if (!(Irp->Flags & IRP_SYNCHRONOUS_API))
370  {
371  /* Dereference the event */
372  ObDereferenceObject(Irp->UserEvent);
373  }
374 
375  /*
376  * Now, if this is a Synch I/O File Object, then this event is
377  * NOT an actual Executive Event, so we won't dereference it,
378  * and instead, we will signal the File Object
379  */
380  if ((FileObject->Flags & FO_SYNCHRONOUS_IO) &&
381  !(Irp->Flags & IRP_OB_QUERY_NAME))
382  {
383  /* Signal the file object and set the status */
384  KeSetEvent(&FileObject->Event, 0, FALSE);
385  FileObject->FinalStatus = Irp->IoStatus.Status;
386  }
387 
388  /*
389  * This could also be a create operation, in which case we want
390  * to make sure there's no APC fired.
391  */
392  if (Irp->Flags & IRP_CREATE_OPERATION)
393  {
394  /* Clear the APC Routine and remember this */
395  Irp->Overlay.AsynchronousParameters.UserApcRoutine = NULL;
396  SignaledCreateRequest = TRUE;
397  }
398  }
399  }
400  else if (FileObject)
401  {
402  /* Signal the file object and set the status */
403  KeSetEvent(&FileObject->Event, 0, FALSE);
404  FileObject->FinalStatus = Irp->IoStatus.Status;
405 
406  /*
407  * This could also be a create operation, in which case we want
408  * to make sure there's no APC fired.
409  */
410  if (Irp->Flags & IRP_CREATE_OPERATION)
411  {
412  /* Clear the APC Routine and remember this */
413  Irp->Overlay.AsynchronousParameters.UserApcRoutine = NULL;
414  SignaledCreateRequest = TRUE;
415  }
416  }
417 
418  /* Update transfer count for everything but create operation */
419  if (!(Irp->Flags & IRP_CREATE_OPERATION))
420  {
421  if (Irp->Flags & IRP_WRITE_OPERATION)
422  {
423  /* Update write transfer count */
425  (ULONG)Irp->IoStatus.Information);
426  }
427  else if (Irp->Flags & IRP_READ_OPERATION)
428  {
429  /* Update read transfer count */
431  (ULONG)Irp->IoStatus.Information);
432  }
433  else
434  {
435  /* Update other transfer count */
437  (ULONG)Irp->IoStatus.Information);
438  }
439  }
440 
441  /* Now that we've signaled the events, de-associate the IRP */
443 
444  /* Now check if a User APC Routine was requested */
445  if (Irp->Overlay.AsynchronousParameters.UserApcRoutine)
446  {
447  /* Initialize it */
448  KeInitializeApc(&Irp->Tail.Apc,
454  Overlay.AsynchronousParameters.UserApcRoutine,
455  Irp->RequestorMode,
456  Irp->
457  Overlay.AsynchronousParameters.UserApcContext);
458 
459  /* Queue it */
460  KeInsertQueueApc(&Irp->Tail.Apc, Irp->UserIosb, NULL, 2);
461  }
462  else if ((Port) &&
463  (Irp->Overlay.AsynchronousParameters.UserApcContext))
464  {
465  /* We have an I/O Completion setup... create the special Overlay */
466  Irp->Tail.CompletionKey = Key;
467  Irp->Tail.Overlay.PacketType = IopCompletionPacketIrp;
468  KeInsertQueue(Port, &Irp->Tail.Overlay.ListEntry);
469  }
470  else
471  {
472  /* Free the IRP since we don't need it anymore */
473  IoFreeIrp(Irp);
474  }
475 
476  /* Check if we have a file object that wasn't part of a create */
477  if ((FileObject) && !(SignaledCreateRequest))
478  {
479  /* Dereference it, since it's not needed anymore either */
481  }
482  }
483  else
484  {
485  /*
486  * Either we didn't return from the request, or we did return but this
487  * request was synchronous.
488  */
489  if ((Irp->PendingReturned) && (FileObject))
490  {
491  /* So we did return with a synch operation, was it the IRP? */
492  if (Irp->Flags & IRP_SYNCHRONOUS_API)
493  {
494  /* Yes, this IRP was synchronous, so return the I/O Status */
495  *Irp->UserIosb = Irp->IoStatus;
496 
497  /* Now check if the user gave an event */
498  if (Irp->UserEvent)
499  {
500  /* Signal it */
501  KeSetEvent(Irp->UserEvent, 0, FALSE);
502  }
503  else
504  {
505  /* No event was given, so signal the FO instead */
506  KeSetEvent(&FileObject->Event, 0, FALSE);
507  }
508  }
509  else
510  {
511  /*
512  * It's not the IRP that was synchronous, it was the FO
513  * that was opened this way. Signal its event.
514  */
515  FileObject->FinalStatus = Irp->IoStatus.Status;
516  KeSetEvent(&FileObject->Event, 0, FALSE);
517  }
518  }
519 
520  /* Now that we got here, we do this for incomplete I/Os as well */
521  if ((FileObject) && !(Irp->Flags & IRP_CREATE_OPERATION))
522  {
523  /* Dereference the File Object unless this was a create */
525  }
526 
527  /*
528  * Check if this was an Executive Event (remember that we know this
529  * by checking if the IRP is synchronous)
530  */
531  if ((Irp->UserEvent) &&
532  (FileObject) &&
533  !(Irp->Flags & IRP_SYNCHRONOUS_API))
534  {
535  /* This isn't a PKEVENT, so dereference it */
536  ObDereferenceObject(Irp->UserEvent);
537  }
538 
539  /* Now that we've signaled the events, de-associate the IRP */
541 
542  /* Free the IRP as well */
543  IoFreeIrp(Irp);
544  }
545 }
VOID NTAPI KeInitializeApc(IN PKAPC Apc, IN PKTHREAD Thread, IN KAPC_ENVIRONMENT TargetEnvironment, IN PKKERNEL_ROUTINE KernelRoutine, IN PKRUNDOWN_ROUTINE RundownRoutine OPTIONAL, IN PKNORMAL_ROUTINE NormalRoutine, IN KPROCESSOR_MODE Mode, IN PVOID Context)
Definition: apc.c:651
CPPORT Port[4]
Definition: headless.c:34
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define IRP_OB_QUERY_NAME
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ULONG Key
Definition: fatprocs.h:2697
static __inline VOID IopUpdateTransferCount(IN IOP_TRANSFER_TYPE Type, IN ULONG TransferCount)
Definition: io_x.h:111
_In_ PIRP Irp
Definition: csq.h:116
VOID NTAPI IopAbortIrpKernelApc(IN PKAPC Apc)
Definition: irp.c:37
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI IopFreeIrpKernelApc(IN PKAPC Apc, IN PKNORMAL_ROUTINE *NormalRoutine, IN PVOID *NormalContext, IN PVOID *SystemArgument1, IN PVOID *SystemArgument2)
Definition: irp.c:25
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
IRP
Definition: iotypes.h:2463
#define STATUS_VERIFY_REQUIRED
Definition: udferr_usr.h:130
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
_SEH2_TRY
Definition: create.c:4250
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1733
#define IO_REPARSE_TAG_MOUNT_POINT
Definition: iotypes.h:6875
VOID NTAPI ObDereferenceObjectDeferDelete(IN PVOID Object)
Definition: obref.c:360
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:675
#define IO_IRP_DEBUG
Definition: io.h:19
#define IRP_READ_OPERATION
#define NT_ERROR(Status)
Definition: umtypes.h:106
* PFILE_OBJECT
Definition: iotypes.h:1955
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
#define IOTRACE(x, fmt,...)
Definition: io.h:47
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
USHORT ReparseDataLength
Definition: shellext.h:166
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:675
FORCEINLINE VOID IopUnQueueIrpFromThread(IN PIRP Irp)
Definition: io_x.h:65
_SEH2_END
Definition: create.c:4424
#define IRP_INPUT_OPERATION
#define IRP_BUFFERED_IO
LONG NTAPI KeInsertQueue(IN PKQUEUE Queue, IN PLIST_ENTRY Entry)
Definition: queue.c:198
#define STATUS_REPARSE
Definition: ntstatus.h:83
BOOLEAN NTAPI KeInsertQueueApc(IN PKAPC Apc, IN PVOID SystemArgument1, IN PVOID SystemArgument2, IN KPRIORITY PriorityBoost)
Definition: apc.c:735
#define IRP_DEALLOCATE_BUFFER
#define IsIrpSynchronous(Irp, FileObject)
Definition: io.h:116
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI IopDoNameTransmogrify(IN PIRP Irp, IN PFILE_OBJECT FileObject, IN PREPARSE_DATA_BUFFER DataBuffer)
Definition: file.c:170
#define IRP_SYNCHRONOUS_API
#define IRP_CREATE_OPERATION
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
VOID(NTAPI * PKNORMAL_ROUTINE)(IN PVOID NormalContext OPTIONAL, IN PVOID SystemArgument1 OPTIONAL, IN PVOID SystemArgument2 OPTIONAL)
Definition: ketypes.h:632
#define IRP_WRITE_OPERATION
#define KeGetCurrentThread
Definition: hal.h:44
#define __FUNCTION__
Definition: types.h:112
#define MAXIMUM_REPARSE_DATA_BUFFER_SIZE
Definition: iotypes.h:6857
struct _REPARSE_DATA_BUFFER * PREPARSE_DATA_BUFFER
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by IofCompleteRequest(), IopPerformSynchronousRequest(), NtQueryInformationFile(), and NtSetInformationFile().

◆ IopCreateArcNames()

INIT_FUNCTION NTSTATUS NTAPI IopCreateArcNames ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 41 of file arcname.c.

42 {
43  SIZE_T Length;
45  CHAR Buffer[128];
46  BOOLEAN SingleDisk;
47  BOOLEAN FoundBoot = FALSE;
48  UNICODE_STRING SystemDevice, LoaderPathNameW, BootDeviceName;
49  PARC_DISK_INFORMATION ArcDiskInfo = LoaderBlock->ArcDiskInformation;
50  ANSI_STRING ArcSystemString, ArcString, LanmanRedirector, LoaderPathNameA;
51 
52  /* Check if we only have one disk on the machine */
53  SingleDisk = ArcDiskInfo->DiskSignatureListHead.Flink->Flink ==
54  (&ArcDiskInfo->DiskSignatureListHead);
55 
56  /* Create the global HAL partition name */
57  sprintf(Buffer, "\\ArcName\\%s", LoaderBlock->ArcHalDeviceName);
58  RtlInitAnsiString(&ArcString, Buffer);
60 
61  /* Create the global system partition name */
62  sprintf(Buffer, "\\ArcName\\%s", LoaderBlock->ArcBootDeviceName);
63  RtlInitAnsiString(&ArcString, Buffer);
65 
66  /* Allocate memory for the string */
67  Length = strlen(LoaderBlock->ArcBootDeviceName) + sizeof(ANSI_NULL);
69  Length,
70  TAG_IO);
72  {
73  /* Copy the name */
75  LoaderBlock->ArcBootDeviceName,
76  Length);
77  }
78 
79  /* Check if we only found a disk, but we're booting from CD-ROM */
80  if ((SingleDisk) && strstr(LoaderBlock->ArcBootDeviceName, "cdrom"))
81  {
82  /* Then disable single-disk mode, since there's a CD drive out there */
83  SingleDisk = FALSE;
84  }
85 
86  /* Build the boot strings */
87  RtlInitAnsiString(&ArcSystemString, LoaderBlock->ArcHalDeviceName);
88 
89  /* If we are doing remote booting */
91  {
92  /* Yes, we have found boot device */
93  FoundBoot = TRUE;
94 
95  /* Get NT device name */
96  RtlInitAnsiString(&LanmanRedirector, "\\Device\\LanmanRedirector");
97  Status = RtlAnsiStringToUnicodeString(&SystemDevice, &LanmanRedirector, TRUE);
98  if (!NT_SUCCESS(Status))
99  {
100  return Status;
101  }
102 
103  /* Get ARC booting device name (in net(0) something) */
104  sprintf(Buffer, "\\ArcName\\%s", LoaderBlock->ArcBootDeviceName);
105  RtlInitAnsiString(&ArcString, Buffer);
106  Status = RtlAnsiStringToUnicodeString(&BootDeviceName, &ArcString, TRUE);
107  if (NT_SUCCESS(Status))
108  {
109  /* Map ARC to NT name */
110  IoAssignArcName(&BootDeviceName, &SystemDevice);
111  RtlFreeUnicodeString(&BootDeviceName);
112 
113  /* Now, get loader path name */
114  RtlInitAnsiString(&LoaderPathNameA, LoaderBlock->NtHalPathName);
115  Status = RtlAnsiStringToUnicodeString(&LoaderPathNameW, &LoaderPathNameA, TRUE);
116  if (!NT_SUCCESS(Status))
117  {
118  RtlFreeUnicodeString(&SystemDevice);
119  return Status;
120  }
121 
122  /* And set it has system partition */
123  IopStoreSystemPartitionInformation(&SystemDevice, &LoaderPathNameW);
124  }
125 
126  RtlFreeUnicodeString(&SystemDevice);
127 
128  /* Don't quit here, even if everything went fine!
129  * We need IopCreateArcNamesDisk to properly map
130  * devices with symlinks.
131  * It will return success if the mapping process went fine
132  * even if it didn't find boot device.
133  * It won't reset boot device finding status as well.
134  */
135  }
136 
137  /* Loop every disk and try to find boot disk */
138  Status = IopCreateArcNamesDisk(LoaderBlock, SingleDisk, &FoundBoot);
139  /* If it succeed but we didn't find boot device, try to browse Cds */
140  if (NT_SUCCESS(Status) && !FoundBoot)
141  {
142  Status = IopCreateArcNamesCd(LoaderBlock);
143  }
144 
145  /* Return success */
146  return Status;
147 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define TAG_IO
Definition: tag.h:69
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define sprintf(buf, format,...)
Definition: sprintf.c:55
PCHAR IoLoaderArcBootDeviceName
Definition: arcname.c:20
#define ANSI_NULL
unsigned char BOOLEAN
Definition: bufpool.h:45
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
UNICODE_STRING IoArcBootDeviceName
Definition: arcname.c:19
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:78
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
#define IoAssignArcName(_ArcName, _DeviceName)
VOID NTAPI IopStoreSystemPartitionInformation(IN PUNICODE_STRING NtSystemPartitionDeviceName, IN PUNICODE_STRING OsLoaderPathName)
Definition: iorsrce.c:697
LIST_ENTRY DiskSignatureListHead
Definition: arc.h:221
INIT_FUNCTION NTSTATUS NTAPI IopCreateArcNamesDisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN BOOLEAN SingleDisk, IN PBOOLEAN FoundBoot)
Definition: arcname.c:414
UNICODE_STRING IoArcHalDeviceName
Definition: arcname.c:19
INIT_FUNCTION NTSTATUS NTAPI IopCreateArcNamesCd(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: arcname.c:152
BOOLEAN IoRemoteBootClient
Definition: init.c:67

Referenced by IoInitSystem().

◆ IopCreateDeviceNode()

NTSTATUS IopCreateDeviceNode ( IN PDEVICE_NODE  ParentNode,
IN PDEVICE_OBJECT  PhysicalDeviceObject,
IN PUNICODE_STRING  ServiceName,
OUT PDEVICE_NODE DeviceNode 
)

◆ IopCreateDriver()

NTSTATUS NTAPI IopCreateDriver ( IN PUNICODE_STRING DriverName  OPTIONAL,
IN PDRIVER_INITIALIZE  InitializationFunction,
IN PUNICODE_STRING RegistryPath  OPTIONAL,
IN PCUNICODE_STRING  ServiceName,
IN PLDR_DATA_TABLE_ENTRY ModuleObject  OPTIONAL,
OUT PDRIVER_OBJECT pDriverObject 
)

Definition at line 1470 of file driver.c.

1476 {
1477  WCHAR NameBuffer[100];
1478  USHORT NameLength;
1479  UNICODE_STRING LocalDriverName;
1480  NTSTATUS Status;
1482  ULONG ObjectSize;
1484  UNICODE_STRING ServiceKeyName;
1485  HANDLE hDriver;
1486  ULONG i, RetryCount = 0;
1487 
1488 try_again:
1489  /* First, create a unique name for the driver if we don't have one */
1490  if (!DriverName)
1491  {
1492  /* Create a random name and set up the string */
1493  NameLength = (USHORT)swprintf(NameBuffer,
1494  DRIVER_ROOT_NAME L"%08u",
1496  LocalDriverName.Length = NameLength * sizeof(WCHAR);
1497  LocalDriverName.MaximumLength = LocalDriverName.Length + sizeof(UNICODE_NULL);
1498  LocalDriverName.Buffer = NameBuffer;
1499  }
1500  else
1501  {
1502  /* So we can avoid another code path, use a local var */
1503  LocalDriverName = *DriverName;
1504  }
1505 
1506  /* Initialize the Attributes */
1507  ObjectSize = sizeof(DRIVER_OBJECT) + sizeof(EXTENDED_DRIVER_EXTENSION);
1509  &LocalDriverName,
1511  NULL,
1512  NULL);
1513 
1514  /* Create the Object */
1518  KernelMode,
1519  NULL,
1520  ObjectSize,
1521  0,
1522  0,
1523  (PVOID*)&DriverObject);
1524  if (!NT_SUCCESS(Status)) return Status;
1525 
1526  DPRINT("IopCreateDriver(): created DO %p\n", DriverObject);
1527 
1528  /* Set up the Object */
1529  RtlZeroMemory(DriverObject, ObjectSize);
1531  DriverObject->Size = sizeof(DRIVER_OBJECT);
1532 
1533  /*
1534  * Check whether RegistryPath and ModuleObject are both NULL because
1535  * IoCreateDriver() was called to initialize a built-in driver.
1536  */
1537  if ((RegistryPath != NULL) || (ModuleObject != NULL))
1539  else
1541 
1544  DriverObject->DriverInit = InitializationFunction;
1545  DriverObject->DriverSection = ModuleObject;
1546  /* Loop all Major Functions */
1547  for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
1548  {
1549  /* Invalidate each function */
1551  }
1552 
1553  /* Set up the service key name buffer */
1554  ServiceKeyName.MaximumLength = ServiceName->Length + sizeof(UNICODE_NULL);
1555  ServiceKeyName.Buffer = ExAllocatePoolWithTag(NonPagedPool,
1556  ServiceKeyName.MaximumLength,
1557  TAG_IO);
1558  if (!ServiceKeyName.Buffer)
1559  {
1560  /* Fail */
1564  }
1565 
1566  /* Copy the name and set it in the driver extension */
1567  RtlCopyUnicodeString(&ServiceKeyName,
1568  ServiceName);
1569  DriverObject->DriverExtension->ServiceKeyName = ServiceKeyName;
1570 
1571  /* Make a copy of the driver name to store in the driver object */
1572  DriverObject->DriverName.MaximumLength = LocalDriverName.Length;
1575  TAG_IO);
1577  {
1578  /* Fail */
1582  }
1583 
1585  &LocalDriverName);
1586 
1587  /* Add the Object and get its handle */
1589  NULL,
1591  0,
1592  NULL,
1593  &hDriver);
1594 
1595  /* Eliminate small possibility when this function is called more than
1596  once in a row, and KeTickCount doesn't get enough time to change */
1597  if (!DriverName && (Status == STATUS_OBJECT_NAME_COLLISION) && (RetryCount < 100))
1598  {
1599  RetryCount++;
1600  goto try_again;
1601  }
1602 
1603  if (!NT_SUCCESS(Status)) return Status;
1604 
1605  /* Now reference it */
1607  0,
1609  KernelMode,
1610  (PVOID*)&DriverObject,
1611  NULL);
1612 
1613  /* Close the extra handle */
1614  ZwClose(hDriver);
1615 
1616  if (!NT_SUCCESS(Status))
1617  {
1618  /* Fail */
1621  return Status;
1622  }
1623 
1625  DriverObject->DriverStart = ModuleObject ? ModuleObject->DllBase : 0;
1626  DriverObject->DriverSize = ModuleObject ? ModuleObject->SizeOfImage : 0;
1627 
1628  /* Finally, call its init function */
1629  DPRINT("RegistryKey: %wZ\n", RegistryPath);
1630  DPRINT("Calling driver entrypoint at %p\n", InitializationFunction);
1631  Status = (*InitializationFunction)(DriverObject, RegistryPath);
1632  if (!NT_SUCCESS(Status))
1633  {
1634  /* If it didn't work, then kill the object */
1635  DPRINT1("'%wZ' initialization failed, status (0x%08lx)\n", DriverName, Status);
1639  return Status;
1640  }
1641  else
1642  {
1643  /* Returns to caller the object */
1644  *pDriverObject = DriverObject;
1645  }
1646 
1647  /* We're going to say if we don't have any DOs from DriverEntry, then we're not legacy.
1648  * Other parts of the I/O manager depend on this behavior */
1650 
1651  /* Loop all Major Functions */
1652  for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
1653  {
1654  /*
1655  * Make sure the driver didn't set any dispatch entry point to NULL!
1656  * Doing so is illegal; drivers shouldn't touch entry points they
1657  * do not implement.
1658  */
1659 
1660  /* Check if it did so anyway */
1661  if (!DriverObject->MajorFunction[i])
1662  {
1663  /* Print a warning in the debug log */
1664  DPRINT1("Driver <%wZ> set DriverObject->MajorFunction[%lu] to NULL!\n",
1666 
1667  /* Fix it up */
1669  }
1670  }
1671 
1672  /* Return the Status */
1673  return Status;
1674 }
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
ULONG LowPart
Definition: ketypes.h:910
#define DRVO_BUILTIN_DRIVER
Definition: iotypes.h:2119
#define DRVO_LEGACY_DRIVER
Definition: iotypes.h:2118
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TAG_IO
Definition: tag.h:69
USHORT MaximumLength
Definition: env_spec_w32.h:370
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define IRP_MJ_MAXIMUM_FUNCTION
LONG NTSTATUS
Definition: precomp.h:26
PVOID DriverStart
Definition: iotypes.h:2171
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR _In_ HANDLE hDriver
Definition: winddi.h:3553
#define OBJ_PERMANENT
Definition: winternl.h:226
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
POBJECT_TYPE IoDriverObjectType
Definition: driver.c:32
NTSTATUS NTAPI IopInvalidDeviceRequest(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: driver.c:46
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:496
#define UNICODE_NULL
struct _DRIVER_OBJECT * DriverObject
Definition: iotypes.h:2111
#define FILE_READ_DATA
Definition: nt_native.h:628
PDRIVER_EXTENSION DriverExtension
Definition: iotypes.h:2174
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
PUNICODE_STRING HardwareDatabase
Definition: iotypes.h:2176
void DPRINT(...)
Definition: polytest.cpp:61
CSHORT Size
Definition: iotypes.h:2168
NTSTATUS NTAPI ObCreateObject(IN KPROCESSOR_MODE ProbeMode OPTIONAL, IN POBJECT_TYPE Type, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN KPROCESSOR_MODE AccessMode, IN OUT PVOID ParseContext OPTIONAL, IN ULONG ObjectSize, IN ULONG PagedPoolCharge OPTIONAL, IN ULONG NonPagedPoolCharge OPTIONAL, OUT PVOID *Object)
Definition: oblife.c:952
LPTSTR ServiceName
Definition: ServiceMain.c:15
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static const WCHAR L[]
Definition: oid.c:1250
NTKERNELAPI volatile KSYSTEM_TIME KeTickCount
Definition: clock.c:19
struct _DRIVER_OBJECT DRIVER_OBJECT
Status
Definition: gdiplustypes.h:24
UNICODE_STRING ServiceKeyName
Definition: iotypes.h:2114
NTSTATUS NTAPI ObInsertObject(IN PVOID Object, IN PACCESS_STATE AccessState OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG ObjectPointerBias, OUT PVOID *NewObject OPTIONAL, OUT PHANDLE Handle)
Definition: obhandle.c:2932
unsigned short USHORT
Definition: pedump.c:61
struct _DRIVER_EXTENSION * PDRIVER_EXTENSION
UNICODE_STRING IopHardwareDatabaseKey
Definition: driver.c:29
#define IO_TYPE_DRIVER
#define DPRINT1
Definition: precomp.h:8
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: iotypes.h:2181
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
ULONG DriverSize
Definition: iotypes.h:2172
CSHORT Type
Definition: iotypes.h:2167
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
PVOID DriverSection
Definition: iotypes.h:2173
PDRIVER_INITIALIZE DriverInit
Definition: iotypes.h:2178
UNICODE_STRING DriverName
Definition: iotypes.h:2175
PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2169
#define DRIVER_ROOT_NAME
Definition: ldr.h:5
VOID NTAPI ObMakeTemporaryObject(IN PVOID ObjectBody)
Definition: oblife.c:1361

Referenced by IoCreateDriver(), and IopInitializeDriverModule().

◆ IopCreateRegistryKeyEx()

NTSTATUS NTAPI IopCreateRegistryKeyEx ( OUT PHANDLE  Handle,
IN HANDLE BaseHandle  OPTIONAL,
IN PUNICODE_STRING  KeyName,
IN ACCESS_MASK  DesiredAccess,
IN ULONG  CreateOptions,
OUT PULONG Disposition  OPTIONAL 
)

◆ IopCreateVpb()

NTSTATUS NTAPI IopCreateVpb ( IN PDEVICE_OBJECT  DeviceObject)

Definition at line 163 of file volume.c.

164 {
165  PVPB Vpb;
166 
167  /* Allocate the Vpb */
169  sizeof(VPB),
170  TAG_VPB);
171  if (!Vpb) return STATUS_INSUFFICIENT_RESOURCES;
172 
173  /* Clear it so we don't waste time manually */
174  RtlZeroMemory(Vpb, sizeof(VPB));
175 
176  /* Set the Header and Device Field */
177  Vpb->Type = IO_TYPE_VPB;
178  Vpb->Size = sizeof(VPB);
179  Vpb->RealDevice = DeviceObject;
180 
181  /* Link it to the Device Object */
182  DeviceObject->Vpb = Vpb;
183  return STATUS_SUCCESS;
184 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TAG_VPB
Definition: cdprocs.h:98
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define IO_TYPE_VPB
struct _VPB VPB
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
Definition: iotypes.h:166
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2938
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1664

Referenced by IoCreateDevice(), and IoVerifyVolume().

◆ IopDeleteDevice()

VOID NTAPI IopDeleteDevice ( IN PVOID  ObjectBody)

Definition at line 52 of file device.c.

53 {
54  PDEVICE_OBJECT DeviceObject = ObjectBody;
56  PAGED_CODE();
57 
58  /* Cleanup and free the device node */
59  if (DeviceNode)
61 
62  /* Dereference the driver object, referenced in IoCreateDevice */
63  if (DeviceObject->DriverObject)
64  ObDereferenceObject(DeviceObject->DriverObject);
65 }
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define PAGED_CODE()
Definition: video.h:57
Definition: Node.h:9
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
NTSTATUS IopFreeDeviceNode(IN PDEVICE_NODE DeviceNode)
PDEVICE_NODE FASTCALL IopGetDeviceNode(IN PDEVICE_OBJECT DeviceObject)

Referenced by IopCreateObjectTypes().

◆ IopDeleteDriver()

VOID NTAPI IopDeleteDriver ( IN PVOID  ObjectBody)

Definition at line 58 of file driver.c.

59 {
60  PDRIVER_OBJECT DriverObject = ObjectBody;
61  PIO_CLIENT_EXTENSION DriverExtension, NextDriverExtension;
62  PAGED_CODE();
63 
64  DPRINT1("Deleting driver object '%wZ'\n", &DriverObject->DriverName);
65 
66  /* There must be no device objects remaining at this point */
68 
69  /* Get the extension and loop them */
70  DriverExtension = IoGetDrvObjExtension(DriverObject)->ClientDriverExtension;
71  while (DriverExtension)
72  {
73  /* Get the next one */
74  NextDriverExtension = DriverExtension->NextExtension;
76 
77  /* Move on */
78  DriverExtension = NextDriverExtension;
79  }
80 
81  /* Check if the driver image is still loaded */
83  {
84  /* Unload it */
86  }
87 
88  /* Check if it has a name */
90  {
91  /* Free it */
93  }
94 
95  /* Check if it has a service key name */
97  {
98  /* Free it */
100  }
101 }
#define PAGED_CODE()
Definition: video.h:57
PDRIVER_EXTENSION DriverExtension
Definition: iotypes.h:2174
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
NTSTATUS NTAPI MmUnloadSystemImage(IN PVOID ImageHandle)
Definition: sysldr.c:912
#define TAG_DRIVER_EXTENSION
Definition: tag.h:42
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
UNICODE_STRING ServiceKeyName
Definition: iotypes.h:2114
#define DPRINT1
Definition: precomp.h:8
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define IoGetDrvObjExtension(DriverObject)
Definition: io.h:132
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
PVOID DriverSection
Definition: iotypes.h:2173
UNICODE_STRING DriverName
Definition: iotypes.h:2175
PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2169

Referenced by IopCreateObjectTypes().

◆ IopDeleteFile()

VOID NTAPI IopDeleteFile ( IN PVOID  ObjectBody)

Definition at line 1354 of file file.c.

1355 {
1356  PFILE_OBJECT FileObject = (PFILE_OBJECT)ObjectBody;
1357  PIRP Irp;
1358  PIO_STACK_LOCATION StackPtr;
1359  NTSTATUS Status;
1360  KEVENT Event;
1362  BOOLEAN DereferenceDone = FALSE;
1363  PVPB Vpb;
1364  KIRQL OldIrql;
1365  IOTRACE(IO_FILE_DEBUG, "ObjectBody: %p\n", ObjectBody);
1366 
1367  /* Check if the file has a device object */
1368  if (FileObject->DeviceObject)
1369  {
1370  /* Check if this is a direct open or not */
1371  if (FileObject->Flags & FO_DIRECT_DEVICE_OPEN)
1372  {
1373  /* Get the attached device */
1374  DeviceObject = IoGetAttachedDevice(FileObject->DeviceObject);
1375  }
1376  else
1377  {
1378  /* Use the file object's device object */
1380  }
1381 
1382  /* Sanity check */
1383  ASSERT(!(FileObject->Flags & FO_SYNCHRONOUS_IO) ||
1384  (InterlockedExchange((PLONG)&FileObject->Busy, TRUE) == FALSE));
1385 
1386  /* Check if the handle wasn't created yet */
1387  if (!(FileObject->Flags & FO_HANDLE_CREATED))
1388  {
1389  /* Send the cleanup IRP */
1390  IopCloseFile(NULL, ObjectBody, 0, 1, 1);
1391  }
1392 
1393  /* Clear and set up Events */
1394  KeClearEvent(&FileObject->Event);
1396 
1397  /* Allocate an IRP */
1399 
1400  /* Set it up */
1401  Irp->UserEvent = &Event;
1402  Irp->UserIosb = &Irp->IoStatus;
1403  Irp->Tail.Overlay.Thread = PsGetCurrentThread();
1404  Irp->Tail.Overlay.OriginalFileObject = FileObject;
1406 
1407  /* Set up Stack Pointer Data */
1408  StackPtr = IoGetNextIrpStackLocation(Irp);
1409  StackPtr->MajorFunction = IRP_MJ_CLOSE;
1410  StackPtr->FileObject = FileObject;
1411 
1412  /* Queue the IRP */
1414 
1415  /* Get the VPB and check if this isn't a direct open */
1416  Vpb = FileObject->Vpb;
1417  if ((Vpb) && !(FileObject->Flags & FO_DIRECT_DEVICE_OPEN))
1418  {
1419  /* Dereference the VPB before the close */
1420  InterlockedDecrement((PLONG)&Vpb->ReferenceCount);
1421  }
1422 
1423  /* Check if the FS will never disappear by itself */
1424  if (FileObject->DeviceObject->Flags & DO_NEVER_LAST_DEVICE)
1425  {
1426  /* Dereference it */
1427  InterlockedDecrement(&FileObject->DeviceObject->ReferenceCount);
1428  DereferenceDone = TRUE;
1429  }
1430 
1431  /* Call the FS Driver */
1433  if (Status == STATUS_PENDING)
1434  {
1435  /* Wait for completion */
1437  }
1438 
1439  /* De-queue the IRP */
1443 
1444  /* Free the IRP */
1445  IoFreeIrp(Irp);
1446 
1447  /* Clear the file name */
1448  if (FileObject->FileName.Buffer)
1449  {
1450  /*
1451  * Don't use TAG_IO_NAME since the FileObject's FileName
1452  * may have been re-allocated using a different tag
1453  * by a filesystem.
1454  */
1455  ExFreePoolWithTag(FileObject->FileName.Buffer, 0);
1456  FileObject->FileName.Buffer = NULL;
1457  }
1458 
1459  /* Check if the FO had a completion port */
1460  if (FileObject->CompletionContext)
1461  {
1462  /* Free it */
1463  ObDereferenceObject(FileObject->CompletionContext->Port);
1464  ExFreePool(FileObject->CompletionContext);
1465  }
1466 
1467  /* Check if the FO had extension */
1469  {
1470  /* Release filter context structure if any */
1472  }
1473 
1474  /* Check if dereference has been done yet */
1475  if (!DereferenceDone)
1476  {
1477  /* Dereference device object */
1479  }
1480  }
1481 }
#define FO_HANDLE_CREATED
Definition: iotypes.h:1751
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define IRP_CLOSE_OPERATION
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
VOID NTAPI FsRtlPTeardownPerFileObjectContexts(IN PFILE_OBJECT FileObject)
Definition: filtrctx.c:28
#define FO_DIRECT_DEVICE_OPEN
Definition: iotypes.h:1744
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI IopDereferenceDeviceObject(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN ForceUnload)
Definition: device.c:462
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1733
#define IO_FILE_DEBUG
Definition: io.h:20
UCHAR KIRQL
Definition: env_spec_w32.h:591
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE VOID IopQueueIrpToThread(IN PIRP Irp)
Definition: io_x.h:49
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
PIRP NTAPI IopAllocateIrpMustSucceed(IN CCHAR StackSize)
Definition: irp.c:716
#define STATUS_PENDING
Definition: ntstatus.h:82
VOID NTAPI IopCloseFile(IN PEPROCESS Process OPTIONAL, IN PVOID ObjectBody, IN ACCESS_MASK GrantedAccess, IN ULONG HandleCount, IN ULONG SystemHandleCount)
Definition: file.c:2177
#define DO_NEVER_LAST_DEVICE
Definition: env_spec_w32.h:402
* PFILE_OBJECT
Definition: iotypes.h:1955
#define IOTRACE(x, fmt,...)
Definition: io.h:47
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define InterlockedDecrement
Definition: armddk.h:52
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define FO_FILE_OBJECT_HAS_EXTENSION
Definition: iotypes.h:144
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
#define InterlockedExchange
Definition: armddk.h:54
Status
Definition: gdiplustypes.h:24
FORCEINLINE VOID IopUnQueueIrpFromThread(IN PIRP Irp)
Definition: io_x.h:65
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
PDEVICE_OBJECT NTAPI IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1385
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
Definition: iotypes.h:166
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
#define IRP_SYNCHRONOUS_API
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
signed int * PLONG
Definition: retypes.h:5
#define APC_LEVEL
Definition: env_spec_w32.h:695
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1664
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by IopCreateObjectTypes(), and IopParseDevice().

◆ IopDeleteIoCompletion()

VOID NTAPI IopDeleteIoCompletion ( PVOID  ObjectBody)

Definition at line 100 of file iocomp.c.

101 {
102  PKQUEUE Queue = ObjectBody;
103  PLIST_ENTRY FirstEntry;
104  PLIST_ENTRY CurrentEntry;
105  PIRP Irp;
107 
108  /* Rundown the Queue */
109  FirstEntry = KeRundownQueue(Queue);
110  if (FirstEntry)
111  {
112  /* Loop the packets */
113  CurrentEntry = FirstEntry;
114  do
115  {
116  /* Get the Packet */
117  Packet = CONTAINING_RECORD(CurrentEntry,
119  ListEntry);
120 
121  /* Go to next Entry */
122  CurrentEntry = CurrentEntry->Flink;
123 
124  /* Check if it's part of an IRP, or a separate packet */
125  if (Packet->PacketType == IopCompletionPacketIrp)
126  {
127  /* Get the IRP and free it */
128  Irp = CONTAINING_RECORD(Packet, IRP, Tail.Overlay.ListEntry);
129  IoFreeIrp(Irp);
130  }
131  else
132  {
133  /* Use common routine */
135  }
136  } while (FirstEntry != CurrentEntry);
137  }
138 }
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
_In_ PIRP Irp
Definition: csq.h:116
IRP
Definition: iotypes.h:2463
PLIST_ENTRY NTAPI KeRundownQueue(IN PKQUEUE Queue)
Definition: queue.c:438
VOID NTAPI IopFreeMiniPacket(PIOP_MINI_COMPLETION_PACKET Packet)
Definition: iocomp.c:63
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
Definition: typedefs.h:117
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666

Referenced by IopCreateObjectTypes().

◆ IopDereferenceDeviceObject()

VOID NTAPI IopDereferenceDeviceObject ( IN PDEVICE_OBJECT  DeviceObject,
IN BOOLEAN  ForceUnload 
)

Definition at line 462 of file device.c.

464 {
465  /* Sanity check */
466  ASSERT(DeviceObject->ReferenceCount);
467 
468  /* Dereference the device */
469  InterlockedDecrement(&DeviceObject->ReferenceCount);
470 
471  /*
472  * Check if we can unload it and it's safe to unload (or if we're forcing
473  * an unload, which is OK too).
474  */
475  ASSERT(!ForceUnload);
476  if (!(DeviceObject->ReferenceCount) &&
478  {
479  /* Unload it */
481  }
482 }
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define DOE_DELETE_PENDING
Definition: iotypes.h:150
#define InterlockedDecrement
Definition: armddk.h:52
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
VOID NTAPI IopUnloadDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:390
#define IoGetDevObjExtension(DeviceObject)
Definition: io.h:125

Referenced by IoCreateStreamFileObjectEx(), IoCreateStreamFileObjectLite(), IopCheckVpbMounted(), IopDeleteFile(), and IopParseDevice().

◆ IopDereferenceVpbAndFree()

VOID NTAPI IopDereferenceVpbAndFree ( IN PVPB  Vpb)

Definition at line 191 of file volume.c.

192 {
193  KIRQL OldIrql;
194 
195  /* Lock the VPBs and decrease references */
197  Vpb->ReferenceCount--;
198 
199  /* Check if we're out of references */
200  if (!Vpb->ReferenceCount && Vpb->RealDevice->Vpb == Vpb &&
201  !(Vpb->Flags & VPB_PERSISTENT))
202  {
203  /* Release VPB lock */
205 
206  /* And free VPB */
208  }
209  else
210  {
211  /* Release VPB lock */
213  }
214 }
VOID NTAPI IoAcquireVpbSpinLock(OUT PKIRQL Irql)
Definition: volume.c:1209
PVPB Vpb
Definition: cdstruc.h:517
#define VPB_PERSISTENT
Definition: iotypes.h:1766
#define TAG_VPB
Definition: cdprocs.h:98
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
VOID NTAPI IoReleaseVpbSpinLock(IN KIRQL Irql)
Definition: volume.c:1220
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1664

Referenced by IopParseDevice(), and IoVerifyVolume().

◆ IopDetectResourceConflict()

NTSTATUS NTAPI IopDetectResourceConflict ( IN PCM_RESOURCE_LIST  ResourceList,
IN BOOLEAN  Silent,
OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR  ConflictingDescriptor 
)

Definition at line 1200 of file pnpres.c.

1204 {
1207  HANDLE ResourceMapKey = NULL, ChildKey2 = NULL, ChildKey3 = NULL;
1208  ULONG KeyInformationLength, RequiredLength, KeyValueInformationLength, KeyNameInformationLength;
1209  PKEY_BASIC_INFORMATION KeyInformation;
1210  PKEY_VALUE_PARTIAL_INFORMATION KeyValueInformation;
1212  ULONG ChildKeyIndex1 = 0, ChildKeyIndex2 = 0, ChildKeyIndex3 = 0;
1213  NTSTATUS Status;
1214 
1215  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\HARDWARE\\RESOURCEMAP");
1217  &KeyName,
1219  NULL,
1220  NULL);
1221  Status = ZwOpenKey(&ResourceMapKey, KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, &ObjectAttributes);
1222  if (!NT_SUCCESS(Status))
1223  {
1224  /* The key is missing which means we are the first device */
1225  return STATUS_SUCCESS;
1226  }
1227 
1228  while (TRUE)
1229  {
1230  Status = ZwEnumerateKey(ResourceMapKey,
1231  ChildKeyIndex1,
1233  NULL,
1234  0,
1235  &RequiredLength);
1237  break;
1239  {
1240  KeyInformationLength = RequiredLength;
1241  KeyInformation = ExAllocatePoolWithTag(PagedPool,
1242  KeyInformationLength,
1243  TAG_IO);
1244  if (!KeyInformation)
1245  {
1247  goto cleanup;
1248  }
1249 
1250  Status = ZwEnumerateKey(ResourceMapKey,
1251  ChildKeyIndex1,
1253  KeyInformation,
1254  KeyInformationLength,
1255  &RequiredLength);
1256  }
1257  else
1258  goto cleanup;
1259  ChildKeyIndex1++;
1260  if (!NT_SUCCESS(Status))
1261  {
1262  ExFreePoolWithTag(KeyInformation, TAG_IO);
1263  goto cleanup;
1264  }
1265 
1266  KeyName.Buffer = KeyInformation->Name;
1267  KeyName.MaximumLength = KeyName.Length = (USHORT)KeyInformation->NameLength;
1269  &KeyName,
1271  ResourceMapKey,
1272  NULL);
1273  Status = ZwOpenKey(&ChildKey2,
1275  &ObjectAttributes);
1276  ExFreePoolWithTag(KeyInformation, TAG_IO);
1277  if (!NT_SUCCESS(Status))
1278  goto cleanup;
1279 
1280  while (TRUE)
1281  {
1282  Status = ZwEnumerateKey(ChildKey2,
1283  ChildKeyIndex2,
1285  NULL,
1286  0,
1287  &RequiredLength);
1289  break;
1290  else if (Status == STATUS_BUFFER_TOO_SMALL)
1291  {
1292  KeyInformationLength = RequiredLength;
1293  KeyInformation = ExAllocatePoolWithTag(PagedPool,
1294  KeyInformationLength,
1295  TAG_IO);
1296  if (!KeyInformation)
1297  {
1299  goto cleanup;
1300  }
1301 
1302  Status = ZwEnumerateKey(ChildKey2,
1303  ChildKeyIndex2,
1305  KeyInformation,
1306  KeyInformationLength,
1307  &RequiredLength);
1308  }
1309  else
1310  goto cleanup;
1311  ChildKeyIndex2++;
1312  if (!NT_SUCCESS(Status))
1313  {
1314  ExFreePoolWithTag(KeyInformation, TAG_IO);
1315  goto cleanup;
1316  }
1317 
1318  KeyName.Buffer = KeyInformation->Name;
1319  KeyName.MaximumLength = KeyName.Length = (USHORT)KeyInformation->NameLength;
1321  &KeyName,
1323  ChildKey2,
1324  NULL);
1325  Status = ZwOpenKey(&ChildKey3, KEY_QUERY_VALUE, &ObjectAttributes);
1326  ExFreePoolWithTag(KeyInformation, TAG_IO);
1327  if (!NT_SUCCESS(Status))
1328  goto cleanup;
1329 
1330  while (TRUE)
1331  {
1332  Status = ZwEnumerateValueKey(ChildKey3,
1333  ChildKeyIndex3,
1335  NULL,
1336  0,
1337  &RequiredLength);
1339  break;
1340  else if (Status == STATUS_BUFFER_TOO_SMALL)
1341  {
1342  KeyValueInformationLength = RequiredLength;
1343  KeyValueInformation = ExAllocatePoolWithTag(PagedPool,
1344  KeyValueInformationLength,
1345  TAG_IO);
1346  if (!KeyValueInformation)
1347  {
1349  goto cleanup;
1350  }
1351 
1352  Status = ZwEnumerateValueKey(ChildKey3,
1353  ChildKeyIndex3,
1355  KeyValueInformation,
1356  KeyValueInformationLength,
1357  &RequiredLength);
1358  }
1359  else
1360  goto cleanup;
1361  if (!NT_SUCCESS(Status))
1362  {
1363  ExFreePoolWithTag(KeyValueInformation, TAG_IO);
1364  goto cleanup;
1365  }
1366 
1367  Status = ZwEnumerateValueKey(ChildKey3,
1368  ChildKeyIndex3,
1370  NULL,
1371  0,
1372  &RequiredLength);
1374  {
1375  KeyNameInformationLength = RequiredLength;
1377  KeyNameInformationLength + sizeof(WCHAR),
1378  TAG_IO);
1379  if (!KeyNameInformation)
1380  {
1382  goto cleanup;
1383  }
1384 
1385  Status = ZwEnumerateValueKey(ChildKey3,
1386  ChildKeyIndex3,
1389  KeyNameInformationLength,
1390  &RequiredLength);
1391  }
1392  else
1393  goto cleanup;
1394  ChildKeyIndex3++;
1395  if (!NT_SUCCESS(Status))
1396  {
1398  goto cleanup;
1399  }
1400 
1401  KeyNameInformation->Name[KeyNameInformation->NameLength / sizeof(WCHAR)] = UNICODE_NULL;
1402 
1403  /* Skip translated entries */
1404  if (wcsstr(KeyNameInformation->Name, L".Translated"))
1405  {
1407  ExFreePoolWithTag(KeyValueInformation, TAG_IO);
1408  continue;
1409  }
1410 
1412 
1414  (PCM_RESOURCE_LIST)KeyValueInformation->Data,
1415  Silent,
1416  ConflictingDescriptor))
1417  {
1418  ExFreePoolWithTag(KeyValueInformation, TAG_IO);
1420  goto cleanup;
1421  }
1422 
1423  ExFreePoolWithTag(KeyValueInformation, TAG_IO);
1424  }
1425  }
1426  }
1427 
1428 cleanup:
1429  if (ResourceMapKey != NULL)
1430  ObCloseHandle(ResourceMapKey, KernelMode);
1431  if (ChildKey2 != NULL)
1432  ObCloseHandle(ChildKey2, KernelMode);
1433  if (ChildKey3 != NULL)
1434  ObCloseHandle(ChildKey3, KernelMode);
1435 
1438 
1439  return Status;
1440 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TAG_IO
Definition: tag.h:69
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:193
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
LONG NTSTATUS
Definition: precomp.h:26
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: