ReactOS 0.4.15-dev-6680-g8c76870
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)
 
FORCEINLINE VOID SimpleInitSlistHdr (SINGLE_LIST_ENTRY *SListHdr)
 
FORCEINLINE VOID SimplePushSlist (SINGLE_LIST_ENTRY *SListHdr, SINGLE_LIST_ENTRY *SListEntry)
 
FORCEINLINE SINGLE_LIST_ENTRYSimplePopSlist (SINGLE_LIST_ENTRY *SListHdr)
 
FORCEINLINE BOOLEAN SimpleIsSlistEmpty (SINGLE_LIST_ENTRY *SListHdr)
 
FORCEINLINE BOOLEAN ClasspIsIdleRequestSupported (PCLASS_PRIVATE_FDO_DATA FdoData, PIRP Irp)
 
FORCEINLINE VOID ClasspMarkIrpAsIdle (PIRP Irp, BOOLEAN Idle)
 
FORCEINLINE BOOLEAN ClasspIsIdleRequest (PIRP Irp)
 
FORCEINLINE LARGE_INTEGER ClasspGetCurrentTime (VOID)
 
FORCEINLINE ULONGLONG ClasspTimeDiffToMs (ULONGLONG TimeDiff)
 
FORCEINLINE BOOLEAN ClasspSupportsUnmap (_In_ PCLASS_FUNCTION_SUPPORT_INFO SupportInfo)
 
FORCEINLINE BOOLEAN ClasspIsThinProvisioned (_In_ PCLASS_FUNCTION_SUPPORT_INFO SupportInfo)
 
FORCEINLINE 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)
 
FORCEINLINE BOOLEAN ClasspIsTokenOperationComplete (_In_ ULONG CurrentStatus)
 
FORCEINLINE BOOLEAN ClasspIsTokenOperation (_In_ PCDB Cdb)
 
FORCEINLINE BOOLEAN ClasspIsReceiveTokenInformation (_In_ PCDB Cdb)
 
FORCEINLINE 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)
 
FORCEINLINE PCDB ClasspTransferPacketGetCdb (_In_ PTRANSFER_PACKET Pkt)
 
FORCEINLINE BOOLEAN ClasspTransferPacketGetNumberOfRetriesDone (_In_ PTRANSFER_PACKET Pkt, _In_ PCDB Cdb, _Out_ PULONG TimesAlreadyRetried)
 
FORCEINLINE PVOID ClasspTransferPacketGetSenseInfoBuffer (_In_ PTRANSFER_PACKET Pkt)
 
FORCEINLINE UCHAR ClasspTransferPacketGetSenseInfoBufferLength (_In_ PTRANSFER_PACKET Pkt)
 
FORCEINLINE VOID ClasspSrbSetOriginalIrp (_In_ PSTORAGE_REQUEST_BLOCK_HEADER Srb, _In_ PIRP Irp)
 
FORCEINLINE BOOLEAN PORT_ALLOCATED_SENSE_EX (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _In_ PSTORAGE_REQUEST_BLOCK_HEADER Srb)
 
FORCEINLINE 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)
 
FORCEINLINE ULONG ClasspGetMaxUsableBufferLengthFromOffset (_In_ PVOID BaseAddress, _In_ ULONG OffsetInBytes, _In_ ULONG BaseStructureSizeInBytes)
 
BOOLEAN ClasspIsThinProvisioningError (_In_ PSCSI_REQUEST_BLOCK _Srb)
 
FORCEINLINE 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) \
)
CONST LARGE_INTEGER Magic10000
Definition: class.c:89
#define SHIFT10000
Definition: classp.h:246

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 \
); \
} \
}
#define NULL
Definition: types.h:112

Definition at line 2330 of file classp.h.

◆ HISTORYLOGRETURNEDPACKET

#define HISTORYLOGRETURNEDPACKET (   _packet)
Value:
{ \
if (_packet->RetryHistory != NULL) { \
HistoryLogReturnedPacket(_packet); \
} \
}

Definition at line 2357 of file classp.h.

◆ HISTORYLOGSENDPACKET

#define HISTORYLOGSENDPACKET (   _packet)
Value:
{ \
if (_packet->RetryHistory != NULL) { \
HistoryLogSendPacket(_packet); \
} \
}

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 491 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 2408 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 CLASS_DETECTION_STATE
@ ClassDetectionUnknown
Definition: classp.h:445
@ ClassDetectionUnsupported
Definition: classp.h:446
@ ClassDetectionSupported
Definition: classp.h:447
enum _CLASS_DETECTION_STATE * PCLASS_DETECTION_STATE

◆ MEDIA_LOCK_TYPE

Enumerator
SimpleMediaLock 
SecureMediaLock 
InternalMediaLock 
SimpleMediaLock 
SecureMediaLock 
InternalMediaLock 

Definition at line 378 of file classp.h.

378 {
enum MEDIA_LOCK_TYPE * PMEDIA_LOCK_TYPE
MEDIA_LOCK_TYPE
Definition: classp.h:378
@ SimpleMediaLock
Definition: classp.h:379
@ InternalMediaLock
Definition: classp.h:381
@ SecureMediaLock
Definition: classp.h:380

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_)
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
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}
base of all file and directory entries
Definition: entries.h:83
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _In_ _Strict_type_match_ POOL_TYPE _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_opt_ ULONG _Out_ WDFLOOKASIDE * Lookaside
Definition: wdfmemory.h:414
_In_ PVOID Entry
Definition: exfuncs.h:229
#define ExInterlockedPopEntrySList(SListHead, Lock)
Definition: exfuncs.h:166
#define InterlockedPopEntrySList(SListHead)
Definition: rtlfuncs.h:3392

◆ _Dispatch_type_() [1/7]

_Dispatch_type_ ( IRP_MJ_CREATE  )

Definition at line 984 of file isapnp.c.

995{
996 PAGED_CODE();
997
998 Irp->IoStatus.Status = STATUS_SUCCESS;
999
1000 DPRINT("%s(%p, %p)\n", __FUNCTION__, DeviceObject, Irp);
1001
1003
1004 return STATUS_SUCCESS;
1005}
#define PAGED_CODE()
_In_ PIRP Irp
Definition: csq.h:116
#define __FUNCTION__
Definition: types.h:116
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define IO_NO_INCREMENT
Definition: iotypes.h:598

◆ _Dispatch_type_() [2/7]

_Dispatch_type_ ( IRP_MJ_DEVICE_CONTROL  )

Definition at line 1007 of file isapnp.c.

1018{
1019 PISAPNP_COMMON_EXTENSION CommonExt = DeviceObject->DeviceExtension;
1020
1021 PAGED_CODE();
1022
1023 DPRINT("%s(%p, %p) Minor - %X\n", __FUNCTION__, DeviceObject, Irp,
1025
1026 if (CommonExt->Signature == IsaPnpBus)
1027 {
1029 return IoCallDriver(((PISAPNP_FDO_EXTENSION)CommonExt)->Ldo, Irp);
1030 }
1031 else
1032 {
1033 NTSTATUS Status = Irp->IoStatus.Status;
1034
1036 return Status;
1037 }
1038}
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:25
@ IsaPnpBus
Definition: isapnp.h:143
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IoCallDriver
Definition: irp.c:1225
ISAPNP_SIGNATURE Signature
Definition: isapnp.h:150
_In_ UCHAR _In_ UCHAR MinorFunction
Definition: wdfdevice.h:1699
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793

◆ _Dispatch_type_() [3/7]

_Dispatch_type_ ( IRP_MJ_PNP  )

Definition at line 1581 of file isapnp.c.

1591{
1593 PISAPNP_COMMON_EXTENSION DevExt = DeviceObject->DeviceExtension;
1594
1595 PAGED_CODE();
1596
1597 if (DevExt->Signature == IsaPnpBus)
1598 return IsaFdoPnp((PISAPNP_FDO_EXTENSION)DevExt, Irp, IrpSp);
1599 else
1600 return IsaPdoPnp((PISAPNP_PDO_EXTENSION)DevExt, Irp, IrpSp);
1601}
NTSTATUS IsaFdoPnp(_In_ PISAPNP_FDO_EXTENSION FdoExt, _Inout_ PIRP Irp, _In_ PIO_STACK_LOCATION IrpSp)
Definition: fdo.c:123
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
NTSTATUS IsaPdoPnp(_In_ PISAPNP_PDO_EXTENSION PdoDeviceExtension, _Inout_ PIRP Irp, _In_ PIO_STACK_LOCATION IrpSp)
Definition: pdo.c:864

◆ _Dispatch_type_() [4/7]

_Dispatch_type_ ( IRP_MJ_POWER  )

Definition at line 1543 of file isapnp.c.

1552{
1553 PISAPNP_COMMON_EXTENSION DevExt = DeviceObject->DeviceExtension;
1555
1556 if (DevExt->Signature != IsaPnpBus)
1557 {
1559 {
1560 case IRP_MN_SET_POWER:
1561 case IRP_MN_QUERY_POWER:
1563 Irp->IoStatus.Status = Status;
1564 break;
1565
1566 default:
1567 Status = Irp->IoStatus.Status;
1568 break;
1569 }
1570
1573 return Status;
1574 }
1575
1578 return PoCallDriver(((PISAPNP_FDO_EXTENSION)DevExt)->Ldo, Irp);
1579}
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:746
#define IRP_MN_SET_POWER
#define IRP_MN_QUERY_POWER

◆ _Dispatch_type_() [5/7]

_Dispatch_type_ ( IRP_MJ_READ  )

Definition at line 3505 of file read.c.

3507 {
3508 device_extension* Vcb = DeviceObject->DeviceExtension;
3511 ULONG bytes_read = 0;
3513 bool top_level;
3514 fcb* fcb;
3515 ccb* ccb;
3516 bool acquired_fcb_lock = false, wait;
3517
3519
3520 top_level = is_top_level(Irp);
3521
3522 TRACE("read\n");
3523
3524 if (Vcb && Vcb->type == VCB_TYPE_VOLUME) {
3526 goto exit2;
3527 } else if (!Vcb || Vcb->type != VCB_TYPE_FS) {
3529 goto end;
3530 }
3531
3532 Irp->IoStatus.Information = 0;
3533
3535 CcMdlReadComplete(IrpSp->FileObject, Irp->MdlAddress);
3536
3537 Irp->MdlAddress = NULL;
3539
3540 goto exit;
3541 }
3542
3543 fcb = FileObject->FsContext;
3544
3545 if (!fcb) {
3546 ERR("fcb was NULL\n");
3548 goto exit;
3549 }
3550
3551 ccb = FileObject->FsContext2;
3552
3553 if (!ccb) {
3554 ERR("ccb was NULL\n");
3556 goto exit;
3557 }
3558
3559 if (Irp->RequestorMode == UserMode && !(ccb->access & FILE_READ_DATA)) {
3560 WARN("insufficient privileges\n");
3562 goto exit;
3563 }
3564
3565 if (fcb == Vcb->volume_fcb) {
3566 TRACE("reading volume FCB\n");
3567
3569
3570 Status = IoCallDriver(Vcb->Vpb->RealDevice, Irp);
3571
3572 goto exit2;
3573 }
3574
3575 if (!(Irp->Flags & IRP_PAGING_IO))
3577
3579
3580 // Don't offload jobs when doing paging IO - otherwise this can lead to
3581 // deadlocks in CcCopyRead.
3582 if (Irp->Flags & IRP_PAGING_IO)
3583 wait = true;
3584
3585 if (!(Irp->Flags & IRP_PAGING_IO) && FileObject->SectionObjectPointer && FileObject->SectionObjectPointer->DataSectionObject) {
3587
3588 CcFlushCache(FileObject->SectionObjectPointer, &IrpSp->Parameters.Read.ByteOffset, IrpSp->Parameters.Read.Length, &iosb);
3589 if (!NT_SUCCESS(iosb.Status)) {
3590 ERR("CcFlushCache returned %08lx\n", iosb.Status);
3591 return iosb.Status;
3592 }
3593 }
3594
3595 if (!ExIsResourceAcquiredSharedLite(fcb->Header.Resource)) {
3596 if (!ExAcquireResourceSharedLite(fcb->Header.Resource, wait)) {
3599 goto exit;
3600 }
3601
3602 acquired_fcb_lock = true;
3603 }
3604
3605 Status = do_read(Irp, wait, &bytes_read);
3606
3607 if (acquired_fcb_lock)
3608 ExReleaseResourceLite(fcb->Header.Resource);
3609
3610exit:
3611 if (FileObject->Flags & FO_SYNCHRONOUS_IO && !(Irp->Flags & IRP_PAGING_IO))
3612 FileObject->CurrentByteOffset.QuadPart = IrpSp->Parameters.Read.ByteOffset.QuadPart + (NT_SUCCESS(Status) ? bytes_read : 0);
3613
3614end:
3615 Irp->IoStatus.Status = Status;
3616
3617 TRACE("Irp->IoStatus.Status = %08lx\n", Irp->IoStatus.Status);
3618 TRACE("Irp->IoStatus.Information = %Iu\n", Irp->IoStatus.Information);
3619 TRACE("returning %08lx\n", Status);
3620
3621 if (Status != STATUS_PENDING)
3623 else {
3624 if (!add_thread_job(Vcb, Irp))
3626 }
3627
3628exit2:
3629 if (top_level)
3631
3633
3634 return Status;
3635}
#define WARN(fmt,...)
Definition: debug.h:112
#define ERR(fmt,...)
Definition: debug.h:110
#define VCB_TYPE_VOLUME
Definition: btrfs_drv.h:689
bool add_thread_job(device_extension *Vcb, PIRP Irp)
struct _fcb fcb
Definition: btrfs_drv.h:1364
#define VCB_TYPE_FS
Definition: btrfs_drv.h:687
NTSTATUS do_read_job(PIRP Irp)
Definition: worker-thread.c:26
NTSTATUS vol_read(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:144
static __inline POPLOCK fcb_oplock(fcb *fcb)
Definition: btrfs_drv.h:1677
struct _ccb ccb
VOID NTAPI CcMdlReadComplete(IN PFILE_OBJECT FileObject, IN PMDL MdlChain)
Definition: mdlsup.c:75
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 NT_SUCCESS(StatCode)
Definition: apphelp.c:32
bool is_top_level(_In_ PIRP Irp)
Definition: btrfs.c:278
#define ExAcquireResourceSharedLite(res, wait)
Definition: env_spec_w32.h:621
NTSTATUS do_read(PIRP Irp, bool wait, ULONG *bytes_read)
Definition: read.c:3328
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
GLuint GLuint end
Definition: gl.h:1545
IoMarkIrpPending(Irp)
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
#define UserMode
Definition: asm.h:35
#define FILE_READ_DATA
Definition: nt_native.h:628
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822
ULONG NTAPI ExIsResourceAcquiredSharedLite(IN PERESOURCE Resource)
Definition: resource.c:1663
BOOLEAN NTAPI IoIsOperationSynchronous(IN PIRP Irp)
Definition: irp.c:1882
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
#define STATUS_PENDING
Definition: ntstatus.h:82
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:1170
#define Vcb
Definition: cdprocs.h:1415
#define exit(n)
Definition: config.h:202
#define TRACE(s)
Definition: solgame.cpp:4
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
ACCESS_MASK access
Definition: btrfs_drv.h:382
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:283
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
#define IRP_MN_COMPLETE
Definition: iotypes.h:4420
#define IRP_PAGING_IO
* PFILE_OBJECT
Definition: iotypes.h:1998
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1776

◆ _Dispatch_type_() [6/7]

_Dispatch_type_ ( IRP_MJ_SHUTDOWN  )

Definition at line 5510 of file btrfs.c.

5512 {
5514 bool top_level;
5515 device_extension* Vcb = DeviceObject->DeviceExtension;
5516
5518
5519 TRACE("shutdown\n");
5520
5521 top_level = is_top_level(Irp);
5522
5523 if (Vcb && Vcb->type == VCB_TYPE_VOLUME) {
5525 goto end;
5526 }
5527
5529
5531
5532end:
5533 Irp->IoStatus.Status = Status;
5534 Irp->IoStatus.Information = 0;
5535
5537
5538 if (top_level)
5540
5542
5543 return Status;
5544}
void do_shutdown(PIRP Irp)
Definition: btrfs.c:5392
return STATUS_SUCCESS
Definition: btrfs.c:3080
InsertTailList & Vcb
Definition: btrfs.c:3044
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138

◆ _Dispatch_type_() [7/7]

_Dispatch_type_ ( IRP_MJ_SYSTEM_CONTROL  )

Definition at line 5748 of file btrfs.c.

5750 {
5752 device_extension* Vcb = DeviceObject->DeviceExtension;
5753 bool top_level;
5754
5756
5757 top_level = is_top_level(Irp);
5758
5759 Irp->IoStatus.Information = 0;
5760
5761 if (Vcb && Vcb->type == VCB_TYPE_VOLUME) {
5762 volume_device_extension* vde = DeviceObject->DeviceExtension;
5763
5765
5767
5768 goto exit;
5769 } else if (Vcb && Vcb->type == VCB_TYPE_FS) {
5771
5772 Status = IoCallDriver(Vcb->Vpb->RealDevice, Irp);
5773
5774 goto exit;
5775 } else if (Vcb && Vcb->type == VCB_TYPE_BUS) {
5776 bus_device_extension* bde = DeviceObject->DeviceExtension;
5777
5779
5781
5782 goto exit;
5783 }
5784
5785 Status = Irp->IoStatus.Status;
5787
5788exit:
5789 if (top_level)
5791
5793
5794 return Status;
5795}
#define VCB_TYPE_BUS
Definition: btrfs_drv.h:691
PDEVICE_OBJECT attached_device
Definition: btrfs_drv.h:880
PDEVICE_OBJECT attached_device
Definition: btrfs_drv.h:849

◆ _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",
13212 status));
13213
13214 return status;
13215}
#define REG_DISK_CLASS_CONTROL
Definition: classp.h:218
#define MAX_TOKEN_LIST_IDENTIFIERS
Definition: classp.h:215
#define MIN_TOKEN_LIST_IDENTIFIERS
Definition: classp.h:214
ULONG MaxTokenOperationListIdentifier
Definition: class.c:107
_IRQL_requires_same_ NTSTATUS ClasspGetBlockDeviceTokenLimitsInfo(_Inout_ PDEVICE_OBJECT DeviceObject)
Definition: class.c:13220
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
Definition: ps.c:97
#define NT_ASSERT
Definition: rtlfuncs.h:3310

◆ _IRQL_requires_max_() [1/2]

_IRQL_requires_max_ ( APC_LEVEL  )

Definition at line 37 of file cddata.c.

254{
255 THREAD_CONTEXT ThreadContext = {0};
256 PIRP_CONTEXT IrpContext = NULL;
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
410
411 Status = CdCommonDevControl( IrpContext, Irp );
412 break;
413
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}
unsigned char BOOLEAN
VOID CdCompleteRequest(_Inout_opt_ PIRP_CONTEXT IrpContext, _Inout_opt_ PIRP Irp, _In_ NTSTATUS Status)
Definition: cddata.c:914
LONG CdExceptionFilter(_Inout_ PIRP_CONTEXT IrpContext, _In_ PEXCEPTION_POINTERS ExceptionPointer)
Definition: cddata.c:525
VOID CdSetThreadContext(_Inout_ PIRP_CONTEXT IrpContext, _In_ PTHREAD_CONTEXT ThreadContext)
Definition: cddata.c:981
#define ASSERT_OPTIONAL_IRP(I)
Definition: cddata.h:251
NTSTATUS CdCompleteMdl(_In_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: cachesup.c:411
VOID CdCleanupIrpContext(_In_ PIRP_CONTEXT IrpContext, _In_ BOOLEAN Post)
Definition: strucsup.c:1733
#define CanFsdWait(I)
Definition: cdprocs.h:2001
NTSTATUS CdCommonLockControl(_Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: lockctrl.c:35
NTSTATUS CdCommonDevControl(_Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: devctrl.c:46
_Ret_valid_ PIRP_CONTEXT CdCreateIrpContext(_In_ PIRP Irp, _In_ BOOLEAN Wait)
Definition: strucsup.c:1573
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define IRP_CONTEXT_FLAG_MORE_PROCESSING
Definition: cdstruc.h:1214
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CDFS_NTC_IRP_CONTEXT
Definition: nodetype.h:34
#define SafeNodeType(Ptr)
Definition: nodetype.h:54
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1843
#define STATUS_CANT_WAIT
Definition: ntstatus.h:452
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:158
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170
#define IRP_MJ_FILE_SYSTEM_CONTROL
#define IRP_MJ_SHUTDOWN
#define IRP_MJ_CLEANUP

◆ _IRQL_requires_max_() [2/2]

_IRQL_requires_max_ ( PASSIVE_LEVEL  )

Definition at line 923 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 */
107 NULL,
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;
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}
static const INTERNET_PORT ServerPort
Definition: CWebService.cpp:11
POBJECT_TYPE ServerPortObjectType
Definition: Messaging.c:24
VOID FLTAPI FltObjectDereference(_Inout_ PVOID Object)
Definition: Object.c:53
NTSTATUS FLTAPI FltObjectReference(_Inout_ PVOID Object)
Definition: Object.c:41
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define InsertTailList(ListHead, Entry)
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
_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:1877
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY ConnectNotifyCallback
Definition: fltkernel.h:1875
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID ServerPortCookie
Definition: fltkernel.h:1874
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY DisconnectNotifyCallback
Definition: fltkernel.h:1876
ULONG FltpObjectPointerReference(_In_ PFLT_OBJECT Object)
Definition: Object.c:322
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
static LONG MaxConnections
#define KernelMode
Definition: asm.h:34
#define STANDARD_RIGHTS_ALL
Definition: nt_native.h:69
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
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:2935
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:1039
FLT_MUTEX_LIST_HEAD ConnectionList
Definition: fltmgrint.h:121
LIST_ENTRY mList
Definition: fltmgrint.h:56
FAST_MUTEX mLock
Definition: fltmgrint.h:55
PFLT_DISCONNECT_NOTIFY DisconnectNotify
Definition: fltmgrint.h:192
PFLT_MESSAGE_NOTIFY MessageNotify
Definition: fltmgrint.h:193
PFLT_CONNECT_NOTIFY ConnectNotify
Definition: fltmgrint.h:191
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

◆ 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}
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 {
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()
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx 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:732
VOID NTAPI ClassReleaseChildLock(_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: class.c:12019
pPkgPnp m_DeviceInterfaceLock AcquireLock(pFxDriverGlobals)
struct _PHYSICAL_DEVICE_EXTENSION * ChildList
Definition: classpnp.h:616
COMMON_DEVICE_EXTENSION CommonExtension
Definition: classpnp.h:652
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536

◆ ClassDeviceGetLBProvisioningResources()

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

Definition at line 5087 of file utils.c.

5113{
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_ PSCSI_REQUEST_BLOCK Srb
Definition: cdrom.h:989
VOID NTAPI ClassCompleteRequest(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ CCHAR PriorityBoost)
Definition: lock.c:401
VOID NTAPI ClassReleaseRemoveLock(_In_ PDEVICE_OBJECT DeviceObject, _In_opt_ PIRP Tag)
Definition: lock.c:251
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
struct _STORAGE_LB_PROVISIONING_MAP_RESOURCES * PSTORAGE_LB_PROVISIONING_MAP_RESOURCES

Referenced by ClassDeviceControl().

◆ ClassDeviceHwFirmwareActivateProcess()

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

Definition at line 8902 of file utils.c.

8907{
8909
8910#if (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)
8911
8912 PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension;
8913 PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = DeviceObject->DeviceExtension;
8914
8916 PSTORAGE_HW_FIRMWARE_ACTIVATE firmwareActivate = (PSTORAGE_HW_FIRMWARE_ACTIVATE)Irp->AssociatedIrp.SystemBuffer;
8917 BOOLEAN passDown = FALSE;
8918 PCDB cdb = NULL;
8919 ULONG i;
8920 BOOLEAN lockHeld = FALSE;
8921 KLOCK_QUEUE_HANDLE lockHandle;
8922
8923
8924 //
8925 // Input buffer is not big enough to contain required input information.
8926 //
8927 if (irpStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(STORAGE_HW_FIRMWARE_ACTIVATE)) {
8928
8930 goto Exit_Firmware_Activate;
8931 }
8932
8933 //
8934 // Input buffer basic validation.
8935 //
8936 if ((firmwareActivate->Version < sizeof(STORAGE_HW_FIRMWARE_ACTIVATE)) ||
8937 (firmwareActivate->Size > irpStack->Parameters.DeviceIoControl.InputBufferLength)) {
8938
8940 goto Exit_Firmware_Activate;
8941 }
8942
8943 //
8944 // Only process the request for a supported port driver.
8945 //
8948 goto Exit_Firmware_Activate;
8949 }
8950
8951 //
8952 // Buffer "FunctionSupportInfo" is allocated during start device process. Following check defends against the situation
8953 // of receiving this IOCTL when the device is created but not started, or device start failed but did not get removed yet.
8954 //
8955 if (commonExtension->IsFdo && (fdoExtension->FunctionSupportInfo == NULL)) {
8956
8958 goto Exit_Firmware_Activate;
8959 }
8960
8961 //
8962 // Process the situation that request should be forwarded to lower level.
8963 //
8964 if (!commonExtension->IsFdo) {
8965 passDown = TRUE;
8966 }
8967
8968 if ((firmwareActivate->Flags & STORAGE_HW_FIRMWARE_REQUEST_FLAG_CONTROLLER) != 0) {
8969 passDown = TRUE;
8970 }
8971
8972 if (passDown) {
8973
8975
8977 status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8978 FREE_POOL(Srb);
8979 return status;
8980 }
8981
8982 //
8983 // If firmware information hasn't been cached in classpnp, retrieve it.
8984 //
8985 if (fdoExtension->FunctionSupportInfo->HwFirmwareInfo == NULL) {
8986 if (fdoExtension->FunctionSupportInfo->HwFirmwareGetInfoSupport == NotSupported) {
8988 goto Exit_Firmware_Activate;
8989 } else {
8990 //
8991 // If this is the first time of retrieving firmware information,
8992 // send request to lower level to get it.
8993 //
8995
8996 if (!NT_SUCCESS(status)) {
8997 goto Exit_Firmware_Activate;
8998 }
8999 }
9000 }
9001
9002 //
9003 // Fail the request if the firmware information cannot be retrieved.
9004 //
9005 if (fdoExtension->FunctionSupportInfo->HwFirmwareInfo == NULL) {
9006 if (fdoExtension->FunctionSupportInfo->HwFirmwareGetInfoSupport == NotSupported) {
9008 } else {
9010 }
9011
9012 goto Exit_Firmware_Activate;
9013 }
9014
9015 //
9016 // Acquire the SyncLock to ensure the HwFirmwareInfo pointer doesn't change
9017 // while we're dereferencing it.
9018 //
9019 lockHeld = TRUE;
9020 KeAcquireInStackQueuedSpinLock(&fdoExtension->FunctionSupportInfo->SyncLock, &lockHandle);
9021
9022 //
9023 // Validate the device support
9024 //
9025 if (fdoExtension->FunctionSupportInfo->HwFirmwareInfo->SupportUpgrade == FALSE) {
9027 goto Exit_Firmware_Activate;
9028 }
9029
9030 //
9031 // Check if the slot number is valid.
9032 //
9033 for (i = 0; i < fdoExtension->FunctionSupportInfo->HwFirmwareInfo->SlotCount; i++) {
9034 if (fdoExtension->FunctionSupportInfo->HwFirmwareInfo->Slot[i].SlotNumber == firmwareActivate->Slot) {
9035 break;
9036 }
9037 }
9038
9039 if (i >= fdoExtension->FunctionSupportInfo->HwFirmwareInfo->SlotCount) {
9040 //
9041 // Either the slot number is out of scope or the slot is read-only.
9042 //
9044 goto Exit_Firmware_Activate;
9045 }
9046
9047 //
9048 // We're done accessing HwFirmwareInfo at this point so we can release
9049 // the SyncLock.
9050 //
9051 NT_ASSERT(lockHeld);
9052 KeReleaseInStackQueuedSpinLock(&lockHandle);
9053 lockHeld = FALSE;
9054
9055 //
9056 // Process the request by translating it into WRITE BUFFER command.
9057 //
9058 //
9059 // Setup the CDB. This should be an untagged request.
9060 //
9062 cdb = SrbGetCdb(Srb);
9063 cdb->WRITE_BUFFER.OperationCode = SCSIOP_WRITE_DATA_BUFF;
9064 cdb->WRITE_BUFFER.Mode = SCSI_WRITE_BUFFER_MODE_ACTIVATE_DEFERRED_MICROCODE;
9065 cdb->WRITE_BUFFER.ModeSpecific = 0; //Reserved for Mode 0x0F
9066 cdb->WRITE_BUFFER.BufferID = firmwareActivate->Slot; //NOTE: this field will be ignored by SCSI device.
9067
9068 //
9069 // Set timeout value.
9070 //
9072
9073 //
9074 // This routine uses a completion routine - ClassIoComplete() so we don't want to release
9075 // the remove lock until then.
9076 //
9078 Srb,
9079 Irp,
9080 NULL,
9081 0,
9082 FALSE);
9083
9084 if (status != STATUS_PENDING) {
9085 //
9086 // If the irp cannot be sent down, the Srb has been freed. NULL it to prevent from freeing it again.
9087 //
9088 Srb = NULL;
9089
9090 goto Exit_Firmware_Activate;
9091 }
9092
9093 return status;
9094
9095Exit_Firmware_Activate:
9096
9097 //
9098 // Release the SyncLock if it's still held.
9099 // This should only happen in the failure path.
9100 //
9101 if (lockHeld) {
9102 KeReleaseInStackQueuedSpinLock(&lockHandle);
9103 lockHeld = FALSE;
9104 }
9105
9106 //
9107 // Firmware Activate request will be failed.
9108 //
9110
9111 Irp->IoStatus.Status = status;
9112
9113#else
9115 Irp->IoStatus.Status = status;
9116#endif // #if (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)
9117
9120
9121 FREE_POOL(Srb);
9122 return status;
9123}
#define FREE_POOL(_PoolPtr)
Definition: cdrom.h:782
#define CDB10GENERIC_LENGTH
Definition: cdrw_hw.h:831
#define SCSIOP_WRITE_DATA_BUFF
Definition: cdrw_hw.h:922
@ NotSupported
Definition: classpnp.h:734
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)
NTSTATUS ClasspGetHwFirmwareInfo(_In_ PDEVICE_OBJECT DeviceObject)
Definition: utils.c:8190
#define FIRMWARE_ACTIVATE_TIMEOUT_VALUE
Definition: utils.c:37
__inline BOOLEAN ClassDeviceHwFirmwareIsPortDriverSupported(_In_ PDEVICE_OBJECT DeviceObject)
Definition: utils.c:8330
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
VOID FASTCALL KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:130
VOID FASTCALL KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:166
if(dx< 0)
Definition: linetemp.h:194
#define IoCopyCurrentIrpStackLocationToNext(Irp)
Definition: ntifs_ex.h:413
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
FORCEINLINE VOID SrbSetCdbLength(_In_ PVOID Srb, _In_ UCHAR CdbLength)
Definition: srbhelper.h:1093
FORCEINLINE VOID SrbSetTimeOutValue(_In_ PVOID Srb, _In_ ULONG TimeOutValue)
Definition: srbhelper.h:821
PDEVICE_OBJECT LowerDeviceObject
Definition: classpnp.h:598
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
Definition: cdrw_hw.h:28
#define SrbGetCdb(srb)
Definition: usbstor.h:17

Referenced by ClassDeviceControl().

◆ ClassDeviceHwFirmwareDownloadProcess()

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

Definition at line 8541 of file utils.c.

8546{
8548
8549#if (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)
8550
8551 PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension;
8552 PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = DeviceObject->DeviceExtension;
8553
8555 PSTORAGE_HW_FIRMWARE_DOWNLOAD firmwareDownload = (PSTORAGE_HW_FIRMWARE_DOWNLOAD)Irp->AssociatedIrp.SystemBuffer;
8556 BOOLEAN passDown = FALSE;
8557 ULONG i;
8558 ULONG bufferSize = 0;
8559 PUCHAR firmwareImageBuffer = NULL;
8560 PIRP irp2 = NULL;
8561 PIO_STACK_LOCATION newStack = NULL;
8562 PCDB cdb = NULL;
8563 BOOLEAN lockHeld = FALSE;
8564 KLOCK_QUEUE_HANDLE lockHandle;
8565
8566
8567 //
8568 // Input buffer is not big enough to contain required input information.
8569 //
8570 if (irpStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(STORAGE_HW_FIRMWARE_DOWNLOAD)) {
8571
8573 goto Exit_Firmware_Download;
8574 }
8575
8576 //
8577 // Input buffer basic validation.
8578 //
8579 if ((firmwareDownload->Version < sizeof(STORAGE_HW_FIRMWARE_DOWNLOAD)) ||
8580 (firmwareDownload->Size > irpStack->Parameters.DeviceIoControl.InputBufferLength) ||
8581 ((firmwareDownload->BufferSize + FIELD_OFFSET(STORAGE_HW_FIRMWARE_DOWNLOAD, ImageBuffer)) > firmwareDownload->Size)) {
8582
8584 goto Exit_Firmware_Download;
8585 }
8586
8587 //
8588 // Only process the request for a supported port driver.
8589 //
8592 goto Exit_Firmware_Download;
8593 }
8594
8595 //
8596 // Buffer "FunctionSupportInfo" is allocated during start device process. Following check defends against the situation
8597 // of receiving this IOCTL when the device is created but not started, or device start failed but did not get removed yet.
8598 //
8599 if (commonExtension->IsFdo && (fdoExtension->FunctionSupportInfo == NULL)) {
8600
8602 goto Exit_Firmware_Download;
8603 }
8604
8605 //
8606 // Process the situation that request should be forwarded to lower level.
8607 //
8608 if (!commonExtension->IsFdo) {
8609 passDown = TRUE;
8610 }
8611
8612 if ((firmwareDownload->Flags & STORAGE_HW_FIRMWARE_REQUEST_FLAG_CONTROLLER) != 0) {
8613 passDown = TRUE;
8614 }
8615
8616 if (passDown) {
8617
8619
8621 status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8622 FREE_POOL(Srb);
8623 return status;
8624 }
8625
8626 //
8627 // If firmware information hasn't been cached in classpnp, retrieve it.
8628 //
8629 if (fdoExtension->FunctionSupportInfo->HwFirmwareInfo == NULL) {
8630 if (fdoExtension->FunctionSupportInfo->HwFirmwareGetInfoSupport == NotSupported) {
8632 goto Exit_Firmware_Download;
8633 } else {
8634 //
8635 // If this is the first time of retrieving firmware information,
8636 // send request to lower level to get it.
8637 //
8639
8640 if (!NT_SUCCESS(status)) {
8641 goto Exit_Firmware_Download;
8642 }
8643 }
8644 }
8645
8646 //
8647 // Fail the request if the firmware information cannot be retrieved.
8648 //
8649 if (fdoExtension->FunctionSupportInfo->HwFirmwareInfo == NULL) {
8650 if (fdoExtension->FunctionSupportInfo->HwFirmwareGetInfoSupport == NotSupported) {
8652 } else {
8654 }
8655
8656 goto Exit_Firmware_Download;
8657 }
8658
8659 //
8660 // Acquire the SyncLock to ensure the HwFirmwareInfo pointer doesn't change
8661 // while we're dereferencing it.
8662 //
8663 lockHeld = TRUE;
8664 KeAcquireInStackQueuedSpinLock(&fdoExtension->FunctionSupportInfo->SyncLock, &lockHandle);
8665
8666 //
8667 // Validate the device support
8668 //
8669 if ((fdoExtension->FunctionSupportInfo->HwFirmwareInfo->SupportUpgrade == FALSE) ||
8670 (fdoExtension->FunctionSupportInfo->HwFirmwareInfo->ImagePayloadAlignment == 0)) {
8672 goto Exit_Firmware_Download;
8673 }
8674
8675 //
8676 // Check if the slot can be used to hold firmware image.
8677 //
8678 for (i = 0; i < fdoExtension->FunctionSupportInfo->HwFirmwareInfo->SlotCount; i++) {
8679 if (fdoExtension->FunctionSupportInfo->HwFirmwareInfo->Slot[i].SlotNumber == firmwareDownload->Slot) {
8680 break;
8681 }
8682 }
8683
8684 if ((i >= fdoExtension->FunctionSupportInfo->HwFirmwareInfo->SlotCount) ||
8685 (fdoExtension->FunctionSupportInfo->HwFirmwareInfo->Slot[i].ReadOnly == TRUE)) {
8686 //
8687 // Either the slot number is out of scope or the slot is read-only.
8688 //
8690 goto Exit_Firmware_Download;
8691 }
8692
8693 //
8694 // Buffer size and alignment validation.
8695 // Max Offset and Buffer Size can be represented by SCSI command is max value for 3 bytes.
8696 //
8697 if ((firmwareDownload->BufferSize == 0) ||
8698 ((firmwareDownload->BufferSize % fdoExtension->FunctionSupportInfo->HwFirmwareInfo->ImagePayloadAlignment) != 0) ||
8699 (firmwareDownload->BufferSize > fdoExtension->FunctionSupportInfo->HwFirmwareInfo->ImagePayloadMaxSize) ||
8700 (firmwareDownload->BufferSize > fdoExtension->AdapterDescriptor->MaximumTransferLength) ||
8701 ((firmwareDownload->Offset % fdoExtension->FunctionSupportInfo->HwFirmwareInfo->ImagePayloadAlignment) != 0) ||
8702 (firmwareDownload->Offset > 0xFFFFFF) ||
8703 (firmwareDownload->BufferSize > 0xFFFFFF)) {
8704
8706 goto Exit_Firmware_Download;
8707 }
8708
8709
8710 //
8711 // Process the request by translating it into WRITE BUFFER command.
8712 //
8713 if (((ULONG_PTR)firmwareDownload->ImageBuffer % fdoExtension->FunctionSupportInfo->HwFirmwareInfo->ImagePayloadAlignment) != 0) {
8714 //
8715 // Allocate buffer aligns to ImagePayloadAlignment to accommodate the alignment requirement.
8716 //
8717 bufferSize = ALIGN_UP_BY(firmwareDownload->BufferSize, fdoExtension->FunctionSupportInfo->HwFirmwareInfo->ImagePayloadAlignment);
8718
8719 //
8720 // We're done accessing HwFirmwareInfo at this point so we can release
8721 // the SyncLock.
8722 //
8723 NT_ASSERT(lockHeld);
8724 KeReleaseInStackQueuedSpinLock(&lockHandle);
8725 lockHeld = FALSE;
8726
8727#ifdef _MSC_VER
8728#pragma prefast(suppress:6014, "The allocated memory that firmwareImageBuffer points to will be freed in ClassHwFirmwareDownloadComplete().")
8729#endif
8730 firmwareImageBuffer = ExAllocatePoolWithTag(NonPagedPoolNx, bufferSize, CLASSPNP_POOL_TAG_FIRMWARE);
8731
8732 if (firmwareImageBuffer == NULL) {
8734 goto Exit_Firmware_Download;
8735 }
8736
8737 RtlZeroMemory(firmwareImageBuffer, bufferSize);
8738
8739 RtlCopyMemory(firmwareImageBuffer, firmwareDownload->ImageBuffer, (ULONG)firmwareDownload->BufferSize);
8740
8741 } else {
8742 NT_ASSERT(lockHeld);
8743 KeReleaseInStackQueuedSpinLock(&lockHandle);
8744 lockHeld = FALSE;
8745
8746 firmwareImageBuffer = firmwareDownload->ImageBuffer;
8747 bufferSize = (ULONG)firmwareDownload->BufferSize;
8748 }
8749
8750 //
8751 // Allocate a new irp to send the WRITE BUFFER command down.
8752 // Similar process as IOCTL_STORAGE_CHECK_VERIFY.
8753 //
8754 irp2 = IoAllocateIrp((CCHAR)(DeviceObject->StackSize + 3), FALSE);
8755
8756 if (irp2 == NULL) {
8758
8759 if (firmwareImageBuffer != firmwareDownload->ImageBuffer) {
8760 FREE_POOL(firmwareImageBuffer);
8761 }
8762
8763 goto Exit_Firmware_Download;
8764 }
8765
8766 //
8767 // Make sure to acquire the lock for the new irp.
8768 //
8770
8771 irp2->Tail.Overlay.Thread = Irp->Tail.Overlay.Thread;
8773
8774 //
8775 // Set the top stack location and shove the master Irp into the
8776 // top location
8777 //
8778 newStack = IoGetCurrentIrpStackLocation(irp2);
8779 newStack->Parameters.Others.Argument1 = Irp;
8780 newStack->DeviceObject = DeviceObject;
8781
8782 //
8783 // Stick the firmware download completion routine onto the stack
8784 // and prepare the irp for the port driver
8785 //
8787 ClassHwFirmwareDownloadComplete,
8788 (firmwareImageBuffer != firmwareDownload->ImageBuffer) ? firmwareImageBuffer : NULL,
8789 TRUE,
8790 TRUE,
8791 TRUE);
8792
8794 newStack = IoGetCurrentIrpStackLocation(irp2);
8795 newStack->DeviceObject = DeviceObject;
8796 newStack->MajorFunction = irpStack->MajorFunction;
8797 newStack->MinorFunction = irpStack->MinorFunction;
8798 newStack->Flags = irpStack->Flags;
8799
8800
8801 //
8802 // Mark the master irp as pending - whether the lower level
8803 // driver completes it immediately or not this should allow it
8804 // to go all the way back up.
8805 //
8807
8808 //
8809 // Setup the CDB.
8810 //
8812 cdb = SrbGetCdb(Srb);
8813 cdb->WRITE_BUFFER.OperationCode = SCSIOP_WRITE_DATA_BUFF;
8814 cdb->WRITE_BUFFER.Mode = SCSI_WRITE_BUFFER_MODE_DOWNLOAD_MICROCODE_WITH_OFFSETS_SAVE_DEFER_ACTIVATE;
8815 cdb->WRITE_BUFFER.ModeSpecific = 0; //Reserved for Mode 0x0E
8816 cdb->WRITE_BUFFER.BufferID = firmwareDownload->Slot;
8817
8818 cdb->WRITE_BUFFER.BufferOffset[0] = *((PCHAR)&firmwareDownload->Offset + 2);
8819 cdb->WRITE_BUFFER.BufferOffset[1] = *((PCHAR)&firmwareDownload->Offset + 1);
8820 cdb->WRITE_BUFFER.BufferOffset[2] = *((PCHAR)&firmwareDownload->Offset);
8821
8822 cdb->WRITE_BUFFER.ParameterListLength[0] = *((PCHAR)&bufferSize + 2);
8823 cdb->WRITE_BUFFER.ParameterListLength[1] = *((PCHAR)&bufferSize + 1);
8824 cdb->WRITE_BUFFER.ParameterListLength[2] = *((PCHAR)&bufferSize);
8825
8826 //
8827 // Send as a tagged command.
8828 //
8831
8832 //
8833 // Set timeout value.
8834 //
8835 SrbSetTimeOutValue(Srb, fdoExtension->TimeOutValue);
8836
8837 //
8838 // This routine uses a completion routine so we don't want to release
8839 // the remove lock until then.
8840 //
8842 Srb,
8843 irp2,
8844 firmwareImageBuffer,
8845 bufferSize,
8846 TRUE);
8847
8848 if (status != STATUS_PENDING) {
8849 //
8850 // If the new irp cannot be sent down, free allocated memory and bail out.
8851 //
8852 if (firmwareImageBuffer != firmwareDownload->ImageBuffer) {
8853 FREE_POOL(firmwareImageBuffer);
8854 }
8855
8856 //
8857 // If the irp cannot be sent down, the Srb has been freed. NULL it to prevent from freeing it again.
8858 //
8859 Srb = NULL;
8860
8862
8863 IoFreeIrp(irp2);
8864
8865 goto Exit_Firmware_Download;
8866 }
8867
8868 return status;
8869
8870Exit_Firmware_Download:
8871
8872 //
8873 // Release the SyncLock if it's still held.
8874 // This should only happen in the failure path.
8875 //
8876 if (lockHeld) {
8877 KeReleaseInStackQueuedSpinLock(&lockHandle);
8878 lockHeld = FALSE;
8879 }
8880
8881 //
8882 // Firmware Download request will be failed.
8883 //
8885
8886 Irp->IoStatus.Status = status;
8887
8888#else
8890 Irp->IoStatus.Status = status;
8891#endif // #if (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)
8892
8895
8896 FREE_POOL(Srb);
8897
8898 return status;
8899}
#define ALIGN_UP_BY(size, align)
#define CLASSPNP_POOL_TAG_FIRMWARE
Definition: classp.h:198
#define ClassAcquireRemoveLock(devobj, tag)
Definition: classpnp.h:100
#define SRB_FLAGS_QUEUE_ACTION_ENABLE
Definition: srb.h:395
#define SRB_HEAD_OF_QUEUE_TAG_REQUEST
Definition: srb.h:424
#define SRB_FLAGS_NO_QUEUE_FREEZE
Definition: srb.h:404
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
size_t bufferSize
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:498
#define PCHAR
Definition: match.c:90
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
FORCEINLINE VOID SrbSetSrbFlags(_In_ PVOID Srb, _In_ ULONG Flags)
Definition: srbhelper.h:964
FORCEINLINE VOID SrbSetRequestAttribute(_In_ PVOID Srb, _In_ UCHAR RequestAttribute)
Definition: srbhelper.h:1131
PSTORAGE_ADAPTER_DESCRIPTOR AdapterDescriptor
Definition: classpnp.h:877
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:65
unsigned char * PUCHAR
Definition: typedefs.h:53
char CCHAR
Definition: typedefs.h:51
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
FORCEINLINE VOID IoSetNextIrpStackLocation(_Inout_ PIRP Irp)
Definition: iofuncs.h:2680

Referenced by ClassDeviceControl().

◆ ClassDeviceHwFirmwareGetInfoProcess()

NTSTATUS ClassDeviceHwFirmwareGetInfoProcess ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp 
)

Definition at line 8366 of file utils.c.

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

Referenced by ClassDeviceControl().

◆ ClassFreeOrReuseSrb()

VOID ClassFreeOrReuseSrb ( IN PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension,
IN __drv_freesMem(mem) PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 882 of file obsolete.c.

905{
906 PCOMMON_DEVICE_EXTENSION commonExt = &FdoExtension->CommonExtension;
907
908 // This function is obsolete, but still called by DISK.SYS .
909 // TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_GENERAL, "ClassFreeOrReuseSrb is OBSOLETE !"));
910
911 //
912 // safety net. this should never occur. if it does, it's a potential
913 // memory leak.
914 //
916
917 if (commonExt->IsSrbLookasideListInitialized){
918 /*
919 * Put the SRB back in our lookaside list.
920 *
921 * Note: Some class drivers use ClassIoComplete
922 * to complete SRBs that they themselves allocated.
923 * So we may be putting a "foreign" SRB
924 * (e.g. with a different pool tag) into our lookaside list.
925 */
927 }
928 else {
929 TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_GENERAL,"ClassFreeOrReuseSrb: someone is trying to use an uninitialized SrbLookasideList !!!"));
930 FREE_POOL(Srb);
931 }
932}
#define TEST_FLAG(Flags, Bit)
Definition: cdrom.h:1495
#define ClasspFreeSrb(ext, srb)
Definition: classpnp.h:150
#define SRB_FLAGS_FREE_SENSE_BUFFER
Definition: srb.h:406
@ FdoExtension
Definition: precomp.h:48
FORCEINLINE ULONG SrbGetSrbFlags(_In_ PVOID Srb)
Definition: srbhelper.h:927
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
BOOLEAN IsSrbLookasideListInitialized
Definition: classpnp.h:610

Referenced by _Success_(), ClassIoComplete(), ClassIoCompleteAssociated(), and ClasspEjectionControl().

◆ ClassGetPdoId()

NTSTATUS ClassGetPdoId ( IN PDEVICE_OBJECT  Pdo,
IN BUS_QUERY_ID_TYPE  IdType,
IN PUNICODE_STRING  IdString 
)

Definition at line 10151 of file class.c.

10156{
10157#ifdef _MSC_VER
10158#pragma warning(suppress:4054) // okay to type cast function pointer as data pointer for this use case
10159#endif
10161
10162 _Analysis_assume_(driverExtension != NULL);
10163
10164 ASSERT_PDO(Pdo);
10165 NT_ASSERT(driverExtension->InitData.ClassQueryId);
10166
10167 PAGED_CODE();
10168
10169 return driverExtension->InitData.ClassQueryId( Pdo, IdType, IdString);
10170} // end ClassGetPdoId()
_In_ BUS_QUERY_ID_TYPE IdType
Definition: classpnp.h:374
_In_ BUS_QUERY_ID_TYPE _In_ PUNICODE_STRING IdString
Definition: classpnp.h:375
#define CLASS_DRIVER_EXTENSION_KEY
Definition: classpnp.h:94
#define ASSERT_PDO(x)
Definition: pci.h:38
#define _Analysis_assume_(expr)
Definition: ms_sal.h:2901
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1890
CLASS_INIT_DATA InitData
Definition: classpnp.h:577
PCLASS_QUERY_ID ClassQueryId
Definition: classpnp.h:542
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_ WDFDRIVER _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT Pdo
Definition: wdfminiport.h:72

Referenced by ClassDispatchPnp().

◆ ClassInitializeDispatchTables()

VOID ClassInitializeDispatchTables ( PCLASS_DRIVER_EXTENSION  DriverExtension)

Definition at line 38 of file dispatch.c.

41{
42 ULONG idx;
43
44 PAGED_CODE();
45
46 //
47 // Initialize the standard device dispatch table
48 //
49
50 for (idx = 0; idx <= IRP_MJ_MAXIMUM_FUNCTION; idx++) {
51 DriverExtension->DeviceMajorFunctionTable[idx] = ClassDispatchUnimplemented;
52 }
53
54 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_CREATE] = ClassCreateClose;
55 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_CLOSE] = ClassCreateClose;
56 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_READ] = ClassReadWrite;
57 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_WRITE] = ClassReadWrite;
59 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_SCSI] = ClassInternalIoControl;
60 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_SHUTDOWN] = ClassShutdownFlush;
61 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_FLUSH_BUFFERS] = ClassShutdownFlush;
62 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_PNP] = ClassDispatchPnp;
63 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_POWER] = ClassDispatchPower;
64 DriverExtension->DeviceMajorFunctionTable[IRP_MJ_SYSTEM_CONTROL] = ClassSystemControl;
65
66
67 return;
68}
NTSTATUS NTAPI ClassSystemControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: classwmi.c:221
unsigned int idx
Definition: utils.c:41
NTSTATUS NTAPI ClassInternalIoControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: class.c:9394
NTSTATUS NTAPI ClassReadWrite(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: class.c:2431
NTSTATUS NTAPI ClassDeviceControlDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: class.c:7258
NTSTATUS NTAPI ClassDispatchPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: class.c:894
NTSTATUS NTAPI ClassShutdownFlush(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: class.c:8773
NTSTATUS NTAPI ClassCreateClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: create.c:57
DRIVER_DISPATCH ClassDispatchUnimplemented
Definition: dispatch.c:30
NTSTATUS NTAPI ClassDispatchPower(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: power.c:105
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
#define IRP_MJ_SCSI
#define IRP_MJ_SYSTEM_CONTROL
#define IRP_MJ_FLUSH_BUFFERS
#define IRP_MJ_POWER
#define IRP_MJ_MAXIMUM_FUNCTION

Referenced by _IRQL_requires_max_().

◆ ClassIoCompletion()

NTSTATUS ClassIoCompletion ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PVOID  Context 
)

◆ ClassMinimalPowerHandler()

NTSTATUS NTAPI ClassMinimalPowerHandler ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 1890 of file power.c.

1894{
1895 PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension;
1898
1901
1902 switch (irpStack->MinorFunction)
1903 {
1904 case IRP_MN_SET_POWER:
1905 {
1906 switch (irpStack->Parameters.Power.ShutdownType)
1907 {
1908 case PowerActionNone:
1909 case PowerActionSleep:
1911 {
1912 if (TEST_FLAG(DeviceObject->Characteristics, FILE_REMOVABLE_MEDIA))
1913 {
1915 {
1916 //
1917 // This flag will cause the filesystem to verify the
1918 // volume when coming out of hibernation or standby or runtime power
1919 //
1921 }
1922 }
1923 }
1924 break;
1925 }
1926 }
1927
1928 //
1929 // Fall through
1930 //
1931
1932 case IRP_MN_QUERY_POWER:
1933 {
1934 if (!commonExtension->IsFdo)
1935 {
1936 Irp->IoStatus.Status = STATUS_SUCCESS;
1937 Irp->IoStatus.Information = 0;
1938 }
1939 }
1940 break;
1941 }
1942
1943 if (commonExtension->IsFdo)
1944 {
1946 status = PoCallDriver(commonExtension->LowerDeviceObject, Irp);
1947 }
1948 else
1949 {
1950 status = Irp->IoStatus.Status;
1952 }
1953
1954 return status;
1955} // end ClassMinimalPowerHandler()
#define SET_FLAG(Flags, Bit)
Definition: cdrom.h:1493
PVPB NTAPI ClassGetVpb(_In_ PDEVICE_OBJECT DeviceObject)
Definition: class.c:11473
#define DO_VERIFY_VOLUME
Definition: env_spec_w32.h:393
#define FILE_REMOVABLE_MEDIA
Definition: nt_native.h:807
@ PowerActionNone
Definition: ntpoapi.h:123
@ PowerActionHibernate
Definition: ntpoapi.h:126
@ PowerActionSleep
Definition: ntpoapi.h:125
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define VPB_MOUNTED
Definition: iotypes.h:1807

Referenced by _IRQL_requires_max_().

◆ ClasspAccessAlignmentProperty()

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

Definition at line 1700 of file utils.c.

1709{
1711
1712 PCOMMON_DEVICE_EXTENSION commonExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
1714 PSTORAGE_PROPERTY_QUERY query = (PSTORAGE_PROPERTY_QUERY)Irp->AssociatedIrp.SystemBuffer;
1716 ULONG length = 0;
1717 ULONG information = 0;
1718
1720
1721 //
1722 // check registry setting and fail the IOCTL if it's required.
1723 // this registry setting can be used to work around issues which upper layer doesn't support large physical sector size.
1724 //
1725 if (fdoExtension->FunctionSupportInfo->RegAccessAlignmentQueryNotSupported) {
1727 goto Exit;
1728 }
1729
1730 if ( (DeviceObject->DeviceType != FILE_DEVICE_DISK) ||
1731 (TEST_FLAG(DeviceObject->Characteristics, FILE_FLOPPY_DISKETTE)) ||
1732 (fdoExtension->FunctionSupportInfo->LowerLayerSupport.AccessAlignmentProperty == Supported) ) {
1733 // if it's not disk, forward the request to lower layer,
1734 // if the IOCTL is supported by lower stack, forward it down.
1736
1738 status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
1739 return status;
1740 }
1741
1742 //
1743 // Check proper query type.
1744 //
1745
1746 if (query->QueryType == PropertyExistsQuery) {
1748 goto Exit;
1749 } else if (query->QueryType != PropertyStandardQuery) {
1751 goto Exit;
1752 }
1753
1754 //
1755 // Request validation.
1756 // Note that InputBufferLength and IsFdo have been validated before entering this routine.
1757 //
1758
1762 goto Exit;
1763 }
1764
1765 // do not touch this buffer because it can still be used as input buffer for lower layer in 'SupportUnknown' case.
1766 accessAlignment = (PSTORAGE_ACCESS_ALIGNMENT_DESCRIPTOR)Irp->AssociatedIrp.SystemBuffer;
1767
1768 length = irpStack->Parameters.DeviceIoControl.OutputBufferLength;
1769
1771
1772 if (length >= sizeof(STORAGE_DESCRIPTOR_HEADER)) {
1773
1775 accessAlignment->Version = sizeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR);
1776 accessAlignment->Size = sizeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR);
1778 goto Exit;
1779 }
1780
1782 goto Exit;
1783 }
1784
1785 // not support Cache Line,
1786 // 'BytesPerCacheLine' and 'BytesOffsetForCacheAlignment' fields are zero-ed.
1787
1788 //
1789 // note that 'Supported' case has been handled at the beginning of this function.
1790 //
1791 switch (fdoExtension->FunctionSupportInfo->LowerLayerSupport.AccessAlignmentProperty) {
1792 case SupportUnknown: {
1793 // send down request and wait for the request to complete.
1794 status = ClassForwardIrpSynchronous(commonExtension, Irp);
1795
1797 // case 1: the request is not supported by lower layer, sends down command
1798 // some port drivers (or filter drivers) return STATUS_INVALID_DEVICE_REQUEST if a request is not supported.
1799
1800 // ClassReadCapacity16() will either return status from cached data or send command to retrieve the information.
1801 if (ClasspIsObsoletePortDriver(fdoExtension) == FALSE) {
1802 status = ClassReadCapacity16(fdoExtension, Srb);
1803 } else {
1804 fdoExtension->FunctionSupportInfo->ReadCapacity16Data.CommandStatus = status;
1805 }
1806
1807 // data is ready in fdoExtension
1808 // set the support status after the SCSI command is executed to avoid racing condition between multiple same type of requests.
1809 fdoExtension->FunctionSupportInfo->LowerLayerSupport.AccessAlignmentProperty = NotSupported;
1810
1811 if (NT_SUCCESS(status)) {
1812 // fill output buffer
1813 RtlZeroMemory(accessAlignment, length);
1814 accessAlignment->Version = sizeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR);
1815 accessAlignment->Size = sizeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR);
1816 accessAlignment->BytesPerLogicalSector = fdoExtension->FunctionSupportInfo->ReadCapacity16Data.BytesPerLogicalSector;
1817 accessAlignment->BytesPerPhysicalSector = fdoExtension->FunctionSupportInfo->ReadCapacity16Data.BytesPerPhysicalSector;
1818 accessAlignment->BytesOffsetForSectorAlignment = fdoExtension->FunctionSupportInfo->ReadCapacity16Data.BytesOffsetForSectorAlignment;
1819
1820 // set returned data length
1822 } else {
1823 information = 0;
1824 }
1825
1826 } else {
1827 // case 2: the request is supported and it completes successfully
1828 // case 3: the request is supported by lower stack but other failure status is returned.
1829 // from now on, the same request will be send down to lower stack directly.
1830 fdoExtension->FunctionSupportInfo->LowerLayerSupport.AccessAlignmentProperty = Supported;
1831 information = (ULONG)Irp->IoStatus.Information;
1832
1833
1834 }
1835
1836
1837 goto Exit;
1838
1839 break;
1840 }
1841
1842 case NotSupported: {
1843
1844 // ClassReadCapacity16() will either return status from cached data or send command to retrieve the information.
1845 status = ClassReadCapacity16(fdoExtension, Srb);
1846
1847 if (NT_SUCCESS(status)) {
1848 RtlZeroMemory(accessAlignment, length);
1849 accessAlignment->Version = sizeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR);
1850 accessAlignment->Size = sizeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR);
1851 accessAlignment->BytesPerLogicalSector = fdoExtension->FunctionSupportInfo->ReadCapacity16Data.BytesPerLogicalSector;
1852 accessAlignment->BytesPerPhysicalSector = fdoExtension->FunctionSupportInfo->ReadCapacity16Data.BytesPerPhysicalSector;
1853 accessAlignment->BytesOffsetForSectorAlignment = fdoExtension->FunctionSupportInfo->ReadCapacity16Data.BytesOffsetForSectorAlignment;
1854
1856 } else {
1857 information = 0;
1858 }
1859 goto Exit;
1860
1861 break;
1862 }
1863
1864 case Supported: {
1865 NT_ASSERT(FALSE); // this case is handled at the beginning of the function.
1867 break;
1868 }
1869
1870 } // end of switch (fdoExtension->FunctionSupportInfo->LowerLayerSupport.AccessAlignmentProperty)
1871
1872Exit:
1873
1874 //
1875 // Set the size and status in IRP
1876 //
1877 Irp->IoStatus.Information = information;
1878 Irp->IoStatus.Status = status;
1879
1882
1883 return status;
1884}
FORCEINLINE BOOLEAN ClasspLowerLayerNotSupport(_In_ NTSTATUS Status)
Definition: classp.h:2638
FORCEINLINE BOOLEAN ClasspIsObsoletePortDriver(_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: classp.h:1335
@ Supported
Definition: classpnp.h:733
@ SupportUnknown
Definition: classpnp.h:732
static PDB_INFORMATION information
Definition: db.cpp:178
struct _COMMON_DEVICE_EXTENSION * PCOMMON_DEVICE_EXTENSION
NTSTATUS NTAPI ClassForwardIrpSynchronous(_In_ PCOMMON_DEVICE_EXTENSION CommonExtension, _In_ PIRP Irp)
Definition: class.c:11343
NTSTATUS ClassReadCapacity16(_Inout_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _Inout_ PSCSI_REQUEST_BLOCK Srb)
Definition: utils.c:1568
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define FILE_FLOPPY_DISKETTE
Definition: nt_native.h:809
STORAGE_DESCRIPTOR_HEADER
Definition: ntddstor.h:560
STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR
Definition: ntddstor.h:609
* PSTORAGE_ACCESS_ALIGNMENT_DESCRIPTOR
Definition: ntddstor.h:609
struct _STORAGE_PROPERTY_QUERY * PSTORAGE_PROPERTY_QUERY
@ PropertyExistsQuery
Definition: ntddstor.h:506
@ PropertyStandardQuery
Definition: ntddstor.h:505
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
#define STATUS_INVALID_LEVEL
Definition: ntstatus.h:564
#define FILE_DEVICE_DISK
Definition: winioctl.h:113
static void Exit(void)
Definition: sock.c:1330

Referenced by ClassDeviceControl().

◆ ClasspAllocatePowerProcessIrp()

NTSTATUS ClasspAllocatePowerProcessIrp ( IN PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension)

◆ ClasspAllocateReleaseQueueIrp()

NTSTATUS ClasspAllocateReleaseQueueIrp ( IN PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension)

◆ ClasspAllocateReleaseRequest()

NTSTATUS ClasspAllocateReleaseRequest ( IN PDEVICE_OBJECT  Fdo)

Definition at line 11489 of file class.c.

11492{
11493 PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
11494
11495 PAGED_CODE();
11496
11498
11499 fdoExtension->ReleaseQueueNeeded = FALSE;
11500 fdoExtension->ReleaseQueueInProgress = FALSE;
11501 fdoExtension->ReleaseQueueIrpFromPool = FALSE;
11502
11503 //
11504 // The class driver is responsible for allocating a properly sized irp,
11505 // or ClassReleaseQueue will attempt to do it on the first error.
11506 //
11507
11508 fdoExtension->ReleaseQueueIrp = NULL;
11509
11510 //
11511 // Write length to SRB.
11512 //
11513
11514 fdoExtension->ReleaseQueueSrb.Length = sizeof(SCSI_REQUEST_BLOCK);
11515
11516 return STATUS_SUCCESS;
11517} // end ClasspAllocateReleaseRequest()
struct _SCSI_REQUEST_BLOCK SCSI_REQUEST_BLOCK
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
KSPIN_LOCK ReleaseQueueSpinLock
Definition: classpnp.h:911
SCSI_REQUEST_BLOCK ReleaseQueueSrb
Definition: classpnp.h:913
USHORT Length
Definition: srb.h:249
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461

◆ ClasspBinaryToAscii()

_IRQL_requires_same_ PUCHAR ClasspBinaryToAscii ( _In_reads_(Length) PUCHAR  HexBuffer,
_In_ ULONG  Length,
_Inout_ PULONG  UpdateLength 
)

Definition at line 7717 of file utils.c.

7744{
7745 static const UCHAR integerTable[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
7746 ULONG i;
7747 ULONG j;
7748 ULONG actualLength;
7749 PUCHAR buffer = NULL;
7750 UCHAR highWord;
7751 UCHAR lowWord;
7752
7753 TracePrint((TRACE_LEVEL_VERBOSE,
7754 TRACE_FLAG_IOCTL,
7755 "ClasspBinaryToAscii (HexBuff %p): Entering function.\n",
7756 HexBuffer));
7757
7758 if (!HexBuffer || Length == 0) {
7759 *UpdateLength = 0;
7760 goto __ClasspBinaryToAscii_Exit;
7761 }
7762
7763 //
7764 // Each byte converts into 2 chars:
7765 // e.g. 0x05 => '0' '5'
7766 // 0x0C => '0' 'C'
7767 // 0x12 => '1' '2'
7768 // And we need a terminating NULL for the string.
7769 //
7770 actualLength = (Length * 2) + 1;
7771
7772 //
7773 // Allocate the buffer.
7774 //
7775 buffer = ExAllocatePoolWithTag(NonPagedPoolNx, actualLength, CLASSPNP_POOL_TAG_TOKEN_OPERATION);
7776 if (!buffer) {
7777
7778 TracePrint((TRACE_LEVEL_ERROR,
7779 TRACE_FLAG_IOCTL,
7780 "ClasspBinaryToAscii (HexBuff %p): Failed to allocate buffer for ASCII equivalent.\n",
7781 HexBuffer));
7782
7783 *UpdateLength = 0;
7784 goto __ClasspBinaryToAscii_Exit;
7785 }
7786
7787 RtlZeroMemory(buffer, actualLength);
7788
7789 for (i = 0, j = 0; i < Length; i++) {
7790
7791 //
7792 // Split out each nibble from the binary byte.
7793 //
7794 highWord = HexBuffer[i] >> 4;
7795 lowWord = HexBuffer[i] & 0x0F;
7796
7797 //
7798 // Using the lookup table, convert and stuff into
7799 // the ascii buffer.
7800 //
7801 buffer[j++] = integerTable[highWord];
7802#ifdef _MSC_VER
7803#pragma warning(suppress: 6386) // PREFast bug means it doesn't see that Length < actualLength
7804#endif
7805 buffer[j++] = integerTable[lowWord];
7806 }
7807
7808 //
7809 // Update the caller's length field.
7810 //
7811 *UpdateLength = actualLength;
7812
7813__ClasspBinaryToAscii_Exit:
7814
7815 TracePrint((TRACE_LEVEL_VERBOSE,
7816 TRACE_FLAG_IOCTL,
7817 "ClasspBinaryToAscii (HexBuff %p): Exiting function with buffer %s.\n",
7818 HexBuffer,
7819 (buffer == NULL) ? "" : (const char*)buffer));
7820
7821 return buffer;
7822}
#define CLASSPNP_POOL_TAG_TOKEN_OPERATION
Definition: classp.h:193
GLuint buffer
Definition: glext.h:5915
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 GLint GLint j
Definition: glfuncs.h:250
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by ClasspContinueOffloadWrite(), and ClasspReceivePopulateTokenInformationTransferPacketDone().

◆ ClasspBlockLimitsDataSnapshot()

NTSTATUS ClasspBlockLimitsDataSnapshot ( _In_ PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension,
_In_ BOOLEAN  ForceQuery,
_Out_ PCLASS_VPD_B0_DATA  BlockLimitsData,
_Out_ PULONG  GenerationCount 
)

Definition at line 16504 of file class.c.

16539{
16541 KLOCK_QUEUE_HANDLE lockHandle;
16542
16544
16545 KeAcquireInStackQueuedSpinLock(&FdoExtension->FunctionSupportInfo->SyncLock, &lockHandle);
16546 *BlockLimitsData = FdoExtension->FunctionSupportInfo->BlockLimitsData;
16547 *GenerationCount = FdoExtension->FunctionSupportInfo->GenerationCount;
16548 KeReleaseInStackQueuedSpinLock(&lockHandle);
16549
16550 return status;
16551}
NTSTATUS ClasspRefreshFunctionSupportInfo(_Inout_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _In_ BOOLEAN ForceQuery)
Definition: class.c:16395

Referenced by ClasspDeviceGetLBAStatus(), ClasspDeviceLBProvisioningProperty(), and ClasspDeviceTrimProcess().

◆ ClasspBuildDeviceMdl()

PMDL ClasspBuildDeviceMdl ( PVOID  Buffer,
ULONG  BufferLen,
BOOLEAN  WriteToDevice 
)

Definition at line 582 of file utils.c.

583{
584 PMDL mdl;
585
586 mdl = IoAllocateMdl(Buffer, BufferLen, FALSE, FALSE, NULL);
587 if (mdl){
588 _SEH2_TRY {
590#ifdef _MSC_VER
591 #pragma warning(suppress: 6320) // We want to handle any exception that MmProbeAndLockPages might throw
592#endif
595
596 TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_INIT, "ClasspBuildDeviceMdl: MmProbeAndLockPages failed with %xh.", status));
597 IoFreeMdl(mdl);
598 mdl = NULL;
599 } _SEH2_END;
600 }
601 else {
602 TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_INIT, "ClasspBuildDeviceMdl: IoAllocateMdl failed"));
603 }
604
605 return mdl;
606}
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID _In_ ULONG _In_ BOOLEAN WriteToDevice
Definition: cdrom.h:992
MDL * mdl
#define IoFreeMdl
Definition: fxmdl.h:89
#define IoAllocateMdl
Definition: fxmdl.h:88
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:931
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
@ IoReadAccess
Definition: ketypes.h:851
@ IoWriteAccess
Definition: ketypes.h:852

Referenced by BuildDeviceInputMdl().

◆ ClasspBuildRequestEx()

VOID ClasspBuildRequestEx ( _In_ PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension,
_In_ PIRP  Irp,
_In_ __drv_aliasesMem PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 537 of file obsolete.c.

575{
578
579 LARGE_INTEGER startingOffset = currentIrpStack->Parameters.Read.ByteOffset;
580
581 PCDB cdb;
582 ULONG logicalBlockAddress;
583 USHORT transferBlocks;
586
587 // This function is obsolete, but still called by CDROM.SYS .
588 // TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_GENERAL, "ClasspBuildRequestEx is OBSOLETE !"));
589
590 if (Srb == NULL) {
592 return;
593 }
594
595 //
596 // Calculate relative sector address.
597 //
598
599 logicalBlockAddress =
600 (ULONG)(Int64ShrlMod32(startingOffset.QuadPart,
601 FdoExtension->SectorShift));
602
603 //
604 // Prepare the SRB.
605 // NOTE - for extended SRB, size used is based on allocation in ClasspAllocateSrb.
606 //
607
608 if (FdoExtension->AdapterDescriptor->SrbType == SRB_TYPE_STORAGE_REQUEST_BLOCK) {
612 1,
614 if (!NT_SUCCESS(status)) {
616 return;
617 }
618
620 } else {
622
623 //
624 // Write length to SRB.
625 //
626
627 Srb->Length = sizeof(SCSI_REQUEST_BLOCK);
628
630 }
631
632
633 //
634 // Set up IRP Address.
635 //
636
637 SrbSetOriginalRequest(srbHeader, Irp);
638
639 //
640 // Set up data buffer
641 //
642
643 SrbSetDataBuffer(srbHeader,
644 MmGetMdlVirtualAddress(Irp->MdlAddress));
645
646 //
647 // Save byte count of transfer in SRB Extension.
648 //
649
650 SrbSetDataTransferLength(srbHeader,
651 currentIrpStack->Parameters.Read.Length);
652
653 //
654 // Initialize the queue actions field.
655 //
656
658
659 //
660 // Queue sort key is Relative Block Address.
661 //
662
663 SrbSetQueueSortKey(srbHeader, logicalBlockAddress);
664
665 //
666 // Indicate auto request sense by specifying buffer and size.
667 //
668
669 SrbSetSenseInfoBuffer(srbHeader, FdoExtension->SenseData);
671
672 //
673 // Set timeout value of one unit per 64k bytes of data.
674 //
675
676 SrbSetTimeOutValue(srbHeader,
677 ((SrbGetDataTransferLength(srbHeader) + 0xFFFF) >> 16) *
678 FdoExtension->TimeOutValue);
679
680 //
681 // Indicate that 10-byte CDB's will be used.
682 //
683
684 SrbSetCdbLength(srbHeader, 10);
685
686 //
687 // Fill in CDB fields.
688 //
689
690 cdb = SrbGetCdb(srbHeader);
691 NT_ASSERT(cdb != NULL);
692
693 transferBlocks = (USHORT)(currentIrpStack->Parameters.Read.Length >>
694 FdoExtension->SectorShift);
695
696 //
697 // Move little endian values into CDB in big endian format.
698 //
699
700 cdb->CDB10.LogicalBlockByte0 = ((PFOUR_BYTE)&logicalBlockAddress)->Byte3;
701 cdb->CDB10.LogicalBlockByte1 = ((PFOUR_BYTE)&logicalBlockAddress)->Byte2;
702 cdb->CDB10.LogicalBlockByte2 = ((PFOUR_BYTE)&logicalBlockAddress)->Byte1;
703 cdb->CDB10.LogicalBlockByte3 = ((PFOUR_BYTE)&logicalBlockAddress)->Byte0;
704
705 cdb->CDB10.TransferBlocksMsb = ((PFOUR_BYTE)&transferBlocks)->Byte1;
706 cdb->CDB10.TransferBlocksLsb = ((PFOUR_BYTE)&transferBlocks)->Byte0;
707
708 //
709 // Set transfer direction flag and Cdb command.
710 //
711
712 if (currentIrpStack->MajorFunction == IRP_MJ_READ) {
713
714 TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_RW, "ClassBuildRequest: Read Command\n"));
715
717 cdb->CDB10.OperationCode = SCSIOP_READ;
718
719 } else {
720
721 TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_RW, "ClassBuildRequest: Write Command\n"));
722
724 cdb->CDB10.OperationCode = SCSIOP_WRITE;
725
726 }
727
728 //
729 // If this is not a write-through request, then allow caching.
730 //
731
732 if (!(currentIrpStack->Flags & SL_WRITE_THROUGH)) {
733
735
736 } else {
737
738 //
739 // If write caching is enable then force media access in the
740 // cdb.
741 //
742
743 cdb->CDB10.ForceUnitAccess = FdoExtension->CdbForceUnitAccess;
744 }
745
748 }
749
750 //
751 // OR in the default flags from the device object.
752 //
753
754 SrbSetSrbFlags(srbHeader, FdoExtension->SrbFlags);
755
756 //
757 // Set up major SCSI function.
758 //
759
760 nextIrpStack->MajorFunction = IRP_MJ_SCSI;
761
762 //
763 // Save SRB address in next stack for port driver.
764 //
765
766 nextIrpStack->Parameters.Scsi.Srb = Srb;
767
768 //
769 // Save retry count in current IRP stack.
770 //
771
772 currentIrpStack->Parameters.Others.Argument4 = (PVOID)MAXIMUM_RETRIES;
773
774 //
775 // Set up IoCompletion routine address.
776 //
777
779
780}
#define MAXIMUM_RETRIES
Definition: cdrom.h:124
#define SRB_CLASS_FLAGS_PAGING
Definition: cdrom.h:165
#define SCSIOP_WRITE
Definition: cdrw_hw.h:906
#define SCSIOP_READ
Definition: cdrw_hw.h:905
NTSTATUS InitializeStorageRequestBlock(_Inout_bytecount_(ByteSize) PSTORAGE_REQUEST_BLOCK Srb, _In_ USHORT AddressType, _In_ ULONG ByteSize, _In_ ULONG NumSrbExData,...)
Definition: srblib.c:206
FORCEINLINE UCHAR GET_FDO_EXTENSON_SENSE_DATA_LENGTH(_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: classpnp.h:1437
#define CLASS_SRBEX_SCSI_CDB16_BUFFER_SIZE
Definition: classpnp.h:695
NTSTATUS NTAPI ClassIoComplete(IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN PVOID Context)
Definition: class.c:3768
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:315
#define SRB_FLAGS_DATA_OUT
Definition: srb.h:401
#define SRB_SIMPLE_TAG_REQUEST
Definition: srb.h:423
#define SRB_FLAGS_DATA_IN
Definition: srb.h:400
#define SRB_FLAGS_ADAPTER_CACHE_ENABLE
Definition: srb.h:405
struct _FOUR_BYTE * PFOUR_BYTE
#define Int64ShrlMod32(a, b)
unsigned short USHORT
Definition: pedump.c:61
#define SRB_TYPE_STORAGE_REQUEST_BLOCK
Definition: srb.h:664
#define STORAGE_ADDRESS_TYPE_BTL8
Definition: srb.h:666
* PSTORAGE_REQUEST_BLOCK
Definition: srb.h:661
@ SrbExDataTypeScsiCdb16
Definition: srb.h:459
struct SRB_ALIGN _STORAGE_REQUEST_BLOCK_HEADER * PSTORAGE_REQUEST_BLOCK_HEADER
FORCEINLINE VOID SrbSetQueueSortKey(_In_ PVOID Srb, _In_ ULONG QueueSortKey)
Definition: srbhelper.h:839
FORCEINLINE VOID SrbSetDataTransferLength(_In_ PVOID Srb, _In_ ULONG DataTransferLength)
Definition: srbhelper.h:784
FORCEINLINE VOID SrbSetOriginalRequest(_In_ PVOID Srb, _In_opt_ PVOID OriginalRequest)
Definition: srbhelper.h:710
FORCEINLINE VOID SrbSetSenseInfoBufferLength(_In_ PVOID Srb, _In_ UCHAR SenseInfoBufferLength)
Definition: srbhelper.h:675
FORCEINLINE VOID SrbSetSenseInfoBuffer(_In_ PVOID Srb, _In_opt_ PVOID SenseInfoBuffer)
Definition: srbhelper.h:657
FORCEINLINE VOID SrbSetDataBuffer(_In_ PVOID Srb, _In_opt_ __drv_aliasesMem PVOID DataBuffer)
Definition: srbhelper.h:747
FORCEINLINE ULONG SrbGetDataTransferLength(_In_ PVOID Srb)
Definition: srbhelper.h:765
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
UCHAR Function
Definition: srb.h:250
void * PVOID
Definition: typedefs.h:50
struct _CDB::_CDB10 CDB10
LONGLONG QuadPart
Definition: typedefs.h:114
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2695
#define SL_WRITE_THROUGH
Definition: iotypes.h:1824
#define IRP_SYNCHRONOUS_PAGING_IO
#define MmGetMdlVirtualAddress(_Mdl)

Referenced by ClassBuildRequest().

◆ ClasspCalculateLogicalSectorSize()

ULONG ClasspCalculateLogicalSectorSize ( _In_ PDEVICE_OBJECT  Fdo,
_In_ ULONG  BytesPerBlockInBigEndian 
)

Definition at line 1483 of file utils.c.

1492{
1493 ULONG logicalSectorSize;
1494
1495 REVERSE_BYTES(&logicalSectorSize, &BytesPerBlockInBigEndian);
1496
1497 if (logicalSectorSize == 0) {
1498 logicalSectorSize = 512;
1499 } else {
1500 //
1501 // Clear all but the highest set bit.
1502 // That will give us a bytesPerSector value that is a power of 2.
1503 //
1504 if (logicalSectorSize & (logicalSectorSize-1)) {
1505 TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_INIT, "FDO %ph has non-standard sector size 0x%x.", Fdo, logicalSectorSize));
1506 do {
1507 logicalSectorSize &= logicalSectorSize-1;
1508 }
1509 while (logicalSectorSize & (logicalSectorSize-1));
1510 }
1511 }
1512
1513 return logicalSectorSize;
1514}
#define REVERSE_BYTES(Destination, Source)
Definition: scsi.h:3465

Referenced by InterpretCapacityData(), and InterpretReadCapacity16Data().

◆ ClasspCleanupOffloadReadContext()

VOID ClasspCleanupOffloadReadContext ( _In_ __drv_freesMem(mem) POFFLOAD_READ_CONTEXT  OffloadReadContext)

Definition at line 14335 of file class.c.

14356{
14357 PMDL populateTokenMdl;
14358
14359 populateTokenMdl = OffloadReadContext->PopulateTokenMdl;
14360
14361 NT_ASSERT(OffloadReadContext != NULL);
14362
14363 if (populateTokenMdl) {
14364 ClasspFreeDeviceMdl(populateTokenMdl);
14365 }
14366 FREE_POOL(OffloadReadContext);
14367
14368 return;
14369}
VOID ClasspFreeDeviceMdl(PMDL Mdl)
Definition: utils.c:615

Referenced by ClasspCompleteOffloadRead().

◆ ClasspCleanupOffloadWriteContext()

VOID ClasspCleanupOffloadWriteContext ( _In_ __drv_freesMem(mem) POFFLOAD_WRITE_CONTEXT  OffloadWriteContext)

Definition at line 15902 of file class.c.

15923{
15924 PMDL writeUsingTokenMdl = OffloadWriteContext->WriteUsingTokenMdl;
15925
15926 if (writeUsingTokenMdl) {
15927 ClasspFreeDeviceMdl(writeUsingTokenMdl);
15928 }
15929 FREE_POOL(OffloadWriteContext);
15930
15931 return;
15932}

Referenced by ClasspCompleteOffloadWrite().

◆ ClasspCleanupProtectedLocks()

VOID ClasspCleanupProtectedLocks ( IN PFILE_OBJECT_EXTENSION  FsContext)

Definition at line 296 of file create.c.

299{
300 PCOMMON_DEVICE_EXTENSION commonExtension =
301 FsContext->DeviceObject->DeviceExtension;
302
303 PFUNCTIONAL_DEVICE_EXTENSION fdoExtension =
304 commonExtension->PartitionZeroExtension;
305
306 ULONG newDeviceLockCount = 1;
307
308 PAGED_CODE();
309
310 TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_INIT,
311 "ClasspCleanupProtectedLocks called for %p\n",
312 FsContext->DeviceObject));
313 TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_INIT,
314 "ClasspCleanupProtectedLocks - FsContext %p is locked "
315 "%d times\n", FsContext, FsContext->LockCount));
316
318
319 //
320 // Synchronize with ejection and ejection control requests.
321 //
322
327 FALSE,
328 NULL);
329
330 //
331 // For each secure lock on this handle decrement the secured lock count
332 // for the FDO. Keep track of the new value.
333 //
334
335 if (FsContext->LockCount != 0) {
336
337 do {
338
339 InterlockedDecrement((volatile LONG *)&FsContext->LockCount);
340
341 newDeviceLockCount =
343
344 } while (FsContext->LockCount > 0);
345
346 //
347 // If the new lock count has been dropped to zero then issue a lock
348 // command to the device.
349 //
350
351 TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_INIT,
352 "ClasspCleanupProtectedLocks: FDO secured lock count = %d "
353 "lock count = %d\n",
354 fdoExtension->ProtectedLockCount,
355 fdoExtension->LockCount));
356
357 if ((newDeviceLockCount == 0) && (fdoExtension->LockCount == 0)) {
358
359 SCSI_REQUEST_BLOCK srb = {0};
360 UCHAR srbExBuffer[CLASS_SRBEX_SCSI_CDB16_BUFFER_SIZE] = {0};
362 PCDB cdb = NULL;
364 PSCSI_REQUEST_BLOCK srbPtr;
365
366 TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_INIT,
367 "ClasspCleanupProtectedLocks: FDO lock count dropped "
368 "to zero\n"));
369
370 if (fdoExtension->AdapterDescriptor->SrbType == SRB_TYPE_STORAGE_REQUEST_BLOCK) {
371#ifdef _MSC_VER
372 #pragma prefast(suppress:26015, "InitializeStorageRequestBlock ensures buffer access is bounded")
373#endif
376 sizeof(srbExBuffer),
377 1,
379 if (NT_SUCCESS(status)) {
380 srbEx->TimeOutValue = fdoExtension->TimeOutValue;
381 SrbSetCdbLength(srbEx, 6);
382 cdb = SrbGetCdb(srbEx);
383 srbPtr = (PSCSI_REQUEST_BLOCK)srbEx;
384 } else {
385 //
386 // Should not happen. Revert to legacy SRB.
387 //
389 srb.TimeOutValue = fdoExtension->TimeOutValue;
390 srb.CdbLength = 6;
391 cdb = (PCDB) &(srb.Cdb);
392 srbPtr = &srb;
393 }
394
395 } else {
396
397 srb.TimeOutValue = fdoExtension->TimeOutValue;
398 srb.CdbLength = 6;
399 cdb = (PCDB) &(srb.Cdb);
400 srbPtr = &srb;
401
402 }
403
404 cdb->MEDIA_REMOVAL.OperationCode = SCSIOP_MEDIUM_REMOVAL;
405
406 //
407 // TRUE - prevent media removal.
408 // FALSE - allow media removal.
409 //
410
411 cdb->MEDIA_REMOVAL.Prevent = FALSE;
412
414 srbPtr,
415 NULL,
416 0,
417 FALSE);
418
419 TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_INIT,
420 "ClasspCleanupProtectedLocks: unlock request to drive "
421 "returned status %lx\n", status));
422 }
423 }
424
427 FALSE);
429 return;
430}
#define VOID
Definition: acefi.h:82
#define InterlockedDecrement
Definition: armddk.h:52
#define SCSIOP_MEDIUM_REMOVAL
Definition: cdrw_hw.h:902
union _CDB * PCDB
PAGED_CODE()
NTSTATUS NTAPI ClassSendSrbSynchronous(_In_ PDEVICE_OBJECT Fdo, _Inout_ PSCSI_REQUEST_BLOCK _Srb, _In_reads_bytes_opt_(BufferLength) PVOID BufferAddress, _In_ ULONG BufferLength, _In_ BOOLEAN WriteToDevice)
Definition: class.c:4042
ULONG BreakOnClose
Definition: create.c:32
struct _SCSI_REQUEST_BLOCK * PSCSI_REQUEST_BLOCK
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
_Inout_ PLIST_ENTRY _In_ PVOID FsContext
Definition: fltkernel.h:2239
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
long LONG
Definition: pedump.c:60
struct _FUNCTIONAL_DEVICE_EXTENSION * PartitionZeroExtension
Definition: classpnp.h:599
PDEVICE_OBJECT DeviceObject
Definition: classpnp.h:871
ULONG TimeOutValue
Definition: srb.h:262
UCHAR CdbLength
Definition: srb.h:258