ReactOS  0.4.15-dev-1397-g19779b3
cdrom.h File Reference
#include "wdf.h"
#include "ntddmmc.h"
#include "ntddcdvd.h"
#include "ntddcdrm.h"
#include "ntdddisk.h"
#include "ntddtape.h"
#include "ntddscsi.h"
#include "ntddvol.h"
#include "specstrings.h"
#include "cdromp.h"
#include <initguid.h>
#include <storswtr.h>
Include dependency graph for cdrom.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _ERROR_RECOVERY_DATA
 
struct  _CDROM_DRIVER_EXTENSION
 
struct  _CDROM_MMC_EXTENSION
 
struct  _CDROM_SCRATCH_READ_WRITE_CONTEXT
 
struct  _CDROM_SCRATCH_CONTEXT
 
struct  _CDROM_IOCTL_CONTEXT
 
struct  _CDROM_READ_WRITE_CONTEXT
 
struct  _CDROM_DATA
 
struct  _CDROM_POWER_OPTIONS
 
struct  _CDROM_POWER_CONTEXT
 
struct  _CDROM_DEVICE_EXTENSION
 
struct  _CDROM_REQUEST_CONTEXT
 
struct  _COMPLETION_CONTEXT
 

Macros

#define DEBUG_COMP_ID   DPFLTR_CDROM_ID
 
#define WPP_GUID_CDROM   (A4196372, C3C4, 42d5, 87BF, 7EDB2E9BCC27)
 
#define WPP_CONTROL_GUIDS   WPP_CONTROL_GUIDS_NORMAL_FLAGS(WPP_GUID_CDROM)
 
#define CDROM_HACK_DEC_RRD   (0x00000001)
 
#define CDROM_HACK_FUJITSU_FMCD_10x   (0x00000002)
 
#define CDROM_HACK_HITACHI_GD_2000   (0x00000008)
 
#define CDROM_HACK_TOSHIBA_SD_W1101   (0x00000010)
 
#define CDROM_HACK_BAD_GET_CONFIG_SUPPORT   (0x00000100)
 
#define CDROM_HACK_BAD_TYPE_ONE_GET_CONFIG   (0x00000800)
 
#define CDROM_HACK_BAD_VENDOR_PROFILES   (0x00001000)
 
#define CDROM_HACK_MSFT_VIRTUAL_ODD   (0x00002000)
 
#define CDROM_HACK_LOCKED_PAGES   (0x80000000)
 
#define CDROM_HACK_VALID_FLAGS   (0x00003fff)
 
#define CDROM_HACK_INVALID_FLAGS   (~CDROM_HACK_VALID_FLAGS)
 
#define WRITE_RETRY_DELAY_CD_1x   ((LONGLONG)4266667)
 
#define WRITE_RETRY_DELAY_CD_4x   ((LONGLONG)1066667)
 
#define WRITE_RETRY_DELAY_CD_10x   ((LONGLONG) 426667)
 
#define WRITE_RETRY_DELAY_DVD_1x   ((LONGLONG) 473373)
 
#define WRITE_RETRY_DELAY_DVD_4x   ((LONGLONG) 118343)
 
#define WRITE_RETRY_DELAY_DVD_16x   ((LONGLONG) 29586)
 
#define WRITE_RETRY_DELAY_HDDVD_1x   ((LONGLONG) 143498)
 
#define MAXIMUM_RETRIES   4
 
#define CDROM_GET_CONFIGURATION_TIMEOUT   (0x4)
 
#define CDROM_READ_DISC_INFORMATION_TIMEOUT   (0x4)
 
#define CDROM_TEST_UNIT_READY_TIMEOUT   (0x14)
 
#define CDROM_GET_PERFORMANCE_TIMEOUT   (0x14)
 
#define CDROM_READ_CAPACITY_TIMEOUT   (0x14)
 
#define START_UNIT_TIMEOUT   (60 * 4)
 
#define MEDIA_CHANGE_TIMEOUT_TIME   300
 
#define DEV_SAFE_START_UNIT   0x00000004
 
#define DEV_POWER_PROTECTED   0x00000010
 
#define CDROM_SPECIAL_DISABLE_SPIN_DOWN   0x00000001
 
#define CDROM_SPECIAL_DISABLE_WRITE_CACHE   0x00000010
 
#define SRB_CLASS_FLAGS_LOW_PRIORITY   0x10000000
 
#define SRB_CLASS_FLAGS_PAGING   0x40000000
 
#define CDROM_INTERPRET_SENSE_INFO2_MAXIMUM_HISTORY_COUNT   30000
 
#define IOCTL_MCN_SYNC_FAKE_IOCTL   IOCTL_DISK_UPDATE_DRIVE_SIZE
 
#define CDROM_FLAG_WINPE_MODE   0x00000001
 
#define CdromMmcUpdateComplete   0
 
#define CdromMmcUpdateRequired   1
 
#define CdromMmcUpdateStarted   2
 
#define SCSI_CDROM_TIMEOUT   10
 
#define SCSI_CHANGER_BONUS_TIMEOUT   10
 
#define SCSI_CDROM_OPC_TIMEOUT   260
 
#define HITACHI_MODE_DATA_SIZE   12
 
#define MODE_DATA_SIZE   64
 
#define RAW_SECTOR_SIZE   2352
 
#define COOKED_SECTOR_SIZE   2048
 
#define CDROM_SRB_LIST_SIZE   4
 
#define PLAY_ACTIVE(x)   (x->DeviceAdditionalData.PlayActive)
 
#define MSF_TO_LBA(Minutes, Seconds, Frames)   (ULONG)((60 * 75 * (Minutes)) + (75 * (Seconds)) + ((Frames) - 150))
 
#define ANY_SECTOR   0
 
#define CD_DA_SECTOR   1
 
#define YELLOW_MODE1_SECTOR   2
 
#define YELLOW_MODE2_SECTOR   3
 
#define FORM2_MODE1_SECTOR   4
 
#define FORM2_MODE2_SECTOR   5
 
#define MAX_COPY_PROTECT_AGID   4
 
#define CDROM_TAG_AUTORUN_DISABLE   'ACcS'
 
#define CDROM_TAG_MEDIA_CHANGE_DETECTION   'aCcS'
 
#define CDROM_TAG_SCRATCH   'BCcS'
 
#define CDROM_TAG_GET_CONFIG   'CCcS'
 
#define CDROM_TAG_COMPLETION_CONTEXT   'cCcS'
 
#define CDROM_TAG_DESCRIPTOR   'DCcS'
 
#define CDROM_TAG_DISC_INFO   'dCcS'
 
#define CDROM_TAG_SYNC_EVENT   'eCcS'
 
#define CDROM_TAG_FEATURE   'FCcS'
 
#define CDROM_TAG_GESN   'GCcS'
 
#define CDROM_TAG_SENSE_INFO   'ICcS'
 
#define CDROM_TAG_INQUIRY   'iCcS'
 
#define CDROM_TAG_MODE_DATA   'MCcS'
 
#define CDROM_TAG_STREAM   'OCCS'
 
#define CDROM_TAG_NOTIFICATION   'oCcS'
 
#define CDROM_TAG_PLAY_ACTIVE   'pCcS'
 
#define CDROM_TAG_REGISTRY   'rCcS'
 
#define CDROM_TAG_SRB   'SCcS'
 
#define CDROM_TAG_STRINGS   'sCcS'
 
#define CDROM_TAG_UPDATE_CAP   'UCcS'
 
#define CDROM_TAG_ZERO_POWER_ODD   'ZCcS'
 
#define DVD_TAG_READ_KEY   'uCcS'
 
#define DVD_TAG_RPC2_CHECK   'VCcS'
 
#define DVD_TAG_DVD_REGION   'vCcS'
 
#define DVD_TAG_SECURITY   'XCcS'
 
#define CDROM_SUBKEY_NAME   (L"CdRom")
 
#define CDROM_READ_CD_NAME   (L"ReadCD")
 
#define CDROM_NON_MMC_DRIVE_NAME   (L"NonMmc")
 
#define CDROM_TYPE_ONE_GET_CONFIG_NAME   (L"NoTypeOneGetConfig")
 
#define CDROM_NON_MMC_VENDOR_SPECIFIC_PROFILE   (L"NonMmcVendorSpecificProfile")
 
#define DVD_DEFAULT_REGION   (L"DefaultDvdRegion")
 
#define DVD_MAX_REGION   8
 
#define AACS_MKB_PACK_SIZE   0x8000
 
#define FREE_POOL(_PoolPtr)
 
#define EXCLUSIVE_MODE(_CdData)   (_CdData->ExclusiveOwner != NULL)
 
#define EXCLUSIVE_OWNER(_CdData, _FileObject)   (_CdData->ExclusiveOwner == _FileObject)
 
#define IS_SCSIOP_READ(opCode)
 
#define IS_SCSIOP_WRITE(opCode)
 
#define IS_SCSIOP_READWRITE(opCode)   (IS_SCSIOP_READ(opCode) || IS_SCSIOP_WRITE(opCode))
 
#define SET_FLAG(Flags, Bit)   ((Flags) |= (Bit))
 
#define CLEAR_FLAG(Flags, Bit)   ((Flags) &= ~(Bit))
 
#define TEST_FLAG(Flags, Bit)   (((Flags) & (Bit)) != 0)
 
#define SIZEOF_ARRAY(ar)   (sizeof(ar)/sizeof((ar)[0]))
 
#define UNIT_100NS_PER_SECOND   (10*1000*1000)
 
#define SECONDS_TO_100NS_UNITS(x)   (((LONGLONG)x) * UNIT_100NS_PER_SECOND)
 
#define SET_FLAG(Flags, Bit)   ((Flags) |= (Bit))
 
#define CLEAR_FLAG(Flags, Bit)   ((Flags) &= ~(Bit))
 
#define TEST_FLAG(Flags, Bit)   (((Flags) & (Bit)) != 0)
 

Typedefs

typedef struct _ERROR_RECOVERY_DATA ERROR_RECOVERY_DATA
 
typedef struct _ERROR_RECOVERY_DATAPERROR_RECOVERY_DATA
 
typedef struct _CDROM_DEVICE_EXTENSION CDROM_DEVICE_EXTENSION
 
typedef struct _CDROM_DEVICE_EXTENSIONPCDROM_DEVICE_EXTENSION
 
typedef VOID(* PCDROM_ERROR_HANDLER) (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ PSCSI_REQUEST_BLOCK Srb, _Inout_ PNTSTATUS Status, _Inout_ PBOOLEAN Retry)
 
typedef struct _CDROM_DRIVER_EXTENSION CDROM_DRIVER_EXTENSION
 
typedef struct _CDROM_DRIVER_EXTENSIONPCDROM_DRIVER_EXTENSION
 
typedef struct _CDROM_MMC_EXTENSION CDROM_MMC_EXTENSION
 
typedef struct _CDROM_MMC_EXTENSIONPCDROM_MMC_EXTENSION
 
typedef struct _CDROM_SCRATCH_READ_WRITE_CONTEXT CDROM_SCRATCH_READ_WRITE_CONTEXT
 
typedef struct _CDROM_SCRATCH_READ_WRITE_CONTEXTPCDROM_SCRATCH_READ_WRITE_CONTEXT
 
typedef struct _CDROM_SCRATCH_CONTEXT CDROM_SCRATCH_CONTEXT
 
typedef struct _CDROM_SCRATCH_CONTEXTPCDROM_SCRATCH_CONTEXT
 
typedef struct _CDROM_IOCTL_CONTEXT CDROM_IOCTL_CONTEXT
 
typedef struct _CDROM_IOCTL_CONTEXTPCDROM_IOCTL_CONTEXT
 
typedef struct _CDROM_READ_WRITE_CONTEXT CDROM_READ_WRITE_CONTEXT
 
typedef struct _CDROM_READ_WRITE_CONTEXTPCDROM_READ_WRITE_CONTEXT
 
typedef struct _CDROM_DATA CDROM_DATA
 
typedef struct _CDROM_DATAPCDROM_DATA
 
typedef struct _CDROM_POWER_OPTIONS CDROM_POWER_OPTIONS
 
typedef struct _CDROM_POWER_OPTIONSPCDROM_POWER_OPTIONS
 
typedef struct _CDROM_POWER_CONTEXT CDROM_POWER_CONTEXT
 
typedef struct _CDROM_POWER_CONTEXTPCDROM_POWER_CONTEXT
 
typedef NTSTATUS SYNC_HANDLER(_In_ WDFDEVICE Device, _In_ WDFREQUEST Request)
 
typedef SYNC_HANDLERPSYNC_HANDLER
 
typedef struct _CDROM_REQUEST_CONTEXT CDROM_REQUEST_CONTEXT
 
typedef struct _CDROM_REQUEST_CONTEXTPCDROM_REQUEST_CONTEXT
 
typedef struct _COMPLETION_CONTEXT COMPLETION_CONTEXT
 
typedef struct _COMPLETION_CONTEXTPCOMPLETION_CONTEXT
 
typedef enum CDROM_DEVICE_INTERFACESPCDROM_DEVICE_INTERFACES
 
typedef VOID(* PCDROM_SCAN_FOR_SPECIAL_HANDLER) (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ ULONG_PTR Data)
 

Enumerations

enum  CDROM_POWER_DOWN_STATE {
  PowerDownDeviceInitial, PowerDownDeviceLocked, PowerDownDeviceQuiesced, PowerDownDeviceFlushed,
  PowerDownDeviceStopped, PowerDownDeviceOff, PowerDownDeviceUnlocked
}
 
enum  CDROM_POWER_UP_STATE {
  PowerUpDeviceInitial, PowerUpDeviceLocked, PowerUpDeviceOn, PowerUpDeviceStarted,
  PowerUpDeviceUnlocked
}
 
enum  CDROM_DEVICE_INTERFACES { CdRomDeviceInterface = 0, MountedDeviceInterface }
 

Functions

 _IRQL_requires_max_ (DISPATCH_LEVEL) NTKERNELAPI BOOLEAN NTAPI PsIsThreadTerminating(_In_ PETHREAD Thread)
 
 C_ASSERT ((MAXULONG - sizeof(SRB_HISTORY))/30000 >=sizeof(SRB_HISTORY_ITEM))
 
__inline BOOLEAN ValidChar (UCHAR Ch)
 
__inline BOOLEAN PORT_ALLOCATED_SENSE (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ PSCSI_REQUEST_BLOCK Srb)
 
__inline VOID FREE_PORT_ALLOCATED_SENSE_BUFFER (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ PSCSI_REQUEST_BLOCK Srb)
 
VOID NTAPI SequentialQueueEvtIoReadWrite (_In_ WDFQUEUE Queue, _In_ WDFREQUEST Request, _In_ size_t Length)
 
 _IRQL_requires_max_ (PASSIVE_LEVEL) NTSTATUS DeviceClaimRelease(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension
 
 _IRQL_requires_max_ (APC_LEVEL) VOID DeviceReleaseMcnResources(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension)
 
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)
 
VOID RequestSetReceivedTime (_In_ WDFREQUEST Request)
 
VOID RequestSetSentTime (_In_ WDFREQUEST Request)
 
VOID RequestClearSendTime (_In_ WDFREQUEST Request)
 
BOOLEAN RequestSenseInfoInterpretForScratchBuffer (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ ULONG RetriedCount, _Out_ NTSTATUS *Status, _Out_ _Deref_out_range_(0, MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS) LONGLONG *RetryIntervalIn100ns)
 
VOID DeviceSendNotification (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ const GUID *Guid, _In_ ULONG ExtraDataSize, _In_opt_ PVOID ExtraData)
 
VOID DeviceSendStartUnit (_In_ WDFDEVICE Device)
 
VOID DeviceReleaseQueue (_In_ WDFDEVICE Device)
 
VOID DevicePerfIncrementErrorCount (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS DeviceErrorHandlerForMmc (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ PSCSI_REQUEST_BLOCK Srb, _Inout_ PNTSTATUS Status, _Inout_ PBOOLEAN Retry)
 
NTSTATUS DeviceErrorHandlerForHitachiGD2000 (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ PSCSI_REQUEST_BLOCK Srb, _Inout_ PNTSTATUS Status, _Inout_ PBOOLEAN Retry)
 
VOID DeviceSetMediaChangeStateEx (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ MEDIA_CHANGE_DETECTION_STATE NewState, _Inout_opt_ PMEDIA_CHANGE_DETECTION_STATE OldState)
 
NTSTATUS RequestSynchronizeProcessWithSerialQueue (_In_ WDFDEVICE Device, _In_ WDFREQUEST Request)
 
NTSTATUS RequestIsIoctlBlockedByExclusiveAccess (_In_ WDFREQUEST Request, _Out_ PBOOLEAN IsBlocked)
 
VOID DeviceSendIoctlAsynchronously (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ ULONG IoControlCode, _In_ PDEVICE_OBJECT TargetDeviceObject)
 
BOOLEAN DeviceIsMmcUpdateRequired (_In_ WDFDEVICE Device)
 
NTSTATUS RequestSetContextFields (_In_ WDFREQUEST Request, _In_ PSYNC_HANDLER Handler)
 
NTSTATUS RequestDuidGetDeviceIdProperty (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
NTSTATUS RequestDuidGetDeviceProperty (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
 
 _In_reads_bytes_ (Length) PCHAR ModeSenseBuffer
 
VOID RequestSetupMcnSyncIrp (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS DeviceZPODDGetPowerupReason (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _Out_ PSTORAGE_IDLE_POWERUP_REASON PowerupReason)
 
__inline ULONG CountOfSetBitsUChar (UCHAR _X)
 
__inline ULONG CountOfSetBitsULong (ULONG _X)
 
__inline ULONG CountOfSetBitsULong32 (ULONG32 _X)
 
__inline ULONG CountOfSetBitsULong64 (ULONG64 _X)
 
__inline ULONG CountOfSetBitsUlongPtr (ULONG_PTR _X)
 
__inline BOOLEAN IsVolumeMounted (_In_ PDEVICE_OBJECT DeviceObject)
 
__inline _Ret_range_ (0, MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS) LONGLONG ConvertSectorsPerSecondTo100nsUnitsFor64kWrite(_In_range_(1
 
__inline UCHAR RequestGetCurrentStackLocationFlags (_In_ WDFREQUEST Request)
 
__inline ULONG TimeOutValueGetCapValue (_In_ ULONG TimeOutValue, _In_ ULONG Times)
 
VOID RequestCompletion (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ NTSTATUS Status, _In_ ULONG_PTR Information)
 
NTSTATUS RequestSend (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDFIOTARGET IoTarget, _In_ ULONG Flags, _Out_opt_ PBOOLEAN RequestSent)
 
VOID RequestProcessInternalDeviceControl (_In_ WDFREQUEST Request, _In_ PCDROM_DEVICE_EXTENSION DeviceExtension)
 

Variables

CDROM_SCAN_FOR_SPECIAL_INFO CdromHackItems []
 
DRIVER_INITIALIZE DriverEntry
 
EVT_WDF_DRIVER_DEVICE_ADD DriverEvtDeviceAdd
 
EVT_WDF_OBJECT_CONTEXT_CLEANUP DriverEvtCleanup
 
EVT_WDF_OBJECT_CONTEXT_CLEANUP DeviceEvtCleanup
 
EVT_WDF_FILE_CLOSE DeviceEvtFileClose
 
EVT_WDF_IO_IN_CALLER_CONTEXT DeviceEvtIoInCallerContext
 
EVT_WDF_DEVICE_SELF_MANAGED_IO_INIT DeviceEvtSelfManagedIoInit
 
EVT_WDF_DEVICE_SELF_MANAGED_IO_CLEANUP DeviceEvtSelfManagedIoCleanup
 
EVT_WDF_DEVICE_D0_ENTRY DeviceEvtD0Entry
 
EVT_WDF_DEVICE_D0_EXIT DeviceEvtD0Exit
 
EVT_WDF_DEVICE_SURPRISE_REMOVAL DeviceEvtSurpriseRemoval
 
EVT_WDF_IO_QUEUE_IO_DEFAULT CreateQueueEvtIoDefault
 
EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL SequentialQueueEvtIoDeviceControl
 
EVT_WDF_IO_QUEUE_IO_CANCELED_ON_QUEUE SequentialQueueEvtCanceledOnQueue
 
EVT_WDF_OBJECT_CONTEXT_CLEANUP RequestEvtCleanup
 
EVT_WDFDEVICE_WDM_IRP_PREPROCESS RequestProcessShutdownFlush
 
EVT_WDFDEVICE_WDM_IRP_PREPROCESS RequestProcessSetPower
 
_In_ BOOLEAN Release
 
_In_ PSTORAGE_PROPERTY_ID PropertyId
 
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADERDescriptor
 
_In_ ULONG_PTR Data
 
_In_z_ PCHAR TargetString
 
_In_opt_ PWSTR SubkeyName
 
_In_opt_ PWSTR _In_ PWSTR ParameterName
 
_In_opt_ PWSTR _In_ PWSTR _Inout_ PULONG ParameterValue
 
_In_ ULONG_PTR HackFlags
 
_In_ PSCSI_REQUEST_BLOCK Srb
 
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID BufferAddress
 
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID _In_ ULONG BufferLength
 
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID _In_ ULONG _In_ BOOLEAN WriteToDevice
 
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID _In_ ULONG _In_ BOOLEAN _In_opt_ WDFREQUEST OriginalRequest
 
EVT_WDF_REQUEST_COMPLETION_ROUTINE DeviceAsynchronousCompletion
 
EVT_WDF_REQUEST_COMPLETION_ROUTINE DeviceReleaseQueueCompletion
 
_In_ ULONG const Length
 
_In_ ULONG const _In_ FEATURE_NUMBER const Feature
 
_In_ ULONG const Usable
 
_In_ PREAD_CAPACITY_DATA ReadCapacityBuffer
 
_In_ CDROM_DEVICE_INTERFACES InterfaceType
 
_In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine
 
_In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE _In_opt_ WDFCONTEXT Context
 
_In_ CDROM_SCAN_FOR_SPECIAL_INFO DeviceList []
 
_In_ CDROM_SCAN_FOR_SPECIAL_INFO _In_ PCDROM_SCAN_FOR_SPECIAL_HANDLER Function
 
EVT_WDF_WORKITEM DeviceRestoreDefaultSpeed
 
_In_ PFILE_OBJECT_CONTEXT FileObjectContext
 
_In_ WDFFILEOBJECT FileObject
 
_In_ WDFFILEOBJECT _In_ BOOLEAN IgnorePreviousMediaChanges
 
_In_ WDFREQUEST Request
 
_In_ WDFREQUEST _In_ BOOLEAN RequestFormated
 
IO_COMPLETION_ROUTINE RequestAsynchronousIrpCompletion
 
_In_ ULONG _In_ UCHAR PageCode
 
_In_ ULONG _In_ UCHAR _In_ UCHAR PageControl
 
_In_ size_t _In_ UCHAR PageMode
 
_In_ size_t _In_ UCHAR _In_ BOOLEAN Use6Byte
 
_In_ WDFREQUEST _In_ MEDIA_LOCK_TYPE LockType
 
_In_ WDFREQUEST _In_ MEDIA_LOCK_TYPE _In_ BOOLEAN Lock
 
EVT_WDF_TIMER DeviceMainTimerTickHandler
 
_In_ BOOLEAN UseGesn
 
POWER_SETTING_CALLBACK DevicePowerSettingCallback
 
_In_ BOOLEAN IsActive
 
_In_ BOOLEAN _In_ BOOLEAN SetIdleTimeout
 
_In_ ULONG IoControlCode
 
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID InputBuffer
 
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t InputBufferLength
 
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID OutputBuffer
 
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t OutputBufferLength
 
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_tDataLength
 
__inline ULONG SectorsPerSecond
 
EVT_WDF_REQUEST_COMPLETION_ROUTINE RequestDummyCompletionRoutine
 
EVT_WDF_WORKITEM IoctlWorkItemRoutine
 
EVT_WDF_WORKITEM ReadWriteWorkItemRoutine
 

Macro Definition Documentation

◆ AACS_MKB_PACK_SIZE

#define AACS_MKB_PACK_SIZE   0x8000

Definition at line 764 of file cdrom.h.

◆ ANY_SECTOR

#define ANY_SECTOR   0

Definition at line 705 of file cdrom.h.

◆ CD_DA_SECTOR

#define CD_DA_SECTOR   1

Definition at line 706 of file cdrom.h.

◆ CDROM_FLAG_WINPE_MODE

#define CDROM_FLAG_WINPE_MODE   0x00000001

Definition at line 237 of file cdrom.h.

◆ CDROM_GET_CONFIGURATION_TIMEOUT

#define CDROM_GET_CONFIGURATION_TIMEOUT   (0x4)

Definition at line 126 of file cdrom.h.

◆ CDROM_GET_PERFORMANCE_TIMEOUT

#define CDROM_GET_PERFORMANCE_TIMEOUT   (0x14)

Definition at line 129 of file cdrom.h.

◆ CDROM_HACK_BAD_GET_CONFIG_SUPPORT

#define CDROM_HACK_BAD_GET_CONFIG_SUPPORT   (0x00000100)

Definition at line 96 of file cdrom.h.

◆ CDROM_HACK_BAD_TYPE_ONE_GET_CONFIG

#define CDROM_HACK_BAD_TYPE_ONE_GET_CONFIG   (0x00000800)

Definition at line 99 of file cdrom.h.

◆ CDROM_HACK_BAD_VENDOR_PROFILES

#define CDROM_HACK_BAD_VENDOR_PROFILES   (0x00001000)

Definition at line 100 of file cdrom.h.

◆ CDROM_HACK_DEC_RRD

#define CDROM_HACK_DEC_RRD   (0x00000001)

Definition at line 88 of file cdrom.h.

◆ CDROM_HACK_FUJITSU_FMCD_10x

#define CDROM_HACK_FUJITSU_FMCD_10x   (0x00000002)

Definition at line 89 of file cdrom.h.

◆ CDROM_HACK_HITACHI_GD_2000

#define CDROM_HACK_HITACHI_GD_2000   (0x00000008)

Definition at line 91 of file cdrom.h.

◆ CDROM_HACK_INVALID_FLAGS

#define CDROM_HACK_INVALID_FLAGS   (~CDROM_HACK_VALID_FLAGS)

Definition at line 105 of file cdrom.h.

◆ CDROM_HACK_LOCKED_PAGES

#define CDROM_HACK_LOCKED_PAGES   (0x80000000)

Definition at line 102 of file cdrom.h.

◆ CDROM_HACK_MSFT_VIRTUAL_ODD

#define CDROM_HACK_MSFT_VIRTUAL_ODD   (0x00002000)

Definition at line 101 of file cdrom.h.

◆ CDROM_HACK_TOSHIBA_SD_W1101

#define CDROM_HACK_TOSHIBA_SD_W1101   (0x00000010)

Definition at line 92 of file cdrom.h.

◆ CDROM_HACK_VALID_FLAGS

#define CDROM_HACK_VALID_FLAGS   (0x00003fff)

Definition at line 104 of file cdrom.h.

◆ CDROM_INTERPRET_SENSE_INFO2_MAXIMUM_HISTORY_COUNT

#define CDROM_INTERPRET_SENSE_INFO2_MAXIMUM_HISTORY_COUNT   30000

Definition at line 176 of file cdrom.h.

◆ CDROM_NON_MMC_DRIVE_NAME

#define CDROM_NON_MMC_DRIVE_NAME   (L"NonMmc")

Definition at line 756 of file cdrom.h.

◆ CDROM_NON_MMC_VENDOR_SPECIFIC_PROFILE

#define CDROM_NON_MMC_VENDOR_SPECIFIC_PROFILE   (L"NonMmcVendorSpecificProfile")

Definition at line 758 of file cdrom.h.

◆ CDROM_READ_CAPACITY_TIMEOUT

#define CDROM_READ_CAPACITY_TIMEOUT   (0x14)

Definition at line 130 of file cdrom.h.

◆ CDROM_READ_CD_NAME

#define CDROM_READ_CD_NAME   (L"ReadCD")

Definition at line 755 of file cdrom.h.

◆ CDROM_READ_DISC_INFORMATION_TIMEOUT

#define CDROM_READ_DISC_INFORMATION_TIMEOUT   (0x4)

Definition at line 127 of file cdrom.h.

◆ CDROM_SPECIAL_DISABLE_SPIN_DOWN

#define CDROM_SPECIAL_DISABLE_SPIN_DOWN   0x00000001

Definition at line 149 of file cdrom.h.

◆ CDROM_SPECIAL_DISABLE_WRITE_CACHE

#define CDROM_SPECIAL_DISABLE_WRITE_CACHE   0x00000010

Definition at line 157 of file cdrom.h.

◆ CDROM_SRB_LIST_SIZE

#define CDROM_SRB_LIST_SIZE   4

Definition at line 696 of file cdrom.h.

◆ CDROM_SUBKEY_NAME

#define CDROM_SUBKEY_NAME   (L"CdRom")

Definition at line 754 of file cdrom.h.

◆ CDROM_TAG_AUTORUN_DISABLE

#define CDROM_TAG_AUTORUN_DISABLE   'ACcS'

Definition at line 724 of file cdrom.h.

◆ CDROM_TAG_COMPLETION_CONTEXT

#define CDROM_TAG_COMPLETION_CONTEXT   'cCcS'

Definition at line 729 of file cdrom.h.

◆ CDROM_TAG_DESCRIPTOR

#define CDROM_TAG_DESCRIPTOR   'DCcS'

Definition at line 730 of file cdrom.h.

◆ CDROM_TAG_DISC_INFO

#define CDROM_TAG_DISC_INFO   'dCcS'

Definition at line 731 of file cdrom.h.

◆ CDROM_TAG_FEATURE

#define CDROM_TAG_FEATURE   'FCcS'

Definition at line 733 of file cdrom.h.

◆ CDROM_TAG_GESN

#define CDROM_TAG_GESN   'GCcS'

Definition at line 734 of file cdrom.h.

◆ CDROM_TAG_GET_CONFIG

#define CDROM_TAG_GET_CONFIG   'CCcS'

Definition at line 728 of file cdrom.h.

◆ CDROM_TAG_INQUIRY

#define CDROM_TAG_INQUIRY   'iCcS'

Definition at line 736 of file cdrom.h.

◆ CDROM_TAG_MEDIA_CHANGE_DETECTION

#define CDROM_TAG_MEDIA_CHANGE_DETECTION   'aCcS'

Definition at line 725 of file cdrom.h.

◆ CDROM_TAG_MODE_DATA

#define CDROM_TAG_MODE_DATA   'MCcS'

Definition at line 737 of file cdrom.h.

◆ CDROM_TAG_NOTIFICATION

#define CDROM_TAG_NOTIFICATION   'oCcS'

Definition at line 739 of file cdrom.h.

◆ CDROM_TAG_PLAY_ACTIVE

#define CDROM_TAG_PLAY_ACTIVE   'pCcS'

Definition at line 740 of file cdrom.h.

◆ CDROM_TAG_REGISTRY

#define CDROM_TAG_REGISTRY   'rCcS'

Definition at line 741 of file cdrom.h.

◆ CDROM_TAG_SCRATCH

#define CDROM_TAG_SCRATCH   'BCcS'

Definition at line 727 of file cdrom.h.

◆ CDROM_TAG_SENSE_INFO

#define CDROM_TAG_SENSE_INFO   'ICcS'

Definition at line 735 of file cdrom.h.

◆ CDROM_TAG_SRB

#define CDROM_TAG_SRB   'SCcS'

Definition at line 742 of file cdrom.h.

◆ CDROM_TAG_STREAM

#define CDROM_TAG_STREAM   'OCCS'

Definition at line 738 of file cdrom.h.

◆ CDROM_TAG_STRINGS

#define CDROM_TAG_STRINGS   'sCcS'

Definition at line 743 of file cdrom.h.

◆ CDROM_TAG_SYNC_EVENT

#define CDROM_TAG_SYNC_EVENT   'eCcS'

Definition at line 732 of file cdrom.h.

◆ CDROM_TAG_UPDATE_CAP

#define CDROM_TAG_UPDATE_CAP   'UCcS'

Definition at line 744 of file cdrom.h.

◆ CDROM_TAG_ZERO_POWER_ODD

#define CDROM_TAG_ZERO_POWER_ODD   'ZCcS'

Definition at line 745 of file cdrom.h.

◆ CDROM_TEST_UNIT_READY_TIMEOUT

#define CDROM_TEST_UNIT_READY_TIMEOUT   (0x14)

Definition at line 128 of file cdrom.h.

◆ CDROM_TYPE_ONE_GET_CONFIG_NAME

#define CDROM_TYPE_ONE_GET_CONFIG_NAME   (L"NoTypeOneGetConfig")

Definition at line 757 of file cdrom.h.

◆ CdromMmcUpdateComplete

#define CdromMmcUpdateComplete   0

Definition at line 241 of file cdrom.h.

◆ CdromMmcUpdateRequired

#define CdromMmcUpdateRequired   1

Definition at line 242 of file cdrom.h.

◆ CdromMmcUpdateStarted

#define CdromMmcUpdateStarted   2

Definition at line 243 of file cdrom.h.

◆ CLEAR_FLAG [1/2]

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

Definition at line 1494 of file cdrom.h.

◆ CLEAR_FLAG [2/2]

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

Definition at line 1494 of file cdrom.h.

◆ COOKED_SECTOR_SIZE

#define COOKED_SECTOR_SIZE   2048

Definition at line 694 of file cdrom.h.

◆ DEBUG_COMP_ID

#define DEBUG_COMP_ID   DPFLTR_CDROM_ID

Definition at line 48 of file cdrom.h.

◆ DEV_POWER_PROTECTED

#define DEV_POWER_PROTECTED   0x00000010

Definition at line 143 of file cdrom.h.

◆ DEV_SAFE_START_UNIT

#define DEV_SAFE_START_UNIT   0x00000004

Definition at line 139 of file cdrom.h.

◆ DVD_DEFAULT_REGION

#define DVD_DEFAULT_REGION   (L"DefaultDvdRegion")

Definition at line 760 of file cdrom.h.

◆ DVD_MAX_REGION

#define DVD_MAX_REGION   8

Definition at line 761 of file cdrom.h.

◆ DVD_TAG_DVD_REGION

#define DVD_TAG_DVD_REGION   'vCcS'

Definition at line 749 of file cdrom.h.

◆ DVD_TAG_READ_KEY

#define DVD_TAG_READ_KEY   'uCcS'

Definition at line 747 of file cdrom.h.

◆ DVD_TAG_RPC2_CHECK

#define DVD_TAG_RPC2_CHECK   'VCcS'

Definition at line 748 of file cdrom.h.

◆ DVD_TAG_SECURITY

#define DVD_TAG_SECURITY   'XCcS'

Definition at line 750 of file cdrom.h.

◆ EXCLUSIVE_MODE

#define EXCLUSIVE_MODE (   _CdData)    (_CdData->ExclusiveOwner != NULL)

Definition at line 788 of file cdrom.h.

◆ EXCLUSIVE_OWNER

#define EXCLUSIVE_OWNER (   _CdData,
  _FileObject 
)    (_CdData->ExclusiveOwner == _FileObject)

Definition at line 789 of file cdrom.h.

◆ FORM2_MODE1_SECTOR

#define FORM2_MODE1_SECTOR   4

Definition at line 709 of file cdrom.h.

◆ FORM2_MODE2_SECTOR

#define FORM2_MODE2_SECTOR   5

Definition at line 710 of file cdrom.h.

◆ FREE_POOL

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

Definition at line 782 of file cdrom.h.

◆ HITACHI_MODE_DATA_SIZE

#define HITACHI_MODE_DATA_SIZE   12

Definition at line 690 of file cdrom.h.

◆ IOCTL_MCN_SYNC_FAKE_IOCTL

#define IOCTL_MCN_SYNC_FAKE_IOCTL   IOCTL_DISK_UPDATE_DRIVE_SIZE

Definition at line 181 of file cdrom.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 791 of file cdrom.h.

◆ IS_SCSIOP_READWRITE

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

Definition at line 803 of file cdrom.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 797 of file cdrom.h.

◆ MAX_COPY_PROTECT_AGID

#define MAX_COPY_PROTECT_AGID   4

Definition at line 712 of file cdrom.h.

◆ MAXIMUM_RETRIES

#define MAXIMUM_RETRIES   4

Definition at line 124 of file cdrom.h.

◆ MEDIA_CHANGE_TIMEOUT_TIME

#define MEDIA_CHANGE_TIMEOUT_TIME   300

Definition at line 135 of file cdrom.h.

◆ MODE_DATA_SIZE

#define MODE_DATA_SIZE   64

Definition at line 691 of file cdrom.h.

◆ MSF_TO_LBA

#define MSF_TO_LBA (   Minutes,
  Seconds,
  Frames 
)    (ULONG)((60 * 75 * (Minutes)) + (75 * (Seconds)) + ((Frames) - 150))

Definition at line 700 of file cdrom.h.

◆ PLAY_ACTIVE

#define PLAY_ACTIVE (   x)    (x->DeviceAdditionalData.PlayActive)

Definition at line 698 of file cdrom.h.

◆ RAW_SECTOR_SIZE

#define RAW_SECTOR_SIZE   2352

Definition at line 693 of file cdrom.h.

◆ SCSI_CDROM_OPC_TIMEOUT

#define SCSI_CDROM_OPC_TIMEOUT   260

Definition at line 688 of file cdrom.h.

◆ SCSI_CDROM_TIMEOUT

#define SCSI_CDROM_TIMEOUT   10

Definition at line 680 of file cdrom.h.

◆ SCSI_CHANGER_BONUS_TIMEOUT

#define SCSI_CHANGER_BONUS_TIMEOUT   10

Definition at line 681 of file cdrom.h.

◆ SECONDS_TO_100NS_UNITS

#define SECONDS_TO_100NS_UNITS (   x)    (((LONGLONG)x) * UNIT_100NS_PER_SECOND)

Definition at line 1488 of file cdrom.h.

◆ SET_FLAG [1/2]

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

Definition at line 1493 of file cdrom.h.

◆ SET_FLAG [2/2]

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

Definition at line 1493 of file cdrom.h.

◆ SIZEOF_ARRAY

#define SIZEOF_ARRAY (   ar)    (sizeof(ar)/sizeof((ar)[0]))

Definition at line 1482 of file cdrom.h.

◆ SRB_CLASS_FLAGS_LOW_PRIORITY

#define SRB_CLASS_FLAGS_LOW_PRIORITY   0x10000000

Definition at line 162 of file cdrom.h.

◆ SRB_CLASS_FLAGS_PAGING

#define SRB_CLASS_FLAGS_PAGING   0x40000000

Definition at line 165 of file cdrom.h.

◆ START_UNIT_TIMEOUT

#define START_UNIT_TIMEOUT   (60 * 4)

Definition at line 132 of file cdrom.h.

◆ TEST_FLAG [1/2]

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

Definition at line 1495 of file cdrom.h.

◆ TEST_FLAG [2/2]

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

Definition at line 1495 of file cdrom.h.

◆ UNIT_100NS_PER_SECOND

#define UNIT_100NS_PER_SECOND   (10*1000*1000)

Definition at line 1487 of file cdrom.h.

◆ WPP_CONTROL_GUIDS

Definition at line 58 of file cdrom.h.

◆ WPP_GUID_CDROM

#define WPP_GUID_CDROM   (A4196372, C3C4, 42d5, 87BF, 7EDB2E9BCC27)

Definition at line 56 of file cdrom.h.

◆ WRITE_RETRY_DELAY_CD_10x

#define WRITE_RETRY_DELAY_CD_10x   ((LONGLONG) 426667)

Definition at line 117 of file cdrom.h.

◆ WRITE_RETRY_DELAY_CD_1x

#define WRITE_RETRY_DELAY_CD_1x   ((LONGLONG)4266667)

Definition at line 115 of file cdrom.h.

◆ WRITE_RETRY_DELAY_CD_4x

#define WRITE_RETRY_DELAY_CD_4x   ((LONGLONG)1066667)

Definition at line 116 of file cdrom.h.

◆ WRITE_RETRY_DELAY_DVD_16x

#define WRITE_RETRY_DELAY_DVD_16x   ((LONGLONG) 29586)

Definition at line 120 of file cdrom.h.

◆ WRITE_RETRY_DELAY_DVD_1x

#define WRITE_RETRY_DELAY_DVD_1x   ((LONGLONG) 473373)

Definition at line 118 of file cdrom.h.

◆ WRITE_RETRY_DELAY_DVD_4x

#define WRITE_RETRY_DELAY_DVD_4x   ((LONGLONG) 118343)

Definition at line 119 of file cdrom.h.

◆ WRITE_RETRY_DELAY_HDDVD_1x

#define WRITE_RETRY_DELAY_HDDVD_1x   ((LONGLONG) 143498)

Definition at line 121 of file cdrom.h.

◆ YELLOW_MODE1_SECTOR

#define YELLOW_MODE1_SECTOR   2

Definition at line 707 of file cdrom.h.

◆ YELLOW_MODE2_SECTOR

#define YELLOW_MODE2_SECTOR   3

Definition at line 708 of file cdrom.h.

Typedef Documentation

◆ CDROM_DATA

◆ CDROM_DEVICE_EXTENSION

Definition at line 216 of file cdrom.h.

◆ CDROM_DRIVER_EXTENSION

◆ CDROM_IOCTL_CONTEXT

◆ CDROM_MMC_EXTENSION

◆ CDROM_POWER_CONTEXT

◆ CDROM_POWER_OPTIONS

◆ CDROM_READ_WRITE_CONTEXT

◆ CDROM_REQUEST_CONTEXT

◆ CDROM_SCRATCH_CONTEXT

◆ CDROM_SCRATCH_READ_WRITE_CONTEXT

◆ COMPLETION_CONTEXT

◆ ERROR_RECOVERY_DATA

◆ PCDROM_DATA

◆ PCDROM_DEVICE_EXTENSION

Definition at line 216 of file cdrom.h.

◆ PCDROM_DEVICE_INTERFACES

◆ PCDROM_DRIVER_EXTENSION

◆ PCDROM_ERROR_HANDLER

typedef VOID(* PCDROM_ERROR_HANDLER) (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ PSCSI_REQUEST_BLOCK Srb, _Inout_ PNTSTATUS Status, _Inout_ PBOOLEAN Retry)

Definition at line 222 of file cdrom.h.

◆ PCDROM_IOCTL_CONTEXT

◆ PCDROM_MMC_EXTENSION

◆ PCDROM_POWER_CONTEXT

◆ PCDROM_POWER_OPTIONS

◆ PCDROM_READ_WRITE_CONTEXT

◆ PCDROM_REQUEST_CONTEXT

◆ PCDROM_SCAN_FOR_SPECIAL_HANDLER

typedef VOID(* PCDROM_SCAN_FOR_SPECIAL_HANDLER) (_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ ULONG_PTR Data)

Definition at line 775 of file cdrom.h.

◆ PCDROM_SCRATCH_CONTEXT

◆ PCDROM_SCRATCH_READ_WRITE_CONTEXT

◆ PCOMPLETION_CONTEXT

◆ PERROR_RECOVERY_DATA

◆ PSYNC_HANDLER

Definition at line 628 of file cdrom.h.

◆ SYNC_HANDLER

typedef NTSTATUS SYNC_HANDLER(_In_ WDFDEVICE Device, _In_ WDFREQUEST Request)

Definition at line 623 of file cdrom.h.

Enumeration Type Documentation

◆ CDROM_DEVICE_INTERFACES

Enumerator
CdRomDeviceInterface 
MountedDeviceInterface 

Definition at line 767 of file cdrom.h.

767  {
768  CdRomDeviceInterface = 0, // CdRomClassGuid
769  MountedDeviceInterface // MOUNTDEV_MOUNTED_DEVICE_GUID
enum CDROM_DEVICE_INTERFACES * PCDROM_DEVICE_INTERFACES
CDROM_DEVICE_INTERFACES
Definition: cdrom.h:767

◆ CDROM_POWER_DOWN_STATE

Enumerator
PowerDownDeviceInitial 
PowerDownDeviceLocked 
PowerDownDeviceQuiesced 
PowerDownDeviceFlushed 
PowerDownDeviceStopped 
PowerDownDeviceOff 
PowerDownDeviceUnlocked 

Definition at line 407 of file cdrom.h.

◆ CDROM_POWER_UP_STATE

Enumerator
PowerUpDeviceInitial 
PowerUpDeviceLocked 
PowerUpDeviceOn 
PowerUpDeviceStarted 
PowerUpDeviceUnlocked 

Definition at line 419 of file cdrom.h.

Function Documentation

◆ _In_reads_bytes_()

_In_reads_bytes_ ( Length  )

◆ _IRQL_requires_max_() [1/3]

_IRQL_requires_max_ ( DISPATCH_LEVEL  )

◆ _IRQL_requires_max_() [2/3]

_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

◆ _IRQL_requires_max_() [3/3]

_IRQL_requires_max_ ( APC_LEVEL  )

Definition at line 197 of file cddata.c.

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

◆ _Ret_range_()

__inline _Ret_range_ ( ,
MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS   
)

◆ C_ASSERT()

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

◆ CountOfSetBitsUChar()

__inline ULONG CountOfSetBitsUChar ( UCHAR  _X)

Definition at line 1500 of file cdrom.h.

1501  { ULONG i = 0; while (_X) { _X &= _X - 1; i++; } return i; }
#define _X(x)
Definition: CString.cpp:149
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
unsigned int ULONG
Definition: retypes.h:1

Referenced by ClasspInitializeGesn(), and ClasspInterpretGesnData().

◆ CountOfSetBitsULong()

__inline ULONG CountOfSetBitsULong ( ULONG  _X)

Definition at line 1502 of file cdrom.h.

1503  { ULONG i = 0; while (_X) { _X &= _X - 1; i++; } return i; }
#define _X(x)
Definition: CString.cpp:149
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
unsigned int ULONG
Definition: retypes.h:1

◆ CountOfSetBitsULong32()

__inline ULONG CountOfSetBitsULong32 ( ULONG32  _X)

Definition at line 1504 of file cdrom.h.

1505  { ULONG i = 0; while (_X) { _X &= _X - 1; i++; } return i; }
#define _X(x)
Definition: CString.cpp:149
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
unsigned int ULONG
Definition: retypes.h:1

◆ CountOfSetBitsULong64()

__inline ULONG CountOfSetBitsULong64 ( ULONG64  _X)

Definition at line 1506 of file cdrom.h.

1507  { ULONG i = 0; while (_X) { _X &= _X - 1; i++; } return i; }
#define _X(x)
Definition: CString.cpp:149
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
unsigned int ULONG
Definition: retypes.h:1

◆ CountOfSetBitsUlongPtr()

__inline ULONG CountOfSetBitsUlongPtr ( ULONG_PTR  _X)

Definition at line 1508 of file cdrom.h.

1509  { ULONG i = 0; while (_X) { _X &= _X - 1; i++; } return i; }
#define _X(x)
Definition: CString.cpp:149
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
unsigned int ULONG
Definition: retypes.h:1

◆ DeviceErrorHandlerForHitachiGD2000()

NTSTATUS DeviceErrorHandlerForHitachiGD2000 ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ PSCSI_REQUEST_BLOCK  Srb,
_Inout_ PNTSTATUS  Status,
_Inout_ PBOOLEAN  Retry 
)

Definition at line 361 of file sense.c.

394 {
395  PSENSE_DATA senseBuffer = Srb->SenseInfoBuffer;
396 
397  if (!TEST_FLAG(Srb->SrbStatus, SRB_STATUS_AUTOSENSE_VALID))
398  {
399  return STATUS_SUCCESS; //nobody cares about this return value yet.
400  }
401 
402  if (((senseBuffer->SenseKey & 0xf) == SCSI_SENSE_HARDWARE_ERROR) &&
403  (senseBuffer->AdditionalSenseCode == 0x44))
404  {
405  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_GENERAL,
406  "DeviceErrorHandlerForHitachiGD2000 (%p) => Internal Target "
407  "Failure Detected -- spinning up drive\n", DeviceExtension->Device));
408 
409  // the request should be retried because the device isn't ready
410  *Retry = TRUE;
412 
413  // send a START_STOP unit to spin up the drive
414  // NOTE: this temporarily violates the StartIo serialization
415  // mechanism, but the completion routine on this will NOT
416  // call StartNextPacket(), so it's a temporary disruption
417  // of the serialization only.
418  DeviceSendStartUnit(DeviceExtension->Device);
419  }
420 
421  return STATUS_SUCCESS;
422 }
UCHAR SenseKey
Definition: cdrw_hw.h:1167
#define SRB_STATUS_AUTOSENSE_VALID
Definition: srb.h:379
#define TRUE
Definition: types.h:120
IN PSCSI_REQUEST_BLOCK IN OUT NTSTATUS IN OUT BOOLEAN * Retry
Definition: class2.h:49
VOID DeviceSendStartUnit(_In_ WDFDEVICE Device)
Definition: common.c:877
#define TEST_FLAG(Flags, Bit)
Definition: cdrom.h:1495
Status
Definition: gdiplustypes.h:24
#define SCSI_SENSE_HARDWARE_ERROR
Definition: cdrw_hw.h:1191
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define STATUS_SUCCESS
Definition: shellext.h:65
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
UCHAR AdditionalSenseCode
Definition: cdrw_hw.h:1175
#define STATUS_DEVICE_NOT_READY
Definition: shellext.h:70

◆ DeviceErrorHandlerForMmc()

NTSTATUS DeviceErrorHandlerForMmc ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ PSCSI_REQUEST_BLOCK  Srb,
_Inout_ PNTSTATUS  Status,
_Inout_ PBOOLEAN  Retry 
)

Definition at line 87 of file sense.c.

117 {
118  BOOLEAN mediaChange = FALSE;
119  PCDB cdb = (PCDB)Srb->Cdb;
120 
122  {
123  PSENSE_DATA senseBuffer = Srb->SenseInfoBuffer;
124 
125  // the following sense keys could indicate a change in capabilities.
126 
127  // we used to expect this to be serialized, and only hit from our
128  // own routine. we now allow some requests to continue during our
129  // processing of the capabilities update in order to allow
130  // IoReadPartitionTable() to succeed.
131  switch (senseBuffer->SenseKey & 0xf)
132  {
133 
134  case SCSI_SENSE_NOT_READY:
135  {
137  {
138  if (DeviceExtension->DeviceAdditionalData.Mmc.WriteAllowed)
139  {
140  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_GENERAL,
141  "DeviceErrorHandlerForMmc: media removed, writes will be "
142  "failed until new media detected\n"));
143  }
144 
145  // NOTE - REF #0002
146  DeviceExtension->DeviceAdditionalData.Mmc.WriteAllowed = FALSE;
147  }
148  else if (senseBuffer->AdditionalSenseCode == SCSI_ADSENSE_LUN_NOT_READY)
149  {
151  {
152  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_GENERAL,
153  "DeviceErrorHandlerForMmc: media becoming ready, "
154  "SHOULD notify shell of change time by sending "
155  "GESN request immediately!\n"));
156  }
159  ) &&
160  ((Srb->Cdb[0] == SCSIOP_READ) ||
161  (Srb->Cdb[0] == SCSIOP_READ6) ||
162  (Srb->Cdb[0] == SCSIOP_READ_CAPACITY) ||
163  (Srb->Cdb[0] == SCSIOP_READ_CD) ||
164  (Srb->Cdb[0] == SCSIOP_READ_CD_MSF) ||
165  (Srb->Cdb[0] == SCSIOP_READ_TOC) ||
166  (Srb->Cdb[0] == SCSIOP_WRITE) ||
167  (Srb->Cdb[0] == SCSIOP_WRITE6) ||
168  (Srb->Cdb[0] == SCSIOP_READ_TRACK_INFORMATION) ||
169  (Srb->Cdb[0] == SCSIOP_READ_DISK_INFORMATION)
170  )
171  )
172  {
173  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_GENERAL,
174  "DeviceErrorHandlerForMmc: LONG_WRITE or "
175  "OP_IN_PROGRESS for limited subset of cmds -- "
176  "setting retry to TRUE\n"));
177  *Retry = TRUE;
179  }
180  }
181  break;
182  } // end SCSI_SENSE_NOT_READY
183 
185  {
186  switch (senseBuffer->AdditionalSenseCode)
187  {
189  {
190  // always update if the medium may have changed
191 
192  // NOTE - REF #0002
193  DeviceExtension->DeviceAdditionalData.Mmc.WriteAllowed = FALSE;
194  DeviceExtension->DeviceAdditionalData.Mmc.UpdateState = CdromMmcUpdateRequired;
195 
196  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_GENERAL,
197  "DeviceErrorHandlerForMmc: media change detected, need to "
198  "update drive capabilities\n"));
199  mediaChange = TRUE;
200  break;
201 
202  } // end SCSI_ADSENSE_MEDIUM_CHANGED
203 
205  {
206  // NOTE - REF #0002
207  DeviceExtension->DeviceAdditionalData.Mmc.WriteAllowed = FALSE;
208  DeviceExtension->DeviceAdditionalData.Mmc.UpdateState = CdromMmcUpdateRequired;
209 
210  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_GENERAL,
211  "DeviceErrorHandlerForMmc: bus reset detected, need to "
212  "update drive capabilities\n"));
213  break;
214 
215  } // end SCSI_ADSENSE_BUS_RESET
216 
218  {
219 
220  BOOLEAN b = FALSE;
221 
222  switch (senseBuffer->AdditionalSenseCodeQualifier)
223  {
225  {
226  // eject notification currently handled by classpnp
227  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_GENERAL,
228  "DeviceErrorHandlerForMmc: Eject requested by user\n"));
229  *Retry = TRUE;
231  break;
232  }
233 
235  b = TRUE;
237  {
238  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_GENERAL,
239  "DeviceErrorHandlerForMmc: Write protect %s requested "
240  "by user\n",
241  (b ? "disable" : "enable")));
242  *Retry = TRUE;
244  // NOTE - REF #0002
245  DeviceExtension->DeviceAdditionalData.Mmc.WriteAllowed = FALSE;
246  DeviceExtension->DeviceAdditionalData.Mmc.UpdateState = CdromMmcUpdateRequired;
247 
248  break;
249  }
250 
251  } // end of AdditionalSenseCodeQualifier switch
252 
253 
254  break;
255 
256  } // end SCSI_ADSENSE_OPERATOR_REQUEST
257 
258  default:
259  {
260  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_GENERAL,
261  "DeviceErrorHandlerForMmc: Unit attention %02x/%02x\n",
262  senseBuffer->AdditionalSenseCode,
263  senseBuffer->AdditionalSenseCodeQualifier));
264  break;
265  }
266 
267  } // end of AdditionSenseCode switch
268  break;
269 
270  } // end SCSI_SENSE_UNIT_ATTENTION
271 
273  {
274  if (senseBuffer->AdditionalSenseCode == SCSI_ADSENSE_WRITE_PROTECT)
275  {
276  if (DeviceExtension->DeviceAdditionalData.Mmc.WriteAllowed)
277  {
278  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_GENERAL,
279  "DeviceErrorHandlerForMmc: media was writable, but "
280  "failed request with WRITE_PROTECT error...\n"));
281  }
282  // NOTE - REF #0002
283  // do not update all the capabilities just because
284  // we can't write to the disc.
285  DeviceExtension->DeviceAdditionalData.Mmc.WriteAllowed = FALSE;
286  }
287  break;
288  } // end SCSI_SENSE_ILLEGAL_REQUEST
289 
290  } // end of SenseKey switch
291 
292  // Check if we failed to set the DVD region key and send appropriate error
293  if (cdb->CDB16.OperationCode == SCSIOP_SEND_KEY)
294  {
295  if (cdb->SEND_KEY.KeyFormat == DvdSetRpcKey)
296  {
298  {
299  // media of appropriate region required
301  *Retry = FALSE;
302  }
303  else if ((senseBuffer->SenseKey == SCSI_SENSE_ILLEGAL_REQUEST) &&
306  {
307  // media of appropriate region required
309  *Retry = FALSE;
310  }
311  else if ((senseBuffer->SenseKey == SCSI_SENSE_ILLEGAL_REQUEST) &&
314  {
315  // media of appropriate region required
317  *Retry = FALSE;
318  }
319  }
320  }
321  } // end of SRB_STATUS_AUTOSENSE_VALID
322 
323  // On media change, if device speed should be reset to default then
324  // queue a workitem to send the commands to the device. Do this on
325  // media arrival as some device will fail this command if no media
326  // is present. Ignore the fake media change from classpnp driver.
327  if ((mediaChange == TRUE) && (*Status != STATUS_MEDIA_CHANGED))
328  {
329  if (DeviceExtension->DeviceAdditionalData.RestoreDefaults == TRUE)
330  {
332  WDF_OBJECT_ATTRIBUTES attributes;
333  WDF_WORKITEM_CONFIG workitemConfig;
334  WDFWORKITEM workItem;
335 
336  WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
337  attributes.ParentObject = DeviceExtension->Device;
338 
339  WDF_WORKITEM_CONFIG_INIT(&workitemConfig,
341 
342  status = WdfWorkItemCreate(&workitemConfig,
343  &attributes,
344  &workItem);
345  if (!NT_SUCCESS(status))
346  {
347  return STATUS_SUCCESS;
348  }
349 
350  WdfWorkItemEnqueue(workItem);
351 
352  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_GENERAL,
353  "DeviceErrorHandlerForMmc: Restore device default speed for %p\n",
354  DeviceExtension->DeviceObject));
355  }
356  }
357  return STATUS_SUCCESS;
358 }
#define SCSIOP_READ_TOC
Definition: cdrw_hw.h:927
#define SCSI_ADSENSE_WRITE_PROTECT
Definition: cdrw_hw.h:1268
UCHAR SenseKey
Definition: cdrw_hw.h:1167
#define STATUS_NO_MEDIA_IN_DEVICE
Definition: udferr_usr.h:141
FORCEINLINE VOID WDF_WORKITEM_CONFIG_INIT(_Out_ PWDF_WORKITEM_CONFIG Config, _In_ PFN_WDF_WORKITEM EvtWorkItemFunc)
Definition: wdfworkitem.h:85
#define SCSI_SENSEQ_INCOMPATIBLE_FORMAT
Definition: cdrw_hw.h:1323
#define SCSI_SENSEQ_MEDIUM_REMOVAL
Definition: scsi.h:879
#define SRB_STATUS_AUTOSENSE_VALID
Definition: srb.h:379
#define TRUE
Definition: types.h:120
#define SCSI_ADSENSE_COPY_PROTECTION_FAILURE
Definition: scsi.h:694
Definition: cdrw_hw.h:28
LONG NTSTATUS
Definition: precomp.h:26
#define SCSIOP_SEND_KEY
Definition: cdrw_hw.h:951
#define SCSI_ADSENSE_LUN_NOT_READY
Definition: cdrw_hw.h:1218
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
#define SCSI_SENSE_NOT_READY
Definition: cdrw_hw.h:1189
struct _CDB::_CDB16 CDB16
struct _CDB::_SEND_KEY SEND_KEY
#define SCSI_ADSENSE_OPERATOR_REQUEST
Definition: scsi.h:691
#define STATUS_MEDIA_CHANGED
Definition: ntstatus.h:207
#define FALSE
Definition: types.h:117
#define SCSIOP_READ_CD_MSF
Definition: cdrw_hw.h:964
#define SCSIOP_READ
Definition: cdrw_hw.h:905
#define SCSIOP_READ6
Definition: cdrw_hw.h:874
#define SCSI_ADSENSE_NO_MEDIA_IN_DEVICE
Definition: cdrw_hw.h:1221
#define SCSIOP_WRITE
Definition: cdrw_hw.h:906
unsigned char BOOLEAN
union _CDB * PCDB
IN PSCSI_REQUEST_BLOCK IN OUT NTSTATUS IN OUT BOOLEAN * Retry
Definition: class2.h:49
#define SCSI_SENSEQ_MEDIA_CODE_MISMATCHED_TO_LOGICAL_UNIT
Definition: cdrw_hw.h:1394
#define TEST_FLAG(Flags, Bit)
Definition: cdrom.h:1495
UCHAR AdditionalSenseCodeQualifier
Definition: cdrw_hw.h:1176
Status
Definition: gdiplustypes.h:24
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define SCSI_SENSEQ_LONG_WRITE_IN_PROGRESS
Definition: cdrw_hw.h:1318
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define SCSI_SENSEQ_BECOMING_READY
Definition: cdrw_hw.h:1313
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SCSIOP_READ_TRACK_INFORMATION
Definition: scsi.h:315
#define SCSI_ADSENSE_INVALID_MEDIA
Definition: cdrw_hw.h:1220
#define SCSI_SENSEQ_OPERATION_IN_PROGRESS
Definition: cdrw_hw.h:1317
#define SCSIOP_READ_DISK_INFORMATION
Definition: scsi.h:313
#define SCSI_ADSENSE_BUS_RESET
Definition: cdrw_hw.h:1289
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
FORCEINLINE VOID WDF_OBJECT_ATTRIBUTES_INIT(_Out_ PWDF_OBJECT_ATTRIBUTES Attributes)
Definition: wdfobject.h:147
#define STATUS_DEVICE_BUSY
Definition: udferr_usr.h:129
WDFOBJECT ParentObject
Definition: wdfobject.h:130
#define SCSIOP_READ_CAPACITY
Definition: cdrw_hw.h:904
#define CdromMmcUpdateRequired
Definition: cdrom.h:242
#define SCSI_SENSEQ_WRITE_PROTECT_ENABLE
Definition: scsi.h:880
#define SCSIOP_READ_CD
Definition: cdrw_hw.h:967
#define STATUS_SUCCESS
Definition: shellext.h:65
EVT_WDF_WORKITEM DeviceRestoreDefaultSpeed
Definition: cdrom.h:1180
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
UCHAR AdditionalSenseCode
Definition: cdrw_hw.h:1175
#define SCSI_SENSE_ILLEGAL_REQUEST
Definition: cdrw_hw.h:1192
#define SCSI_SENSEQ_WRITE_PROTECT_DISABLE
Definition: scsi.h:881
#define SCSI_SENSE_UNIT_ATTENTION
Definition: cdrw_hw.h:1193
#define SCSIOP_WRITE6
Definition: cdrw_hw.h:876
#define SCSI_ADSENSE_MEDIUM_CHANGED
Definition: cdrw_hw.h:1288
#define STATUS_CSS_REGION_MISMATCH
Definition: ntstatus.h:886
Definition: ps.c:97

◆ DeviceIsMmcUpdateRequired()

BOOLEAN DeviceIsMmcUpdateRequired ( _In_ WDFDEVICE  Device)

Definition at line 4180 of file cdrom.c.

4197 {
4198  PCDROM_DEVICE_EXTENSION deviceExtension = DeviceGetExtension(Device);
4199  PCDROM_DATA cdData = &(deviceExtension->DeviceAdditionalData);
4200 
4201  if ((cdData->Mmc.IsMmc) &&
4202  (cdData->Mmc.UpdateState == CdromMmcUpdateRequired))
4203  {
4204  return TRUE;
4205  }
4206  else
4207  {
4208  // no update required: just proceed
4209  return FALSE;
4210  }
4211 }
#define TRUE
Definition: types.h:120
CDROM_DATA DeviceAdditionalData
Definition: cdrom.h:598
#define FALSE
Definition: types.h:117
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define CdromMmcUpdateRequired
Definition: cdrom.h:242
CDROM_MMC_EXTENSION Mmc
Definition: cdrom.h:341

Referenced by IoctlWorkItemRoutine(), ReadWriteWorkItemRoutine(), and SequentialQueueEvtIoReadWrite().

◆ DevicePerfIncrementErrorCount()

VOID DevicePerfIncrementErrorCount ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension)

Definition at line 1378 of file common.c.

1381 {
1382  PCDROM_PRIVATE_FDO_DATA fdoData = DeviceExtension->PrivateFdoData;
1383  KIRQL oldIrql;
1384  ULONG errors;
1385 
1386  KeAcquireSpinLock(&fdoData->SpinLock, &oldIrql);
1387 
1388  fdoData->Perf.SuccessfulIO = 0; // implicit interlock
1389  errors = InterlockedIncrement((PLONG)&DeviceExtension->ErrorCount);
1390 
1391  if (errors >= CLASS_ERROR_LEVEL_1)
1392  {
1393  // If the error count has exceeded the error limit, then disable
1394  // any tagged queuing, multiple requests per lu queueing
1395  // and sychronous data transfers.
1396  //
1397  // Clearing the no queue freeze flag prevents the port driver
1398  // from sending multiple requests per logical unit.
1399  CLEAR_FLAG(DeviceExtension->SrbFlags, SRB_FLAGS_NO_QUEUE_FREEZE);
1400  CLEAR_FLAG(DeviceExtension->SrbFlags, SRB_FLAGS_QUEUE_ACTION_ENABLE);
1401 
1402  SET_FLAG(DeviceExtension->SrbFlags, SRB_FLAGS_DISABLE_SYNCH_TRANSFER);
1403 
1404  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_GENERAL,
1405  "PerfIncrementErrorCount: Too many errors; disabling tagged queuing and "
1406  "synchronous data tranfers.\n"));
1407  }
1408 
1409  if (errors >= CLASS_ERROR_LEVEL_2)
1410  {
1411  // If a second threshold is reached, disable disconnects.
1412  SET_FLAG(DeviceExtension->SrbFlags, SRB_FLAGS_DISABLE_DISCONNECT);
1413  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_GENERAL,
1414  "PerfIncrementErrorCount: Too many errors; disabling disconnects.\n"));
1415  }
1416 
1417  KeReleaseSpinLock(&fdoData->SpinLock, oldIrql);
1418  return;
1419 }
#define CLASS_ERROR_LEVEL_1
Definition: cdromp.h:130
#define SRB_FLAGS_NO_QUEUE_FREEZE
Definition: srb.h:396
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define CLEAR_FLAG(Flags, Bit)
Definition: cdrom.h:1494
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define SRB_FLAGS_DISABLE_SYNCH_TRANSFER
Definition: srb.h:389
#define SRB_FLAGS_DISABLE_DISCONNECT
Definition: srb.h:388
KSPIN_LOCK SpinLock
Definition: cdromp.h:351
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define InterlockedIncrement
Definition: armddk.h:53
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
struct _CDROM_PRIVATE_FDO_DATA::@1029 Perf
unsigned int ULONG
Definition: retypes.h:1
signed int * PLONG
Definition: retypes.h:5
#define CLASS_ERROR_LEVEL_2
Definition: cdromp.h:131
#define SET_FLAG(Flags, Bit)
Definition: cdrom.h:1493
#define SRB_FLAGS_QUEUE_ACTION_ENABLE
Definition: srb.h:387

Referenced by SenseInfoInterpretBySrbStatus().

◆ DeviceReleaseQueue()

VOID DeviceReleaseQueue ( _In_ WDFDEVICE  Device)

Definition at line 1179 of file common.c.

1203 {
1204  PCDROM_DEVICE_EXTENSION deviceExtension = DeviceGetExtension(Device);
1205  PSCSI_REQUEST_BLOCK srb = NULL;
1206  KIRQL currentIrql;
1207 
1208  // we raise irql seperately so we're not swapped out or suspended
1209  // while holding the release queue irp in this routine. this lets
1210  // us release the spin lock before lowering irql.
1211  KeRaiseIrql(DISPATCH_LEVEL, &currentIrql);
1212 
1213  WdfSpinLockAcquire(deviceExtension->ReleaseQueueSpinLock);
1214 
1215  if (deviceExtension->ReleaseQueueInProgress)
1216  {
1217  // Someone is already doing this work - just set the flag to indicate that
1218  // we need to release the queue again.
1219  deviceExtension->ReleaseQueueNeeded = TRUE;
1220  WdfSpinLockRelease(deviceExtension->ReleaseQueueSpinLock);
1221  KeLowerIrql(currentIrql);
1222 
1223  return;
1224  }
1225 
1226  // Mark that there is a release queue in progress and drop the spinlock.
1227  deviceExtension->ReleaseQueueInProgress = TRUE;
1228 
1229  WdfSpinLockRelease(deviceExtension->ReleaseQueueSpinLock);
1230 
1231  srb = &(deviceExtension->ReleaseQueueSrb);
1232 
1233  // Optical media are removable, so we just flush the queue. This will also release it.
1235 
1236  srb->OriginalRequest = WdfRequestWdmGetIrp(deviceExtension->ReleaseQueueRequest);
1237 
1238  // Set a CompletionRoutine callback function.
1239  WdfRequestSetCompletionRoutine(deviceExtension->ReleaseQueueRequest,
1241  Device);
1242  // Send the request. If an error occurs, complete the request.
1243  RequestSend(deviceExtension,
1244  deviceExtension->ReleaseQueueRequest,
1245  deviceExtension->IoTarget,
1247  NULL);
1248 
1249  KeLowerIrql(currentIrql);
1250 
1251  return;
1252 
1253 } // end DeviceReleaseQueue()
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
BOOLEAN ReleaseQueueInProgress
Definition: cdrom.h:581
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
PVOID OriginalRequest
Definition: srb.h:258
#define TRUE
Definition: types.h:120
WDFIOTARGET IoTarget
Definition: cdrom.h:476
#define SRB_FUNCTION_FLUSH_QUEUE
Definition: srb.h:321
UCHAR KIRQL
Definition: env_spec_w32.h:591
WDFREQUEST ReleaseQueueRequest
Definition: cdrom.h:577
VOID NTAPI DeviceReleaseQueueCompletion(_In_ WDFREQUEST Request, _In_ WDFIOTARGET Target, _In_ PWDF_REQUEST_COMPLETION_PARAMS Params, _In_ WDFCONTEXT Context)
Definition: common.c:1257
UCHAR Function
Definition: srb.h:242
NTSTATUS RequestSend(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDFIOTARGET IoTarget, _In_ ULONG Flags, _Out_opt_ PBOOLEAN RequestSent)
Definition: common.c:3793
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
WDFSPINLOCK ReleaseQueueSpinLock
Definition: cdrom.h:576
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
BOOLEAN ReleaseQueueNeeded
Definition: cdrom.h:580
#define NULL
Definition: types.h:112
SCSI_REQUEST_BLOCK ReleaseQueueSrb
Definition: cdrom.h:578

Referenced by DeviceAsynchronousCompletion(), DeviceReleaseQueueCompletion(), and RequestSenseInfoInterpret().

◆ DeviceSendIoctlAsynchronously()

VOID DeviceSendIoctlAsynchronously ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ ULONG  IoControlCode,
_In_ PDEVICE_OBJECT  TargetDeviceObject 
)

Definition at line 1030 of file common.c.

1052 {
1053  PIRP irp = NULL;
1054  PIO_STACK_LOCATION nextIrpStack = NULL;
1055 
1056  irp = IoAllocateIrp(DeviceExtension->DeviceObject->StackSize, FALSE);
1057 
1058  if (irp != NULL)
1059  {
1060  nextIrpStack = IoGetNextIrpStackLocation(irp);
1061 
1062  nextIrpStack->MajorFunction = IRP_MJ_DEVICE_CONTROL;
1063 
1064  nextIrpStack->Parameters.DeviceIoControl.OutputBufferLength = 0;
1065  nextIrpStack->Parameters.DeviceIoControl.InputBufferLength = 0;
1066  nextIrpStack->Parameters.DeviceIoControl.IoControlCode = IoControlCode;
1067  nextIrpStack->Parameters.DeviceIoControl.Type3InputBuffer = NULL;
1068 
1071  DeviceExtension,
1072  TRUE,
1073  TRUE,
1074  TRUE);
1075 
1077  }
1078 }
#define TRUE
Definition: types.h:120
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:498
NTSTATUS NTAPI RequestAsynchronousIrpCompletion(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_reads_opt_(_Inexpressible_("varies")) PVOID Context)
Definition: common.c:1082
#define FALSE
Definition: types.h:117
#define VOID
Definition: acefi.h:82
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:318
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2691
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
IN OUT PVCB IN PDEVICE_OBJECT TargetDeviceObject
Definition: fatprocs.h:1673
FxIrp * irp
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52

Referenced by DeviceEvtD0Entry().

◆ DeviceSendNotification()

VOID DeviceSendNotification ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ const GUID Guid,
_In_ ULONG  ExtraDataSize,
_In_opt_ PVOID  ExtraData 
)

Definition at line 799 of file common.c.

824 {
826  ULONG requiredSize;
828 
829  status = RtlULongAdd((sizeof(TARGET_DEVICE_CUSTOM_NOTIFICATION) - sizeof(UCHAR)),
831  &requiredSize);
832 
833  if (!(NT_SUCCESS(status)) || (requiredSize > 0x0000ffff))
834  {
835  // MAX_USHORT, max total size for these events!
836  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_MCN,
837  "Error sending event: size too large! (%x)\n",
838  requiredSize));
839  return;
840  }
841 
842  notification = ExAllocatePoolWithTag(NonPagedPoolNx,
843  requiredSize,
845 
846  // if none allocated, exit
847  if (notification == NULL)
848  {
849  return;
850  }
851 
852  // Prepare and send the request!
853  RtlZeroMemory(notification, requiredSize);
854  notification->Version = 1;
855  notification->Size = (USHORT)(requiredSize);
856  notification->FileObject = NULL;
857  notification->NameBufferOffset = -1;
858  notification->Event = *Guid;
859 
860  if (ExtraData != NULL)
861  {
862  RtlCopyMemory(notification->CustomDataBuffer, ExtraData, ExtraDataSize);
863  }
864 
865  IoReportTargetDeviceChangeAsynchronous(DeviceExtension->LowerPdo,
866  notification,
867  NULL,
868  NULL);
869 
871 
872  return;
873 }
_In_ const GUID _In_ ULONG ExtraDataSize
Definition: classpnp.h:1429
LONG NTSTATUS
Definition: precomp.h:26
#define FREE_POOL(_PoolPtr)
Definition: cdrom.h:782
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:760
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
unsigned char UCHAR
Definition: xmlstorage.h:181
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
unsigned short USHORT
Definition: pedump.c:61
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define CDROM_TAG_NOTIFICATION
Definition: cdrom.h:739
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
NTSTATUS NTAPI IoReportTargetDeviceChangeAsynchronous(IN PDEVICE_OBJECT PhysicalDeviceObject, IN PVOID NotificationStructure, IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL, IN PVOID Context OPTIONAL)
Definition: pnpreport.c:515
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by DeviceInternalSetMediaChangeState(), SenseInfoInterpretByAdditionalSenseCode(), and SenseInfoInterpretForZPODD().

◆ DeviceSendStartUnit()

VOID DeviceSendStartUnit ( _In_ WDFDEVICE  Device)

Definition at line 877 of file common.c.

907 {
909  PCDROM_DEVICE_EXTENSION deviceExtension = NULL;
910  WDF_OBJECT_ATTRIBUTES attributes;
911  WDFREQUEST startUnitRequest = NULL;
912  WDFMEMORY inputMemory = NULL;
913 
916  PCDB cdb = NULL;
917 
918  deviceExtension = DeviceGetExtension(Device);
919 
920  if (NT_SUCCESS(status))
921  {
922  // Allocate Srb from nonpaged pool.
923  context = ExAllocatePoolWithTag(NonPagedPoolNx,
924  sizeof(COMPLETION_CONTEXT),
926 
927  if (context == NULL)
928  {
929  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_GENERAL,
930  "DeviceSendStartUnit: Failed to allocate completion context\n"));
931 
933  }
934  }
935 
936  if (NT_SUCCESS(status))
937  {
938  // Save the device object in the context for use by the completion
939  // routine.
940  context->Device = Device;
941  srb = &context->Srb;
942 
943  // Zero out srb.
944  RtlZeroMemory(srb, sizeof(SCSI_REQUEST_BLOCK));
945 
946  // setup SRB structure.
947  srb->Length = sizeof(SCSI_REQUEST_BLOCK);
950 
953 
954  // setup CDB
955  srb->CdbLength = 6;
956  cdb = (PCDB)srb->Cdb;
957 
958  cdb->START_STOP.OperationCode = SCSIOP_START_STOP_UNIT;
959  cdb->START_STOP.Start = 1;
960  cdb->START_STOP.Immediate = 0;
961  cdb->START_STOP.LogicalUnitNumber = srb->Lun;
962 
963  //Create Request for sending down to port driver
966  attributes.ParentObject = deviceExtension->IoTarget;
967 
968  status = WdfRequestCreate(&attributes,
969  deviceExtension->IoTarget,
970  &startUnitRequest);
971  }
972 
973  if (NT_SUCCESS(status))
974  {
975  srb->OriginalRequest = WdfRequestWdmGetIrp(startUnitRequest);
976  NT_ASSERT(srb->OriginalRequest != NULL);
977 
978  //Prepare the request
979  WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
980  attributes.ParentObject = startUnitRequest;
981 
982  status = WdfMemoryCreatePreallocated(&attributes,
983  (PVOID)srb,
984  sizeof(SCSI_REQUEST_BLOCK),
985  &inputMemory);
986  }
987 
988  if (NT_SUCCESS(status))
989  {
990  status = WdfIoTargetFormatRequestForInternalIoctlOthers(deviceExtension->IoTarget,
991  startUnitRequest,
993  inputMemory,
994  NULL,
995  NULL,
996  NULL,
997  NULL,
998  NULL);
999  }
1000 
1001  if (NT_SUCCESS(status))
1002  {
1003  // Set a CompletionRoutine callback function.
1004  WdfRequestSetCompletionRoutine(startUnitRequest,
1006  context);
1007 
1008  status = RequestSend(deviceExtension,
1009  startUnitRequest,
1010  deviceExtension->IoTarget,
1011  0,
1012  NULL);
1013  }
1014 
1015  // release resources when failed.
1016  if (!NT_SUCCESS(status))
1017  {
1018  FREE_POOL(context);
1019  if (startUnitRequest != NULL)
1020  {
1021  WdfObjectDelete(startUnitRequest);
1022  }
1023  }
1024 
1025  return;
1026 } // end StartUnit()
ULONG SrbFlags
Definition: srb.h:252
PVOID OriginalRequest
Definition: srb.h:258
UCHAR Cdb[16]
Definition: srb.h:271
Definition: http.c:7094
WDFIOTARGET IoTarget
Definition: cdrom.h:476
Definition: cdrw_hw.h:28
LONG NTSTATUS
Definition: precomp.h:26
UCHAR CdbLength
Definition: srb.h:250
ULONG TimeOutValue
Definition: srb.h:254
#define WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(_attributes, _contexttype)
Definition: wdfobject.h:170
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
#define FREE_POOL(_PoolPtr)
Definition: cdrom.h:782
union _CDB * PCDB
struct _CDB::_START_STOP START_STOP
#define CDROM_TAG_COMPLETION_CONTEXT
Definition: cdrom.h:729
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
UCHAR Function
Definition: srb.h:242
#define SRB_FLAGS_DISABLE_SYNCH_TRANSFER
Definition: srb.h:389
USHORT Length
Definition: srb.h:241
struct _SCSI_REQUEST_BLOCK SCSI_REQUEST_BLOCK
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define SRB_FLAGS_NO_DATA_TRANSFER
Definition: srb.h:394
NTSTATUS RequestSend(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDFIOTARGET IoTarget, _In_ ULONG Flags, _Out_opt_ PBOOLEAN RequestSent)
Definition: common.c:3793
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define IOCTL_SCSI_EXECUTE_NONE
Definition: cdrw_hw.h:1453
FORCEINLINE VOID WDF_OBJECT_ATTRIBUTES_INIT(_Out_ PWDF_OBJECT_ATTRIBUTES Attributes)
Definition: wdfobject.h:147
VOID NTAPI DeviceAsynchronousCompletion(_In_ WDFREQUEST Request, _In_ WDFIOTARGET Target, _In_ PWDF_REQUEST_COMPLETION_PARAMS Params, _In_ WDFCONTEXT Context)
Definition: common.c:1116
WDFOBJECT ParentObject
Definition: wdfobject.h:130
#define NULL
Definition: types.h:112
#define START_UNIT_TIMEOUT
Definition: cdrom.h:132
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:307
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
#define SCSIOP_START_STOP_UNIT
Definition: cdrw_hw.h:897
#define NT_ASSERT
Definition: rtlfuncs.h:3312
Definition: ps.c:97

Referenced by DeviceErrorHandlerForHitachiGD2000(), and SenseInfoInterpretByAdditionalSenseCode().

◆ DeviceSetMediaChangeStateEx()

VOID DeviceSetMediaChangeStateEx ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ MEDIA_CHANGE_DETECTION_STATE  NewState,
_Inout_opt_ PMEDIA_CHANGE_DETECTION_STATE  OldState 
)

Definition at line 751 of file autorun.c.

778 {
779  PMEDIA_CHANGE_DETECTION_INFO info = DeviceExtension->MediaChangeDetectionInfo;
782 
783  // timeout value must be 0, as this function can be called at DISPATCH_LEVEL.
784  zero.QuadPart = 0;
785 
786  if (info == NULL)
787  {
788  return;
789  }
790 
791  status = KeWaitForMutexObject(&info->MediaChangeMutex,
792  Executive,
793  KernelMode,
794  FALSE,
795  &zero);
796 
797  if (status == STATUS_TIMEOUT)
798  {
799  // Someone else is in the process of setting the media state.
800  return;
801  }
802 
803  // Change the media present state and signal an event, if applicable
804  DeviceInternalSetMediaChangeState(DeviceExtension, NewState, OldState);
805 
806  KeReleaseMutex(&info->MediaChangeMutex, FALSE);
807 
808  return;
809 } // end DeviceSetMediaChangeStateEx()
#define KeWaitForMutexObject
Definition: kefuncs.h:555
LONG NTSTATUS
Definition: precomp.h:26
LONG NTAPI KeReleaseMutex(IN PKMUTEX Mutex, IN BOOLEAN Wait)
Definition: mutex.c:189
VOID DeviceInternalSetMediaChangeState(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ MEDIA_CHANGE_DETECTION_STATE NewState, _Inout_opt_ PMEDIA_CHANGE_DETECTION_STATE OldState)
Definition: autorun.c:630
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
#define FALSE
Definition: types.h:117
int zero
Definition: sehframes.cpp:29
#define NULL
Definition: types.h:112
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by DeviceEvtSelfManagedIoInit(), and SenseInfoInterpretByAdditionalSenseCode().

◆ DeviceZPODDGetPowerupReason()

NTSTATUS DeviceZPODDGetPowerupReason ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_Out_ PSTORAGE_IDLE_POWERUP_REASON  PowerupReason 
)

Definition at line 608 of file zpodd.c.

627 {
629  PIRP irp = NULL;
630  IO_STATUS_BLOCK ioStatus = {0};
631  KEVENT event;
632 
633  RtlZeroMemory(PowerupReason, sizeof (STORAGE_IDLE_POWERUP_REASON));
634 
635  PowerupReason->Size = sizeof (STORAGE_IDLE_POWERUP_REASON);
636  PowerupReason->Version = STORAGE_IDLE_POWERUP_REASON_VERSION_V1;
637 
638  //
639  // Setup a synchronous irp.
640  //
641 
643 
645  DeviceExtension->LowerPdo,
646  PowerupReason,
648  PowerupReason,
650  FALSE,
651  &event,
652  &ioStatus);
653 
654  if (irp == NULL)
655  {
657  }
658  else
659  {
660  //
661  // Send the synchronous request to port driver.
662  //
663 
664  status = IoCallDriver(DeviceExtension->LowerPdo, irp);
665 
666  if (status == STATUS_PENDING)
667  {
669 
670  status = ioStatus.Status;
671  }
672  }
673 
674  return status;
675 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define FALSE
Definition: types.h:117
struct _STORAGE_IDLE_POWERUP_REASON STORAGE_IDLE_POWERUP_REASON
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STORAGE_IDLE_POWERUP_REASON_VERSION_V1
Definition: ntddstor.h:1105
struct _cl_event * event
Definition: glext.h:7739
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IOCTL_STORAGE_GET_IDLE_POWERUP_REASON
Definition: ntddstor.h:217
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
FxIrp * irp
Definition: ps.c:97

Referenced by DeviceEvtD0Entry().

◆ FREE_PORT_ALLOCATED_SENSE_BUFFER()

__inline VOID FREE_PORT_ALLOCATED_SENSE_BUFFER ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 839 of file cdrom.h.

843 {
844 #ifndef DEBUG
845  UNREFERENCED_PARAMETER(DeviceExtension);
846 #endif
849  NT_ASSERT(Srb->SenseInfoBuffer != DeviceExtension->SenseData);
850 
851  ExFreePool(Srb->SenseInfoBuffer);
852  Srb->SenseInfoBuffer = NULL;
853  Srb->SenseInfoBufferLength = 0;
855  return;
856 }
#define SRB_FLAGS_FREE_SENSE_BUFFER
Definition: srb.h:398
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define CLEAR_FLAG(Flags, Bit)
Definition: cdrom.h:1494
#define TEST_FLAG(Flags, Bit)
Definition: cdrom.h:1495
#define SRB_FLAGS_PORT_DRIVER_ALLOCSENSE
Definition: srb.h:405
#define NULL
Definition: types.h:112
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by ClassAsynchronousCompletion(), ClassIoComplete(), ClassIoCompleteAssociated(), and DeviceAsynchronousCompletion().

◆ IsVolumeMounted()

__inline BOOLEAN IsVolumeMounted ( _In_ PDEVICE_OBJECT  DeviceObject)

Definition at line 1514 of file cdrom.h.

1517 {
1518 #pragma prefast(push)
1519 #pragma prefast(disable: 28175, "there is no other way to check if there is volume mounted")
1520  return (DeviceObject->Vpb != NULL) &&
1521  ((DeviceObject->Vpb->Flags & VPB_MOUNTED) != 0);
1522 #pragma prefast(pop)
1523 }
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define NULL
Definition: types.h:112
#define VPB_MOUNTED
Definition: iotypes.h:1787

Referenced by SenseInfoInterpretByAdditionalSenseCode(), and SenseInfoInterpretBySenseKey().

◆ PORT_ALLOCATED_SENSE()

__inline BOOLEAN PORT_ALLOCATED_SENSE ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 826 of file cdrom.h.

830 {
831  UNREFERENCED_PARAMETER(DeviceExtension);
832  return (BOOLEAN)((TEST_FLAG(Srb->SrbFlags, SRB_FLAGS_PORT_DRIVER_ALLOCSENSE) &&
834  );
835 }
#define SRB_FLAGS_FREE_SENSE_BUFFER
Definition: srb.h:398
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
unsigned char BOOLEAN
#define TEST_FLAG(Flags, Bit)
Definition: cdrom.h:1495
#define SRB_FLAGS_PORT_DRIVER_ALLOCSENSE
Definition: srb.h:405
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49

Referenced by ClassAsynchronousCompletion(), ClassIoComplete(), ClassIoCompleteAssociated(), and DeviceAsynchronousCompletion().

◆ RequestClearSendTime()

VOID RequestClearSendTime ( _In_ WDFREQUEST  Request)

Definition at line 111 of file common.c.

126 {
127  PCDROM_REQUEST_CONTEXT requestContext = RequestGetContext(Request);
128 
129  requestContext->TimeSentDownFirstTime.QuadPart = 0;
130  requestContext->TimeSentDownLasttTime.QuadPart = 0;
131 
132  return;
133 }
LARGE_INTEGER TimeSentDownLasttTime
Definition: cdrom.h:637
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
LARGE_INTEGER TimeSentDownFirstTime
Definition: cdrom.h:636
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by _IRQL_requires_max_(), DeviceReleaseQueueCompletion(), and ScratchBuffer_BeginUseX().

◆ RequestCompletion()

VOID RequestCompletion ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ WDFREQUEST  Request,
_In_ NTSTATUS  Status,
_In_ ULONG_PTR  Information 
)

Definition at line 3439 of file common.c.

3445 {
3446 #ifdef DBG
3447  ULONG ioctlCode = 0;
3448  WDF_REQUEST_PARAMETERS requestParameters;
3449 
3450  // Get the Request parameters
3451  WDF_REQUEST_PARAMETERS_INIT(&requestParameters);
3452  WdfRequestGetParameters(Request, &requestParameters);
3453 
3454  if (requestParameters.Type == WdfRequestTypeDeviceControl)
3455  {
3456  ioctlCode = requestParameters.Parameters.DeviceIoControl.IoControlCode;
3457 
3458  if (requestParameters.Parameters.DeviceIoControl.IoControlCode != IOCTL_MCN_SYNC_FAKE_IOCTL)
3459  {
3460  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_GENERAL,
3461  "Request complete - IOCTL - code: %X; Status: %X; Information: %X\n",
3462  ioctlCode,
3463  Status,
3464  (ULONG)Information));
3465  }
3466  else
3467  {
3468  TracePrint((TRACE_LEVEL_VERBOSE, TRACE_FLAG_GENERAL,
3469  "Request complete - IOCTL - code: %X; Status: %X; Information: %X\n",
3470  ioctlCode,
3471  Status,
3472  (ULONG)Information));
3473  }
3474  }
3475  else if (requestParameters.Type == WdfRequestTypeRead)
3476  {
3477  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_GENERAL,
3478  "Request complete - READ - Starting Offset: %X; Length: %X; Transferred Length: %X; Status: %X\n",
3479  (ULONG)requestParameters.Parameters.Read.DeviceOffset,
3480  (ULONG)requestParameters.Parameters.Read.Length,
3481  (ULONG)Information,
3482  Status));
3483  }
3484  else if (requestParameters.Type == WdfRequestTypeWrite)
3485  {
3486  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_GENERAL,
3487  "Request complete - WRITE - Starting Offset: %X; Length: %X; Transferred Length: %X; Status: %X\n",
3488  (ULONG)requestParameters.Parameters.Write.DeviceOffset,
3489  (ULONG)requestParameters.Parameters.Write.Length,
3490  (ULONG)Information,
3491  Status));
3492  }
3493 #endif
3494 
3496  {
3497  PIRP irp = WdfRequestWdmGetIrp(Request);
3498  if (irp->Tail.Overlay.Thread)
3499  {
3500  IoSetHardErrorOrVerifyDevice(irp, DeviceExtension->DeviceObject);
3501  }
3502  }
3503 
3504  if (!NT_SUCCESS(Status) && DeviceExtension->SurpriseRemoved == TRUE)
3505  {
3506  // IMAPI expects ERROR_DEV_NOT_EXISTS if recorder has been surprised removed,
3507  // or it will retry WRITE commands for up to 3 minutes
3508  // CDROM behavior should be consistent for all requests, including SCSI pass-through
3510  }
3511 
3512  WdfRequestCompleteWithInformation(Request, Status, Information);
3513 
3514  return;
3515 }
#define STATUS_DEVICE_DOES_NOT_EXIST
Definition: ntstatus.h:428
#define TRUE
Definition: types.h:120
#define IoIsErrorUserInduced(Status)
Definition: iofuncs.h:2813
WDF_REQUEST_TYPE Type
Definition: wdfrequest.h:142
struct _WDF_REQUEST_PARAMETERS::@3696::@3700 DeviceIoControl
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
struct _WDF_REQUEST_PARAMETERS::@3696::@3699 Write
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1044
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _WDF_REQUEST_PARAMETERS::@3696::@3698 Read
#define IOCTL_MCN_SYNC_FAKE_IOCTL
Definition: cdrom.h:181
FORCEINLINE VOID WDF_REQUEST_PARAMETERS_INIT(_Out_ PWDF_REQUEST_PARAMETERS Parameters)
Definition: wdfrequest.h:211
union _WDF_REQUEST_PARAMETERS::@3696 Parameters
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI IoSetHardErrorOrVerifyDevice(IN PIRP Irp, IN PDEVICE_OBJECT DeviceObject)
Definition: util.c:316
FxIrp * irp

Referenced by CreateQueueEvtIoDefault(), DeviceEvtIoInCallerContext(), ReadWriteWorkItemRoutine(), RequestDispatchProcessDirectly(), RequestDispatchSpecialIoctls(), RequestDispatchSyncWithSequentialQueue(), RequestDispatchToSequentialQueue(), RequestDispatchUnknownRequests(), RequestHandleQueryPropertyDeviceUniqueId(), RequestHandleQueryPropertyWriteCache(), RequestHandleReadWrite(), RequestProcessInternalDeviceControl(), RequestSynchronizeProcessWithSerialQueue(), ScratchBuffer_ReadWriteCompletionRoutine(), ScratchBuffer_ReadWriteEvtRequestCancel(), ScratchBuffer_ReadWriteTimerRoutine(), SequentialQueueEvtCanceledOnQueue(), SequentialQueueEvtIoDeviceControl(), and SequentialQueueEvtIoReadWrite().

◆ RequestDuidGetDeviceIdProperty()

NTSTATUS RequestDuidGetDeviceIdProperty ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ WDFREQUEST  Request,
_In_ WDF_REQUEST_PARAMETERS  RequestParameters,
_Out_ size_t DataLength 
)

Definition at line 2797 of file common.c.

2821 {
2823  PSTORAGE_DEVICE_ID_DESCRIPTOR deviceIdDescriptor = NULL;
2824  PSTORAGE_DESCRIPTOR_HEADER descHeader = NULL;
2826 
2827  *DataLength = 0;
2828 
2829  // Get the VPD page 83h data.
2830  status = DeviceRetrieveDescriptor(DeviceExtension->Device,
2831  &propertyId,
2832  (PSTORAGE_DESCRIPTOR_HEADER*)&deviceIdDescriptor);
2833 
2834  if (NT_SUCCESS(status) && (deviceIdDescriptor == NULL))
2835  {
2837  }
2838 
2839  if (NT_SUCCESS(status))
2840  {
2841  status = WdfRequestRetrieveOutputBuffer(Request,
2842  RequestParameters.Parameters.DeviceIoControl.OutputBufferLength,
2843  &descHeader,
2844  NULL);
2845  }
2846 
2847  if (NT_SUCCESS(status))
2848  {
2850  ULONG offset = descHeader->Size;
2851  PUCHAR dest = (PUCHAR)descHeader + offset;
2852  size_t outputBufferSize;
2853 
2854  outputBufferSize = RequestParameters.Parameters.DeviceIoControl.OutputBufferLength;
2855 
2856  // Adjust required size and potential destination location.
2857  status = RtlULongAdd(descHeader->Size, deviceIdDescriptor->Size, &descHeader->Size);
2858 
2859  if (NT_SUCCESS(status) &&
2860  (outputBufferSize < descHeader->Size))
2861  {
2862  // Output buffer is too small. Return error and make sure
2863  // the caller gets info about required buffer size.
2864  *DataLength = descHeader->Size;
2866  }
2867 
2868  if (NT_SUCCESS(status))
2869  {
2870  storageDuid = (PSTORAGE_DEVICE_UNIQUE_IDENTIFIER)descHeader;
2871  storageDuid->StorageDeviceIdOffset = offset;
2872 
2874  deviceIdDescriptor,
2875  deviceIdDescriptor->Size);
2876 
2877  *DataLength = storageDuid->Size;
2879  }
2880 
2881  FREE_POOL(deviceIdDescriptor);
2882  }
2883 
2884  return status;
2885 }
enum _STORAGE_PROPERTY_ID STORAGE_PROPERTY_ID
* PSTORAGE_DESCRIPTOR_HEADER
Definition: ntddstor.h:560
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
struct _WDF_REQUEST_PARAMETERS::@3696::@3700 DeviceIoControl
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define FREE_POOL(_PoolPtr)
Definition: cdrom.h:782
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
#define STATUS_NOT_FOUND
Definition: shellext.h:72
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
GLintptr offset
Definition: glext.h:5920
struct _STORAGE_DEVICE_UNIQUE_IDENTIFIER * PSTORAGE_DEVICE_UNIQUE_IDENTIFIER
_In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_PARAMETERS RequestParameters
Definition: ioctl.h:137
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define NULL
Definition: types.h:112
union _WDF_REQUEST_PARAMETERS::@3696 Parameters
unsigned int ULONG
Definition: retypes.h:1
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
static char * dest
Definition: rtl.c:135
#define STATUS_SUCCESS
Definition: shellext.h:65
* PSTORAGE_DEVICE_ID_DESCRIPTOR
Definition: ntddstor.h:742
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by RequestHandleQueryPropertyDeviceUniqueId().

◆ RequestDuidGetDeviceProperty()

NTSTATUS RequestDuidGetDeviceProperty ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ WDFREQUEST  Request,
_In_ WDF_REQUEST_PARAMETERS  RequestParameters,
_Out_ size_t DataLength 
)

Definition at line 2888 of file common.c.

2912 {
2914  PSTORAGE_DEVICE_DESCRIPTOR deviceDescriptor = DeviceExtension->DeviceDescriptor;
2915  PSTORAGE_DESCRIPTOR_HEADER descHeader = NULL;
2917  PUCHAR dest = NULL;
2918 
2919  if (deviceDescriptor == NULL)
2920  {
2922  }
2923 
2924  if (NT_SUCCESS(status))
2925  {
2926  status = WdfRequestRetrieveOutputBuffer(Request,
2927  RequestParameters.Parameters.DeviceIoControl.OutputBufferLength,
2928  &descHeader,
2929  NULL);
2930  }
2931 
2932  if (NT_SUCCESS(status) &&
2933  (deviceDescriptor->SerialNumberOffset == 0))
2934  {
2936  }
2937 
2938  // Use this info only if serial number is available.
2939  if (NT_SUCCESS(status))
2940  {
2941  ULONG offset = descHeader->Size;
2942  size_t outputBufferSize = RequestParameters.Parameters.DeviceIoControl.OutputBufferLength;
2943 
2944  // Adjust required size and potential destination location.
2945  dest = (PUCHAR)descHeader + offset;
2946 
2947  status = RtlULongAdd(descHeader->Size, deviceDescriptor->Size, &descHeader->Size);
2948 
2949  if (NT_SUCCESS(status) &&
2950  (outputBufferSize < descHeader->Size))
2951  {
2952  // Output buffer is too small. Return error and make sure
2953  // the caller get info about required buffer size.
2954  *DataLength = descHeader->Size;
2956  }
2957 
2958  if (NT_SUCCESS(status))
2959  {
2960  storageDuid = (PSTORAGE_DEVICE_UNIQUE_IDENTIFIER)descHeader;
2961  storageDuid->StorageDeviceOffset = offset;
2962 
2964  deviceDescriptor,
2965  deviceDescriptor->Size);
2966 
2967  *DataLength = storageDuid->Size;
2969  }
2970  }
2971 
2972  return status;
2973 }
* PSTORAGE_DESCRIPTOR_HEADER
Definition: ntddstor.h:560
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
struct _WDF_REQUEST_PARAMETERS::@3696::@3700 DeviceIoControl
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
* PSTORAGE_DEVICE_DESCRIPTOR
Definition: ntddstor.h:576
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
#define STATUS_NOT_FOUND
Definition: shellext.h:72
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
GLintptr offset
Definition: glext.h:5920
struct _STORAGE_DEVICE_UNIQUE_IDENTIFIER * PSTORAGE_DEVICE_UNIQUE_IDENTIFIER
_In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_PARAMETERS RequestParameters
Definition: ioctl.h:137
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define NULL
Definition: types.h:112
union _WDF_REQUEST_PARAMETERS::@3696 Parameters
unsigned int ULONG
Definition: retypes.h:1
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
static char * dest
Definition: rtl.c:135
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by RequestHandleQueryPropertyDeviceUniqueId().

◆ RequestGetCurrentStackLocationFlags()

__inline UCHAR RequestGetCurrentStackLocationFlags ( _In_ WDFREQUEST  Request)

Definition at line 1554 of file cdrom.h.

1557 {
1558  PIRP irp = NULL;
1559  PIO_STACK_LOCATION currentStack = NULL;
1560 
1561  irp = WdfRequestWdmGetIrp(Request);
1562  currentStack = IoGetCurrentIrpStackLocation(irp);
1563 
1564  return currentStack->Flags;
1565 }
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define NULL
Definition: types.h:112
FxIrp * irp

Referenced by RequestDispatchProcessDirectly(), RequestDispatchSpecialIoctls(), RequestDispatchSyncWithSequentialQueue(), RequestDispatchToSequentialQueue(), and RequestIsRealtimeStreaming().

◆ RequestIsIoctlBlockedByExclusiveAccess()

NTSTATUS RequestIsIoctlBlockedByExclusiveAccess ( _In_ WDFREQUEST  Request,
_Out_ PBOOLEAN  IsBlocked 
)

Definition at line 4058 of file cdrom.c.

4079 {
4081  ULONG ioctlCode = 0;
4082  ULONG baseCode = 0;
4083  WDF_REQUEST_PARAMETERS requestParameters;
4084 
4085  // Get the Request parameters
4086  WDF_REQUEST_PARAMETERS_INIT(&requestParameters);
4087  WdfRequestGetParameters(Request, &requestParameters);
4088 
4089  // check and initialize parameter
4090  if (IsBlocked == NULL)
4091  {
4092  //This is an internal function and this parameter must be supplied.
4093  NT_ASSERT(FALSE);
4094 
4095  return STATUS_INVALID_PARAMETER;
4096  }
4097  else
4098  {
4099  *IsBlocked = FALSE;
4100  }
4101 
4102  // check if this is an IOCTL
4103  if ((requestParameters.Type == WdfRequestTypeDeviceControl) ||
4104  (requestParameters.Type == WdfRequestTypeDeviceControlInternal))
4105  {
4106  //
4107  // Allow minimum set of commands that are required for the disk manager
4108  // to show the CD device, while in exclusive mode.
4109  // Note: These commands should not generate any requests to the device,
4110  // and thus must be handled directly in StartIO during exclusive
4111  // access (except for the exclusive owner, of course).
4112  //
4113  ioctlCode = requestParameters.Parameters.DeviceIoControl.IoControlCode;
4114  baseCode = DEVICE_TYPE_FROM_CTL_CODE(ioctlCode);
4115 
4116  if (ioctlCode == IOCTL_SCSI_GET_ADDRESS ||
4117  ioctlCode == IOCTL_STORAGE_GET_HOTPLUG_INFO ||
4118  ioctlCode == IOCTL_STORAGE_GET_DEVICE_NUMBER ||
4119  ioctlCode == IOCTL_STORAGE_GET_MEDIA_TYPES_EX ||
4120  ioctlCode == IOCTL_CDROM_EXCLUSIVE_ACCESS ||
4121  ioctlCode == IOCTL_CDROM_GET_INQUIRY_DATA
4122  )
4123  {
4124  *IsBlocked = FALSE;
4125  }
4126 
4127  //
4128  // Handle IOCTL_STORAGE_QUERY_PROPERTY special because:
4129  // (1) PropertyExistsQuery should not generate device i/o
4130  // (2) Queries for StorageDeviceProperty and StorageAdapterDescriptor
4131  // will return cache'd data
4132  else if (ioctlCode == IOCTL_STORAGE_QUERY_PROPERTY)
4133  {
4135  status = WdfRequestRetrieveInputBuffer(Request,
4136  requestParameters.Parameters.DeviceIoControl.InputBufferLength,
4137  (PVOID*)&query,
4138  NULL);
4139 
4140  if (NT_SUCCESS(status))
4141  {
4142  if (query != NULL)
4143  {
4144  if (query->QueryType == PropertyExistsQuery)
4145  {
4146  *IsBlocked = FALSE;
4147  }
4148  else if ((query->QueryType == PropertyStandardQuery) &&
4149  ((query->PropertyId == StorageDeviceProperty) ||
4150  (query->PropertyId == StorageAdapterProperty)))
4151  {
4152  *IsBlocked = FALSE;
4153  }
4154  }
4155  }
4156  }
4157 
4158  // Return TRUE for unknown IOCTLs with STORAGE bases
4159  else if (baseCode == IOCTL_SCSI_BASE ||
4160  baseCode == IOCTL_DISK_BASE ||
4161  baseCode == IOCTL_CDROM_BASE ||
4162  baseCode == IOCTL_STORAGE_BASE ||
4163  baseCode == IOCTL_DVD_BASE )
4164  {
4165  *IsBlocked = TRUE;
4166  }
4167  }
4168  else
4169  {
4170  // this should only be called with an IOCTL
4171  NT_ASSERT(FALSE);
4172 
4174  }
4175 
4176  return status;
4177 }
#define IOCTL_DISK_BASE
Definition: ntdddisk.h:44
#define IOCTL_CDROM_BASE
Definition: vcdcli.c:21
#define IOCTL_SCSI_GET_ADDRESS
Definition: scsi_port.h:52
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
WDF_REQUEST_TYPE Type
Definition: wdfrequest.h:142
struct _WDF_REQUEST_PARAMETERS::@3696::@3700 DeviceIoControl
#define IOCTL_STORAGE_GET_HOTPLUG_INFO
Definition: imports.h:238
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define FALSE
Definition: types.h:117
#define IOCTL_STORAGE_GET_DEVICE_NUMBER
Definition: ntddstor.h:143
#define IOCTL_STORAGE_QUERY_PROPERTY
Definition: ntddstor.h:178
#define IOCTL_STORAGE_GET_MEDIA_TYPES_EX
Definition: cdrw_usr.h:190
#define IOCTL_DVD_BASE
Definition: ntddcdvd.h:32
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IOCTL_CDROM_EXCLUSIVE_ACCESS
Definition: ntddcdrm.h:85
#define IOCTL_CDROM_GET_INQUIRY_DATA
Definition: ntddcdrm.h:91
#define IOCTL_SCSI_BASE
Definition: scsi_port.h:37
#define NULL
Definition: types.h:112
#define DEVICE_TYPE_FROM_CTL_CODE(c)
Definition: winioctl.h:176
FORCEINLINE VOID WDF_REQUEST_PARAMETERS_INIT(_Out_ PWDF_REQUEST_PARAMETERS Parameters)
Definition: wdfrequest.h:211
union _WDF_REQUEST_PARAMETERS::@3696 Parameters
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
#define IOCTL_STORAGE_BASE
Definition: ntddstor.h:96
#define NT_ASSERT
Definition: rtlfuncs.h:3312
Definition: ps.c:97

Referenced by DeviceEvtIoInCallerContext(), RequestSynchronizeProcessWithSerialQueue(), and SequentialQueueEvtIoDeviceControl().

◆ RequestProcessInternalDeviceControl()

VOID RequestProcessInternalDeviceControl ( _In_ WDFREQUEST  Request,
_In_ PCDROM_DEVICE_EXTENSION  DeviceExtension 
)

Definition at line 3154 of file cdrom.c.

3173 {
3175  PIRP irp = NULL;
3176  PIO_STACK_LOCATION irpStack = NULL;
3177  PIO_STACK_LOCATION nextStack = NULL;
3178  BOOLEAN requestSent = FALSE;
3179 
3180  irp = WdfRequestWdmGetIrp(Request);
3181  irpStack = IoGetCurrentIrpStackLocation(irp);
3182  nextStack = IoGetNextIrpStackLocation(irp);
3183 
3184  // Set the parameters in the next stack location.
3185  nextStack->Parameters.Scsi.Srb = irpStack->Parameters.Scsi.Srb;
3186  nextStack->MajorFunction = IRP_MJ_SCSI;
3187  nextStack->MinorFunction = IRP_MN_SCSI_CLASS;
3188 
3189  WdfRequestSetCompletionRoutine(Request, RequestDummyCompletionRoutine, NULL);
3190 
3191  status = RequestSend(DeviceExtension,
3192  Request,
3193  DeviceExtension->IoTarget,
3194  0,
3195  &requestSent);
3196 
3197  // send the request straight down (asynchronously)
3198  if (!requestSent)
3199  {
3200  // fail the request
3201  RequestCompletion(DeviceExtension, Request, status, WdfRequestGetInformation(Request));
3202  }
3203 
3204  return;
3205 }
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS RequestSend(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDFIOTARGET IoTarget, _In_ ULONG Flags, _Out_opt_ PBOOLEAN RequestSent)
Definition: common.c:3793
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
EVT_WDF_REQUEST_COMPLETION_ROUTINE RequestDummyCompletionRoutine
Definition: cdrom.h:1608
#define IRP_MJ_SCSI
VOID RequestCompletion(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ NTSTATUS Status, _In_ ULONG_PTR Information)
Definition: common.c:3439
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2691
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65
#define IRP_MN_SCSI_CLASS
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
FxIrp * irp
Definition: ps.c:97

Referenced by DeviceEvtIoInCallerContext().

◆ RequestSend()

NTSTATUS RequestSend ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ WDFREQUEST  Request,
_In_ WDFIOTARGET  IoTarget,
_In_ ULONG  Flags,
_Out_opt_ PBOOLEAN  RequestSent 
)

Definition at line 3793 of file common.c.

3819 {
3821  BOOLEAN requestSent = FALSE;
3823 
3824  UNREFERENCED_PARAMETER(DeviceExtension);
3825 
3826  if ((DeviceExtension->ZeroPowerODDInfo != NULL) &&
3827  (DeviceExtension->ZeroPowerODDInfo->InZeroPowerState != FALSE))
3828  {
3829  }
3830 
3831  // Now send down the request
3832  if (NT_SUCCESS(status))
3833  {
3835 
3837 
3838  // send request and check status
3839 
3840  // Disable SDV warning about infinitely waiting in caller's context:
3841  // 1. Some requests (such as SCSI_PASS_THROUGH, contains buffer from user space) need to be sent down in caller’s context.
3842  // Consequently, these requests wait in caller’s context until they are allowed to be sent down.
3843  // 2. Considering the situation that during sleep, a request can be hold by storage port driver. When system resumes, any time out value (if we set using KMDF time out value) might be expires.
3844  // This will cause the waiting request being failed (behavior change). We’d rather not set time out value.
3845 
3846  _Analysis_assume_(options.Timeout != 0);
3847  requestSent = WdfRequestSend(Request, IoTarget, &options);
3848  _Analysis_assume_(options.Timeout == 0);
3849 
3850  // If WdfRequestSend fails, or if the WDF_REQUEST_SEND_OPTION_SYNCHRONOUS flag is set,
3851  // the driver can call WdfRequestGetStatus immediately after calling WdfRequestSend.
3852  if ((requestSent == FALSE) ||
3854  {
3855  status = WdfRequestGetStatus(Request);
3856 
3857  if (requestSent == FALSE)
3858  {
3859  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_GENERAL,
3860  "WdfRequestSend failed: %lx\n",
3861  status
3862  ));
3863  }
3864  }
3865  else
3866  {
3868  }
3869 
3870  if (RequestSent != NULL)
3871  {
3872  *RequestSent = requestSent;
3873  }
3874  }
3875 
3876  return status;
3877 }
FORCEINLINE VOID WDF_REQUEST_SEND_OPTIONS_INIT(_Out_ PWDF_REQUEST_SEND_OPTIONS Options, _In_ ULONG Flags)
Definition: wdfrequest.h:409
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
int options
Definition: main.c:106
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID RequestSetSentTime(_In_ WDFREQUEST Request)
Definition: common.c:79
_Must_inspect_result_ FORCEINLINE BOOLEAN WdfRequestSend(_In_ WDFREQUEST Request, _In_ WDFIOTARGET Target, _In_opt_ PWDF_REQUEST_SEND_OPTIONS Options)
Definition: wdfrequest.h:677
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
#define _Analysis_assume_
Definition: no_sal2.h:388
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIOTARGET * IoTarget
Definition: wdfiotarget.h:363
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by _IRQL_requires_max_(), DeviceReleaseQueue(), DeviceSendStartUnit(), RequestProcessInternalDeviceControl(), and ScratchBuffer_SendSrb().

◆ RequestSenseInfoInterpret()

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 at line 2467 of file sense.c.

2500 {
2501  BOOLEAN retry = FALSE;
2502  LONGLONG retryIntervalIn100ns = 0;
2503  PZERO_POWER_ODD_INFO zpoddInfo = DeviceExtension->ZeroPowerODDInfo;
2504 
2505  if (SRB_STATUS(Srb->SrbStatus) == SRB_STATUS_SUCCESS)
2506  {
2507  // request succeeded.
2508  if ((zpoddInfo != NULL) &&
2509  (zpoddInfo->BecomingReadyRetryCount > 0))
2510  {
2511  zpoddInfo->BecomingReadyRetryCount = 0;
2512  }
2513 
2515  retry = FALSE;
2516  }
2517  else
2518  {
2519  // request failed. We need to process the error.
2520 
2521  // 1. Release the queue if it is frozen.
2522  if (Srb->SrbStatus & SRB_STATUS_QUEUE_FROZEN)
2523  {
2524  DeviceReleaseQueue(DeviceExtension->Device);
2525  }
2526 
2527  if ((zpoddInfo != NULL) &&
2528  ((zpoddInfo->RetryFirstCommand != FALSE) || (zpoddInfo->BecomingReadyRetryCount > 0)))
2529  {
2530  retry = SenseInfoInterpretForZPODD(DeviceExtension,
2531  Srb,
2532  Status,
2533  &retryIntervalIn100ns);
2534  }
2535 
2536  if (retry == FALSE)
2537  {
2538  // 2. Error Processing
2539  if ((zpoddInfo != NULL) &&
2540  (zpoddInfo->BecomingReadyRetryCount > 0))
2541  {
2542  zpoddInfo->BecomingReadyRetryCount = 0;
2543  }
2544 
2545  retry = SenseInfoInterpret(DeviceExtension,
2546  Request,
2547  Srb,
2548  RetriedCount,
2549  Status,
2550  &retryIntervalIn100ns);
2551  }
2552  }
2553 
2554  if (RetryIntervalIn100ns != NULL)
2555  {
2556  *RetryIntervalIn100ns = retryIntervalIn100ns;
2557  }
2558 
2559  return retry;
2560 }
BOOLEAN RetryFirstCommand
Definition: cdromp.h:273
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define SRB_STATUS(Status)
Definition: srb.h:381
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
Status
Definition: gdiplustypes.h:24
int64_t LONGLONG
Definition: typedefs.h:68
BOOLEAN SenseInfoInterpret(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ PSCSI_REQUEST_BLOCK Srb, _In_ ULONG RetriedCount, _Out_ NTSTATUS *Status, _Out_ _Deref_out_range_(0, MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS) LONGLONG *RetryIntervalIn100ns)
Definition: sense.c:2038
#define SRB_STATUS_QUEUE_FROZEN
Definition: srb.h:378
BOOLEAN SenseInfoInterpretForZPODD(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ PSCSI_REQUEST_BLOCK Srb, _Out_ NTSTATUS *Status, _Out_ _Out_range_(0, MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS) LONGLONG *RetryIntervalIn100ns)
Definition: sense.c:2341
VOID DeviceReleaseQueue(_In_ WDFDEVICE Device)
Definition: common.c:1179
#define NULL
Definition: types.h:112
ULONG BecomingReadyRetryCount
Definition: cdromp.h:277
#define SRB_STATUS_SUCCESS
Definition: srb.h:333
#define STATUS_SUCCESS
Definition: shellext.h:65
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49

Referenced by _IRQL_requires_max_(), and RequestSenseInfoInterpretForScratchBuffer().

◆ RequestSenseInfoInterpretForScratchBuffer()

BOOLEAN RequestSenseInfoInterpretForScratchBuffer ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension,
_In_ ULONG  RetriedCount,
_Out_ NTSTATUS Status,
_Out_ _Deref_out_range_(0, MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS) LONGLONG RetryIntervalIn100ns 
)

Definition at line 2564 of file sense.c.

2589 {
2590  NT_ASSERT(DeviceExtension->ScratchContext.ScratchInUse != 0);
2591 
2592  return RequestSenseInfoInterpret(DeviceExtension,
2593  DeviceExtension->ScratchContext.ScratchRequest,
2594  DeviceExtension->ScratchContext.ScratchSrb,
2595  RetriedCount,
2596  Status,
2597  RetryIntervalIn100ns);
2598 }
Status
Definition: gdiplustypes.h:24
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 NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by RequestIssueShutdownFlush(), and ScratchBuffer_ReadWriteCompletionRoutine().

◆ RequestSetContextFields()

NTSTATUS RequestSetContextFields ( _In_ WDFREQUEST  Request,
_In_ PSYNC_HANDLER  Handler 
)

Definition at line 2748 of file common.c.

2768 {
2770  PCDROM_REQUEST_CONTEXT requestContext = RequestGetContext(Request);
2771  PKEVENT syncEvent = NULL;
2772 
2773  syncEvent = ExAllocatePoolWithTag(NonPagedPoolNx,
2774  sizeof(KEVENT),
2776 
2777  if (syncEvent == NULL)
2778  {
2779  // memory allocation failed.
2781  }
2782  else
2783  {
2784  // now, put the special synchronization information into the context
2785  requestContext->SyncRequired = TRUE;
2786  requestContext->SyncEvent = syncEvent;
2787  requestContext->SyncCallback = Handler;
2788 
2790  }
2791 
2792  return status;
2793 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN SyncRequired
Definition: cdrom.h:643
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
PSYNC_HANDLER SyncCallback
Definition: cdrom.h:645
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define CDROM_TAG_SYNC_EVENT
Definition: cdrom.h:732
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER Handler
Definition: acpixf.h:668
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by RequestDispatchSpecialIoctls(), RequestDispatchSyncWithSequentialQueue(), and RequestDispatchUnknownRequests().

◆ RequestSetReceivedTime()

VOID RequestSetReceivedTime ( _In_ WDFREQUEST  Request)

Definition at line 64 of file common.c.

67 {
68  PCDROM_REQUEST_CONTEXT requestContext = RequestGetContext(Request);
70 
72 
73  requestContext->TimeReceived = temp;
74 
75  return;
76 }
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
LARGE_INTEGER TimeReceived
Definition: cdrom.h:635
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
static calc_node_t temp
Definition: rpn_ieee.c:38

Referenced by DeviceEvtIoInCallerContext().

◆ RequestSetSentTime()

VOID RequestSetSentTime ( _In_ WDFREQUEST  Request)

Definition at line 79 of file common.c.

82 {
83  PCDROM_REQUEST_CONTEXT requestContext = RequestGetContext(Request);
85 
87 
88  if (requestContext->TimeSentDownFirstTime.QuadPart == 0)
89  {
90  requestContext->TimeSentDownFirstTime = temp;
91  }
92 
93  requestContext->TimeSentDownLasttTime = temp;
94 
95  if (requestContext->OriginalRequest != NULL)
96  {
97  PCDROM_REQUEST_CONTEXT originalRequestContext = RequestGetContext(requestContext->OriginalRequest);
98 
99  if (originalRequestContext->TimeSentDownFirstTime.QuadPart == 0)
100  {
101  originalRequestContext->TimeSentDownFirstTime = temp;
102  }
103 
104  originalRequestContext->TimeSentDownLasttTime = temp;
105  }
106 
107  return;
108 }
LARGE_INTEGER TimeSentDownLasttTime
Definition: cdrom.h:637
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
static calc_node_t temp
Definition: rpn_ieee.c:38
#define NULL
Definition: types.h:112
LARGE_INTEGER TimeSentDownFirstTime
Definition: cdrom.h:636
LONGLONG QuadPart
Definition: typedefs.h:114
WDFREQUEST OriginalRequest
Definition: cdrom.h:633

Referenced by RequestSend().

◆ RequestSetupMcnSyncIrp()

VOID RequestSetupMcnSyncIrp ( _In_ PCDROM_DEVICE_EXTENSION  DeviceExtension)

Definition at line 2749 of file autorun.c.

2766 {
2767  PIRP irp = NULL;
2768  PIO_STACK_LOCATION irpStack = NULL;
2769  PIO_STACK_LOCATION nextIrpStack = NULL;
2770 
2771  irp = DeviceExtension->MediaChangeDetectionInfo->MediaChangeSyncIrp;
2772  NT_ASSERT(irp != NULL);
2773 
2774  //
2775  // For the driver that creates an IRP, there is no 'current' stack location.
2776  // Step down one IRP stack location so that the extra top one
2777  // becomes our 'current' one.
2778  //
2780 
2781  /*
2782  * Cache our device object in the extra top IRP stack location
2783  * so we have it in our completion routine.
2784  */
2785  irpStack = IoGetCurrentIrpStackLocation(irp);
2786  irpStack->DeviceObject = DeviceExtension->DeviceObject;
2787 
2788  //
2789  // If the irp is sent down when the volume needs to be
2790  // verified, CdRomUpdateGeometryCompletion won't complete
2791  // it since it's not associated with a thread. Marking
2792  // it to override the verify causes it always be sent
2793  // to the port driver
2794  //
2795  nextIrpStack = IoGetNextIrpStackLocation(irp);
2796 
2797  SET_FLAG(nextIrpStack->Flags, SL_OVERRIDE_VERIFY_VOLUME);
2798 
2799  nextIrpStack->MajorFunction = IRP_MJ_DEVICE_CONTROL;
2800  // pick up this IOCTL code as it's not normaly seen for CD/DVD drive and does not require input.
2801  // set other fields to make this IOCTL recognizable by CDROM.SYS
2802  nextIrpStack->Parameters.Others.Argument1 = RequestSetupMcnSyncIrp;
2803  nextIrpStack->Parameters.Others.Argument2 = RequestSetupMcnSyncIrp;
2804  nextIrpStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_MCN_SYNC_FAKE_IOCTL; //Argument3.
2805  nextIrpStack->Parameters.Others.Argument4 = RequestSetupMcnSyncIrp;
2806 
2809  DeviceExtension,
2810  TRUE,
2811  TRUE,
2812  TRUE);
2813 
2814  return;
2815 }
#define TRUE
Definition: types.h:120
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:498
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1803
VOID RequestSetupMcnSyncIrp(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension)
Definition: autorun.c:2749
PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:3202
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2691
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define NULL
Definition: types.h:112
#define IOCTL_MCN_SYNC_FAKE_IOCTL
Definition: cdrom.h:181
IO_COMPLETION_ROUTINE RequestMcnSyncIrpCompletion
Definition: autorun.c:2691
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
FORCEINLINE VOID IoSetNextIrpStackLocation(_Inout_ PIRP Irp)
Definition: iofuncs.h:2676
#define SET_FLAG(Flags, Bit)
Definition: cdrom.h:1493
FxIrp * irp
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by RequestDispatchSpecialIoctls(), and RequestSetupMcnSyncIrp().

◆ RequestSynchronizeProcessWithSerialQueue()

NTSTATUS RequestSynchronizeProcessWithSerialQueue ( _In_ WDFDEVICE  Device,
_In_ WDFREQUEST  Request 
)

Definition at line 3893 of file cdrom.c.

3916 {
3918  PCDROM_DEVICE_EXTENSION deviceExtension = DeviceGetExtension(Device);
3919  PCDROM_REQUEST_CONTEXT requestContext = RequestGetContext(Request);
3920  PKEVENT bufferToFree = requestContext->SyncEvent;
3921 
3922  if (KeGetCurrentIrql() >= DISPATCH_LEVEL) {
3923  // cannot block at or above DISPATCH_LEVEL
3924  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_IOCTL,
3925  "RequestSynchronousProcessWithSerialQueue called at DISPATCH_LEVEL or above"));
3926  NT_ASSERT(FALSE);
3927  RequestCompletion(deviceExtension, Request, STATUS_INVALID_LEVEL, 0);
3928  return STATUS_INVALID_LEVEL;
3929  }
3930 
3931  // init the synchronization event
3933 
3934  // do we still need to do something like this?
3935  // SET_FLAG(nextStack->Flags, SL_OVERRIDE_VERIFY_VOLUME);
3936 
3937  // NOTE: this mechanism relies on that KMDF will not complete request by itself.
3938  // Doing that will cause the syncEvent not fired thus this thread will stuck.
3939  // This should not really happen: our EvtCanceledOnQueue callbacks should be
3940  // called even if queues are purged for some reason. The only case when these
3941  // callbacks are not called is when a request is owned by the driver (i.e. has
3942  // already been passed to one of the registered handlers). In this case, it is
3943  // our responsibility to cancel such requests properly.
3944  status = WdfDeviceEnqueueRequest(Device, Request);
3945 
3946  if (!NT_SUCCESS(status))
3947  {
3948  // Failed to forward request! Pretend the sync event already occured, otherwise we'll hit
3949  // an assert in RequestEvtCleanup.
3950  KeSetEvent(requestContext->SyncEvent, IO_CD_ROM_INCREMENT, FALSE);
3951  RequestCompletion(deviceExtension, Request, status, WdfRequestGetInformation(Request));
3952  }
3953  else
3954  {
3955  NTSTATUS waitStatus = STATUS_UNSUCCESSFUL;
3956  PCDROM_DATA cdData = &(deviceExtension->DeviceAdditionalData);
3957  BOOLEAN fCallSyncCallback = FALSE;
3958  PIRP irp = WdfRequestWdmGetIrp(Request);
3959 
3960  // ok, now wait on the event
3961  while (waitStatus != STATUS_SUCCESS)
3962  {
3963  waitStatus = KeWaitForSingleObject(requestContext->SyncEvent, Executive, KernelMode, TRUE, NULL);
3964  if (waitStatus == STATUS_SUCCESS) // must check equality -- STATUS_ALERTED is success code
3965  {
3966  // do nothing
3967  }
3968  else if (waitStatus != STATUS_ALERTED)
3969  {
3970  // do nothing
3971  TracePrint((TRACE_LEVEL_FATAL, TRACE_FLAG_IOCTL,
3972  "Request %p on device object %p had a non-alert, non-success result from wait (%!HRESULT!)\n",
3973  Request, Device, waitStatus));
3974  NT_ASSERT(FALSE);
3975  }
3977  {
3978  // the thread was alerted and is terminating, so cancel the irp
3979  // this will cause EvtIoCanceledOnQueue to be called, which will signal the event,
3980  // so we will get out of the while loop and eventually complete the request.
3981  if (IoCancelIrp(irp))
3982  {
3983  // cancellation routine was called
3984  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL,
3985  "Sychronize Ioctl: request %p cancelled from device %p\n",
3986  Request, Device));
3987  }
3988  else
3989  {
3990  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL,
3991  "Sychronize Ioctl: request %p could not be cancelled from device %p\n",
3992  Request, Device));
3993  }
3994  }
3995  else
3996  {
3997  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL,
3998  "SPURIOUS ALERT waiting for Request %p on device %p (%!STATUS!)\n",
3999  Request, Device, status));
4000  }
4001  } // end of wait loop on the event
4002 
4003  // because we've waited an unknown amount of time, should check
4004  // the cancelled flag to immediately fail the irp as appropriate
4005  if (WdfRequestIsCanceled(Request))
4006  {
4007  // the request was cancelled, thus we should always stop
4008  // processing here if possible.
4010  RequestCompletion(deviceExtension, Request, status, 0);
4011  }
4012  else if (EXCLUSIVE_MODE(cdData) && !EXCLUSIVE_OWNER(cdData, WdfRequestGetFileObject(Request)))
4013  {
4014  WDF_REQUEST_PARAMETERS requestParameters;
4015  BOOLEAN isBlocked = FALSE;
4016 
4017  // get the request parameters
4018  WDF_REQUEST_PARAMETERS_INIT(&requestParameters);
4019  WdfRequestGetParameters(Request, &requestParameters);
4020 
4022  if (isBlocked)
4023  {
4024  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_IOCTL,
4025  "Access Denied! Device in exclusive mode.Failing Ioctl %lx\n",
4026  requestParameters.Parameters.DeviceIoControl.IoControlCode));
4027  RequestCompletion(deviceExtension, Request, STATUS_ACCESS_DENIED, 0);
4028  }
4029  else
4030  {
4031  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
4032  "Ioctl %lx not blocked by cdrom being in exclusive mode\n",
4033  requestParameters.Parameters.DeviceIoControl.IoControlCode));
4034  fCallSyncCallback = TRUE;
4035  }
4036  }
4037  else
4038  {
4039  fCallSyncCallback = TRUE;
4040  }
4041 
4042  if (fCallSyncCallback)
4043  {
4044  // Synchronization completed successfully. Call the requested routine
4045  status = requestContext->SyncCallback(Device, Request);
4046  }
4047  }
4048 
4049  // The next SequentialQueue evt routine will not be triggered until the current request is completed.
4050 
4051  // clean up the request context setting.
4052  FREE_POOL(bufferToFree);
4053 
4054  return status;
4055 }
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
#define TRUE
Definition: types.h:120
CDROM_DATA DeviceAdditionalData
Definition: cdrom.h:598
NTSTATUS RequestIsIoctlBlockedByExclusiveAccess(_In_ WDFREQUEST Request, _Out_ PBOOLEAN IsBlocked)
Definition: cdrom.c:4058
LONG NTSTATUS
Definition: precomp.h:26
struct _WDF_REQUEST_PARAMETERS::@3696::@3700 DeviceIoControl
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
#define STATUS_ALERTED
Definition: ntstatus.h:80
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
PSYNC_HANDLER SyncCallback
Definition: cdrom.h:645
VOID RequestCompletion(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ NTSTATUS Status, _In_ ULONG_PTR Information)
Definition: common.c:3439
#define FALSE
Definition: types.h:117
#define FREE_POOL(_PoolPtr)
Definition: cdrom.h:782
#define TRACE_LEVEL_FATAL
Definition: storswtr.h:26
unsigned char BOOLEAN
#define STATUS_INVALID_LEVEL
Definition: ntstatus.h:564
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
#define EXCLUSIVE_MODE(_CdData)
Definition: cdrom.h:788
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define EXCLUSIVE_OWNER(_CdData, _FileObject)
Definition: cdrom.h:789
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define IO_CD_ROM_INCREMENT
Definition: iotypes.h:582
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define NULL
Definition: types.h:112
FORCEINLINE VOID WDF_REQUEST_PARAMETERS_INIT(_Out_ PWDF_REQUEST_PARAMETERS Parameters)
Definition: wdfrequest.h:211
BOOLEAN NTAPI IoCancelIrp(IN PIRP Irp)
Definition: irp.c:1101
union _WDF_REQUEST_PARAMETERS::@3696 Parameters
#define STATUS_SUCCESS
Definition: shellext.h:65
BOOLEAN NTAPI PsIsThreadTerminating(IN PETHREAD Thread)
Definition: thread.c:868
static SERVICE_STATUS status
Definition: service.c:31
FxIrp * irp
#define NT_ASSERT
Definition: rtlfuncs.h:3312
Definition: ps.c:97

Referenced by RequestDispatchSpecialIoctls(), RequestDispatchSyncWithSequentialQueue(), and RequestDispatchUnknownRequests().

◆ SequentialQueueEvtIoReadWrite()

VOID NTAPI SequentialQueueEvtIoReadWrite ( _In_ WDFQUEUE  Queue,
_In_ WDFREQUEST  Request,
_In_ size_t  Length 
)

Definition at line 3215 of file cdrom.c.

3238 {
3240  WDFDEVICE device = WdfIoQueueGetDevice(Queue);
3241  PCDROM_DEVICE_EXTENSION deviceExtension = DeviceGetExtension(device);
3242  WDF_REQUEST_PARAMETERS requestParameters;
3243  PIRP wdmIrp = WdfRequestWdmGetIrp(Request);
3244  PIO_STACK_LOCATION currentIrpStack = IoGetCurrentIrpStackLocation(wdmIrp);
3245  PCDROM_DATA cdData = &(deviceExtension->DeviceAdditionalData);
3246 
3247  // Get the request parameters
3248  WDF_REQUEST_PARAMETERS_INIT(&requestParameters);
3249  WdfRequestGetParameters(Request, &requestParameters);
3250 
3251  if (requestParameters.Type == WdfRequestTypeRead)
3252  {
3253  TracePrint((TRACE_LEVEL_VERBOSE, TRACE_FLAG_GENERAL,
3254  "Receiving READ, Length %Ix\n", (ULONG) Length));
3255  }
3256  else
3257  {
3258  TracePrint((TRACE_LEVEL_VERBOSE, TRACE_FLAG_GENERAL,
3259  "Receiving WRITE, Length %Ix\n", (ULONG) Length));
3260  }
3261 
3262  // Check if a verify is required before a READ/WRITE
3263  if (TEST_FLAG(deviceExtension->DeviceObject->Flags, DO_VERIFY_VOLUME) &&
3264  (requestParameters.MinorFunction != CDROM_VOLUME_VERIFY_CHECKED) &&
3265  !TEST_FLAG(currentIrpStack->Flags, SL_OVERRIDE_VERIFY_VOLUME))
3266  {
3267  // DO_VERIFY_VOLUME is set for the device object,
3268  // but this request is not itself a verify request.
3269  // So fail this request.
3270  RequestCompletion(deviceExtension, Request, STATUS_VERIFY_REQUIRED, 0);
3271  }
3272  else
3273  {
3274  // Since we've bypassed the verify-required tests we don't need to repeat
3275  // them with this IRP - in particular we don't want to worry about
3276  // hitting them at the partition 0 level if the request has come through
3277  // a non-zero partition.
3278  currentIrpStack->MinorFunction = CDROM_VOLUME_VERIFY_CHECKED;
3279 
3280  // Fail READ/WRITE requests when music is playing
3281  if (deviceExtension->DeviceAdditionalData.PlayActive)
3282  {
3283  RequestCompletion(deviceExtension, Request, STATUS_DEVICE_BUSY, 0);
3284 
3285  return;
3286  }
3287 
3288  // Fail READ/WRITE requests from non-owners if the drive is locked
3289  if (EXCLUSIVE_MODE(cdData) && !EXCLUSIVE_OWNER(cdData, WdfRequestGetFileObject(Request)))
3290  {
3291  RequestCompletion(deviceExtension, Request, STATUS_ACCESS_DENIED, 0);
3292 
3293  return;
3294  }
3295 
3296  // Succeed READ/WRITE requests of length 0
3297  if (Length == 0)
3298  {
3299  // Several parts of the code turn 0 into 0xffffffff,
3300  // so don't process a zero-length request any further.
3301  RequestCompletion(deviceExtension, Request, STATUS_SUCCESS, Length);
3302 
3303  return;
3304  }
3305 
3306  // If there is an unexpected write request, we want to rediscover MMC capabilities
3307  if (!deviceExtension->DeviceAdditionalData.Mmc.WriteAllowed &&
3308  (requestParameters.Type == WdfRequestTypeWrite))
3309  {
3310  // Schedule MMC capabilities update now, but perform it later in a work item
3312  }
3313 
3314  // If MMC capabilities update is required, we create a separate work item to avoid blocking
3315  // the current thread; otherwise, we initiate an async read/write in the current thread.
3316  if (DeviceIsMmcUpdateRequired(deviceExtension->Device))
3317  {
3319  WdfWorkItemEnqueue(deviceExtension->ReadWriteWorkItem);
3320 
3322  }
3323  else
3324  {
3325  status = RequestValidateReadWrite(deviceExtension, Request, requestParameters);
3326 
3327  if (NT_SUCCESS(status))
3328  {
3329  status = RequestHandleReadWrite(deviceExtension, Request, requestParameters);
3330  }
3331  }
3332 
3333  if (!NT_SUCCESS(status))
3334  {
3335  RequestCompletion(deviceExtension, Request, status, 0);
3336  }
3337  }
3338 
3339  return;
3340 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOLEAN WriteAllowed
Definition: cdrom.h:250
#define CDROM_VOLUME_VERIFY_CHECKED
Definition: cdromp.h:171
WDFWORKITEM ReadWriteWorkItem
Definition: cdrom.h:608
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2221
CDROM_DATA DeviceAdditionalData
Definition: cdrom.h:598
LONG NTSTATUS
Definition: precomp.h:26
WDF_REQUEST_TYPE Type
Definition: wdfrequest.h:142
#define DO_VERIFY_VOLUME
Definition: env_spec_w32.h:393
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
CDROM_READ_WRITE_CONTEXT ReadWriteWorkItemContext
Definition: cdrom.h:609
#define STATUS_VERIFY_REQUIRED
Definition: udferr_usr.h:130
VOID RequestCompletion(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ NTSTATUS Status, _In_ ULONG_PTR Information)
Definition: common.c:3439
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
Definition: devices.h:37
WDFREQUEST OriginalRequest
Definition: cdrom.h:335
NTSTATUS RequestValidateReadWrite(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters)
Definition: ioctl.c:6117
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1803
BOOLEAN PlayActive
Definition: cdrom.c:68
NTSTATUS RequestHandleReadWrite(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters)
Definition: ioctl.c:6353
#define TEST_FLAG(Flags, Bit)
Definition: cdrom.h:1495
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define EXCLUSIVE_MODE(_CdData)
Definition: cdrom.h:788
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define EXCLUSIVE_OWNER(_CdData, _FileObject)
Definition: cdrom.h:789
WDFDEVICE Device
Definition: cdrom.h:473
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define STATUS_DEVICE_BUSY
Definition: udferr_usr.h:129
FORCEINLINE VOID WDF_REQUEST_PARAMETERS_INIT(_Out_ PWDF_REQUEST_PARAMETERS Parameters)
Definition: wdfrequest.h:211
#define CdromMmcUpdateRequired
Definition: cdrom.h:242
CDROM_MMC_EXTENSION Mmc
Definition: cdrom.h:341
BOOLEAN DeviceIsMmcUpdateRequired(_In_ WDFDEVICE Device)
Definition: cdrom.c:4180
unsigned int ULONG
Definition: retypes.h:1
PDEVICE_OBJECT DeviceObject
Definition: cdrom.h:493
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: ps.c:97

Referenced by DriverEvtDeviceAdd().

◆ TimeOutValueGetCapValue()

__inline ULONG TimeOutValueGetCapValue ( _In_ ULONG  TimeOutValue,
_In_ ULONG  Times 
)

Definition at line 1569 of file cdrom.h.

1573 {
1574  ULONG value = 0;
1575 
1576  if (TimeOutValue > SCSI_CDROM_OPC_TIMEOUT)
1577  {
1578  // if time out value is specified by user in registry, and is
1579  // bigger than OPC time out, it should be big enough
1580  value = TimeOutValue;
1581  }
1582  else
1583  {
1584  // otherwise, OPC time out value should be the upper limit
1585  value = min(TimeOutValue * Times, SCSI_CDROM_OPC_TIMEOUT);
1586  }
1587 
1588  return value;
1589 }
#define SCSI_CDROM_OPC_TIMEOUT
Definition: cdrom.h:688
GLsizei const GLfloat * value
Definition: glext.h:6069
#define min(a, b)
Definition: monoChain.cc:55
unsigned int ULONG
Definition: retypes.h:1

Referenced by DeviceScratchSyncCache(), RequestHandleQueryPropertyWriteCache(), and RequestIssueShutdownFlush().

◆ ValidChar()

__inline BOOLEAN ValidChar ( UCHAR  Ch)

Definition at line 812 of file cdrom.h.

813 {
814  if (((Ch >= '0') && (Ch <= '9')) ||
815  (((Ch|0x20) >= 'a') && ((Ch|0x20) <= 'z')) ||
816  (strchr(" .,:;_-", Ch) != NULL))
817  {
818  return TRUE;
819  }
820  return FALSE;
821 }
#define TRUE
Definition: types.h:120
#define Ch(x, y, z)
Definition: sha2.c:141
#define FALSE
Definition: types.h:117
#define NULL
Definition: types.h:112
char * strchr(const char *String, int ch)
Definition: utclib.c:501

Variable Documentation

◆ BufferAddress

◆ BufferLength

◆ CdromHackItems

CDROM_SCAN_FOR_SPECIAL_INFO CdromHackItems[]

Definition at line 44 of file data.c.

◆ CompletionRoutine

◆ Context