ReactOS  0.4.15-dev-1197-g8081ba9
classp.h File Reference
#include <stddef.h>
#include <stdarg.h>
#include <stdlib.h>
#include <ntddk.h>
#include <scsi.h>
#include <wmidata.h>
#include <classpnp.h>
#include <storduid.h>
#include <mountdev.h>
#include <ioevent.h>
#include <ntstrsafe.h>
#include <ntintsafe.h>
#include <wdmguid.h>
#include <ntpoapi.h>
#include <srbhelper.h>
#include <storswtr.h>
Include dependency graph for classp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _MEDIA_CHANGE_DETECTION_INFO
 
struct  _FAILURE_PREDICTION_INFO
 
struct  _CLASS_RETRY_INFO
 
struct  _CSCAN_LIST
 
struct  _CLASS_ERROR_LOG_DATA
 
struct  _TRANSFER_PACKET
 
struct  _PNL_SLIST_HEADER
 
struct  _CLASS_PRIVATE_FDO_DATA
 
struct  _CLASS_PRIVATE_COMMON_DATA
 
struct  _IDLE_POWER_FDO_LIST_ENTRY
 
struct  _OFFLOAD_READ_CONTEXT
 
struct  _OFFLOAD_WRITE_CONTEXT
 
struct  _OPCODE_SENSE_DATA_IO_LOG_MESSAGE_CONTEXT_HEADER
 
struct  _IO_RETRIED_LOG_MESSAGE_CONTEXT
 

Macros

#define RTL_USE_AVL_TABLES   0
 
#define DEBUG_COMP_ID   DPFLTR_CLASSPNP_ID
 
#define WPP_GUID_CLASSPNP   (FA8DE7C4, ACDE, 4443, 9994, C4E2359A9EDB)
 
#define WPP_CONTROL_GUIDS   WPP_CONTROL_GUIDS_NORMAL_FLAGS(WPP_GUID_CLASSPNP)
 
#define PTRALIGN
 
#define Add2Ptr(P, I)   ((PVOID)((PUCHAR)(P) + (I)))
 
#define CLASSP_REG_SUBKEY_NAME   (L"Classpnp")
 
#define CLASSP_REG_HACK_VALUE_NAME   (L"HackMask")
 
#define CLASSP_REG_MMC_DETECTION_VALUE_NAME   (L"MMCDetectionState")
 
#define CLASSP_REG_WRITE_CACHE_VALUE_NAME   (L"WriteCacheEnableOverride")
 
#define CLASSP_REG_PERF_RESTORE_VALUE_NAME   (L"RestorePerfAtCount")
 
#define CLASSP_REG_REMOVAL_POLICY_VALUE_NAME   (L"UserRemovalPolicy")
 
#define CLASSP_REG_IDLE_INTERVAL_NAME   (L"IdleInterval")
 
#define CLASSP_REG_IDLE_ACTIVE_MAX   (L"IdleOutstandingIoMax")
 
#define CLASSP_REG_IDLE_PRIORITY_SUPPORTED   (L"IdlePrioritySupported")
 
#define CLASSP_REG_ACCESS_ALIGNMENT_NOT_SUPPORTED   (L"AccessAlignmentQueryNotSupported")
 
#define CLASSP_REG_DISBALE_IDLE_POWER_NAME   (L"DisableIdlePowerManagement")
 
#define CLASSP_REG_IDLE_TIMEOUT_IN_SECONDS   (L"IdleTimeoutInSeconds")
 
#define CLASSP_REG_DISABLE_D3COLD   (L"DisableD3Cold")
 
#define CLASSP_REG_QERR_OVERRIDE_MODE   (L"QERROverrideMode")
 
#define CLASSP_REG_LEGACY_ERROR_HANDLING   (L"LegacyErrorHandling")
 
#define CLASSP_REG_COPY_OFFLOAD_MAX_TARGET_DURATION   (L"CopyOffloadMaxTargetDuration")
 
#define CLASS_PERF_RESTORE_MINIMUM   (0x10)
 
#define CLASS_ERROR_LEVEL_1   (0x4)
 
#define CLASS_ERROR_LEVEL_2   (0x8)
 
#define CLASS_MAX_INTERLEAVE_PER_CRITICAL_IO   (0x4)
 
#define FDO_HACK_CANNOT_LOCK_MEDIA   (0x00000001)
 
#define FDO_HACK_GESN_IS_BAD   (0x00000002)
 
#define FDO_HACK_NO_SYNC_CACHE   (0x00000004)
 
#define FDO_HACK_NO_RESERVE6   (0x00000008)
 
#define FDO_HACK_GESN_IGNORE_OPCHANGE   (0x00000010)
 
#define FDO_HACK_VALID_FLAGS   (0x0000001F)
 
#define FDO_HACK_INVALID_FLAGS   (~FDO_HACK_VALID_FLAGS)
 
#define NUM_LOCKMEDIAREMOVAL_RETRIES   1
 
#define NUM_MODESENSE_RETRIES   1
 
#define NUM_MODESELECT_RETRIES   1
 
#define NUM_DRIVECAPACITY_RETRIES   1
 
#define NUM_THIN_PROVISIONING_RETRIES   32
 
#define NUM_IO_RETRIES   MAXIMUM_RETRIES
 
#define LEGACY_NUM_IO_RETRIES   8
 
#define CLASS_FILE_OBJECT_EXTENSION_KEY   'eteP'
 
#define CLASSP_VOLUME_VERIFY_CHECKED   0x34
 
#define CLASS_TAG_PRIVATE_DATA   'CPcS'
 
#define CLASS_TAG_SENSE2   '2ScS'
 
#define CLASS_TAG_WORKING_SET   'sWcS'
 
#define CLASSPNP_POOL_TAG_GENERIC   'pCcS'
 
#define CLASSPNP_POOL_TAG_TOKEN_OPERATION   'oTcS'
 
#define CLASSPNP_POOL_TAG_SRB   'rScS'
 
#define CLASSPNP_POOL_TAG_VPD   'pVcS'
 
#define CLASSPNP_POOL_TAG_LOG_MESSAGE   'mlcS'
 
#define CLASSPNP_POOL_TAG_ADDITIONAL_DATA   'DAcS'
 
#define CLASSPNP_POOL_TAG_FIRMWARE   'wFcS'
 
#define MAX_LIST_IDENTIFIER   MAXULONG
 
#define NUM_POPULATE_TOKEN_RETRIES   1
 
#define NUM_WRITE_USING_TOKEN_RETRIES   2
 
#define NUM_RECEIVE_TOKEN_INFORMATION_RETRIES   2
 
#define MAX_TOKEN_OPERATION_PARAMETER_DATA_LENGTH   MAXUSHORT
 
#define MAX_RECEIVE_TOKEN_INFORMATION_PARAMETER_DATA_LENGTH   MAXULONG
 
#define MAX_TOKEN_TRANSFER_SIZE   MAXULONGLONG
 
#define MAX_NUMBER_BLOCKS_PER_BLOCK_DEVICE_RANGE_DESCRIPTOR   MAXULONG
 
#define DEFAULT_MAX_TARGET_DURATION   4
 
#define DEFAULT_MAX_NUMBER_BYTES_PER_SYNC_WRITE_USING_TOKEN   (64ULL * 1024 * 1024)
 
#define MAX_NUMBER_BYTES_PER_SYNC_WRITE_USING_TOKEN   (256ULL * 1024 * 1024)
 
#define MIN_TOKEN_LIST_IDENTIFIERS   256
 
#define MAX_TOKEN_LIST_IDENTIFIERS   MAXULONG
 
#define MAX_NUMBER_BLOCK_DEVICE_DESCRIPTORS   64
 
#define REG_DISK_CLASS_CONTROL   L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control\\DISK"
 
#define REG_MAX_LIST_IDENTIFIER_VALUE   L"MaximumListIdentifier"
 
#define VPD_PAGE_HEADER_SIZE   0x04
 
#define GET_LBA_STATUS_RETRY_COUNT_MAX   (2)
 
#define SHIFT10000   13
 
#define CONST_MSECS_PER_SEC   1000
 
#define Convert100nsToMilliseconds(LARGE_INTEGER)
 
#define ConvertMillisecondsTo100ns(MILLISECONDS)
 
#define NUM_ERROR_LOG_ENTRIES   16
 
#define DBG_NUM_PACKET_LOG_ENTRIES   (64*2)
 
#define MIN_INITIAL_TRANSFER_PACKETS   1
 
#define MIN_WORKINGSET_TRANSFER_PACKETS_Client   16
 
#define MAX_WORKINGSET_TRANSFER_PACKETS_Client   32
 
#define MIN_WORKINGSET_TRANSFER_PACKETS_Server_UpperBound   256
 
#define MIN_WORKINGSET_TRANSFER_PACKETS_Server_LowerBound   32
 
#define MAX_WORKINGSET_TRANSFER_PACKETS_Server   1024
 
#define MIN_WORKINGSET_TRANSFER_PACKETS_SPACES   512
 
#define MAX_WORKINGSET_TRANSFER_PACKETS_SPACES   2048
 
#define MAX_OUTSTANDING_IO_PER_LUN_DEFAULT   16
 
#define MAX_CLEANUP_TRANSFER_PACKETS_AT_ONCE   8192
 
#define QERR_SET_ZERO_ODX_OR_TP_ONLY   0
 
#define QERR_SET_ZERO_ALWAYS   1
 
#define QERR_SET_ZERO_NEVER   2
 
#define MIN(a, b)   ((a) < (b) ? (a) : (b))
 
#define MAX(a, b)   ((a) > (b) ? (a) : (b))
 
#define NOT_READY_RETRY_INTERVAL   10
 
#define MINIMUM_RETRY_UNITS   ((LONGLONG)32)
 
#define MODE_PAGE_DATA_SIZE   192
 
#define CLASS_IDLE_INTERVAL_MIN   12
 
#define CLASS_IDLE_INTERVAL   12
 
#define CLASS_STARVATION_INTERVAL   500
 
#define FIFTY_MS_IN_100NS_UNITS   50 * 100
 
#define HISTORYINITIALIZERETRYLOGS(_packet)
 
#define HISTORYLOGSENDPACKET(_packet)
 
#define HISTORYLOGRETURNEDPACKET(_packet)
 
#define TRACKING_FORWARD_PROGRESS_PATH1   (0x00000001)
 
#define TRACKING_FORWARD_PROGRESS_PATH2   (0x00000002)
 
#define TRACKING_FORWARD_PROGRESS_PATH3   (0x00000004)
 

Typedefs

typedef struct _MEDIA_CHANGE_DETECTION_INFO MEDIA_CHANGE_DETECTION_INFO
 
typedef struct _MEDIA_CHANGE_DETECTION_INFOPMEDIA_CHANGE_DETECTION_INFO
 
typedef enum MEDIA_LOCK_TYPEPMEDIA_LOCK_TYPE
 
typedef struct _FAILURE_PREDICTION_INFO FAILURE_PREDICTION_INFO
 
typedef struct _FAILURE_PREDICTION_INFOPFAILURE_PREDICTION_INFO
 
typedef struct _CLASS_RETRY_INFO CLASS_RETRY_INFO
 
typedef struct _CLASS_RETRY_INFOPCLASS_RETRY_INFO
 
typedef struct _CSCAN_LIST CSCAN_LIST
 
typedef struct _CSCAN_LISTPCSCAN_LIST
 
typedef enum _CLASS_DETECTION_STATE CLASS_DETECTION_STATE
 
typedef enum _CLASS_DETECTION_STATEPCLASS_DETECTION_STATE
 
typedef struct _CLASS_ERROR_LOG_DATA CLASS_ERROR_LOG_DATA
 
typedef struct _CLASS_ERROR_LOG_DATAPCLASS_ERROR_LOG_DATA
 
typedef VOID(* PCONTINUATION_ROUTINE) (_In_ PVOID Context)
 
typedef struct _TRANSFER_PACKET TRANSFER_PACKET
 
typedef struct _TRANSFER_PACKETPTRANSFER_PACKET
 
typedef struct _PNL_SLIST_HEADER PNL_SLIST_HEADER
 
typedef struct _PNL_SLIST_HEADERPPNL_SLIST_HEADER
 
typedef struct _IDLE_POWER_FDO_LIST_ENTRY IDLE_POWER_FDO_LIST_ENTRY
 
typedef struct _IDLE_POWER_FDO_LIST_ENTRYPIDLE_POWER_FDO_LIST_ENTRY
 
typedef struct _OFFLOAD_READ_CONTEXT OFFLOAD_READ_CONTEXT
 
typedef struct _OFFLOAD_READ_CONTEXTPOFFLOAD_READ_CONTEXT
 
typedef struct _OFFLOAD_WRITE_CONTEXT OFFLOAD_WRITE_CONTEXT
 
typedef struct _OFFLOAD_WRITE_CONTEXTPOFFLOAD_WRITE_CONTEXT
 
typedef struct _OPCODE_SENSE_DATA_IO_LOG_MESSAGE_CONTEXT_HEADER OPCODE_SENSE_DATA_IO_LOG_MESSAGE_CONTEXT_HEADER
 
typedef struct _OPCODE_SENSE_DATA_IO_LOG_MESSAGE_CONTEXT_HEADERPOPCODE_SENSE_DATA_IO_LOG_MESSAGE_CONTEXT_HEADER
 
typedef struct _IO_RETRIED_LOG_MESSAGE_CONTEXT IO_RETRIED_LOG_MESSAGE_CONTEXT
 
typedef struct _IO_RETRIED_LOG_MESSAGE_CONTEXTPIO_RETRIED_LOG_MESSAGE_CONTEXT
 
typedef PVOID(* PSRB_ALLOCATE_ROUTINE) (_In_ CLONG ByteSize)
 

Enumerations

enum  MEDIA_LOCK_TYPE {
  SimpleMediaLock, SecureMediaLock, InternalMediaLock, SimpleMediaLock,
  SecureMediaLock, InternalMediaLock
}
 
enum  _CLASS_DETECTION_STATE { ClassDetectionUnknown = 0, ClassDetectionUnsupported = 1, ClassDetectionSupported = 2 }
 

Functions

 C_ASSERT ((sizeof(struct _CLASS_PRIVATE_COMMON_DATA) % sizeof(PVOID))==0)
 
__inline VOID SimpleInitSlistHdr (SINGLE_LIST_ENTRY *SListHdr)
 
__inline VOID SimplePushSlist (SINGLE_LIST_ENTRY *SListHdr, SINGLE_LIST_ENTRY *SListEntry)
 
__inline SINGLE_LIST_ENTRYSimplePopSlist (SINGLE_LIST_ENTRY *SListHdr)
 
__inline BOOLEAN SimpleIsSlistEmpty (SINGLE_LIST_ENTRY *SListHdr)
 
__inline BOOLEAN ClasspIsIdleRequestSupported (PCLASS_PRIVATE_FDO_DATA FdoData, PIRP Irp)
 
__inline VOID ClasspMarkIrpAsIdle (PIRP Irp, BOOLEAN Idle)
 
__inline BOOLEAN ClasspIsIdleRequest (PIRP Irp)
 
__inline LARGE_INTEGER ClasspGetCurrentTime (VOID)
 
__inline ULONGLONG ClasspTimeDiffToMs (ULONGLONG TimeDiff)
 
__inline BOOLEAN ClasspSupportsUnmap (_In_ PCLASS_FUNCTION_SUPPORT_INFO SupportInfo)
 
__inline BOOLEAN ClasspIsThinProvisioned (_In_ PCLASS_FUNCTION_SUPPORT_INFO SupportInfo)
 
__inline BOOLEAN ClasspIsObsoletePortDriver (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
ULONG ClasspCalculateLogicalSectorSize (_In_ PDEVICE_OBJECT Fdo, _In_ ULONG BytesPerBlockInBigEndian)
 
 _Dispatch_type_ (IRP_MJ_CREATE) _Dispatch_type_(IRP_MJ_CLOSE) DRIVER_DISPATCH ClassCreateClose
 
NTSTATUS ClasspCreateClose (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
VOID ClasspCleanupProtectedLocks (IN PFILE_OBJECT_EXTENSION FsContext)
 
NTSTATUS ClasspEjectionControl (IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN MEDIA_LOCK_TYPE LockType, IN BOOLEAN Lock)
 
 _Dispatch_type_ (IRP_MJ_READ) _Dispatch_type_(IRP_MJ_WRITE) DRIVER_DISPATCH ClassReadWrite
 
 _Dispatch_type_ (IRP_MJ_DEVICE_CONTROL) DRIVER_DISPATCH ClassDeviceControlDispatch
 
 _Dispatch_type_ (IRP_MJ_PNP) DRIVER_DISPATCH ClassDispatchPnp
 
NTSTATUS ClassPnpStartDevice (IN PDEVICE_OBJECT DeviceObject)
 
 _Dispatch_type_ (IRP_MJ_SHUTDOWN) _Dispatch_type_(IRP_MJ_FLUSH_BUFFERS) DRIVER_DISPATCH ClassShutdownFlush
 
 _Dispatch_type_ (IRP_MJ_SYSTEM_CONTROL) DRIVER_DISPATCH ClassSystemControl
 
VOID RetryRequest (PDEVICE_OBJECT DeviceObject, PIRP Irp, PSCSI_REQUEST_BLOCK Srb, BOOLEAN Associated, LONGLONG TimeDelta100ns)
 
NTSTATUS ClassIoCompletion (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
 
NTSTATUS ClassPnpQueryFdoRelations (IN PDEVICE_OBJECT Fdo, IN PIRP Irp)
 
NTSTATUS ClassRetrieveDeviceRelations (IN PDEVICE_OBJECT Fdo, IN DEVICE_RELATION_TYPE RelationType, OUT PDEVICE_RELATIONS *DeviceRelations)
 
NTSTATUS ClassGetPdoId (IN PDEVICE_OBJECT Pdo, IN BUS_QUERY_ID_TYPE IdType, IN PUNICODE_STRING IdString)
 
NTSTATUS ClassQueryPnpCapabilities (IN PDEVICE_OBJECT PhysicalDeviceObject, IN PDEVICE_CAPABILITIES Capabilities)
 
NTSTATUS ClasspPagingNotificationCompletion (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PDEVICE_OBJECT RealDeviceObject)
 
NTSTATUS ClasspMediaChangeCompletion (PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
 
NTSTATUS ClasspMcnControl (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PIRP Irp, IN PSCSI_REQUEST_BLOCK Srb)
 
VOID ClasspRegisterMountedDeviceInterface (IN PDEVICE_OBJECT DeviceObject)
 
VOID ClasspDisableTimer (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
VOID ClasspEnableTimer (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
NTSTATUS ClasspInitializeTimer (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
VOID ClasspDeleteTimer (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
BOOLEAN ClasspUpdateTimerNoWakeTolerance (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
NTSTATUS ClasspDuidQueryProperty (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
VOID ClassInitializeDispatchTables (PCLASS_DRIVER_EXTENSION DriverExtension)
 
NTSTATUS ClasspPersistentReserve (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
 
VOID InitializeDictionary (IN PDICTIONARY Dictionary)
 
BOOLEAN TestDictionarySignature (IN PDICTIONARY Dictionary)
 
NTSTATUS AllocateDictionaryEntry (IN PDICTIONARY Dictionary, IN ULONGLONG Key, IN ULONG Size, IN ULONG Tag, OUT PVOID *Entry)
 
PVOID GetDictionaryEntry (IN PDICTIONARY Dictionary, IN ULONGLONG Key)
 
VOID FreeDictionaryEntry (IN PDICTIONARY Dictionary, IN PVOID Entry)
 
NTSTATUS ClasspAllocateReleaseRequest (IN PDEVICE_OBJECT Fdo)
 
VOID ClasspFreeReleaseRequest (IN PDEVICE_OBJECT Fdo)
 
VOID ClasspReleaseQueue (IN PDEVICE_OBJECT DeviceObject, IN PIRP ReleaseQueueIrp)
 
VOID ClasspDisablePowerNotification (PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
 _Dispatch_type_ (IRP_MJ_POWER) DRIVER_DISPATCH ClassDispatchPower
 
NTSTATUS NTAPI ClassMinimalPowerHandler (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
_IRQL_requires_same_ NTSTATUS ClasspEnableIdlePower (_In_ PDEVICE_OBJECT DeviceObject)
 
VOID ClassAddChild (_In_ PFUNCTIONAL_DEVICE_EXTENSION Parent, _In_ PPHYSICAL_DEVICE_EXTENSION Child, _In_ BOOLEAN AcquireLock)
 
PPHYSICAL_DEVICE_EXTENSION ClassRemoveChild (IN PFUNCTIONAL_DEVICE_EXTENSION Parent, IN PPHYSICAL_DEVICE_EXTENSION Child, IN BOOLEAN AcquireLock)
 
VOID ClasspRetryDpcTimer (IN PCLASS_PRIVATE_FDO_DATA FdoData)
 
VOID ClassFreeOrReuseSrb (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN __drv_freesMem(mem) PSCSI_REQUEST_BLOCK Srb)
 
VOID ClassRetryRequest (IN PDEVICE_OBJECT SelfDeviceObject, IN PIRP Irp, _In_ _In_range_(0, MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS) IN LONGLONG TimeDelta100ns)
 
VOID ClasspBuildRequestEx (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _In_ PIRP Irp, _In_ __drv_aliasesMem PSCSI_REQUEST_BLOCK Srb)
 
NTSTATUS ClasspAllocateReleaseQueueIrp (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
NTSTATUS ClasspAllocatePowerProcessIrp (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
NTSTATUS ClasspInitializeGesn (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PMEDIA_CHANGE_DETECTION_INFO Info)
 
VOID ClassSendEjectionNotification (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
VOID ClasspScanForSpecialInRegistry (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
VOID NTAPI ClasspScanForClassHacks (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN ULONG_PTR Data)
 
NTSTATUS ClasspInitializeHotplugInfo (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
VOID ClasspPerfIncrementErrorCount (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
VOID ClasspPerfIncrementSuccessfulIo (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
 __drv_allocatesMem (Mem) PTRANSFER_PACKET NewTransferPacket(PDEVICE_OBJECT Fdo)
 
VOID DestroyTransferPacket (_In_ __drv_freesMem(mem) PTRANSFER_PACKET Pkt)
 
VOID EnqueueFreeTransferPacket (PDEVICE_OBJECT Fdo, __drv_aliasesMem PTRANSFER_PACKET Pkt)
 
PTRANSFER_PACKET DequeueFreeTransferPacket (PDEVICE_OBJECT Fdo, BOOLEAN AllocIfNeeded)
 
PTRANSFER_PACKET DequeueFreeTransferPacketEx (_In_ PDEVICE_OBJECT Fdo, _In_ BOOLEAN AllocIfNeeded, _In_ ULONG Node)
 
VOID SetupReadWriteTransferPacket (PTRANSFER_PACKET pkt, PVOID Buf, ULONG Len, LARGE_INTEGER DiskLocation, PIRP OriginalIrp)
 
NTSTATUS SubmitTransferPacket (PTRANSFER_PACKET Pkt)
 
NTSTATUS ServiceTransferRequest (PDEVICE_OBJECT Fdo, PIRP Irp, BOOLEAN PostToDpc)
 
VOID TransferPacketQueueRetryDpc (PTRANSFER_PACKET Pkt)
 
BOOLEAN InterpretTransferPacketError (PTRANSFER_PACKET Pkt)
 
BOOLEAN RetryTransferPacket (PTRANSFER_PACKET Pkt)
 
VOID EnqueueDeferredClientIrp (PDEVICE_OBJECT Fdo, PIRP Irp)
 
PIRP DequeueDeferredClientIrp (PDEVICE_OBJECT Fdo)
 
VOID InitLowMemRetry (PTRANSFER_PACKET Pkt, PVOID BufPtr, ULONG Len, LARGE_INTEGER TargetLocation)
 
BOOLEAN StepLowMemRetry (PTRANSFER_PACKET Pkt)
 
VOID SetupEjectionTransferPacket (TRANSFER_PACKET *Pkt, BOOLEAN PreventMediaRemoval, PKEVENT SyncEventPtr, PIRP OriginalIrp)
 
VOID SetupModeSenseTransferPacket (TRANSFER_PACKET *Pkt, PKEVENT SyncEventPtr, PVOID ModeSenseBuffer, UCHAR ModeSenseBufferLen, UCHAR PageMode, UCHAR SubPage, PIRP OriginalIrp, UCHAR PageControl)
 
VOID SetupModeSelectTransferPacket (TRANSFER_PACKET *Pkt, PKEVENT SyncEventPtr, PVOID ModeSelectBuffer, UCHAR ModeSelectBufferLen, BOOLEAN SavePages, PIRP OriginalIrp)
 
VOID SetupDriveCapacityTransferPacket (TRANSFER_PACKET *Pkt, PVOID ReadCapacityBuffer, ULONG ReadCapacityBufferLen, PKEVENT SyncEventPtr, PIRP OriginalIrp, BOOLEAN Use16ByteCdb)
 
PMDL BuildDeviceInputMdl (PVOID Buffer, ULONG BufferLen)
 
PMDL ClasspBuildDeviceMdl (PVOID Buffer, ULONG BufferLen, BOOLEAN WriteToDevice)
 
VOID FreeDeviceInputMdl (PMDL Mdl)
 
VOID ClasspFreeDeviceMdl (PMDL Mdl)
 
NTSTATUS InitializeTransferPackets (PDEVICE_OBJECT Fdo)
 
VOID DestroyAllTransferPackets (PDEVICE_OBJECT Fdo)
 
VOID InterpretCapacityData (PDEVICE_OBJECT Fdo, PREAD_CAPACITY_DATA_EX ReadCapacityData)
 
VOID CleanupTransferPacketToWorkingSetSize (_In_ PDEVICE_OBJECT Fdo, _In_ BOOLEAN LimitNumPktToDelete, _In_ ULONG Node)
 
 _IRQL_requires_max_ (APC_LEVEL) _IRQL_requires_min_(PASSIVE_LEVEL) _IRQL_requires_same_ VOID ClasspSetupPopulateTokenTransferPacket(_In_ __drv_aliasesMem POFFLOAD_READ_CONTEXT OffloadReadContext
 
_In_ PTRANSFER_PACKET _In_ ULONG _In_reads_bytes_ (Length) PUCHAR PopulateTokenBuffer
 
ULONG ClasspModeSense (_In_ PDEVICE_OBJECT Fdo, _In_reads_bytes_(Length) PCHAR ModeSenseBuffer, _In_ ULONG Length, _In_ UCHAR PageMode, _In_ UCHAR PageControl)
 
NTSTATUS ClasspModeSelect (_In_ PDEVICE_OBJECT Fdo, _In_reads_bytes_(Length) PCHAR ModeSelectBuffer, _In_ ULONG Length, _In_ BOOLEAN SavePages)
 
NTSTATUS ClasspWriteCacheProperty (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
 
NTSTATUS ClasspAccessAlignmentProperty (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
 
NTSTATUS ClasspDeviceSeekPenaltyProperty (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
 
NTSTATUS ClasspDeviceGetLBProvisioningVPDPage (_In_ PDEVICE_OBJECT DeviceObject, _Inout_opt_ PSCSI_REQUEST_BLOCK Srb)
 
NTSTATUS ClasspDeviceGetBlockDeviceCharacteristicsVPDPage (_In_ PFUNCTIONAL_DEVICE_EXTENSION fdoExtension, _In_ PSCSI_REQUEST_BLOCK Srb)
 
NTSTATUS ClasspDeviceGetBlockLimitsVPDPage (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _Inout_bytecount_(SrbSize) PSCSI_REQUEST_BLOCK Srb, _In_ ULONG SrbSize, _Out_ PCLASS_VPD_B0_DATA BlockLimitsData)
 
NTSTATUS ClasspDeviceTrimProperty (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
 
NTSTATUS ClasspDeviceLBProvisioningProperty (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
 
NTSTATUS ClasspDeviceTrimProcess (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ PGUID ActivityId, _Inout_ PSCSI_REQUEST_BLOCK Srb)
 
NTSTATUS ClasspDeviceGetLBAStatus (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
 
NTSTATUS ClasspDeviceGetLBAStatusWorker (_In_ PDEVICE_OBJECT DeviceObject, _In_ PCLASS_VPD_B0_DATA BlockLimitsData, _In_ ULONGLONG StartingOffset, _In_ ULONGLONG LengthInBytes, _Out_ PDEVICE_MANAGE_DATA_SET_ATTRIBUTES_OUTPUT DsmOutput, _Inout_ PULONG DsmOutputLength, _Inout_ PSCSI_REQUEST_BLOCK Srb, _In_ BOOLEAN ConsolidateableBlocksOnly, _In_ ULONG OutputVersion, _Out_ PBOOLEAN BlockLimitsDataMayHaveChanged)
 
VOID ClassQueueThresholdEventWorker (_In_ PDEVICE_OBJECT DeviceObject)
 
VOID ClassQueueResourceExhaustionEventWorker (_In_ PDEVICE_OBJECT DeviceObject)
 
VOID ClassQueueCapacityChangedEventWorker (_In_ PDEVICE_OBJECT DeviceObject)
 
VOID ClassQueueProvisioningTypeChangedEventWorker (_In_ PDEVICE_OBJECT DeviceObject)
 
VOID ClasspQueueLogIOEventWithContextWorker (_In_ PDEVICE_OBJECT DeviceObject, _In_ ULONG SenseBufferSize, _In_ PVOID SenseData, _In_ UCHAR SrbStatus, _In_ UCHAR ScsiStatus, _In_ ULONG ErrorCode, _In_ ULONG CdbLength, _In_opt_ PCDB Cdb, _In_opt_ PTRANSFER_PACKET Pkt)
 
VOID ClasspZeroQERR (_In_ PDEVICE_OBJECT DeviceObject)
 
 _IRQL_requires_max_ (PASSIVE_LEVEL) NTSTATUS ClasspGetMaximumTokenListIdentifier(_In_ PDEVICE_OBJECT DeviceObject
 
_IRQL_requires_same_ NTSTATUS ClasspGetTokenOperationCommandBufferLength (_In_ PDEVICE_OBJECT Fdo, _In_ ULONG ServiceAction, _Inout_ PULONG CommandBufferLength, _Out_opt_ PULONG TokenOperationBufferLength, _Out_opt_ PULONG ReceiveTokenInformationBufferLength)
 
_IRQL_requires_same_ NTSTATUS ClasspGetTokenOperationDescriptorLimits (_In_ PDEVICE_OBJECT Fdo, _In_ ULONG ServiceAction, _In_ ULONG MaxParameterBufferLength, _Out_ PULONG MaxBlockDescriptorsCount, _Out_ PULONGLONG MaxBlockDescriptorsLength)
 
NTSTATUS ClasspDeviceMediaTypeProperty (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
 
_IRQL_requires_same_ PUCHAR ClasspBinaryToAscii (_In_reads_(Length) PUCHAR HexBuffer, _In_ ULONG Length, _Inout_ PULONG UpdateLength)
 
__inline BOOLEAN ClasspIsTokenOperationComplete (_In_ ULONG CurrentStatus)
 
__inline BOOLEAN ClasspIsTokenOperation (_In_ PCDB Cdb)
 
__inline BOOLEAN ClasspIsReceiveTokenInformation (_In_ PCDB Cdb)
 
__inline BOOLEAN ClasspIsOffloadDataTransferCommand (_In_ PCDB Cdb)
 
VOID ClasspInitializeIdleTimer (PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
NTSTATUS ClasspIsPortable (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _Out_ PBOOLEAN IsPortable)
 
VOID ClasspGetInquiryVpdSupportInfo (_Inout_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
NTSTATUS ClasspGetLBProvisioningInfo (_Inout_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
 _IRQL_requires_ (PASSIVE_LEVEL) _IRQL_requires_same_ NTSTATUS ClassDetermineTokenOperationCommandSupport(_In_ PDEVICE_OBJECT DeviceObject)
 
_IRQL_requires_same_ NTSTATUS ClasspGetBlockDeviceTokenLimitsInfo (_Inout_ PDEVICE_OBJECT DeviceObject)
 
_IRQL_requires_same_ VOID ClasspReceivePopulateTokenInformation (_In_ POFFLOAD_READ_CONTEXT OffloadReadContext)
 
_IRQL_requires_same_ VOID ClasspReceiveWriteUsingTokenInformation (_In_ POFFLOAD_WRITE_CONTEXT OffloadWriteContext)
 
VOID ClasspCompleteOffloadRequest (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ NTSTATUS CompletionStatus)
 
VOID ClasspCleanupOffloadReadContext (_In_ __drv_freesMem(mem) POFFLOAD_READ_CONTEXT OffloadReadContext)
 
VOID ClasspCompleteOffloadRead (_In_ POFFLOAD_READ_CONTEXT OffloadReadContext, _In_ NTSTATUS CompletionStatus)
 
VOID ClasspPopulateTokenTransferPacketDone (_In_ PVOID Context)
 
VOID ClasspReceivePopulateTokenInformationTransferPacketDone (_In_ PVOID Context)
 
VOID ClasspContinueOffloadWrite (_In_ __drv_aliasesMem POFFLOAD_WRITE_CONTEXT OffloadWriteContext)
 
VOID ClasspCleanupOffloadWriteContext (_In_ __drv_freesMem(mem) POFFLOAD_WRITE_CONTEXT OffloadWriteContext)
 
VOID ClasspCompleteOffloadWrite (_In_ __drv_freesMem(Mem) POFFLOAD_WRITE_CONTEXT OffloadWriteContext, _In_ NTSTATUS CompletionCausingStatus)
 
VOID ClasspReceiveWriteUsingTokenInformationDone (_In_ POFFLOAD_WRITE_CONTEXT OffloadWriteContext, _In_ NTSTATUS CompletionCausingStatus)
 
VOID ClasspWriteUsingTokenTransferPacketDone (_In_ PVOID Context)
 
VOID ClasspReceiveWriteUsingTokenInformationTransferPacketDone (_In_ POFFLOAD_WRITE_CONTEXT OffloadWriteContext)
 
NTSTATUS ClasspRefreshFunctionSupportInfo (_Inout_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _In_ BOOLEAN ForceQuery)
 
NTSTATUS ClasspBlockLimitsDataSnapshot (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _In_ BOOLEAN ForceQuery, _Out_ PCLASS_VPD_B0_DATA BlockLimitsData, _Out_ PULONG GenerationCount)
 
NTSTATUS InterpretReadCapacity16Data (_Inout_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _In_ PREAD_CAPACITY16_DATA ReadCapacity16Data)
 
NTSTATUS ClassReadCapacity16 (_Inout_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _Inout_ PSCSI_REQUEST_BLOCK Srb)
 
NTSTATUS ClassDeviceGetLBProvisioningResources (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
 
_IRQL_requires_same_ NTSTATUS ClasspStorageEventNotification (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
 
NTSTATUS ClasspLogSystemEventWithDeviceNumber (_In_ PDEVICE_OBJECT DeviceObject, _In_ NTSTATUS IoErrorCode)
 
NTSTATUS ClasspEnqueueIdleRequest (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
VOID ClasspCompleteIdleRequest (PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
NTSTATUS ClasspPriorityHint (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
VOID HistoryInitializeRetryLogs (_Out_ PSRB_HISTORY History, ULONG HistoryCount)
 
VOID HistoryLogSendPacket (TRANSFER_PACKET *Pkt)
 
VOID HistoryLogReturnedPacket (TRANSFER_PACKET *Pkt)
 
BOOLEAN InterpretSenseInfoWithoutHistory (_In_ PDEVICE_OBJECT Fdo, _In_opt_ PIRP OriginalRequest, _In_ PSCSI_REQUEST_BLOCK Srb, UCHAR MajorFunctionCode, ULONG IoDeviceCode, ULONG PreviousRetryCount, _Out_ NTSTATUS *Status, _Out_opt_ _Deref_out_range_(0, MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS) LONGLONG *RetryIn100nsUnits)
 
BOOLEAN ClasspMyStringMatches (_In_opt_z_ PCHAR StringToMatch, _In_z_ PCHAR TargetString)
 
VOID ClasspInitializeRemoveTracking (_In_ PDEVICE_OBJECT DeviceObject)
 
VOID ClasspUninitializeRemoveTracking (_In_ PDEVICE_OBJECT DeviceObject)
 
PVOID DefaultStorageRequestBlockAllocateRoutine (_In_ CLONG ByteSize)
 
NTSTATUS CreateStorageRequestBlock (_Inout_ PSTORAGE_REQUEST_BLOCK *Srb, _In_ USHORT AddressType, _In_opt_ PSRB_ALLOCATE_ROUTINE AllocateRoutine, _Inout_opt_ ULONG *ByteSize, _In_ ULONG NumSrbExData,...)
 
NTSTATUS InitializeStorageRequestBlock (_Inout_bytecount_(ByteSize) PSTORAGE_REQUEST_BLOCK Srb, _In_ USHORT AddressType, _In_ ULONG ByteSize, _In_ ULONG NumSrbExData,...)
 
VOID ClasspConvertToScsiRequestBlock (_Out_ PSCSI_REQUEST_BLOCK Srb, _In_ PSTORAGE_REQUEST_BLOCK SrbEx)
 
__inline PCDB ClasspTransferPacketGetCdb (_In_ PTRANSFER_PACKET Pkt)
 
__inline BOOLEAN ClasspTransferPacketGetNumberOfRetriesDone (_In_ PTRANSFER_PACKET Pkt, _In_ PCDB Cdb, _Out_ PULONG TimesAlreadyRetried)
 
__inline PVOID ClasspTransferPacketGetSenseInfoBuffer (_In_ PTRANSFER_PACKET Pkt)
 
__inline UCHAR ClasspTransferPacketGetSenseInfoBufferLength (_In_ PTRANSFER_PACKET Pkt)
 
__inline VOID ClasspSrbSetOriginalIrp (_In_ PSTORAGE_REQUEST_BLOCK_HEADER Srb, _In_ PIRP Irp)
 
__inline BOOLEAN PORT_ALLOCATED_SENSE_EX (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _In_ PSTORAGE_REQUEST_BLOCK_HEADER Srb)
 
__inline VOID FREE_PORT_ALLOCATED_SENSE_BUFFER_EX (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _In_ PSTORAGE_REQUEST_BLOCK_HEADER Srb)
 
BOOLEAN ClasspFailurePredictionPeriodMissed (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
__inline ULONG ClasspGetMaxUsableBufferLengthFromOffset (_In_ PVOID BaseAddress, _In_ ULONG OffsetInBytes, _In_ ULONG BaseStructureSizeInBytes)
 
BOOLEAN ClasspIsThinProvisioningError (_In_ PSCSI_REQUEST_BLOCK _Srb)
 
__inline BOOLEAN ClasspLowerLayerNotSupport (_In_ NTSTATUS Status)
 
NTSTATUS ClassDeviceHwFirmwareGetInfoProcess (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
 
NTSTATUS ClassDeviceHwFirmwareDownloadProcess (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
 
NTSTATUS ClassDeviceHwFirmwareActivateProcess (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
 

Variables

CLASSPNP_SCAN_FOR_SPECIAL_INFO ClassBadItems []
 
GUID ClassGuidQueryRegInfoEx
 
GUID ClassGuidSenseInfo2
 
GUID ClassGuidWorkingSet
 
GUID ClassGuidSrbSupport
 
ULONG ClassMaxInterleavePerCriticalIo
 
ULONG MaxTokenOperationListIdentifier
 
volatile ULONG TokenOperationListIdentifier
 
LIST_ENTRY IdlePowerFDOList
 
PVOID PowerSettingNotificationHandle
 
PVOID ScreenStateNotificationHandle
 
BOOLEAN ClasspScreenOff
 
KGUARDED_MUTEX IdlePowerFDOListMutex
 
ULONG DiskIdleTimeoutInMS
 
CONST LARGE_INTEGER Magic10000
 
DRIVER_INITIALIZE DriverEntry
 
DRIVER_UNLOAD ClassUnload
 
DRIVER_ADD_DEVICE ClassAddDevice
 
IO_COMPLETION_ROUTINE ClasspSendSynchronousCompletion
 
DRIVER_STARTIO ClasspStartIo
 
IO_COMPLETION_ROUTINE ClassReleaseQueueCompletion
 
POWER_SETTING_CALLBACK ClasspPowerSettingCallback
 
KDEFERRED_ROUTINE ClasspRetryRequestDpc
 
IO_WORKITEM_ROUTINE ClasspUpdateDiskProperties
 
IO_COMPLETION_ROUTINE TransferPktComplete
 
KDEFERRED_ROUTINE TransferPacketRetryTimerDpc
 
IO_WORKITEM_ROUTINE_EX CleanupTransferPacketToWorkingSetSizeWorker
 
_In_ PTRANSFER_PACKET Pkt
 
_In_ PTRANSFER_PACKET _In_ ULONG Length
 
_In_ PTRANSFER_PACKET _In_ ULONG _In_ PIRP OriginalIrp
 
_In_ PTRANSFER_PACKET _In_ ULONG _In_ PIRP _In_ ULONG ListIdentifier
 
IO_WORKITEM_ROUTINE ClasspLogIOEventWithContext
 
_In_z_ PWSTR RegistryPath
 
_In_z_ PWSTR _Out_ PULONG MaximumListIdentifier
 
_In_z_ PWSTR _Out_ PULONG MaxDuration
 
_Inout_ PIRP Irp
 
_Inout_ PIRP _Inout_ PSCSI_REQUEST_BLOCK Srb
 
_In_ PVOID BlockDescr
 
_In_ PVOID _Inout_ PULONG CurrentBlockDescrIndex
 
_In_ PVOID _Inout_ PULONG _In_ ULONG MaxBlockDescrCount
 
_In_ PVOID _Inout_ PULONG _In_ ULONG _Inout_ PULONG CurrentLbaCount
 
_In_ PVOID _Inout_ PULONG _In_ ULONG _Inout_ PULONG _In_ ULONGLONG MaxLbaCount
 
_In_ PVOID _Inout_ PULONG _In_ ULONG _Inout_ PULONG _In_ ULONGLONG _Inout_ PDEVICE_DATA_SET_RANGE DataSetRange
 
_In_ PVOID _Inout_ PULONG _In_ ULONG _Inout_ PULONG _In_ ULONGLONG _Inout_ PDEVICE_DATA_SET_RANGE _Inout_ PULONGLONG TotalSectorsProcessed
 
LIST_ENTRY AllFdosList
 
IO_WORKITEM_ROUTINE ClassLogThresholdEvent
 
IO_WORKITEM_ROUTINE ClassLogResourceExhaustionEvent
 
RTL_GENERIC_COMPARE_ROUTINE RemoveTrackingCompareRoutine
 
RTL_GENERIC_ALLOCATE_ROUTINE RemoveTrackingAllocateRoutine
 
RTL_GENERIC_FREE_ROUTINE RemoveTrackingFreeRoutine
 

Macro Definition Documentation

◆ Add2Ptr

#define Add2Ptr (   P,
  I 
)    ((PVOID)((PUCHAR)(P) + (I)))

Definition at line 110 of file classp.h.

◆ CLASS_ERROR_LEVEL_1

#define CLASS_ERROR_LEVEL_1   (0x4)

Definition at line 131 of file classp.h.

◆ CLASS_ERROR_LEVEL_2

#define CLASS_ERROR_LEVEL_2   (0x8)

Definition at line 132 of file classp.h.

◆ CLASS_FILE_OBJECT_EXTENSION_KEY

#define CLASS_FILE_OBJECT_EXTENSION_KEY   'eteP'

Definition at line 186 of file classp.h.

◆ CLASS_IDLE_INTERVAL

#define CLASS_IDLE_INTERVAL   12

Definition at line 1199 of file classp.h.

◆ CLASS_IDLE_INTERVAL_MIN

#define CLASS_IDLE_INTERVAL_MIN   12

Definition at line 1198 of file classp.h.

◆ CLASS_MAX_INTERLEAVE_PER_CRITICAL_IO

#define CLASS_MAX_INTERLEAVE_PER_CRITICAL_IO   (0x4)

Definition at line 133 of file classp.h.

◆ CLASS_PERF_RESTORE_MINIMUM

#define CLASS_PERF_RESTORE_MINIMUM   (0x10)

Definition at line 130 of file classp.h.

◆ CLASS_STARVATION_INTERVAL

#define CLASS_STARVATION_INTERVAL   500

Definition at line 1200 of file classp.h.

◆ CLASS_TAG_PRIVATE_DATA

#define CLASS_TAG_PRIVATE_DATA   'CPcS'

Definition at line 189 of file classp.h.

◆ CLASS_TAG_SENSE2

#define CLASS_TAG_SENSE2   '2ScS'

Definition at line 190 of file classp.h.

◆ CLASS_TAG_WORKING_SET

#define CLASS_TAG_WORKING_SET   'sWcS'

Definition at line 191 of file classp.h.

◆ CLASSP_REG_ACCESS_ALIGNMENT_NOT_SUPPORTED

#define CLASSP_REG_ACCESS_ALIGNMENT_NOT_SUPPORTED   (L"AccessAlignmentQueryNotSupported")

Definition at line 122 of file classp.h.

◆ CLASSP_REG_COPY_OFFLOAD_MAX_TARGET_DURATION

#define CLASSP_REG_COPY_OFFLOAD_MAX_TARGET_DURATION   (L"CopyOffloadMaxTargetDuration")

Definition at line 128 of file classp.h.

◆ CLASSP_REG_DISABLE_D3COLD

#define CLASSP_REG_DISABLE_D3COLD   (L"DisableD3Cold")

Definition at line 125 of file classp.h.

◆ CLASSP_REG_DISBALE_IDLE_POWER_NAME

#define CLASSP_REG_DISBALE_IDLE_POWER_NAME   (L"DisableIdlePowerManagement")

Definition at line 123 of file classp.h.

◆ CLASSP_REG_HACK_VALUE_NAME

#define CLASSP_REG_HACK_VALUE_NAME   (L"HackMask")

Definition at line 114 of file classp.h.

◆ CLASSP_REG_IDLE_ACTIVE_MAX

#define CLASSP_REG_IDLE_ACTIVE_MAX   (L"IdleOutstandingIoMax")

Definition at line 120 of file classp.h.

◆ CLASSP_REG_IDLE_INTERVAL_NAME

#define CLASSP_REG_IDLE_INTERVAL_NAME   (L"IdleInterval")

Definition at line 119 of file classp.h.

◆ CLASSP_REG_IDLE_PRIORITY_SUPPORTED

#define CLASSP_REG_IDLE_PRIORITY_SUPPORTED   (L"IdlePrioritySupported")

Definition at line 121 of file classp.h.

◆ CLASSP_REG_IDLE_TIMEOUT_IN_SECONDS

#define CLASSP_REG_IDLE_TIMEOUT_IN_SECONDS   (L"IdleTimeoutInSeconds")

Definition at line 124 of file classp.h.

◆ CLASSP_REG_LEGACY_ERROR_HANDLING

#define CLASSP_REG_LEGACY_ERROR_HANDLING   (L"LegacyErrorHandling")

Definition at line 127 of file classp.h.

◆ CLASSP_REG_MMC_DETECTION_VALUE_NAME

#define CLASSP_REG_MMC_DETECTION_VALUE_NAME   (L"MMCDetectionState")

Definition at line 115 of file classp.h.

◆ CLASSP_REG_PERF_RESTORE_VALUE_NAME

#define CLASSP_REG_PERF_RESTORE_VALUE_NAME   (L"RestorePerfAtCount")

Definition at line 117 of file classp.h.

◆ CLASSP_REG_QERR_OVERRIDE_MODE

#define CLASSP_REG_QERR_OVERRIDE_MODE   (L"QERROverrideMode")

Definition at line 126 of file classp.h.

◆ CLASSP_REG_REMOVAL_POLICY_VALUE_NAME

#define CLASSP_REG_REMOVAL_POLICY_VALUE_NAME   (L"UserRemovalPolicy")

Definition at line 118 of file classp.h.

◆ CLASSP_REG_SUBKEY_NAME

#define CLASSP_REG_SUBKEY_NAME   (L"Classpnp")

Definition at line 112 of file classp.h.

◆ CLASSP_REG_WRITE_CACHE_VALUE_NAME

#define CLASSP_REG_WRITE_CACHE_VALUE_NAME   (L"WriteCacheEnableOverride")

Definition at line 116 of file classp.h.

◆ CLASSP_VOLUME_VERIFY_CHECKED

#define CLASSP_VOLUME_VERIFY_CHECKED   0x34

Definition at line 187 of file classp.h.

◆ CLASSPNP_POOL_TAG_ADDITIONAL_DATA

#define CLASSPNP_POOL_TAG_ADDITIONAL_DATA   'DAcS'

Definition at line 197 of file classp.h.

◆ CLASSPNP_POOL_TAG_FIRMWARE

#define CLASSPNP_POOL_TAG_FIRMWARE   'wFcS'

Definition at line 198 of file classp.h.

◆ CLASSPNP_POOL_TAG_GENERIC

#define CLASSPNP_POOL_TAG_GENERIC   'pCcS'

Definition at line 192 of file classp.h.

◆ CLASSPNP_POOL_TAG_LOG_MESSAGE

#define CLASSPNP_POOL_TAG_LOG_MESSAGE   'mlcS'

Definition at line 196 of file classp.h.

◆ CLASSPNP_POOL_TAG_SRB

#define CLASSPNP_POOL_TAG_SRB   'rScS'

Definition at line 194 of file classp.h.

◆ CLASSPNP_POOL_TAG_TOKEN_OPERATION

#define CLASSPNP_POOL_TAG_TOKEN_OPERATION   'oTcS'

Definition at line 193 of file classp.h.

◆ CLASSPNP_POOL_TAG_VPD

#define CLASSPNP_POOL_TAG_VPD   'pVcS'

Definition at line 195 of file classp.h.

◆ CONST_MSECS_PER_SEC

#define CONST_MSECS_PER_SEC   1000

Definition at line 251 of file classp.h.

◆ Convert100nsToMilliseconds

#define Convert100nsToMilliseconds (   LARGE_INTEGER)
Value:
( \
RtlExtendedMagicDivide((LARGE_INTEGER), Magic10000, SHIFT10000) \
)
#define SHIFT10000
Definition: classp.h:246
CONST LARGE_INTEGER Magic10000
Definition: class.c:89

Definition at line 253 of file classp.h.

◆ ConvertMillisecondsTo100ns

#define ConvertMillisecondsTo100ns (   MILLISECONDS)
Value:
( \
RtlExtendedIntegerMultiply ((MILLISECONDS), 10000) \
)
#define MILLISECONDS(milli)
Definition: nfs41_driver.c:116

Definition at line 258 of file classp.h.

◆ DBG_NUM_PACKET_LOG_ENTRIES

#define DBG_NUM_PACKET_LOG_ENTRIES   (64*2)

Definition at line 487 of file classp.h.

◆ DEBUG_COMP_ID

#define DEBUG_COMP_ID   DPFLTR_CLASSPNP_ID

Definition at line 78 of file classp.h.

◆ DEFAULT_MAX_NUMBER_BYTES_PER_SYNC_WRITE_USING_TOKEN

#define DEFAULT_MAX_NUMBER_BYTES_PER_SYNC_WRITE_USING_TOKEN   (64ULL * 1024 * 1024)

Definition at line 212 of file classp.h.

◆ DEFAULT_MAX_TARGET_DURATION

#define DEFAULT_MAX_TARGET_DURATION   4

Definition at line 211 of file classp.h.

◆ FDO_HACK_CANNOT_LOCK_MEDIA

#define FDO_HACK_CANNOT_LOCK_MEDIA   (0x00000001)

Definition at line 135 of file classp.h.

◆ FDO_HACK_GESN_IGNORE_OPCHANGE

#define FDO_HACK_GESN_IGNORE_OPCHANGE   (0x00000010)

Definition at line 139 of file classp.h.

◆ FDO_HACK_GESN_IS_BAD

#define FDO_HACK_GESN_IS_BAD   (0x00000002)

Definition at line 136 of file classp.h.

◆ FDO_HACK_INVALID_FLAGS

#define FDO_HACK_INVALID_FLAGS   (~FDO_HACK_VALID_FLAGS)

Definition at line 142 of file classp.h.

◆ FDO_HACK_NO_RESERVE6

#define FDO_HACK_NO_RESERVE6   (0x00000008)

Definition at line 138 of file classp.h.

◆ FDO_HACK_NO_SYNC_CACHE

#define FDO_HACK_NO_SYNC_CACHE   (0x00000004)

Definition at line 137 of file classp.h.

◆ FDO_HACK_VALID_FLAGS

#define FDO_HACK_VALID_FLAGS   (0x0000001F)

Definition at line 141 of file classp.h.

◆ FIFTY_MS_IN_100NS_UNITS

#define FIFTY_MS_IN_100NS_UNITS   50 * 100

Definition at line 1205 of file classp.h.

◆ GET_LBA_STATUS_RETRY_COUNT_MAX

#define GET_LBA_STATUS_RETRY_COUNT_MAX   (2)

Definition at line 229 of file classp.h.

◆ HISTORYINITIALIZERETRYLOGS

#define HISTORYINITIALIZERETRYLOGS (   _packet)
Value:
{ \
if (_packet->RetryHistory != NULL) \
{ \
HistoryInitializeRetryLogs( \
_packet->RetryHistory, \
_packet->RetryHistory->TotalHistoryCount \
); \
} \
}
smooth NULL
Definition: ftsmooth.c:416

Definition at line 2330 of file classp.h.

◆ HISTORYLOGRETURNEDPACKET

#define HISTORYLOGRETURNEDPACKET (   _packet)
Value:
{ \
if (_packet->RetryHistory != NULL) { \
HistoryLogReturnedPacket(_packet); \
} \
}
smooth NULL
Definition: ftsmooth.c:416

Definition at line 2357 of file classp.h.

◆ HISTORYLOGSENDPACKET

#define HISTORYLOGSENDPACKET (   _packet)
Value:
{ \
if (_packet->RetryHistory != NULL) { \
HistoryLogSendPacket(_packet); \
} \
}
smooth NULL
Definition: ftsmooth.c:416

Definition at line 2345 of file classp.h.

◆ LEGACY_NUM_IO_RETRIES

#define LEGACY_NUM_IO_RETRIES   8

Definition at line 170 of file classp.h.

◆ MAX

#define MAX (   a,
  b 
)    ((a) > (b) ? (a) : (b))

Definition at line 1191 of file classp.h.

◆ MAX_CLEANUP_TRANSFER_PACKETS_AT_ONCE

#define MAX_CLEANUP_TRANSFER_PACKETS_AT_ONCE   8192

Definition at line 639 of file classp.h.

◆ MAX_LIST_IDENTIFIER

#define MAX_LIST_IDENTIFIER   MAXULONG

Definition at line 203 of file classp.h.

◆ MAX_NUMBER_BLOCK_DEVICE_DESCRIPTORS

#define MAX_NUMBER_BLOCK_DEVICE_DESCRIPTORS   64

Definition at line 216 of file classp.h.

◆ MAX_NUMBER_BLOCKS_PER_BLOCK_DEVICE_RANGE_DESCRIPTOR

#define MAX_NUMBER_BLOCKS_PER_BLOCK_DEVICE_RANGE_DESCRIPTOR   MAXULONG

Definition at line 210 of file classp.h.

◆ MAX_NUMBER_BYTES_PER_SYNC_WRITE_USING_TOKEN

#define MAX_NUMBER_BYTES_PER_SYNC_WRITE_USING_TOKEN   (256ULL * 1024 * 1024)

Definition at line 213 of file classp.h.

◆ MAX_OUTSTANDING_IO_PER_LUN_DEFAULT

#define MAX_OUTSTANDING_IO_PER_LUN_DEFAULT   16

Definition at line 638 of file classp.h.

◆ MAX_RECEIVE_TOKEN_INFORMATION_PARAMETER_DATA_LENGTH

#define MAX_RECEIVE_TOKEN_INFORMATION_PARAMETER_DATA_LENGTH   MAXULONG

Definition at line 208 of file classp.h.

◆ MAX_TOKEN_LIST_IDENTIFIERS

#define MAX_TOKEN_LIST_IDENTIFIERS   MAXULONG

Definition at line 215 of file classp.h.

◆ MAX_TOKEN_OPERATION_PARAMETER_DATA_LENGTH

#define MAX_TOKEN_OPERATION_PARAMETER_DATA_LENGTH   MAXUSHORT

Definition at line 207 of file classp.h.

◆ MAX_TOKEN_TRANSFER_SIZE

#define MAX_TOKEN_TRANSFER_SIZE   MAXULONGLONG

Definition at line 209 of file classp.h.

◆ MAX_WORKINGSET_TRANSFER_PACKETS_Client

#define MAX_WORKINGSET_TRANSFER_PACKETS_Client   32

Definition at line 632 of file classp.h.

◆ MAX_WORKINGSET_TRANSFER_PACKETS_Server

#define MAX_WORKINGSET_TRANSFER_PACKETS_Server   1024

Definition at line 635 of file classp.h.

◆ MAX_WORKINGSET_TRANSFER_PACKETS_SPACES

#define MAX_WORKINGSET_TRANSFER_PACKETS_SPACES   2048

Definition at line 637 of file classp.h.

◆ MIN

#define MIN (   a,
  b 
)    ((a) < (b) ? (a) : (b))

Definition at line 1190 of file classp.h.

◆ MIN_INITIAL_TRANSFER_PACKETS

#define MIN_INITIAL_TRANSFER_PACKETS   1

Definition at line 630 of file classp.h.

◆ MIN_TOKEN_LIST_IDENTIFIERS

#define MIN_TOKEN_LIST_IDENTIFIERS   256

Definition at line 214 of file classp.h.

◆ MIN_WORKINGSET_TRANSFER_PACKETS_Client

#define MIN_WORKINGSET_TRANSFER_PACKETS_Client   16

Definition at line 631 of file classp.h.

◆ MIN_WORKINGSET_TRANSFER_PACKETS_Server_LowerBound

#define MIN_WORKINGSET_TRANSFER_PACKETS_Server_LowerBound   32

Definition at line 634 of file classp.h.

◆ MIN_WORKINGSET_TRANSFER_PACKETS_Server_UpperBound

#define MIN_WORKINGSET_TRANSFER_PACKETS_Server_UpperBound   256

Definition at line 633 of file classp.h.

◆ MIN_WORKINGSET_TRANSFER_PACKETS_SPACES

#define MIN_WORKINGSET_TRANSFER_PACKETS_SPACES   512

Definition at line 636 of file classp.h.

◆ MINIMUM_RETRY_UNITS

#define MINIMUM_RETRY_UNITS   ((LONGLONG)32)

Definition at line 1195 of file classp.h.

◆ MODE_PAGE_DATA_SIZE

#define MODE_PAGE_DATA_SIZE   192

Definition at line 1196 of file classp.h.

◆ NOT_READY_RETRY_INTERVAL

#define NOT_READY_RETRY_INTERVAL   10

Definition at line 1194 of file classp.h.

◆ NUM_DRIVECAPACITY_RETRIES

#define NUM_DRIVECAPACITY_RETRIES   1

Definition at line 161 of file classp.h.

◆ NUM_ERROR_LOG_ENTRIES

#define NUM_ERROR_LOG_ENTRIES   16

Definition at line 486 of file classp.h.

◆ NUM_IO_RETRIES

#define NUM_IO_RETRIES   MAXIMUM_RETRIES

Definition at line 169 of file classp.h.

◆ NUM_LOCKMEDIAREMOVAL_RETRIES

#define NUM_LOCKMEDIAREMOVAL_RETRIES   1

Definition at line 158 of file classp.h.

◆ NUM_MODESELECT_RETRIES

#define NUM_MODESELECT_RETRIES   1

Definition at line 160 of file classp.h.

◆ NUM_MODESENSE_RETRIES

#define NUM_MODESENSE_RETRIES   1

Definition at line 159 of file classp.h.

◆ NUM_POPULATE_TOKEN_RETRIES

#define NUM_POPULATE_TOKEN_RETRIES   1

Definition at line 204 of file classp.h.

◆ NUM_RECEIVE_TOKEN_INFORMATION_RETRIES

#define NUM_RECEIVE_TOKEN_INFORMATION_RETRIES   2

Definition at line 206 of file classp.h.

◆ NUM_THIN_PROVISIONING_RETRIES

#define NUM_THIN_PROVISIONING_RETRIES   32

Definition at line 162 of file classp.h.

◆ NUM_WRITE_USING_TOKEN_RETRIES

#define NUM_WRITE_USING_TOKEN_RETRIES   2

Definition at line 205 of file classp.h.

◆ PTRALIGN

#define PTRALIGN

Definition at line 96 of file classp.h.

◆ QERR_SET_ZERO_ALWAYS

#define QERR_SET_ZERO_ALWAYS   1

Definition at line 1186 of file classp.h.

◆ QERR_SET_ZERO_NEVER

#define QERR_SET_ZERO_NEVER   2

Definition at line 1187 of file classp.h.

◆ QERR_SET_ZERO_ODX_OR_TP_ONLY

#define QERR_SET_ZERO_ODX_OR_TP_ONLY   0

Definition at line 1185 of file classp.h.

◆ REG_DISK_CLASS_CONTROL

#define REG_DISK_CLASS_CONTROL   L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control\\DISK"

Definition at line 218 of file classp.h.

◆ REG_MAX_LIST_IDENTIFIER_VALUE

#define REG_MAX_LIST_IDENTIFIER_VALUE   L"MaximumListIdentifier"

Definition at line 219 of file classp.h.

◆ RTL_USE_AVL_TABLES

#define RTL_USE_AVL_TABLES   0

Definition at line 28 of file classp.h.

◆ SHIFT10000

#define SHIFT10000   13

Definition at line 246 of file classp.h.

◆ TRACKING_FORWARD_PROGRESS_PATH1

#define TRACKING_FORWARD_PROGRESS_PATH1   (0x00000001)

Definition at line 2385 of file classp.h.

◆ TRACKING_FORWARD_PROGRESS_PATH2

#define TRACKING_FORWARD_PROGRESS_PATH2   (0x00000002)

Definition at line 2386 of file classp.h.

◆ TRACKING_FORWARD_PROGRESS_PATH3

#define TRACKING_FORWARD_PROGRESS_PATH3   (0x00000004)

Definition at line 2387 of file classp.h.

◆ VPD_PAGE_HEADER_SIZE

#define VPD_PAGE_HEADER_SIZE   0x04

Definition at line 221 of file classp.h.

◆ WPP_CONTROL_GUIDS

Definition at line 87 of file classp.h.

◆ WPP_GUID_CLASSPNP

#define WPP_GUID_CLASSPNP   (FA8DE7C4, ACDE, 4443, 9994, C4E2359A9EDB)

Definition at line 85 of file classp.h.

Typedef Documentation

◆ CLASS_DETECTION_STATE

◆ CLASS_ERROR_LOG_DATA

◆ CLASS_RETRY_INFO

◆ CSCAN_LIST

◆ FAILURE_PREDICTION_INFO

◆ IDLE_POWER_FDO_LIST_ENTRY

◆ IO_RETRIED_LOG_MESSAGE_CONTEXT

◆ MEDIA_CHANGE_DETECTION_INFO

◆ OFFLOAD_READ_CONTEXT

◆ OFFLOAD_WRITE_CONTEXT

◆ OPCODE_SENSE_DATA_IO_LOG_MESSAGE_CONTEXT_HEADER

◆ PCLASS_DETECTION_STATE

◆ PCLASS_ERROR_LOG_DATA

◆ PCLASS_RETRY_INFO

◆ PCONTINUATION_ROUTINE

typedef VOID(* PCONTINUATION_ROUTINE) (_In_ PVOID Context)

Definition at line 492 of file classp.h.

◆ PCSCAN_LIST

◆ PFAILURE_PREDICTION_INFO

◆ PIDLE_POWER_FDO_LIST_ENTRY

◆ PIO_RETRIED_LOG_MESSAGE_CONTEXT

◆ PMEDIA_CHANGE_DETECTION_INFO

◆ PMEDIA_LOCK_TYPE

◆ PNL_SLIST_HEADER

◆ POFFLOAD_READ_CONTEXT

◆ POFFLOAD_WRITE_CONTEXT

◆ POPCODE_SENSE_DATA_IO_LOG_MESSAGE_CONTEXT_HEADER

◆ PPNL_SLIST_HEADER

◆ PSRB_ALLOCATE_ROUTINE

typedef PVOID(* PSRB_ALLOCATE_ROUTINE) (_In_ CLONG ByteSize)

Definition at line 2409 of file classp.h.

◆ PTRANSFER_PACKET

◆ TRANSFER_PACKET

Enumeration Type Documentation

◆ _CLASS_DETECTION_STATE

Enumerator
ClassDetectionUnknown 
ClassDetectionUnsupported 
ClassDetectionSupported 

Definition at line 444 of file classp.h.

444  {
enum _CLASS_DETECTION_STATE * PCLASS_DETECTION_STATE
enum _CLASS_DETECTION_STATE CLASS_DETECTION_STATE

◆ MEDIA_LOCK_TYPE

Enumerator
SimpleMediaLock 
SecureMediaLock 
InternalMediaLock 
SimpleMediaLock 
SecureMediaLock 
InternalMediaLock 

Definition at line 378 of file classp.h.

378  {
MEDIA_LOCK_TYPE
Definition: classp.h:378
enum MEDIA_LOCK_TYPE * PMEDIA_LOCK_TYPE

Function Documentation

◆ __drv_allocatesMem()

__drv_allocatesMem ( Mem  )

Definition at line 1476 of file exfuncs.h.

1484 {
1485  PVOID Entry;
1486 
1487  Lookaside->L.TotalAllocates++;
1488 #ifdef NONAMELESSUNION
1489 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
1490  Entry = ExInterlockedPopEntrySList(&Lookaside->L.u.ListHead,
1491  &Lookaside->Lock__ObsoleteButDoNotDelete);
1492 #else
1493  Entry = InterlockedPopEntrySList(&Lookaside->L.u.ListHead);
1494 #endif
1495  if (Entry == NULL) {
1496  Lookaside->L.u2.AllocateMisses++;
1497  Entry = (Lookaside->L.u4.Allocate)(Lookaside->L.Type,
1498  Lookaside->L.Size,
1499  Lookaside->L.Tag);
1500  }
1501 #else /* NONAMELESSUNION */
1502 #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
1504  &Lookaside->Lock__ObsoleteButDoNotDelete);
1505 #else
1506  Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
1507 #endif
1508  if (Entry == NULL) {
1509  Lookaside->L.AllocateMisses++;
1510  Entry = (Lookaside->L.Allocate)(Lookaside->L.Type,
1511  Lookaside->L.Size,
1512  Lookaside->L.Tag);
1513  }
1514 #endif /* NONAMELESSUNION */
1515  return Entry;
1516 }
_In_ PVOID Entry
Definition: exfuncs.h:229
#define ExInterlockedPopEntrySList(SListHead, Lock)
Definition: exfuncs.h:166
PSLIST_ENTRY WINAPI InterlockedPopEntrySList(PSLIST_HEADER ListHead)
Definition: interlocked.c:55
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PVOID Lookaside
Definition: fltkernel.h:2532
base of all file and directory entries
Definition: entries.h:82

◆ _Dispatch_type_() [1/7]

_Dispatch_type_ ( IRP_MJ_CREATE  )

Definition at line 4769 of file create.c.

4771  {
4772  NTSTATUS Status;
4774  device_extension* Vcb = DeviceObject->DeviceExtension;
4775  bool top_level, locked = false;
4776 
4778 
4779  TRACE("create (flags = %lx)\n", Irp->Flags);
4780 
4781  top_level = is_top_level(Irp);
4782 
4783  /* return success if just called for FS device object */
4784  if (DeviceObject == master_devobj) {
4785  TRACE("create called for FS device object\n");
4786 
4787  Irp->IoStatus.Information = FILE_OPENED;
4789 
4790  goto exit;
4791  } else if (Vcb && Vcb->type == VCB_TYPE_VOLUME) {
4793  goto exit;
4794  } else if (!Vcb || Vcb->type != VCB_TYPE_FS) {
4796  goto exit;
4797  }
4798 
4799  if (!(Vcb->Vpb->Flags & VPB_MOUNTED)) {
4801  goto exit;
4802  }
4803 
4804  if (Vcb->removing) {
4806  goto exit;
4807  }
4808 
4809  Status = verify_vcb(Vcb, Irp);
4810  if (!NT_SUCCESS(Status)) {
4811  ERR("verify_vcb returned %08lx\n", Status);
4812  goto exit;
4813  }
4814 
4815  ExAcquireResourceSharedLite(&Vcb->load_lock, true);
4816  locked = true;
4817 
4819 
4820  if (IrpSp->Flags != 0) {
4822 
4823  TRACE("flags:\n");
4824 
4825  if (flags & SL_CASE_SENSITIVE) {
4826  TRACE("SL_CASE_SENSITIVE\n");
4828  }
4829 
4830  if (flags & SL_FORCE_ACCESS_CHECK) {
4831  TRACE("SL_FORCE_ACCESS_CHECK\n");
4833  }
4834 
4835  if (flags & SL_OPEN_PAGING_FILE) {
4836  TRACE("SL_OPEN_PAGING_FILE\n");
4838  }
4839 
4841  TRACE("SL_OPEN_TARGET_DIRECTORY\n");
4843  }
4844 
4845  if (flags & SL_STOP_ON_SYMLINK) {
4846  TRACE("SL_STOP_ON_SYMLINK\n");
4848  }
4849 
4850  if (flags)
4851  WARN("unknown flags: %x\n", flags);
4852  } else {
4853  TRACE("flags: (none)\n");
4854  }
4855 
4856  if (!IrpSp->FileObject) {
4857  ERR("FileObject was NULL\n");
4859  goto exit;
4860  }
4861 
4862  if (IrpSp->FileObject->RelatedFileObject) {
4863  fcb* relatedfcb = IrpSp->FileObject->RelatedFileObject->FsContext;
4864 
4865  if (relatedfcb && relatedfcb->Vcb != Vcb) {
4866  WARN("RelatedFileObject was for different device\n");
4868  goto exit;
4869  }
4870  }
4871 
4872  // opening volume
4873  if (IrpSp->FileObject->FileName.Length == 0 && !IrpSp->FileObject->RelatedFileObject) {
4874  ULONG RequestedDisposition = ((IrpSp->Parameters.Create.Options >> 24) & 0xff);
4875  ULONG RequestedOptions = IrpSp->Parameters.Create.Options & FILE_VALID_OPTION_FLAGS;
4876 #ifdef DEBUG_FCB_REFCOUNTS
4877  LONG rc;
4878 #endif
4879  ccb* ccb;
4880 
4881  TRACE("open operation for volume\n");
4882 
4883  if (RequestedDisposition != FILE_OPEN && RequestedDisposition != FILE_OPEN_IF) {
4885  goto exit;
4886  }
4887 
4888  if (RequestedOptions & FILE_DIRECTORY_FILE) {
4890  goto exit;
4891  }
4892 
4894  if (!ccb) {
4895  ERR("out of memory\n");
4897  goto exit;
4898  }
4899 
4900  RtlZeroMemory(ccb, sizeof(*ccb));
4901 
4903  ccb->NodeSize = sizeof(*ccb);
4904  ccb->disposition = RequestedDisposition;
4905  ccb->options = RequestedOptions;
4906  ccb->access = IrpSp->Parameters.Create.SecurityContext->AccessState->PreviouslyGrantedAccess;
4908  IrpSp->Flags & SL_FORCE_ACCESS_CHECK ? UserMode : Irp->RequestorMode);
4909  ccb->reserving = false;
4910  ccb->lxss = called_from_lxss();
4911 
4912 #ifdef DEBUG_FCB_REFCOUNTS
4913  rc = InterlockedIncrement(&Vcb->volume_fcb->refcount);
4914  WARN("fcb %p: refcount now %i (volume)\n", Vcb->volume_fcb, rc);
4915 #else
4916  InterlockedIncrement(&Vcb->volume_fcb->refcount);
4917 #endif
4918  IrpSp->FileObject->FsContext = Vcb->volume_fcb;
4919  IrpSp->FileObject->FsContext2 = ccb;
4920 
4921  IrpSp->FileObject->SectionObjectPointer = &Vcb->volume_fcb->nonpaged->segment_object;
4922 
4923  if (!IrpSp->FileObject->Vpb)
4924  IrpSp->FileObject->Vpb = DeviceObject->Vpb;
4925 
4926  InterlockedIncrement(&Vcb->open_files);
4927 
4928  Irp->IoStatus.Information = FILE_OPENED;
4930  } else {
4932  bool skip_lock;
4933 
4935 
4936  TRACE("file name: %.*S\n", (int)(IrpSp->FileObject->FileName.Length / sizeof(WCHAR)), IrpSp->FileObject->FileName.Buffer);
4937 
4938  if (IrpSp->FileObject->RelatedFileObject)
4939  TRACE("related file = %p\n", IrpSp->FileObject->RelatedFileObject);
4940 
4941  // Don't lock again if we're being called from within CcCopyRead etc.
4942  skip_lock = ExIsResourceAcquiredExclusiveLite(&Vcb->tree_lock);
4943 
4944  if (!skip_lock)
4945  ExAcquireResourceSharedLite(&Vcb->tree_lock, true);
4946 
4947  ExAcquireResourceSharedLite(&Vcb->fileref_lock, true);
4948 
4950 
4951  if (!NT_SUCCESS(Status))
4953  else
4955 
4956  ExReleaseResourceLite(&Vcb->fileref_lock);
4957 
4958  if (!skip_lock)
4959  ExReleaseResourceLite(&Vcb->tree_lock);
4960  }
4961 
4962 exit:
4963  Irp->IoStatus.Status = Status;
4965 
4966  TRACE("create returning %08lx\n", Status);
4967 
4968  if (locked)
4969  ExReleaseResourceLite(&Vcb->load_lock);
4970 
4971  if (top_level)
4973 
4975 
4976  return Status;
4977 }
void do_rollback(device_extension *Vcb, LIST_ENTRY *rollback)
Definition: treefuncs.c:1050
void clear_rollback(LIST_ENTRY *rollback)
Definition: treefuncs.c:1029
#define SL_CASE_SENSITIVE
Definition: iotypes.h:1800
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define FsRtlEnterFileSystem
#define FILE_OPEN_IF
Definition: from_kernel.h:56
ULONG options
Definition: btrfs_drv.h:390
USHORT Flags
Definition: iotypes.h:171
#define FsRtlExitFileSystem
Iosb Status
Definition: create.c:4287
#define SL_OPEN_PAGING_FILE
Definition: iotypes.h:1797
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
#define WARN(fmt,...)
Definition: debug.h:112
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_OPENED
Definition: nt_native.h:769
#define SL_STOP_ON_SYMLINK
Definition: iotypes.h:1799
#define VCB_TYPE_FS
Definition: btrfs_drv.h:695
ACCESS_MASK access
Definition: btrfs_drv.h:398
bool is_top_level(_In_ PIRP Irp)
Definition: btrfs.c:279
#define SL_FORCE_ACCESS_CHECK
Definition: iotypes.h:1796
bool manage_volume_privilege
Definition: btrfs_drv.h:395
#define FILE_VALID_OPTION_FLAGS
Definition: nt_native.h:759
#define ALLOC_TAG
Definition: btrfs_drv.h:91
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB Vcb
Definition: create.c:4137
#define STATUS_NOT_A_DIRECTORY
Definition: udferr_usr.h:169
#define IO_DISK_INCREMENT
Definition: iotypes.h:583
long LONG
Definition: pedump.c:60
PDEVICE_OBJECT master_devobj
Definition: btrfs.c:69
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN NTAPI ExIsResourceAcquiredExclusiveLite(IN PERESOURCE Resource)
Definition: resource.c:1619
#define IoCompleteRequest
Definition: irp.c:1240
static bool has_manage_volume_privilege(ACCESS_STATE *access_state, KPROCESSOR_MODE processor_mode)
Definition: create.c:4758
#define BTRFS_NODE_TYPE_CCB
Definition: btrfs_drv.h:88
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define VCB_TYPE_VOLUME
Definition: btrfs_drv.h:697
NTSTATUS vol_create(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:36
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
USHORT NodeType
Definition: btrfs_drv.h:387
GLbitfield flags
Definition: glext.h:7161
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static NTSTATUS open_file(PDEVICE_OBJECT DeviceObject, _Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, PIRP Irp, LIST_ENTRY *rollback)
Definition: create.c:4408
Status
Definition: gdiplustypes.h:24
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
Definition: typedefs.h:119
#define FILE_OPEN
Definition: from_kernel.h:54
#define ERR(fmt,...)
Definition: debug.h:110
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
PFILE_OBJECT FileObject
Definition: iotypes.h:3148
#define SL_OPEN_TARGET_DIRECTORY
Definition: iotypes.h:1798
#define InterlockedIncrement
Definition: armddk.h:53
ULONG disposition
Definition: btrfs_drv.h:389
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY * rollback
Definition: btrfs_drv.h:1357
UINT32 uint32_t
Definition: types.h:75
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
#define called_from_lxss()
Definition: create.c:2989
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
bool reserving
Definition: btrfs_drv.h:397
bool lxss
Definition: btrfs_drv.h:407
void exit(int exitcode)
Definition: _exit.c:33
struct _ccb ccb
static NTSTATUS verify_vcb(device_extension *Vcb, PIRP Irp)
Definition: create.c:4696
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014
CSHORT NodeSize
Definition: btrfs_drv.h:388
#define VPB_MOUNTED
Definition: iotypes.h:1787
HRESULT Create([out]ITransactionReceiver **ppReceiver)
struct _device_extension * Vcb
Definition: btrfs_drv.h:298
#define STATUS_DEVICE_NOT_READY
Definition: shellext.h:70

◆ _Dispatch_type_() [2/7]

_Dispatch_type_ ( IRP_MJ_READ  )

Definition at line 3515 of file read.c.

3517  {
3518  device_extension* Vcb = DeviceObject->DeviceExtension;
3521  ULONG bytes_read = 0;
3522  NTSTATUS Status;
3523  bool top_level;
3524  fcb* fcb;
3525  ccb* ccb;
3526  bool acquired_fcb_lock = false, wait;
3527 
3529 
3530  top_level = is_top_level(Irp);
3531 
3532  TRACE("read\n");
3533 
3534  if (Vcb && Vcb->type == VCB_TYPE_VOLUME) {
3536  goto exit2;
3537  } else if (!Vcb || Vcb->type != VCB_TYPE_FS) {
3539  goto end;
3540  }
3541 
3542  Irp->IoStatus.Information = 0;
3543 
3545  CcMdlReadComplete(IrpSp->FileObject, Irp->MdlAddress);
3546 
3547  Irp->MdlAddress = NULL;
3549 
3550  goto exit;
3551  }
3552 
3553  fcb = FileObject->FsContext;
3554 
3555  if (!fcb) {
3556  ERR("fcb was NULL\n");
3558  goto exit;
3559  }
3560 
3561  ccb = FileObject->FsContext2;
3562 
3563  if (!ccb) {
3564  ERR("ccb was NULL\n");
3566  goto exit;
3567  }
3568 
3569  if (Irp->RequestorMode == UserMode && !(ccb->access & FILE_READ_DATA)) {
3570  WARN("insufficient privileges\n");
3572  goto exit;
3573  }
3574 
3575  if (fcb == Vcb->volume_fcb) {
3576  TRACE("reading volume FCB\n");
3577 
3579 
3580  Status = IoCallDriver(Vcb->Vpb->RealDevice, Irp);
3581 
3582  goto exit2;
3583  }
3584 
3585  if (!(Irp->Flags & IRP_PAGING_IO))
3587 
3588  wait = IoIsOperationSynchronous(Irp);
3589 
3590  // Don't offload jobs when doing paging IO - otherwise this can lead to
3591  // deadlocks in CcCopyRead.
3592  if (Irp->Flags & IRP_PAGING_IO)
3593  wait = true;
3594 
3595  if (!(Irp->Flags & IRP_PAGING_IO) && FileObject->SectionObjectPointer && FileObject->SectionObjectPointer->DataSectionObject) {
3597 
3598  CcFlushCache(FileObject->SectionObjectPointer, &IrpSp->Parameters.Read.ByteOffset, IrpSp->Parameters.Read.Length, &iosb);
3599  if (!NT_SUCCESS(iosb.Status)) {
3600  ERR("CcFlushCache returned %08lx\n", iosb.Status);
3601  return iosb.Status;
3602  }
3603  }
3604 
3605  if (!ExIsResourceAcquiredSharedLite(fcb->Header.Resource)) {
3606  if (!ExAcquireResourceSharedLite(fcb->Header.Resource, wait)) {
3609  goto exit;
3610  }
3611 
3612  acquired_fcb_lock = true;
3613  }
3614 
3615  Status = do_read(Irp, wait, &bytes_read);
3616 
3617  if (acquired_fcb_lock)
3618  ExReleaseResourceLite(fcb->Header.Resource);
3619 
3620 exit:
3621  if (FileObject->Flags & FO_SYNCHRONOUS_IO && !(Irp->Flags & IRP_PAGING_IO))
3622  FileObject->CurrentByteOffset.QuadPart = IrpSp->Parameters.Read.ByteOffset.QuadPart + (NT_SUCCESS(Status) ? bytes_read : 0);
3623 
3624 end:
3625  Irp->IoStatus.Status = Status;
3626 
3627  TRACE("Irp->IoStatus.Status = %08lx\n", Irp->IoStatus.Status);
3628  TRACE("Irp->IoStatus.Information = %Iu\n", Irp->IoStatus.Information);
3629  TRACE("returning %08lx\n", Status);
3630 
3631  if (Status != STATUS_PENDING)
3633  else {
3634  if (!add_thread_job(Vcb, Irp))
3635  Status = do_read_job(Irp);
3636  }
3637 
3638 exit2:
3639  if (top_level)
3641 
3643 
3644  return Status;
3645 }
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
NTSTATUS do_read_job(PIRP Irp)
Definition: worker-thread.c:26
#define FsRtlEnterFileSystem
VOID NTAPI CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, OUT OPTIONAL PIO_STATUS_BLOCK IoStatus)
Definition: cachesub.c:222
#define FsRtlExitFileSystem
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define WARN(fmt,...)
Definition: debug.h:112
LONG NTSTATUS
Definition: precomp.h:26
#define VCB_TYPE_FS
Definition: btrfs_drv.h:695
GLuint GLuint end
Definition: gl.h:1545
ACCESS_MASK access
Definition: btrfs_drv.h:398
BOOLEAN NTAPI IoIsOperationSynchronous(IN PIRP Irp)
Definition: irp.c:1882
bool is_top_level(_In_ PIRP Irp)
Definition: btrfs.c:279
NTSTATUS do_read(PIRP Irp, bool wait, ULONG *bytes_read)
Definition: read.c:3361
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1756
#define IRP_MN_COMPLETE
Definition: iotypes.h:4399
#define FILE_READ_DATA
Definition: nt_native.h:628
VOID NTAPI CcMdlReadComplete(IN PFILE_OBJECT FileObject, IN PMDL MdlChain)
Definition: mdlsup.c:75
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:588
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:294
bool add_thread_job(device_extension *Vcb, PIRP Irp)
#define TRACE(s)
Definition: solgame.cpp:4
struct _fcb fcb
Definition: btrfs_drv.h:1357
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define VCB_TYPE_VOLUME
Definition: btrfs_drv.h:697
#define Vcb
Definition: cdprocs.h:1415
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
* PFILE_OBJECT
Definition: iotypes.h:1978
Status
Definition: gdiplustypes.h:24
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
#define ERR(fmt,...)
Definition: debug.h:110
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
PFILE_OBJECT FileObject
Definition: iotypes.h:3148
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IRP_PAGING_IO
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
static __inline POPLOCK fcb_oplock(fcb *fcb)
Definition: btrfs_drv.h:1683
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:581
ULONG NTAPI ExIsResourceAcquiredSharedLite(IN PERESOURCE Resource)
Definition: resource.c:1658
NTSTATUS NTAPI FsRtlCheckOplock(IN POPLOCK Oplock, IN PIRP Irp, IN PVOID Context, IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL)
Definition: oplock.c:1172
void exit(int exitcode)
Definition: _exit.c:33
struct _ccb ccb
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014
IoMarkIrpPending(Irp)
NTSTATUS vol_read(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:144

◆ _Dispatch_type_() [3/7]

_Dispatch_type_ ( IRP_MJ_DEVICE_CONTROL  )

Definition at line 252 of file devctrl.c.

254  {
257  device_extension* Vcb = DeviceObject->DeviceExtension;
258  bool top_level;
259 
261 
262  top_level = is_top_level(Irp);
263 
264  Irp->IoStatus.Information = 0;
265 
266  if (Vcb) {
267  if (Vcb->type == VCB_TYPE_CONTROL) {
269  goto end;
270  } else if (Vcb->type == VCB_TYPE_VOLUME) {
272  goto end;
273  } else if (Vcb->type != VCB_TYPE_FS) {
275  goto end;
276  }
277  } else {
279  goto end;
280  }
281 
282  switch (IrpSp->Parameters.DeviceIoControl.IoControlCode) {
285  goto end;
286 
289  goto end;
290 
291  default:
292  TRACE("unhandled control code %lx\n", IrpSp->Parameters.DeviceIoControl.IoControlCode);
293  break;
294  }
295 
297 
298  Status = IoCallDriver(Vcb->Vpb->RealDevice, Irp);
299 
300  goto end2;
301 
302 end:
303  Irp->IoStatus.Status = Status;
304 
305  if (Status != STATUS_PENDING)
307 
308 end2:
309  TRACE("returning %08lx\n", Status);
310 
311  if (top_level)
313 
315 
316  return Status;
317 }
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define IOCTL_DISK_IS_WRITABLE
Definition: cdrw_usr.h:172
#define VCB_TYPE_FS
Definition: btrfs_drv.h:695
GLuint GLuint end
Definition: gl.h:1545
bool is_top_level(_In_ PIRP Irp)
Definition: btrfs.c:279
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
#define IOCTL_MOUNTDEV_QUERY_STABLE_GUID
Definition: imports.h:255
#define TRACE(s)
Definition: solgame.cpp:4
static NTSTATUS control_ioctl(PIRP Irp)
Definition: devctrl.c:226
#define STATUS_PENDING
Definition: ntstatus.h:82
#define VCB_TYPE_VOLUME
Definition: btrfs_drv.h:697
#define Vcb
Definition: cdprocs.h:1415
Status
Definition: gdiplustypes.h:24
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
#define VCB_TYPE_CONTROL
Definition: btrfs_drv.h:696
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
NTSTATUS vol_device_control(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:820
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
static NTSTATUS is_writable(device_extension *Vcb)
Definition: devctrl.c:43
#define IO_NO_INCREMENT
Definition: iotypes.h:581
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
static NTSTATUS mountdev_query_stable_guid(device_extension *Vcb, PIRP Irp)
Definition: devctrl.c:27

◆ _Dispatch_type_() [4/7]

_Dispatch_type_ ( IRP_MJ_PNP  )

Definition at line 620 of file pnp.c.

622  {
624  device_extension* Vcb = DeviceObject->DeviceExtension;
626  bool top_level;
627 
629 
630  top_level = is_top_level(Irp);
631 
632  if (Vcb && Vcb->type == VCB_TYPE_BUS) {
633  Status = bus_pnp(DeviceObject->DeviceExtension, Irp);
634  goto exit;
635  } else if (Vcb && Vcb->type == VCB_TYPE_VOLUME) {
636  volume_device_extension* vde = DeviceObject->DeviceExtension;
639  goto exit;
640  } else if (Vcb && Vcb->type == VCB_TYPE_PDO) {
642  goto end;
643  } else if (!Vcb || Vcb->type != VCB_TYPE_FS) {
645  goto end;
646  }
647 
649 
650  switch (IrpSp->MinorFunction) {
653  break;
654 
657  break;
658 
661  break;
662 
665  break;
666 
669  goto exit;
670 
671  default:
672  TRACE("passing minor function 0x%x on\n", IrpSp->MinorFunction);
673 
675  Status = IoCallDriver(Vcb->Vpb->RealDevice, Irp);
676  goto exit;
677  }
678 
679 end:
680  Irp->IoStatus.Status = Status;
681 
683 
684 exit:
685  TRACE("returning %08lx\n", Status);
686 
687  if (top_level)
689 
691 
692  return Status;
693 }
NTSTATUS pnp_query_remove_device(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: pnp.c:181
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define VCB_TYPE_PDO
Definition: btrfs_drv.h:698
#define IRP_MN_REMOVE_DEVICE
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define VCB_TYPE_FS
Definition: btrfs_drv.h:695
GLuint GLuint end
Definition: gl.h:1545
bool is_top_level(_In_ PIRP Irp)
Definition: btrfs.c:279
#define VCB_TYPE_BUS
Definition: btrfs_drv.h:699
static NTSTATUS pnp_remove_device(PDEVICE_OBJECT DeviceObject)
Definition: pnp.c:221
#define IRP_MN_QUERY_REMOVE_DEVICE
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define TRACE(s)
Definition: solgame.cpp:4
static NTSTATUS bus_pnp(bus_device_extension *bde, PIRP Irp)
Definition: pnp.c:360
#define VCB_TYPE_VOLUME
Definition: btrfs_drv.h:697
#define Vcb
Definition: cdprocs.h:1415
Status
Definition: gdiplustypes.h:24
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
static NTSTATUS pnp_cancel_remove_device(PDEVICE_OBJECT DeviceObject)
Definition: pnp.c:155
PDEVICE_OBJECT attached_device
Definition: btrfs_drv.h:888
static NTSTATUS pdo_pnp(PDEVICE_OBJECT pdo, PIRP Irp)
Definition: pnp.c:572
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
static NTSTATUS pnp_device_usage_notification(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: pnp.c:599
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define IRP_MN_DEVICE_USAGE_NOTIFICATION
void exit(int exitcode)
Definition: _exit.c:33
NTSTATUS pnp_surprise_removal(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: pnp.c:254

◆ _Dispatch_type_() [5/7]

_Dispatch_type_ ( IRP_MJ_SHUTDOWN  )

Definition at line 5437 of file btrfs.c.

5439  {
5440  NTSTATUS Status;
5441  bool top_level;
5442  device_extension* Vcb = DeviceObject->DeviceExtension;
5443 
5445 
5446  TRACE("shutdown\n");
5447 
5448  top_level = is_top_level(Irp);
5449 
5450  if (Vcb && Vcb->type == VCB_TYPE_VOLUME) {
5452  goto end;
5453  }
5454 
5456 
5457  do_shutdown(Irp);
5458 
5459 end:
5460  Irp->IoStatus.Status = Status;
5461  Irp->IoStatus.Information = 0;
5462 
5464 
5465  if (top_level)
5467 
5469 
5470  return Status;
5471 }
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: btrfs.c:4232
GLuint GLuint end
Definition: gl.h:1545
bool is_top_level(_In_ PIRP Irp)
Definition: btrfs.c:279
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
InsertTailList & Vcb
Definition: btrfs.c:2978
#define TRACE(s)
Definition: solgame.cpp:4
NTSTATUS vol_shutdown(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:899
#define VCB_TYPE_VOLUME
Definition: btrfs_drv.h:697
Status
Definition: gdiplustypes.h:24
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define IO_NO_INCREMENT
Definition: iotypes.h:581
return STATUS_SUCCESS
Definition: btrfs.c:3014
void do_shutdown(PIRP Irp)
Definition: btrfs.c:5319

◆ _Dispatch_type_() [6/7]

_Dispatch_type_ ( IRP_MJ_SYSTEM_CONTROL  )

Definition at line 5675 of file btrfs.c.

5677  {
5678  NTSTATUS Status;
5679  device_extension* Vcb = DeviceObject->DeviceExtension;
5680  bool top_level;
5681 
5683 
5684  top_level = is_top_level(Irp);
5685 
5686  Irp->IoStatus.Information = 0;
5687 
5688  if (Vcb && Vcb->type == VCB_TYPE_VOLUME) {
5689  volume_device_extension* vde = DeviceObject->DeviceExtension;
5690 
5692 
5694 
5695  goto exit;
5696  } else if (Vcb && Vcb->type == VCB_TYPE_FS) {
5698 
5699  Status = IoCallDriver(Vcb->Vpb->RealDevice, Irp);
5700 
5701  goto exit;
5702  } else if (Vcb && Vcb->type == VCB_TYPE_BUS) {
5703  bus_device_extension* bde = DeviceObject->DeviceExtension;
5704 
5706 
5708 
5709  goto exit;
5710  }
5711 
5712  Status = Irp->IoStatus.Status;
5714 
5715 exit:
5716  if (top_level)
5718 
5720 
5721  return Status;
5722 }
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: btrfs.c:4232
#define VCB_TYPE_FS
Definition: btrfs_drv.h:695
bool is_top_level(_In_ PIRP Irp)
Definition: btrfs.c:279
#define VCB_TYPE_BUS
Definition: btrfs_drv.h:699
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
InsertTailList & Vcb
Definition: btrfs.c:2978
#define VCB_TYPE_VOLUME
Definition: btrfs_drv.h:697
Status
Definition: gdiplustypes.h:24
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
PDEVICE_OBJECT attached_device
Definition: btrfs_drv.h:888
PDEVICE_OBJECT attached_device
Definition: btrfs_drv.h:857
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IO_NO_INCREMENT
Definition: iotypes.h:581
void exit(int exitcode)
Definition: _exit.c:33

◆ _Dispatch_type_() [7/7]

_Dispatch_type_ ( IRP_MJ_POWER  )

Definition at line 5581 of file btrfs.c.

5583  {
5584  NTSTATUS Status;
5586  device_extension* Vcb = DeviceObject->DeviceExtension;
5587  bool top_level;
5588 
5589  // no need for FsRtlEnterFileSystem, as this only ever gets called in a system thread
5590 
5591  top_level = is_top_level(Irp);
5592 
5593  Irp->IoStatus.Information = 0;
5594 
5595  if (Vcb && Vcb->type == VCB_TYPE_VOLUME) {
5596  volume_device_extension* vde = DeviceObject->DeviceExtension;
5597 
5599  IrpSp->Parameters.Power.State.SystemState != PowerSystemWorking && vde->mounted_device) {
5601 
5602  /* If power state is about to go to sleep or hibernate, do a flush. We do this on IRP_MJ_QUERY_POWER
5603  * rather than IRP_MJ_SET_POWER because we know that the hard disks are still awake. */
5604 
5605  if (Vcb2) {
5606  ExAcquireResourceExclusiveLite(&Vcb2->tree_lock, true);
5607 
5608  if (Vcb2->need_write && !Vcb2->readonly) {
5609  TRACE("doing protective flush on power state change\n");
5610  Status = do_write(Vcb2, NULL);
5611  } else
5613 
5614  free_trees(Vcb2);
5615 
5616  if (!NT_SUCCESS(Status))
5617  ERR("do_write returned %08lx\n", Status);
5618 
5619  ExReleaseResourceLite(&Vcb2->tree_lock);
5620  }
5621  } else if (IrpSp->MinorFunction == IRP_MN_SET_POWER && IrpSp->Parameters.Power.Type == SystemPowerState &&
5622  IrpSp->Parameters.Power.State.SystemState == PowerSystemWorking && vde->mounted_device) {
5624 
5625  /* If waking up, make sure that the FS hasn't been changed while we've been out (e.g., by dual-boot Linux) */
5626 
5627  if (Vcb2) {
5628  PIO_WORKITEM work_item;
5629 
5630  work_item = IoAllocateWorkItem(DeviceObject);
5631  if (!work_item) {
5632  ERR("out of memory\n");
5633  } else
5634  IoQueueWorkItem(work_item, check_after_wakeup, DelayedWorkQueue, Vcb2);
5635  }
5636  }
5637 
5640  Status = PoCallDriver(vde->attached_device, Irp);
5641 
5642  goto exit;
5643  } else if (Vcb && Vcb->type == VCB_TYPE_FS) {
5645 
5646  Status = IoCallDriver(Vcb->Vpb->RealDevice, Irp);
5647 
5648  goto exit;
5649  } else if (Vcb && Vcb->type == VCB_TYPE_BUS) {
5650  bus_device_extension* bde = DeviceObject->DeviceExtension;
5651 
5654  Status = PoCallDriver(bde->attached_device, Irp);
5655 
5656  goto exit;
5657  }
5658 
5660  Irp->IoStatus.Status = STATUS_SUCCESS;
5661 
5662  Status = Irp->IoStatus.Status;
5663 
5665 
5667 
5668 exit:
5669  if (top_level)
5671 
5672  return Status;
5673 }
#define IRP_MN_QUERY_POWER
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS do_write(device_extension *Vcb, PIRP Irp)
Definition: flushthread.c:7789
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: btrfs.c:4232
#define VCB_TYPE_FS
Definition: btrfs_drv.h:695
PIO_WORKITEM NTAPI IoAllocateWorkItem(IN PDEVICE_OBJECT DeviceObject)
Definition: iowork.c:75
bool is_top_level(_In_ PIRP Irp)
Definition: btrfs.c:279
#define VCB_TYPE_BUS
Definition: btrfs_drv.h:699
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
void free_trees(device_extension *Vcb)
Definition: treefuncs.c:794
InsertTailList & Vcb
Definition: btrfs.c:2978
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define VCB_TYPE_VOLUME
Definition: btrfs_drv.h:697
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
PDEVICE_OBJECT mounted_device
Definition: btrfs_drv.h:884
Status
Definition: gdiplustypes.h:24
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
#define IRP_MN_SET_POWER
PDEVICE_OBJECT attached_device
Definition: btrfs_drv.h:888
#define ERR(fmt,...)
Definition: debug.h:110
VOID NTAPI IoQueueWorkItem(IN PIO_WORKITEM IoWorkItem, IN PIO_WORKITEM_ROUTINE WorkerRoutine, IN WORK_QUEUE_TYPE QueueType, IN PVOID Context)
Definition: iowork.c:40
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
PDEVICE_OBJECT attached_device
Definition: btrfs_drv.h:857
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:737
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IO_NO_INCREMENT
Definition: iotypes.h:581
_In_ SYSTEM_POWER_STATE SystemPowerState
Definition: iotypes.h:7498
void exit(int exitcode)
Definition: _exit.c:33
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014

◆ _In_reads_bytes_()

_In_ PTRANSFER_PACKET _In_ ULONG _In_reads_bytes_ ( Length  )

◆ _IRQL_requires_()

_IRQL_requires_ ( PASSIVE_LEVEL  )

Definition at line 13147 of file class.c.

13175 {
13177 
13178  PAGED_CODE();
13179 
13180  TracePrint((TRACE_LEVEL_VERBOSE,
13181  TRACE_FLAG_PNP,
13182  "ClassDetermineTokenOperationCommandSupport (%p): Entering function.\n",
13183  DeviceObject));
13184 
13185  //
13186  // Send down Inquiry for VPD_THIRD_PARTY_COPY_PAGE and cache away the device parameters
13187  // from WINDOWS_BLOCK_DEVICE_TOKEN_LIMITS_DESCRIPTOR.
13188  //
13190 
13191  if (NT_SUCCESS(status)) {
13192 
13193  ULONG maxListIdentifier = MaxTokenOperationListIdentifier;
13194 
13195  //
13196  // Query the maximum list identifier to use for TokenOperation commands.
13197  //
13198  if (NT_SUCCESS(ClasspGetMaximumTokenListIdentifier(DeviceObject, REG_DISK_CLASS_CONTROL, &maxListIdentifier))) {
13199  if (maxListIdentifier >= MIN_TOKEN_LIST_IDENTIFIERS) {
13200 
13201  NT_ASSERT(maxListIdentifier <= MAX_TOKEN_LIST_IDENTIFIERS);
13202  MaxTokenOperationListIdentifier = maxListIdentifier;
13203  }
13204  }
13205 
13206  }
13207 
13208  TracePrint((TRACE_LEVEL_VERBOSE,
13209  TRACE_FLAG_PNP,
13210  "ClassDetermineTokenOperationCommandSupport (%p): Exiting function with status %x.\n",
13211  DeviceObject,
13212  status));
13213 
13214  return status;
13215 }
LONG NTSTATUS
Definition: precomp.h:26
#define MAX_TOKEN_LIST_IDENTIFIERS
Definition: classp.h:215
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MIN_TOKEN_LIST_IDENTIFIERS
Definition: classp.h:214
#define REG_DISK_CLASS_CONTROL
Definition: classp.h:218
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
unsigned int ULONG
Definition: retypes.h:1
ULONG MaxTokenOperationListIdentifier
Definition: class.c:107
return STATUS_SUCCESS
Definition: btrfs.c:3014
static SERVICE_STATUS status
Definition: service.c:31
_IRQL_requires_same_ NTSTATUS ClasspGetBlockDeviceTokenLimitsInfo(_Inout_ PDEVICE_OBJECT DeviceObject)
Definition: class.c:13220
#define PAGED_CODE()
#define NT_ASSERT
Definition: rtlfuncs.h:3312
Definition: ps.c:97

◆ _IRQL_requires_max_() [1/2]

_IRQL_requires_max_ ( APC_LEVEL  )

Definition at line 197 of file cddata.c.

254 {
255  THREAD_CONTEXT ThreadContext = {0};
256  PIRP_CONTEXT IrpContext = NULL;
257  BOOLEAN Wait;
258 
259 #ifdef CD_SANITY
260  PVOID PreviousTopLevel;
261 #endif
262 
264 
265 #if DBG
266 
267  KIRQL SaveIrql = KeGetCurrentIrql();
268 
269 #endif
270 
272 
274 
276 
277 #ifdef CD_SANITY
278  PreviousTopLevel = IoGetTopLevelIrp();
279 #endif
280 
281  //
282  // Loop until this request has been completed or posted.
283  //
284 
285  do {
286 
287  //
288  // Use a try-except to handle the exception cases.
289  //
290 
291  _SEH2_TRY {
292 
293  //
294  // If the IrpContext is NULL then this is the first pass through
295  // this loop.
296  //
297 
298  if (IrpContext == NULL) {
299 
300  //
301  // Decide if this request is waitable an allocate the IrpContext.
302  // If the file object in the stack location is NULL then this
303  // is a mount which is always waitable. Otherwise we look at
304  // the file object flags.
305  //
306 
308 
309  Wait = TRUE;
310 
311  } else {
312 
313  Wait = CanFsdWait( Irp );
314  }
315 
316  IrpContext = CdCreateIrpContext( Irp, Wait );
317 
318  //
319  // Update the thread context information.
320  //
321 
322  CdSetThreadContext( IrpContext, &ThreadContext );
323 
324 #ifdef CD_SANITY
325  NT_ASSERT( !CdTestTopLevel ||
326  SafeNodeType( IrpContext->TopLevel ) == CDFS_NTC_IRP_CONTEXT );
327 #endif
328 
329  //
330  // Otherwise cleanup the IrpContext for the retry.
331  //
332 
333  } else {
334 
335  //
336  // Set the MORE_PROCESSING flag to make sure the IrpContext
337  // isn't inadvertently deleted here. Then cleanup the
338  // IrpContext to perform the retry.
339  //
340 
341  SetFlag( IrpContext->Flags, IRP_CONTEXT_FLAG_MORE_PROCESSING );
342  CdCleanupIrpContext( IrpContext, FALSE );
343  }
344 
345  //
346  // Case on the major irp code.
347  //
348 
349  switch (IrpContext->MajorFunction) {
350 
351  case IRP_MJ_CREATE :
352 
353  Status = CdCommonCreate( IrpContext, Irp );
354  break;
355 
356  case IRP_MJ_CLOSE :
357 
358  Status = CdCommonClose( IrpContext, Irp );
359  break;
360 
361  case IRP_MJ_READ :
362 
363  //
364  // If this is an Mdl complete request, don't go through
365  // common read.
366  //
367 
368  if (FlagOn( IrpContext->MinorFunction, IRP_MN_COMPLETE )) {
369 
370  Status = CdCompleteMdl( IrpContext, Irp );
371 
372  } else {
373 
374  Status = CdCommonRead( IrpContext, Irp );
375  }
376 
377  break;
378 
379  case IRP_MJ_WRITE :
380 
381  Status = CdCommonWrite( IrpContext, Irp );
382  break;
383 
385 
386  Status = CdCommonQueryInfo( IrpContext, Irp );
387  break;
388 
390 
391  Status = CdCommonSetInfo( IrpContext, Irp );
392  break;
393 
395 
396  Status = CdCommonQueryVolInfo( IrpContext, Irp );
397  break;
398 
400 
401  Status = CdCommonDirControl( IrpContext, Irp );
402  break;
403 
405 
406  Status = CdCommonFsControl( IrpContext, Irp );
407  break;
408 
409  case IRP_MJ_DEVICE_CONTROL :
410 
411  Status = CdCommonDevControl( IrpContext, Irp );
412  break;
413 
414  case IRP_MJ_LOCK_CONTROL :
415 
416  Status = CdCommonLockControl( IrpContext, Irp );
417  break;
418 
419  case IRP_MJ_CLEANUP :
420 
421  Status = CdCommonCleanup( IrpContext, Irp );
422  break;
423 
424  case IRP_MJ_PNP :
425 
426  Status = CdCommonPnp( IrpContext, Irp );
427  break;
428 
429  case IRP_MJ_SHUTDOWN :
430 
431  Status = CdCommonShutdown( IrpContext, Irp );
432  break;
433 
434  default :
435 
437  CdCompleteRequest( IrpContext, Irp, Status );
438  }
439 
441 
442  Status = CdProcessException( IrpContext, Irp, _SEH2_GetExceptionCode() );
443  } _SEH2_END;
444 
445  } while (Status == STATUS_CANT_WAIT);
446 
447 #ifdef CD_SANITY
448  NT_ASSERT( !CdTestTopLevel ||
449  (PreviousTopLevel == IoGetTopLevelIrp()) );
450 #endif
451 
453 
454  NT_ASSERT( SaveIrql == KeGetCurrentIrql( ));
455 
456  return Status;
457 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
VOID CdSetThreadContext(_Inout_ PIRP_CONTEXT IrpContext, _In_ PTHREAD_CONTEXT ThreadContext)
Definition: cddata.c:981
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
#define IRP_MJ_SHUTDOWN
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define IRP_CONTEXT_FLAG_MORE_PROCESSING
Definition: cdstruc.h:1220
#define SafeNodeType(Ptr)
Definition: nodetype.h:54
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
_SEH2_TRY
Definition: create.c:4226
#define IRP_MN_COMPLETE
Definition: iotypes.h:4399
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
VOID CdCompleteRequest(_Inout_opt_ PIRP_CONTEXT IrpContext, _Inout_opt_ PIRP Irp, _In_ NTSTATUS Status)
Definition: cddata.c:914
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:11
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:588
#define IRP_MJ_FILE_SYSTEM_CONTROL
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1843
#define CanFsdWait(I)
Definition: cdprocs.h:2001
NTSTATUS CdCompleteMdl(_In_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: cachesup.c:411
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
Status
Definition: gdiplustypes.h:24
NTSTATUS CdCommonDevControl(_Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: devctrl.c:46
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4400
LONG CdExceptionFilter(_Inout_ PIRP_CONTEXT IrpContext, _In_ PEXCEPTION_POINTERS ExceptionPointer)
Definition: cddata.c:525
#define ASSERT_OPTIONAL_IRP(I)
Definition: cddata.h:252
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
VOID CdCleanupIrpContext(_In_ PIRP_CONTEXT IrpContext, _In_ BOOLEAN Post)
Definition: strucsup.c:1733
NTSTATUS CdCommonLockControl(_Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: lockctrl.c:35
#define CDFS_NTC_IRP_CONTEXT
Definition: nodetype.h:34
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_CLEANUP
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
_Ret_valid_ PIRP_CONTEXT CdCreateIrpContext(_In_ PIRP Irp, _In_ BOOLEAN Wait)
Definition: strucsup.c:1573
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define STATUS_CANT_WAIT
Definition: ntstatus.h:452
IN BOOLEAN Wait
Definition: fatprocs.h:1538
#define NT_ASSERT
Definition: rtlfuncs.h:3312

◆ _IRQL_requires_max_() [2/2]

_IRQL_requires_max_ ( PASSIVE_LEVEL  )

Definition at line 64 of file Messaging.c.

75 {
76  PFLT_SERVER_PORT_OBJECT PortObject;
78 
79  /* The caller must allow at least one connection */
80  if (MaxConnections == 0)
81  {
83  }
84 
85  /* The request must be for a kernel handle */
86  if (!(ObjectAttributes->Attributes & OBJ_KERNEL_HANDLE))
87  {
89  }
90 
91  /*
92  * Get rundown protection on the target to stop the owner
93  * from unloading whilst this port object is open. It gets
94  * removed in the FltpServerPortClose callback
95  */
97  if (!NT_SUCCESS(Status))
98  {
99  return Status;
100  }
101 
102  /* Create the server port object for this filter */
106  KernelMode,
107  NULL,
108  sizeof(FLT_SERVER_PORT_OBJECT),
109  0,
110  0,
111  (PVOID *)&PortObject);
112  if (NT_SUCCESS(Status))
113  {
114  /* Zero out the struct */
115  RtlZeroMemory(PortObject, sizeof(FLT_SERVER_PORT_OBJECT));
116 
117  /* Increment the ref count on the target filter */
119 
120  /* Setup the filter port object */
121  PortObject->Filter = Filter;
122  PortObject->ConnectNotify = ConnectNotifyCallback;
124  PortObject->MessageNotify = MessageNotifyCallback;
125  PortObject->Cookie = ServerPortCookie;
126  PortObject->MaxConnections = MaxConnections;
127 
128  /* Insert the object */
129  Status = ObInsertObject(PortObject,
130  NULL,
132  0,
133  NULL,
135  if (NT_SUCCESS(Status))
136  {
137  /* Lock the connection list */
139 
140  /* Add the new port object to the connection list and increment the count */
143 
144  /* Unlock the connection list*/
146  }
147  }
148 
149  if (!NT_SUCCESS(Status))
150  {
151  /* Allow the filter to be cleaned up */
153  }
154 
155  return Status;
156 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _Outptr_ PFLT_PORT * ServerPort
Definition: fltkernel.h:1873
PFLT_CONNECT_NOTIFY ConnectNotify
Definition: fltmgrint.h:191
VOID FLTAPI FltObjectDereference(_Inout_ PVOID Object)
Definition: Object.c:53
LONG NTSTATUS
Definition: precomp.h:26
#define InsertTailList(ListHead, Entry)
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
ULONG FltpObjectPointerReference(_In_ PFLT_OBJECT Object)
Definition: Object.c:322
LIST_ENTRY mList
Definition: fltmgrint.h:56
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
#define FILE_READ_DATA
Definition: nt_native.h:628
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI ObCreateObject(IN KPROCESSOR_MODE ProbeMode OPTIONAL, IN POBJECT_TYPE Type, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN KPROCESSOR_MODE AccessMode, IN OUT PVOID ParseContext OPTIONAL, IN ULONG ObjectSize, IN ULONG PagedPoolCharge OPTIONAL, IN ULONG NonPagedPoolCharge OPTIONAL, OUT PVOID *Object)
Definition: oblife.c:952
POBJECT_TYPE ServerPortObjectType
Definition: Messaging.c:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY DisconnectNotifyCallback
Definition: fltkernel.h:1873
Status
Definition: gdiplustypes.h:24
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:454
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY ConnectNotifyCallback
Definition: fltkernel.h:1873
NTSTATUS NTAPI ObInsertObject(IN PVOID Object, IN PACCESS_STATE AccessState OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG ObjectPointerBias, OUT PVOID *NewObject OPTIONAL, OUT PHANDLE Handle)
Definition: obhandle.c:2932
#define STANDARD_RIGHTS_ALL
Definition: nt_native.h:69
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
NTSTATUS FLTAPI FltObjectReference(_Inout_ PVOID Object)
Definition: Object.c:41
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID ServerPortCookie
Definition: fltkernel.h:1873
FAST_MUTEX mLock
Definition: fltmgrint.h:55
PFLT_MESSAGE_NOTIFY MessageNotify
Definition: fltmgrint.h:193
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY _In_opt_ PFLT_MESSAGE_NOTIFY _In_ LONG MaxConnections
Definition: fltkernel.h:1873
PFLT_DISCONNECT_NOTIFY DisconnectNotify
Definition: fltmgrint.h:192
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY _In_opt_ PFLT_MESSAGE_NOTIFY MessageNotifyCallback
Definition: fltkernel.h:1873
FLT_MUTEX_LIST_HEAD ConnectionList
Definition: fltmgrint.h:121

◆ AllocateDictionaryEntry()

NTSTATUS AllocateDictionaryEntry ( IN PDICTIONARY  Dictionary,
IN ULONGLONG  Key,
IN ULONG  Size,
IN ULONG  Tag,
OUT PVOID Entry 
)

Referenced by ClasspCreateClose().

◆ BuildDeviceInputMdl()

PMDL BuildDeviceInputMdl ( PVOID  Buffer,
ULONG  BufferLen 
)

Definition at line 609 of file utils.c.

610 {
611  return ClasspBuildDeviceMdl(Buffer, BufferLen, FALSE);
612 }
#define FALSE
Definition: types.h:117
Definition: bufpool.h:45
PMDL ClasspBuildDeviceMdl(PVOID Buffer, ULONG BufferLen, BOOLEAN WriteToDevice)
Definition: utils.c:582

Referenced by ClasspModeSelect(), ClasspModeSense(), and ClassReadDriveCapacity().

◆ C_ASSERT()

◆ ClassAddChild()

VOID ClassAddChild ( _In_ PFUNCTIONAL_DEVICE_EXTENSION  Parent,
_In_ PPHYSICAL_DEVICE_EXTENSION  Child,
_In_ BOOLEAN  AcquireLock 
)

Definition at line 12058 of file class.c.

12063 {
12064  if(AcquireLock) {
12065  ClassAcquireChildLock(Parent);
12066  }
12067 
12068  #if DBG
12069  //
12070  // Make sure this child's not already in the list.
12071  //
12072  {
12073  PPHYSICAL_DEVICE_EXTENSION testChild;
12074 
12075  for (testChild = Parent->CommonExtension.ChildList;
12076  testChild != NULL;
12077  testChild = testChild->CommonExtension.ChildList) {
12078 
12079  NT_ASSERT(testChild != Child);
12080  }
12081  }
12082  #endif
12083 
12084  Child->CommonExtension.ChildList = Parent->CommonExtension.ChildList;
12085  Parent->CommonExtension.ChildList = Child;
12086 
12087  if(AcquireLock) {
12089  }
12090  return;
12091 } // end ClassAddChild()
COMMON_DEVICE_EXTENSION CommonExtension
Definition: classpnp.h:652
VOID NTAPI ClassReleaseChildLock(_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: class.c:12019
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:728
smooth NULL
Definition: ftsmooth.c:416
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE Child
Definition: acpixf.h:728
#define NT_ASSERT
Definition: rtlfuncs.h:3312

◆ ClassDeviceGetLBProvisioningResources()

NTSTATUS ClassDeviceGetLBProvisioningResources ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp,
_Inout_ PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 5087 of file utils.c.

5113 {
5114  NTSTATUS status;
5116  PSTORAGE_LB_PROVISIONING_MAP_RESOURCES mapResources = (PSTORAGE_LB_PROVISIONING_MAP_RESOURCES)Irp->AssociatedIrp.SystemBuffer;
5117 
5119  Srb,
5120  irpStack->Parameters.DeviceIoControl.OutputBufferLength,
5121  mapResources);
5122 
5123  if (NT_SUCCESS(status)) {
5124  Irp->IoStatus.Information = mapResources->Size;
5125  } else {
5126  Irp->IoStatus.Information = 0;
5127  }
5128 
5129  Irp->IoStatus.Status = status;
5132 
5133  return status;
5134 }
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS ClassGetLBProvisioningResources(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PSCSI_REQUEST_BLOCK Srb, _In_ ULONG ResourcesSize, _Inout_ PSTORAGE_LB_PROVISIONING_MAP_RESOURCES Resources)
Definition: utils.c:4958
VOID NTAPI ClassReleaseRemoveLock(_In_ PDEVICE_OBJECT DeviceObject, _In_opt_ PIRP Tag)
Definition: lock.c:251
struct _STORAGE_LB_PROVISIONING_MAP_RESOURCES * PSTORAGE_LB_PROVISIONING_MAP_RESOURCES
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define IO_NO_INCREMENT
Definition: iotypes.h:581
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
VOID NTAPI ClassCompleteRequest(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ CCHAR PriorityBoost)
Definition: lock.c:401
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by ClassDeviceControl().

◆ ClassDeviceHwFirmwareActivateProcess()

NTSTATUS ClassDeviceHwFirmwareActivateProcess ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp,
_Inout_ PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 8900 of file utils.c.

8905 {
8907 
8908 #if (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)
8909 
8910  PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension;
8911  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = DeviceObject->DeviceExtension;
8912 
8914  PSTORAGE_HW_FIRMWARE_ACTIVATE firmwareActivate = (PSTORAGE_HW_FIRMWARE_ACTIVATE)Irp->AssociatedIrp.SystemBuffer;
8915  BOOLEAN passDown = FALSE;
8916  PCDB cdb = NULL;
8917  ULONG i;
8918  BOOLEAN lockHeld = FALSE;
8919  KLOCK_QUEUE_HANDLE lockHandle;
8920 
8921 
8922  //
8923  // Input buffer is not big enough to contain required input information.
8924  //
8925  if (irpStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(STORAGE_HW_FIRMWARE_ACTIVATE)) {
8926 
8928  goto Exit_Firmware_Activate;
8929  }
8930 
8931  //
8932  // Input buffer basic validation.
8933  //
8934  if ((firmwareActivate->Version < sizeof(STORAGE_HW_FIRMWARE_ACTIVATE)) ||
8935  (firmwareActivate->Size > irpStack->Parameters.DeviceIoControl.InputBufferLength)) {
8936 
8938  goto Exit_Firmware_Activate;
8939  }
8940 
8941  //
8942  // Only process the request for a supported port driver.
8943  //
8946  goto Exit_Firmware_Activate;
8947  }
8948 
8949  //
8950  // Buffer "FunctionSupportInfo" is allocated during start device process. Following check defends against the situation
8951  // of receiving this IOCTL when the device is created but not started, or device start failed but did not get removed yet.
8952  //
8953  if (commonExtension->IsFdo && (fdoExtension->FunctionSupportInfo == NULL)) {
8954 
8956  goto Exit_Firmware_Activate;
8957  }
8958 
8959  //
8960  // Process the situation that request should be forwarded to lower level.
8961  //
8962  if (!commonExtension->IsFdo) {
8963  passDown = TRUE;
8964  }
8965 
8966  if ((firmwareActivate->Flags & STORAGE_HW_FIRMWARE_REQUEST_FLAG_CONTROLLER) != 0) {
8967  passDown = TRUE;
8968  }
8969 
8970  if (passDown) {
8971 
8973 
8975  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8976  FREE_POOL(Srb);
8977  return status;
8978  }
8979 
8980  //
8981  // If firmware information hasn't been cached in classpnp, retrieve it.
8982  //
8983  if (fdoExtension->FunctionSupportInfo->HwFirmwareInfo == NULL) {
8984  if (fdoExtension->FunctionSupportInfo->HwFirmwareGetInfoSupport == NotSupported) {
8986  goto Exit_Firmware_Activate;
8987  } else {
8988  //
8989  // If this is the first time of retrieving firmware information,
8990  // send request to lower level to get it.
8991  //
8993 
8994  if (!NT_SUCCESS(status)) {
8995  goto Exit_Firmware_Activate;
8996  }
8997  }
8998  }
8999 
9000  //
9001  // Fail the request if the firmware information cannot be retrieved.
9002  //
9003  if (fdoExtension->FunctionSupportInfo->HwFirmwareInfo == NULL) {
9004  if (fdoExtension->FunctionSupportInfo->HwFirmwareGetInfoSupport == NotSupported) {
9006  } else {
9008  }
9009 
9010  goto Exit_Firmware_Activate;
9011  }
9012 
9013  //
9014  // Acquire the SyncLock to ensure the HwFirmwareInfo pointer doesn't change
9015  // while we're dereferencing it.
9016  //
9017  lockHeld = TRUE;
9018  KeAcquireInStackQueuedSpinLock(&fdoExtension->FunctionSupportInfo->SyncLock, &lockHandle);
9019 
9020  //
9021  // Validate the device support
9022  //
9023  if (fdoExtension->FunctionSupportInfo->HwFirmwareInfo->SupportUpgrade == FALSE) {
9025  goto Exit_Firmware_Activate;
9026  }
9027 
9028  //
9029  // Check if the slot number is valid.
9030  //
9031  for (i = 0; i < fdoExtension->FunctionSupportInfo->HwFirmwareInfo->SlotCount; i++) {
9032  if (fdoExtension->FunctionSupportInfo->HwFirmwareInfo->Slot[i].SlotNumber == firmwareActivate->Slot) {
9033  break;
9034  }
9035  }
9036 
9037  if (i >= fdoExtension->FunctionSupportInfo->HwFirmwareInfo->SlotCount) {
9038  //
9039  // Either the slot number is out of scope or the slot is read-only.
9040  //
9042  goto Exit_Firmware_Activate;
9043  }
9044 
9045  //
9046  // We're done accessing HwFirmwareInfo at this point so we can release
9047  // the SyncLock.
9048  //
9049  NT_ASSERT(lockHeld);
9050  KeReleaseInStackQueuedSpinLock(&lockHandle);
9051  lockHeld = FALSE;
9052 
9053  //
9054  // Process the request by translating it into WRITE BUFFER command.
9055  //
9056  //
9057  // Setup the CDB. This should be an untagged request.
9058  //
9060  cdb = SrbGetCdb(Srb);
9061  cdb->WRITE_BUFFER.OperationCode = SCSIOP_WRITE_DATA_BUFF;
9062  cdb->WRITE_BUFFER.Mode = SCSI_WRITE_BUFFER_MODE_ACTIVATE_DEFERRED_MICROCODE;
9063  cdb->WRITE_BUFFER.ModeSpecific = 0; //Reserved for Mode 0x0F
9064  cdb->WRITE_BUFFER.BufferID = firmwareActivate->Slot; //NOTE: this field will be ignored by SCSI device.
9065 
9066  //
9067  // Set timeout value.
9068  //
9070 
9071  //
9072  // This routine uses a completion routine - ClassIoComplete() so we don't want to release
9073  // the remove lock until then.
9074  //
9076  Srb,
9077  Irp,
9078  NULL,
9079  0,
9080  FALSE);
9081 
9082  if (status != STATUS_PENDING) {
9083  //
9084  // If the irp cannot be sent down, the Srb has been freed. NULL it to prevent from freeing it again.
9085  //
9086  Srb = NULL;
9087 
9088  goto Exit_Firmware_Activate;
9089  }
9090 
9091  return status;
9092 
9093 Exit_Firmware_Activate:
9094 
9095  //
9096  // Release the SyncLock if it's still held.
9097  // This should only happen in the failure path.
9098  //
9099  if (lockHeld) {
9100  KeReleaseInStackQueuedSpinLock(&lockHandle);
9101  lockHeld = FALSE;
9102  }
9103 
9104  //
9105  // Firmware Activate request will be failed.
9106  //
9108 
9109  Irp->IoStatus.Status = status;
9110 
9111 #else
9113  Irp->IoStatus.Status = status;
9114 #endif // #if (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)
9115 
9118 
9119  FREE_POOL(Srb);
9120  return status;
9121 }
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define SCSIOP_WRITE_DATA_BUFF
Definition: cdrw_hw.h:922
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
Definition: cdrw_hw.h:28
LONG NTSTATUS
Definition: precomp.h:26
FORCEINLINE PCDB SrbGetCdb(_In_ PVOID Srb)
Definition: srbhelper.h:583
VOID FASTCALL KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:130
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2864
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FALSE
Definition: types.h:117
#define FREE_POOL(_PoolPtr)
Definition: cdrom.h:782
unsigned char BOOLEAN
VOID NTAPI ClassReleaseRemoveLock(_In_ PDEVICE_OBJECT DeviceObject, _In_opt_ PIRP Tag)
Definition: lock.c:251
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE VOID SrbSetCdbLength(_In_ PVOID Srb, _In_ UCHAR CdbLength)
Definition: srbhelper.h:1093
VOID FASTCALL KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:166
#define FIRMWARE_ACTIVATE_TIMEOUT_VALUE
Definition: utils.c:37
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
FORCEINLINE VOID SrbSetTimeOutValue(_In_ PVOID Srb, _In_ ULONG TimeOutValue)
Definition: srbhelper.h:821
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
__inline BOOLEAN ClassDeviceHwFirmwareIsPortDriverSupported(_In_ PDEVICE_OBJECT DeviceObject)
Definition: utils.c:8329
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
NTSTATUS ClasspGetHwFirmwareInfo(_In_ PDEVICE_OBJECT DeviceObject)
Definition: utils.c:8190
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
PDEVICE_OBJECT LowerDeviceObject
Definition: classpnp.h:598
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:581
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
SCSIPORT_API NTSTATUS NTAPI ClassSendSrbAsynchronous(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PSCSI_REQUEST_BLOCK Srb, _In_ PIRP Irp, _In_reads_bytes_opt_(BufferLength) __drv_aliasesMem PVOID BufferAddress, _In_ ULONG BufferLength, _In_ BOOLEAN WriteToDevice)
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014
VOID NTAPI ClassCompleteRequest(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ CCHAR PriorityBoost)
Definition: lock.c:401
static SERVICE_STATUS status
Definition: service.c:31
#define CDB10GENERIC_LENGTH
Definition: cdrw_hw.h:831
#define NT_ASSERT
Definition: rtlfuncs.h:3312
Definition: ps.c:97

Referenced by ClassDeviceControl().

◆ ClassDeviceHwFirmwareDownloadProcess()

NTSTATUS ClassDeviceHwFirmwareDownloadProcess ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp,
_Inout_ PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 8539 of file utils.c.

8544 {
8546 
8547 #if (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)
8548 
8549  PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension;
8550  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = DeviceObject->DeviceExtension;
8551 
8553  PSTORAGE_HW_FIRMWARE_DOWNLOAD firmwareDownload = (PSTORAGE_HW_FIRMWARE_DOWNLOAD)Irp->AssociatedIrp.SystemBuffer;
8554  BOOLEAN passDown = FALSE;
8555  ULONG i;
8556  ULONG bufferSize = 0;
8557  PUCHAR firmwareImageBuffer = NULL;
8558  PIRP irp2 = NULL;
8559  PIO_STACK_LOCATION newStack = NULL;
8560  PCDB cdb = NULL;
8561  BOOLEAN lockHeld = FALSE;
8562  KLOCK_QUEUE_HANDLE lockHandle;
8563 
8564 
8565  //
8566  // Input buffer is not big enough to contain required input information.
8567  //
8568  if (irpStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(STORAGE_HW_FIRMWARE_DOWNLOAD)) {
8569 
8571  goto Exit_Firmware_Download;
8572  }
8573 
8574  //
8575  // Input buffer basic validation.
8576  //
8577  if ((firmwareDownload->Version < sizeof(STORAGE_HW_FIRMWARE_DOWNLOAD)) ||
8578  (firmwareDownload->Size > irpStack->Parameters.DeviceIoControl.InputBufferLength) ||
8579  ((firmwareDownload->BufferSize + FIELD_OFFSET(STORAGE_HW_FIRMWARE_DOWNLOAD, ImageBuffer)) > firmwareDownload->Size)) {
8580 
8582  goto Exit_Firmware_Download;
8583  }
8584 
8585  //
8586  // Only process the request for a supported port driver.
8587  //
8590  goto Exit_Firmware_Download;
8591  }
8592 
8593  //
8594  // Buffer "FunctionSupportInfo" is allocated during start device process. Following check defends against the situation
8595  // of receiving this IOCTL when the device is created but not started, or device start failed but did not get removed yet.
8596  //
8597  if (commonExtension->IsFdo && (fdoExtension->FunctionSupportInfo == NULL)) {
8598 
8600  goto Exit_Firmware_Download;
8601  }
8602 
8603  //
8604  // Process the situation that request should be forwarded to lower level.
8605  //
8606  if (!commonExtension->IsFdo) {
8607  passDown = TRUE;
8608  }
8609 
8610  if ((firmwareDownload->Flags & STORAGE_HW_FIRMWARE_REQUEST_FLAG_CONTROLLER) != 0) {
8611  passDown = TRUE;
8612  }
8613 
8614  if (passDown) {
8615 
8617 
8619  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8620  FREE_POOL(Srb);
8621  return status;
8622  }
8623 
8624  //
8625  // If firmware information hasn't been cached in classpnp, retrieve it.
8626  //
8627  if (fdoExtension->FunctionSupportInfo->HwFirmwareInfo == NULL) {
8628  if (fdoExtension->FunctionSupportInfo->HwFirmwareGetInfoSupport == NotSupported) {
8630  goto Exit_Firmware_Download;
8631  } else {
8632  //
8633  // If this is the first time of retrieving firmware information,
8634  // send request to lower level to get it.
8635  //
8637 
8638  if (!NT_SUCCESS(status)) {
8639  goto Exit_Firmware_Download;
8640  }
8641  }
8642  }
8643 
8644  //
8645  // Fail the request if the firmware information cannot be retrieved.
8646  //
8647  if (fdoExtension->FunctionSupportInfo->HwFirmwareInfo == NULL) {
8648  if (fdoExtension->FunctionSupportInfo->HwFirmwareGetInfoSupport == NotSupported) {
8650  } else {
8652  }
8653 
8654  goto Exit_Firmware_Download;
8655  }
8656 
8657  //
8658  // Acquire the SyncLock to ensure the HwFirmwareInfo pointer doesn't change
8659  // while we're dereferencing it.
8660  //
8661  lockHeld = TRUE;
8662  KeAcquireInStackQueuedSpinLock(&fdoExtension->FunctionSupportInfo->SyncLock, &lockHandle);
8663 
8664  //
8665  // Validate the device support
8666  //
8667  if ((fdoExtension->FunctionSupportInfo->HwFirmwareInfo->SupportUpgrade == FALSE) ||
8668  (fdoExtension->FunctionSupportInfo->HwFirmwareInfo->ImagePayloadAlignment == 0)) {
8670  goto Exit_Firmware_Download;
8671  }
8672 
8673  //
8674  // Check if the slot can be used to hold firmware image.
8675  //
8676  for (i = 0; i < fdoExtension->FunctionSupportInfo->HwFirmwareInfo->SlotCount; i++) {
8677  if (fdoExtension->FunctionSupportInfo->HwFirmwareInfo->Slot[i].SlotNumber == firmwareDownload->Slot) {
8678  break;
8679  }
8680  }
8681 
8682  if ((i >= fdoExtension->FunctionSupportInfo->HwFirmwareInfo->SlotCount) ||
8683  (fdoExtension->FunctionSupportInfo->HwFirmwareInfo->Slot[i].ReadOnly == TRUE)) {
8684  //
8685  // Either the slot number is out of scope or the slot is read-only.
8686  //
8688  goto Exit_Firmware_Download;
8689  }
8690 
8691  //
8692  // Buffer size and alignment validation.
8693  // Max Offset and Buffer Size can be represented by SCSI command is max value for 3 bytes.
8694  //
8695  if ((firmwareDownload->BufferSize == 0) ||
8696  ((firmwareDownload->BufferSize % fdoExtension->FunctionSupportInfo->HwFirmwareInfo->ImagePayloadAlignment) != 0) ||
8697  (firmwareDownload->BufferSize > fdoExtension->FunctionSupportInfo->HwFirmwareInfo->ImagePayloadMaxSize) ||
8698  (firmwareDownload->BufferSize > fdoExtension->AdapterDescriptor->MaximumTransferLength) ||
8699  ((firmwareDownload->Offset % fdoExtension->FunctionSupportInfo->HwFirmwareInfo->ImagePayloadAlignment) != 0) ||
8700  (firmwareDownload->Offset > 0xFFFFFF) ||
8701  (firmwareDownload->BufferSize > 0xFFFFFF)) {
8702 
8704  goto Exit_Firmware_Download;
8705  }
8706 
8707 
8708  //
8709  // Process the request by translating it into WRITE BUFFER command.
8710  //
8711  if (((ULONG_PTR)firmwareDownload->ImageBuffer % fdoExtension->FunctionSupportInfo->HwFirmwareInfo->ImagePayloadAlignment) != 0) {
8712  //
8713  // Allocate buffer aligns to ImagePayloadAlignment to accommodate the alignment requirement.
8714  //
8715  bufferSize = ALIGN_UP_BY(firmwareDownload->BufferSize, fdoExtension->FunctionSupportInfo->HwFirmwareInfo->ImagePayloadAlignment);
8716 
8717  //
8718  // We're done accessing HwFirmwareInfo at this point so we can release
8719  // the SyncLock.
8720  //
8721  NT_ASSERT(lockHeld);
8722  KeReleaseInStackQueuedSpinLock(&lockHandle);
8723  lockHeld = FALSE;
8724 
8725 #ifdef _MSC_VER
8726 #pragma prefast(suppress:6014, "The allocated memory that firmwareImageBuffer points to will be freed in ClassHwFirmwareDownloadComplete().")
8727 #endif
8728  firmwareImageBuffer = ExAllocatePoolWithTag(NonPagedPoolNx, bufferSize, CLASSPNP_POOL_TAG_FIRMWARE);
8729 
8730  if (firmwareImageBuffer == NULL) {
8732  goto Exit_Firmware_Download;
8733  }
8734 
8735  RtlZeroMemory(firmwareImageBuffer, bufferSize);
8736 
8737  RtlCopyMemory(firmwareImageBuffer, firmwareDownload->ImageBuffer, (ULONG)firmwareDownload->BufferSize);
8738 
8739  } else {
8740  NT_ASSERT(lockHeld);
8741  KeReleaseInStackQueuedSpinLock(&lockHandle);
8742  lockHeld = FALSE;
8743 
8744  firmwareImageBuffer = firmwareDownload->ImageBuffer;
8745  bufferSize = (ULONG)firmwareDownload->BufferSize;
8746  }
8747 
8748  //
8749  // Allocate a new irp to send the WRITE BUFFER command down.
8750  // Similar process as IOCTL_STORAGE_CHECK_VERIFY.
8751  //
8752  irp2 = IoAllocateIrp((CCHAR)(DeviceObject->StackSize + 3), FALSE);
8753 
8754  if (irp2 == NULL) {
8756 
8757  if (firmwareImageBuffer != firmwareDownload->ImageBuffer) {
8758  FREE_POOL(firmwareImageBuffer);
8759  }
8760 
8761  goto Exit_Firmware_Download;
8762  }
8763 
8764  //
8765  // Make sure to acquire the lock for the new irp.
8766  //
8768 
8769  irp2->Tail.Overlay.Thread = Irp->Tail.Overlay.Thread;
8771 
8772  //
8773  // Set the top stack location and shove the master Irp into the
8774  // top location
8775  //
8776  newStack = IoGetCurrentIrpStackLocation(irp2);
8777  newStack->Parameters.Others.Argument1 = Irp;
8778  newStack->DeviceObject = DeviceObject;
8779 
8780  //
8781  // Stick the firmware download completion routine onto the stack
8782  // and prepare the irp for the port driver
8783  //
8785  ClassHwFirmwareDownloadComplete,
8786  (firmwareImageBuffer != firmwareDownload->ImageBuffer) ? firmwareImageBuffer : NULL,
8787  TRUE,
8788  TRUE,
8789  TRUE);
8790 
8792  newStack = IoGetCurrentIrpStackLocation(irp2);
8793  newStack->DeviceObject = DeviceObject;
8794  newStack->MajorFunction = irpStack->MajorFunction;
8795  newStack->MinorFunction = irpStack->MinorFunction;
8796  newStack->Flags = irpStack->Flags;
8797 
8798 
8799  //
8800  // Mark the master irp as pending - whether the lower level
8801  // driver completes it immediately or not this should allow it
8802  // to go all the way back up.
8803  //
8805 
8806  //
8807  // Setup the CDB.
8808  //
8810  cdb = SrbGetCdb(Srb);
8811  cdb->WRITE_BUFFER.OperationCode = SCSIOP_WRITE_DATA_BUFF;
8812  cdb->WRITE_BUFFER.Mode = SCSI_WRITE_BUFFER_MODE_DOWNLOAD_MICROCODE_WITH_OFFSETS_SAVE_DEFER_ACTIVATE;
8813  cdb->WRITE_BUFFER.ModeSpecific = 0; //Reserved for Mode 0x0E
8814  cdb->WRITE_BUFFER.BufferID = firmwareDownload->Slot;
8815 
8816  cdb->WRITE_BUFFER.BufferOffset[0] = *((PCHAR)&firmwareDownload->Offset + 2);
8817  cdb->WRITE_BUFFER.BufferOffset[1] = *((PCHAR)&firmwareDownload->Offset + 1);
8818  cdb->WRITE_BUFFER.BufferOffset[2] = *((PCHAR)&firmwareDownload->Offset);
8819 
8820  cdb->WRITE_BUFFER.ParameterListLength[0] = *((PCHAR)&bufferSize + 2);
8821  cdb->WRITE_BUFFER.ParameterListLength[1] = *((PCHAR)&bufferSize + 1);
8822  cdb->WRITE_BUFFER.ParameterListLength[2] = *((PCHAR)&bufferSize);
8823 
8824  //
8825  // Send as a tagged command.
8826  //
8829 
8830  //
8831  // Set timeout value.
8832  //
8833  SrbSetTimeOutValue(Srb, fdoExtension->TimeOutValue);
8834 
8835  //
8836  // This routine uses a completion routine so we don't want to release
8837  // the remove lock until then.
8838  //
8840  Srb,
8841  irp2,
8842  firmwareImageBuffer,
8843  bufferSize,
8844  TRUE);
8845 
8846  if (status != STATUS_PENDING) {
8847  //
8848  // If the new irp cannot be sent down, free allocated memory and bail out.
8849  //
8850  if (firmwareImageBuffer != firmwareDownload->ImageBuffer) {
8851  FREE_POOL(firmwareImageBuffer);
8852  }
8853 
8854  //
8855  // If the irp cannot be sent down, the Srb has been freed. NULL it to prevent from freeing it again.
8856  //
8857  Srb = NULL;
8858 
8860 
8861  IoFreeIrp(irp2);
8862 
8863  goto Exit_Firmware_Download;
8864  }
8865 
8866  return status;
8867 
8868 Exit_Firmware_Download:
8869 
8870  //
8871  // Release the SyncLock if it's still held.
8872  // This should only happen in the failure path.
8873  //
8874  if (lockHeld) {
8875  KeReleaseInStackQueuedSpinLock(&lockHandle);
8876  lockHeld = FALSE;
8877  }
8878 
8879  //
8880  // Firmware Download request will be failed.
8881  //
8883 
8884  Irp->IoStatus.Status = status;
8885 
8886 #else
8888  Irp->IoStatus.Status = status;
8889 #endif // #if (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)
8890 
8893 
8894  FREE_POOL(Srb);
8895 
8896  return status;
8897 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define ClassAcquireRemoveLock(devobj, tag)
Definition: classpnp.h:100
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define SCSIOP_WRITE_DATA_BUFF
Definition: cdrw_hw.h:922
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
_In_ PIRP Irp
Definition: csq.h:116
#define SRB_FLAGS_NO_QUEUE_FREEZE
Definition: srb.h:396
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
unsigned char * PUCHAR
Definition: retypes.h:3
Definition: cdrw_hw.h:28
LONG NTSTATUS
Definition: precomp.h:26
#define CLASSPNP_POOL_TAG_FIRMWARE
Definition: classp.h:198
FORCEINLINE PCDB SrbGetCdb(_In_ PVOID Srb)
Definition: srbhelper.h:583
VOID FASTCALL KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:130
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:498
uint32_t ULONG_PTR
Definition: typedefs.h:65
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2864
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FALSE
Definition: types.h:117
#define FREE_POOL(_PoolPtr)
Definition: cdrom.h:782
unsigned char BOOLEAN
VOID NTAPI ClassReleaseRemoveLock(_In_ PDEVICE_OBJECT DeviceObject, _In_opt_ PIRP Tag)
Definition: lock.c:251
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE VOID SrbSetCdbLength(_In_ PVOID Srb, _In_ UCHAR CdbLength)
Definition: srbhelper.h:1093
#define PCHAR
Definition: match.c:90
VOID FASTCALL KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:166
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
char CCHAR
Definition: typedefs.h:51
FORCEINLINE VOID SrbSetTimeOutValue(_In_ PVOID Srb, _In_ ULONG TimeOutValue)
Definition: srbhelper.h:821
PSTORAGE_ADAPTER_DESCRIPTOR AdapterDescriptor
Definition: classpnp.h:877
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
__inline BOOLEAN ClassDeviceHwFirmwareIsPortDriverSupported(_In_ PDEVICE_OBJECT DeviceObject)
Definition: utils.c:8329
FORCEINLINE VOID SrbSetRequestAttribute(_In_ PVOID Srb, _In_ UCHAR RequestAttribute)
Definition: srbhelper.h:1131
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
NTSTATUS ClasspGetHwFirmwareInfo(_In_ PDEVICE_OBJECT DeviceObject)
Definition: utils.c:8190
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
PDEVICE_OBJECT LowerDeviceObject
Definition: classpnp.h:598
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define SRB_HEAD_OF_QUEUE_TAG_REQUEST
Definition: srb.h:416
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:581
FORCEINLINE VOID SrbSetSrbFlags(_In_ PVOID Srb, _In_ ULONG Flags)
Definition: srbhelper.h:964
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ALIGN_UP_BY(size, align)
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
SCSIPORT_API NTSTATUS NTAPI ClassSendSrbAsynchronous(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PSCSI_REQUEST_BLOCK Srb, _In_ PIRP Irp, _In_reads_bytes_opt_(BufferLength) __drv_aliasesMem PVOID BufferAddress, _In_ ULONG BufferLength, _In_ BOOLEAN WriteToDevice)
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014
IoMarkIrpPending(Irp)
VOID NTAPI ClassCompleteRequest(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ CCHAR PriorityBoost)
Definition: lock.c:401
static SERVICE_STATUS status
Definition: service.c:31
FORCEINLINE VOID IoSetNextIrpStackLocation(_Inout_ PIRP Irp)
Definition: iofuncs.h:2676
#define CDB10GENERIC_LENGTH
Definition: cdrw_hw.h:831
#define SRB_FLAGS_QUEUE_ACTION_ENABLE
Definition: srb.h:387
#define NT_ASSERT
Definition: rtlfuncs.h:3312
Definition: ps.c:97

Referenced by ClassDeviceControl().

◆ ClassDeviceHwFirmwareGetInfoProcess()

NTSTATUS ClassDeviceHwFirmwareGetInfoProcess ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp 
)

Definition at line 8364 of file utils.c.

8383 {
8385 
8386 #if (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)
8387 
8388  PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension;
8389  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = DeviceObject->DeviceExtension;
8391  PSTORAGE_HW_FIRMWARE_INFO_QUERY query = (PSTORAGE_HW_FIRMWARE_INFO_QUERY)Irp->AssociatedIrp.SystemBuffer;
8392  BOOLEAN passDown = FALSE;
8393  BOOLEAN copyData = FALSE;
8394 
8395 
8396  //
8397  // Input buffer is not big enough to contain required input information.
8398  //
8399  if (irpStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(STORAGE_HW_FIRMWARE_INFO_QUERY)) {
8400 
8402  goto Exit_Firmware_Get_Info;
8403  }
8404 
8405  //
8406  // Output buffer is too small to contain return data.
8407  //
8408  if (irpStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(STORAGE_HW_FIRMWARE_INFO)) {
8409 
8411  goto Exit_Firmware_Get_Info;
8412  }
8413 
8414  //
8415  // Only process the request for a supported port driver.
8416  //
8419  goto Exit_Firmware_Get_Info;
8420  }
8421 
8422  //
8423  // Buffer "FunctionSupportInfo" is allocated during start device process. Following check defends against the situation
8424  // of receiving this IOCTL when the device is created but not started, or device start failed but did not get removed yet.
8425  //
8426  if (commonExtension->IsFdo && (fdoExtension->FunctionSupportInfo == NULL)) {
8427 
8429  goto Exit_Firmware_Get_Info;
8430  }
8431 
8432  //
8433  // Process the situation that request should be forwarded to lower level.
8434  //
8435  if (!commonExtension->IsFdo) {
8436  passDown = TRUE;
8437  }
8438 
8439  if ((query->Flags & STORAGE_HW_FIRMWARE_REQUEST_FLAG_CONTROLLER) != 0) {
8440  passDown = TRUE;
8441  }
8442 
8443  if (passDown) {
8444 
8446 
8448  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8449  return status;
8450  }
8451 
8452  //
8453  // The request is for a FDO. Process the request.
8454  //
8455  if (fdoExtension->FunctionSupportInfo->HwFirmwareGetInfoSupport == NotSupported) {
8457  goto Exit_Firmware_Get_Info;
8458  } else {
8459  //
8460  // Retrieve information from lower layer for the request. The cached information is not used
8461  // in case device firmware information changed.
8462  //
8464  copyData = NT_SUCCESS(status);
8465  }
8466 
8467 Exit_Firmware_Get_Info:
8468 
8469  if (copyData) {
8470  //
8471  // Firmware information is already cached in classpnp. Return a copy.
8472  //
8473  KLOCK_QUEUE_HANDLE lockHandle;
8474  KeAcquireInStackQueuedSpinLock(&fdoExtension->FunctionSupportInfo->SyncLock, &lockHandle);
8475 
8476  ULONG dataLength = min(irpStack->Parameters.DeviceIoControl.OutputBufferLength, fdoExtension->FunctionSupportInfo->HwFirmwareInfo->Size);
8477 
8478  memcpy(Irp->AssociatedIrp.SystemBuffer, fdoExtension->FunctionSupportInfo->HwFirmwareInfo, dataLength);
8479 
8480  KeReleaseInStackQueuedSpinLock(&lockHandle);
8481 
8482  Irp->IoStatus.Information = dataLength;
8483  }
8484 
8485  Irp->IoStatus.Status = status;
8486 
8487 #else
8489  Irp->IoStatus.Status = status;
8490 #endif // #if (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)
8491 
8494 
8495  return status;
8496 }