ReactOS  0.4.15-dev-1377-ga59cecd
classpnp.h File Reference
#include <ntdddisk.h>
#include <ntddcdrm.h>
#include <ntddtape.h>
#include <ntddscsi.h>
#include <ntddstor.h>
#include <stdio.h>
#include <scsi.h>
Include dependency graph for classpnp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _DICTIONARY
 
struct  _CLASSPNP_SCAN_FOR_SPECIAL_INFO
 
struct  _SRB_HISTORY_ITEM
 
struct  _SRB_HISTORY
 
struct  GUIDREGINFO
 
struct  _CLASS_WMI_INFO
 
struct  _CLASS_DEV_INFO
 
struct  _CLASS_INIT_DATA
 
struct  _FILE_OBJECT_EXTENSION
 
struct  _CLASS_WORKING_SET
 
struct  _CLASS_INTERPRET_SENSE_INFO2
 
struct  _CLASS_DRIVER_EXTENSION
 
struct  _COMMON_DEVICE_EXTENSION
 
struct  _PHYSICAL_DEVICE_EXTENSION
 
struct  _CLASS_POWER_OPTIONS
 
struct  _CLASS_POWER_CONTEXT
 
struct  _COMPLETION_CONTEXT
 
struct  _CLASS_QUERY_WMI_REGINFO_EX_LIST
 
struct  _CLASS_VPD_B1_DATA
 
struct  _CLASS_VPD_B0_DATA
 
struct  _CLASS_VPD_B2_DATA
 
struct  _CLASS_READ_CAPACITY16_DATA
 
struct  _CLASS_VPD_ECOP_BLOCK_DEVICE_ROD_LIMITS
 
struct  _CLASS_FUNCTION_SUPPORT_INFO
 
struct  _FUNCTIONAL_DEVICE_EXTENSION
 

Macros

#define _CLASS_
 
#define max(a, b)   (((a) > (b)) ? (a) : (b))
 
#define min(a, b)   (((a) < (b)) ? (a) : (b))
 
#define SRB_CLASS_FLAGS_LOW_PRIORITY   0x10000000
 
#define SRB_CLASS_FLAGS_PERSISTANT   0x20000000
 
#define SRB_CLASS_FLAGS_PAGING   0x40000000
 
#define SRB_CLASS_FLAGS_FREE_MDL   0x80000000
 
#define ASSERT_FDO(x)   ASSERT(((PCOMMON_DEVICE_EXTENSION) (x)->DeviceExtension)->IsFdo)
 
#define ASSERT_PDO(x)   ASSERT(!(((PCOMMON_DEVICE_EXTENSION) (x)->DeviceExtension)->IsFdo))
 
#define IS_CLEANUP_REQUEST(majorFunction)
 
#define DO_MCD(fdoExtension)
 
#define IS_SCSIOP_READ(opCode)
 
#define IS_SCSIOP_WRITE(opCode)
 
#define IS_SCSIOP_READWRITE(opCode)   (IS_SCSIOP_READ(opCode) || IS_SCSIOP_WRITE(opCode))
 
#define ADJUST_FUA_FLAG(fdoExt)
 
#define FREE_POOL(_PoolPtr)
 
#define CLASS_TAG_AUTORUN_DISABLE   'ALcS'
 
#define CLASS_TAG_FILE_OBJECT_EXTENSION   'FLcS'
 
#define CLASS_TAG_MEDIA_CHANGE_DETECTION   'MLcS'
 
#define CLASS_TAG_MOUNT   'mLcS'
 
#define CLASS_TAG_RELEASE_QUEUE   'qLcS'
 
#define CLASS_TAG_POWER   'WLcS'
 
#define CLASS_TAG_WMI   'wLcS'
 
#define CLASS_TAG_FAILURE_PREDICT   'fLcS'
 
#define CLASS_TAG_DEVICE_CONTROL   'OIcS'
 
#define CLASS_TAG_MODE_DATA   'oLcS'
 
#define CLASS_TAG_MULTIPATH   'mPcS'
 
#define CLASS_TAG_LOCK_TRACKING   'TLcS'
 
#define CLASS_TAG_LB_PROVISIONING   'PLcS'
 
#define CLASS_TAG_MANAGE_DATASET   'MDcS'
 
#define MAXIMUM_RETRIES   4
 
#define CLASS_DRIVER_EXTENSION_KEY   ((PVOID) ClassInitialize)
 
#define NO_REMOVE   0
 
#define REMOVE_PENDING   1
 
#define REMOVE_COMPLETE   2
 
#define ClassAcquireRemoveLock(devobj, tag)   ClassAcquireRemoveLockEx(devobj, tag, __FILE__, __LINE__)
 
#define TRY
 
#define LEAVE   goto __tryLabel;
 
#define FINALLY   __tryLabel:
 
#define DebugPrint(x)
 
#define DEBUG_BUFFER_LENGTH   256
 
#define START_UNIT_TIMEOUT   (60 * 4)
 
#define MEDIA_CHANGE_DEFAULT_TIME   1
 
#define MEDIA_CHANGE_TIMEOUT_TIME   300
 
#define ClasspAllocateSrb(ext)
 
#define ClasspFreeSrb(ext, srb)
 
#define SET_FLAG(Flags, Bit)   ((Flags) |= (Bit))
 
#define CLEAR_FLAG(Flags, Bit)   ((Flags) &= ~(Bit))
 
#define TEST_FLAG(Flags, Bit)   (((Flags) & (Bit)) != 0)
 
#define CLASS_WORKING_SET_MAXIMUM   2048
 
#define CLASS_INTERPRET_SENSE_INFO2_MAXIMUM_HISTORY_COUNT   30000
 
#define CLASS_SPECIAL_DISABLE_SPIN_DOWN   0x00000001
 
#define CLASS_SPECIAL_DISABLE_SPIN_UP   0x00000002
 
#define CLASS_SPECIAL_NO_QUEUE_LOCK   0x00000008
 
#define CLASS_SPECIAL_DISABLE_WRITE_CACHE   0x00000010
 
#define CLASS_SPECIAL_CAUSE_NOT_REPORTABLE_HACK   0x00000020
 
#define CLASS_SPECIAL_DISABLE_WRITE_CACHE_NOT_SUPPORTED   0x00000040
 
#define CLASS_SPECIAL_MODIFY_CACHE_UNSUCCESSFUL   0x00000040
 
#define CLASS_SPECIAL_FUA_NOT_SUPPORTED   0x00000080
 
#define CLASS_SPECIAL_VALID_MASK   0x000000FB
 
#define CLASS_SPECIAL_RESERVED   (~CLASS_SPECIAL_VALID_MASK)
 
#define DEV_WRITE_CACHE   0x00000001
 
#define DEV_USE_SCSI1   0x00000002
 
#define DEV_SAFE_START_UNIT   0x00000004
 
#define DEV_NO_12BYTE_CDB   0x00000008
 
#define DEV_POWER_PROTECTED   0x00000010
 
#define DEV_USE_16BYTE_CDB   0x00000020
 
#define GUID_CLASSPNP_QUERY_REGINFOEX   {0x00e34b11, 0x2444, 0x4745, {0xa5, 0x3d, 0x62, 0x01, 0x00, 0xcd, 0x82, 0xf7}}
 
#define GUID_CLASSPNP_SENSEINFO2   {0x509a8c5f, 0x71d7, 0x48f6, {0x82, 0x1e, 0x17, 0x3c, 0x49, 0xbf, 0x2f, 0x18}}
 
#define GUID_CLASSPNP_WORKING_SET   {0x105701b0, 0x9e9b, 0x47cb, {0x97, 0x80, 0x81, 0x19, 0x8a, 0xf7, 0xb5, 0x24}}
 
#define GUID_CLASSPNP_SRB_SUPPORT   {0x0a483941, 0xbdfd, 0x4f7b, {0xbe, 0x95, 0xce, 0xe2, 0xa2, 0x16, 0x09, 0x0c}}
 
#define DEFAULT_FAILURE_PREDICTION_PERIOD   60 * 60 * 1
 
#define MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS   (0x3b9aca00)
 
#define CLASS_SRB_SCSI_REQUEST_BLOCK   0x1
 
#define CLASS_SRB_STORAGE_REQUEST_BLOCK   0x2
 
#define CLASS_SRBEX_SCSI_CDB16_BUFFER_SIZE   (sizeof(STORAGE_REQUEST_BLOCK) + sizeof(STOR_ADDR_BTL8) + sizeof(SRBEX_DATA_SCSI_CDB16))
 
#define CLASS_SRBEX_NO_SRBEX_DATA_BUFFER_SIZE   (sizeof(STORAGE_REQUEST_BLOCK) + sizeof(STOR_ADDR_BTL8))
 

Typedefs

typedef enum _MEDIA_CHANGE_DETECTION_STATE MEDIA_CHANGE_DETECTION_STATE
 
typedef enum _MEDIA_CHANGE_DETECTION_STATEPMEDIA_CHANGE_DETECTION_STATE
 
typedef enum _CLASS_DEBUG_LEVEL CLASS_DEBUG_LEVEL
 
typedef enum _CLASS_DEBUG_LEVELPCLASS_DEBUG_LEVEL
 
typedef enum FAILURE_PREDICTION_METHODPFAILURE_PREDICTION_METHOD
 
typedef struct _CLASS_INIT_DATA CLASS_INIT_DATA
 
typedef struct _CLASS_INIT_DATAPCLASS_INIT_DATA
 
typedef struct _CLASS_PRIVATE_FDO_DATA CLASS_PRIVATE_FDO_DATA
 
typedef struct _CLASS_PRIVATE_FDO_DATAPCLASS_PRIVATE_FDO_DATA
 
typedef struct _CLASS_PRIVATE_PDO_DATA CLASS_PRIVATE_PDO_DATA
 
typedef struct _CLASS_PRIVATE_PDO_DATA * PCLASS_PRIVATE_PDO_DATA
 
typedef struct _CLASS_PRIVATE_COMMON_DATA CLASS_PRIVATE_COMMON_DATA
 
typedef struct _CLASS_PRIVATE_COMMON_DATAPCLASS_PRIVATE_COMMON_DATA
 
typedef struct _MEDIA_CHANGE_DETECTION_INFO MEDIA_CHANGE_DETECTION_INFO
 
typedef struct _MEDIA_CHANGE_DETECTION_INFOPMEDIA_CHANGE_DETECTION_INFO
 
typedef struct _DICTIONARY_HEADER DICTIONARY_HEADER
 
typedef struct _DICTIONARY_HEADERPDICTIONARY_HEADER
 
typedef struct _DICTIONARY DICTIONARY
 
typedef struct _DICTIONARYPDICTIONARY
 
typedef struct _CLASSPNP_SCAN_FOR_SPECIAL_INFO CLASSPNP_SCAN_FOR_SPECIAL_INFO
 
typedef struct _CLASSPNP_SCAN_FOR_SPECIAL_INFOPCLASSPNP_SCAN_FOR_SPECIAL_INFO
 
typedef NTSTATUS(NTAPIPCLASS_POWER_DEVICE) (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
 
typedef struct _SRB_HISTORY_ITEM SRB_HISTORY_ITEM
 
typedef struct _SRB_HISTORY_ITEMPSRB_HISTORY_ITEM
 
typedef struct _SRB_HISTORY SRB_HISTORY
 
typedef struct _SRB_HISTORYPSRB_HISTORY
 
typedef struct GUIDREGINFOPGUIDREGINFO
 
typedef struct _CLASS_WMI_INFO CLASS_WMI_INFO
 
typedef struct _CLASS_WMI_INFOPCLASS_WMI_INFO
 
typedef struct _CLASS_DEV_INFO CLASS_DEV_INFO
 
typedef struct _CLASS_DEV_INFOPCLASS_DEV_INFO
 
typedef struct _FILE_OBJECT_EXTENSION FILE_OBJECT_EXTENSION
 
typedef struct _FILE_OBJECT_EXTENSIONPFILE_OBJECT_EXTENSION
 
typedef struct _CLASS_WORKING_SET CLASS_WORKING_SET
 
typedef struct _CLASS_WORKING_SETPCLASS_WORKING_SET
 
typedef struct _CLASS_INTERPRET_SENSE_INFO2 CLASS_INTERPRET_SENSE_INFO2
 
typedef struct _CLASS_INTERPRET_SENSE_INFO2PCLASS_INTERPRET_SENSE_INFO2
 
typedef struct _CLASS_DRIVER_EXTENSION CLASS_DRIVER_EXTENSION
 
typedef struct _CLASS_DRIVER_EXTENSIONPCLASS_DRIVER_EXTENSION
 
typedef struct _COMMON_DEVICE_EXTENSION COMMON_DEVICE_EXTENSION
 
typedef struct _COMMON_DEVICE_EXTENSIONPCOMMON_DEVICE_EXTENSION
 
typedef struct _PHYSICAL_DEVICE_EXTENSION PHYSICAL_DEVICE_EXTENSION
 
typedef struct _PHYSICAL_DEVICE_EXTENSIONPPHYSICAL_DEVICE_EXTENSION
 
typedef struct _CLASS_POWER_OPTIONS CLASS_POWER_OPTIONS
 
typedef struct _CLASS_POWER_OPTIONSPCLASS_POWER_OPTIONS
 
typedef struct _CLASS_POWER_CONTEXT CLASS_POWER_CONTEXT
 
typedef struct _CLASS_POWER_CONTEXTPCLASS_POWER_CONTEXT
 
typedef struct _COMPLETION_CONTEXT COMPLETION_CONTEXT
 
typedef struct _COMPLETION_CONTEXTPCOMPLETION_CONTEXT
 
typedef struct _CLASS_QUERY_WMI_REGINFO_EX_LIST CLASS_QUERY_WMI_REGINFO_EX_LIST
 
typedef struct _CLASS_QUERY_WMI_REGINFO_EX_LISTPCLASS_QUERY_WMI_REGINFO_EX_LIST
 
typedef struct _CLASS_VPD_B1_DATA CLASS_VPD_B1_DATA
 
typedef struct _CLASS_VPD_B1_DATAPCLASS_VPD_B1_DATA
 
typedef struct _CLASS_VPD_B0_DATA CLASS_VPD_B0_DATA
 
typedef struct _CLASS_VPD_B0_DATAPCLASS_VPD_B0_DATA
 
typedef struct _CLASS_VPD_B2_DATA CLASS_VPD_B2_DATA
 
typedef struct _CLASS_VPD_B2_DATAPCLASS_VPD_B2_DATA
 
typedef struct _CLASS_READ_CAPACITY16_DATA CLASS_READ_CAPACITY16_DATA
 
typedef struct _CLASS_READ_CAPACITY16_DATAPCLASS_READ_CAPACITY16_DATA
 
typedef struct _CLASS_VPD_ECOP_BLOCK_DEVICE_ROD_LIMITS CLASS_VPD_ECOP_BLOCK_DEVICE_ROD_LIMITS
 
typedef struct _CLASS_VPD_ECOP_BLOCK_DEVICE_ROD_LIMITSPCLASS_VPD_ECOP_BLOCK_DEVICE_ROD_LIMITS
 
typedef struct _CLASS_FUNCTION_SUPPORT_INFO CLASS_FUNCTION_SUPPORT_INFO
 
typedef struct _CLASS_FUNCTION_SUPPORT_INFOPCLASS_FUNCTION_SUPPORT_INFO
 
typedef struct _FUNCTIONAL_DEVICE_EXTENSION FUNCTIONAL_DEVICE_EXTENSION
 
typedef struct _FUNCTIONAL_DEVICE_EXTENSIONPFUNCTIONAL_DEVICE_EXTENSION
 

Enumerations

enum  _MEDIA_CHANGE_DETECTION_STATE {
  MediaUnknown, MediaPresent, MediaNotPresent, MediaUnavailable,
  MediaUnknown, MediaPresent, MediaNotPresent, MediaUnavailable
}
 
enum  _CLASS_DEBUG_LEVEL {
  ClassDebugError = 0, ClassDebugWarning = 1, ClassDebugTrace = 2, ClassDebugInfo = 3,
  ClassDebugMediaLocks = 8, ClassDebugMCN = 9, ClassDebugDelayedRetry = 10, ClassDebugSenseInfo = 11,
  ClassDebugRemoveLock = 12, ClassDebugExternal4 = 13, ClassDebugExternal3 = 14, ClassDebugExternal2 = 15,
  ClassDebugExternal1 = 16
}
 
enum  CLASSENABLEDISABLEFUNCTION { EventGeneration, DataBlockCollection }
 
enum  FAILURE_PREDICTION_METHOD { FailurePredictionNone = 0, FailurePredictionIoctl, FailurePredictionSmart, FailurePredictionSense }
 
enum  CLASS_POWER_DOWN_STATE {
  PowerDownDeviceInitial, PowerDownDeviceLocked, PowerDownDeviceStopped, PowerDownDeviceOff,
  PowerDownDeviceUnlocked
}
 
enum  CLASS_POWER_DOWN_STATE2 {
  PowerDownDeviceInitial2, PowerDownDeviceLocked2, PowerDownDeviceFlushed2, PowerDownDeviceStopped2,
  PowerDownDeviceOff2, PowerDownDeviceUnlocked2
}
 
enum  CLASS_POWER_DOWN_STATE3 {
  PowerDownDeviceInitial3 = 0, PowerDownDeviceLocked3, PowerDownDeviceQuiesced3, PowerDownDeviceFlushed3,
  PowerDownDeviceStopped3, PowerDownDeviceOff3, PowerDownDeviceUnlocked3
}
 
enum  CLASS_POWER_UP_STATE {
  PowerUpDeviceInitial, PowerUpDeviceLocked, PowerUpDeviceOn, PowerUpDeviceStarted,
  PowerUpDeviceUnlocked
}
 
enum  CLASS_FUNCTION_SUPPORT { SupportUnknown = 0, Supported, NotSupported }
 

Functions

static ULONG CountOfSetBitsUChar (UCHAR _X)
 
static ULONG CountOfSetBitsULong (ULONG _X)
 
static ULONG CountOfSetBitsULong32 (ULONG32 _X)
 
static ULONG CountOfSetBitsULong64 (ULONG64 _X)
 
static ULONG CountOfSetBitsUlongPtr (ULONG_PTR _X)
 
 _IRQL_requires_max_ (DISPATCH_LEVEL) typedef VOID(NTAPI *PCLASS_ERROR)(_In_ PDEVICE_OBJECT DeviceObject
 
 _IRQL_requires_max_ (PASSIVE_LEVEL) typedef NTSTATUS(NTAPI *PCLASS_ADD_DEVICE)(_In_ PDRIVER_OBJECT DriverObject
 
 _IRQL_requires_ (DISPATCH_LEVEL) typedef VOID(NTAPI *PCLASS_TICK)(_In_ PDEVICE_OBJECT DeviceObject)
 
_In_ PIRP _In_ ULONG _In_ ULONG _Out_writes_bytes_ (BufferAvail) PUCHAR Buffer)
 
_In_ PIRP _In_ ULONG _In_ ULONG _In_reads_bytes_ (BufferSize) PUCHAR Buffer)
 
_In_ PIRP _In_ ULONG _In_ ULONG _In_ ULONG _In_ ULONG _In_reads_ (_Inexpressible_(max(InBufferSize, OutBufferSize))) PUCHAR Buffer)
 
_In_opt_ PIRP _In_ PSCSI_REQUEST_BLOCK _In_ UCHAR _In_ ULONG _In_ ULONG _In_opt_ SRB_HISTORY _Out_ NTSTATUS _Out_ _Deref_out_range_ (0, MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS) LONGLONG *RetryIn100nsUnits)
 
 C_ASSERT ((MAXULONG - sizeof(SRB_HISTORY))/30000 >=sizeof(SRB_HISTORY_ITEM))
 
_In_z_ PCCHAR _In_ PDEVICE_OBJECT _In_ BOOLEAN _Outptr_result_nullonfailure_ _At_DeviceObject (Mem) __drv_aliasesMem) PDEVICE_OBJECT *DeviceObject
 
_Must_inspect_result_ SCSIPORT_API NTSTATUS NTAPI ClassReadDriveCapacity (_In_ PDEVICE_OBJECT DeviceObject)
 
SCSIPORT_API VOID NTAPI ClassReleaseQueue (_In_ PDEVICE_OBJECT DeviceObject)
 
SCSIPORT_API VOID NTAPI ClassSplitRequest (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ ULONG MaximumBytes)
 
SCSIPORT_API NTSTATUS NTAPI ClassDeviceControl (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
 
SCSIPORT_API NTSTATUS NTAPI ClassIoComplete (PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
 
SCSIPORT_API NTSTATUS NTAPI ClassIoCompleteAssociated (PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
 
SCSIPORT_API BOOLEAN NTAPI ClassInterpretSenseInfo (_In_ PDEVICE_OBJECT DeviceObject, _In_ PSCSI_REQUEST_BLOCK Srb, _In_ UCHAR MajorFunctionCode, _In_ ULONG IoDeviceCode, _In_ ULONG RetryCount, _Out_ NTSTATUS *Status, _Out_opt_ _Deref_out_range_(0, 100) ULONG *RetryInterval)
 
VOID NTAPI ClassSendDeviceIoControlSynchronous (_In_ ULONG IoControlCode, _In_ PDEVICE_OBJECT TargetDeviceObject, _Inout_updates_opt_(_Inexpressible_(max(InputBufferLength, OutputBufferLength))) PVOID Buffer, _In_ ULONG InputBufferLength, _In_ ULONG OutputBufferLength, _In_ BOOLEAN InternalDeviceIoControl, _Out_ PIO_STATUS_BLOCK IoStatus)
 
SCSIPORT_API NTSTATUS NTAPI ClassSendIrpSynchronous (_In_ PDEVICE_OBJECT TargetDeviceObject, _In_ PIRP Irp)
 
SCSIPORT_API NTSTATUS NTAPI ClassForwardIrpSynchronous (_In_ PCOMMON_DEVICE_EXTENSION CommonExtension, _In_ PIRP Irp)
 
SCSIPORT_API NTSTATUS NTAPI ClassSendSrbSynchronous (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PSCSI_REQUEST_BLOCK Srb, _In_reads_bytes_opt_(BufferLength) PVOID BufferAddress, _In_ ULONG BufferLength, _In_ BOOLEAN WriteToDevice)
 
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)
 
SCSIPORT_API NTSTATUS NTAPI ClassBuildRequest (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
 
SCSIPORT_API ULONG NTAPI ClassModeSense (_In_ PDEVICE_OBJECT DeviceObject, _In_reads_bytes_(Length) PCHAR ModeSenseBuffer, _In_ ULONG Length, _In_ UCHAR PageMode)
 
SCSIPORT_API PVOID NTAPI ClassFindModePage (_In_reads_bytes_(Length) PCHAR ModeSenseBuffer, _In_ ULONG Length, _In_ UCHAR PageMode, _In_ BOOLEAN Use6Byte)
 
SCSIPORT_API NTSTATUS NTAPI ClassInternalIoControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
SCSIPORT_API VOID ClassDebugPrint (_In_ CLASS_DEBUG_LEVEL DebugPrintLevel, _In_z_ PCCHAR DebugMessage,...)
 
SCSIPORT_API VOID NTAPI ClassCompleteRequest (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ CCHAR PriorityBoost)
 
SCSIPORT_API VOID NTAPI ClassReleaseRemoveLock (_In_ PDEVICE_OBJECT DeviceObject, PIRP Tag)
 
SCSIPORT_API ULONG NTAPI ClassAcquireRemoveLockEx (_In_ PDEVICE_OBJECT DeviceObject, PVOID Tag, _In_ PCSTR File, _In_ ULONG Line)
 
_In_ PCHAR _In_ ULONG _In_reads_bytes_opt_ (InquiryDataLength) PINQUIRYDATA InquiryData
 
SCSIPORT_API NTSTATUS NTAPI ClassWmiCompleteRequest (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _In_ NTSTATUS Status, _In_ ULONG BufferUsed, _In_ CCHAR PriorityBoost)
 
_In_ LPGUID _In_ ULONG _In_ ULONG _In_reads_bytes_ (EventDataSize) PVOID EventData)
 
SCSIPORT_API VOID NTAPI ClassResetMediaChangeTimer (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
SCSIPORT_API PVPB NTAPI ClassGetVpb (_In_ PDEVICE_OBJECT DeviceObject)
 
SCSIPORT_API NTSTATUS NTAPI ClassSpinDownPowerHandler (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
 
NTSTATUS NTAPI ClassStopUnitPowerHandler (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
 
SCSIPORT_API VOID NTAPI ClassReleaseChildLock (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
VOID NTAPI ClassSendStartUnit (_In_ PDEVICE_OBJECT DeviceObject)
 
SCSIPORT_API NTSTATUS NTAPI ClassAsynchronousCompletion (PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Event)
 
SCSIPORT_API VOID NTAPI ClassCheckMediaState (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
SCSIPORT_API NTSTATUS NTAPI ClassCheckVerifyComplete (PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
 
_In_ const GUID _In_ ULONG _In_reads_bytes_opt_ (ExtraDataSize) PVOID ExtraData)
 
__inline UCHAR GET_FDO_EXTENSON_SENSE_DATA_LENGTH (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
static __inline BOOLEAN PORT_ALLOCATED_SENSE (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _In_ PSCSI_REQUEST_BLOCK Srb)
 
static __inline VOID FREE_PORT_ALLOCATED_SENSE_BUFFER (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _In_ PSCSI_REQUEST_BLOCK Srb)
 

Variables

_In_ PSCSI_REQUEST_BLOCK Srb
 
_In_ PSCSI_REQUEST_BLOCK _Out_ NTSTATUSStatus
 
_In_ PSCSI_REQUEST_BLOCK _Out_ NTSTATUS _Inout_ BOOLEANRetry
 
_In_ PDEVICE_OBJECT Pdo
 
_In_ UCHAR Type
 
_In_ PIRP Irp
 
_In_ BUS_QUERY_ID_TYPE IdType
 
_In_ BUS_QUERY_ID_TYPE _In_ PUNICODE_STRING IdString
 
_In_ PDEVICE_CAPABILITIES Capabilities
 
_Out_ ULONGRegFlags
 
_Out_ ULONG _Out_ PUNICODE_STRING Name
 
_Out_ ULONG _Out_ PUNICODE_STRING _Out_ PUNICODE_STRING MofResourceName
 
_In_ PIRP _In_ ULONG GuidIndex
 
_In_ PIRP _In_ ULONG _In_ ULONG BufferAvail
 
_In_ PIRP _In_ ULONG _In_ ULONG BufferSize
 
_In_ PIRP _In_ ULONG _In_ ULONG DataItemId
 
_In_ PIRP _In_ ULONG _In_ ULONG MethodId
 
_In_ PIRP _In_ ULONG _In_ ULONG _In_ ULONG InBufferSize
 
_In_ PIRP _In_ ULONG _In_ ULONG _In_ ULONG _In_ ULONG OutBufferSize
 
_In_ PIRP _In_ ULONG _In_ CLASSENABLEDISABLEFUNCTION Function
 
_In_ PIRP _In_ ULONG _In_ CLASSENABLEDISABLEFUNCTION _In_ BOOLEAN Enable
 
_In_opt_ PIRP OriginalRequest
 
_In_opt_ PIRP _In_ PSCSI_REQUEST_BLOCK _In_ UCHAR MajorFunctionCode
 
_In_opt_ PIRP _In_ PSCSI_REQUEST_BLOCK _In_ UCHAR _In_ ULONG IoDeviceCode
 
_In_opt_ PIRP _In_ PSCSI_REQUEST_BLOCK _In_ UCHAR _In_ ULONG _In_ ULONG PreviousRetryCount
 
_In_opt_ PIRP _In_ PSCSI_REQUEST_BLOCK _In_ UCHAR _In_ ULONG _In_ ULONG _In_opt_ SRB_HISTORYRequestHistory
 
_In_ PVOID Argument2
 
_In_ PVOID _In_ PCLASS_INIT_DATA InitializationData
 
_In_ LPGUID Guid
 
_In_ LPGUID _In_ PVOID Data
 
_In_z_ PCCHAR ObjectNameBuffer
 
_In_z_ PCCHAR _In_ PDEVICE_OBJECT LowerDeviceObject
 
_In_z_ PCCHAR _In_ PDEVICE_OBJECT _In_ BOOLEAN IsFdo
 
_In_ BOOLEAN Release
 
_In_ ULONG NumberElements
 
_In_ PSTORAGE_PROPERTY_ID PropertyId
 
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PVOIDDescriptor
 
_In_ BOOLEAN AcquireChildLock
 
_In_ PCHAR DeviceName
 
_In_ PCHAR _In_ ULONG DeviceNumber
 
_In_ PCHAR _In_ ULONG _In_ ULONG InquiryDataLength
 
_In_ LPGUID _In_ ULONG InstanceIndex
 
_In_ LPGUID _In_ ULONG _In_ ULONG EventDataSize
 
_In_ PUCHAR EventPrefix
 
_In_ BOOLEAN AllowDriveToSleep
 
_In_ FAILURE_PREDICTION_METHOD FailurePredictionMethod
 
_In_ FAILURE_PREDICTION_METHOD _In_ ULONG PollingPeriod
 
_In_ ULONG _In_ BOOLEAN LogError
 
_In_ ULONG _In_ BOOLEAN _In_ ULONG UniqueErrorValue
 
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR PathId
 
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR TargetId
 
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR _In_ UCHAR Lun
 
IO_COMPLETION_ROUTINE ClassSignalCompletion
 
_In_ UCHAR RemoveType
 
_In_ MEDIA_CHANGE_DETECTION_STATE State
 
_In_ MEDIA_CHANGE_DETECTION_STATE _In_ BOOLEAN Wait
 
_In_opt_ PWSTR SubkeyName
 
_In_opt_ PWSTR _In_ PWSTR ParameterName
 
_In_opt_ PWSTR _In_ PWSTR _Inout_ PULONG ParameterValue
 
_In_ PFILE_OBJECT FileObject
 
_In_ const GUID _In_ ULONG ExtraDataSize
 
_In_ CLASSPNP_SCAN_FOR_SPECIAL_INFO DeviceList []
 

Macro Definition Documentation

◆ _CLASS_

#define _CLASS_

Definition at line 4 of file classpnp.h.

◆ ADJUST_FUA_FLAG

#define ADJUST_FUA_FLAG (   fdoExt)
Value:
{ \
if (TEST_FLAG(fdoExt->DeviceFlags, DEV_WRITE_CACHE) && \
!TEST_FLAG(fdoExt->DeviceFlags, DEV_POWER_PROTECTED) && \
!TEST_FLAG(fdoExt->ScanForSpecialFlags, CLASS_SPECIAL_FUA_NOT_SUPPORTED) ) { \
fdoExt->CdbForceUnitAccess = TRUE; \
} else { \
fdoExt->CdbForceUnitAccess = FALSE; \
} \
}
#define CLASS_SPECIAL_FUA_NOT_SUPPORTED
Definition: classpnp.h:174
#define TEST_FLAG(Flags, Bit)
Definition: classpnp.h:159
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define DEV_POWER_PROTECTED
Definition: classpnp.h:182
#define DEV_WRITE_CACHE
Definition: classpnp.h:178

Definition at line 53 of file classpnp.h.

◆ ASSERT_FDO

#define ASSERT_FDO (   x)    ASSERT(((PCOMMON_DEVICE_EXTENSION) (x)->DeviceExtension)->IsFdo)

Definition at line 24 of file classpnp.h.

◆ ASSERT_PDO

#define ASSERT_PDO (   x)    ASSERT(!(((PCOMMON_DEVICE_EXTENSION) (x)->DeviceExtension)->IsFdo))

Definition at line 27 of file classpnp.h.

◆ CLASS_DRIVER_EXTENSION_KEY

#define CLASS_DRIVER_EXTENSION_KEY   ((PVOID) ClassInitialize)

Definition at line 94 of file classpnp.h.

◆ CLASS_INTERPRET_SENSE_INFO2_MAXIMUM_HISTORY_COUNT

#define CLASS_INTERPRET_SENSE_INFO2_MAXIMUM_HISTORY_COUNT   30000

Definition at line 163 of file classpnp.h.

◆ CLASS_SPECIAL_CAUSE_NOT_REPORTABLE_HACK

#define CLASS_SPECIAL_CAUSE_NOT_REPORTABLE_HACK   0x00000020

Definition at line 169 of file classpnp.h.

◆ CLASS_SPECIAL_DISABLE_SPIN_DOWN

#define CLASS_SPECIAL_DISABLE_SPIN_DOWN   0x00000001

Definition at line 165 of file classpnp.h.

◆ CLASS_SPECIAL_DISABLE_SPIN_UP

#define CLASS_SPECIAL_DISABLE_SPIN_UP   0x00000002

Definition at line 166 of file classpnp.h.

◆ CLASS_SPECIAL_DISABLE_WRITE_CACHE

#define CLASS_SPECIAL_DISABLE_WRITE_CACHE   0x00000010

Definition at line 168 of file classpnp.h.

◆ CLASS_SPECIAL_DISABLE_WRITE_CACHE_NOT_SUPPORTED

#define CLASS_SPECIAL_DISABLE_WRITE_CACHE_NOT_SUPPORTED   0x00000040

Definition at line 171 of file classpnp.h.

◆ CLASS_SPECIAL_FUA_NOT_SUPPORTED

#define CLASS_SPECIAL_FUA_NOT_SUPPORTED   0x00000080

Definition at line 174 of file classpnp.h.

◆ CLASS_SPECIAL_MODIFY_CACHE_UNSUCCESSFUL

#define CLASS_SPECIAL_MODIFY_CACHE_UNSUCCESSFUL   0x00000040

Definition at line 173 of file classpnp.h.

◆ CLASS_SPECIAL_NO_QUEUE_LOCK

#define CLASS_SPECIAL_NO_QUEUE_LOCK   0x00000008

Definition at line 167 of file classpnp.h.

◆ CLASS_SPECIAL_RESERVED

#define CLASS_SPECIAL_RESERVED   (~CLASS_SPECIAL_VALID_MASK)

Definition at line 176 of file classpnp.h.

◆ CLASS_SPECIAL_VALID_MASK

#define CLASS_SPECIAL_VALID_MASK   0x000000FB

Definition at line 175 of file classpnp.h.

◆ CLASS_SRB_SCSI_REQUEST_BLOCK

#define CLASS_SRB_SCSI_REQUEST_BLOCK   0x1

Definition at line 572 of file classpnp.h.

◆ CLASS_SRB_STORAGE_REQUEST_BLOCK

#define CLASS_SRB_STORAGE_REQUEST_BLOCK   0x2

Definition at line 573 of file classpnp.h.

◆ CLASS_SRBEX_NO_SRBEX_DATA_BUFFER_SIZE

#define CLASS_SRBEX_NO_SRBEX_DATA_BUFFER_SIZE   (sizeof(STORAGE_REQUEST_BLOCK) + sizeof(STOR_ADDR_BTL8))

Definition at line 696 of file classpnp.h.

◆ CLASS_SRBEX_SCSI_CDB16_BUFFER_SIZE

#define CLASS_SRBEX_SCSI_CDB16_BUFFER_SIZE   (sizeof(STORAGE_REQUEST_BLOCK) + sizeof(STOR_ADDR_BTL8) + sizeof(SRBEX_DATA_SCSI_CDB16))

Definition at line 695 of file classpnp.h.

◆ CLASS_TAG_AUTORUN_DISABLE

#define CLASS_TAG_AUTORUN_DISABLE   'ALcS'

Definition at line 77 of file classpnp.h.

◆ CLASS_TAG_DEVICE_CONTROL

#define CLASS_TAG_DEVICE_CONTROL   'OIcS'

Definition at line 85 of file classpnp.h.

◆ CLASS_TAG_FAILURE_PREDICT

#define CLASS_TAG_FAILURE_PREDICT   'fLcS'

Definition at line 84 of file classpnp.h.

◆ CLASS_TAG_FILE_OBJECT_EXTENSION

#define CLASS_TAG_FILE_OBJECT_EXTENSION   'FLcS'

Definition at line 78 of file classpnp.h.

◆ CLASS_TAG_LB_PROVISIONING

#define CLASS_TAG_LB_PROVISIONING   'PLcS'

Definition at line 89 of file classpnp.h.

◆ CLASS_TAG_LOCK_TRACKING

#define CLASS_TAG_LOCK_TRACKING   'TLcS'

Definition at line 88 of file classpnp.h.

◆ CLASS_TAG_MANAGE_DATASET

#define CLASS_TAG_MANAGE_DATASET   'MDcS'

Definition at line 90 of file classpnp.h.

◆ CLASS_TAG_MEDIA_CHANGE_DETECTION

#define CLASS_TAG_MEDIA_CHANGE_DETECTION   'MLcS'

Definition at line 79 of file classpnp.h.

◆ CLASS_TAG_MODE_DATA

#define CLASS_TAG_MODE_DATA   'oLcS'

Definition at line 86 of file classpnp.h.

◆ CLASS_TAG_MOUNT

#define CLASS_TAG_MOUNT   'mLcS'

Definition at line 80 of file classpnp.h.

◆ CLASS_TAG_MULTIPATH

#define CLASS_TAG_MULTIPATH   'mPcS'

Definition at line 87 of file classpnp.h.

◆ CLASS_TAG_POWER

#define CLASS_TAG_POWER   'WLcS'

Definition at line 82 of file classpnp.h.

◆ CLASS_TAG_RELEASE_QUEUE

#define CLASS_TAG_RELEASE_QUEUE   'qLcS'

Definition at line 81 of file classpnp.h.

◆ CLASS_TAG_WMI

#define CLASS_TAG_WMI   'wLcS'

Definition at line 83 of file classpnp.h.

◆ CLASS_WORKING_SET_MAXIMUM

#define CLASS_WORKING_SET_MAXIMUM   2048

Definition at line 161 of file classpnp.h.

◆ ClassAcquireRemoveLock

#define ClassAcquireRemoveLock (   devobj,
  tag 
)    ClassAcquireRemoveLockEx(devobj, tag, __FILE__, __LINE__)

Definition at line 100 of file classpnp.h.

◆ ClasspAllocateSrb

#define ClasspAllocateSrb (   ext)
Value:
ExAllocateFromNPagedLookasideList( \
&((ext)->CommonExtension.SrbLookasideList))
char ext[3]
Definition: mkdosfs.c:358

Definition at line 146 of file classpnp.h.

◆ ClasspFreeSrb

#define ClasspFreeSrb (   ext,
  srb 
)
Value:
ExFreeToNPagedLookasideList( \
&((ext)->CommonExtension.SrbLookasideList), \
(srb))
char ext[3]
Definition: mkdosfs.c:358

Definition at line 150 of file classpnp.h.

◆ CLEAR_FLAG

#define CLEAR_FLAG (   Flags,
  Bit 
)    ((Flags) &= ~(Bit))

Definition at line 158 of file classpnp.h.

◆ DEBUG_BUFFER_LENGTH

#define DEBUG_BUFFER_LENGTH   256

Definition at line 128 of file classpnp.h.

◆ DebugPrint

#define DebugPrint (   x)

Definition at line 125 of file classpnp.h.

◆ DEFAULT_FAILURE_PREDICTION_PERIOD

#define DEFAULT_FAILURE_PREDICTION_PERIOD   60 * 60 * 1

Definition at line 190 of file classpnp.h.

◆ DEV_NO_12BYTE_CDB

#define DEV_NO_12BYTE_CDB   0x00000008

Definition at line 181 of file classpnp.h.

◆ DEV_POWER_PROTECTED

#define DEV_POWER_PROTECTED   0x00000010

Definition at line 182 of file classpnp.h.

◆ DEV_SAFE_START_UNIT

#define DEV_SAFE_START_UNIT   0x00000004

Definition at line 180 of file classpnp.h.

◆ DEV_USE_16BYTE_CDB

#define DEV_USE_16BYTE_CDB   0x00000020

Definition at line 183 of file classpnp.h.

◆ DEV_USE_SCSI1

#define DEV_USE_SCSI1   0x00000002

Definition at line 179 of file classpnp.h.

◆ DEV_WRITE_CACHE

#define DEV_WRITE_CACHE   0x00000001

Definition at line 178 of file classpnp.h.

◆ DO_MCD

#define DO_MCD (   fdoExtension)
Value:
(((fdoExtension)->MediaChangeDetectionInfo != NULL) && \
((fdoExtension)->MediaChangeDetectionInfo->MediaChangeDetectionDisableCount == 0))
#define NULL
Definition: types.h:112

Definition at line 35 of file classpnp.h.

◆ FINALLY

#define FINALLY   __tryLabel:

Definition at line 116 of file classpnp.h.

◆ FREE_POOL

#define FREE_POOL (   _PoolPtr)
Value:
if (_PoolPtr != NULL) { \
ExFreePool(_PoolPtr); \
_PoolPtr = NULL; \
}
#define NULL
Definition: types.h:112

Definition at line 63 of file classpnp.h.

◆ GUID_CLASSPNP_QUERY_REGINFOEX

#define GUID_CLASSPNP_QUERY_REGINFOEX   {0x00e34b11, 0x2444, 0x4745, {0xa5, 0x3d, 0x62, 0x01, 0x00, 0xcd, 0x82, 0xf7}}

Definition at line 185 of file classpnp.h.

◆ GUID_CLASSPNP_SENSEINFO2

#define GUID_CLASSPNP_SENSEINFO2   {0x509a8c5f, 0x71d7, 0x48f6, {0x82, 0x1e, 0x17, 0x3c, 0x49, 0xbf, 0x2f, 0x18}}

Definition at line 186 of file classpnp.h.

◆ GUID_CLASSPNP_SRB_SUPPORT

#define GUID_CLASSPNP_SRB_SUPPORT   {0x0a483941, 0xbdfd, 0x4f7b, {0xbe, 0x95, 0xce, 0xe2, 0xa2, 0x16, 0x09, 0x0c}}

Definition at line 188 of file classpnp.h.

◆ GUID_CLASSPNP_WORKING_SET

#define GUID_CLASSPNP_WORKING_SET   {0x105701b0, 0x9e9b, 0x47cb, {0x97, 0x80, 0x81, 0x19, 0x8a, 0xf7, 0xb5, 0x24}}

Definition at line 187 of file classpnp.h.

◆ IS_CLEANUP_REQUEST

#define IS_CLEANUP_REQUEST (   majorFunction)
Value:
#define IRP_MJ_SHUTDOWN
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
UCHAR majorFunction
#define IRP_MJ_CLEANUP

Definition at line 30 of file classpnp.h.

◆ IS_SCSIOP_READ

#define IS_SCSIOP_READ (   opCode)
Value:
((opCode == SCSIOP_READ6) || \
(opCode == SCSIOP_READ) || \
(opCode == SCSIOP_READ12) || \
(opCode == SCSIOP_READ16))
#define SCSIOP_READ
Definition: cdrw_hw.h:905
#define SCSIOP_READ16
Definition: scsi.h:914
#define SCSIOP_READ6
Definition: cdrw_hw.h:874
#define SCSIOP_READ12
Definition: cdrw_hw.h:956

Definition at line 39 of file classpnp.h.

◆ IS_SCSIOP_READWRITE

#define IS_SCSIOP_READWRITE (   opCode)    (IS_SCSIOP_READ(opCode) || IS_SCSIOP_WRITE(opCode))

Definition at line 51 of file classpnp.h.

◆ IS_SCSIOP_WRITE

#define IS_SCSIOP_WRITE (   opCode)
Value:
((opCode == SCSIOP_WRITE6) || \
(opCode == SCSIOP_WRITE) || \
(opCode == SCSIOP_WRITE12) || \
(opCode == SCSIOP_WRITE16))
#define SCSIOP_WRITE16
Definition: scsi.h:915
#define SCSIOP_WRITE12
Definition: cdrw_hw.h:957
#define SCSIOP_WRITE
Definition: cdrw_hw.h:906
#define SCSIOP_WRITE6
Definition: cdrw_hw.h:876

Definition at line 45 of file classpnp.h.

◆ LEAVE

#define LEAVE   goto __tryLabel;

Definition at line 115 of file classpnp.h.

◆ max

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

Definition at line 16 of file classpnp.h.

◆ MAXIMUM_RETRIES

#define MAXIMUM_RETRIES   4

Definition at line 92 of file classpnp.h.

◆ MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS

#define MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS   (0x3b9aca00)

Definition at line 192 of file classpnp.h.

◆ MEDIA_CHANGE_DEFAULT_TIME

#define MEDIA_CHANGE_DEFAULT_TIME   1

Definition at line 132 of file classpnp.h.

◆ MEDIA_CHANGE_TIMEOUT_TIME

#define MEDIA_CHANGE_TIMEOUT_TIME   300

Definition at line 133 of file classpnp.h.

◆ min

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

Definition at line 17 of file classpnp.h.

◆ NO_REMOVE

#define NO_REMOVE   0

Definition at line 96 of file classpnp.h.

◆ REMOVE_COMPLETE

#define REMOVE_COMPLETE   2

Definition at line 98 of file classpnp.h.

◆ REMOVE_PENDING

#define REMOVE_PENDING   1

Definition at line 97 of file classpnp.h.

◆ SET_FLAG

#define SET_FLAG (   Flags,
  Bit 
)    ((Flags) |= (Bit))

Definition at line 157 of file classpnp.h.

◆ SRB_CLASS_FLAGS_FREE_MDL

#define SRB_CLASS_FLAGS_FREE_MDL   0x80000000

Definition at line 22 of file classpnp.h.

◆ SRB_CLASS_FLAGS_LOW_PRIORITY

#define SRB_CLASS_FLAGS_LOW_PRIORITY   0x10000000

Definition at line 19 of file classpnp.h.

◆ SRB_CLASS_FLAGS_PAGING

#define SRB_CLASS_FLAGS_PAGING   0x40000000

Definition at line 21 of file classpnp.h.

◆ SRB_CLASS_FLAGS_PERSISTANT

#define SRB_CLASS_FLAGS_PERSISTANT   0x20000000

Definition at line 20 of file classpnp.h.

◆ START_UNIT_TIMEOUT

#define START_UNIT_TIMEOUT   (60 * 4)

Definition at line 130 of file classpnp.h.

◆ TEST_FLAG

#define TEST_FLAG (   Flags,
  Bit 
)    (((Flags) & (Bit)) != 0)

Definition at line 159 of file classpnp.h.

◆ TRY

#define TRY

Definition at line 114 of file classpnp.h.

Typedef Documentation

◆ CLASS_DEBUG_LEVEL

◆ CLASS_DEV_INFO

◆ CLASS_DRIVER_EXTENSION

◆ CLASS_FUNCTION_SUPPORT_INFO

◆ CLASS_INIT_DATA

Definition at line 276 of file classpnp.h.

◆ CLASS_INTERPRET_SENSE_INFO2

◆ CLASS_POWER_CONTEXT

◆ CLASS_POWER_OPTIONS

◆ CLASS_PRIVATE_COMMON_DATA

◆ CLASS_PRIVATE_FDO_DATA

◆ CLASS_PRIVATE_PDO_DATA

typedef struct _CLASS_PRIVATE_PDO_DATA CLASS_PRIVATE_PDO_DATA

Definition at line 282 of file classpnp.h.

◆ CLASS_QUERY_WMI_REGINFO_EX_LIST

◆ CLASS_READ_CAPACITY16_DATA

◆ CLASS_VPD_B0_DATA

◆ CLASS_VPD_B1_DATA

◆ CLASS_VPD_B2_DATA

◆ CLASS_VPD_ECOP_BLOCK_DEVICE_ROD_LIMITS

◆ CLASS_WMI_INFO

◆ CLASS_WORKING_SET

◆ CLASSPNP_SCAN_FOR_SPECIAL_INFO

◆ COMMON_DEVICE_EXTENSION

◆ COMPLETION_CONTEXT

◆ DICTIONARY

◆ DICTIONARY_HEADER

Definition at line 291 of file classpnp.h.

◆ FILE_OBJECT_EXTENSION

◆ FUNCTIONAL_DEVICE_EXTENSION

◆ MEDIA_CHANGE_DETECTION_INFO

◆ MEDIA_CHANGE_DETECTION_STATE

◆ PCLASS_DEBUG_LEVEL

◆ PCLASS_DEV_INFO

◆ PCLASS_DRIVER_EXTENSION

◆ PCLASS_FUNCTION_SUPPORT_INFO

◆ PCLASS_INIT_DATA

Definition at line 276 of file classpnp.h.

◆ PCLASS_INTERPRET_SENSE_INFO2

◆ PCLASS_POWER_CONTEXT

◆ PCLASS_POWER_DEVICE

typedef NTSTATUS(NTAPI * PCLASS_POWER_DEVICE) (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)

Definition at line 321 of file classpnp.h.

◆ PCLASS_POWER_OPTIONS

◆ PCLASS_PRIVATE_COMMON_DATA

◆ PCLASS_PRIVATE_FDO_DATA

Definition at line 279 of file classpnp.h.

◆ PCLASS_PRIVATE_PDO_DATA

typedef struct _CLASS_PRIVATE_PDO_DATA * PCLASS_PRIVATE_PDO_DATA

Definition at line 282 of file classpnp.h.

◆ PCLASS_QUERY_WMI_REGINFO_EX_LIST

◆ PCLASS_READ_CAPACITY16_DATA

◆ PCLASS_VPD_B0_DATA

◆ PCLASS_VPD_B1_DATA

◆ PCLASS_VPD_B2_DATA

◆ PCLASS_VPD_ECOP_BLOCK_DEVICE_ROD_LIMITS

◆ PCLASS_WMI_INFO

◆ PCLASS_WORKING_SET

◆ PCLASSPNP_SCAN_FOR_SPECIAL_INFO

◆ PCOMMON_DEVICE_EXTENSION

◆ PCOMPLETION_CONTEXT

◆ PDICTIONARY

◆ PDICTIONARY_HEADER

Definition at line 291 of file classpnp.h.

◆ PFAILURE_PREDICTION_METHOD

◆ PFILE_OBJECT_EXTENSION

◆ PFUNCTIONAL_DEVICE_EXTENSION

◆ PGUIDREGINFO

◆ PHYSICAL_DEVICE_EXTENSION

◆ PMEDIA_CHANGE_DETECTION_INFO

◆ PMEDIA_CHANGE_DETECTION_STATE

◆ PPHYSICAL_DEVICE_EXTENSION

◆ PSRB_HISTORY

◆ PSRB_HISTORY_ITEM

◆ SRB_HISTORY

◆ SRB_HISTORY_ITEM

Enumeration Type Documentation

◆ _CLASS_DEBUG_LEVEL

Enumerator
ClassDebugError 
ClassDebugWarning 
ClassDebugTrace 
ClassDebugInfo 
ClassDebugMediaLocks 
ClassDebugMCN 
ClassDebugDelayedRetry 
ClassDebugSenseInfo 
ClassDebugRemoveLock 
ClassDebugExternal4 
ClassDebugExternal3 
ClassDebugExternal2 
ClassDebugExternal1 

Definition at line 212 of file classpnp.h.

◆ _MEDIA_CHANGE_DETECTION_STATE

Enumerator
MediaUnknown 
MediaPresent 
MediaNotPresent 
MediaUnavailable 
MediaUnknown 
MediaPresent 
MediaNotPresent 
MediaUnavailable 

Definition at line 205 of file classpnp.h.

205  {
206  MediaUnknown,
207  MediaPresent,
enum _MEDIA_CHANGE_DETECTION_STATE MEDIA_CHANGE_DETECTION_STATE
enum _MEDIA_CHANGE_DETECTION_STATE * PMEDIA_CHANGE_DETECTION_STATE

◆ CLASS_FUNCTION_SUPPORT

Enumerator
SupportUnknown 
Supported 
NotSupported 

Definition at line 730 of file classpnp.h.

731 {
732  SupportUnknown = 0,
733  Supported,
CLASS_FUNCTION_SUPPORT
Definition: classpnp.h:730

◆ CLASS_POWER_DOWN_STATE

Enumerator
PowerDownDeviceInitial 
PowerDownDeviceLocked 
PowerDownDeviceStopped 
PowerDownDeviceOff 
PowerDownDeviceUnlocked 

Definition at line 240 of file classpnp.h.

◆ CLASS_POWER_DOWN_STATE2

Enumerator
PowerDownDeviceInitial2 
PowerDownDeviceLocked2 
PowerDownDeviceFlushed2 
PowerDownDeviceStopped2 
PowerDownDeviceOff2 
PowerDownDeviceUnlocked2 

Definition at line 248 of file classpnp.h.

◆ CLASS_POWER_DOWN_STATE3

Enumerator
PowerDownDeviceInitial3 
PowerDownDeviceLocked3 
PowerDownDeviceQuiesced3 
PowerDownDeviceFlushed3 
PowerDownDeviceStopped3 
PowerDownDeviceOff3 
PowerDownDeviceUnlocked3 

Definition at line 257 of file classpnp.h.

◆ CLASS_POWER_UP_STATE

Enumerator
PowerUpDeviceInitial 
PowerUpDeviceLocked 
PowerUpDeviceOn 
PowerUpDeviceStarted 
PowerUpDeviceUnlocked 

Definition at line 267 of file classpnp.h.

◆ CLASSENABLEDISABLEFUNCTION

Enumerator
EventGeneration 
DataBlockCollection 

Definition at line 228 of file classpnp.h.

◆ FAILURE_PREDICTION_METHOD

Enumerator
FailurePredictionNone 
FailurePredictionIoctl 
FailurePredictionSmart 
FailurePredictionSense 

Definition at line 233 of file classpnp.h.

Function Documentation

◆ _Deref_out_range_()

◆ _In_reads_()

_In_ PIRP _In_ ULONG _In_ ULONG _In_ ULONG _In_ ULONG _In_reads_ ( _Inexpressible_(max(InBufferSize, OutBufferSize))  )

◆ _In_reads_bytes_() [1/2]

_In_ PIRP _In_ ULONG _In_ ULONG _In_reads_bytes_ ( BufferSize  )

◆ _In_reads_bytes_() [2/2]

_In_ LPGUID _In_ ULONG _In_ ULONG _In_reads_bytes_ ( EventDataSize  )

◆ _In_reads_bytes_opt_() [1/2]

_In_ PCHAR _In_ ULONG _In_reads_bytes_opt_ ( InquiryDataLength  )

◆ _In_reads_bytes_opt_() [2/2]

_In_ const GUID _In_ ULONG _In_reads_bytes_opt_ ( ExtraDataSize  )

◆ _IRQL_requires_()

_IRQL_requires_ ( DISPATCH_LEVEL  )

Definition at line 1448 of file expool.c.

1453 {
1454  ULONG OldSize = PoolBigPageTableSize;
1455  ULONG NewSize = 2 * OldSize;
1456  ULONG NewSizeInBytes;
1457  PPOOL_TRACKER_BIG_PAGES NewTable;
1458  PPOOL_TRACKER_BIG_PAGES OldTable;
1459  ULONG i;
1460  ULONG PagesFreed;
1461  ULONG Hash;
1462  ULONG HashMask;
1463 
1464  /* Must be holding ExpLargePoolTableLock */
1466 
1467  /* Make sure we don't overflow */
1468  if (!NT_SUCCESS(RtlULongMult(2,
1469  OldSize * sizeof(POOL_TRACKER_BIG_PAGES),
1470  &NewSizeInBytes)))
1471  {
1472  DPRINT1("Overflow expanding big page table. Size=%lu\n", OldSize);
1474  return FALSE;
1475  }
1476 
1477  NewTable = MiAllocatePoolPages(NonPagedPool, NewSizeInBytes);
1478  if (NewTable == NULL)
1479  {
1480  DPRINT1("Could not allocate %lu bytes for new big page table\n", NewSizeInBytes);
1482  return FALSE;
1483  }
1484 
1485  DPRINT("Expanding big pool tracker table to %lu entries\n", NewSize);
1486 
1487  /* Initialize the new table */
1488  RtlZeroMemory(NewTable, NewSizeInBytes);
1489  for (i = 0; i < NewSize; i++)
1490  {
1491  NewTable[i].Va = (PVOID)POOL_BIG_TABLE_ENTRY_FREE;
1492  }
1493 
1494  /* Copy over all items */
1495  OldTable = PoolBigPageTable;
1496  HashMask = NewSize - 1;
1497  for (i = 0; i < OldSize; i++)
1498  {
1499  /* Skip over empty items */
1500  if ((ULONG_PTR)OldTable[i].Va & POOL_BIG_TABLE_ENTRY_FREE)
1501  {
1502  continue;
1503  }
1504 
1505  /* Recalculate the hash due to the new table size */
1506  Hash = ExpComputePartialHashForAddress(OldTable[i].Va) & HashMask;
1507 
1508  /* Find the location in the new table */
1509  while (!((ULONG_PTR)NewTable[Hash].Va & POOL_BIG_TABLE_ENTRY_FREE))
1510  {
1511  Hash = (Hash + 1) & HashMask;
1512  }
1513 
1514  /* We just enlarged the table, so we must have space */
1516 
1517  /* Finally, copy the item */
1518  NewTable[Hash] = OldTable[i];
1519  }
1520 
1521  /* Activate the new table */
1522  PoolBigPageTable = NewTable;
1525 
1526  /* Release the lock, we're done changing global state */
1528 
1529  /* Free the old table and update our tracker */
1530  PagesFreed = MiFreePoolPages(OldTable);
1531  ExpRemovePoolTracker('looP', PagesFreed << PAGE_SHIFT, 0);
1532  ExpInsertPoolTracker('looP', ALIGN_UP_BY(NewSizeInBytes, PAGE_SIZE), 0);
1533 
1534  return TRUE;
1535 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
static int Hash(const char *)
Definition: reader.c:2257
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define TRUE
Definition: types.h:120
uint32_t ULONG_PTR
Definition: typedefs.h:65
KSPIN_LOCK ExpLargePoolTableLock
Definition: expool.c:46
#define FALSE
Definition: types.h:117
SIZE_T PoolBigPageTableSize
Definition: expool.c:39
void DPRINT(...)
Definition: polytest.cpp:61
void * PVOID
Definition: retypes.h:9
VOID NTAPI ExpRemovePoolTracker(IN ULONG Key, IN SIZE_T NumberOfBytes, IN POOL_TYPE PoolType)
Definition: expool.c:748
#define ASSERT(a)
Definition: mode.c:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PVOID NTAPI MiAllocatePoolPages(IN POOL_TYPE PoolType, IN SIZE_T SizeInBytes)
Definition: pool.c:420
ULONG NTAPI MiFreePoolPages(IN PVOID StartingAddress)
Definition: pool.c:905
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
_Must_inspect_result_ _In_ USHORT NewSize
Definition: fltkernel.h:975
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
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 NTAPI ExpInsertPoolTracker(IN ULONG Key, IN SIZE_T NumberOfBytes, IN POOL_TYPE PoolType)
Definition: expool.c:839
#define NULL
Definition: types.h:112
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
FORCEINLINE ULONG ExpComputePartialHashForAddress(IN PVOID BaseAddress)
Definition: expool.c:449
#define DPRINT1
Definition: precomp.h:8
PPOOL_TRACKER_BIG_PAGES PoolBigPageTable
Definition: expool.c:42
SIZE_T PoolBigPageTableHash
Definition: expool.c:39
#define POOL_BIG_TABLE_ENTRY_FREE
Definition: expool.c:23
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ALIGN_UP_BY(size, align)

◆ _IRQL_requires_max_() [1/2]

_IRQL_requires_max_ ( DISPATCH_LEVEL  )

Definition at line 3557 of file common.c.

3587 {
3588  NTSTATUS status;
3589  BOOLEAN requestSent = FALSE;
3590 
3591  BOOLEAN shouldRetry = TRUE;
3592  PCDB cdb = (PCDB)DeviceExtension->PowerContext.Srb.Cdb;
3593  ULONG timeoutValue = DeviceExtension->TimeOutValue;
3594  ULONG retryCount = 1;
3595 
3596  // reset some fields.
3597  DeviceExtension->PowerContext.RetryIntervalIn100ns = 0;
3598  status = PowerContextReuseRequest(DeviceExtension);
3599  RequestClearSendTime(DeviceExtension->PowerContext.PowerRequest);
3600 
3601  if (!NT_SUCCESS(status))
3602  {
3603  return status;
3604  }
3605 
3606  // set proper timeout value and max retry count.
3607  switch(DeviceExtension->PowerContext.PowerChangeState.PowerDown)
3608  {
3612  break;
3613 
3614  case PowerDownDeviceLocked:
3615  // Case of issuing SYNC CACHE command. Do not use power irp timeout remaining time in this case
3616  // as we want to give best try on SYNC CACHE command.
3617  retryCount = MAXIMUM_RETRIES;
3618  timeoutValue = DeviceExtension->TimeOutValue;
3619  break;
3620 
3622  {
3623  // Case of issuing STOP UNIT command
3624  // As "Imme" bit is set to '1', this command should be completed in short time.
3625  // This command is at low importance, failure of this command has very small impact.
3626  ULONG secondsRemaining = 0;
3627 
3628 #if (WINVER >= 0x0601)
3629  // this API is introduced in Windows7
3630  PoQueryWatchdogTime(DeviceExtension->LowerPdo, &secondsRemaining);
3631 #endif
3632 
3633  if (secondsRemaining == 0)
3634  {
3635  // not able to retrieve remaining time from PoQueryWatchdogTime API, use default values.
3636  retryCount = MAXIMUM_RETRIES;
3637  timeoutValue = SCSI_CDROM_TIMEOUT;
3638  }
3639  else
3640  {
3641  // plan to leave about 30 seconds to lower level drivers if possible.
3642  if (secondsRemaining >= 32)
3643  {
3644  retryCount = (secondsRemaining - 30)/SCSI_CDROM_TIMEOUT + 1;
3645  timeoutValue = SCSI_CDROM_TIMEOUT;
3646 
3647  if (retryCount > MAXIMUM_RETRIES)
3648  {
3649  retryCount = MAXIMUM_RETRIES;
3650  }
3651 
3652  if (retryCount == 1)
3653  {
3654  timeoutValue = secondsRemaining - 30;
3655  }
3656  }
3657  else
3658  {
3659  // issue the command with minimal timeout value and do not retry on it.
3660  retryCount = 1;
3661  timeoutValue = 2;
3662  }
3663  }
3664  }
3665  break;
3666  default:
3667  NT_ASSERT( FALSE );
3669  return status;
3670  }
3671 
3672  DeviceExtension->PowerContext.RetryCount = retryCount;
3673 
3674  // issue command.
3675  while (shouldRetry)
3676  {
3677 
3678  // set SRB fields.
3679  DeviceExtension->PowerContext.Srb.SrbFlags = SRB_FLAGS_NO_DATA_TRANSFER |
3684 
3685  DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_EXECUTE_SCSI;
3686  DeviceExtension->PowerContext.Srb.TimeOutValue = timeoutValue;
3687 
3688  if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceInitial)
3689  {
3690  DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_LOCK_QUEUE;
3691  }
3692  else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceLocked)
3693  {
3694  DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_QUIESCE_DEVICE;
3695  }
3696  else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceQuiesced)
3697  {
3698  // Case of issuing SYNC CACHE command.
3699  DeviceExtension->PowerContext.Srb.CdbLength = 10;
3700  cdb->SYNCHRONIZE_CACHE10.OperationCode = SCSIOP_SYNCHRONIZE_CACHE;
3701  }
3702  else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceFlushed)
3703  {
3704  // Case of issuing STOP UNIT command.
3705  DeviceExtension->PowerContext.Srb.CdbLength = 6;
3706  cdb->START_STOP.OperationCode = SCSIOP_START_STOP_UNIT;
3707  cdb->START_STOP.Start = 0;
3708  cdb->START_STOP.Immediate = 1;
3709  }
3710  else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceStopped)
3711  {
3712  DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_UNLOCK_QUEUE;
3713  }
3714 
3715  // Set up completion routine and context if requested
3716  if (CompletionRoutine)
3717  {
3718  WdfRequestSetCompletionRoutine(DeviceExtension->PowerContext.PowerRequest,
3720  Context);
3721  }
3722 
3723  status = RequestSend(DeviceExtension,
3724  DeviceExtension->PowerContext.PowerRequest,
3725  DeviceExtension->IoTarget,
3727  &requestSent);
3728 
3729  if (requestSent)
3730  {
3731  if ((CompletionRoutine == NULL) &&
3732  (SRB_STATUS(DeviceExtension->PowerContext.Srb.SrbStatus) != SRB_STATUS_SUCCESS))
3733  {
3734  TracePrint((TRACE_LEVEL_ERROR,
3735  TRACE_FLAG_POWER,
3736  "%p\tError occured when issuing %s command to device. Srb %p, Status %x\n",
3737  DeviceExtension->PowerContext.PowerRequest,
3738  (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceQuiesced) ? "SYNC CACHE" : "STOP UNIT",
3739  &DeviceExtension->PowerContext.Srb,
3740  DeviceExtension->PowerContext.Srb.SrbStatus));
3741 
3742  NT_ASSERT(!(TEST_FLAG(DeviceExtension->PowerContext.Srb.SrbStatus, SRB_STATUS_QUEUE_FROZEN)));
3743 
3744  shouldRetry = RequestSenseInfoInterpret(DeviceExtension,
3745  DeviceExtension->PowerContext.PowerRequest,
3746  &(DeviceExtension->PowerContext.Srb),
3747  retryCount - DeviceExtension->PowerContext.RetryCount,
3748  &status,
3749  &(DeviceExtension->PowerContext.RetryIntervalIn100ns));
3750 
3751  if (shouldRetry && (DeviceExtension->PowerContext.RetryCount-- == 0))
3752  {
3753  shouldRetry = FALSE;
3754  }
3755  }
3756  else
3757  {
3758  // succeeded, do not need to retry.
3759  shouldRetry = FALSE;
3760  }
3761 
3762  }
3763  else
3764  {
3765  // request failed to be sent
3766  shouldRetry = FALSE;
3767  }
3768 
3769  if (shouldRetry)
3770  {
3771  LARGE_INTEGER t;
3772  t.QuadPart = -DeviceExtension->PowerContext.RetryIntervalIn100ns;
3774 
3775  status = PowerContextReuseRequest(DeviceExtension);
3776  if (!NT_SUCCESS(status))
3777  {
3778  shouldRetry = FALSE;
3779  }
3780  }
3781  }
3782 
3783  if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceQuiesced)
3784  {
3785  // record SYNC CACHE command completion time stamp.
3786  KeQueryTickCount(&DeviceExtension->PowerContext.Step1CompleteTime);
3787  }
3788 
3789  return status;
3790 }
#define SRB_FUNCTION_UNLOCK_QUEUE
Definition: srb.h:325
#define SCSIOP_SYNCHRONIZE_CACHE
Definition: cdrw_hw.h:918
#define SRB_FUNCTION_QUIESCE_DEVICE
Definition: srb.h:90
#define SRB_FLAGS_NO_QUEUE_FREEZE
Definition: srb.h:396
#define TRUE
Definition: types.h:120
Definition: cdrw_hw.h:28
LONG NTSTATUS
Definition: precomp.h:26
struct _CDB::_SYNCHRONIZE_CACHE10 SYNCHRONIZE_CACHE10
GLdouble GLdouble t
Definition: gl.h:2047
#define SRB_STATUS(Status)
Definition: srb.h:381
VOID RequestClearSendTime(_In_ WDFREQUEST Request)
Definition: common.c:111
#define MAXIMUM_RETRIES
Definition: cdrom.h:124
return STATUS_NOT_IMPLEMENTED
#define SCSI_CDROM_TIMEOUT
Definition: cdrom.c:170
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI KeDelayExecutionThread(IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Interval OPTIONAL)
Definition: wait.c:283
#define SRB_FLAGS_BYPASS_LOCKED_QUEUE
Definition: srb.h:402
unsigned char BOOLEAN
union _CDB * PCDB
struct _CDB::_START_STOP START_STOP
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
#define TEST_FLAG(Flags, Bit)
Definition: cdrom.h:1495
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SRB_FLAGS_DISABLE_SYNCH_TRANSFER
Definition: srb.h:389
#define SRB_FLAGS_NO_DATA_TRANSFER
Definition: srb.h:394
BOOLEAN RequestSenseInfoInterpret(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ PSCSI_REQUEST_BLOCK Srb, _In_ ULONG RetriedCount, _Out_ NTSTATUS *Status, _Out_opt_ _Deref_out_range_(0, MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS) LONGLONG *RetryIntervalIn100ns)
Definition: sense.c:2467
#define SRB_STATUS_QUEUE_FROZEN
Definition: srb.h:378
NTSTATUS RequestSend(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDFIOTARGET IoTarget, _In_ ULONG Flags, _Out_opt_ PBOOLEAN RequestSent)
Definition: common.c:3793
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine
Definition: wdfrequest.h:893
#define NULL
Definition: types.h:112
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:307
unsigned int ULONG
Definition: retypes.h:1
#define SRB_STATUS_SUCCESS
Definition: srb.h:333
#define SRB_FLAGS_D3_PROCESSING
Definition: srb.h:156
static SERVICE_STATUS status
Definition: service.c:31
#define SCSIOP_START_STOP_UNIT
Definition: cdrw_hw.h:897
#define SRB_FUNCTION_LOCK_QUEUE
Definition: srb.h:324
#define NT_ASSERT
Definition: rtlfuncs.h:3312
Definition: ps.c:97

◆ _IRQL_requires_max_() [2/2]

_IRQL_requires_max_ ( PASSIVE_LEVEL  )

Definition at line 64 of file Messaging.c.

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

◆ _Out_writes_bytes_()

_In_ PIRP _In_ ULONG _In_ ULONG _Out_writes_bytes_ ( BufferAvail  )

◆ C_ASSERT()

C_ASSERT ( (MAXULONG - sizeof(SRB_HISTORY))/30000 >=sizeof(SRB_HISTORY_ITEM )

◆ ClassAcquireRemoveLockEx()

SCSIPORT_API ULONG NTAPI ClassAcquireRemoveLockEx ( _In_ PDEVICE_OBJECT  DeviceObject,
PVOID  Tag,
_In_ PCSTR  File,
_In_ ULONG  Line 
)

◆ ClassAsynchronousCompletion()

SCSIPORT_API NTSTATUS NTAPI ClassAsynchronousCompletion ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp,
PVOID  Event 
)

Definition at line 3246 of file class.c.

3251 {
3253  PSCSI_REQUEST_BLOCK srb;
3254  ULONG srbFunction;
3255  ULONG srbFlags;
3256 
3257  if (context == NULL) {
3258  return STATUS_INVALID_PARAMETER;
3259  }
3260 
3261  if (DeviceObject == NULL) {
3262 
3263  DeviceObject = context->DeviceObject;
3264  }
3265 
3266  srb = &context->Srb.Srb;
3267 
3269  srbFunction = ((PSTORAGE_REQUEST_BLOCK)srb)->SrbFunction;
3270  srbFlags = ((PSTORAGE_REQUEST_BLOCK)srb)->SrbFlags;
3271  } else {
3272  srbFunction = srb->Function;
3273  srbFlags = srb->SrbFlags;
3274  }
3275 
3276  //
3277  // If this is an execute srb, then check the return status and make sure.
3278  // the queue is not frozen.
3279  //
3280 
3281  if (srbFunction == SRB_FUNCTION_EXECUTE_SCSI) {
3282 
3283  //
3284  // Check for a frozen queue.
3285  //
3286 
3287  if (srb->SrbStatus & SRB_STATUS_QUEUE_FROZEN) {
3288 
3289  //
3290  // Unfreeze the queue getting the device object from the context.
3291  //
3292 
3293  ClassReleaseQueue(context->DeviceObject);
3294  }
3295  }
3296 
3297  { // free port-allocated sense buffer if we can detect
3298 
3299  if (((PCOMMON_DEVICE_EXTENSION)(DeviceObject->DeviceExtension))->IsFdo) {
3300 
3301  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = DeviceObject->DeviceExtension;
3302  if (PORT_ALLOCATED_SENSE(fdoExtension, srb)) {
3303  FREE_PORT_ALLOCATED_SENSE_BUFFER(fdoExtension, srb);
3304  }
3305 
3306  } else {
3307 
3309 
3310  }
3311  }
3312 
3313 
3314  //
3315  // Free the context and the Irp.
3316  //
3317 
3318  if (Irp->MdlAddress != NULL) {
3319  MmUnlockPages(Irp->MdlAddress);
3320  IoFreeMdl(Irp->MdlAddress);
3321 
3322  Irp->MdlAddress = NULL;
3323  }
3324 
3326 
3327  FREE_POOL(context);
3328 
3329  IoFreeIrp(Irp);
3330 
3331  //
3332  // Indicate the I/O system should stop processing the Irp completion.
3333  //
3334 
3336 
3337 } // end ClassAsynchronousCompletion()
ULONG SrbFlags
Definition: srb.h:252
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
Definition: http.c:7094
#define SRB_FLAGS_FREE_SENSE_BUFFER
Definition: srb.h:398
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
VOID NTAPI ClassReleaseQueue(_In_ PDEVICE_OBJECT Fdo)
Definition: class.c:11589
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
Definition: mdlsup.c:1439
UCHAR SrbStatus
Definition: srb.h:243
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define FREE_POOL(_PoolPtr)
Definition: cdrom.h:782
VOID NTAPI ClassReleaseRemoveLock(_In_ PDEVICE_OBJECT DeviceObject, _In_opt_ PIRP Tag)
Definition: lock.c:251
* PSTORAGE_REQUEST_BLOCK
Definition: srb.h:652
__inline VOID FREE_PORT_ALLOCATED_SENSE_BUFFER(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ PSCSI_REQUEST_BLOCK Srb)
Definition: cdrom.h:839
#define TEST_FLAG(Flags, Bit)
Definition: cdrom.h:1495
UCHAR Function
Definition: srb.h:242
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
#define SRB_FUNCTION_STORAGE_REQUEST_BLOCK
Definition: srb.h:99
#define SRB_STATUS_QUEUE_FROZEN
Definition: srb.h:378
__inline BOOLEAN PORT_ALLOCATED_SENSE(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ PSCSI_REQUEST_BLOCK Srb)
Definition: cdrom.h:826
#define NULL
Definition: types.h:112
struct tagContext Context
Definition: acpixf.h:1034
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:307
unsigned int ULONG
Definition: retypes.h:1
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by ClassSendStartUnit(), ResetBus(), and ScsiFlopProcessError().

◆ ClassBuildRequest()

SCSIPORT_API NTSTATUS NTAPI ClassBuildRequest ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIRP  Irp 
)

Definition at line 505 of file obsolete.c.

509 {
510  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
511 
513 
514  // This function is obsolete, but still called by CDROM.SYS .
515  // TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_GENERAL, "ClassBuildRequest is OBSOLETE !"));
516 
517  //
518  // Allocate an Srb.
519  //
520 
521  srb = ClasspAllocateSrb(fdoExtension);
522 
523  if (srb == NULL) {
525  }
526 
527  ClasspBuildRequestEx(fdoExtension, Irp, srb);
528  return STATUS_SUCCESS;
529 
530 } // end ClassBuildRequest()
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define ClasspAllocateSrb(ext)
Definition: classpnp.h:146
VOID ClasspBuildRequestEx(_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _In_ PIRP Irp, _In_ __drv_aliasesMem PSCSI_REQUEST_BLOCK Srb)
Definition: obsolete.c:537
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ ClassCheckMediaState()

SCSIPORT_API VOID NTAPI ClassCheckMediaState ( _In_ PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension)

Definition at line 1752 of file autorun.c.

1755 {
1756  PMEDIA_CHANGE_DETECTION_INFO info = FdoExtension->MediaChangeDetectionInfo;
1757  LONG countDown;
1758 
1759  if(info == NULL) {
1760  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_MCN,
1761  "ClassCheckMediaState: detection not enabled\n"));
1762  return;
1763  }
1764 
1765  //
1766  // Media change support is active and the IRP is waiting. Decrement the
1767  // timer. There is no MP protection on the timer counter. This code
1768  // is the only code that will manipulate the timer counter and only one
1769  // instance of it should be running at any given time.
1770  //
1771 
1772  countDown = InterlockedDecrement(&(info->MediaChangeCountDown));
1773 
1774  //
1775  // Try to acquire the media change event. If we can't do it immediately
1776  // then bail out and assume the caller will try again later.
1777  //
1779  info,
1780  countDown);
1781 
1782  return;
1783 } // end ClassCheckMediaState()
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
long LONG
Definition: pedump.c:60
VOID ClasspSendMediaStateIrp(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PMEDIA_CHANGE_DETECTION_INFO Info, IN ULONG CountDown)
Definition: autorun.c:1559
#define InterlockedDecrement
Definition: armddk.h:52
#define NULL
Definition: types.h:112

Referenced by _Function_class_(), and ClasspStorageEventNotification().

◆ ClassCheckVerifyComplete()

SCSIPORT_API NTSTATUS NTAPI ClassCheckVerifyComplete ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp,
PVOID  Context 
)

◆ ClassCompleteRequest()

SCSIPORT_API VOID NTAPI ClassCompleteRequest ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIRP  Irp,
_In_ CCHAR  PriorityBoost 
)

Definition at line 401 of file lock.c.

406 {
407  #if DBG
408  PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension;
409 
410  PRTL_GENERIC_TABLE removeTrackingList = NULL;
411  REMOVE_TRACKING_BLOCK searchDataBlock;
412  PREMOVE_TRACKING_BLOCK foundTrackingBlock;
413 
414  KIRQL oldIrql;
415 
416  KeAcquireSpinLock(&commonExtension->RemoveTrackingSpinlock, &oldIrql);
417 
418  removeTrackingList = commonExtension->RemoveTrackingList;
419 
420  if (removeTrackingList != NULL)
421  {
422  searchDataBlock.Tag = Irp;
423 
424  foundTrackingBlock = RtlLookupElementGenericTable(removeTrackingList, &searchDataBlock);
425 
426  if(foundTrackingBlock != NULL) {
427 
428  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_LOCK, ">>>>>ClassCompleteRequest: "
429  "Irp %p completed while still holding the remove lock\n", Irp));
430  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_LOCK, ">>>>>ClassCompleteRequest: "
431  "Lock acquired in file %s on line %d\n",
432  foundTrackingBlock->File, foundTrackingBlock->Line));
433  NT_ASSERT(FALSE);
434  }
435  }
436 
437  KeReleaseSpinLock(&commonExtension->RemoveTrackingSpinlock, oldIrql);
438  #endif
439 
440 
442 
444  return;
445 } // end ClassCompleteRequest()
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
UCHAR KIRQL
Definition: env_spec_w32.h:591
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
_In_ WDFREQUEST _In_ NTSTATUS _In_ CCHAR PriorityBoost
Definition: wdfrequest.h:1011
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
_Must_inspect_result_ NTSYSAPI PVOID NTAPI RtlLookupElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ PVOID Buffer)
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define NULL
Definition: types.h:112
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
KSPIN_LOCK RemoveTrackingSpinlock
Definition: classpnp.h:603
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by _IRQL_requires_max_(), _Success_(), ClassCheckVerifyComplete(), ClassCreateClose(), ClassDeviceControl(), ClassDeviceControlDispatch(), ClassDeviceGetLBProvisioningResources(), ClassDeviceHwFirmwareActivateProcess(), ClassDeviceHwFirmwareDownloadProcess(), ClassDeviceHwFirmwareGetInfoProcess(), ClassDispatchPnp(), ClassDispatchPower(), ClassInternalIoControl(), ClassIoCompleteAssociated(), ClassMinimalPowerHandler(), ClasspAccessAlignmentProperty(), ClasspCompleteOffloadRequest(), ClasspDeviceGetLBAStatus(), ClasspDeviceLBProvisioningProperty(), ClasspDeviceMediaTypeProperty(), ClasspDeviceSeekPenaltyProperty(), ClasspDeviceTrimProcess(), ClasspDeviceTrimProperty(), ClasspDuidQueryProperty(), ClasspMcnControl(), ClasspPersistentReserve(), ClasspPowerDownCompletion(), ClasspPowerHandler(), ClasspPowerUpCompletion(), ClasspPriorityHint(), ClasspStartIo(), ClasspStorageEventNotification(), ClasspWriteCacheProperty(), ClassReadWrite(), ClassShutdownFlush(), ClassSystemControl(), ClassWmiCompleteRequest(), DiskDeviceControl(), DiskFlushComplete(), DiskIoctlVerifyThread(), DiskShutdownFlush(), ScsiFlopDeviceControl(), and TransferPktComplete().

◆ ClassDebugPrint()

SCSIPORT_API VOID ClassDebugPrint ( _In_ CLASS_DEBUG_LEVEL  DebugPrintLevel,
_In_z_ PCCHAR  DebugMessage,
  ... 
)

Definition at line 563 of file debug.c.

564  {
565  UNREFERENCED_PARAMETER(DebugPrintLevel);
566  UNREFERENCED_PARAMETER(DebugMessage);
567  }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317

◆ ClassDeviceControl()

SCSIPORT_API NTSTATUS NTAPI ClassDeviceControl ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp 
)

Definition at line 7317 of file class.c.

7321 {
7322  PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension;
7323 
7325  PIO_STACK_LOCATION nextStack = NULL;
7326 
7327  ULONG controlCode = irpStack->Parameters.DeviceIoControl.IoControlCode;
7328 
7329  PSCSI_REQUEST_BLOCK srb = NULL;
7330  PCDB cdb = NULL;
7331 
7332  NTSTATUS status;
7333  ULONG modifiedIoControlCode = 0;
7334  GUID activityId = {0};
7335 
7336 
7337  //
7338  // If this is a pass through I/O control, set the minor function code
7339  // and device address and pass it to the port driver.
7340  //
7341 
7342  if ( (controlCode == IOCTL_SCSI_PASS_THROUGH) ||
7343  (controlCode == IOCTL_SCSI_PASS_THROUGH_DIRECT) ||
7344  (controlCode == IOCTL_SCSI_PASS_THROUGH_EX) ||
7345  (controlCode == IOCTL_SCSI_PASS_THROUGH_DIRECT_EX) ) {
7346 
7347 
7348 
7349  //
7350  // Validiate the user buffer for SCSI pass through.
7351  // For pass through EX: as the handler will validate the size anyway,
7352  // do not apply the similar check and leave the work to the handler.
7353  //
7354  if ( (controlCode == IOCTL_SCSI_PASS_THROUGH) ||
7355  (controlCode == IOCTL_SCSI_PASS_THROUGH_DIRECT) ) {
7356 
7357  #if BUILD_WOW64_ENABLED && defined(_WIN64)
7358 
7359  if (IoIs32bitProcess(Irp)) {
7360 
7361  if (irpStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(SCSI_PASS_THROUGH32)){
7362 
7363  Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
7364 
7367 
7369  goto SetStatusAndReturn;
7370  }
7371  }
7372  else
7373 
7374  #endif
7375 
7376  {
7377  if (irpStack->Parameters.DeviceIoControl.InputBufferLength <
7378  sizeof(SCSI_PASS_THROUGH)) {
7379 
7380  Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
7381 
7384 
7386  goto SetStatusAndReturn;
7387  }
7388  }
7389  }
7390 
7391 
7393 
7394  nextStack = IoGetNextIrpStackLocation(Irp);
7395  nextStack->MinorFunction = 1;
7396 
7398 
7399  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
7400  goto SetStatusAndReturn;
7401 
7402  }
7403 
7404  Irp->IoStatus.Information = 0;
7405 
7406 
7407  switch (controlCode) {
7408 
7410 
7411  PMOUNTDEV_UNIQUE_ID uniqueId;
7412 
7413  if (!commonExtension->MountedDeviceInterfaceName.Buffer) {
7415  break;
7416  }
7417 
7418  if (irpStack->Parameters.DeviceIoControl.OutputBufferLength <
7419  sizeof(MOUNTDEV_UNIQUE_ID)) {
7420 
7422  Irp->IoStatus.Information = sizeof(MOUNTDEV_UNIQUE_ID);
7423  break;
7424  }
7425 
7426  uniqueId = Irp->AssociatedIrp.SystemBuffer;
7427  RtlZeroMemory(uniqueId, sizeof(MOUNTDEV_UNIQUE_ID));
7428  uniqueId->UniqueIdLength =
7429  commonExtension->MountedDeviceInterfaceName.Length;
7430 
7431  if (irpStack->Parameters.DeviceIoControl.OutputBufferLength <
7432  sizeof(USHORT) + uniqueId->UniqueIdLength) {
7433 
7435  Irp->IoStatus.Information = sizeof(MOUNTDEV_UNIQUE_ID);
7436  break;
7437  }
7438 
7439  RtlCopyMemory(uniqueId->UniqueId,
7440  commonExtension->MountedDeviceInterfaceName.Buffer,
7441  uniqueId->UniqueIdLength);
7442 
7444  Irp->IoStatus.Information = sizeof(USHORT) +
7445  uniqueId->UniqueIdLength;
7446  break;
7447  }
7448 
7450 
7452 
7453  NT_ASSERT(commonExtension->DeviceName.Buffer);
7454 
7455  if (irpStack->Parameters.DeviceIoControl.OutputBufferLength <
7456  sizeof(MOUNTDEV_NAME)) {
7457 
7459  Irp->IoStatus.Information = sizeof(MOUNTDEV_NAME);
7460  break;
7461  }
7462 
7463  name = Irp->AssociatedIrp.SystemBuffer;
7464  RtlZeroMemory(name, sizeof(MOUNTDEV_NAME));
7465  name->NameLength = commonExtension->DeviceName.Length;
7466 
7467  if (irpStack->Parameters.DeviceIoControl.OutputBufferLength <
7468  sizeof(USHORT) + name->NameLength) {
7469 
7471  Irp->IoStatus.Information = sizeof(MOUNTDEV_NAME);
7472  break;
7473  }
7474 
7475  RtlCopyMemory(name->Name, commonExtension->DeviceName.Buffer,
7476  name->NameLength);
7477 
7479  Irp->IoStatus.Information = sizeof(USHORT) + name->NameLength;
7480  break;
7481  }
7482 
7484 
7485  PMOUNTDEV_SUGGESTED_LINK_NAME suggestedName;
7486  WCHAR driveLetterNameBuffer[10] = {0};
7487  RTL_QUERY_REGISTRY_TABLE queryTable[2] = {0};
7488  PWSTR valueName;
7489  UNICODE_STRING driveLetterName;
7490 
7491  if (irpStack->Parameters.DeviceIoControl.OutputBufferLength <
7492  sizeof(MOUNTDEV_SUGGESTED_LINK_NAME)) {
7493 
7495  Irp->IoStatus.Information = sizeof(MOUNTDEV_SUGGESTED_LINK_NAME);
7496  break;
7497  }
7498 
7499  valueName = ExAllocatePoolWithTag(
7500  PagedPool,
7501  commonExtension->DeviceName.Length + sizeof(WCHAR),
7502  '8CcS');
7503 
7504  if (!valueName) {
7506  break;
7507  }
7508 
7509  RtlCopyMemory(valueName, commonExtension->DeviceName.Buffer,
7510  commonExtension->DeviceName.Length);
7511  valueName[commonExtension->DeviceName.Length/sizeof(WCHAR)] = 0;
7512 
7513  driveLetterName.Buffer = driveLetterNameBuffer;
7514  driveLetterName.MaximumLength = sizeof(driveLetterNameBuffer);
7515  driveLetterName.Length = 0;
7516 
7517  queryTable[0].Flags = RTL_QUERY_REGISTRY_REQUIRED |
7520  queryTable[0].Name = valueName;
7521  queryTable[0].EntryContext = &driveLetterName;
7523 
7525  L"\\Registry\\Machine\\System\\DISK",
7526  queryTable, NULL, NULL);
7527 
7528  if (!NT_SUCCESS(status)) {
7529  FREE_POOL(valueName);
7530  break;
7531  }
7532 
7533  if (driveLetterName.Length == 4 &&
7534  driveLetterName.Buffer[0] == '%' &&
7535  driveLetterName.Buffer[1] == ':') {
7536 
7537  driveLetterName.Buffer[0] = 0xFF;
7538 
7539  } else if (driveLetterName.Length != 4 ||
7540  driveLetterName.Buffer[0] < FirstDriveLetter ||
7541  driveLetterName.Buffer[0] > LastDriveLetter ||
7542  driveLetterName.Buffer[1] != ':') {
7543 
7545  FREE_POOL(valueName);
7546  break;
7547  }
7548 
7549  suggestedName = Irp->AssociatedIrp.SystemBuffer;
7550  RtlZeroMemory(suggestedName, sizeof(MOUNTDEV_SUGGESTED_LINK_NAME));
7551  suggestedName->UseOnlyIfThereAreNoOtherLinks = TRUE;
7552  suggestedName->NameLength = 28;
7553 
7554  Irp->IoStatus.Information =
7556 
7557  if (irpStack->Parameters.DeviceIoControl.OutputBufferLength <
7558  Irp->IoStatus.Information) {
7559 
7560  Irp->IoStatus.Information =
7563  FREE_POOL(valueName);
7564  break;
7565  }
7566 
7568  L"\\Registry\\Machine\\System\\DISK",
7569  valueName);
7570 
7571  FREE_POOL(valueName);
7572 
7573  RtlCopyMemory(suggestedName->Name, L"\\DosDevices\\", 24);
7574  suggestedName->Name[12] = driveLetterName.Buffer[0];
7575  suggestedName->Name[13] = ':';
7576 
7577  //
7578  // NT_SUCCESS(status) based on RtlQueryRegistryValues
7579  //
7581 
7582  break;
7583  }
7584 
7585  default:
7587  break;
7588  }
7589 
7590  if (status != STATUS_PENDING) {
7592  Irp->IoStatus.Status = status;
7593 
7594 
7596  return status;
7597  }
7598 
7599  if (commonExtension->IsFdo){
7600 
7601  PULONG_PTR function;
7602  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = (PFUNCTIONAL_DEVICE_EXTENSION)commonExtension;
7603  size_t sizeNeeded;
7604 
7605  //
7606  // Allocate a SCSI SRB for handling various IOCTLs.
7607  // NOTE - there is a case where an IOCTL is sent to classpnp before AdapterDescriptor
7608  // is initialized. In this case, default to legacy SRB.
7609  //
7610  if ((fdoExtension->AdapterDescriptor != NULL) &&
7611  (fdoExtension->AdapterDescriptor->SrbType == SRB_TYPE_STORAGE_REQUEST_BLOCK)) {
7613  } else {
7614  sizeNeeded = sizeof(SCSI_REQUEST_BLOCK);
7615  }
7616 
7617  srb = ExAllocatePoolWithTag(NonPagedPoolNx,
7618  sizeNeeded +
7619  (sizeof(ULONG_PTR) * 2),
7620  '9CcS');
7621 
7622  if (srb == NULL) {
7623 
7624  Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
7628  goto SetStatusAndReturn;
7629  }
7630 
7631  if ((fdoExtension->AdapterDescriptor != NULL) &&
7632  (fdoExtension->AdapterDescriptor->SrbType == SRB_TYPE_STORAGE_REQUEST_BLOCK)) {
7636  1,
7638  if (NT_SUCCESS(status)) {
7639  ((PSTORAGE_REQUEST_BLOCK)srb)->SrbFunction = SRB_FUNCTION_EXECUTE_SCSI;
7640  function = (PULONG_PTR)((PCHAR)srb + sizeNeeded);
7641  } else {
7642  //
7643  // Should not occur.
7644  //
7645  NT_ASSERT(FALSE);
7646  goto SetStatusAndReturn;
7647  }
7648  } else {
7649  RtlZeroMemory(srb, sizeof(SCSI_REQUEST_BLOCK));
7650  srb->Length = sizeof(SCSI_REQUEST_BLOCK);
7651  srb->Function = SRB_FUNCTION_EXECUTE_SCSI;
7652  function = (PULONG_PTR) ((PSCSI_REQUEST_BLOCK) (srb + 1));
7653  }
7654 
7655  //
7656  // Save the function code and the device object in the memory after
7657  // the SRB.
7658  //
7659 
7660  *function = (ULONG_PTR) DeviceObject;
7661  function++;
7662  *function = (ULONG_PTR) controlCode;
7663 
7664  } else {
7665  srb = NULL;
7666  }
7667 
7668  //
7669  // Change the device type to storage for the switch statement, but only
7670  // if from a legacy device type
7671  //
7672 
7673  if (((controlCode & 0xffff0000) == (IOCTL_DISK_BASE << 16)) ||
7674  ((controlCode & 0xffff0000) == (IOCTL_TAPE_BASE << 16)) ||
7675  ((controlCode & 0xffff0000) == (IOCTL_CDROM_BASE << 16))
7676  ) {
7677 
7678  modifiedIoControlCode = (controlCode & ~0xffff0000);
7679  modifiedIoControlCode |= (IOCTL_STORAGE_BASE << 16);
7680 
7681  } else {
7682 
7683  modifiedIoControlCode = controlCode;
7684 
7685  }
7686 
7687  TracePrint((TRACE_LEVEL_VERBOSE, TRACE_FLAG_GENERAL, "> ioctl %xh (%s)", modifiedIoControlCode, DBGGETIOCTLSTR(modifiedIoControlCode)));
7688 
7689 
7690  switch (modifiedIoControlCode) {
7691 
7693 
7694  FREE_POOL(srb);
7695 
7696  if (irpStack->Parameters.DeviceIoControl.OutputBufferLength <
7697  sizeof(STORAGE_HOTPLUG_INFO)) {
7698 
7699  //
7700  // Indicate unsuccessful status and no data transferred.
7701  //
7702 
7703  Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
7704  Irp->IoStatus.Information = sizeof(STORAGE_HOTPLUG_INFO);
7705 
7709 
7710  } else if (!commonExtension->IsFdo) {
7711 
7712 
7713  //
7714  // Just forward this down and return
7715  //
7716 
7718 
7720  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
7721 
7722  } else {
7723 
7724  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension;
7726 
7727  fdoExtension = (PFUNCTIONAL_DEVICE_EXTENSION)commonExtension;
7728  info = Irp->AssociatedIrp.SystemBuffer;
7729 
7730  *info = fdoExtension->PrivateFdoData->HotplugInfo;
7731  Irp->IoStatus.Status = STATUS_SUCCESS;
7732  Irp->IoStatus.Information = sizeof(STORAGE_HOTPLUG_INFO);
7736  }
7737  break;
7738  }
7739 
7741 
7742  FREE_POOL(srb);
7743 
7744  if (irpStack->Parameters.DeviceIoControl.InputBufferLength <
7745  sizeof(STORAGE_HOTPLUG_INFO)) {
7746 
7747  //
7748  // Indicate unsuccessful status and no data transferred.
7749  //
7750 
7751  Irp->IoStatus.Status = STATUS_INFO_LENGTH_MISMATCH;
7752 
7756  goto SetStatusAndReturn;
7757 
7758  }
7759 
7760  if (!commonExtension->IsFdo) {
7761 
7762 
7763  //
7764  // Just forward this down and return
7765  //
7766 
7768 
7770  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
7771 
7772  } else {
7773 
7774  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = (PFUNCTIONAL_DEVICE_EXTENSION)commonExtension;
7775  PSTORAGE_HOTPLUG_INFO info = Irp->AssociatedIrp.SystemBuffer;
7776 
7778 
7779  if (info->Size != fdoExtension->PrivateFdoData->HotplugInfo.Size)
7780  {
7782  }
7783 
7784  if (info->MediaRemovable != fdoExtension->PrivateFdoData->HotplugInfo.MediaRemovable)
7785  {
7787  }
7788 
7789  if (info->MediaHotplug != fdoExtension->PrivateFdoData->HotplugInfo.MediaHotplug)
7790  {
7792  }
7793 
7794  if (NT_SUCCESS(status))
7795  {
7796  if (info->WriteCacheEnableOverride != fdoExtension->PrivateFdoData->HotplugInfo.WriteCacheEnableOverride)
7797  {
7798  fdoExtension->PrivateFdoData->HotplugInfo.WriteCacheEnableOverride = info->WriteCacheEnableOverride;
7799 
7800  //
7801  // Store the user-defined override in the registry
7802  //
7803 
7804  ClassSetDeviceParameter(fdoExtension,
7807  info->WriteCacheEnableOverride);
7808  }
7809 
7810  fdoExtension->PrivateFdoData->HotplugInfo.DeviceHotplug = info->DeviceHotplug;
7811 
7812  //
7813  // Store the user-defined override in the registry
7814  //
7815 
7816  ClassSetDeviceParameter(fdoExtension,
7820  }
7821 
7822  Irp->IoStatus.Status = status;
7823 
7826  }
7827 
7828  break;
7829  }
7830 
7833 
7834  PIRP irp2 = NULL;
7835  PIO_STACK_LOCATION newStack;
7836 
7837  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = NULL;
7838 
7839  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL, "DeviceIoControl: Check verify\n"));
7840 
7841  //
7842  // If a buffer for a media change count was provided, make sure it's
7843  // big enough to hold the result
7844  //
7845 
7846  if (irpStack->Parameters.DeviceIoControl.OutputBufferLength) {
7847 
7848  //
7849  // If the buffer is too small to hold the media change count
7850  // then return an error to the caller
7851  //
7852 
7853  if (irpStack->Parameters.DeviceIoControl.OutputBufferLength <
7854  sizeof(ULONG)) {
7855 
7856  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL, "DeviceIoControl: media count "
7857  "buffer too small\n"));
7858 
7859  Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
7860  Irp->IoStatus.Information = sizeof(ULONG);
7861 
7862  FREE_POOL(srb);
7863 
7866 
7868  goto SetStatusAndReturn;
7869  }
7870  }
7871 
7872  if (!commonExtension->IsFdo) {
7873 
7874 
7875  //
7876  // If this is a PDO then we should just forward the request down
7877  //
7878  NT_ASSERT(!srb);
7879 
7881 
7883 
7884  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
7885 
7886  goto SetStatusAndReturn;
7887 
7888  } else {
7889 
7890  fdoExtension = DeviceObject->DeviceExtension;
7891 
7892  }
7893 
7894  if (irpStack->Parameters.DeviceIoControl.OutputBufferLength) {
7895 
7896  //
7897  // The caller has provided a valid buffer. Allocate an additional
7898  // irp and stick the CheckVerify completion routine on it. We will
7899  // then send this down to the port driver instead of the irp the
7900  // caller sent in
7901  //
7902 
7903  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL, "DeviceIoControl: Check verify wants "
7904  "media count\n"));
7905 
7906  //
7907  // Allocate a new irp to send the TestUnitReady to the port driver
7908  //
7909 
7910  irp2 = IoAllocateIrp((CCHAR) (DeviceObject->StackSize + 3), FALSE);
7911 
7912  if (irp2 == NULL) {
7913  Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
7914  Irp->IoStatus.Information = 0;
7915  FREE_POOL(srb);
7919  goto SetStatusAndReturn;
7920 
7921  break;
7922  }
7923 
7924  //
7925  // Make sure to acquire the lock for the new irp.
7926  //
7927 
7929 
7930  irp2->Tail.Overlay.Thread = Irp->Tail.Overlay.Thread;
7932 
7933  //
7934  // Set the top stack location and shove the master Irp into the
7935  // top location
7936  //
7937 
7938  newStack = IoGetCurrentIrpStackLocation(irp2);
7939  newStack->Parameters.Others.Argument1 = Irp;
7940  newStack->DeviceObject = DeviceObject;
7941 
7942  //
7943  // Stick the check verify completion routine onto the stack
7944  // and prepare the irp for the port driver
7945  //
7946 
7949  NULL,
7950  TRUE,
7951  TRUE,
7952  TRUE);
7953 
7955  newStack = IoGetCurrentIrpStackLocation(irp2);
7956  newStack->DeviceObject = DeviceObject;
7957  newStack->MajorFunction = irpStack->MajorFunction;
7958  newStack->MinorFunction = irpStack->MinorFunction;
7959  newStack->Flags = irpStack->Flags;
7960 
7961 
7962  //
7963  // Mark the master irp as pending - whether the lower level
7964  // driver completes it immediately or not this should allow it
7965  // to go all the way back up.
7966  //
7967 
7969 
7970  Irp = irp2;
7971 
7972  }
7973 
7974  //
7975  // Test Unit Ready
7976  //
7977 
7978  SrbSetCdbLength(srb, 6);
7979  cdb = SrbGetCdb(srb);
7980  cdb->CDB6GENERIC.OperationCode = SCSIOP_TEST_UNIT_READY;
7981 
7982  //
7983  // Set timeout value.
7984  //
7985 
7986  SrbSetTimeOutValue(srb, fdoExtension->TimeOutValue);
7987 
7988  //
7989  // If this was a CV2 then mark the request as low-priority so we don't
7990  // spin up the drive just to satisfy it.
7991  //
7992 
7993  if (controlCode == IOCTL_STORAGE_CHECK_VERIFY2) {
7995  }
7996 
7997  //
7998  // Since this routine will always hand the request to the
7999  // port driver if there isn't a data transfer to be done
8000  // we don't have to worry about completing the request here
8001  // on an error
8002  //
8003 
8004  //
8005  // This routine uses a completion routine so we don't want to release
8006  // the remove lock until then.
8007  //
8008 
8010  srb,
8011  Irp,
8012  NULL,
8013  0,
8014  FALSE);
8015 
8016  break;
8017  }
8018 
8021 
8022  PPREVENT_MEDIA_REMOVAL mediaRemoval = Irp->AssociatedIrp.SystemBuffer;
8023 
8024  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL, "DiskIoControl: ejection control\n"));
8025 
8026  FREE_POOL(srb);
8027 
8028  if (irpStack->Parameters.DeviceIoControl.InputBufferLength <
8029  sizeof(PREVENT_MEDIA_REMOVAL)) {
8030 
8031  //
8032  // Indicate unsuccessful status and no data transferred.
8033  //
8034 
8035  Irp->IoStatus.Status = STATUS_INFO_LENGTH_MISMATCH;
8036 
8040  goto SetStatusAndReturn;
8041  }
8042 
8043  if (!commonExtension->IsFdo) {
8044 
8045 
8046  //
8047  // Just forward this down and return
8048  //
8049 
8051 
8053  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8054  }
8055  else {
8056 
8057  // i don't believe this assertion is valid. this is a request
8058  // from user-mode, so they could request this for any device
8059  // they want? also, we handle it properly.
8060  // NT_ASSERT(TEST_FLAG(DeviceObject->Characteristics, FILE_REMOVABLE_MEDIA));
8062  DeviceObject,
8063  Irp,
8064  ((modifiedIoControlCode ==
8066  SimpleMediaLock),
8067  mediaRemoval->PreventMediaRemoval);
8068 
8069  Irp->IoStatus.Status = status;
8072  }
8073 
8074  break;
8075  }
8076 
8078 
8079  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL, "DiskIoControl: MCN control\n"));
8080 
8081  if (irpStack->Parameters.DeviceIoControl.InputBufferLength <
8082  sizeof(PREVENT_MEDIA_REMOVAL)) {
8083 
8084  //
8085  // Indicate unsuccessful status and no data transferred.
8086  //
8087 
8088  Irp->IoStatus.Status = STATUS_INFO_LENGTH_MISMATCH;
8089  Irp->IoStatus.Information = 0;
8090 
8091  FREE_POOL(srb);
8092 
8096  goto SetStatusAndReturn;
8097  }
8098 
8099  if (!commonExtension->IsFdo) {
8100 
8101 
8102  //
8103  // Just forward this down and return
8104  //
8105 
8106  FREE_POOL(srb);
8107 
8109 
8111  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8112 
8113  } else {
8114 
8115  //
8116  // Call to the FDO - handle the ejection control.
8117  //
8118 
8119  status = ClasspMcnControl(DeviceObject->DeviceExtension,
8120  Irp,
8121  srb);
8122  }
8123  goto SetStatusAndReturn;
8124  }
8125 
8126  case IOCTL_STORAGE_RESERVE:
8127  case IOCTL_STORAGE_RELEASE: {
8128 
8129  //
8130  // Reserve logical unit.
8131  //
8132 
8133  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = NULL;
8134 
8135  if (!commonExtension->IsFdo) {
8136 
8137 
8139 
8141  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8142  goto SetStatusAndReturn;
8143 
8144  } else {
8145  fdoExtension = DeviceObject->DeviceExtension;
8146  }
8147 
8148  if (TEST_FLAG(fdoExtension->PrivateFdoData->HackFlags, FDO_HACK_NO_RESERVE6))
8149  {
8150  SrbSetCdbLength(srb, 10);
8151  cdb = SrbGetCdb(srb);
8152  cdb->CDB10.OperationCode = (modifiedIoControlCode == IOCTL_STORAGE_RESERVE) ? SCSIOP_RESERVE_UNIT10 : SCSIOP_RELEASE_UNIT10;
8153  }
8154  else
8155  {
8156  SrbSetCdbLength(srb, 6);
8157  cdb = SrbGetCdb(srb);
8158  cdb->CDB6GENERIC.OperationCode = (modifiedIoControlCode == IOCTL_STORAGE_RESERVE) ? SCSIOP_RESERVE_UNIT : SCSIOP_RELEASE_UNIT;
8159  }
8160 
8161  //
8162  // Set timeout value.
8163  //
8164 
8165  SrbSetTimeOutValue(srb, fdoExtension->TimeOutValue);
8166 
8167  //
8168  // Send reserves as tagged requests.
8169  //
8170 
8171  if ( IOCTL_STORAGE_RESERVE == modifiedIoControlCode ) {
8174  }
8175 
8177  srb,
8178  Irp,
8179  NULL,
8180  0,
8181  FALSE);
8182 
8183  break;
8184  }
8185 
8188 
8189  if (!commonExtension->IsFdo) {
8190 
8192 
8194  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8195  goto SetStatusAndReturn;
8196  }
8197 
8198  //
8199  // Process Persistent Reserve
8200  //
8201 
8203 
8204  break;
8205 
8206  }
8207 
8211 
8212  //
8213  // Eject media.
8214  //
8215 
8216  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = NULL;
8217 
8218  if (!commonExtension->IsFdo) {
8219 
8220 
8222 
8224 
8225  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8226  goto SetStatusAndReturn;
8227  } else {
8228  fdoExtension = DeviceObject->DeviceExtension;
8229  }
8230 
8231  if (commonExtension->PagingPathCount != 0) {
8232 
8233  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL, "ClassDeviceControl: call to eject paging device - "
8234  "failure\n"));
8235 
8237  Irp->IoStatus.Status = status;
8238 
8239  Irp->IoStatus.Information = 0;
8240 
8241  FREE_POOL(srb);
8242 
8245  goto SetStatusAndReturn;
8246  }
8247 
8248  //
8249  // Synchronize with ejection control and ejection cleanup code as
8250  // well as other eject/load requests.
8251  //
8252 
8255  UserRequest,
8256  KernelMode,
8257  FALSE,
8258  NULL);
8259 
8260  if (fdoExtension->ProtectedLockCount != 0) {
8261 
8262  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL, "ClassDeviceControl: call to eject protected locked "
8263  "device - failure\n"));
8264 
8266  Irp->IoStatus.Status = status;
8267  Irp->IoStatus.Information = 0;
8268 
8269  FREE_POOL(srb);
8270 
8273 
8274  KeSetEvent(&fdoExtension->EjectSynchronizationEvent,
8276  FALSE);
8278 
8279  goto SetStatusAndReturn;
8280  }
8281 
8282  SrbSetCdbLength(srb, 6);
8283  cdb = SrbGetCdb(srb);
8284 
8285  cdb->START_STOP.OperationCode = SCSIOP_START_STOP_UNIT;
8286  cdb->START_STOP.LoadEject = 1;
8287 
8288  if (modifiedIoControlCode == IOCTL_STORAGE_EJECT_MEDIA) {
8289  cdb->START_STOP.Start = 0;
8290  } else {
8291  cdb->START_STOP.Start = 1;
8292  }
8293 
8294  //
8295  // Set timeout value.
8296  //
8297 
8298  SrbSetTimeOutValue(srb, fdoExtension->TimeOutValue);
8300  srb,
8301  Irp,
8302  NULL,
8303  0,
8304  FALSE);
8305 
8308 
8309  break;
8310  }
8311 
8313 
8314  FREE_POOL(srb);
8315 
8316  if (commonExtension->IsFdo) {
8317 
8319  ((PFUNCTIONAL_DEVICE_EXTENSION) commonExtension)->LowerPdo,
8320  BusRelations);
8321 
8323  Irp->IoStatus.Status = status;
8324 
8327  }
8328  else {
8329 
8330 
8332 
8334  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8335  }
8336  break;
8337  }
8338 
8340 
8341  FREE_POOL(srb);
8342 
8343  if (irpStack->Parameters.DeviceIoControl.OutputBufferLength >=
8344  sizeof(STORAGE_DEVICE_NUMBER)) {
8345 
8346  PSTORAGE_DEVICE_NUMBER deviceNumber =
8347  Irp->AssociatedIrp.SystemBuffer;
8348  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension =
8349  commonExtension->PartitionZeroExtension;
8350 
8351  deviceNumber->DeviceType = fdoExtension->CommonExtension.DeviceObject->DeviceType;
8352  deviceNumber->DeviceNumber = fdoExtension->DeviceNumber;
8353  deviceNumber->PartitionNumber = commonExtension->PartitionNumber;
8354 
8356  Irp->IoStatus.Information = sizeof(STORAGE_DEVICE_NUMBER);
8357 
8358  } else {
8360  Irp->IoStatus.Information = sizeof(STORAGE_DEVICE_NUMBER);
8361  }
8362 
8363  Irp->IoStatus.Status = status;
8366 
8367  break;
8368  }
8369 
8370 
8372 
8373  FREE_POOL(srb);
8374 
8375  if (irpStack->Parameters.DeviceIoControl.OutputBufferLength <
8376  sizeof(STORAGE_READ_CAPACITY)) {
8377 
8378  //
8379  // Indicate unsuccessful status and no data transferred.
8380  //
8381 
8382  Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
8383  Irp->IoStatus.Information = sizeof(STORAGE_READ_CAPACITY);
8384 
8388  break;
8389  }
8390 
8391  if (!commonExtension->IsFdo) {
8392 
8393 
8394  //
8395  // Just forward this down and return
8396  //
8397 
8399 
8401  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8402  }
8403  else {
8404 
8405  PFUNCTIONAL_DEVICE_EXTENSION fdoExt = DeviceObject->DeviceExtension;
8406  PCLASS_PRIVATE_FDO_DATA fdoData = fdoExt->PrivateFdoData;
8407  PSTORAGE_READ_CAPACITY readCapacity = Irp->AssociatedIrp.SystemBuffer;
8408  LARGE_INTEGER diskLength;
8409 
8411  if (NT_SUCCESS(status) && fdoData->IsCachedDriveCapDataValid) {
8412 
8413  readCapacity->Version = sizeof(STORAGE_READ_CAPACITY);
8414  readCapacity->Size = sizeof(STORAGE_READ_CAPACITY);
8415 
8416  REVERSE_BYTES(&readCapacity->BlockLength,
8418  REVERSE_BYTES_QUAD(&readCapacity->NumberOfBlocks,
8420  readCapacity->NumberOfBlocks.QuadPart++;
8421 
8422  readCapacity->DiskLength = fdoExt->CommonExtension.PartitionLength;
8423 
8424  //
8425  // Make sure the lengths are equal.
8426  // Remove this after testing.
8427  //
8428  diskLength.QuadPart = readCapacity->NumberOfBlocks.QuadPart *
8429  readCapacity->BlockLength;
8430 
8431  Irp->IoStatus.Status = STATUS_SUCCESS;
8432  Irp->IoStatus.Information = sizeof(STORAGE_READ_CAPACITY);
8433 
8434  } else {
8435  //
8436  // Read capacity request failed.
8437  //
8438  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL, "ClassDeviceControl: ClassReadDriveCapacity failed: 0x%X IsCachedDriveCapDataValid: %d\n",
8439  status, fdoData->IsCachedDriveCapDataValid));
8440  Irp->IoStatus.Status = status;
8441  Irp->IoStatus.Information = 0;
8442  }
8445  }
8446 
8447  break;
8448  }
8449 
8451 
8452  PSTORAGE_PROPERTY_QUERY query = Irp->AssociatedIrp.SystemBuffer;
8453 
8454  if (irpStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(STORAGE_PROPERTY_QUERY)) {
8455 
8457  Irp->IoStatus.Status = status;
8460  FREE_POOL(srb);
8461  break;
8462  }
8463 
8464  if (!commonExtension->IsFdo) {
8465 
8466 
8468 
8470  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8471  FREE_POOL(srb);
8472  break;
8473  }
8474 
8475  //
8476  // Determine PropertyId type and either call appropriate routine
8477  // or pass request to lower drivers.
8478  //
8479 
8480  switch ( query->PropertyId ) {
8481 
8483 
8485  break;
8486  }
8487 
8489 
8491  break;
8492  }
8493 
8494  // these propertyId has been implemented in some port driver and filter drivers.
8495  // to keep the backwards compatibility, classpnp will send the request down if it's supported by lower layer.
8496  // otherwise, classpnp sends SCSI command and then interprets the result.
8498 
8500  break;
8501  }
8502 
8504 
8506  break;
8507  }
8508 
8510 
8512  break;
8513  }
8514 
8516 
8518  break;
8519  }
8520 
8522 
8523  status = ClasspDeviceCopyOffloadProperty(DeviceObject, Irp, srb);
8524  break;
8525  }
8526 
8528 
8530  break;
8531  }
8532 
8533  default: {
8534 
8535  //
8536  // Copy the Irp stack parameters to the next stack location.
8537  //
8538 
8540 
8542  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8543  break;
8544  }
8545  } // end switch
8546 
8547  FREE_POOL(srb);
8548  break;
8549  }
8550 
8552 
8553  FREE_POOL(srb);
8554 
8555  if (!commonExtension->IsFdo) {
8556 
8557 
8559 
8561  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8562  break;
8563  }
8564 
8565  //
8566  // Process priority hit request
8567  //
8568 
8570  break;
8571  }
8572 
8574 
8575  PDEVICE_MANAGE_DATA_SET_ATTRIBUTES dsmAttributes = Irp->AssociatedIrp.SystemBuffer;
8576 
8577  if (irpStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(DEVICE_MANAGE_DATA_SET_ATTRIBUTES)) {
8578 
8580  Irp->IoStatus.Status = status;
8583  FREE_POOL(srb);
8584  break;
8585  }
8586 
8587  if (irpStack->Parameters.DeviceIoControl.InputBufferLength <
8588  (sizeof(DEVICE_MANAGE_DATA_SET_ATTRIBUTES) + dsmAttributes->ParameterBlockLength + dsmAttributes->DataSetRangesLength)) {
8589 
8591  Irp->IoStatus.Status = status;
8594  FREE_POOL(srb);
8595  break;
8596  }
8597 
8598  if (!commonExtension->IsFdo) {
8599 
8600 
8602 
8604  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8605  FREE_POOL(srb);
8606  break;
8607  }
8608 
8609  switch(dsmAttributes->Action) {
8610 
8611  // only process Trim action in class layer if possible.
8612  case DeviceDsmAction_Trim: {
8613  status = ClasspDeviceTrimProcess(DeviceObject, Irp, &activityId, srb);
8614  break;
8615  }
8616 
8618  status = ClassDeviceProcessOffloadRead(DeviceObject, Irp, srb);
8619  break;
8620  }
8621 
8623  status = ClassDeviceProcessOffloadWrite(DeviceObject, Irp, srb);
8624  break;
8625  }
8626 
8629  break;
8630  }
8631 
8632 
8633  default: {
8634 
8635 
8636  //
8637  // Copy the Irp stack parameters to the next stack location.
8638  //
8639 
8641 
8643  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8644  break;
8645  }
8646  } // end switch
8647 
8648  FREE_POOL(srb);
8649  break;
8650  }
8651 
8653 
8654  if (commonExtension->IsFdo) {
8655 
8657 
8658  } else {
8659 
8661 
8663  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8664  }
8665 
8666  FREE_POOL(srb);
8667 
8668  break;
8669  }
8670 
8672 
8673  FREE_POOL(srb);
8674 
8676  break;
8677  }
8678 
8679 #if (NTDDI_VERSION >= NTDDI_WINTRHESHOLD)
8681  FREE_POOL(srb);
8682 
8684  break;
8685  }
8686 
8688  if (!commonExtension->IsFdo) {
8689 
8691 
8693  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8694  goto SetStatusAndReturn;
8695  }
8696 
8698  break;
8699  }
8700 
8702  if (!commonExtension->IsFdo) {
8703 
8705 
8707  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8708  goto SetStatusAndReturn;
8709  }
8710 
8712  break;
8713  }
8714 #endif
8715 
8716 
8717  default: {
8718 
8719  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_IOCTL, "IoDeviceControl: Unsupported device IOCTL %x for %p\n",
8720  controlCode, DeviceObject));
8721 
8722 
8723  //
8724  // Pass the device control to the next driver.
8725  //
8726 
8727  FREE_POOL(srb);
8728 
8729  //
8730  // Copy the Irp stack parameters to the next stack location.
8731  //
8732 
8734 
8736  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
8737  break;
8738  }
8739 
8740  } // end switch( ...
8741 
8742 SetStatusAndReturn:
8743 
8744  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL, "< ioctl %xh (%s): status %xh.", modifiedIoControlCode, DBGGETIOCTLSTR(modifiedIoControlCode), status));
8745 
8746  return status;
8747 } // end ClassDeviceControl()
DEVICE_TYPE DeviceType
Definition: ntddstor.h:324
IO_COMPLETION_ROUTINE ClassCheckVerifyComplete
Definition: class.c:84
signed char * PCHAR
Definition: retypes.h:7
#define IOCTL_STORAGE_MCN_CONTROL
Definition: ntddstor.h:128
#define SRB_TYPE_STORAGE_REQUEST_BLOCK
Definition: srb.h:655
#define SCSIOP_RESERVE_UNIT
Definition: cdrw_hw.h:892
NTSTATUS ClassDeviceHwFirmwareActivateProcess(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
Definition: utils.c:8900
#define IOCTL_DISK_BASE
Definition: ntdddisk.h:44
#define IOCTL_CDROM_BASE
Definition: vcdcli.c:21
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define ClassAcquireRemoveLock(devobj, tag)
Definition: classpnp.h:100
#define SCSIOP_RESERVE_UNIT10
Definition: scsi.h:320
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define IOCTL_STORAGE_SET_HOTPLUG_INFO
Definition: ntddstor.h:157
NTSTATUS ClasspEjectionControl(IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN MEDIA_LOCK_TYPE LockType, IN BOOLEAN Lock)
Definition: create.c:474
NTSTATUS ClasspDeviceMediaTypeProperty(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
Definition: utils.c:1917
#define IOCTL_SCSI_PASS_THROUGH_DIRECT_EX
Definition: ntddscsi.h:38
#define IOCTL_STORAGE_GET_LB_PROVISIONING_MAP_RESOURCES
Definition: ntddstor.h:184
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
#define IOCTL_STORAGE_MEDIA_REMOVAL
Definition: ntddstor.h:104
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define SCSIOP_RELEASE_UNIT
Definition: cdrw_hw.h:893
#define DeviceDsmAction_OffloadWrite
Definition: ntddstor.h:279
#define TRUE
Definition: types.h:120
NTSTATUS ClasspPriorityHint(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: utils.c:6480
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
uint16_t * PWSTR
Definition: typedefs.h:56
NTSTATUS InitializeStorageRequestBlock(_Inout_bytecount_(ByteSize) PSTORAGE_REQUEST_BLOCK Srb, _In_ USHORT AddressType, _In_ ULONG ByteSize, _In_ ULONG NumSrbExData,...)
Definition: srblib.c:206
struct _FUNCTIONAL_DEVICE_EXTENSION * PartitionZeroExtension
Definition: classpnp.h:599
Definition: cdrw_hw.h:28
LONG NTSTATUS
Definition: precomp.h:26
COMMON_DEVICE_EXTENSION CommonExtension
Definition: classpnp.h:873
#define IOCTL_TAPE_BASE
Definition: ntddtape.h:35
#define IOCTL_STORAGE_PERSISTENT_RESERVE_OUT
Definition: ntddstor.h:172
USHORT UniqueIdLength
Definition: imports.h:138
#define SCSIOP_TEST_UNIT_READY
Definition: cdrw_hw.h:866
#define REVERSE_BYTES(Destination, Source)
Definition: scsi.h:3465
#define IOCTL_STORAGE_GET_HOTPLUG_INFO
Definition: imports.h:238
NTSTATUS ClasspDeviceSeekPenaltyProperty(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
Definition: utils.c:2172
NTSTATUS ClasspPersistentReserve(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
Definition: utils.c:6211
#define IOCTL_STORAGE_CHECK_PRIORITY_HINT_SUPPORT
Definition: ntddstor.h:196
READ_CAPACITY_DATA_EX LastKnownDriveCapacityData
Definition: classp.h:802
FORCEINLINE PCDB SrbGetCdb(_In_ PVOID Srb)
Definition: srbhelper.h:583
struct _CDB::_CDB10 CDB10
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
#define IOCTL_STORAGE_FIRMWARE_ACTIVATE
Definition: ntddstor.h:211
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
NTSTATUS ClasspDeviceTrimProcess(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ PGUID ActivityId, _Inout_ PSCSI_REQUEST_BLOCK Srb)
Definition: utils.c:3476
#define SRB_CLASS_FLAGS_LOW_PRIORITY
Definition: cdrom.h:162
NTSTATUS ClassDeviceGetLBProvisioningResources(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
Definition: utils.c:5087
#define SCSIOP_RELEASE_UNIT10
Definition: scsi.h:322
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_Must_inspect_result_ NTSTATUS NTAPI ClassReadDriveCapacity(_In_ PDEVICE_OBJECT Fdo)
Definition: class.c:2742
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:498
DEVICE_DATA_MANAGEMENT_SET_ACTION Action
Definition: ntddstor.h:773
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IOCTL_SCSI_PASS_THROUGH_EX
Definition: ntddscsi.h:37
#define IOCTL_STORAGE_FIND_NEW_DEVICES
Definition: ntddstor.h:122
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2864
#define IOCTL_MOUNTDEV_QUERY_DEVICE_NAME
Definition: imports.h:93
PDEVICE_OBJECT DeviceObject
Definition: kstypes.h:153
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
NTSTATUS ClasspAccessAlignmentProperty(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
Definition: utils.c:1700
#define IOCTL_MOUNTDEV_QUERY_UNIQUE_ID
Definition: imports.h:80
#define STATUS_INVALID_PARAMETER_3
Definition: ntstatus.h:477
#define CLASSP_REG_SUBKEY_NAME
Definition: cdromp.h:120
#define FALSE
Definition: types.h:117
#define LastDriveLetter
Definition: class.c:93
_In_ PIRP Irp
Definition: csq.h:116
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
#define FREE_POOL(_PoolPtr)
Definition: cdrom.h:782
struct _FUNCTIONAL_DEVICE_EXTENSION * PFUNCTIONAL_DEVICE_EXTENSION
* PSTORAGE_READ_CAPACITY
Definition: ntddstor.h:861
#define CLASS_SRBEX_SCSI_CDB16_BUFFER_SIZE
Definition: classpnp.h:695
NTSTATUS ClasspWriteCacheProperty(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
Definition: utils.c:1199
#define IOCTL_STORAGE_EJECTION_CONTROL
Definition: ntddstor.h:125
#define IOCTL_STORAGE_RELEASE
Definition: ntddstor.h:119
#define DeviceDsmAction_Trim
Definition: ntddstor.h:276
#define IOCTL_STORAGE_EJECT_MEDIA
Definition: ntddstor.h:107
struct _MOUNTDEV_NAME MOUNTDEV_NAME
STORAGE_READ_CAPACITY
Definition: ntddstor.h:861
_IRQL_requires_same_ NTSTATUS ClasspStorageEventNotification(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: utils.c:7826
VOID NTAPI ClassReleaseRemoveLock(_In_ PDEVICE_OBJECT DeviceObject, _In_opt_ PIRP Tag)
Definition: lock.c:251
NTSTATUS ClasspDeviceGetLBAStatus(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
Definition: utils.c:3861
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
* PSTORAGE_REQUEST_BLOCK
Definition: srb.h:652
#define IoCompleteRequest
Definition: irp.c:1240
#define IOCTL_STORAGE_GET_DEVICE_NUMBER
Definition: ntddstor.h:143
#define RTL_QUERY_REGISTRY_TYPECHECK
struct _CDB::_START_STOP START_STOP
#define IOCTL_STORAGE_RESERVE
Definition: ntddstor.h:116
UNICODE_STRING DeviceName
Definition: classpnp.h:615
#define TEST_FLAG(Flags, Bit)
Definition: cdrom.h:1495
FORCEINLINE VOID SrbSetCdbLength(_In_ PVOID Srb, _In_ UCHAR CdbLength)
Definition: srbhelper.h:1093
#define IOCTL_STORAGE_CHECK_VERIFY
Definition: ntddstor.h:98
const char name[9]
Definition: class.c:927
#define STATUS_NOT_FOUND
Definition: shellext.h:72
#define IOCTL_STORAGE_QUERY_PROPERTY
Definition: ntddstor.h:178
struct _MOUNTDEV_UNIQUE_ID MOUNTDEV_UNIQUE_ID
#define DeviceDsmAction_Allocation
Definition: ntddstor.h:280
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define IOCTL_STORAGE_PERSISTENT_RESERVE_IN
Definition: ntddstor.h:169
char CCHAR
Definition: typedefs.h:51
#define IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES
Definition: ntddstor.h:181
#define CLASSP_REG_WRITE_CACHE_VALUE_NAME
Definition: cdromp.h:124
FORCEINLINE VOID SrbSetTimeOutValue(_In_ PVOID Srb, _In_ ULONG TimeOutValue)
Definition: srbhelper.h:821
PSTORAGE_ADAPTER_DESCRIPTOR AdapterDescriptor
Definition: classpnp.h:877
UNICODE_STRING MountedDeviceInterfaceName
Definition: classpnp.h:628
PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:3202
#define IOCTL_STORAGE_LOAD_MEDIA2
Definition: ntddk_ex.h:210
#define STORAGE_ADDRESS_TYPE_BTL8
Definition: srb.h:657
struct _SCSI_REQUEST_BLOCK SCSI_REQUEST_BLOCK
struct _test_info info[]
Definition: SetCursorPos.c:19
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
BOOLEAN PreventMediaRemoval
Definition: ntddstor.h:343
#define IOCTL_STORAGE_FIRMWARE_GET_INFO
Definition: ntddstor.h:205
static const WCHAR L[]
Definition: oid.c:1250
FORCEINLINE VOID SrbSetRequestAttribute(_In_ PVOID Srb, _In_ UCHAR RequestAttribute)
Definition: srbhelper.h:1131
struct _STORAGE_DEVICE_NUMBER STORAGE_DEVICE_NUMBER
NTSYSAPI NTSTATUS WINAPI RtlDeleteRegistryValue(ULONG, PCWSTR, PCWSTR)
#define VOID
Definition: acefi.h:82
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:475
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
#define IOCTL_STORAGE_CHECK_VERIFY2
Definition: ntddk_ex.h:212
#define RTL_REGISTRY_ABSOLUTE
Definition: nt_native.h:161
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2691
#define STATUS_FILES_OPEN
Definition: ntstatus.h:499
#define IOCTL_STORAGE_EVENT_NOTIFICATION
Definition: ntddstor.h:226
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
#define DBGGETIOCTLSTR(_ioctl)
Definition: debug.h:25
#define IOCTL_SCSI_PASS_THROUGH
Definition: scsi_port.h:47
#define DeviceDsmAction_OffloadRead
Definition: ntddstor.h:278
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
VOID NTAPI IoInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
Definition: pnpmgr.c:2486
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
struct _MOUNTDEV_SUGGESTED_LINK_NAME MOUNTDEV_SUGGESTED_LINK_NAME
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define IOCTL_SCSI_PASS_THROUGH_DIRECT
Definition: scsi_port.h:51
#define FirstDriveLetter
Definition: class.c:92
NTSTATUS ClasspDeviceLBProvisioningProperty(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
Definition: utils.c:2894
unsigned short USHORT
Definition: pedump.c:61
#define IOCTL_MOUNTDEV_QUERY_SUGGESTED_LINK_NAME
Definition: imports.h:99
NTSTATUS ClasspMcnControl(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PIRP Irp, IN PSCSI_REQUEST_BLOCK Srb)
Definition: autorun.c:3276
#define RTL_QUERY_REGISTRY_TYPECHECK_SHIFT
struct _CDB::_CDB6GENERIC CDB6GENERIC
#define STATUS_DEVICE_BUSY
Definition: udferr_usr.h:129
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define SRB_SIMPLE_TAG_REQUEST
Definition: srb.h:415
#define IOCTL_STORAGE_LOAD_MEDIA
Definition: ntddstor.h:110
#define NULL
Definition: types.h:112
PDEVICE_OBJECT LowerDeviceObject
Definition: classpnp.h:598
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IOCTL_STORAGE_FIRMWARE_DOWNLOAD
Definition: ntddstor.h:208
#define CLASSP_REG_REMOVAL_POLICY_VALUE_NAME
Definition: cdromp.h:126
Definition: name.c:38
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:307
#define FDO_HACK_NO_RESERVE6
Definition: cdromp.h:135
NTSTATUS ClassDeviceHwFirmwareDownloadProcess(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
Definition: utils.c:8539
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS ClassDeviceHwFirmwareGetInfoProcess(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
Definition: utils.c:8364
#define IO_NO_INCREMENT
Definition: iotypes.h:581
FORCEINLINE VOID SrbSetSrbFlags(_In_ PVOID Srb, _In_ ULONG Flags)
Definition: srbhelper.h:964
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
uint32_t * PULONG_PTR
Definition: typedefs.h:65
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
#define STATUS_SUCCESS
Definition: shellext.h:65
#define REG_NONE
Definition: nt_native.h:1492
SCSIPORT_API NTSTATUS NTAPI ClassSendSrbAsynchronous(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PSCSI_REQUEST_BLOCK Srb, _In_ PIRP Irp, _In_reads_bytes_opt_(BufferLength) __drv_aliasesMem PVOID BufferAddress, _In_ ULONG BufferLength, _In_ BOOLEAN WriteToDevice)
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
NTSTATUS ClasspDeviceTrimProperty(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _Inout_ PSCSI_REQUEST_BLOCK Srb)
Definition: utils.c:2730
IoMarkIrpPending(Irp)
#define RTL_QUERY_REGISTRY_REQUIRED
Definition: nt_native.h:132
VOID NTAPI ClassCompleteRequest(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ CCHAR PriorityBoost)
Definition: lock.c:401
static SERVICE_STATUS status
Definition: service.c:31
#define IOCTL_STORAGE_BASE
Definition: ntddstor.h:96
UCHAR UniqueId[1]
Definition: imports.h:139
FORCEINLINE VOID IoSetNextIrpStackLocation(_Inout_ PIRP Irp)
Definition: iofuncs.h:2676
BOOLEAN IsCachedDriveCapDataValid
Definition: classp.h:803
#define SCSIOP_START_STOP_UNIT
Definition: cdrw_hw.h:897
struct _STORAGE_HOTPLUG_INFO STORAGE_HOTPLUG_INFO
LARGE_INTEGER LogicalBlockAddress
Definition: scsi.h:2749
#define RTL_QUERY_REGISTRY_DIRECT
Definition: nt_native.h:144
#define REVERSE_BYTES_QUAD(Destination, Source)
Definition: scsi.h:3452
NTSTATUS ClasspDuidQueryProperty(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: utils.c:997
#define SRB_FLAGS_QUEUE_ACTION_ENABLE
Definition: srb.h:387
LONGLONG QuadPart
Definition: typedefs.h:114
#define IOCTL_STORAGE_READ_CAPACITY
Definition: ntddstor.h:175
#define NT_ASSERT
Definition: rtlfuncs.h:3312
#define REG_SZ
Definition: layer.c:22
Definition: ps.c:97

◆ ClassFindModePage()

SCSIPORT_API PVOID NTAPI ClassFindModePage ( _In_reads_bytes_(Length) PCHAR  ModeSenseBuffer,
_In_ ULONG  Length,
_In_ UCHAR  PageMode,
_In_ BOOLEAN  Use6Byte 
)

Definition at line 6798 of file class.c.

6804 {
6805  PUCHAR limit;
6806  ULONG parameterHeaderLength;
6807  PVOID result = NULL;
6808 
6809  limit = (PUCHAR)ModeSenseBuffer + Length;
6810  parameterHeaderLength = (Use6Byte) ? sizeof(MODE_PARAMETER_HEADER) : sizeof(MODE_PARAMETER_HEADER10);
6811 
6812  if (Length >= parameterHeaderLength) {
6813 
6814  PMODE_PARAMETER_HEADER10 modeParam10;
6815  ULONG blockDescriptorLength;
6816 
6817  /*
6818  * Skip the mode select header and block descriptors.
6819  */
6820  if (Use6Byte){
6821  blockDescriptorLength = ((PMODE_PARAMETER_HEADER) ModeSenseBuffer)->BlockDescriptorLength;
6822  }
6823  else {
6824  modeParam10 = (PMODE_PARAMETER_HEADER10) ModeSenseBuffer;
6825  blockDescriptorLength = modeParam10->BlockDescriptorLength[1];
6826  }
6827 
6828  ModeSenseBuffer += parameterHeaderLength + blockDescriptorLength;
6829 
6830  //
6831  // ModeSenseBuffer now points at pages. Walk the pages looking for the
6832  // requested page until the limit is reached.
6833  //
6834 
6835  while (ModeSenseBuffer +
6837 
6838  if (((PMODE_DISCONNECT_PAGE) ModeSenseBuffer)->PageCode == PageMode) {
6839 
6840  /*
6841  * found the mode page. make sure it's safe to touch it all
6842  * before returning the pointer to caller
6843  */
6844 
6845  if (ModeSenseBuffer + ((PMODE_DISCONNECT_PAGE)ModeSenseBuffer)->PageLength > (PCHAR)limit) {
6846  /*
6847  * Return NULL since the page is not safe to access in full
6848  */
6849  result = NULL;
6850  }
6851  else {
6852  result = ModeSenseBuffer;
6853  }
6854  break;
6855  }
6856 
6857  //
6858  // Advance to the next page which is 4-byte-aligned offset after this page.
6859  //
6860  ModeSenseBuffer +=
6861  ((PMODE_DISCONNECT_PAGE) ModeSenseBuffer)->PageLength +
6863 
6864  }
6865  }
6866 
6867  return result;
6868 } // end ClassFindModePage()
signed char * PCHAR
Definition: retypes.h:7
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_In_ size_t _In_ UCHAR PageMode
Definition: cdrom.h:1325
struct _MODE_DISCONNECT_PAGE * PMODE_DISCONNECT_PAGE
GLuint64EXT * result
Definition: glext.h:11304
unsigned char * PUCHAR
Definition: retypes.h:3
_In_ size_t _In_ UCHAR _In_ BOOLEAN Use6Byte
Definition: cdrom.h:1325
GLint limit
Definition: glext.h:10326
UCHAR BlockDescriptorLength[2]
Definition: cdrw_hw.h:2516
struct _MODE_PARAMETER_HEADER10 MODE_PARAMETER_HEADER10
struct _MODE_PARAMETER_HEADER * PMODE_PARAMETER_HEADER
_In_ ULONG _In_ UCHAR PageCode
Definition: cdrom.h:1316
#define PCHAR
Definition: match.c:90
struct _MODE_PARAMETER_HEADER10 * PMODE_PARAMETER_HEADER10
#define RTL_SIZEOF_THROUGH_FIELD(type, field)
Definition: ntbasedef.h:673
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1

Referenced by ClasspWriteCacheProperty(), ClasspZeroQERR(), DetermineDriveType(), DiskGetCacheInformation(), DiskGetInfoExceptionInformation(), DiskGetModePage(), DiskInfoExceptionComplete(), DiskSetCacheInformation(), and FormatMedia().

◆ ClassForwardIrpSynchronous()

SCSIPORT_API NTSTATUS NTAPI ClassForwardIrpSynchronous ( _In_ PCOMMON_DEVICE_EXTENSION  CommonExtension,
_In_ PIRP  Irp 
)

Definition at line 11343 of file class.c.

11347 {
11349  return ClassSendIrpSynchronous(CommonExtension->LowerDeviceObject, Irp);
11350 } // end ClassForwardIrpSynchronous()
NTSTATUS NTAPI ClassSendIrpSynchronous(_In_ PDEVICE_OBJECT TargetDeviceObject, _In_ PIRP Irp)
Definition: class.c:11373
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2864
_In_ PIRP Irp
Definition: csq.h:116

Referenced by ClassDispatchPnp(), ClasspAccessAlignmentProperty(), ClasspDeviceSeekPenaltyProperty(), ClasspDeviceTrimProcess(), ClasspDeviceTrimProperty(), and ClasspPriorityHint().

◆ ClassGetVpb()

SCSIPORT_API PVPB NTAPI ClassGetVpb ( _In_ PDEVICE_OBJECT  DeviceObject)

Definition at line 11473 of file class.c.

11476 {
11477 #ifdef _MSC_VER
11478 #pragma prefast(suppress:28175)
11479 #endif
11480  return DeviceObject->Vpb;
11481 } // end ClassGetVpb()
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055

Referenced by ClassInterpretSenseInfo(), ClassMinimalPowerHandler(), and ClasspInterpretGesnData().

◆ ClassInternalIoControl()

SCSIPORT_API NTSTATUS NTAPI ClassInternalIoControl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

◆ ClassInterpretSenseInfo()

SCSIPORT_API BOOLEAN NTAPI ClassInterpretSenseInfo ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PSCSI_REQUEST_BLOCK  Srb,
_In_ UCHAR  MajorFunctionCode,
_In_ ULONG  IoDeviceCode,
_In_ ULONG  RetryCount,
_Out_ NTSTATUS Status,
_Out_opt_ _Deref_out_range_(0, 100) ULONG RetryInterval 
)

Definition at line 4452 of file class.c.

4461 {