36#include "pnppower.tmh"
63#pragma alloc_text(PAGE, DevicePowerSettingCallback)
68#pragma warning(disable:4152)
70#pragma warning(disable:28118)
191 IrpMarkedPending =
TRUE;
199#pragma warning(disable: 28193)
207 if (IrpMarkedPending)
240 ULONG transferSize = 0;
281 ULONG transferSize = 0;
293 status = ScratchBuffer_ExecuteCdb(DeviceExtension,
NULL, transferSize,
FALSE, &cdb, 6);
326 ULONG transferSize = 0;
328 ULONG timesAlreadyRetried = 0;
339 ScratchBuffer_SetupSrb(DeviceExtension,
NULL, transferSize,
FALSE);
366 status = WdfRequestGetStatus(DeviceExtension->ScratchContext.ScratchRequest);
393 PowerContextEndUse(deviceExtension);
430 if (
Irp->PendingReturned)
447 (
VOID)DeviceSendPowerDownProcessRequest(deviceExtension,
458 PowerContextEndUse(deviceExtension);
467PowerContextReuseRequest(
490 RtlZeroMemory(&(DeviceExtension->PowerContext.SenseData),
sizeof(DeviceExtension->PowerContext.SenseData));
491 RtlZeroMemory(&(DeviceExtension->PowerContext.Srb),
sizeof(DeviceExtension->PowerContext.Srb));
493 irp = WdfRequestWdmGetIrp(DeviceExtension->PowerContext.PowerRequest);
497 status = WdfRequestReuse(DeviceExtension->PowerContext.PowerRequest, &reuseParams);
501 status = WdfIoTargetFormatRequestForInternalIoctlOthers(DeviceExtension->IoTarget,
502 DeviceExtension->PowerContext.PowerRequest,
511 "PowerContextReuseRequest: WdfIoTargetFormatRequestForInternalIoctlOthers failed, %!STATUS!\n",
525 nextStack->
Parameters.
Scsi.Srb = &(DeviceExtension->PowerContext.Srb);
528 DeviceExtension->PowerContext.Srb.OriginalRequest =
irp;
530 DeviceExtension->PowerContext.Srb.SenseInfoBuffer = &(DeviceExtension->PowerContext.SenseData);
560 NT_ASSERT(!DeviceExtension->PowerContext.InUse);
562 DeviceExtension->PowerContext.InUse =
TRUE;
564 DeviceExtension->PowerContext.RetryIntervalIn100ns = 0;
568 RtlZeroMemory(&(DeviceExtension->PowerContext.Options),
sizeof(DeviceExtension->PowerContext.Options));
569 RtlZeroMemory(&(DeviceExtension->PowerContext.PowerChangeState),
sizeof(DeviceExtension->PowerContext.PowerChangeState));
571 status = PowerContextReuseRequest(DeviceExtension);
599 NT_ASSERT(DeviceExtension->PowerContext.InUse);
601 DeviceExtension->PowerContext.InUse =
FALSE;
673 DeviceMarkActive(DeviceExtension,
FALSE,
TRUE);
679 DeviceMarkActive(DeviceExtension,
TRUE,
TRUE);
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
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)
EVT_WDFDEVICE_WDM_IRP_PREPROCESS RequestProcessSetPower
POWER_SETTING_CALLBACK DevicePowerSettingCallback
#define CLEAR_FLAG(Flags, Bit)
#define SET_FLAG(Flags, Bit)
EVT_WDFDEVICE_WDM_IRP_PREPROCESS RequestProcessShutdownFlush
VOID RequestClearSendTime(_In_ WDFREQUEST Request)
FORCEINLINE ULONG TimeOutValueGetCapValue(_In_ ULONG TimeOutValue, _In_ ULONG Times)
#define IOCTL_SCSI_EXECUTE_IN
#define SCSIOP_MEDIUM_REMOVAL
#define SENSE_BUFFER_SIZE
#define SCSIOP_SYNCHRONIZE_CACHE
#define NT_SUCCESS(StatCode)
struct _SCSI_REQUEST_BLOCK SCSI_REQUEST_BLOCK
#define SRB_SIMPLE_TAG_REQUEST
#define SRB_FUNCTION_FLUSH
#define SRB_FUNCTION_SHUTDOWN
#define SRB_FLAGS_NO_KEEP_AWAKE
#define _IRQL_requires_same_
#define _IRQL_requires_max_(irql)
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
#define _Function_class_(x)
#define _In_reads_bytes_(size)
#define _In_reads_opt_(size)
#define _Analysis_assume_(expr)
#define UNREFERENCED_PARAMETER(P)
#define IoSkipCurrentIrpStackLocation(Irp)
#define IoCopyCurrentIrpStackLocationToNext(Irp)
#define IoCompleteRequest
#define STATUS_NOT_SUPPORTED
NTSTATUS RequestIssueShutdownFlush(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ PIRP Irp)
NTSTATUS DeviceScratchPreventMediaRemoval(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ BOOLEAN Prevent)
NTSTATUS DeviceScratchSyncCache(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension)
IO_COMPLETION_ROUTINE RequestProcessPowerIrpCompletion
EVT_WDF_REQUEST_COMPLETION_ROUTINE RequestUnlockQueueCompletion
#define IsEqualGUID(rguid1, rguid2)
NTSTATUS ScratchBuffer_SendSrb(_Inout_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ BOOLEAN SynchronousSrb, _When_(SynchronousSrb, _Pre_null_) _When_(!SynchronousSrb, _In_opt_) PSRB_HISTORY_ITEM *SrbHistoryItem)
FORCEINLINE VOID ScratchBuffer_EndUse(_Inout_ PCDROM_DEVICE_EXTENSION DeviceExtension)
#define ScratchBuffer_BeginUse(context)
#define KeQueryTickCount(CurrentCount)
#define STATUS_MORE_PROCESSING_REQUIRED
#define TRACE_LEVEL_ERROR
CDROM_POWER_CONTEXT PowerContext
WDFWAITLOCK ShutdownFlushWaitLock
PMEDIA_CHANGE_DETECTION_INFO MediaChangeDetectionInfo
union _CDROM_POWER_CONTEXT::@1054 PowerChangeState
CDROM_POWER_OPTIONS Options
CDROM_POWER_DOWN_STATE PowerDown
struct _IO_STACK_LOCATION::@3974::@3996 Scsi
struct _IO_STACK_LOCATION::@3974::@4010 Power
union _IO_STACK_LOCATION::@1575 Parameters
#define RtlZeroMemory(Destination, Length)
struct _CDB::_MEDIA_REMOVAL MEDIA_REMOVAL
struct _CDB::_SYNCHRONIZE_CACHE10 SYNCHRONIZE_CACHE10
_Must_inspect_result_ _In_ WDFDEVICE Device
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
@ WDF_REQUEST_REUSE_NO_FLAGS
FORCEINLINE VOID WDF_REQUEST_REUSE_PARAMS_INIT(_Out_ PWDF_REQUEST_REUSE_PARAMS Params, _In_ ULONG Flags, _In_ NTSTATUS Status)
_Must_inspect_result_ FORCEINLINE NTSTATUS WdfWaitLockAcquire(_In_ _Requires_lock_not_held_(_Curr_) WDFWAITLOCK Lock, _In_opt_ PLONGLONG Timeout)
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
#define STATUS_CONTINUE_COMPLETION
enum _MONITOR_DISPLAY_STATE MONITOR_DISPLAY_STATE