ReactOS  r76032
io.h File Reference
#include "ntdddisk.h"
#include "io_x.h"
Include dependency graph for io.h:

Go to the source code of this file.

Classes

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

Macros

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

Typedefs

typedef struct
_FILE_OBJECT_EXTENSION 
FILE_OBJECT_EXTENSION
 
typedef struct
_FILE_OBJECT_EXTENSION
PFILE_OBJECT_EXTENSION
 
typedef enum
_IOP_DEVICE_LIST_OPERATION 
IOP_DEVICE_LIST_OPERATION
 
typedef enum
_IOP_DEVICE_LIST_OPERATION
PIOP_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_TYPE
PCOMPLETION_PACKET_TYPE
 
typedef struct
_IOP_MINI_COMPLETION_PACKET 
IOP_MINI_COMPLETION_PACKET
 
typedef struct
_IOP_MINI_COMPLETION_PACKET
PIOP_MINI_COMPLETION_PACKET
 
typedef struct
_IO_UNLOAD_SAFE_COMPLETION_CONTEXT 
IO_UNLOAD_SAFE_COMPLETION_CONTEXT
 
typedef struct
_IO_UNLOAD_SAFE_COMPLETION_CONTEXT
PIO_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_LOCK
PEXTENDED_IO_REMOVE_LOCK
 
typedef struct _DUMMY_FILE_OBJECT DUMMY_FILE_OBJECT
 
typedef struct _DUMMY_FILE_OBJECTPDUMMY_FILE_OBJECT
 
typedef struct _OPEN_PACKET OPEN_PACKET
 
typedef struct _OPEN_PACKETPOPEN_PACKET
 
typedef struct _LOAD_UNLOAD_PARAMS LOAD_UNLOAD_PARAMS
 
typedef struct
_LOAD_UNLOAD_PARAMS
PLOAD_UNLOAD_PARAMS
 
typedef struct _DRIVER_INFORMATION DRIVER_INFORMATION
 
typedef struct
_DRIVER_INFORMATION
PDRIVER_INFORMATION
 
typedef struct _BOOT_DRIVER_NODE BOOT_DRIVER_NODE
 
typedef struct _BOOT_DRIVER_NODEPBOOT_DRIVER_NODE
 
typedef struct
_IO_BUS_TYPE_GUID_LIST 
IO_BUS_TYPE_GUID_LIST
 
typedef struct
_IO_BUS_TYPE_GUID_LIST
PIO_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_ENTRY
PFS_CHANGE_NOTIFY_ENTRY
 
typedef struct _DRIVER_REINIT_ITEM DRIVER_REINIT_ITEM
 
typedef struct
_DRIVER_REINIT_ITEM
PDRIVER_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_CONTEXT
PDEVICETREE_TRAVERSE_CONTEXT
 

Enumerations

enum  _IOP_DEVICE_LIST_OPERATION { IopRemove, IopAdd }
 
enum  _IOP_TRANSFER_TYPE { IopReadTransfer, IopWriteTransfer, IopOtherTransfer }
 
enum  _COMPLETION_PACKET_TYPE { IopCompletionPacketIrp, IopCompletionPacketMini, IopCompletionPacketQuota }
 

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)
 
VOID IopInitPnpNotificationImplementation (VOID)
 
VOID IopNotifyPlugPlayNotification (IN PDEVICE_OBJECT DeviceObject, IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory, IN LPCGUID Event, IN PVOID EventCategoryData1, IN PVOID EventCategoryData2)
 
NTSTATUS IopGetSystemPowerDeviceObject (IN PDEVICE_OBJECT *DeviceObject)
 
PDEVICE_NODE NTAPI PipAllocateDeviceNode (IN PDEVICE_OBJECT PhysicalDeviceObject)
 
NTSTATUS IopCreateDeviceNode (IN PDEVICE_NODE ParentNode, IN PDEVICE_OBJECT PhysicalDeviceObject, IN PUNICODE_STRING ServiceName, OUT PDEVICE_NODE *DeviceNode)
 
NTSTATUS IopFreeDeviceNode (IN PDEVICE_NODE DeviceNode)
 
NTSTATUS NTAPI IopQueryDeviceCapabilities (PDEVICE_NODE DeviceNode, PDEVICE_CAPABILITIES DeviceCaps)
 
NTSTATUS NTAPI IopSynchronousCall (IN PDEVICE_OBJECT DeviceObject, IN PIO_STACK_LOCATION IoStackLocation, OUT PVOID *Information)
 
NTSTATUS NTAPI IopInitiatePnpIrp (IN PDEVICE_OBJECT DeviceObject, IN PIO_STATUS_BLOCK IoStatusBlock, IN UCHAR MinorFunction, IN PIO_STACK_LOCATION Stack)
 
PDEVICE_NODE FASTCALL IopGetDeviceNode (IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS IopActionConfigureChildServices (IN PDEVICE_NODE DeviceNode, IN PVOID Context)
 
NTSTATUS IopActionInitChildServices (IN PDEVICE_NODE DeviceNode, IN PVOID Context)
 
NTSTATUS IopEnumerateDevice (IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS IoCreateDriverList (VOID)
 
NTSTATUS IoDestroyDriverList (VOID)
 
NTSTATUS IopInitPlugPlayEvents (VOID)
 
NTSTATUS IopQueueTargetDeviceEvent (const GUID *Guid, PUNICODE_STRING DeviceIds)
 
NTSTATUS IopInitializePnpServices (IN PDEVICE_NODE DeviceNode)
 
NTSTATUS NTAPI IopOpenRegistryKeyEx (PHANDLE KeyHandle, HANDLE ParentKey, PUNICODE_STRING Name, ACCESS_MASK DesiredAccess)
 
NTSTATUS NTAPI IopGetRegistryValue (IN HANDLE Handle, IN PWSTR ValueName, OUT PKEY_VALUE_FULL_INFORMATION *Information)
 
NTSTATUS NTAPI IopCreateRegistryKeyEx (OUT PHANDLE Handle, IN HANDLE BaseHandle OPTIONAL, IN PUNICODE_STRING KeyName, IN ACCESS_MASK DesiredAccess, IN ULONG CreateOptions, OUT PULONG Disposition OPTIONAL)
 
NTSTATUS IopTraverseDeviceTree (PDEVICETREE_TRAVERSE_CONTEXT Context)
 
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)
 
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 NTAPI IopVerifyDiskSignature (IN PDRIVE_LAYOUT_INFORMATION_EX DriveLayout, IN PARC_DISK_SIGNATURE ArcDiskSignature, OUT PULONG Signature)
 
VOID NTAPI IopReadyDeviceObjects (IN PDRIVER_OBJECT Driver)
 
NTSTATUS FASTCALL IopInitializeDevice (IN PDEVICE_NODE DeviceNode, IN PDRIVER_OBJECT DriverObject)
 
NTSTATUS IopStartDevice (IN PDEVICE_NODE DeviceNode)
 
NTSTATUS IopStopDevice (IN PDEVICE_NODE DeviceNode)
 
NTSTATUS IopRemoveDevice (IN PDEVICE_NODE DeviceNode)
 
PVPB NTAPI IopCheckVpbMounted (IN POPEN_PACKET OpenPacket, IN PDEVICE_OBJECT DeviceObject, IN PUNICODE_STRING RemainingName, OUT PNTSTATUS Status)
 
NTSTATUS NTAPI IopMountVolume (IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN AllowRawMount, IN BOOLEAN DeviceIsLocked, IN BOOLEAN Alertable, OUT PVPB *Vpb)
 
PVOID IoOpenSymlink (IN PVOID SymbolicLink)
 
PVOID IoOpenFileOnDevice (IN PVOID SymbolicLink, IN PWCHAR Name)
 
NTSTATUS NTAPI IopCreateVpb (IN PDEVICE_OBJECT DeviceObject)
 
VOID NTAPI IopDereferenceVpbAndFree (IN PVPB Vpb)
 
VOID NTAPI IoInitFileSystemImplementation (VOID)
 
VOID NTAPI IoInitVpbImplementation (VOID)
 
NTSTATUS NTAPI IopReferenceDeviceObject (IN PDEVICE_OBJECT DeviceObject)
 
VOID NTAPI IopDereferenceDeviceObject (IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN ForceUnload)
 
NTSTATUS NTAPI IoGetRelatedTargetDevice (IN PFILE_OBJECT FileObject, OUT PDEVICE_OBJECT *DeviceObject)
 
VOID NTAPI IopUnloadDevice (IN PDEVICE_OBJECT DeviceObject)
 
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)
 
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 PnpRootCreateDevice (IN PUNICODE_STRING ServiceName, IN OPTIONAL PDRIVER_OBJECT DriverObject, OUT PDEVICE_OBJECT *PhysicalDeviceObject, OUT OPTIONAL PUNICODE_STRING FullInstancePath)
 
NTSTATUS PnpRootRegisterDevice (IN PDEVICE_OBJECT DeviceObject)
 
VOID FASTCALL IopInitializeBootDrivers (VOID)
 
VOID FASTCALL IopInitializeSystemDrivers (VOID)
 
NTSTATUS NTAPI IopCreateDriver (IN PUNICODE_STRING DriverName OPTIONAL, IN PDRIVER_INITIALIZE InitializationFunction, IN PUNICODE_STRING RegistryPath, IN PCUNICODE_STRING ServiceName, PLDR_DATA_TABLE_ENTRY ModuleObject, OUT PDRIVER_OBJECT *pDriverObject)
 
VOID NTAPI IopDeleteDriver (IN PVOID ObjectBody)
 
NTSTATUS FASTCALL IopGetDriverObject (OUT PDRIVER_OBJECT *DriverObject, IN PUNICODE_STRING ServiceName, IN BOOLEAN FileSystem)
 
NTSTATUS FASTCALL IopLoadServiceModule (IN PUNICODE_STRING ServiceName, OUT PLDR_DATA_TABLE_ENTRY *ModuleObject)
 
NTSTATUS NTAPI IopLoadUnloadDriver (_In_opt_ PCUNICODE_STRING RegistryPath, _Inout_ PDRIVER_OBJECT *DriverObject)
 
NTSTATUS FASTCALL IopInitializeDriverModule (IN PDEVICE_NODE DeviceNode, IN PLDR_DATA_TABLE_ENTRY ModuleObject, IN PUNICODE_STRING ServiceName, IN BOOLEAN FileSystemDriver, OUT PDRIVER_OBJECT *DriverObject)
 
NTSTATUS FASTCALL IopAttachFilterDrivers (IN PDEVICE_NODE DeviceNode, IN HANDLE EnumSubKey, IN HANDLE ClassKey, IN BOOLEAN Lower)
 
VOID NTAPI IopReinitializeDrivers (VOID)
 
VOID NTAPI IopReinitializeBootDrivers (VOID)
 
VOID NTAPI IopDeleteDevice (IN PVOID ObjectBody)
 
NTSTATUS NTAPI IopParseDevice (IN PVOID ParseObject, IN PVOID ObjectType, IN OUT PACCESS_STATE AccessState, IN KPROCESSOR_MODE AccessMode, IN ULONG Attributes, IN OUT PUNICODE_STRING CompleteName, IN OUT PUNICODE_STRING RemainingName, IN OUT PVOID Context, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL, OUT PVOID *Object)
 
NTSTATUS NTAPI IopParseFile (IN PVOID ParseObject, IN PVOID ObjectType, IN OUT PACCESS_STATE AccessState, IN KPROCESSOR_MODE AccessMode, IN ULONG Attributes, IN OUT PUNICODE_STRING CompleteName, IN OUT PUNICODE_STRING RemainingName, IN OUT PVOID Context OPTIONAL, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL, OUT PVOID *Object)
 
VOID NTAPI IopDeleteFile (IN PVOID ObjectBody)
 
NTSTATUS NTAPI IopGetSetSecurityObject (IN PVOID ObjectBody, IN SECURITY_OPERATION_CODE OperationCode, IN PSECURITY_INFORMATION SecurityInformation, IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor, IN OUT PULONG BufferLength, OUT PSECURITY_DESCRIPTOR *OldSecurityDescriptor, IN POOL_TYPE PoolType, IN OUT PGENERIC_MAPPING GenericMapping)
 
NTSTATUS NTAPI IopQueryNameFile (IN PVOID ObjectBody, IN BOOLEAN HasName, 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)
 
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)
 
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 NTAPI IopFetchConfigurationInformation (OUT PWSTR *SymbolicLinkList, IN GUID Guid, IN ULONG ExpectedInterfaces, IN PULONG Interfaces)
 
VOID NTAPI IopStoreSystemPartitionInformation (IN PUNICODE_STRING NtSystemPartitionDeviceName, IN PUNICODE_STRING OsLoaderPathName)
 

Variables

PIO_BUS_TYPE_GUID_LIST IopBusTypeGuidList
 
POBJECT_TYPE IoCompletionType
 
PDEVICE_NODE IopRootDeviceNode
 
KSPIN_LOCK IopDeviceTreeLock
 
ULONG IopTraceLevel
 
GENERAL_LOOKASIDE IopMdlLookasideList
 
GENERIC_MAPPING IopCompletionMapping
 
GENERIC_MAPPING IopFileMapping
 
POBJECT_TYPE _IoFileObjectType
 
HAL_DISPATCH _HalDispatchTable
 
LIST_ENTRY IopErrorLogListHead
 
ULONG IopNumTriageDumpDataBlocks
 
PVOID IopTriageDumpDataBlocks [64]
 
PIO_BUS_TYPE_GUID_LIST PnpBusTypeGuidList
 
PDRIVER_OBJECT IopRootDriverObject
 
KSPIN_LOCK IopDeviceRelationsSpinLock
 
LIST_ENTRY IopDeviceRelationsRequestList
 

Macro Definition Documentation

#define _IO_DEBUG_   0x00

Definition at line 14 of file io.h.

#define ENUM_ROOT   L"\\Registry\\Machine\\System\\CurrentControlSet\\Enum"
#define IO_CTL_DEBUG   0x08

Definition at line 22 of file io.h.

Referenced by IopDeviceFsIoControl().

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

Definition at line 58 of file io.h.

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

Definition at line 131 of file io.h.

Referenced by IoAllocateDriverObjectExtension(), IoGetDriverObjectExtension(), and IopDeleteDriver().

#define IOP_CREATE_FILE_OBJECT_EXTENSION   0x02

Definition at line 93 of file io.h.

Referenced by IoCreateFileSpecifyDeviceObjectHint(), and IopParseDevice().

#define IOP_MAX_REPARSE_TRAVERSAL   0x20

Definition at line 87 of file io.h.

Referenced by IopParseDevice().

#define IOP_USE_TOP_LEVEL_DEVICE_HINT   0x01

Definition at line 92 of file io.h.

Referenced by IoCreateFileSpecifyDeviceObjectHint(), and IopParseDevice().

#define IopAllocateMdlFromLookaside   ObpAllocateObjectCreateInfoBuffer

Definition at line 107 of file io.h.

Referenced by IoAllocateMdl().

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

Definition at line 150 of file io.h.

Referenced by IopAssignDeviceResources().

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

Definition at line 204 of file io.h.

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

Definition at line 177 of file io.h.

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

Definition at line 159 of file io.h.

Referenced by IopActionInitChildServices(), and IopActionInterrogateDeviceStack().

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

Definition at line 213 of file io.h.

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

Definition at line 186 of file io.h.

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

Definition at line 195 of file io.h.

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

Definition at line 168 of file io.h.

#define IopFreeMdlFromLookaside   ObpFreeCapturedAttributes

Definition at line 109 of file io.h.

Referenced by IoFreeMdl().

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

Definition at line 224 of file io.h.

Referenced by IopEnumerateDevice(), IopInitializePnpServices(), and PopSetSystemPowerState().

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

Definition at line 237 of file io.h.

Referenced by IoOpenDeviceRegistryKey(), IoReportTargetDeviceChange(), and IoReportTargetDeviceChangeAsynchronous().

#define IsIrpSynchronous (   Irp,
  FileObject 
)
Value:
((Irp->Flags & IRP_SYNCHRONOUS_API) || \
(!(FileObject) ? \
_In_ PIRP Irp
Definition: csq.h:116
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1727
#define FALSE
Definition: types.h:117
_In_ PFILE_OBJECT FileObject
Definition: classpnp.h:1229
#define IRP_SYNCHRONOUS_API

Definition at line 115 of file io.h.

Referenced by IopCompleteRequest().

#define RD_FSCTL_FAILED   3

Definition at line 74 of file io.h.

Referenced by IopStartRamdisk().

#define RD_GUID_CONVERT_FAILED   4

Definition at line 78 of file io.h.

Referenced by IopStartRamdisk().

#define RD_NO_RAMDISK_DRIVER   2

Definition at line 70 of file io.h.

Referenced by IopStartRamdisk().

#define RD_NO_XIPROM_DESCRIPTOR   1

Definition at line 66 of file io.h.

Referenced by IopStartRamdisk().

#define RD_SYMLINK_CREATE_FAILED   5

Definition at line 82 of file io.h.

Referenced by IopStartRamdisk().

Typedef Documentation

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

Definition at line 485 of file io.h.

Enumeration Type Documentation

Enumerator
IopCompletionPacketIrp 
IopCompletionPacketMini 
IopCompletionPacketQuota 

Definition at line 264 of file io.h.

265  {
enum _COMPLETION_PACKET_TYPE * PCOMPLETION_PACKET_TYPE
enum _COMPLETION_PACKET_TYPE COMPLETION_PACKET_TYPE
Enumerator
IopRemove 
IopAdd 

Definition at line 245 of file io.h.

246 {
247  IopRemove,
248  IopAdd
Definition: io.h:247
enum _IOP_DEVICE_LIST_OPERATION * PIOP_DEVICE_LIST_OPERATION
enum _IOP_DEVICE_LIST_OPERATION IOP_DEVICE_LIST_OPERATION
Definition: io.h:248
Enumerator
IopReadTransfer 
IopWriteTransfer 
IopOtherTransfer 

Definition at line 254 of file io.h.

255 {
enum _IOP_TRANSFER_TYPE IOP_TRANSFER_TYPE
enum _IOP_TRANSFER_TYPE * PIOP_TRANSFER_TYPE

Function Documentation

VOID NTAPI IoCancelThreadIo ( IN PETHREAD  Thread)

Definition at line 1083 of file irp.c.

Referenced by PspExitThread().

1084 {
1085  KIRQL OldIrql;
1086  ULONG Retries = 3000;
1088  PLIST_ENTRY ListHead, NextEntry;
1089  PIRP Irp;
1090  PAGED_CODE();
1091 
1092  /* Windows isn't using given thread, but using current. */
1094 
1096  "%s - Canceling IRPs for Thread %p\n",
1097  __FUNCTION__,
1098  Thread);
1099 
1100  /* Raise to APC to protect the IrpList */
1101  KeRaiseIrql(APC_LEVEL, &OldIrql);
1102 
1103  /* Start by cancelling all the IRPs in the current thread queue. */
1104  ListHead = &Thread->IrpList;
1105  NextEntry = ListHead->Flink;
1106  while (ListHead != NextEntry)
1107  {
1108  /* Get the IRP */
1109  Irp = CONTAINING_RECORD(NextEntry, IRP, ThreadListEntry);
1110 
1111  /* Cancel it */
1112  IoCancelIrp(Irp);
1113 
1114  /* Move to the next entry */
1115  NextEntry = NextEntry->Flink;
1116  }
1117 
1118  /* Wait 100 milliseconds */
1119  Interval.QuadPart = -1000000;
1120 
1121  /* Wait till all the IRPs are completed or cancelled. */
1122  while (!IsListEmpty(&Thread->IrpList))
1123  {
1124  /* Now we can lower */
1125  KeLowerIrql(OldIrql);
1126 
1127  /* Wait a short while and then look if all our IRPs were completed. */
1129 
1130  /*
1131  * Don't stay here forever if some broken driver doesn't complete
1132  * the IRP.
1133  */
1134  if (!(Retries--))
1135  {
1136  /* Print out a message and remove the IRP */
1137  DPRINT1("Broken driver did not complete!\n");
1139  }
1140 
1141  /* Raise the IRQL Again */
1142  KeRaiseIrql(APC_LEVEL, &OldIrql);
1143  }
1144 
1145  /* We're done, lower the IRQL */
1146  KeLowerIrql(OldIrql);
1147 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
_In_ PIRP Irp
Definition: csq.h:116
IRP
Definition: iotypes.h:2457
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI KeDelayExecutionThread(IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Interval OPTIONAL)
Definition: wait.c:283
DWORD Interval
Definition: netstat.c:30
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define IO_IRP_DEBUG
Definition: io.h:19
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define PAGED_CODE()
Definition: video.h:57
#define IOTRACE(x, fmt,...)
Definition: io.h:47
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Definition: typedefs.h:117
#define DPRINT1
Definition: precomp.h:8
BOOLEAN NTAPI IoCancelIrp(IN PIRP Irp)
Definition: irp.c:1038
PVOID PIRP
Definition: usb.h:38
unsigned int ULONG
Definition: retypes.h:1
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:259
#define __FUNCTION__
Definition: compiler.h:205
VOID NTAPI IopDisassociateThreadIrp(VOID)
Definition: irp.c:113
LIST_ENTRY IrpList
Definition: pstypes.h:1076
#define APC_LEVEL
Definition: env_spec_w32.h:695
LONGLONG QuadPart
Definition: typedefs.h:112
NTSTATUS NTAPI IoChangeFileObjectFilterContext ( IN PFILE_OBJECT  FileObject,
IN PVOID  FilterContext,
IN BOOLEAN  Define 
)

Definition at line 2142 of file file.c.

Referenced by FsRtlInsertPerFileObjectContext(), and FsRtlPTeardownPerFileObjectContexts().

2145 {
2146  if (!(FileObject->Flags & FO_FILE_OBJECT_HAS_EXTENSION))
2147  {
2148  return STATUS_INVALID_PARAMETER;
2149  }
2150 
2151  UNIMPLEMENTED;
2152 
2153  return STATUS_NOT_IMPLEMENTED;
2154 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ PFILE_OBJECT FileObject
Definition: classpnp.h:1229
#define FO_FILE_OBJECT_HAS_EXTENSION
Definition: iotypes.h:144
#define UNIMPLEMENTED
Definition: debug.h:114
NTSTATUS IoCreateDriverList ( VOID  )
NTSTATUS IoDestroyDriverList ( VOID  )
PVOID NTAPI IoGetFileObjectFilterContext ( IN PFILE_OBJECT  FileObject)

Definition at line 2128 of file file.c.

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

2129 {
2131  {
2132  UNIMPLEMENTED;
2133  /* FIXME: return NULL for the moment ~ */
2134  return NULL;
2135  }
2136 
2137  return NULL;
2138 }
smooth NULL
Definition: ftsmooth.c:557
_In_ PFILE_OBJECT FileObject
Definition: classpnp.h:1229
#define FO_FILE_OBJECT_HAS_EXTENSION
Definition: iotypes.h:144
#define UNIMPLEMENTED
Definition: debug.h:114
NTSTATUS NTAPI IoGetRelatedTargetDevice ( IN PFILE_OBJECT  FileObject,
OUT PDEVICE_OBJECT DeviceObject 
)

Definition at line 1380 of file device.c.

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

1382 {
1383  NTSTATUS Status;
1385 
1386  /* Call the internal helper function */
1387  Status = IopGetRelatedTargetDevice(FileObject, &DeviceNode);
1388  if (NT_SUCCESS(Status) && DeviceNode)
1389  {
1390  *DeviceObject = DeviceNode->PhysicalDeviceObject;
1391  }
1392  return Status;
1393 }
PDEVICE_OBJECT PhysicalDeviceObject
Definition: iotypes.h:839
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
Definition: npfs.h:636
smooth NULL
Definition: ftsmooth.c:557
_In_ PFILE_OBJECT FileObject
Definition: classpnp.h:1229
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
Definition: Node.h:9
NTSTATUS NTAPI IopGetRelatedTargetDevice(IN PFILE_OBJECT FileObject, OUT PDEVICE_NODE *DeviceNode)
Definition: device.c:651
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
VOID IoInitCancelHandling ( VOID  )
VOID NTAPI IoInitFileSystemImplementation ( VOID  )
VOID IoInitShutdownNotification ( VOID  )
BOOLEAN NTAPI IoInitSystem ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 470 of file iomgr.c.

Referenced by Phase1InitializationDiscard().

471 {
472  LARGE_INTEGER ExpireTime;
474  CHAR Buffer[256];
475  ANSI_STRING NtBootPath, RootString;
476 
477  /* Initialize empty NT Boot Path */
478  RtlInitEmptyAnsiString(&NtBootPath, Buffer, sizeof(Buffer));
479 
480  /* Initialize the lookaside lists */
482 
483  /* Initialize all locks and lists */
504 
505  /* Initialize Timer List Lock */
507 
508  /* Initialize Timer List */
510 
511  /* Initialize the DPC/Timer which will call the other Timer Routines */
512  ExpireTime.QuadPart = -10000000;
515  KeSetTimerEx(&IopTimer, ExpireTime, 1000, &IopTimerDpc);
516 
517  /* Create Object Types */
518  if (!IopCreateObjectTypes())
519  {
520  DPRINT1("IopCreateObjectTypes failed!\n");
521  return FALSE;
522  }
523 
524  /* Create Object Directories */
526  {
527  DPRINT1("IopCreateRootDirectories failed!\n");
528  return FALSE;
529  }
530 
531  /* Initialize PnP manager */
533 
534  /* Initialize SHIM engine */
536 
537  /* Initialize WMI */
538  WmiInitialize();
539 
540  /* Initialize HAL Root Bus Driver */
542 
543  /* Make loader block available for the whole kernel */
544  IopLoaderBlock = LoaderBlock;
545 
546  /* Load boot start drivers */
548 
549  /* Call back drivers that asked for */
551 
552  /* Check if this was a ramdisk boot */
553  if (!_strnicmp(LoaderBlock->ArcBootDeviceName, "ramdisk(0)", 10))
554  {
555  /* Initialize the ramdisk driver */
556  IopStartRamdisk(LoaderBlock);
557  }
558 
559  /* No one should need loader block any longer */
561 
562  /* Create ARC names for boot devices */
563  Status = IopCreateArcNames(LoaderBlock);
564  if (!NT_SUCCESS(Status))
565  {
566  DPRINT1("IopCreateArcNames failed: %lx\n", Status);
567  return FALSE;
568  }
569 
570  /* Mark the system boot partition */
571  if (!IopMarkBootPartition(LoaderBlock))
572  {
573  DPRINT1("IopMarkBootPartition failed!\n");
574  return FALSE;
575  }
576 
577  /* Initialize PnP root relations */
579 
580 #ifndef _WINKD_
581  /* Read KDB Data */
582  KdbInit();
583 
584  /* I/O is now setup for disk access, so phase 3 */
585  KdInitSystem(3, LoaderBlock);
586 #endif
587 
588  /* Load services for devices found by PnP manager */
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 */
614  Status = RtlUnicodeStringToAnsiString(&RootString, &NtSystemRoot, FALSE);
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 */
628  Status = RtlAnsiStringToUnicodeString(&NtSystemRoot, &RootString, FALSE);
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 */
636  Status = PsLocateSystemDll();
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 }
ERESOURCE IopDatabaseResource
Definition: volume.c:25
NTSTATUS NTAPI IopReassignSystemRoot(IN PLOADER_PARAMETER_BLOCK LoaderBlock, OUT PANSI_STRING NtBootPath)
Definition: arcname.c:837
ERESOURCE IopSecurityResource
Definition: iomgr.c:60
LIST_ENTRY DriverBootReinitListHead
Definition: driver.c:26
#define TRUE
Definition: types.h:120
KSPIN_LOCK DriverBootReinitListLock
Definition: driver.c:27
PDEVICE_OBJECT PhysicalDeviceObject
Definition: iotypes.h:839
PDEVICE_NODE IopRootDeviceNode
Definition: pnpmgr.c:18
NTSTATUS IopInitializePnpServices(IN PDEVICE_NODE DeviceNode)
Definition: pnpmgr.c:2782
#define TAG_IO
Definition: tag.h:69
UNICODE_STRING NtSystemRoot
Definition: init.c:72
LIST_ENTRY IopCdRomFileSystemQueueHead
Definition: volume.c:27
KTIMER IopTimer
Definition: iotimer.c:23
VOID NTAPI IopReinitializeDrivers(VOID)
Definition: driver.c:1348
VOID FASTCALL IoAssignDriveLetters(IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, IN PSTRING NtDeviceName, OUT PUCHAR NtSystemPath, OUT PSTRING NtSystemPathString)
Definition: ntoskrnl.c:54
USHORT MaximumLength
Definition: env_spec_w32.h:370
unsigned char * PUCHAR
Definition: retypes.h:3
char CHAR
Definition: xmlstorage.h:175
LIST_ENTRY IopTimerQueueHead
Definition: iotimer.c:19
VOID NTAPI IopReinitializeBootDrivers(VOID)
Definition: driver.c:1384
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
BOOLEAN NTAPI KeSetTimerEx(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN LONG Period, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:294
#define WCHAR
Definition: msvc.h:43
BOOLEAN PnpSystemInit
Definition: iomgr.c:17
VOID FASTCALL IopInitializeSystemDrivers(VOID)
Definition: driver.c:1120
NTSTATUS NTAPI ApphelpCacheInitialize(VOID)
Definition: apphelp.c:440
ERESOURCE IopDriverLoadResource
Definition: driver.c:19
#define FALSE
Definition: types.h:117
_Check_return_ _CRTIMP int __cdecl _strnicmp(_In_reads_or_z_(_MaxCount) const char *_Str1, _In_reads_or_z_(_MaxCount) const char *_Str2, _In_ size_t _MaxCount)
LIST_ENTRY IopTapeFileSystemQueueHead
Definition: volume.c:27
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
LIST_ENTRY IopNetworkFileSystemQueueHead
Definition: volume.c:26
BOOLEAN NTAPI WmiInitialize(VOID)
Definition: wmi.c:38
LIST_ENTRY DriverReinitListHead
Definition: driver.c:21
KGUARDED_MUTEX PnpNotifyListLock
Definition: pnpnotify.c:30
smooth NULL
Definition: ftsmooth.c:557
VOID INIT_FUNCTION NTAPI IopInitLookasideLists(VOID)
Definition: iomgr.c:99
Definition: bufpool.h:45
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
VOID FASTCALL IopInitializeBootDrivers(VOID)
Definition: driver.c:929
KDPC IopTimerDpc
Definition: iotimer.c:22
NTSTATUS IopEnumerateDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: pnpmgr.c:2348
LIST_ENTRY IopDiskFileSystemQueueHead
Definition: volume.c:26
BOOLEAN INIT_FUNCTION NTAPI IopMarkBootPartition(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: iomgr.c:400
USHORT MaximumLength
Definition: env_spec_w32.h:377
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
LIST_ENTRY PnpNotifyListHead
Definition: pnpnotify.c:31
NTSTATUS NTAPI IopInitializePlugPlayServices(VOID)
Definition: pnpinit.c:391
NTSTATUS NTAPI IopCreateArcNames(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: arcname.c:42
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
KSPIN_LOCK DriverReinitListLock
Definition: driver.c:22
NTSTATUS NTAPI PsLocateSystemDll(VOID)
Definition: psmgr.c:279
PLOADER_PARAMETER_BLOCK IopLoaderBlock
Definition: iomgr.c:88
Status
Definition: gdiplustypes.h:24
KSPIN_LOCK IopLogListLock
Definition: error.c:31
KSPIN_LOCK IopTimerLock
Definition: iotimer.c:18
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:31
LONG NTSTATUS
Definition: DriverTester.h:11
BOOLEAN NTAPI KdInitSystem(ULONG Reserved, PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: kdinit.c:174
BOOLEAN INIT_FUNCTION NTAPI IopCreateObjectTypes(VOID)
Definition: iomgr.c:246
VOID NTAPI IopTimerDispatch(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: iotimer.c:32
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
KSPIN_LOCK IoStatisticsLock
Definition: iomgr.c:45
#define DPRINT1
Definition: precomp.h:8
KSPIN_LOCK ShutdownListLock
Definition: device.c:21
BOOLEAN INIT_FUNCTION NTAPI IopCreateRootDirectories(VOID)
Definition: iomgr.c:335
LIST_ENTRY IopFsNotifyChangeQueueHead
Definition: volume.c:28
NTSTATUS NTAPI IopStartRamdisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: ramdisk.c:28
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711
LIST_ENTRY IopErrorLogListHead
Definition: error.c:30
LIST_ENTRY ShutdownListHead
Definition: device.c:20
#define HalInitPnpDriver
Definition: haltypes.h:289
LIST_ENTRY LastChanceShutdownListHead
Definition: device.c:20
VOID NTAPI KeInitializeTimerEx(OUT PKTIMER Timer, IN TIMER_TYPE Type)
Definition: timerobj.c:244
LONGLONG QuadPart
Definition: typedefs.h:112
VOID NTAPI IoInitVpbImplementation ( VOID  )
PVOID IoOpenFileOnDevice ( IN PVOID  SymbolicLink,
IN PWCHAR  Name 
)
PVOID IoOpenSymlink ( IN PVOID  SymbolicLink)
VOID NTAPI IopAbortInterruptedIrp ( IN PKEVENT  EventObject,
IN PIRP  Irp 
)

Definition at line 65 of file irp.c.

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

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

Referenced by IopResetDevice().

PIRP NTAPI IopAllocateIrpMustSucceed ( IN CCHAR  StackSize)

Definition at line 653 of file irp.c.

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

654 {
655  LONG i;
656  PIRP Irp;
658 
659  /* Try to get an IRP */
660  Irp = IoAllocateIrp(StackSize, FALSE);
661  if (Irp)
662  return Irp;
663 
664  /* If we fail, start looping till we may get one */
665  i = LONG_MAX;
666  do {
667  i--;
668 
669  /* First, sleep for 10ms */
670  Sleep.QuadPart = -10 * 1000 * 10;
672 
673  /* Then, retry allocation */
674  Irp = IoAllocateIrp(StackSize, FALSE);
675  if (Irp)
676  return Irp;
677  } while (i > 0);
678 
679  return Irp;
680 }
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
_In_ PIRP Irp
Definition: csq.h:116
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
NTSTATUS NTAPI KeDelayExecutionThread(IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Interval OPTIONAL)
Definition: wait.c:283
#define LONG_MAX
Definition: limits.h:43
_In_ USHORT _In_ CCHAR StackSize
Definition: iofuncs.h:1056
PVOID PIRP
Definition: usb.h:38
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:552
LONGLONG QuadPart
Definition: typedefs.h:112
NTSTATUS NTAPI IopAssignDeviceResources ( IN PDEVICE_NODE  DeviceNode)

Definition at line 1060 of file pnpres.c.

Referenced by IopStartDevice(), and IoReportDetectedDevice().

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

Referenced by PipCallDriverAddDevice().

VOID IopBootLog ( IN PUNICODE_STRING  DriverName,
IN BOOLEAN  Success 
)
PVPB NTAPI IopCheckVpbMounted ( IN POPEN_PACKET  OpenPacket,
IN PDEVICE_OBJECT  DeviceObject,
IN PUNICODE_STRING  RemainingName,
OUT PNTSTATUS  Status 
)

Definition at line 81 of file volume.c.

Referenced by IopParseDevice().

85 {
87  KIRQL OldIrql;
88  PVPB Vpb = NULL;
89 
90  /* Lock the VPBs */
91  IoAcquireVpbSpinLock(&OldIrql);
92 
93  /* Set VPB mount settings */
94  Raw = !RemainingName->Length && !OpenPacket->RelatedFileObject;
95  Alertable = (OpenPacket->CreateOptions & FILE_SYNCHRONOUS_IO_ALERT) ?
96  TRUE: FALSE;
97 
98  /* Start looping until the VPB is mounted */
99  while (!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
100  {
101  /* Release the lock */
102  IoReleaseVpbSpinLock(OldIrql);
103 
104  /* Mount the volume */
106  Raw,
107  FALSE,
108  Alertable,
109  &Vpb);
110 
111  /* Check if we failed or if we were alerted */
112  if (!(NT_SUCCESS(*Status)) ||
113  (*Status == STATUS_USER_APC) ||
114  (*Status == STATUS_ALERTED))
115  {
116  /* Dereference the device, since IopParseDevice referenced it */
118 
119  /* Check if it was a total failure */
120  if (!NT_SUCCESS(*Status)) return NULL;
121 
122  /* Otherwise we were alerted */
124  return NULL;
125  }
126 
127  /* Re-acquire the lock */
128  IoAcquireVpbSpinLock(&OldIrql);
129  }
130 
131  /* Make sure the VPB isn't locked */
132  Vpb = DeviceObject->Vpb;
133  if (Vpb->Flags & VPB_LOCKED)
134  {
135  /* We're locked, so fail */
137  Vpb = NULL;
138  }
139  else
140  {
141  /* Success! Reference the VPB */
142  Vpb->ReferenceCount++;
143  }
144 
145  /* Release the lock and return the VPB */
146  IoReleaseVpbSpinLock(OldIrql);
147  return Vpb;
148 }
_In_ PVOID _In_ BOOLEAN Alertable
Definition: exfuncs.h:452
#define TRUE
Definition: types.h:120
USHORT Flags
Definition: iotypes.h:169
VOID NTAPI IopDereferenceDeviceObject(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN ForceUnload)
Definition: device.c:460
NTSTATUS NTAPI IopMountVolume(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN AllowRawMount, IN BOOLEAN DeviceIsLocked, IN BOOLEAN Alertable, OUT PVPB *Vpb)
Definition: volume.c:459
VOID NTAPI IoAcquireVpbSpinLock(OUT PKIRQL Irql)
Definition: volume.c:1201
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
Definition: npfs.h:636
#define STATUS_WRONG_VOLUME
Definition: udferr_usr.h:140
#define STATUS_ALERTED
Definition: ntstatus.h:80
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FILE_SYNCHRONOUS_IO_ALERT
Definition: from_kernel.h:30
#define FALSE
Definition: types.h:117
ULONG ReferenceCount
Definition: iotypes.h:174
#define VPB_LOCKED
Definition: iotypes.h:1759
smooth NULL
Definition: ftsmooth.c:557
unsigned char BOOLEAN
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
Status
Definition: gdiplustypes.h:24
#define STATUS_USER_APC
Definition: ntstatus.h:78
Definition: iotypes.h:166
Definition: sacdrv.h:279
_In_opt_ PVPB Vpb
Definition: iofuncs.h:1499
#define VPB_MOUNTED
Definition: iotypes.h:1758
VOID NTAPI IoReleaseVpbSpinLock(IN KIRQL Irql)
Definition: volume.c:1212
NTSTATUS NTAPI IopCleanupFailedIrp ( IN PFILE_OBJECT  FileObject,
IN PKEVENT  EventObject,
IN PVOID Buffer  OPTIONAL 
)

Definition at line 43 of file irp.c.

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

46 {
47  PAGED_CODE();
48 
49  /* Dereference the event */
50  if (EventObject) ObDereferenceObject(EventObject);
51 
52  /* Free a buffer, if any */
53  if (Buffer) ExFreePool(Buffer);
54 
55  /* If this was a file opened for synch I/O, then unlock it */
57 
58  /* Now dereference it and return */
61 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:267
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1727
_In_ PFILE_OBJECT FileObject
Definition: classpnp.h:1229
Definition: bufpool.h:45
#define PAGED_CODE()
Definition: video.h:57
static __inline VOID IopUnlockFileObject(IN PFILE_OBJECT FileObject)
Definition: io_x.h:26
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
VOID NTAPI IopCloseFile ( IN PEPROCESS Process  OPTIONAL,
IN PVOID  Object,
IN ACCESS_MASK  GrantedAccess,
IN ULONG  ProcessHandleCount,
IN ULONG  SystemHandleCount 
)

Definition at line 1928 of file file.c.

Referenced by IopCreateObjectTypes(), and IopDeleteFile().

1933 {
1934  PFILE_OBJECT FileObject = (PFILE_OBJECT)ObjectBody;
1935  KEVENT Event;
1936  PIRP Irp;
1937  PIO_STACK_LOCATION StackPtr;
1938  NTSTATUS Status;
1940  KIRQL OldIrql;
1941  IOTRACE(IO_FILE_DEBUG, "ObjectBody: %p\n", ObjectBody);
1942 
1943  /* If this isn't the last handle for the current process, quit */
1944  if (HandleCount != 1) return;
1945 
1946  /* Check if the file is locked and has more then one handle opened */
1947  if ((FileObject->LockOperation) && (SystemHandleCount != 1))
1948  {
1949  DPRINT1("We need to unlock this file!\n");
1950  ASSERT(FALSE);
1951  }
1952 
1953  /* Make sure this is the last handle */
1954  if (SystemHandleCount != 1) return;
1955 
1956  /* Check if this is a direct open or not */
1957  if (FileObject->Flags & FO_DIRECT_DEVICE_OPEN)
1958  {
1959  /* Get the attached device */
1960  DeviceObject = IoGetAttachedDevice(FileObject->DeviceObject);
1961  }
1962  else
1963  {
1964  /* Get the FO's device */
1965  DeviceObject = IoGetRelatedDeviceObject(FileObject);
1966  }
1967 
1968  /* Set the handle created flag */
1969  FileObject->Flags |= FO_HANDLE_CREATED;
1970 
1971  /* Check if this is a sync FO and lock it */
1972  if (FileObject->Flags & FO_SYNCHRONOUS_IO) IopLockFileObject(FileObject);
1973 
1974  /* Clear and set up Events */
1975  KeClearEvent(&FileObject->Event);
1977 
1978  /* Allocate an IRP */
1979  Irp = IopAllocateIrpMustSucceed(DeviceObject->StackSize);
1980 
1981  /* Set it up */
1982  Irp->UserEvent = &Event;
1983  Irp->UserIosb = &Irp->IoStatus;
1984  Irp->Tail.Overlay.Thread = PsGetCurrentThread();
1985  Irp->Tail.Overlay.OriginalFileObject = FileObject;
1986  Irp->Overlay.AsynchronousParameters.UserApcRoutine = NULL;
1988 
1989  /* Set up Stack Pointer Data */
1990  StackPtr = IoGetNextIrpStackLocation(Irp);
1991  StackPtr->MajorFunction = IRP_MJ_CLEANUP;
1992  StackPtr->FileObject = FileObject;
1993 
1994  /* Queue the IRP */
1995  IopQueueIrpToThread(Irp);
1996 
1997  /* Update operation counts */
1999 
2000  /* Call the FS Driver */
2001  Status = IoCallDriver(DeviceObject, Irp);
2002  if (Status == STATUS_PENDING)
2003  {
2004  /* Wait for completion */
2006  }
2007 
2008  /* Unqueue the IRP */
2009  KeRaiseIrql(APC_LEVEL, &OldIrql);
2011  KeLowerIrql(OldIrql);
2012 
2013  /* Free the IRP */
2014  IoFreeIrp(Irp);
2015 
2016  /* Release the lock if we were holding it */
2017  if (FileObject->Flags & FO_SYNCHRONOUS_IO) IopUnlockFileObject(FileObject);
2018 }
#define FO_HANDLE_CREATED
Definition: iotypes.h:1745
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define IRP_CLOSE_OPERATION
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
#define FO_DIRECT_DEVICE_OPEN
Definition: iotypes.h:1738
_In_ PIRP Irp
Definition: csq.h:116
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
Definition: npfs.h:636
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1313
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1727
ACPI_EFI_EVENT Event
Definition: acefiex.h:633
#define IO_FILE_DEBUG
Definition: io.h:20
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:557
_In_ PFILE_OBJECT FileObject
Definition: classpnp.h:1229
FORCEINLINE VOID IopQueueIrpToThread(IN PIRP Irp)
Definition: io_x.h:35
PIRP NTAPI IopAllocateIrpMustSucceed(IN CCHAR StackSize)
Definition: irp.c:653
#define STATUS_PENDING
Definition: ntstatus.h:82
* PFILE_OBJECT
Definition: iotypes.h:1949
#define IOTRACE(x, fmt,...)
Definition: io.h:47
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
FORCEINLINE VOID IopUnQueueIrpFromThread(IN PIRP Irp)
Definition: io_x.h:51
PFILE_OBJECT FileObject
Definition: iotypes.h:2787
LONG NTSTATUS
Definition: DriverTester.h:11
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
PDEVICE_OBJECT NTAPI IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1159
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1155
static __inline VOID IopUnlockFileObject(IN PFILE_OBJECT FileObject)
Definition: io_x.h:26
#define DPRINT1
Definition: precomp.h:8
#define IRP_MJ_CLEANUP
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1589
static __inline VOID IopUpdateOperationCount(IN IOP_TRANSFER_TYPE Type)
Definition: io_x.h:63
PVOID PIRP
Definition: usb.h:38
#define IRP_SYNCHRONOUS_API
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
static __inline VOID IopLockFileObject(IN PFILE_OBJECT FileObject)
Definition: io_x.h:12
#define APC_LEVEL
Definition: env_spec_w32.h:695
VOID NTAPI IopCompleteRequest ( IN PKAPC  Apc,
IN PKNORMAL_ROUTINE NormalRoutine,
IN PVOID NormalContext,
IN PVOID SystemArgument1,
IN PVOID SystemArgument2 
)

Definition at line 236 of file irp.c.

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

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

Definition at line 42 of file arcname.c.

Referenced by IoInitSystem().

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

Definition at line 1420 of file driver.c.

Referenced by IoCreateDriver(), and IopInitializeDriverModule().

1426 {
1427  WCHAR NameBuffer[100];
1428  USHORT NameLength;
1429  UNICODE_STRING LocalDriverName;
1430  NTSTATUS Status;
1432  ULONG ObjectSize;
1434  UNICODE_STRING ServiceKeyName;
1435  HANDLE hDriver;
1436  ULONG i, RetryCount = 0;
1437 
1438 try_again:
1439  /* First, create a unique name for the driver if we don't have one */
1440  if (!DriverName)
1441  {
1442  /* Create a random name and set up the string */
1443  NameLength = (USHORT)swprintf(NameBuffer,
1444  DRIVER_ROOT_NAME L"%08u",
1446  LocalDriverName.Length = NameLength * sizeof(WCHAR);
1447  LocalDriverName.MaximumLength = LocalDriverName.Length + sizeof(UNICODE_NULL);
1448  LocalDriverName.Buffer = NameBuffer;
1449  }
1450  else
1451  {
1452  /* So we can avoid another code path, use a local var */
1453  LocalDriverName = *DriverName;
1454  }
1455 
1456  /* Initialize the Attributes */
1457  ObjectSize = sizeof(DRIVER_OBJECT) + sizeof(EXTENDED_DRIVER_EXTENSION);
1458  InitializeObjectAttributes(&ObjectAttributes,
1459  &LocalDriverName,
1461  NULL,
1462  NULL);
1463 
1464  /* Create the Object */
1465  Status = ObCreateObject(KernelMode,
1467  &ObjectAttributes,
1468  KernelMode,
1469  NULL,
1470  ObjectSize,
1471  0,
1472  0,
1473  (PVOID*)&DriverObject);
1474  if (!NT_SUCCESS(Status)) return Status;
1475 
1476  DPRINT("IopCreateDriver(): created DO %p\n", DriverObject);
1477 
1478  /* Set up the Object */
1479  RtlZeroMemory(DriverObject, ObjectSize);
1480  DriverObject->Type = IO_TYPE_DRIVER;
1481  DriverObject->Size = sizeof(DRIVER_OBJECT);
1482  DriverObject->Flags = DRVO_LEGACY_DRIVER;
1483  DriverObject->DriverExtension = (PDRIVER_EXTENSION)(DriverObject + 1);
1484  DriverObject->DriverExtension->DriverObject = DriverObject;
1485  DriverObject->DriverInit = InitializationFunction;
1486  DriverObject->DriverSection = ModuleObject;
1487  /* Loop all Major Functions */
1488  for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
1489  {
1490  /* Invalidate each function */
1491  DriverObject->MajorFunction[i] = IopInvalidDeviceRequest;
1492  }
1493 
1494  /* Set up the service key name buffer */
1495  ServiceKeyName.MaximumLength = ServiceName->Length + sizeof(UNICODE_NULL);
1496  ServiceKeyName.Buffer = ExAllocatePoolWithTag(NonPagedPool,
1497  ServiceKeyName.MaximumLength,
1498  TAG_IO);
1499  if (!ServiceKeyName.Buffer)
1500  {
1501  /* Fail */
1502  ObMakeTemporaryObject(DriverObject);
1503  ObDereferenceObject(DriverObject);
1505  }
1506 
1507  /* Copy the name and set it in the driver extension */
1508  RtlCopyUnicodeString(&ServiceKeyName,
1509  ServiceName);
1510  DriverObject->DriverExtension->ServiceKeyName = ServiceKeyName;
1511 
1512  /* Make a copy of the driver name to store in the driver object */
1513  DriverObject->DriverName.MaximumLength = LocalDriverName.Length;
1515  DriverObject->DriverName.MaximumLength,
1516  TAG_IO);
1517  if (!DriverObject->DriverName.Buffer)
1518  {
1519  /* Fail */
1520  ObMakeTemporaryObject(DriverObject);
1521  ObDereferenceObject(DriverObject);
1523  }
1524 
1525  RtlCopyUnicodeString(&DriverObject->DriverName,
1526  &LocalDriverName);
1527 
1528  /* Add the Object and get its handle */
1529  Status = ObInsertObject(DriverObject,
1530  NULL,
1532  0,
1533  NULL,
1534  &hDriver);
1535 
1536  /* Eliminate small possibility when this function is called more than
1537  once in a row, and KeTickCount doesn't get enough time to change */
1538  if (!DriverName && (Status == STATUS_OBJECT_NAME_COLLISION) && (RetryCount < 100))
1539  {
1540  RetryCount++;
1541  goto try_again;
1542  }
1543 
1544  if (!NT_SUCCESS(Status)) return Status;
1545 
1546  /* Now reference it */
1547  Status = ObReferenceObjectByHandle(hDriver,
1548  0,
1550  KernelMode,
1551  (PVOID*)&DriverObject,
1552  NULL);
1553 
1554  /* Close the extra handle */
1555  ZwClose(hDriver);
1556 
1557  if (!NT_SUCCESS(Status))
1558  {
1559  /* Fail */
1560  ObMakeTemporaryObject(DriverObject);
1561  ObDereferenceObject(DriverObject);
1562  return Status;
1563  }
1564 
1565  DriverObject->HardwareDatabase = &IopHardwareDatabaseKey;
1566  DriverObject->DriverStart = ModuleObject ? ModuleObject->DllBase : 0;
1567  DriverObject->DriverSize = ModuleObject ? ModuleObject->SizeOfImage : 0;
1568 
1569  /* Finally, call its init function */
1570  DPRINT("RegistryKey: %wZ\n", RegistryPath);
1571  DPRINT("Calling driver entrypoint at %p\n", InitializationFunction);
1572  Status = (*InitializationFunction)(DriverObject, RegistryPath);
1573  if (!NT_SUCCESS(Status))
1574  {
1575  /* If it didn't work, then kill the object */
1576  DPRINT1("'%wZ' initialization failed, status (0x%08lx)\n", DriverName, Status);
1577  DriverObject->DriverSection = NULL;
1578  ObMakeTemporaryObject(DriverObject);
1579  ObDereferenceObject(DriverObject);
1580  return Status;
1581  }
1582  else
1583  {
1584  /* Returns to caller the object */
1585  *pDriverObject = DriverObject;
1586  }
1587 
1588  /* We're going to say if we don't have any DOs from DriverEntry, then we're not legacy.
1589  * Other parts of the I/O manager depend on this behavior */
1590  if (!DriverObject->DeviceObject) DriverObject->Flags &= ~DRVO_LEGACY_DRIVER;
1591 
1592  /* Loop all Major Functions */
1593  for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
1594  {
1595  /*
1596  * Make sure the driver didn't set any dispatch entry point to NULL!
1597  * Doing so is illegal; drivers shouldn't touch entry points they
1598  * do not implement.
1599  */
1600 
1601  /* Check if it did so anyway */
1602  if (!DriverObject->MajorFunction[i])
1603  {
1604  /* Print a warning in the debug log */
1605  DPRINT1("Driver <%wZ> set DriverObject->MajorFunction[%lu] to NULL!\n",
1606  &DriverObject->DriverName, i);
1607 
1608  /* Fix it up */
1609  DriverObject->MajorFunction[i] = IopInvalidDeviceRequest;
1610  }
1611  }
1612 
1613  /* Return the Status */
1614  return Status;
1615 }
DWORD *typedef PVOID
Definition: winlogon.h:52
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
ULONG LowPart
Definition: ketypes.h:895
#define DRVO_LEGACY_DRIVER
Definition: iotypes.h:2112
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TAG_IO
Definition: tag.h:69
USHORT MaximumLength
Definition: env_spec_w32.h:370
Definition: bidi.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define IRP_MJ_MAXIMUM_FUNCTION
PVOID DriverStart
Definition: iotypes.h:2165
ULONG SizeOfImage
Definition: ldrtypes.h:141
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR _In_ HANDLE hDriver
Definition: winddi.h:3553
#define OBJ_PERMANENT
Definition: winternl.h:226
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:267
POBJECT_TYPE IoDriverObjectType
Definition: driver.c:32
#define WCHAR
Definition: msvc.h:43
NTSTATUS NTAPI IopInvalidDeviceRequest(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: driver.c:46
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
PVOID DllBase
Definition: btrfs_drv.h:1714
GLenum GLclampf GLint i
Definition: glfuncs.h:14
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:388
#define UNICODE_NULL
struct _DRIVER_OBJECT * DriverObject
Definition: iotypes.h:2105
#define FILE_READ_DATA
Definition: nt_native.h:628
PDRIVER_EXTENSION DriverExtension
Definition: iotypes.h:2168
smooth NULL
Definition: ftsmooth.c:557
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
PUNICODE_STRING HardwareDatabase
Definition: iotypes.h:2170
void DPRINT(...)
Definition: polytest.cpp:61
CSHORT Size
Definition: iotypes.h:2162
NTSTATUS NTAPI ObCreateObject(IN KPROCESSOR_MODE ProbeMode OPTIONAL, IN POBJECT_TYPE Type, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN KPROCESSOR_MODE AccessMode, IN OUT PVOID ParseContext OPTIONAL, IN ULONG ObjectSize, IN ULONG PagedPoolCharge OPTIONAL, IN ULONG NonPagedPoolCharge OPTIONAL, OUT PVOID *Object)
Definition: oblife.c:938
LPTSTR ServiceName
Definition: ServiceMain.c:15
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTKERNELAPI volatile KSYSTEM_TIME KeTickCount
Definition: clock.c:19
struct _DRIVER_OBJECT DRIVER_OBJECT
Status
Definition: gdiplustypes.h:24
UNICODE_STRING ServiceKeyName
Definition: iotypes.h:2108
DWORD *typedef HANDLE
Definition: winlogon.h:52
NTSTATUS NTAPI ObInsertObject(IN PVOID Object, IN PACCESS_STATE AccessState OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG ObjectPointerBias, OUT PVOID *NewObject OPTIONAL, OUT PHANDLE Handle)
Definition: obhandle.c:2925
LONG NTSTATUS
Definition: DriverTester.h:11
unsigned short USHORT
Definition: pedump.c:61
struct _DRIVER_EXTENSION * PDRIVER_EXTENSION
UNICODE_STRING IopHardwareDatabaseKey
Definition: driver.c:29
#define IO_TYPE_DRIVER
#define DPRINT1
Definition: precomp.h:8
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: iotypes.h:2175
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
ULONG DriverSize
Definition: iotypes.h:2166
CSHORT Type
Definition: iotypes.h:2161
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
PVOID DriverSection
Definition: iotypes.h:2167
PDRIVER_INITIALIZE DriverInit
Definition: iotypes.h:2172
UNICODE_STRING DriverName
Definition: iotypes.h:2169
#define DRIVER_ROOT_NAME
Definition: ldr.h:5
VOID NTAPI ObMakeTemporaryObject(IN PVOID ObjectBody)
Definition: oblife.c:1347
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 NTAPI IopCreateVpb ( IN PDEVICE_OBJECT  DeviceObject)

Definition at line 155 of file volume.c.

Referenced by IoCreateDevice(), and IoVerifyVolume().

156 {
157  PVPB Vpb;
158 
159  /* Allocate the Vpb */
161  sizeof(VPB),
162  TAG_VPB);
163  if (!Vpb) return STATUS_INSUFFICIENT_RESOURCES;
164 
165  /* Clear it so we don't waste time manually */
166  RtlZeroMemory(Vpb, sizeof(VPB));
167 
168  /* Set the Header and Device Field */
169  Vpb->Type = IO_TYPE_VPB;
170  Vpb->Size = sizeof(VPB);
171  Vpb->RealDevice = DeviceObject;
172 
173  /* Link it to the Device Object */
174  DeviceObject->Vpb = Vpb;
175  return STATUS_SUCCESS;
176 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
return STATUS_SUCCESS
Definition: btrfs.c:2664
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
Definition: npfs.h:636
#define TAG_VPB
Definition: cdprocs.h:70
struct _DEVICE_OBJECT * RealDevice
Definition: iotypes.h:172
CSHORT Size
Definition: iotypes.h:168
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define IO_TYPE_VPB
struct _VPB VPB
CSHORT Type
Definition: iotypes.h:167
Definition: iotypes.h:166
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_In_opt_ PVPB Vpb
Definition: iofuncs.h:1499
VOID NTAPI IopDeleteDevice ( IN PVOID  ObjectBody)

Definition at line 49 of file device.c.

Referenced by IopCreateObjectTypes().

50 {
51  PDEVICE_OBJECT DeviceObject = ObjectBody;
53  PAGED_CODE();
54 
55  /* Cleanup and free the device node */
56  if (DeviceNode)
57  IopFreeDeviceNode(DeviceNode);
58 
59  /* Dereference the driver object, referenced in IoCreateDevice */
60  if (DeviceObject->DriverObject)
61  ObDereferenceObject(DeviceObject->DriverObject);
62 }
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:267
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
Definition: npfs.h:636
#define PAGED_CODE()
Definition: video.h:57
Definition: Node.h:9
NTSTATUS IopFreeDeviceNode(IN PDEVICE_NODE DeviceNode)
PDEVICE_NODE FASTCALL IopGetDeviceNode(IN PDEVICE_OBJECT DeviceObject)
VOID NTAPI IopDeleteDriver ( IN PVOID  ObjectBody)

Definition at line 58 of file driver.c.

Referenced by IopCreateObjectTypes().

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

Definition at line 1242 of file file.c.

Referenced by IopCreateObjectTypes(), and IopParseDevice().

1243 {
1244  PFILE_OBJECT FileObject = (PFILE_OBJECT)ObjectBody;
1245  PIRP Irp;
1246  PIO_STACK_LOCATION StackPtr;
1247  NTSTATUS Status;
1248  KEVENT Event;
1250  BOOLEAN DereferenceDone = FALSE;
1251  PVPB Vpb;
1252  KIRQL OldIrql;
1253  IOTRACE(IO_FILE_DEBUG, "ObjectBody: %p\n", ObjectBody);
1254 
1255  /* Check if the file has a device object */
1256  if (FileObject->DeviceObject)
1257  {
1258  /* Check if this is a direct open or not */
1259  if (FileObject->Flags & FO_DIRECT_DEVICE_OPEN)
1260  {
1261  /* Get the attached device */
1262  DeviceObject = IoGetAttachedDevice(FileObject->DeviceObject);
1263  }
1264  else
1265  {
1266  /* Use the file object's device object */
1267  DeviceObject = IoGetRelatedDeviceObject(FileObject);
1268  }
1269 
1270  /* Sanity check */
1271  ASSERT(!(FileObject->Flags & FO_SYNCHRONOUS_IO) ||
1272  (InterlockedExchange((PLONG)&FileObject->Busy, TRUE) == FALSE));
1273 
1274  /* Check if the handle wasn't created yet */
1275  if (!(FileObject->Flags & FO_HANDLE_CREATED))
1276  {
1277  /* Send the cleanup IRP */
1278  IopCloseFile(NULL, ObjectBody, 0, 1, 1);
1279  }
1280 
1281  /* Clear and set up Events */
1282  KeClearEvent(&FileObject->Event);
1284 
1285  /* Allocate an IRP */
1286  Irp = IopAllocateIrpMustSucceed(DeviceObject->StackSize);
1287 
1288  /* Set it up */
1289  Irp->UserEvent = &Event;
1290  Irp->UserIosb = &Irp->IoStatus;
1291  Irp->Tail.Overlay.Thread = PsGetCurrentThread();
1292  Irp->Tail.Overlay.OriginalFileObject = FileObject;
1294 
1295  /* Set up Stack Pointer Data */
1296  StackPtr = IoGetNextIrpStackLocation(Irp);
1297  StackPtr->MajorFunction = IRP_MJ_CLOSE;
1298  StackPtr->FileObject = FileObject;
1299 
1300  /* Queue the IRP */
1301  IopQueueIrpToThread(Irp);
1302 
1303  /* Get the VPB and check if this isn't a direct open */
1304  Vpb = FileObject->Vpb;
1305  if ((Vpb) && !(FileObject->Flags & FO_DIRECT_DEVICE_OPEN))
1306  {
1307  /* Dereference the VPB before the close */
1309  }
1310 
1311  /* Check if the FS will never disappear by itself */
1312  if (FileObject->DeviceObject->Flags & DO_NEVER_LAST_DEVICE)
1313  {
1314  /* Dereference it */
1315  InterlockedDecrement(&FileObject->DeviceObject->ReferenceCount);
1316  DereferenceDone = TRUE;
1317  }
1318 
1319  /* Call the FS Driver */
1320  Status = IoCallDriver(DeviceObject, Irp);
1321  if (Status == STATUS_PENDING)
1322  {
1323  /* Wait for completion */
1325  }
1326 
1327  /* De-queue the IRP */
1328  KeRaiseIrql(APC_LEVEL, &OldIrql);
1330  KeLowerIrql(OldIrql);
1331 
1332  /* Free the IRP */
1333  IoFreeIrp(Irp);
1334 
1335  /* Clear the file name */
1336  if (FileObject->FileName.Buffer)
1337  {
1338  ExFreePoolWithTag(FileObject->FileName.Buffer, TAG_IO_NAME);
1339  FileObject->FileName.Buffer = NULL;
1340  }
1341 
1342  /* Check if the FO had a completion port */
1343  if (FileObject->CompletionContext)
1344  {
1345  /* Free it */
1346  ObDereferenceObject(FileObject->CompletionContext->Port);
1347  ExFreePool(FileObject->CompletionContext);
1348  }
1349 
1350  /* Check if the FO had extension */
1351  if (FileObject->Flags & FO_FILE_OBJECT_HAS_EXTENSION)
1352  {
1353  /* Release filter context structure if any */
1355  }
1356 
1357  /* Check if dereference has been done yet */
1358  if (!DereferenceDone)
1359  {
1360  /* Dereference device object */
1361  IopDereferenceDeviceObject(FileObject->DeviceObject, FALSE);
1362  }
1363  }
1364 }
#define FO_HANDLE_CREATED
Definition: iotypes.h:1745
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define IRP_CLOSE_OPERATION
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
VOID NTAPI FsRtlPTeardownPerFileObjectContexts(IN PFILE_OBJECT FileObject)
Definition: filtrctx.c:28
#define FO_DIRECT_DEVICE_OPEN
Definition: iotypes.h:1738
#define TAG_IO_NAME
Definition: tag.h:72
_In_ PIRP Irp
Definition: csq.h:116
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
VOID NTAPI IopDereferenceDeviceObject(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN ForceUnload)
Definition: device.c:460
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:267
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
Definition: npfs.h:636
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1313
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1727
ACPI_EFI_EVENT Event
Definition: acefiex.h:633
#define IO_FILE_DEBUG
Definition: io.h:20
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
ULONG ReferenceCount
Definition: iotypes.h:174
smooth NULL
Definition: ftsmooth.c:557
_In_ PFILE_OBJECT FileObject
Definition: classpnp.h:1229
FORCEINLINE VOID IopQueueIrpToThread(IN PIRP Irp)
Definition: io_x.h:35
unsigned char BOOLEAN
PIRP NTAPI IopAllocateIrpMustSucceed(IN CCHAR StackSize)
Definition: irp.c:653
#define STATUS_PENDING
Definition: ntstatus.h:82
VOID NTAPI IopCloseFile(IN PEPROCESS Process OPTIONAL, IN PVOID ObjectBody, IN ACCESS_MASK GrantedAccess, IN ULONG HandleCount, IN ULONG SystemHandleCount)
Definition: file.c:1928
#define DO_NEVER_LAST_DEVICE
Definition: env_spec_w32.h:402
* PFILE_OBJECT
Definition: iotypes.h:1949
#define IOTRACE(x, fmt,...)
Definition: io.h:47
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define InterlockedDecrement
Definition: armddk.h:52
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define FO_FILE_OBJECT_HAS_EXTENSION
Definition: iotypes.h:144
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
#define InterlockedExchange
Definition: armddk.h:54
Status
Definition: gdiplustypes.h:24
FORCEINLINE VOID IopUnQueueIrpFromThread(IN PIRP Irp)
Definition: io_x.h:51
PFILE_OBJECT FileObject
Definition: iotypes.h:2787
LONG NTSTATUS
Definition: DriverTester.h:11
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
PDEVICE_OBJECT NTAPI IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1159
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1155
Definition: iotypes.h:166
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1589
PVOID PIRP
Definition: usb.h:38
#define IRP_SYNCHRONOUS_API
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1097
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
_In_opt_ PVPB Vpb
Definition: iofuncs.h:1499
signed int * PLONG
Definition: retypes.h:5
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
VOID NTAPI IopDeleteIoCompletion ( PVOID  ObjectBody)

Definition at line 100 of file iocomp.c.

Referenced by IopCreateObjectTypes().

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 */
134  IopFreeMiniPacket(Packet);
135  }
136  } while (FirstEntry != CurrentEntry);
137  }
138 }
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1529
_In_ PIRP Irp
Definition: csq.h:116
IRP
Definition: iotypes.h:2457
PLIST_ENTRY NTAPI KeRundownQueue(IN PKQUEUE Queue)
Definition: queue.c:438
VOID NTAPI IopFreeMiniPacket(PIOP_MINI_COMPLETION_PACKET Packet)
Definition: iocomp.c:63
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
Definition: typedefs.h:117
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1589
PVOID PIRP
Definition: usb.h:38
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:259
VOID NTAPI IopDereferenceDeviceObject ( IN PDEVICE_OBJECT  DeviceObject,
IN BOOLEAN  ForceUnload 
)

Definition at line 460 of file device.c.

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

462 {
463  /* Sanity check */
464  ASSERT(DeviceObject->ReferenceCount);
465 
466  /* Dereference the device */
467  InterlockedDecrement(&DeviceObject->ReferenceCount);
468 
469  /*
470  * Check if we can unload it and it's safe to unload (or if we're forcing
471  * an unload, which is OK too).
472  */
473  ASSERT(!ForceUnload);
474  if (!(DeviceObject->ReferenceCount) &&
476  {
477  /* Unload it */
479  }
480 }
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
Definition: npfs.h:636
#define DOE_DELETE_PENDING
Definition: iotypes.h:150
#define InterlockedDecrement
Definition: armddk.h:52
VOID NTAPI IopUnloadDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:388
#define IoGetDevObjExtension(DeviceObject)
Definition: io.h:124
VOID NTAPI IopDereferenceVpbAndFree ( IN PVPB  Vpb)

Definition at line 183 of file volume.c.

Referenced by IopParseDevice(), and IoVerifyVolume().

184 {
185  KIRQL OldIrql;
186 
187  /* Lock the VPBs and decrease references */
188  IoAcquireVpbSpinLock(&OldIrql);
189  Vpb->ReferenceCount--;
190 
191  /* Check if we're out of references */
192  if (!Vpb->ReferenceCount && Vpb->RealDevice->Vpb == Vpb &&
193  !(Vpb->Flags & VPB_PERSISTENT))
194  {
195  /* Release VPB lock */
196  IoReleaseVpbSpinLock(OldIrql);
197 
198  /* And free VPB */
200  }
201  else
202  {
203  /* Release VPB lock */
204  IoReleaseVpbSpinLock(OldIrql);
205  }
206 }
USHORT Flags
Definition: iotypes.h:169
VOID NTAPI IoAcquireVpbSpinLock(OUT PKIRQL Irql)
Definition: volume.c:1201
#define VPB_PERSISTENT
Definition: iotypes.h:1760
#define TAG_VPB
Definition: cdprocs.h:70
UCHAR KIRQL
Definition: env_spec_w32.h:591
ULONG ReferenceCount
Definition: iotypes.h:174
struct _DEVICE_OBJECT * RealDevice
Definition: iotypes.h:172
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1097
_In_opt_ PVPB Vpb
Definition: iofuncs.h:1499
VOID NTAPI IoReleaseVpbSpinLock(IN KIRQL Irql)
Definition: volume.c:1212
NTSTATUS NTAPI IopDetectResourceConflict ( IN PCM_RESOURCE_LIST  ResourceList,
IN BOOLEAN  Silent,
OUT OPTIONAL PCM_PARTIAL_RESOURCE_DESCRIPTOR  ConflictingDescriptor 
)

Definition at line 1200 of file pnpres.c.

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

1204 {
1207  HANDLE ResourceMapKey = NULL, ChildKey2 = NULL, ChildKey3 = NULL;
1208  ULONG KeyInformationLength, RequiredLength, KeyValueInformationLength, KeyNameInformationLength;
1209  PKEY_BASIC_INFORMATION KeyInformation;
1210  PKEY_VALUE_PARTIAL_INFORMATION KeyValueInformation;
1212  ULONG ChildKeyIndex1 = 0, ChildKeyIndex2 = 0, ChildKeyIndex3 = 0;
1213  NTSTATUS Status;
1214 
1215  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\HARDWARE\\RESOURCEMAP");
1216  InitializeObjectAttributes(&ObjectAttributes,
1217  &KeyName,
1219  NULL,
1220  NULL);
1221  Status = ZwOpenKey(&ResourceMapKey, KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, &ObjectAttributes);
1222  if (!NT_SUCCESS(Status))
1223  {
1224  /* The key is missing which means we are the first device */
1225  return STATUS_SUCCESS;
1226  }
1227 
1228  while (TRUE)
1229  {
1230  Status = ZwEnumerateKey(ResourceMapKey,
1231  ChildKeyIndex1,
1233  NULL,
1234  0,
1235  &RequiredLength);
1236  if (Status == STATUS_NO_MORE_ENTRIES)
1237  break;
1238  else if (Status == STATUS_BUFFER_OVERFLOW || Status == STATUS_BUFFER_TOO_SMALL)
1239  {
1240  KeyInformationLength = RequiredLength;
1241  KeyInformation = ExAllocatePoolWithTag(PagedPool,
1242  KeyInformationLength,
1243  TAG_IO);
1244  if (!KeyInformation)
1245  {
1247  goto cleanup;
1248  }
1249 
1250  Status = ZwEnumerateKey(ResourceMapKey,
1251  ChildKeyIndex1,
1253  KeyInformation,
1254  KeyInformationLength,
1255  &RequiredLength);
1256  }
1257  else
1258  goto cleanup;
1259  ChildKeyIndex1++;
1260  if (!NT_SUCCESS(Status))
1261  {
1262  ExFreePoolWithTag(KeyInformation, TAG_IO);
1263  goto cleanup;
1264  }
1265 
1266  KeyName.Buffer = KeyInformation->Name;
1267  KeyName.MaximumLength = KeyName.Length = (USHORT)KeyInformation->NameLength;
1268  InitializeObjectAttributes(&ObjectAttributes,
1269  &KeyName,
1271  ResourceMapKey,
1272  NULL);
1273  Status = ZwOpenKey(&ChildKey2,
1275  &ObjectAttributes);
1276  ExFreePoolWithTag(KeyInformation, TAG_IO);
1277  if (!NT_SUCCESS(Status))
1278  goto cleanup;
1279 
1280  while (TRUE)
1281  {
1282  Status = ZwEnumerateKey(ChildKey2,
1283  ChildKeyIndex2,
1285  NULL,
1286  0,
1287  &RequiredLength);
1288  if (Status == STATUS_NO_MORE_ENTRIES)
1289  break;
1290  else if (Status == STATUS_BUFFER_TOO_SMALL)
1291  {
1292  KeyInformationLength = RequiredLength;
1293  KeyInformation = ExAllocatePoolWithTag(PagedPool,
1294  KeyInformationLength,
1295  TAG_IO);
1296  if (!KeyInformation)
1297  {
1299  goto cleanup;
1300  }
1301 
1302  Status = ZwEnumerateKey(ChildKey2,
1303  ChildKeyIndex2,
1305  KeyInformation,
1306  KeyInformationLength,
1307  &RequiredLength);
1308  }
1309  else
1310  goto cleanup;
1311  ChildKeyIndex2++;
1312  if (!NT_SUCCESS(Status))
1313  {
1314  ExFreePoolWithTag(KeyInformation, TAG_IO);
1315  goto cleanup;
1316  }
1317 
1318  KeyName.Buffer = KeyInformation->Name;
1319  KeyName.MaximumLength = KeyName.Length = (USHORT)KeyInformation->NameLength;
1320  InitializeObjectAttributes(&ObjectAttributes,
1321  &KeyName,
1323  ChildKey2,
1324  NULL);
1325  Status = ZwOpenKey(&ChildKey3, KEY_QUERY_VALUE, &ObjectAttributes);
1326  ExFreePoolWithTag(KeyInformation, TAG_IO);
1327  if (!NT_SUCCESS(Status))
1328  goto cleanup;
1329 
1330  while (TRUE)
1331  {
1332  Status = ZwEnumerateValueKey(ChildKey3,
1333  ChildKeyIndex3,
1335  NULL,
1336  0,
1337  &RequiredLength);
1338  if (Status == STATUS_NO_MORE_ENTRIES)
1339  break;
1340  else if (Status == STATUS_BUFFER_TOO_SMALL)
1341  {
1342  KeyValueInformationLength = RequiredLength;
1343  KeyValueInformation = ExAllocatePoolWithTag(PagedPool,
1344  KeyValueInformationLength,
1345  TAG_IO);
1346  if (!KeyValueInformation)
1347  {
1349  goto cleanup;
1350  }
1351 
1352  Status = ZwEnumerateValueKey(ChildKey3,
1353  ChildKeyIndex3,
1355  KeyValueInformation,
1356  KeyValueInformationLength,
1357  &RequiredLength);
1358  }
1359  else
1360  goto cleanup;
1361  if (!NT_SUCCESS(Status))
1362  {
1363  ExFreePoolWithTag(KeyValueInformation, TAG_IO);
1364  goto cleanup;
1365  }
1366 
1367  Status = ZwEnumerateValueKey(ChildKey3,
1368  ChildKeyIndex3,
1370  NULL,
1371  0,
1372  &RequiredLength);
1373  if (Status == STATUS_BUFFER_TOO_SMALL)
1374  {
1375  KeyNameInformationLength = RequiredLength;
1376  KeyNameInformation = ExAllocatePoolWithTag(PagedPool,
1377  KeyNameInformationLength + sizeof(WCHAR),
1378  TAG_IO);
1379  if (!KeyNameInformation)
1380  {
1382  goto cleanup;
1383  }
1384 
1385  Status = ZwEnumerateValueKey(ChildKey3,
1386  ChildKeyIndex3,
1388  KeyNameInformation,
1389  KeyNameInformationLength,
1390  &RequiredLength);
1391  }
1392  else
1393  goto cleanup;
1394  ChildKeyIndex3++;
1395  if (!NT_SUCCESS(Status))
1396  {
1397  ExFreePoolWithTag(KeyNameInformation, TAG_IO);
1398  goto cleanup;
1399  }
1400 
1401  KeyNameInformation->Name[KeyNameInformation->NameLength / sizeof(WCHAR)] = UNICODE_NULL;
1402 
1403  /* Skip translated entries */
1404  if (wcsstr(KeyNameInformation->Name, L".Translated"))
1405  {
1406  ExFreePoolWithTag(KeyNameInformation, TAG_IO);
1407  ExFreePoolWithTag(KeyValueInformation, TAG_IO);
1408  continue;
1409  }
1410 
1411  ExFreePoolWithTag(KeyNameInformation, TAG_IO);
1412 
1414  (PCM_RESOURCE_LIST)KeyValueInformation->Data,
1415  Silent,
1416  ConflictingDescriptor))
1417  {
1418  ExFreePoolWithTag(KeyValueInformation, TAG_IO);
1420  goto cleanup;
1421  }
1422 
1423  ExFreePoolWithTag(KeyValueInformation, TAG_IO);
1424  }
1425  }
1426  }
1427 
1428 cleanup:
1429  if (ResourceMapKey != NULL)
1430  ObCloseHandle(ResourceMapKey, KernelMode);
1431  if (ChildKey2 != NULL)
1432  ObCloseHandle(ChildKey2, KernelMode);
1433  if (ChildKey3 != NULL)
1434  ObCloseHandle(ChildKey3, KernelMode);
1435 
1436  if (Status == STATUS_NO_MORE_ENTRIES)
1437  Status = STATUS_SUCCESS;
1438 
1439  return Status;
1440 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4692
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TAG_IO
Definition: tag.h:69
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:193
USHORT MaximumLength
Definition: env_spec_w32.h:370
Definition: bidi.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
return STATUS_SUCCESS
Definition: btrfs.c:2664
#define WCHAR
Definition: msvc.h:43
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:50
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:557
static PUCHAR ResourceList[1+IDB_CLUSTER_SERVER]
Definition: inbv.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3369
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:1170
Status
Definition: gdiplustypes.h:24
DWORD *typedef HANDLE
Definition: winlogon.h:52
LONG NTSTATUS
Definition: DriverTester.h:11
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:47
unsigned short USHORT
Definition: pedump.c:61
_In_ ULONG _Out_opt_ PULONG RequiredLength
Definition: wmifuncs.h:29
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
char * cleanup(char *str)
Definition: wpickclick.c:99
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1097
#define STATUS_CONFLICTING_ADDRESSES
Definition: ntstatus.h:247
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
VOID NTAPI IopDoNameTransmogrify ( IN PIRP  Irp,
IN PFILE_OBJECT  FileObject,
IN PREPARSE_DATA_BUFFER  DataBuffer 
)

Definition at line 169 of file file.c.

Referenced by IopCompleteRequest(), and IopParseDevice().

172 {
173  PWSTR Buffer;
174  USHORT Length;
176  PWSTR NewBuffer;
177 
178  PAGED_CODE();
179 
180  ASSERT(Irp->IoStatus.Status == STATUS_REPARSE);
181  ASSERT(Irp->IoStatus.Information == IO_REPARSE_TAG_MOUNT_POINT);
182  ASSERT(Irp->Tail.Overlay.AuxiliaryBuffer != NULL);
183  ASSERT(DataBuffer != NULL);
184  ASSERT(DataBuffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT);
185  ASSERT(DataBuffer->ReparseDataLength < MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
186  ASSERT(DataBuffer->Reserved < MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
187 
188  /* First of all, validate data */
189  if (DataBuffer->ReparseDataLength < REPARSE_DATA_BUFFER_HEADER_SIZE ||
190  (DataBuffer->SymbolicLinkReparseBuffer.PrintNameLength +
191  DataBuffer->SymbolicLinkReparseBuffer.SubstituteNameLength +
193  {
194  Irp->IoStatus.Status = STATUS_IO_REPARSE_DATA_INVALID;
195  }
196 
197  /* Everything went right */
198  if (NT_SUCCESS(Irp->IoStatus.Status))
199  {
200  /* Compute buffer & length */
201  Buffer = (PWSTR)((ULONG_PTR)DataBuffer->MountPointReparseBuffer.PathBuffer +
202  DataBuffer->MountPointReparseBuffer.SubstituteNameOffset);
203  Length = DataBuffer->MountPointReparseBuffer.SubstituteNameLength;
204 
205  /* Check we don't overflow */
206  if (((ULONG)MAXUSHORT - DataBuffer->Reserved) <= (Length + sizeof(UNICODE_NULL)))
207  {
208  Irp->IoStatus.Status = STATUS_IO_REPARSE_DATA_INVALID;
209  }
210  else
211  {
212  /* Compute how much mem we'll need */
213  RequiredLength = DataBuffer->Reserved + Length + sizeof(UNICODE_NULL);
214 
215  /* Check if FileObject can already hold what we need */
216  if (FileObject->FileName.MaximumLength >= RequiredLength)
217  {
218  NewBuffer = FileObject->FileName.Buffer;
219  }
220  else
221  {
222  /* Allocate otherwise */
223  NewBuffer = ExAllocatePoolWithTag(PagedPool, RequiredLength, TAG_IO_NAME);
224  if (NewBuffer == NULL)
225  {
226  Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
227  }
228  }
229  }
230  }
231 
232  /* Everything went right */
233  if (NT_SUCCESS(Irp->IoStatus.Status))
234  {
235  /* Copy reserved */
236  if (DataBuffer->Reserved)
237  {
238  RtlMoveMemory((PWSTR)((ULONG_PTR)NewBuffer + Length),
239  (PWSTR)((ULONG_PTR)FileObject->FileName.Buffer + FileObject->FileName.Length - DataBuffer->Reserved),
240  DataBuffer->Reserved);
241  }
242 
243  /* Then, buffer */
244  if (Length)
245  {
246  RtlCopyMemory(NewBuffer, Buffer, Length);
247  }
248 
249  /* And finally replace buffer if new one was allocated */
250  FileObject->FileName.Length = RequiredLength - sizeof(UNICODE_NULL);
251  if (NewBuffer != FileObject->FileName.Buffer)
252  {
253  if (FileObject->FileName.Buffer)
254  {
255  ExFreePoolWithTag(FileObject->FileName.Buffer, TAG_IO_NAME);
256  }
257 
258  FileObject->FileName.Buffer = NewBuffer;
259  FileObject->FileName.MaximumLength = RequiredLength;
260  FileObject->FileName.Buffer[RequiredLength / sizeof(WCHAR) - 1] = UNICODE_NULL;
261  }
262  }
263 
264  /* We don't need them anymore - it was allocated by the driver */
265  ExFreePool(DataBuffer);
266 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TAG_IO_NAME
Definition: tag.h:72
_In_ PIRP Irp
Definition: csq.h:116
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
PVOID *typedef PWSTR
Definition: winlogon.h:57
#define WCHAR
Definition: msvc.h:43
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define IO_REPARSE_TAG_MOUNT_POINT
Definition: iotypes.h:6842
WCHAR PathBuffer[1]
Definition: shellext.h:130
#define UNICODE_NULL
#define STATUS_IO_REPARSE_DATA_INVALID
Definition: ntstatus.h:742
smooth NULL
Definition: ftsmooth.c:557
_In_ PFILE_OBJECT FileObject
Definition: classpnp.h:1229
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define PAGED_CODE()
Definition: video.h:57
UINTN VOID * Buffer
Definition: acefiex.h:370
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
VOID UINTN Length
Definition: acefiex.h:744
#define REPARSE_DATA_BUFFER_HEADER_SIZE
Definition: iotypes.h:6810
unsigned short USHORT
Definition: pedump.c:61
_In_ ULONG _Out_opt_ PULONG RequiredLength
Definition: wmifuncs.h:29
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define STATUS_REPARSE
Definition: ntstatus.h:83
#define MAXUSHORT
Definition: typedefs.h:81
unsigned int ULONG
Definition: retypes.h:1
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1097
#define MAXIMUM_REPARSE_DATA_BUFFER_SIZE
Definition: iotypes.h:6824
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
NTSTATUS IopEnumerateDevice ( IN PDEVICE_OBJECT  DeviceObject)

Definition at line 2348 of file pnpmgr.c.

Referenced by IoInitSystem(), and IoSynchronousInvalidateDeviceRelations().

2350 {
2353  PDEVICE_RELATIONS DeviceRelations;
2354  PDEVICE_OBJECT ChildDeviceObject;
2356  PDEVICE_NODE ChildDeviceNode;
2357  IO_STACK_LOCATION Stack;
2358  NTSTATUS Status;
2359  ULONG i;
2360 
2361  DPRINT("DeviceObject 0x%p\n", DeviceObject);
2362 
2363  if (DeviceNode->Flags & DNF_NEED_ENUMERATION_ONLY)
2364  {
2365  DeviceNode->Flags &= ~DNF_NEED_ENUMERATION_ONLY;
2366 
2367  DPRINT("Sending GUID_DEVICE_ARRIVAL\n");
2368  IopQueueTargetDeviceEvent(&GUID_DEVICE_ARRIVAL,
2369  &DeviceNode->InstancePath);
2370  }
2371 
2372  DPRINT("Sending IRP_MN_QUERY_DEVICE_RELATIONS to device stack\n");
2373 
2375 
2376  Status = IopInitiatePnpIrp(
2377  DeviceObject,
2378  &IoStatusBlock,
2380  &Stack);
2381  if (!NT_SUCCESS(Status) || Status == STATUS_PENDING)
2382  {
2383  DPRINT("IopInitiatePnpIrp() failed with status 0x%08lx\n", Status);
2384  return Status;
2385  }
2386 
2387  DeviceRelations = (PDEVICE_RELATIONS)IoStatusBlock.Information;
2388 
2389  /*
2390  * Send removal IRPs for devices that have disappeared
2391  * NOTE: This code handles the case where no relations are specified
2392  */
2393  IopHandleDeviceRemoval(DeviceNode, DeviceRelations);
2394 
2395  /* Now we bail if nothing was returned */
2396  if (!DeviceRelations)
2397  {
2398  /* We're all done */
2399  DPRINT("No PDOs\n");
2400  return STATUS_SUCCESS;
2401  }
2402 
2403  DPRINT("Got %u PDOs\n", DeviceRelations->Count);
2404 
2405  /*
2406  * Create device nodes for all discovered devices
2407  */
2408  for (i = 0; i < DeviceRelations->Count; i++)
2409  {
2410  ChildDeviceObject = DeviceRelations->Objects[i];
2411  ASSERT((ChildDeviceObject->Flags & DO_DEVICE_INITIALIZING) == 0);
2412 
2413  ChildDeviceNode = IopGetDeviceNode(ChildDeviceObject);
2414  if (!ChildDeviceNode)
2415  {
2416  /* One doesn't exist, create it */
2417  Status = IopCreateDeviceNode(
2418  DeviceNode,
2419  ChildDeviceObject,
2420  NULL,
2421  &ChildDeviceNode);
2422  if (NT_SUCCESS(Status))
2423  {
2424  /* Mark the node as enumerated */
2425  ChildDeviceNode->Flags |= DNF_ENUMERATED;
2426 
2427  /* Mark the DO as bus enumerated */
2428  ChildDeviceObject->Flags |= DO_BUS_ENUMERATED_DEVICE;
2429  }
2430  else
2431  {
2432  /* Ignore this DO */
2433  DPRINT1("IopCreateDeviceNode() failed with status 0x%08x. Skipping PDO %u\n", Status, i);
2434  ObDereferenceObject(ChildDeviceObject);
2435  }
2436  }
2437  else
2438  {
2439  /* Mark it as enumerated */
2440  ChildDeviceNode->Flags |= DNF_ENUMERATED;
2441  ObDereferenceObject(ChildDeviceObject);
2442  }
2443  }
2444  ExFreePool(DeviceRelations);
2445 
2446  /*
2447  * Retrieve information about all discovered children from the bus driver
2448  */
2450  &Context,
2451  DeviceNode,
2453  DeviceNode);
2454 
2455  Status = IopTraverseDeviceTree(&Context);
2456  if (!NT_SUCCESS(Status))
2457  {
2458  DPRINT("IopTraverseDeviceTree() failed with status 0x%08lx\n", Status);
2459  return Status;
2460  }
2461 
2462  /*
2463  * Retrieve configuration from the registry for discovered children
2464  */
2466  &Context,
2467  DeviceNode,
2469  DeviceNode);
2470 
2471  Status = IopTraverseDeviceTree(&Context);
2472  if (!NT_SUCCESS(Status))
2473  {
2474  DPRINT("IopTraverseDeviceTree() failed with status 0x%08lx\n", Status);
2475  return Status;
2476  }
2477 
2478  /*
2479  * Initialize services for discovered children.
2480  */
2481  Status = IopInitializePnpServices(DeviceNode);
2482  if (!NT_SUCCESS(Status))
2483  {
2484  DPRINT("IopInitializePnpServices() failed with status 0x%08lx\n", Status);
2485  return Status;
2486  }
2487 
2488  DPRINT("IopEnumerateDevice() finished\n");
2489  return STATUS_SUCCESS;
2490 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
ULONG Flags
Definition: iotypes.h:836
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
return STATUS_SUCCESS
Definition: btrfs.c:2664
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2049
struct _IO_STACK_LOCATION::@3397::@3419 QueryDeviceRelations
static VOID IopHandleDeviceRemoval(IN PDEVICE_NODE DeviceNode, IN PDEVICE_RELATIONS DeviceRelations)
Definition: pnpmgr.c:2302
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:267
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
Definition: npfs.h:636
NTSTATUS IopCreateDeviceNode(PDEVICE_NODE ParentNode, PDEVICE_OBJECT PhysicalDeviceObject, PUNICODE_STRING ServiceName, PDEVICE_NODE *DeviceNode)
Definition: pnpmgr.c:1031
NTSTATUS IopActionConfigureChildServices(PDEVICE_NODE DeviceNode, PVOID Context)
Definition: pnpmgr.c:2510
GLenum GLclampf GLint i
Definition: glfuncs.h:14
NTSTATUS IopActionInterrogateDeviceStack(PDEVICE_NODE DeviceNode, PVOID Context)
Definition: pnpmgr.c:2033
struct _DEVICE_RELATIONS * PDEVICE_RELATIONS
smooth NULL
Definition: ftsmooth.c:557
#define DO_BUS_ENUMERATED_DEVICE
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS IopQueueTargetDeviceEvent(const GUID *Guid, PUNICODE_STRING DeviceIds)
Definition: plugplay.c:46
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define STATUS_PENDING
Definition: ntstatus.h:82
#define DNF_NEED_ENUMERATION_ONLY
Definition: iotypes.h:194
Definition: Node.h:9
PDEVICE_NODE FASTCALL IopGetDeviceNode(PDEVICE_OBJECT DeviceObject)
Definition: pnpmgr.c:63
union _IO_STACK_LOCATION::@3397 Parameters
NTSTATUS NTAPI IopInitiatePnpIrp(IN PDEVICE_OBJECT DeviceObject, IN OUT PIO_STATUS_BLOCK IoStatusBlock, IN UCHAR MinorFunction, IN PIO_STACK_LOCATION Stack OPTIONAL)
Definition: pnpmgr.c:1330
UNICODE_STRING InstancePath
Definition: iotypes.h:842
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define DPRINT1
Definition: precomp.h:8
struct tagContext Context
Definition: acpixf.h:1014
unsigned int ULONG
Definition: retypes.h:1
#define DNF_ENUMERATED
Definition: iotypes.h:170
NTSTATUS IopInitializePnpServices(IN PDEVICE_NODE DeviceNode)
Definition: pnpmgr.c:2782
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define IopInitDeviceTreeTraverseContext(_DeviceTreeTraverseContext, _DeviceNode, _Action,_Context)
Definition: io.h:224
NTSTATUS IopTraverseDeviceTree(PDEVICETREE_TRAVERSE_CONTEXT Context)
Definition: pnpmgr.c:1393
NTSTATUS NTAPI IopFetchConfigurationInformation ( OUT PWSTR SymbolicLinkList,
IN GUID  Guid,
IN ULONG  ExpectedInterfaces,
IN PULONG  Interfaces 
)

Definition at line 656 of file iorsrce.c.

Referenced by IopCreateArcNamesCd(), and IopCreateArcNamesDisk().

660 {
662  ULONG IntInterfaces = 0;
663  PWSTR IntSymbolicLinkList;
664 
665  /* Get the associated enabled interfaces with the given GUID */
667  if (!NT_SUCCESS(Status))
668  {
669  /* Zero output and leave */
670  if (SymbolicLinkList != 0)
671  {
672  *SymbolicLinkList = 0;
673  }
674 
675  return STATUS_UNSUCCESSFUL;
676  }
677 
678  IntSymbolicLinkList = *SymbolicLinkList;
679 
680  /* Count the number of enabled interfaces by counting the number of symbolic links */
681  while (*IntSymbolicLinkList != UNICODE_NULL)
682  {
683  IntInterfaces++;
684  IntSymbolicLinkList += wcslen(IntSymbolicLinkList) + (sizeof(UNICODE_NULL) / sizeof(WCHAR));
685  }
686 
687  /* Matching result will define the result */
688  Status = (IntInterfaces >= ExpectedInterfaces) ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
689  /* Finally, give back to the caller the number of found interfaces */
690  *Interfaces = IntInterfaces;
691 
692  return Status;
693 }
_In_opt_ PDEVICE_OBJECT _In_ ULONG _Outptr_result_nullonfailure_ _At_ * SymbolicLinkList(return==0, __drv_allocatesMem(Mem))) PZZWSTR *SymbolicLinkList
__wchar_t WCHAR
Definition: xmlstorage.h:180
return STATUS_SUCCESS
Definition: btrfs.c:2664
PVOID *typedef PWSTR
Definition: winlogon.h:57
static const CLASS_AND_INTERFACES ExpectedInterfaces[]
Definition: browseui.c:13
NTSTATUS NTAPI IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid, IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, IN ULONG Flags, OUT PWSTR *SymbolicLinkList)
Definition: deviface.c:458
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:557
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_In_ LPGUID Guid
Definition: classpnp.h:778
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
unsigned int ULONG
Definition: retypes.h:1
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSTATUS NTAPI IopFixupResourceListWithRequirements ( IN PIO_RESOURCE_REQUIREMENTS_LIST  RequirementsList,
OUT PCM_RESOURCE_LIST ResourceList 
)

Definition at line 202 of file pnpres.c.

Referenced by IopAssignDeviceResources(), and IopLegacyResourceAllocation().

205 {
206  ULONG i, OldCount;
207  BOOLEAN AlternateRequired = FALSE;
208 
209  /* Save the initial resource count when we got here so we can restore if an alternate fails */
210  if (*ResourceList != NULL)
211  OldCount = (*ResourceList)->List[0].PartialResourceList.Count;
212  else
213  OldCount = 0;
214 
215  for (i = 0; i < RequirementsList->AlternativeLists; i++)
216  {
217  ULONG ii;
218  PIO_RESOURCE_LIST ResList = &RequirementsList->List[i];
219 
220  /* We need to get back to where we were before processing the last alternative list */
221  if (OldCount == 0 && *ResourceList != NULL)
222  {
223  /* Just free it and kill the pointer */
225  *ResourceList = NULL;
226  }
227  else if (OldCount != 0)
228  {
229  PCM_RESOURCE_LIST NewList;
230 
231  /* Let's resize it */
232  (*ResourceList)->List[0].PartialResourceList.Count = OldCount;
233 
234  /* Allocate the new smaller list */
236  if (!NewList)
237  return STATUS_NO_MEMORY;
238 
239  /* Copy the old stuff back */
241 
242  /* Free the old one */
244 
245  /* Store the pointer to the new one */
246  *ResourceList = NewList;
247  }
248 
249  for (ii = 0; ii < ResList->Count; ii++)
250  {
251  ULONG iii;
252  PCM_PARTIAL_RESOURCE_LIST PartialList = (*ResourceList) ? &(*ResourceList)->List[0].PartialResourceList : NULL;
253  PIO_RESOURCE_DESCRIPTOR IoDesc = &ResList->Descriptors[ii];
254  BOOLEAN Matched = FALSE;
255 
256  /* Skip alternates if we don't need one */
257  if (!AlternateRequired && (IoDesc->Option & IO_RESOURCE_ALTERNATIVE))
258  {
259  DPRINT("Skipping unneeded alternate\n");
260  continue;
261  }
262 
263  /* Check if we couldn't satsify a requirement or its alternates */
264  if (AlternateRequired && !(IoDesc->Option & IO_RESOURCE_ALTERNATIVE))
265  {
266  DPRINT1("Unable to satisfy preferred resource or alternates in list %lu\n", i);
267 
268  /* Break out of this loop and try the next list */
269  break;
270  }
271 
272  for (iii = 0; PartialList && iii < PartialList->Count && !Matched; iii++)
273  {
274  PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDesc = &PartialList->PartialDescriptors[iii];
275 
276  /* First check types */
277  if (IoDesc->Type != CmDesc->Type)
278  continue;
279 
280  switch (IoDesc->Type)
281  {
283  /* Make sure it satisfies our vector range */
284  if (CmDesc->u.Interrupt.Vector >= IoDesc->u.Interrupt.MinimumVector &&
285  CmDesc->u.Interrupt.Vector <= IoDesc->u.Interrupt.MaximumVector)
286  {
287  /* Found it */
288  Matched = TRUE;
289  }
290  else
291  {
292  DPRINT("Interrupt - Not a match! 0x%x not inside 0x%x to 0x%x\n",
293  CmDesc->u.Interrupt.Vector,
294  IoDesc->u.Interrupt.MinimumVector,
295  IoDesc->u.Interrupt.MaximumVector);
296  }
297  break;
298 
300  case CmResourceTypePort:
301  /* Make sure the length matches and it satisfies our address range */
302  if (CmDesc->u.Memory.Length == IoDesc->u.Memory.Length &&
303  (ULONGLONG)CmDesc->u.Memory.Start.QuadPart >= (ULONGLONG)IoDesc->u.Memory.MinimumAddress.QuadPart &&
304  (ULONGLONG)CmDesc->u.Memory.Start.QuadPart + CmDesc->u.Memory.Length - 1 <= (ULONGLONG)IoDesc->u.Memory.MaximumAddress.QuadPart)
305  {
306  /* Found it */
307  Matched = TRUE;
308  }
309  else
310  {
311  DPRINT("Memory/Port - Not a match! 0x%I64x with length 0x%x not inside 0x%I64x to 0x%I64x with length 0x%x\n",
312  CmDesc->u.Memory.Start.QuadPart,
313  CmDesc->u.Memory.Length,
314  IoDesc->u.Memory.MinimumAddress.QuadPart,
315  IoDesc->u.Memory.MaximumAddress.QuadPart,
316  IoDesc->u.Memory.Length);
317  }
318  break;
319 
321  /* Make sure the length matches and it satisfies our bus number range */
322  if (CmDesc->u.BusNumber.Length == IoDesc->u.BusNumber.Length &&
323  CmDesc->u.BusNumber.Start >= IoDesc->u.BusNumber.MinBusNumber &&
324  CmDesc->u.BusNumber.Start + CmDesc->u.BusNumber.Length - 1 <= IoDesc->u.BusNumber.MaxBusNumber)
325  {
326  /* Found it */
327  Matched = TRUE;
328  }
329  else
330  {
331  DPRINT("Bus Number - Not a match! 0x%x with length 0x%x not inside 0x%x to 0x%x with length 0x%x\n",
332  CmDesc->