ReactOS 0.4.16-dev-91-g764881a
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  _DRIVER_INFORMATION
 
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 RD_SYSROOT_INIT_FAILED   6
 
#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 _DRIVER_INFORMATION DRIVER_INFORMATION
 
typedef struct _DRIVER_INFORMATIONPDRIVER_INFORMATION
 
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
 
typedef enum _DEVICE_ACTION DEVICE_ACTION
 

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
}
 
enum  _DEVICE_ACTION {
  PiActionEnumDeviceTree , PiActionEnumRootDevices , PiActionResetDevice , PiActionAddBootDevices ,
  PiActionStartDevice , PiActionQueryState
}
 

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)
 
NTSTATUS NTAPI IopInitializePlugPlayServices (VOID)
 
BOOLEAN NTAPI PpInitSystem (VOID)
 
VOID PnpInit2 (VOID)
 
VOID IopInitDriverImplementation (VOID)
 
NTSTATUS IopGetSystemPowerDeviceObject (IN PDEVICE_OBJECT *DeviceObject)
 
PDEVICE_NODE PipAllocateDeviceNode (IN PDEVICE_OBJECT PhysicalDeviceObject)
 
VOID PiInsertDevNode (_In_ PDEVICE_NODE DeviceNode, _In_ PDEVICE_NODE ParentNode)
 
PNP_DEVNODE_STATE PiSetDevNodeState (_In_ PDEVICE_NODE DeviceNode, _In_ PNP_DEVNODE_STATE NewState)
 
VOID PiSetDevNodeProblem (_In_ PDEVICE_NODE DeviceNode, _In_ UINT32 Problem)
 
VOID PiClearDevNodeProblem (_In_ PDEVICE_NODE DeviceNode)
 
NTSTATUS IopFreeDeviceNode (IN PDEVICE_NODE DeviceNode)
 
NTSTATUS NTAPI IopQueryDeviceCapabilities (PDEVICE_NODE DeviceNode, PDEVICE_CAPABILITIES DeviceCaps)
 
NTSTATUS 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 IoCreateDriverList (VOID)
 
NTSTATUS IoDestroyDriverList (VOID)
 
NTSTATUS IopInitPlugPlayEvents (VOID)
 
NTSTATUS IopQueueDeviceChangeEvent (_In_ const GUID *EventGuid, _In_ const GUID *InterfaceClassGuid, _In_ PUNICODE_STRING SymbolicLinkName)
 
NTSTATUS IopQueueTargetDeviceEvent (_In_ const GUID *Guid, _In_ PUNICODE_STRING DeviceIds)
 
NTSTATUS IopQueueDeviceInstallEvent (_In_ const GUID *Guid, _In_ PUNICODE_STRING DeviceId)
 
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)
 
NTSTATUS NTAPI IopCreateDeviceKeyPath (IN PCUNICODE_STRING RegistryPath, IN ULONG CreateOptions, OUT PHANDLE Handle)
 
NTSTATUS NTAPI IopUpdateRootKey (VOID)
 
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)
 
VOID PiSetDevNodeText (_In_ PDEVICE_NODE DeviceNode, _In_ HANDLE InstanceKey)
 Sets the DeviceNode's DeviceDesc and LocationInformation registry values.
 
NTSTATUS NTAPI IopCreateArcNames (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
NTSTATUS NTAPI IopReassignSystemRoot (IN PLOADER_PARAMETER_BLOCK LoaderBlock, OUT PANSI_STRING NtBootPath)
 
BOOLEAN NTAPI IoInitSystem (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
BOOLEAN IopVerifyDiskSignature (_In_ PDRIVE_LAYOUT_INFORMATION_EX DriveLayout, _In_ PARC_DISK_SIGNATURE ArcDiskSignature, _Out_ PULONG Signature)
 
BOOLEAN NTAPI IoInitializeCrashDump (IN HANDLE PageFileHandle)
 
VOID PiInitializeNotifications (VOID)
 
VOID NTAPI IopReadyDeviceObjects (IN PDRIVER_OBJECT Driver)
 
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 IopGetRelatedTargetDevice (IN PFILE_OBJECT FileObject, OUT PDEVICE_NODE *DeviceNode)
 
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)
 
VOID IopInitBootLog (IN BOOLEAN StartBootLog)
 
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)
 
NTSTATUS NTAPI RawFsDriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
 
NTSTATUS NTAPI PnpRootDriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
 
NTSTATUS PnpRootCreateDeviceObject (OUT PDEVICE_OBJECT *DeviceObject)
 
NTSTATUS PnpRootCreateDevice (IN PUNICODE_STRING ServiceName, OUT PDEVICE_OBJECT *PhysicalDeviceObject, OUT PUNICODE_STRING FullInstancePath)
 
NTSTATUS PnpRootRegisterDevice (IN PDEVICE_OBJECT DeviceObject)
 
VOID PnpRootInitializeDevExtension (VOID)
 
VOID FASTCALL IopInitializeBootDrivers (VOID)
 
VOID FASTCALL IopInitializeSystemDrivers (VOID)
 
VOID NTAPI IopDeleteDriver (IN PVOID ObjectBody)
 
NTSTATUS IopLoadDriver (_In_ HANDLE ServiceHandle, _Out_ PDRIVER_OBJECT *DriverObject)
 
NTSTATUS IopGetDriverNames (_In_ HANDLE ServiceHandle, _Out_ PUNICODE_STRING DriverName, _Out_opt_ PUNICODE_STRING ServiceName)
 
NTSTATUS IopInitializeDriverModule (_In_ PLDR_DATA_TABLE_ENTRY ModuleObject, _In_ HANDLE ServiceHandle, _Out_ PDRIVER_OBJECT *DriverObject, _Out_ NTSTATUS *DriverEntryStatus)
 Initialize a loaded driver.
 
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)
 
NTSTATUS NTAPI IopStartRamdisk (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
NTSTATUS IopFetchConfigurationInformation (_Out_ PWSTR *SymbolicLinkList, _In_ GUID Guid, _In_ ULONG ExpectedInterfaces, _Out_ PULONG Interfaces)
 
VOID IopStoreSystemPartitionInformation (_In_ PUNICODE_STRING NtSystemPartitionDeviceName, _In_ PUNICODE_STRING OsLoaderPathName)
 
VOID PiQueueDeviceAction (_In_ PDEVICE_OBJECT DeviceObject, _In_ DEVICE_ACTION Action, _In_opt_ PKEVENT CompletionEvent, _Out_opt_ NTSTATUS *CompletionStatus)
 Queue a device operation to a worker thread.
 
NTSTATUS PiPerformSyncDeviceAction (_In_ PDEVICE_OBJECT DeviceObject, _In_ DEVICE_ACTION Action)
 Perfom a device operation synchronously via PiQueueDeviceAction.
 
VOID PiNotifyDeviceInterfaceChange (_In_ LPCGUID Event, _In_ LPCGUID InterfaceClassGuid, _In_ PUNICODE_STRING SymbolicLinkName)
 Delivers the event to all drivers subscribed to EventCategoryDeviceInterfaceChange.
 
VOID PiNotifyHardwareProfileChange (_In_ LPCGUID Event)
 Delivers the event to all drivers subscribed to EventCategoryHardwareProfileChange PnP event.
 
VOID PiNotifyTargetDeviceChange (_In_ LPCGUID Event, _In_ PDEVICE_OBJECT DeviceObject, _In_opt_ PTARGET_DEVICE_CUSTOM_NOTIFICATION CustomNotification)
 Delivers the event to all drivers subscribed to EventCategoryTargetDeviceChange PnP event.
 
NTSTATUS PiIrpStartDevice (_In_ PDEVICE_NODE DeviceNode)
 
NTSTATUS PiIrpStopDevice (_In_ PDEVICE_NODE DeviceNode)
 
NTSTATUS PiIrpQueryStopDevice (_In_ PDEVICE_NODE DeviceNode)
 
NTSTATUS PiIrpCancelStopDevice (_In_ PDEVICE_NODE DeviceNode)
 
NTSTATUS PiIrpQueryDeviceRelations (_In_ PDEVICE_NODE DeviceNode, _In_ DEVICE_RELATION_TYPE Type)
 
NTSTATUS PiIrpQueryResources (_In_ PDEVICE_NODE DeviceNode, _Out_ PCM_RESOURCE_LIST *Resources)
 
NTSTATUS PiIrpQueryResourceRequirements (_In_ PDEVICE_NODE DeviceNode, _Out_ PIO_RESOURCE_REQUIREMENTS_LIST *Resources)
 
NTSTATUS PiIrpQueryDeviceText (_In_ PDEVICE_NODE DeviceNode, _In_ LCID LocaleId, _In_ DEVICE_TEXT_TYPE Type, _Out_ PWSTR *DeviceText)
 
NTSTATUS PiIrpQueryPnPDeviceState (_In_ PDEVICE_NODE DeviceNode, _Out_ PPNP_DEVICE_STATE DeviceState)
 

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: wdfdevice.h:2055

Definition at line 129 of file io.h.

◆ IoGetDrvObjExtension

#define IoGetDrvObjExtension (   DriverObject)
Value:
(DriverObject->DriverExtension)) \
struct _EXTENDED_DRIVER_EXTENSION * PEXTENDED_DRIVER_EXTENSION
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213

Definition at line 136 of file io.h.

◆ IOP_CREATE_FILE_OBJECT_EXTENSION

#define IOP_CREATE_FILE_OBJECT_EXTENSION   0x02

Definition at line 97 of file io.h.

◆ IOP_MAX_REPARSE_TRAVERSAL

#define IOP_MAX_REPARSE_TRAVERSAL   0x20

Definition at line 91 of file io.h.

◆ IOP_USE_TOP_LEVEL_DEVICE_HINT

#define IOP_USE_TOP_LEVEL_DEVICE_HINT   0x01

Definition at line 96 of file io.h.

◆ IopAllocateMdlFromLookaside

#define IopAllocateMdlFromLookaside    ObpAllocateObjectCreateInfoBuffer

Definition at line 112 of file io.h.

◆ IopDeviceNodeClearFlag

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

Definition at line 155 of file io.h.

◆ IopDeviceNodeClearProblem

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

Definition at line 209 of file io.h.

◆ IopDeviceNodeClearUserFlag

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

Definition at line 182 of file io.h.

◆ IopDeviceNodeHasFlag

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

Definition at line 164 of file io.h.

◆ IopDeviceNodeHasProblem

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

Definition at line 218 of file io.h.

◆ IopDeviceNodeHasUserFlag

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

Definition at line 191 of file io.h.

◆ IopDeviceNodeSetFlag

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

Definition at line 146 of file io.h.

◆ IopDeviceNodeSetProblem

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

Definition at line 200 of file io.h.

◆ IopDeviceNodeSetUserFlag

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

Definition at line 173 of file io.h.

◆ IopFreeMdlFromLookaside

#define IopFreeMdlFromLookaside    ObpFreeCapturedAttributes

Definition at line 114 of file io.h.

◆ IopInitDeviceTreeTraverseContext

#define IopInitDeviceTreeTraverseContext (   _DeviceTreeTraverseContext,
  _DeviceNode,
  _Action,
  _Context 
)
Value:
{ \
(_DeviceTreeTraverseContext)->FirstDeviceNode = \
(_DeviceNode); \
(_DeviceTreeTraverseContext)->Action = (_Action); \
(_DeviceTreeTraverseContext)->Context = (_Context); }
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510

Definition at line 229 of file io.h.

◆ IopIsValidPhysicalDeviceObject

#define IopIsValidPhysicalDeviceObject (   PhysicalDeviceObject)
Value:
(((PEXTENDED_DEVOBJ_EXTENSION)PhysicalDeviceObject->DeviceObjectExtension)->DeviceNode) && \
@ DeviceNode
Definition: Node.h:9
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
#define DNF_ENUMERATED
Definition: iotypes.h:174

Definition at line 242 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 : \
_In_ PIRP Irp
Definition: csq.h:116
#define FALSE
Definition: types.h:117
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
#define IRP_SYNCHRONOUS_API
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1776

Definition at line 120 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.

◆ RD_SYSROOT_INIT_FAILED

#define RD_SYSROOT_INIT_FAILED   6

Definition at line 86 of file io.h.

Typedef Documentation

◆ COMPLETION_PACKET_TYPE

◆ DEVICE_ACTION

◆ DEVICETREE_TRAVERSE_CONTEXT

◆ DEVICETREE_TRAVERSE_ROUTINE

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

Definition at line 465 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

◆ OPEN_PACKET

◆ 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

◆ 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 269 of file io.h.

270 {
@ IopCompletionPacketIrp
Definition: io.h:271
@ IopCompletionPacketMini
Definition: io.h:272
@ IopCompletionPacketQuota
Definition: io.h:273
enum _COMPLETION_PACKET_TYPE COMPLETION_PACKET_TYPE
enum _COMPLETION_PACKET_TYPE * PCOMPLETION_PACKET_TYPE

◆ _DEVICE_ACTION

Enumerator
PiActionEnumDeviceTree 
PiActionEnumRootDevices 
PiActionResetDevice 
PiActionAddBootDevices 
PiActionStartDevice 
PiActionQueryState 

Definition at line 524 of file io.h.

525{
@ PiActionResetDevice
Definition: io.h:528
@ PiActionQueryState
Definition: io.h:531
@ PiActionAddBootDevices
Definition: io.h:529
@ PiActionStartDevice
Definition: io.h:530
@ PiActionEnumRootDevices
Definition: io.h:527
@ PiActionEnumDeviceTree
Definition: io.h:526
enum _DEVICE_ACTION DEVICE_ACTION

◆ _IOP_DEVICE_LIST_OPERATION

Enumerator
IopRemove 
IopAdd 

Definition at line 250 of file io.h.

251{
252 IopRemove,
253 IopAdd
enum _IOP_DEVICE_LIST_OPERATION * PIOP_DEVICE_LIST_OPERATION
@ IopAdd
Definition: io.h:253
@ IopRemove
Definition: io.h:252
enum _IOP_DEVICE_LIST_OPERATION IOP_DEVICE_LIST_OPERATION

◆ _IOP_TRANSFER_TYPE

Enumerator
IopReadTransfer 
IopWriteTransfer 
IopOtherTransfer 

Definition at line 259 of file io.h.

260{
enum _IOP_TRANSFER_TYPE IOP_TRANSFER_TYPE
@ IopWriteTransfer
Definition: io.h:262
@ IopReadTransfer
Definition: io.h:261
@ IopOtherTransfer
Definition: io.h:263
enum _IOP_TRANSFER_TYPE * PIOP_TRANSFER_TYPE

◆ _SECURITY_DESCRIPTOR_TYPE

Enumerator
RestrictedPublic 
UnrestrictedPublic 
RestrictedPublicOpen 
UnrestrictedPublicOpen 
SystemDefault 

Definition at line 512 of file io.h.

513{
enum _SECURITY_DESCRIPTOR_TYPE SECURITY_DESCRIPTOR_TYPE
@ RestrictedPublicOpen
Definition: io.h:516
@ RestrictedPublic
Definition: io.h:514
@ UnrestrictedPublicOpen
Definition: io.h:517
@ SystemDefault
Definition: io.h:518
@ UnrestrictedPublic
Definition: io.h:515
enum _SECURITY_DESCRIPTOR_TYPE * PSECURITY_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",
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 */
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 PAGED_CODE()
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:116
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define KeDelayExecutionThread(mode, foo, t)
Definition: env_spec_w32.h:484
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define KernelMode
Definition: asm.h:34
DWORD Interval
Definition: netstat.c:30
#define IO_IRP_DEBUG
Definition: io.h:19
#define IOTRACE(x, fmt,...)
Definition: io.h:47
VOID NTAPI IopDisassociateThreadIrp(VOID)
Definition: irp.c:115
BOOLEAN NTAPI IoCancelIrp(IN PIRP Irp)
Definition: irp.c:1101
LIST_ENTRY IrpList
Definition: pstypes.h:1145
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

Referenced by PspExitThread().

◆ IoChangeFileObjectFilterContext()

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

Definition at line 2511 of file file.c.

2514{
2516 PFILE_OBJECT_EXTENSION FileObjectExtension;
2517
2519 {
2521 }
2522
2523 FileObjectExtension = FileObject->FileObjectExtension;
2524 if (Define)
2525 {
2526 /* If define, just set the new value if not value is set
2527 * Success will only contain old value. It is valid if it is NULL
2528 */
2530 }
2531 else
2532 {
2533 /* If not define, we want to reset filter context.
2534 * We will remove value (provided by the caller) and set NULL instead.
2535 * This will only success if caller provides correct previous value.
2536 * To catch whether it worked, we substract previous value to expect value:
2537 * If it matches (and thus, we reset), Success will contain 0
2538 * Otherwise, it will contain a non-zero value.
2539 */
2541 }
2542
2543 /* If success isn't 0, it means we failed somewhere (set or unset) */
2544 if (Success != 0)
2545 {
2547 }
2548
2549 return STATUS_SUCCESS;
2550}
#define NULL
Definition: types.h:112
#define ULONG_PTR
Definition: config.h:101
@ Success
Definition: eventcreate.c:712
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
_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:746
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
#define FO_FILE_OBJECT_HAS_EXTENSION
Definition: iotypes.h:144
#define STATUS_ALREADY_COMMITTED
Definition: ntstatus.h:270
#define STATUS_SUCCESS
Definition: shellext.h:65
PVOID FilterContext
Definition: io.h:103
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

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:7
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
#define OBJECT_TO_OBJECT_HEADER(o)
Definition: obtypes.h:111
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define FILE_APPEND_DATA
Definition: nt_native.h:634
#define STATUS_OBJECT_TYPE_MISMATCH
Definition: ntstatus.h:273
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
#define FO_NAMED_PIPE
Definition: iotypes.h:1782

Referenced by ObReferenceFileObjectForWrite().

◆ IoCreateDriverList()

NTSTATUS IoCreateDriverList ( VOID  )

◆ IoDestroyDriverList()

NTSTATUS IoDestroyDriverList ( VOID  )

◆ IoGetFileObjectFilterContext()

PVOID NTAPI IoGetFileObjectFilterContext ( IN PFILE_OBJECT  FileObject)

Definition at line 2496 of file file.c.

2497{
2499 {
2500 PFILE_OBJECT_EXTENSION FileObjectExtension;
2501
2502 FileObjectExtension = FileObject->FileObjectExtension;
2503 return FileObjectExtension->FilterContext;
2504 }
2505
2506 return NULL;
2507}

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{
1612
1613 /* Call the internal helper function */
1616 {
1617 *DeviceObject = DeviceNode->PhysicalDeviceObject;
1618 }
1619 return Status;
1620}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
NTSTATUS NTAPI IopGetRelatedTargetDevice(IN PFILE_OBJECT FileObject, OUT PDEVICE_NODE *DeviceNode)
Definition: device.c:653

Referenced by FsRtlNotifyVolumeEvent(), and NtSetVolumeInformationFile().

◆ IoInitCancelHandling()

VOID IoInitCancelHandling ( VOID  )

◆ IoInitFileSystemImplementation()

VOID NTAPI IoInitFileSystemImplementation ( VOID  )

◆ IoInitializeCrashDump()

BOOLEAN NTAPI IoInitializeCrashDump ( IN HANDLE  PageFileHandle)

Definition at line 649 of file iomgr.c.

650{
652 return FALSE;
653}
#define UNIMPLEMENTED
Definition: debug.h:118

Referenced by NtCreatePagingFile().

◆ IoInitShutdownNotification()

VOID IoInitShutdownNotification ( VOID  )

◆ IoInitSystem()

BOOLEAN NTAPI IoInitSystem ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 465 of file iomgr.c.

466{
467 LARGE_INTEGER ExpireTime;
469 CHAR Buffer[256];
470 ANSI_STRING NtBootPath, RootString;
471
472 /* Initialize empty NT Boot Path */
473 RtlInitEmptyAnsiString(&NtBootPath, Buffer, sizeof(Buffer));
474
475 /* Initialize the lookaside lists */
477
478 /* Initialize all locks and lists */
497
498 /* Initialize PnP notifications */
500
501 /* Initialize the reserve IRP */
503 {
504 DPRINT1("IopInitializeReserveIrp failed!\n");
505 return FALSE;
506 }
507
508 /* Initialize Timer List Lock */
510
511 /* Initialize Timer List */
513
514 /* Initialize the DPC/Timer which will call the other Timer Routines */
515 ExpireTime.QuadPart = -10000000;
518 KeSetTimerEx(&IopTimer, ExpireTime, 1000, &IopTimerDpc);
519
520 /* Create Object Types */
522 {
523 DPRINT1("IopCreateObjectTypes failed!\n");
524 return FALSE;
525 }
526
527 /* Create Object Directories */
529 {
530 DPRINT1("IopCreateRootDirectories failed!\n");
531 return FALSE;
532 }
533
534 /* Initialize PnP manager */
536
537 /* Initialize SHIM engine */
539
540 /* Initialize WMI */
542
543 /* Initialize HAL Root Bus Driver */
545
546 /* Reenumerate what HAL has added (synchronously)
547 * This function call should eventually become a 2nd stage of the PnP initialization */
550 NULL,
551 NULL);
552
553 /* Make loader block available for the whole kernel */
554 IopLoaderBlock = LoaderBlock;
555
556 /* Load boot start drivers */
558
559 /* Call back drivers that asked for */
561
562 /* Check if this was a ramdisk boot */
563 if (!_strnicmp(LoaderBlock->ArcBootDeviceName, "ramdisk(0)", 10))
564 {
565 /* Initialize the ramdisk driver */
566 IopStartRamdisk(LoaderBlock);
567 }
568
569 /* No one should need loader block any longer */
571
572 /* Create ARC names for boot devices */
573 Status = IopCreateArcNames(LoaderBlock);
574 if (!NT_SUCCESS(Status))
575 {
576 DPRINT1("IopCreateArcNames failed: %lx\n", Status);
577 return FALSE;
578 }
579
580 /* Mark the system boot partition */
581 if (!IopMarkBootPartition(LoaderBlock))
582 {
583 DPRINT1("IopMarkBootPartition failed!\n");
584 return FALSE;
585 }
586
587 /* The disk subsystem is initialized here and the SystemRoot is set too.
588 * We can finally load other drivers from the boot volume. */
590
591 /* Load system start drivers */
594
595 /* Reinitialize drivers that requested it */
597
598 /* Convert SystemRoot from ARC to NT path */
599 Status = IopReassignSystemRoot(LoaderBlock, &NtBootPath);
600 if (!NT_SUCCESS(Status))
601 {
602 DPRINT1("IopReassignSystemRoot failed: %lx\n", Status);
603 return FALSE;
604 }
605
606 /* Set the ANSI_STRING for the root path */
607 RootString.MaximumLength = NtSystemRoot.MaximumLength / sizeof(WCHAR);
608 RootString.Length = 0;
610 RootString.MaximumLength,
611 TAG_IO);
612
613 /* Convert the path into the ANSI_STRING */
615 if (!NT_SUCCESS(Status))
616 {
617 DPRINT1("RtlUnicodeStringToAnsiString failed: %lx\n", Status);
618 return FALSE;
619 }
620
621 /* Assign drive letters */
622 IoAssignDriveLetters(LoaderBlock,
623 &NtBootPath,
624 (PUCHAR)RootString.Buffer,
625 &RootString);
626
627 /* Update system root */
629 if (!NT_SUCCESS(Status))
630 {
631 DPRINT1("RtlAnsiStringToUnicodeString failed: %lx\n", Status);
632 return FALSE;
633 }
634
635 /* Load the System DLL and its entrypoints */
637 if (!NT_SUCCESS(Status))
638 {
639 DPRINT1("PsLocateSystemDll failed: %lx\n", Status);
640 return FALSE;
641 }
642
643 /* Return success */
644 return TRUE;
645}
VOID FASTCALL IoAssignDriveLetters(IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, IN PSTRING NtDeviceName, OUT PUCHAR NtSystemPath, OUT PSTRING NtSystemPathString)
Definition: ntoskrnl.c:36
Definition: bufpool.h:45
#define TRUE
Definition: types.h:120
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:712
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
#define PagedPool
Definition: env_spec_w32.h:308
LIST_ENTRY IopErrorLogListHead
Definition: error.c:30
LIST_ENTRY DriverReinitListHead
Definition: driver.c:22
KDPC IopTimerDpc
Definition: iotimer.c:22
VOID NTAPI IopInitLookasideLists(VOID)
Definition: iomgr.c:94
BOOLEAN NTAPI IopCreateRootDirectories(VOID)
Definition: iomgr.c:330
LIST_ENTRY ShutdownListHead
Definition: device.c:21
ERESOURCE IopDriverLoadResource
Definition: driver.c:20
ERESOURCE IopSecurityResource
Definition: iomgr.c:60
BOOLEAN PnPBootDriversInitialized
Definition: pnpinit.c:21
BOOLEAN PnpSystemInit
Definition: iomgr.c:17
KSPIN_LOCK DriverBootReinitListLock
Definition: driver.c:28
BOOLEAN NTAPI WmiInitialize(VOID)
Definition: wmi.c:38
KSPIN_LOCK IoStatisticsLock
Definition: iomgr.c:45
BOOLEAN NTAPI IopMarkBootPartition(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: iomgr.c:395
KSPIN_LOCK IopTimerLock
Definition: iotimer.c:18
KSPIN_LOCK ShutdownListLock
Definition: device.c:22
LIST_ENTRY IopCdRomFileSystemQueueHead
Definition: volume.c:22
ERESOURCE IopDatabaseResource
Definition: volume.c:20
LIST_ENTRY DriverBootReinitListHead
Definition: driver.c:27
KSPIN_LOCK IopLogListLock
Definition: error.c:31
KSPIN_LOCK DriverReinitListLock
Definition: driver.c:23
KTIMER IopTimer
Definition: iotimer.c:23
LIST_ENTRY LastChanceShutdownListHead
Definition: device.c:21
VOID NTAPI IopTimerDispatch(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: iotimer.c:32
LIST_ENTRY IopNetworkFileSystemQueueHead
Definition: volume.c:21
LIST_ENTRY IopDiskFileSystemQueueHead
Definition: volume.c:21
PLOADER_PARAMETER_BLOCK IopLoaderBlock
Definition: iomgr.c:87
LIST_ENTRY IopFsNotifyChangeQueueHead
Definition: volume.c:23
BOOLEAN NTAPI IopCreateObjectTypes(VOID)
Definition: iomgr.c:241
LIST_ENTRY IopTimerQueueHead
Definition: iotimer.c:19
LIST_ENTRY IopTapeFileSystemQueueHead
Definition: volume.c:22
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
@ SynchronizationTimer
UNICODE_STRING NtSystemRoot
Definition: init.c:76
VOID NTAPI IopReinitializeBootDrivers(VOID)
Definition: driver.c:1532
BOOLEAN NTAPI IopInitializeReserveIrp(IN PRESERVE_IRP_ALLOCATOR ReserveIrpAllocator)
Definition: irp.c:549
VOID FASTCALL IopInitializeSystemDrivers(VOID)
Definition: driver.c:1210
NTSTATUS NTAPI IopInitializePlugPlayServices(VOID)
Definition: pnpinit.c:287
VOID FASTCALL IopInitializeBootDrivers(VOID)
Definition: driver.c:1023
NTSTATUS NTAPI IopStartRamdisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: ramdisk.c:26
VOID NTAPI IopReinitializeDrivers(VOID)
Definition: driver.c:1496
NTSTATUS NTAPI IopReassignSystemRoot(IN PLOADER_PARAMETER_BLOCK LoaderBlock, OUT PANSI_STRING NtBootPath)
Definition: arcname.c:842
VOID PiQueueDeviceAction(_In_ PDEVICE_OBJECT DeviceObject, _In_ DEVICE_ACTION Action, _In_opt_ PKEVENT CompletionEvent, _Out_opt_ NTSTATUS *CompletionStatus)
Queue a device operation to a worker thread.
Definition: devaction.c:2659
VOID PiInitializeNotifications(VOID)
Definition: pnpnotify.c:55
PDEVICE_NODE IopRootDeviceNode
Definition: devnode.c:18
NTSTATUS NTAPI IopCreateArcNames(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: arcname.c:39
RESERVE_IRP_ALLOCATOR IopReserveIrpAllocator
Definition: irp.c:19
NTSTATUS NTAPI ApphelpCacheInitialize(VOID)
Definition: apphelp.c:439
NTSTATUS NTAPI PsLocateSystemDll(VOID)
Definition: psmgr.c:187
USHORT MaximumLength
Definition: env_spec_w32.h:377
PDEVICE_OBJECT PhysicalDeviceObject
Definition: iotypes.h:1005
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define TAG_IO
Definition: tag.h:80
BOOLEAN NTAPI KeSetTimerEx(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN LONG Period, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:294
VOID NTAPI KeInitializeTimerEx(OUT PKTIMER Timer, IN TIMER_TYPE Type)
Definition: timerobj.c:244
unsigned char * PUCHAR
Definition: typedefs.h:53
LONGLONG QuadPart
Definition: typedefs.h:114
#define HalInitPnpDriver
Definition: haltypes.h:300
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175

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{
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,
102 FALSE,
103 NULL);
104 }
105 }
106 else
107 {
108 /* We got preempted, so give up */
110 }
111}
unsigned char BOOLEAN
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
LONG NTAPI KeReadStateEvent(IN PKEVENT Event)
Definition: eventobj.c:120
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170
@ Executive
Definition: ketypes.h:415

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 2450 of file file.c.

2455{
2457
2458 PAGED_CODE();
2459
2461
2463 do
2464 {
2466 {
2467 break;
2468 }
2470 Executive,
2471 WaitMode,
2472 Alertable,
2473 NULL);
2474 } while (Status == STATUS_SUCCESS);
2475
2477 if (Status == STATUS_SUCCESS)
2478 {
2480 *LockFailed = FALSE;
2481 }
2482 else
2483 {
2484 if (!FileObject->Busy && FileObject->Waiters)
2485 {
2487 }
2488 *LockFailed = TRUE;
2489 }
2490
2491 return Status;
2492}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedExchange
Definition: armddk.h:54
#define InterlockedDecrement
Definition: armddk.h:52
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
_In_ PVOID _In_ BOOLEAN Alertable
Definition: exfuncs.h:453
int32_t * PLONG
Definition: typedefs.h:58
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define ObReferenceObject
Definition: obfuncs.h:204

Referenced by IopLockFileObject().

◆ 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}
static ULONG StackSize
Definition: StackOverflow.c:19
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
#define LONG_MAX
Definition: limits.h:43
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
long LONG
Definition: pedump.c:60
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790

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,
587 FALSE,
588 NULL);
589 }
590
591 /* It's ours! Initialize it */
593
594 /* And return it to the caller */
596}
VOID NTAPI IoInitializeIrp(IN PIRP Irp, IN USHORT PacketSize, IN CCHAR StackSize)
Definition: irp.c:1854
RESERVE_IRP_ALLOCATOR IopReserveIrpAllocator
Definition: irp.c:19
volatile LONG ReserveIrpInUse
Definition: io.h:504
KEVENT WaitEvent
Definition: io.h:505
#define IoSizeOfIrp(_StackSize)

Referenced by IoPageRead().

◆ IopAssignDeviceResources()

NTSTATUS NTAPI IopAssignDeviceResources ( IN PDEVICE_NODE  DeviceNode)

Definition at line 1116 of file pnpres.c.

1118{
1120 ULONG ListSize;
1121
1123 if (!NT_SUCCESS(Status))
1124 goto ByeBye;
1125
1126 if (!DeviceNode->BootResources && !DeviceNode->ResourceRequirements)
1127 {
1128 /* No resource needed for this device */
1129 DeviceNode->ResourceList = NULL;
1130 DeviceNode->ResourceListTranslated = NULL;
1133
1134 return STATUS_SUCCESS;
1135 }
1136
1137 if (DeviceNode->BootResources)
1138 {
1139 ListSize = PnpDetermineResourceListSize(DeviceNode->BootResources);
1140
1141 DeviceNode->ResourceList = ExAllocatePool(PagedPool, ListSize);
1142 if (!DeviceNode->ResourceList)
1143 {
1145 goto ByeBye;
1146 }
1147
1148 RtlCopyMemory(DeviceNode->ResourceList, DeviceNode->BootResources, ListSize);
1149
1151 if (!NT_SUCCESS(Status))
1152 {
1153 DPRINT1("Boot resources for %wZ cause a resource conflict!\n", &DeviceNode->InstancePath);
1154 ExFreePool(DeviceNode->ResourceList);
1155 DeviceNode->ResourceList = NULL;
1156 }
1157 }
1158 else
1159 {
1160 /* We'll make this from the requirements */
1161 DeviceNode->ResourceList = NULL;
1162 }
1163
1164 /* No resources requirements */
1165 if (!DeviceNode->ResourceRequirements)
1166 goto Finish;
1167
1168 /* Call HAL to fixup our resource requirements list */
1169 HalAdjustResourceList(&DeviceNode->ResourceRequirements);
1170
1171 /* Add resource requirements that aren't in the list we already got */
1173 &DeviceNode->ResourceList);
1174 if (!NT_SUCCESS(Status))
1175 {
1176 DPRINT1("Failed to fixup a resource list from supplied resources for %wZ\n", &DeviceNode->InstancePath);
1178 goto ByeBye;
1179 }
1180
1181 /* IopFixupResourceListWithRequirements should NEVER give us a conflicting list */
1183
1184Finish:
1186 if (!NT_SUCCESS(Status))
1187 {
1189 DPRINT1("Failed to translate resources for %wZ\n", &DeviceNode->InstancePath);
1190 goto ByeBye;
1191 }
1192
1194 if (!NT_SUCCESS(Status))
1195 goto ByeBye;
1196
1198 if (!NT_SUCCESS(Status))
1199 goto ByeBye;
1200
1202
1203 return STATUS_SUCCESS;
1204
1205ByeBye:
1206 if (DeviceNode->ResourceList)
1207 {
1208 ExFreePool(DeviceNode->ResourceList);
1209 DeviceNode->ResourceList = NULL;
1210 }
1211
1212 DeviceNode->ResourceListTranslated = NULL;
1213
1214 return Status;
1215}
#define CM_PROB_TRANSLATION_FAILED
Definition: cfg.h:63
#define CM_PROB_NORMAL_CONFLICT
Definition: cfg.h:42
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
NTSTATUS NTAPI HalAdjustResourceList(IN PIO_RESOURCE_REQUIREMENTS_LIST *ResourceList)
Definition: bus.c:26
#define ASSERT(a)
Definition: mode.c:44
@ DeviceNodeResourcesAssigned
Definition: iotypes.h:538
#define DNF_NO_RESOURCE_REQUIRED
Definition: iotypes.h:178
ULONG NTAPI PnpDetermineResourceListSize(IN PCM_RESOURCE_LIST ResourceList)
Definition: pnpmgr.c:1237
PNP_DEVNODE_STATE PiSetDevNodeState(_In_ PDEVICE_NODE DeviceNode, _In_ PNP_DEVNODE_STATE NewState)
Definition: devnode.c:108
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define STATUS_CONFLICTING_ADDRESSES
Definition: ntstatus.h:261
NTSTATUS IopUpdateResourceMapForPnPDevice(IN PDEVICE_NODE DeviceNode)
Definition: pnpres.c:961
NTSTATUS NTAPI IopFixupResourceListWithRequirements(IN PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList, OUT PCM_RESOURCE_LIST *ResourceList)
Definition: pnpres.c:219
static NTSTATUS IopTranslateDeviceResources(IN PDEVICE_NODE DeviceNode)
Definition: pnpres.c:969
static NTSTATUS IopUpdateControlKeyWithResources(IN PDEVICE_NODE DeviceNode)
Definition: pnpres.c:716
static NTSTATUS IopFilterResourceRequirements(IN PDEVICE_NODE DeviceNode)
Definition: pnpres.c:773
NTSTATUS NTAPI IopDetectResourceConflict(IN PCM_RESOURCE_LIST ResourceList, IN BOOLEAN Silent, OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
Definition: pnpres.c:1255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by IoReportDetectedDevice(), and PiDevNodeStateMachine().

◆ IopAttachFilterDrivers()

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

◆ 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 76 of file volume.c.

80{
83 PVPB Vpb = NULL;
84
85 /* Lock the VPBs */
87
88 /* Set VPB mount settings */
89 Raw = !RemainingName->Length && !OpenPacket->RelatedFileObject;
90 Alertable = (OpenPacket->CreateOptions & FILE_SYNCHRONOUS_IO_ALERT) ?
91 TRUE: FALSE;
92
93 /* Start looping until the VPB is mounted */
94 while (!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
95 {
96 /* Release the lock */
98
99 /* Mount the volume */
101 Raw,
102 FALSE,
103 Alertable,
104 &Vpb);
105
106 /* Check if we failed or if we were alerted */
107 if (!(NT_SUCCESS(*Status)) ||
108 (*Status == STATUS_USER_APC) ||
110 {
111 /* Dereference the device, since IopParseDevice referenced it */
113
114 /* Check if it was a total failure */
115 if (!NT_SUCCESS(*Status)) return NULL;
116
117 /* Otherwise we were alerted */
119 return NULL;
120 }
121 /*
122 * In case IopMountVolume returns a valid VPB
123 * Then, the volume is mounted, return it
124 */
125 else if (Vpb != NULL)
126 {
127 return Vpb;
128 }
129
130 /* Re-acquire the lock */
132 }
133
134 /* Make sure the VPB isn't locked */
136 if (Vpb->Flags & VPB_LOCKED)
137 {
138 /* We're locked, so fail */
140 Vpb = NULL;
141 }
142 else
143 {
144 /* Success! Reference the VPB */
145 Vpb->ReferenceCount++;
146 }
147
148 /* Release the lock and return the VPB */
150 return Vpb;
151}
_Inout_ PFCB _Inout_ PUNICODE_STRING RemainingName
Definition: cdprocs.h:802
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1676
#define FILE_SYNCHRONOUS_IO_ALERT
Definition: from_kernel.h:30
VOID NTAPI IopDereferenceDeviceObject(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN ForceUnload)
Definition: device.c:462
VOID NTAPI IoReleaseVpbSpinLock(IN KIRQL Irql)
Definition: volume.c:1215
NTSTATUS NTAPI IopMountVolume(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN AllowRawMount, IN BOOLEAN DeviceIsLocked, IN BOOLEAN Alertable, OUT PVPB *Vpb)
Definition: volume.c:462
VOID NTAPI IoAcquireVpbSpinLock(OUT PKIRQL Irql)
Definition: volume.c:1204
#define STATUS_ALERTED
Definition: ntstatus.h:80
#define STATUS_USER_APC
Definition: ntstatus.h:78
@ Raw
Definition: sacdrv.h:279
PVPB Vpb
Definition: cdstruc.h:511
Definition: iotypes.h:189
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_WRONG_VOLUME
Definition: udferr_usr.h:140
#define VPB_MOUNTED
Definition: iotypes.h:1807
#define VPB_LOCKED
Definition: iotypes.h:1808

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 */
56
57 /* If this was a file opened for synch I/O, then unlock it */
59
60 /* Now dereference it and return */
63}
static __inline VOID IopUnlockFileObject(IN PFILE_OBJECT FileObject)
Definition: io_x.h:36
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define ObDereferenceObject
Definition: obfuncs.h:203

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 2178 of file file.c.

2183{
2184 PFILE_OBJECT FileObject = (PFILE_OBJECT)ObjectBody;
2185 KEVENT Event;
2186 PIRP Irp;
2187 PIO_STACK_LOCATION StackPtr;
2190 KIRQL OldIrql;
2192 IOTRACE(IO_FILE_DEBUG, "ObjectBody: %p\n", ObjectBody);
2193
2194 /* If this isn't the last handle for the current process, quit */
2195 if (HandleCount != 1) return;
2196
2197 /* Check if the file is locked and has more then one handle opened */
2198 if ((FileObject->LockOperation) && (SystemHandleCount != 1))
2199 {
2200 /* Check if this is a direct open or not */
2202 {
2203 /* Get the attached device */
2205 }
2206 else
2207 {
2208 /* Get the FO's device */
2210 }
2211
2212 /* Check if this is a sync FO and lock it */
2214 {
2216 }
2217
2218 /* Go the FastIO path if possible, otherwise fall back to IRP */
2219 if (DeviceObject->DriverObject->FastIoDispatch == NULL ||
2220 DeviceObject->DriverObject->FastIoDispatch->FastIoUnlockAll == NULL ||
2221 !DeviceObject->DriverObject->FastIoDispatch->FastIoUnlockAll(FileObject, PsGetCurrentProcess(), &IoStatusBlock, DeviceObject))
2222 {
2223 /* Clear and set up Events */
2224 KeClearEvent(&FileObject->Event);
2226
2227 /* Allocate an IRP */
2229
2230 /* Set it up */
2231 Irp->UserEvent = &Event;
2232 Irp->UserIosb = &Irp->IoStatus;
2233 Irp->Tail.Overlay.Thread = PsGetCurrentThread();
2234 Irp->Tail.Overlay.OriginalFileObject = FileObject;
2235 Irp->RequestorMode = KernelMode;
2236 Irp->Flags = IRP_SYNCHRONOUS_API;
2237 Irp->Overlay.AsynchronousParameters.UserApcRoutine = NULL;
2239
2240 /* Set up Stack Pointer Data */
2241 StackPtr = IoGetNextIrpStackLocation(Irp);
2243 StackPtr->MinorFunction = IRP_MN_UNLOCK_ALL;
2244 StackPtr->FileObject = FileObject;
2245
2246 /* Queue the IRP */
2248
2249 /* Call the FS Driver */
2251 if (Status == STATUS_PENDING)
2252 {
2253 /* Wait for completion */
2255 }
2256
2257 /* IO will unqueue & free for us */
2258 }
2259
2260 /* Release the lock if we were holding it */
2262 {
2264 }
2265 }
2266
2267 /* Make sure this is the last handle */
2268 if (SystemHandleCount != 1) return;
2269
2270 /* Check if this is a direct open or not */
2271 if (FileObject->Flags & FO_DIRECT_DEVICE_OPEN)
2272 {
2273 /* Get the attached device */
2275 }
2276 else
2277 {
2278 /* Get the FO's device */
2280 }
2281
2282 /* Set the handle created flag */
2283 FileObject->Flags |= FO_HANDLE_CREATED;
2284
2285 /* Check if this is a sync FO and lock it */
2286 if (Process != NULL &&
2288 {
2290 }
2291
2292 /* Clear and set up Events */
2293 KeClearEvent(&FileObject->Event);
2295
2296 /* Allocate an IRP */
2298
2299 /* Set it up */
2300 Irp->UserEvent = &Event;
2301 Irp->UserIosb = &Irp->IoStatus;
2302 Irp->Tail.Overlay.Thread = PsGetCurrentThread();
2303 Irp->Tail.Overlay.OriginalFileObject = FileObject;
2304 Irp->Overlay.AsynchronousParameters.UserApcRoutine = NULL;
2306
2307 /* Set up Stack Pointer Data */
2308 StackPtr = IoGetNextIrpStackLocation(Irp);
2309 StackPtr->MajorFunction = IRP_MJ_CLEANUP;
2310 StackPtr->FileObject = FileObject;
2311
2312 /* Queue the IRP */
2314
2315 /* Update operation counts */
2317
2318 /* Call the FS Driver */
2320 if (Status == STATUS_PENDING)
2321 {
2322 /* Wait for completion */
2324 }
2325
2326 /* Unqueue the IRP */
2330
2331 /* Free the IRP */
2332 IoFreeIrp(Irp);
2333
2334 /* Release the lock if we were holding it */
2335 if (Process != NULL &&
2337 {
2339 }
2340}
#define VOID
Definition: acefi.h:82
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
static __inline NTSTATUS IopLockFileObject(_In_ PFILE_OBJECT FileObject, _In_ KPROCESSOR_MODE WaitMode)
Definition: io_x.h:12
FORCEINLINE VOID IopQueueIrpToThread(IN PIRP Irp)
Definition: io_x.h:49
static __inline VOID IopUpdateOperationCount(IN IOP_TRANSFER_TYPE Type)
Definition: io_x.h:82
FORCEINLINE VOID IopUnQueueIrpFromThread(IN PIRP Irp)
Definition: io_x.h:66
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
@ SynchronizationEvent
PIRP NTAPI IopAllocateIrpMustSucceed(IN CCHAR StackSize)
Definition: irp.c:716
#define IO_FILE_DEBUG
Definition: io.h:20
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
PDEVICE_OBJECT NTAPI IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1385
#define IoCallDriver
Definition: irp.c:1225
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
#define STATUS_PENDING
Definition: ntstatus.h:82
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2695
#define IRP_MN_UNLOCK_ALL
Definition: iotypes.h:4412
#define IRP_CLOSE_OPERATION
#define FO_HANDLE_CREATED
Definition: iotypes.h:1794
#define FO_DIRECT_DEVICE_OPEN
Definition: iotypes.h:1787
* PFILE_OBJECT
Definition: iotypes.h:1998
#define IRP_MJ_CLEANUP
@ UserRequest
Definition: ketypes.h:421
#define PsGetCurrentProcess
Definition: psfuncs.h:17

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",
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
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 {
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 */
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}
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define IoFreeMdl
Definition: fxmdl.h:89
#define KeGetCurrentThread
Definition: hal.h:55
CPPORT Port[4]
Definition: headless.c:35
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
static __inline VOID IopUpdateTransferCount(IN IOP_TRANSFER_TYPE Type, IN ULONG TransferCount)
Definition: io_x.h:116
@ CurrentApcEnvironment
Definition: ketypes.h:769
VOID(NTAPI * PKNORMAL_ROUTINE)(IN PVOID NormalContext OPTIONAL, IN PVOID SystemArgument1 OPTIONAL, IN PVOID SystemArgument2 OPTIONAL)
Definition: ketypes.h:744
VOID NTAPI IopDoNameTransmogrify(IN PIRP Irp, IN PFILE_OBJECT FileObject, IN PREPARSE_DATA_BUFFER DataBuffer)
Definition: file.c:170
#define IsIrpSynchronous(Irp, FileObject)
Definition: io.h:120
VOID NTAPI IopAbortIrpKernelApc(IN PKAPC Apc)
Definition: irp.c:37
VOID NTAPI IopFreeIrpKernelApc(IN PKAPC Apc, IN PKNORMAL_ROUTINE *NormalRoutine, IN PVOID *NormalContext, IN PVOID *SystemArgument1, IN PVOID *SystemArgument2)
Definition: irp.c:25
BOOLEAN NTAPI KeInsertQueueApc(IN PKAPC Apc, IN PVOID SystemArgument1, IN PVOID SystemArgument2, IN KPRIORITY PriorityBoost)
Definition: apc.c:735
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
LONG NTAPI KeInsertQueue(IN PKQUEUE Queue, IN PLIST_ENTRY Entry)
Definition: queue.c:198
#define STATUS_REPARSE
Definition: ntstatus.h:83
VOID NTAPI ObDereferenceObjectDeferDelete(IN PVOID Object)
Definition: obref.c:358
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
struct _REPARSE_DATA_BUFFER * PREPARSE_DATA_BUFFER
Key()
Definition: map_test.cpp:305
USHORT ReparseDataLength
Definition: shellext.h:166
#define STATUS_VERIFY_REQUIRED
Definition: udferr_usr.h:130
#define NT_ERROR(Status)
Definition: umtypes.h:106
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
#define IRP_DEALLOCATE_BUFFER
#define IRP_INPUT_OPERATION
#define IRP_OB_QUERY_NAME
#define IRP_WRITE_OPERATION
#define IRP_CREATE_OPERATION
#define MAXIMUM_REPARSE_DATA_BUFFER_SIZE
Definition: iotypes.h:7213
#define IRP_READ_OPERATION
#define IO_REPARSE_TAG_MOUNT_POINT
Definition: iotypes.h:7231
#define IRP_BUFFERED_IO
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:688
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:689

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

◆ IopCreateArcNames()

NTSTATUS NTAPI IopCreateArcNames ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 39 of file arcname.c.

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

Referenced by IoInitSystem().

◆ IopCreateDeviceKeyPath()

NTSTATUS NTAPI IopCreateDeviceKeyPath ( IN PCUNICODE_STRING  RegistryPath,
IN ULONG  CreateOptions,
OUT PHANDLE  Handle 
)

Definition at line 522 of file pnpmgr.c.

525{
527 HANDLE hParent = NULL, hKey;
530 PCWSTR Current, Last;
533
534 /* Assume failure */
535 *Handle = NULL;
536
537 /* Open root key for device instances */
539 if (!NT_SUCCESS(Status))
540 {
541 DPRINT1("ZwOpenKey('%wZ') failed with status 0x%08lx\n", &EnumU, Status);
542 return Status;
543 }
544
545 Current = KeyName.Buffer = RegistryPath->Buffer;
546 Last = &RegistryPath->Buffer[RegistryPath->Length / sizeof(WCHAR)];
547
548 /* Go up to the end of the string */
549 while (Current <= Last)
550 {
551 if (Current != Last && *Current != L'\\')
552 {
553 /* Not the end of the string and not a separator */
554 Current++;
555 continue;
556 }
557
558 /* Prepare relative key name */
559 Length = (USHORT)((ULONG_PTR)Current - (ULONG_PTR)KeyName.Buffer);
560 KeyName.MaximumLength = KeyName.Length = Length;
561 DPRINT("Create '%wZ'\n", &KeyName);
562
563 /* Open key */
565 &KeyName,
567 hParent,
568 NULL);
569 Status = ZwCreateKey(&hKey,
570 Current == Last ? KEY_ALL_ACCESS : KEY_CREATE_SUB_KEY,
572 0,
573 NULL,
575 NULL);
576
577 /* Close parent key handle, we don't need it anymore */
578 if (hParent)
579 ZwClose(hParent);
580
581 /* Key opening/creating failed? */
582 if (!NT_SUCCESS(Status))
583 {
584 DPRINT1("ZwCreateKey('%wZ') failed with status 0x%08lx\n", &KeyName, Status);
585 return Status;
586 }
587
588 /* Check if it is the end of the string */
589 if (Current == Last)
590 {
591 /* Yes, return success */
592 *Handle = hKey;
593 return STATUS_SUCCESS;
594 }
595
596 /* Start with this new parent key */
597 hParent = hKey;
598 Current++;
599 KeyName.Buffer = (PWSTR)Current;
600 }
601
602 return STATUS_UNSUCCESSFUL;
603}
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
FxAutoRegKey hKey
ULONG Handle
Definition: gdb_input.c:15
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#define ENUM_ROOT
Definition: io.h:53
#define L(x)
Definition: ntvdm.h:50
unsigned short USHORT
Definition: pedump.c:61
NTSTATUS NTAPI IopOpenRegistryKeyEx(PHANDLE KeyHandle, HANDLE ParentKey, PUNICODE_STRING Name, ACCESS_MASK DesiredAccess)
Definition: pnpmgr.c:885
#define DPRINT
Definition: sndvol32.h:73
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
uint16_t * PWSTR
Definition: typedefs.h:56
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_opt_ WDFKEY _In_ PCUNICODE_STRING _In_ ACCESS_MASK _In_ ULONG CreateOptions
Definition: wdfregistry.h:118

Referenced by IopInstallCriticalDevice(), IopQueryDeviceCapabilities(), IoReportDetectedDevice(), PiControlInitializeDevice(), and PiInitializeDevNode().

◆ 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 158 of file volume.c.

159{
160 PVPB Vpb;
161
162 /* Allocate the Vpb */
164 sizeof(VPB),
165 TAG_VPB);
167
168 /* Clear it so we don't waste time manually */
169 RtlZeroMemory(Vpb, sizeof(VPB));
170
171 /* Set the Header and Device Field */
172 Vpb->Type = IO_TYPE_VPB;
173 Vpb->Size = sizeof(VPB);
174 Vpb->RealDevice = DeviceObject;
175
176 /* Link it to the Device Object */
177 DeviceObject->Vpb = Vpb;
178 return STATUS_SUCCESS;
179}
#define TAG_VPB
Definition: cdprocs.h:106
#define NonPagedPool
Definition: env_spec_w32.h:307
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IO_TYPE_VPB
struct _VPB VPB

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}
PDEVICE_NODE FASTCALL IopGetDeviceNode(IN PDEVICE_OBJECT DeviceObject)
NTSTATUS IopFreeDeviceNode(IN PDEVICE_NODE DeviceNode)

Referenced by IopCreateObjectTypes().

◆ IopDeleteDriver()

VOID NTAPI IopDeleteDriver ( IN PVOID  ObjectBody)

Definition at line 77 of file driver.c.

78{
79 PDRIVER_OBJECT DriverObject = ObjectBody;
80 PIO_CLIENT_EXTENSION DriverExtension, NextDriverExtension;
81 PAGED_CODE();
82
83 DPRINT1("Deleting driver object '%wZ'\n", &DriverObject->DriverName);
84
85 /* There must be no device objects remaining at this point */
86 ASSERT(!DriverObject->DeviceObject);
87
88 /* Get the extension and loop them */
89 DriverExtension = IoGetDrvObjExtension(DriverObject)->ClientDriverExtension;
90 while (DriverExtension)
91 {
92 /* Get the next one */
93 NextDriverExtension = DriverExtension->NextExtension;
95
96 /* Move on */
97 DriverExtension = NextDriverExtension;
98 }
99
100 /* Check if the driver image is still loaded */
101 if (DriverObject->DriverSection)
102 {
103 /* Unload it */
104 MmUnloadSystemImage(DriverObject->DriverSection);
105 }
106
107 /* Check if it has a name */
108 if (DriverObject->DriverName.Buffer)
109 {
110 /* Free it */
111 ExFreePool(DriverObject->DriverName.Buffer);
112 }
113
114 /* Check if it has a service key name */
115 if (DriverObject->DriverExtension->ServiceKeyName.Buffer)
116 {
117 /* Free it */
118 ExFreePool(DriverObject->DriverExtension->ServiceKeyName.Buffer);
119 }
120}
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define IoGetDrvObjExtension(DriverObject)
Definition: io.h:136
NTSTATUS NTAPI MmUnloadSystemImage(IN PVOID ImageHandle)
Definition: sysldr.c:945
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
#define TAG_DRIVER_EXTENSION
Definition: tag.h:61

Referenced by IopCreateObjectTypes().

◆ IopDeleteFile()

VOID NTAPI IopDeleteFile ( IN PVOID  ObjectBody)

Definition at line 1355 of file file.c.

1356{
1357 PFILE_OBJECT FileObject = (PFILE_OBJECT)ObjectBody;
1358 PIRP Irp;
1359 PIO_STACK_LOCATION StackPtr;
1361 KEVENT Event;
1363 BOOLEAN DereferenceDone = FALSE;
1364 PVPB Vpb;
1365 KIRQL OldIrql;
1366 IOTRACE(IO_FILE_DEBUG, "ObjectBody: %p\n", ObjectBody);
1367
1368 /* Check if the file has a device object */
1369 if (FileObject->DeviceObject)
1370 {
1371 /* Check if this is a direct open or not */
1372 if (FileObject->Flags & FO_DIRECT_DEVICE_OPEN)
1373 {
1374 /* Get the attached device */
1376 }
1377 else
1378 {
1379 /* Use the file object's device object */
1381 }
1382
1383 /* Sanity check */
1384 ASSERT(!(FileObject->Flags & FO_SYNCHRONOUS_IO) ||
1386
1387 /* Check if the handle wasn't created yet */
1388 if (!(FileObject->Flags & FO_HANDLE_CREATED))
1389 {
1390 /* Send the cleanup IRP */
1391 IopCloseFile(NULL, ObjectBody, 0, 1, 1);
1392 }
1393
1394 /* Clear and set up Events */
1395 KeClearEvent(&FileObject->Event);
1397
1398 /* Allocate an IRP */
1400
1401 /* Set it up */
1402 Irp->UserEvent = &Event;
1403 Irp->UserIosb = &Irp->IoStatus;
1404 Irp->Tail.Overlay.Thread = PsGetCurrentThread();
1405 Irp->Tail.Overlay.OriginalFileObject = FileObject;
1407
1408 /* Set up Stack Pointer Data */
1409 StackPtr = IoGetNextIrpStackLocation(Irp);
1410 StackPtr->MajorFunction = IRP_MJ_CLOSE;
1411 StackPtr->FileObject = FileObject;
1412
1413 /* Queue the IRP */
1415
1416 /* Get the VPB and check if this isn't a direct open */
1417 Vpb = FileObject->Vpb;
1418 if ((Vpb) && !(FileObject->Flags & FO_DIRECT_DEVICE_OPEN))
1419 {
1420 /* Dereference the VPB before the close */
1421 InterlockedDecrement((PLONG)&Vpb->ReferenceCount);
1422 }
1423
1424 /* Check if the FS will never disappear by itself */
1425 if (FileObject->DeviceObject->Flags & DO_NEVER_LAST_DEVICE)
1426 {
1427 /* Dereference it */
1428 InterlockedDecrement(&FileObject->DeviceObject->ReferenceCount);
1429 DereferenceDone = TRUE;
1430 }
1431
1432 /* Call the FS Driver */
1434 if (Status == STATUS_PENDING)
1435 {
1436 /* Wait for completion */
1438 }
1439
1440 /* De-queue the IRP */
1444
1445 /* Free the IRP */
1446 IoFreeIrp(Irp);
1447
1448 /* Clear the file name */
1449 if (FileObject->FileName.Buffer)
1450 {
1451 /*
1452 * Don't use TAG_IO_NAME since the FileObject's FileName
1453 * may have been re-allocated using a different tag
1454 * by a filesystem.
1455 */
1456 ExFreePoolWithTag(FileObject->FileName.Buffer, 0);
1457 FileObject->FileName.Buffer = NULL;
1458 }
1459
1460 /* Check if the FO had a completion port */
1461 if (FileObject->CompletionContext)
1462 {
1463 /* Free it */
1464 ObDereferenceObject(FileObject->CompletionContext->Port);
1465 ExFreePool(FileObject->CompletionContext);
1466 }
1467
1468 /* Check if the FO had extension */
1470 {
1471 /* Release filter context structure if any */
1473 }
1474
1475 /* Check if dereference has been done yet */
1476 if (!DereferenceDone)
1477 {
1478 /* Dereference device object */
1480 }
1481 }
1482}
#define DO_NEVER_LAST_DEVICE
Definition: env_spec_w32.h:402
VOID NTAPI FsRtlPTeardownPerFileObjectContexts(IN PFILE_OBJECT FileObject)
Definition: filtrctx.c:28
VOID NTAPI IopCloseFile(IN PEPROCESS Process OPTIONAL, IN PVOID ObjectBody, IN ACCESS_MASK GrantedAccess, IN ULONG HandleCount, IN ULONG SystemHandleCount)
Definition: file.c:2178
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45

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}
VOID NTAPI IopFreeMiniPacket(PIOP_MINI_COMPLETION_PACKET Packet)
Definition: iocomp.c:63
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1549
PLIST_ENTRY NTAPI KeRundownQueue(IN PKQUEUE Queue)
Definition: queue.c:438
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2225

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}
#define DOE_DELETE_PENDING
Definition: iotypes.h:150
#define IoGetDevObjExtension(DeviceObject)
Definition: io.h:129
VOID NTAPI IopUnloadDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:390

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

◆ IopDereferenceVpbAndFree()

VOID NTAPI IopDereferenceVpbAndFree ( IN PVPB  Vpb)

Definition at line 186 of file volume.c.

187{
189
190 /* Lock the VPBs and decrease references */
192 Vpb->ReferenceCount--;
193
194 /* Check if we're out of references */
195 if (!Vpb->ReferenceCount && Vpb->RealDevice->Vpb == Vpb &&
196 !(Vpb->Flags & VPB_PERSISTENT))
197 {
198 /* Release VPB lock */
200
201 /* And free VPB */
203 }
204 else
205 {
206 /* Release VPB lock */
208 }
209}
#define VPB_PERSISTENT
Definition: iotypes.h:1809

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 1255 of file pnpres.c.

1259{
1262 HANDLE ResourceMapKey = NULL, ChildKey2 = NULL, ChildKey3 = NULL;
1263 ULONG KeyInformationLength, RequiredLength, KeyValueInformationLength, KeyNameInformationLength;
1264 PKEY_BASIC_INFORMATION KeyInformation;
1265 PKEY_VALUE_PARTIAL_INFORMATION KeyValueInformation;
1267 ULONG ChildKeyIndex1 = 0, ChildKeyIndex2, ChildKeyIndex3;
1269
1270 RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\HARDWARE\\RESOURCEMAP");
1272 &KeyName,
1274 NULL,
1275 NULL);
1276 Status = ZwOpenKey(&ResourceMapKey, KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, &ObjectAttributes);
1277 if (!NT_SUCCESS(Status))
1278 {
1279 /* The key is missing which means we are the first device */
1280 return STATUS_SUCCESS;
1281 }
1282
1283 while (TRUE)
1284 {
1285 Status = ZwEnumerateKey(ResourceMapKey,
1286 ChildKeyIndex1,
1288 NULL,
1289 0,
1292 break;
1294 {
1295 KeyInformationLength = RequiredLength;
1296 KeyInformation = ExAllocatePoolWithTag(PagedPool,
1297 KeyInformationLength,
1298 TAG_IO);
1299 if (!KeyInformation)
1300 {
1302 goto cleanup;
1303 }
1304
1305 Status = ZwEnumerateKey(ResourceMapKey,
1306 ChildKeyIndex1,
1308 KeyInformation,
1309 KeyInformationLength,
1311 }
1312 else
1313 goto cleanup;
1314 ChildKeyIndex1++;
1315 if (!NT_SUCCESS(Status))
1316 {
1317 ExFreePoolWithTag(KeyInformation, TAG_IO);
1318 goto cleanup;
1319 }
1320
1321 KeyName.Buffer = KeyInformation->Name;
1322 KeyName.MaximumLength = KeyName.Length = (USHORT)KeyInformation->NameLength;
1324 &KeyName,
1326 ResourceMapKey,
1327 NULL);
1328 Status = ZwOpenKey(&ChildKey2,
1331 ExFreePoolWithTag(KeyInformation, TAG_IO);
1332 if (!NT_SUCCESS(Status))
1333 goto cleanup;
1334
1335 ChildKeyIndex2 = 0;
1336 while (TRUE)
1337 {
1338 Status = ZwEnumerateKey(ChildKey2,
1339 ChildKeyIndex2,
1341 NULL,
1342 0,
1345 break;
1346 else if (Status == STATUS_BUFFER_TOO_SMALL)
1347 {
1348 KeyInformationLength = RequiredLength;
1349 KeyInformation = ExAllocatePoolWithTag(PagedPool,
1350 KeyInformationLength,
1351 TAG_IO);
1352 if (!KeyInformation)
1353 {
1355 goto cleanup;
1356 }
1357
1358 Status = ZwEnumerateKey(ChildKey2,
1359 ChildKeyIndex2,
1361 KeyInformation,
1362 KeyInformationLength,
1364 }
1365 else
1366 goto cleanup;
1367 ChildKeyIndex2++;
1368 if (!NT_SUCCESS(Status))
1369 {
1370 ExFreePoolWithTag(KeyInformation, TAG_IO);
1371 goto cleanup;
1372 }
1373
1374 KeyName.Buffer = KeyInformation->Name;
1375 KeyName.MaximumLength = KeyName.Length = (USHORT)KeyInformation->NameLength;
1377 &KeyName,
1379 ChildKey2,
1380 NULL);
1381 Status = ZwOpenKey(&ChildKey3, KEY_QUERY_VALUE, &ObjectAttributes);
1382 ExFreePoolWithTag(KeyInformation, TAG_IO);
1383 if (!NT_SUCCESS(Status))
1384 goto cleanup;
1385
1386 ChildKeyIndex3 = 0;
1387 while (TRUE)
1388 {
1389 Status = ZwEnumerateValueKey(ChildKey3,
1390 ChildKeyIndex3,
1392 NULL,
1393 0,
1396 break;
1397 else if (Status == STATUS_BUFFER_TOO_SMALL)
1398 {
1399 KeyValueInformationLength = RequiredLength;
1400 KeyValueInformation = ExAllocatePoolWithTag(PagedPool,
1401 KeyValueInformationLength,
1402 TAG_IO);
1403 if (!KeyValueInformation)
1404 {
1406 goto cleanup;
1407 }
1408
1409 Status = ZwEnumerateValueKey(ChildKey3,
1410 ChildKeyIndex3,
1412 KeyValueInformation,
1413 KeyValueInformationLength,
1415 }
1416 else
1417 goto cleanup;
1418 if (!NT_SUCCESS(Status))
1419 {
1420 ExFreePoolWithTag(KeyValueInformation, TAG_IO);
1421 goto cleanup;
1422 }
1423
1424 Status = ZwEnumerateValueKey(ChildKey3,
1425 ChildKeyIndex3,
1427 NULL,
1428 0,
1431 {
1432 KeyNameInformationLength = RequiredLength;
1434 KeyNameInformationLength + sizeof(WCHAR),
1435 TAG_IO);
1436 if (!KeyNameInformation)
1437 {
1439 goto cleanup;
1440 }
1441
1442 Status = ZwEnumerateValueKey(ChildKey3,
1443 ChildKeyIndex3,
1446 KeyNameInformationLength,
1448 }
1449 else
1450 goto cleanup;
1451 ChildKeyIndex3++;
1452 if (!NT_SUCCESS(Status))
1453 {
1455 goto cleanup;
1456 }
1457
1458 KeyNameInformation->Name[KeyNameInformation->NameLength / sizeof(WCHAR)] = UNICODE_NULL;
1459
1460 /* Skip translated entries */
1461 if (wcsstr(KeyNameInformation->Name, L".Translated"))
1462 {
1464 ExFreePoolWithTag(KeyValueInformation, TAG_IO);
1465 continue;
1466 }
1467
1469
1471 (PCM_RESOURCE_LIST)KeyValueInformation->Data,
1472 Silent,
1473 ConflictingDescriptor))
1474 {
1475 ExFreePoolWithTag(KeyValueInformation, TAG_IO);
1477 goto cleanup;
1478 }
1479
1480 ExFreePoolWithTag(KeyValueInformation, TAG_IO);
1481 }
1482 }
1483 }
1484
1485cleanup:
1486 if (ResourceMapKey != NULL)
1487 ObCloseHandle(ResourceMapKey, KernelMode);
1488 if (ChildKey2 != NULL)
1489 ObCloseHandle(ChildKey2, KernelMode);
1490 if (ChildKey3 != NULL)
1491 ObCloseHandle(ChildKey3, KernelMode);
1492
1495
1496 return Status;
1497}
static void cleanup(void)
Definition: main.c:1335
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
@ KeyNameInformation
Definition: winternl.h:831
@ KeyBasicInformation
Definition: nt_native.h:1131
@ KeyValueBasicInformation
Definition: nt_native.h:1180
@ KeyValuePartialInformation
Definition: nt_native.h:1182
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define UNICODE_NULL
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:205
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3379
static BOOLEAN IopCheckForResourceConflict(IN PCM_RESOURCE_LIST ResourceList1, IN PCM_RESOURCE_LIST ResourceList2, IN BOOLEAN Silent, OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR ConflictingDescriptor)
Definition: pnpres.c:1219
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309
_In_ ULONG _Out_opt_ PULONG RequiredLength
Definition: wmifuncs.h:30

Referenced by IopAssignDeviceResources(), IopCheckDescriptorForConflict(), IoReportResourceForDetection(), and IoReportResourceUsage().

◆ IopDoNameTransmogrify()

VOID NTAPI IopDoNameTransmogrify ( IN PIRP  Irp,
IN PFILE_OBJECT  FileObject,
IN PREPARSE_DATA_BUFFER  DataBuffer 
)

Definition at line 170 of file file.c.

173{
177 PWSTR NewBuffer;
178
179 PAGED_CODE();
180
181 ASSERT(Irp->IoStatus.Status == STATUS_REPARSE);
182 ASSERT(Irp->IoStatus.Information == IO_REPARSE_TAG_MOUNT_POINT);
183 ASSERT(Irp->Tail.Overlay.AuxiliaryBuffer != NULL);
184 ASSERT(DataBuffer != NULL);
185 ASSERT(DataBuffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT);
186 ASSERT(DataBuffer->ReparseDataLength < MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
187 ASSERT(DataBuffer->Reserved < MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
188
189 /* First of all, validate data */
190 if (DataBuffer->ReparseDataLength < REPARSE_DATA_BUFFER_HEADER_SIZE ||
191 (DataBuffer->SymbolicLinkReparseBuffer.PrintNameLength +
192 DataBuffer->SymbolicLinkReparseBuffer.SubstituteNameLength +
194 {
195 Irp->IoStatus.Status = STATUS_IO_REPARSE_DATA_INVALID;
196 }
197
198 /* Everything went right */
199 if (NT_SUCCESS(Irp->IoStatus.Status))
200 {
201 /* Compute buffer & length */
202 Buffer = (PWSTR)((ULONG_PTR)DataBuffer->MountPointReparseBuffer.PathBuffer +
203 DataBuffer->MountPointReparseBuffer.SubstituteNameOffset);
204 Length = DataBuffer->MountPointReparseBuffer.SubstituteNameLength;
205
206 /* Check we don't overflow */
207 if (((ULONG)MAXUSHORT - DataBuffer->Reserved) <= (Length + sizeof(UNICODE_NULL)))
208 {
209 Irp->IoStatus.Status = STATUS_IO_REPARSE_DATA_INVALID;
210 }
211 else
212 {
213 /* Compute how much memory we'll need */
214 RequiredLength = DataBuffer->Reserved + Length + sizeof(UNICODE_NULL);
215
216 /* Check if FileObject can already hold what we need */
217 if (FileObject->FileName.MaximumLength >= RequiredLength)
218 {
219 NewBuffer = FileObject->FileName.Buffer;
220 }
221 else
222 {
223 /* Allocate otherwise */
225 if (NewBuffer == NULL)
226 {
227 Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
228 }
229 }
230 }
231 }
232
233 /* Everything went right */
234 if (NT_SUCCESS(Irp->IoStatus.Status))
235 {
236 /* Copy the reserved data */
237 if (DataBuffer->Reserved)
238 {
239 RtlMoveMemory((PWSTR)((ULONG_PTR)NewBuffer + Length),
240 (PWSTR)((ULONG_PTR)FileObject->FileName.Buffer + FileObject->FileName.Length - DataBuffer->Reserved),
241 DataBuffer->Reserved);
242 }
243
244 /* Then the buffer */
245 if (Length)
246 {
247 RtlCopyMemory(NewBuffer, Buffer, Length);
248 }
249
250 /* And finally replace buffer if new one was allocated */
251 FileObject->FileName.Length = RequiredLength - sizeof(UNICODE_NULL);
252 if (NewBuffer != FileObject->FileName.Buffer)
253 {
254 if (FileObject->FileName.Buffer)
255 {
256 /*
257 * Don't use TAG_IO_NAME since the FileObject's FileName
258 * may have been re-allocated using a different tag
259 * by a filesystem.
260 */
261 ExFreePoolWithTag(FileObject->FileName.Buffer, 0);
262 }
263
264 FileObject->FileName.Buffer = NewBuffer;
265 FileObject->FileName.MaximumLength = RequiredLength;
266 FileObject->FileName.Buffer[RequiredLength / sizeof(WCHAR) - 1] = UNICODE_NULL;
267 }
268 }
269
270 /* We don't need them anymore - it was allocated by the driver */
271 ExFreePool(DataBuffer);
272}
#define REPARSE_DATA_BUFFER_HEADER_SIZE
Definition: vista.c:17
#define STATUS_IO_REPARSE_DATA_INVALID
Definition: ntstatus.h:756
WCHAR PathBuffer[1]
Definition: shellext.h:176
#define TAG_IO_NAME
Definition: tag.h:83
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define MAXUSHORT
Definition: typedefs.h:83
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264

Referenced by IopCompleteRequest(), and IopParseDevice().

◆ IopFetchConfigurationInformation()

NTSTATUS IopFetchConfigurationInformation ( _Out_ PWSTR SymbolicLinkList,
_In_ GUID  Guid,
_In_ ULONG  ExpectedInterfaces,
_Out_ PULONG  Interfaces 
)

Definition at line 821 of file iorsrce.c.

826{
828 ULONG interfaces = 0;
829 PWSTR symbolicLinkList;
830
831 /* Get the associated enabled interfaces with the given GUID */
833 if (!NT_SUCCESS(Status))
834 {
835 /* Zero output and leave */
838
839 return STATUS_UNSUCCESSFUL;
840 }
841
842 symbolicLinkList = *SymbolicLinkList;
843
844 /* Count the number of enabled interfaces by counting the number of symbolic links */
845 while (*symbolicLinkList != UNICODE_NULL)
846 {
847 interfaces++;
848 symbolicLinkList += (wcslen(symbolicLinkList) + 1);
849 }
850
851 /* Matching result will define the result */
853 /* Finally, give back to the caller the number of found interfaces */
854 *Interfaces = interfaces;
855
856 return Status;
857}
static const CLASS_AND_INTERFACES ExpectedInterfaces[]
Definition: browseui.c:13
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSTATUS NTAPI IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid, IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, IN ULONG Flags, OUT PWSTR *SymbolicLinkList)
Definition: deviface.c:454
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:762
_In_opt_ PDEVICE_OBJECT _In_ ULONG _Outptr_result_nullonfailure_ _At_ * SymbolicLinkList(return==0, __drv_allocatesMem(Mem))) PZZWSTR *SymbolicLinkList

Referenced by IopCreateArcNamesCd(), and IopCreateArcNamesDisk().

◆ IopFixupResourceListWithRequirements()

NTSTATUS NTAPI IopFixupResourceListWithRequirements ( IN PIO_RESOURCE_REQUIREMENTS_LIST  RequirementsList,
OUT PCM_RESOURCE_LIST ResourceList 
)

Definition at line 219 of file pnpres.c.

222{
223 ULONG i, OldCount;
224 BOOLEAN AlternateRequired = FALSE;
225 PIO_RESOURCE_LIST ResList;
226
227 /* Save the initial resource count when we got here so we can restore if an alternate fails */
228 if (*ResourceList != NULL)
229 OldCount = (*ResourceList)->List[0].PartialResourceList.Count;
230 else
231 OldCount = 0;
232
233 ResList = &RequirementsList->List[0];
234 for (i = 0; i < RequirementsList->AlternativeLists; i++, ResList = IopGetNextResourceList(ResList))
235 {
236 ULONG ii;
237
238 /* We need to get back to where we were before processing the last alternative list */
239 if (OldCount == 0 && *ResourceList != NULL)
240 {
241 /* Just free it and kill the pointer */
244 }
245 else if (OldCount != 0)
246 {
247 PCM_RESOURCE_LIST NewList;
248
249 /* Let's resize it */
250 (*ResourceList)->List[0].PartialResourceList.Count = OldCount;
251
252 /* Allocate the new smaller list */
254 if (!NewList)
255 return STATUS_NO_MEMORY;
256
257 /* Copy the old stuff back */
259
260 /* Free the old one */
262
263 /* Store the pointer to the new one */
264 *ResourceList = NewList;
265 }
266
267 for (ii = 0; ii < ResList->Count; ii++)
268 {
269 ULONG iii;
270 PCM_PARTIAL_RESOURCE_LIST PartialList = (*ResourceList) ? &(*ResourceList)->List[0].PartialResourceList : NULL;
271 PIO_RESOURCE_DESCRIPTOR IoDesc = &ResList->Descriptors[ii];
272 BOOLEAN Matched = FALSE;
273
274 /* Skip alternates if we don't need one */
275 if (!AlternateRequired && (IoDesc->Option & IO_RESOURCE_ALTERNATIVE))
276 {
277 DPRINT("Skipping unneeded alternate\n");
278 continue;
279 }
280
281 /* Check if we couldn't satsify a requirement or its alternates */
282 if (AlternateRequired && !(IoDesc->Option & IO_RESOURCE_ALTERNATIVE))
283 {
284 DPRINT1("Unable to satisfy preferred resource or alternates in list %lu\n", i);
285
286 /* Break out of this loop and try the next list */
287 break;
288 }
289
290 for (iii = 0; PartialList && iii < PartialList->Count && !Matched; iii++)
291 {
292 /* Partial resource descriptors can be of variable size (CmResourceTypeDeviceSpecific),
293 but only one is allowed and it must be the last one in the list! */
294 PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc = &PartialList->PartialDescriptors[iii];
295
296 /* First check types */
297 if (IoDesc->Type != CmDesc->Type)
298 continue;
299
300 switch (IoDesc->Type)
301 {
303 /* Make sure it satisfies our vector range */
304 if (CmDesc->u.Interrupt.Vector >= IoDesc->u.Interrupt.MinimumVector &&
305 CmDesc->u.Interrupt.Vector <= IoDesc->u.Interrupt.MaximumVector)
306 {
307 /* Found it */
308 Matched = TRUE;
309 }
310 else
311 {
312 DPRINT("Interrupt - Not a match! 0x%x not inside 0x%x to 0x%x\n",
313 CmDesc->u.Interrupt.Vector,
314 IoDesc->u.Interrupt.MinimumVector,
315 IoDesc->u.Interrupt.MaximumVector);
316 }
317 break;
318
321 /* Make sure the length matches and it satisfies our address range */
322 if (CmDesc->u.Memory.Length == IoDesc->u.Memory.Length &&
323 (ULONGLONG)CmDesc->u.Memory.Start.QuadPart >= (ULONGLONG)IoDesc->u.Memory.MinimumAddress.QuadPart &&
324 (ULONGLONG)CmDesc->u.Memory.Start.QuadPart + CmDesc->u.Memory.Length - 1 <= (ULONGLONG)IoDesc->u.Memory.MaximumAddress.QuadPart)
325 {
326 /* Found it */
327 Matched = TRUE;
328 }
329 else
330 {
331 DPRINT("Memory/Port - Not a match! 0x%I64x with length 0x%x not inside 0x%I64x to 0x%I64x with length 0x%x\n",
332 CmDesc->u.Memory.Start.QuadPart,
333 CmDesc->u.Memory.Length,
334 IoDesc->u.Memory.MinimumAddress.QuadPart,
335 IoDesc->u.Memory.MaximumAddress.QuadPart,
336 IoDesc->u.Memory.Length);
337 }
338 break;
339
341 /* Make sure the length matches and it satisfies our bus number range */
342 if (CmDesc->u.BusNumber.Length == IoDesc->u.BusNumber.Length &&
343 CmDesc->u.BusNumber.Start >= IoDesc->u.BusNumber.MinBusNumber &&
344 CmDesc->u.BusNumber.Start + CmDesc->u.BusNumber.Length - 1 <= IoDesc->u.BusNumber.MaxBusNumber)
345 {
346 /* Found it */
347 Matched = TRUE;
348 }
349 else
350 {
351 DPRINT("Bus Number - Not a match! 0x%x with length 0x%x not inside 0x%x to 0x%x with length 0x%x\n",
352 CmDesc->u.BusNumber.Start,
353 CmDesc->u.BusNumber.Length,
354 IoDesc->u.BusNumber.MinBusNumber,
355 IoDesc->u.BusNumber.MaxBusNumber,
356 IoDesc->u.BusNumber.Length);
357 }
358 break;
359
361 /* Make sure it fits in our channel range */
362 if (CmDesc->u.Dma.Channel >= IoDesc->u.Dma.MinimumChannel &&
363 CmDesc->u.Dma.Channel <= IoDesc->u.Dma.MaximumChannel)
364 {
365 /* Found it */
366 Matched = TRUE;
367 }
368 else
369 {
370 DPRINT("DMA - Not a match! 0x%x not inside 0x%x to 0x%x\n",
371 CmDesc->u.Dma.Channel,
372 IoDesc->u.Dma.MinimumChannel,
373 IoDesc->u.Dma.MaximumChannel);
374 }
375 break;
376
377 default:
378 /* Other stuff is fine */
379 Matched = TRUE;
380 break;
381 }
382 }
383
384 /* Check if we found a matching descriptor */
385 if (!Matched)
386 {
387 PCM_RESOURCE_LIST NewList;
390 BOOLEAN FoundResource = TRUE;
391
392 /* Setup the new CM descriptor */
393 NewDesc.Type = IoDesc->Type;
394 NewDesc.Flags = IoDesc->Flags;
395 NewDesc.ShareDisposition = IoDesc->ShareDisposition;
396
397 /* Let'se see if we can find a resource to satisfy this */
398 switch (IoDesc->Type)
399 {
401 /* Find an available interrupt */
402 if (!IopFindInterruptResource(IoDesc, &NewDesc))
403 {
404 DPRINT1("Failed to find an available interrupt resource (0x%x to 0x%x)\n",
405 IoDesc->u.Interrupt.MinimumVector, IoDesc->u.Interrupt.MaximumVector);
406
407 FoundResource = FALSE;
408 }
409 break;
410
412 /* Find an available port range */
413 if (!IopFindPortResource(IoDesc, &NewDesc))
414 {
415 DPRINT1("Failed to find an available port resource (0x%I64x to 0x%I64x length: 0x%x)\n",
416 IoDesc->u.Port.MinimumAddress.QuadPart, IoDesc->u.Port.MaximumAddress.QuadPart,
417 IoDesc->u.Port.Length);
418
419 FoundResource = FALSE;
420 }
421 break;
422
424 /* Find an available memory range */
425 if (!IopFindMemoryResource(IoDesc, &NewDesc))
426 {
427 DPRINT1("Failed to find an available memory resource (0x%I64x to 0x%I64x length: 0x%x)\n",
428 IoDesc->u.Memory.MinimumAddress.QuadPart, IoDesc->u.Memory.MaximumAddress.QuadPart,
429 IoDesc->u.Memory.Length);
430
431 FoundResource = FALSE;
432 }
433 break;
434
436 /* Find an available bus address range */
437 if (!IopFindBusNumberResource(IoDesc, &NewDesc))
438 {
439 DPRINT1("Failed to find an available bus number resource (0x%x to 0x%x length: 0x%x)\n",
440 IoDesc->u.BusNumber.MinBusNumber, IoDesc->u.BusNumber.MaxBusNumber,
441 IoDesc->u.BusNumber.Length);
442
443 FoundResource = FALSE;
444 }
445 break;
446
448 /* Find an available DMA channel */
449 if (!IopFindDmaResource(IoDesc, &NewDesc))
450 {
451 DPRINT1("Failed to find an available dma resource (0x%x to 0x%x)\n",
452 IoDesc->u.Dma.MinimumChannel, IoDesc->u.Dma.MaximumChannel);
453
454 FoundResource = FALSE;
455 }
456 break;
457
458 default:
459 DPRINT1("Unsupported resource type: %x\n", IoDesc->Type);
460 FoundResource = FALSE;
461 break;
462 }
463
464 /* Check if it's missing and required */
465 if (!FoundResource && IoDesc->Option == 0)
466 {
467 /* Break out of this loop and try the next list */
468 DPRINT1("Unable to satisfy required resource in list %lu\n", i);
469 break;
470 }
471 else if (!FoundResource)
472 {
473 /* Try an alternate for this preferred descriptor */
474 AlternateRequired = TRUE;
475 continue;
476 }
477 else
478 {
479 /* Move on to the next preferred or required descriptor after this one */
480 AlternateRequired = FALSE;
481 }
482
483 /* Figure out what we need */
484 if (PartialList == NULL)
485 {
486 /* We need a new list */
487 NewList = ExAllocatePool(PagedPool, sizeof(CM_RESOURCE_LIST));
488 if (!NewList)
489 return STATUS_NO_MEMORY;
490
491 /* Set it up */
492 NewList->Count = 1;
493 NewList->List[0].InterfaceType = RequirementsList->InterfaceType;
494 NewList->List[0].BusNumber = RequirementsList->BusNumber;
495 NewList->List[0].PartialResourceList.Version = 1;
496 NewList->List[0].PartialResourceList.Revision = 1;
497 NewList->List[0].PartialResourceList.Count = 1;
498
499 /* Set our pointer */
500 DescPtr = &NewList->List[0].PartialResourceList.PartialDescriptors[0];
501 }
502 else
503 {
504 /* Allocate the new larger list */
506 if (!NewList)
507 return STATUS_NO_MEMORY;
508
509 /* Copy the old stuff back */
511
512 /* Set our pointer */
513 DescPtr = &NewList->List[0].PartialResourceList.PartialDescriptors[NewList->List[0].PartialResourceList.Count];
514
515 /* Increment the descriptor count */
516 NewList->List[0].PartialResourceList.Count++;
517
518 /* Free the old list */
520 }
521
522 /* Copy the descriptor in */
523 *DescPtr = NewDesc;
524
525 /* Store the new list */
526 *ResourceList = NewList;
527 }
528 }
529
530 /* Check if we need an alternate with no resources left */
531 if (AlternateRequired)
532 {
533 DPRINT1("Unable to satisfy preferred resource or alternates in list %lu\n", i);
534
535 /* Try the next alternate list */
536 continue;
537 }
538
539 /* We're done because we satisfied one of the alternate lists */
540 return STATUS_SUCCESS;
541 }
542
543 /* We ran out of alternates */
544 DPRINT1("Out of alternate lists!\n");
545
546 /* Free the list */
547 if (*ResourceList)
548 {
551 }
552
553 /* Fail */
555}
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
#define CmResourceTypeDma
Definition: hwresource.cpp:126
#define CmResourceTypePort
Definition: hwresource.cpp:123
#define CmResourceTypeBusNumber
Definition: hwresource.cpp:128
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
static BOOLEAN IopFindPortResource(IN PIO_RESOURCE_DESCRIPTOR IoDesc, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
Definition: pnpres.c:122
static BOOLEAN IopFindMemoryResource(IN PIO_RESOURCE_DESCRIPTOR IoDesc, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
Definition: pnpres.c:84
static BOOLEAN IopFindDmaResource(IN PIO_RESOURCE_DESCRIPTOR IoDesc, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
Definition: pnpres.c:160
static BOOLEAN IopFindInterruptResource(IN PIO_RESOURCE_DESCRIPTOR IoDesc, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
Definition: pnpres.c:188
FORCEINLINE PIO_RESOURCE_LIST IopGetNextResourceList(_In_ const IO_RESOURCE_LIST *ResourceList)
Definition: pnpres.c:17
static BOOLEAN IopFindBusNumberResource(IN PIO_RESOURCE_DESCRIPTOR IoDesc, OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc)
Definition: pnpres.c:51
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: hwresource.cpp:160
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@391::@399 BusNumber
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@391::@396 Memory
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@391 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@391::@394 Interrupt
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@391::@397 Dma
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
CM_FULL_RESOURCE_DESCRIPTOR List[1]
Definition: hwresource.cpp:165
union _IO_RESOURCE_DESCRIPTOR::@2051 u
struct _IO_RESOURCE_DESCRIPTOR::@2051::@2052 Port
struct _IO_RESOURCE_DESCRIPTOR::@2051::@2055 Dma
struct _IO_RESOURCE_DESCRIPTOR::@2051::@2053 Memory
struct _IO_RESOURCE_DESCRIPTOR::@2051::@2058 BusNumber
struct _IO_RESOURCE_DESCRIPTOR::@2051::@2054 Interrupt
uint64_t ULONGLONG
Definition: typedefs.h:67
_In_ WDFIORESREQLIST RequirementsList
Definition: wdfresource.h:65
#define IO_RESOURCE_ALTERNATIVE

Referenced by IopAssignDeviceResources(), and IopLegacyResourceAllocation().

◆ IopFreeDeviceNode()

NTSTATUS IopFreeDeviceNode ( IN PDEVICE_NODE  DeviceNode)

◆ IopGetDeviceAttachmentBase()

PDEVICE_OBJECT NTAPI IopGetDeviceAttachmentBase ( IN PDEVICE_OBJECT  DeviceObject)

Definition at line 1486 of file file.c.

1487{
1489
1490 /* Go down the stack to attempt to get the PDO */
1491 for (; ((PEXTENDED_DEVOBJ_EXTENSION)PDO->DeviceObjectExtension)->AttachedTo != NULL;
1492 PDO = ((PEXTENDED_DEVOBJ_EXTENSION)PDO->DeviceObjectExtension)->AttachedTo);
1493
1494 return PDO;
1495}

Referenced by IopGetDevicePDO(), and IopVerifyDriverObjectOnStack().

◆ IopGetDeviceNode()

◆ IopGetDriverNames()

NTSTATUS IopGetDriverNames ( _In_ HANDLE  ServiceHandle,
_Out_ PUNICODE_STRING  DriverName,
_Out_opt_ PUNICODE_STRING  ServiceName 
)

Definition at line 123 of file driver.c.

127{
128 UNICODE_STRING driverName = {.Buffer = NULL}, serviceName;
131
132 PAGED_CODE();
133
134 /* 1. Check the "ObjectName" field in the driver's registry key (it has priority) */
135 status = IopGetRegistryValue(ServiceHandle, L"ObjectName", &kvInfo);
136 if (NT_SUCCESS(status))
137 {
138 /* We've got the ObjectName, use it as the driver name */
139 if (kvInfo->Type != REG_SZ || kvInfo->DataLength == 0)
140 {
141 ExFreePool(kvInfo);
143 }
144
145 driverName.Length = kvInfo->DataLength - sizeof(UNICODE_NULL);
146 driverName.MaximumLength = kvInfo->DataLength;
148 if (!driverName.Buffer)
149 {
150 ExFreePool(kvInfo);
152 }
153
154 RtlMoveMemory(driverName.Buffer,
155 (PVOID)((ULONG_PTR)kvInfo + kvInfo->DataOffset),
156 driverName.Length);
157 driverName.Buffer[driverName.Length / sizeof(WCHAR)] = UNICODE_NULL;
158 ExFreePool(kvInfo);
159 }
160
161 /* Check whether we need to get ServiceName as well, either to construct
162 * the driver name (because we could not use "ObjectName"), or because
163 * it is requested by the caller. */
164 PKEY_BASIC_INFORMATION basicInfo = NULL;
165 if (!NT_SUCCESS(status) || ServiceName != NULL)
166 {
167 /* Retrieve the necessary buffer size */
168 ULONG infoLength;
169 status = ZwQueryKey(ServiceHandle, KeyBasicInformation, NULL, 0, &infoLength);
171 {
173 goto Cleanup;
174 }
175
176 /* Allocate the buffer and retrieve the data */
177 basicInfo = ExAllocatePoolWithTag(PagedPool, infoLength, TAG_IO);
178 if (!basicInfo)
179 {
181 goto Cleanup;
182 }
183
184 status = ZwQueryKey(ServiceHandle, KeyBasicInformation, basicInfo, infoLength, &infoLength);
185 if (!NT_SUCCESS(status))
186 {
187 goto Cleanup;
188 }
189
190 serviceName.Length = basicInfo->NameLength;
191 serviceName.MaximumLength = basicInfo->NameLength;
192 serviceName.Buffer = basicInfo->Name;
193 }
194
195 /* 2. There is no "ObjectName" - construct it ourselves. Depending on the driver type,
196 * it will be either "\Driver<ServiceName>" or "\FileSystem<ServiceName>" */
197 if (driverName.Buffer == NULL)
198 {
199 ASSERT(basicInfo); // Container for serviceName
200
201 /* Retrieve the driver type */
202 ULONG driverType;
203 status = IopGetRegistryValue(ServiceHandle, L"Type", &kvInfo);
204 if (!NT_SUCCESS(status))
205 {
206 goto Cleanup;
207 }
208 if (kvInfo->Type != REG_DWORD || kvInfo->DataLength != sizeof(ULONG))
209 {
210 ExFreePool(kvInfo);
212 goto Cleanup;
213 }
214
215 RtlMoveMemory(&driverType,
216 (PVOID)((ULONG_PTR)kvInfo + kvInfo->DataOffset),
217 sizeof(ULONG));
218 ExFreePool(kvInfo);
219
220 /* Compute the necessary driver name string size */
221 if (driverType == SERVICE_RECOGNIZER_DRIVER || driverType == SERVICE_FILE_SYSTEM_DRIVER)
222 driverName.MaximumLength = sizeof(FILESYSTEM_ROOT_NAME);
223 else
224 driverName.MaximumLength = sizeof(DRIVER_ROOT_NAME);
225
226 driverName.MaximumLength += serviceName.Length;
227 driverName.Length = 0;
228
229 /* Allocate and build it */
231 if (!driverName.Buffer)
232 {
234 goto Cleanup;
235 }
236
237 if (driverType == SERVICE_RECOGNIZER_DRIVER || driverType == SERVICE_FILE_SYSTEM_DRIVER)
239 else
241
243 }
244
245 if (ServiceName != NULL)
246 {
247 ASSERT(basicInfo); // Container for serviceName
248
249 /* Allocate a copy for the caller */
250