39#define GESN_TIMEOUT_VALUE (0x4)
40#define GESN_BUFFER_SIZE (0x8)
41#define GESN_DEVICE_BUSY_LOWER_THRESHOLD_100_MS (2)
43#define MAXIMUM_IMMEDIATE_MCN_RETRIES (0x20)
44#define MCN_REG_SUBKEY_NAME (L"MediaChangeNotification")
45#define MCN_REG_AUTORUN_DISABLE_INSTANCE_NAME (L"AlwaysDisableMCN")
46#define MCN_REG_AUTORUN_ENABLE_INSTANCE_NAME (L"AlwaysEnableMCN")
68DeviceIsMediaChangeDisabledDueToHardwareLimitation(
74DeviceIsMediaChangeDisabledForClass(
80DeviceMediaChangeDeviceInstanceOverride(
112#pragma alloc_text(PAGE, DeviceInitializeMediaChangeDetection)
113#pragma alloc_text(PAGE, DeviceEnableMediaChangeDetection)
114#pragma alloc_text(PAGE, DeviceDisableMediaChangeDetection)
115#pragma alloc_text(PAGE, DeviceSendDelayedMediaChangeNotifications)
116#pragma alloc_text(PAGE, DeviceReleaseMcnResources)
117#pragma alloc_text(PAGE, DeviceMediaChangeRegistryCallBack)
118#pragma alloc_text(PAGE, DeviceInitializeMcn)
119#pragma alloc_text(PAGE, DeviceDisableGesn)
121#pragma alloc_text(PAGE, DeviceIsMediaChangeDisabledDueToHardwareLimitation)
122#pragma alloc_text(PAGE, DeviceMediaChangeDeviceInstanceOverride)
123#pragma alloc_text(PAGE, DeviceIsMediaChangeDisabledForClass)
125#pragma alloc_text(PAGE, DeviceDisableMainTimer)
127#pragma alloc_text(PAGE, GesnDataInterpret)
129#pragma alloc_text(PAGE, RequestSetupMcnRequest)
130#pragma alloc_text(PAGE, RequestPostWorkMcnRequest)
131#pragma alloc_text(PAGE, RequestSendMcnRequest)
139#pragma alloc_text(PAGE, DeviceInitializeGesn)
141#pragma alloc_text(PAGE, RequestHandleMcnControl)
146#pragma warning(disable:4152)
214 LONG requiredLength = 0;
221 *ResendImmediately =
FALSE;
239 if (
info->Gesn.HackEventMask)
245 UCHAR thisEventBit = (1 <<
Header->NotificationClass);
254 lowestSetBit =
info->Gesn.EventMask;
255 lowestSetBit &= (
info->Gesn.EventMask - 1);
256 lowestSetBit ^= (
info->Gesn.EventMask);
258 if (thisEventBit != lowestSetBit)
266 "GESN::NONE: Compliant drive found, "
267 "removing GESN hack (%x, %x)\n",
268 thisEventBit,
info->Gesn.EventMask));
272 else if (thisEvent == 0)
285 if (
info->Gesn.EventMask == 0)
287 info->Gesn.EventMask =
info->Gesn.NoChangeEventMask;
288 info->Gesn.NoChangeEventMask = 0;
292 *ResendImmediately =
TRUE;
300 (
Header->EventDataLength[1] & 0xff);
307 "error - GESN returned only %x bytes data for fdo %p\n",
316 "error - GESN returned too many (%x) bytes data for fdo %p\n",
320 if ((
Header->ClassEventData[0] & 0xf) == 0)
328 *ResendImmediately =
TRUE;
330 switch (
Header->NotificationClass)
344 event = (opChangeInfo->
Operation[0] << 8) |
352 if (
info->MediaChangeRetryCount >= 4)
366 static UCHAR const OpChangeMask = 0x02;
373 "GESN OpChange events are broken. Working around this problem in software (for WDFDEVICE %p)\n",
374 DeviceExtension->Device));
387 if (
info->Gesn.EventMask == 0)
389 info->Gesn.EventMask =
info->Gesn.NoChangeEventMask;
390 info->Gesn.NoChangeEventMask = 0;
391 *ResendImmediately =
FALSE;
395 *ResendImmediately =
TRUE;
406 "GESN says features added/changed for WDFDEVICE %p\n",
407 DeviceExtension->Device));
441 if (DeviceExtension->DeviceAdditionalData.ErrorHandler)
443 DeviceExtension->DeviceAdditionalData.ErrorHandler(DeviceExtension,
469 "GESN::EXTERNAL: Event: %x Status %x Req %x\n",
478 (externalInfo->
Request[1] & 0xff);
483 &GUID_IO_DEVICE_EXTERNAL_REQUEST,
499 "GESN::MEDIA ARRIVAL, Status %x\n",
512 if ((DeviceExtension->ZeroPowerODDInfo !=
NULL) &&
514 (DeviceExtension->ZeroPowerODDInfo->Load == 0))
517 "GesnDataInterpret: MediaArrival event detected, device marked as active\n"));
519 DeviceMarkActive(DeviceExtension,
TRUE,
FALSE);
525 "GESN::MEDIA REMOVAL, Status %x\n",
534 if ((DeviceExtension->ZeroPowerODDInfo !=
NULL) &&
536 (DeviceExtension->ZeroPowerODDInfo->Load == 0))
539 "GesnDataInterpret: MediaRemoval event detected, device marked as idle\n"));
541 DeviceMarkActive(DeviceExtension,
FALSE,
FALSE);
547 "GESN::MEDIA EJECTION, Status %x\n",
551 &GUID_IO_MEDIA_EJECT_REQUEST,
569 (busyInfo->
Time[1] & 0xff);
572 "GESN::BUSY: Event: %x Status %x Time %x\n",
581 "GesnDataInterpret: media BECOMING_READY\n"));
584 &GUID_IO_DEVICE_BECOMING_READY,
591 if ((DeviceExtension->ZeroPowerODDInfo !=
NULL) &&
593 (DeviceExtension->ZeroPowerODDInfo->Load == 0) &&
597 inHomePosition = DeviceZPODDIsInHomePosition(DeviceExtension);
599 if (inHomePosition ==
FALSE)
602 "GesnDataInterpret: LoChange event detected, device marked as active\n"));
604 DeviceMarkActive(DeviceExtension,
TRUE,
FALSE);
609 "GesnDataInterpret: LoChange event detected, device marked as idle\n"));
611 DeviceMarkActive(DeviceExtension,
FALSE,
FALSE);
663 LPCSTR states[] = {
"Unknown",
"Present",
"Not Present",
"Unavailable"};
679 oldMediaState =
info->LastKnownMediaDetectionState;
682 *OldState = oldMediaState;
685 info->LastKnownMediaDetectionState = NewState;
688 if (NewState ==
MediaPresent && oldMediaState != NewState)
693 if (
info->MediaChangeDetectionDisableCount != 0)
697 "DeviceInternalSetMediaChangeState: MCN not enabled, state "
698 "changed from %s to %s\n",
699 states[oldMediaState], states[NewState]));
705 "DeviceInternalSetMediaChangeState: State change from %s to %s\n",
706 states[oldMediaState], states[NewState]));
709 if (
info->LastReportedMediaDetectionState ==
info->LastKnownMediaDetectionState)
722 "DeviceInternalSetMediaChangeState: Reporting media ARRIVAL\n"));
725 &GUID_IO_MEDIA_ARRIVAL,
732 "DeviceInternalSetMediaChangeState: Reporting media REMOVAL\n"));
734 &GUID_IO_MEDIA_REMOVAL,
744 info->LastReportedMediaDetectionState =
info->LastKnownMediaDetectionState;
814DeviceSendDelayedMediaChangeNotifications(
865 if ((
info->LastKnownMediaDetectionState !=
info->LastReportedMediaDetectionState) &&
866 (
info->MediaChangeDetectionDisableCount == 0))
879RequestSetupMcnRequest(
910 irp = WdfRequestWdmGetIrp(
info->MediaChangeRequest);
933 status = WdfIoTargetFormatRequestForInternalIoctlOthers(DeviceExtension->IoTarget,
934 info->MediaChangeRequest,
943 "RequestSetupMcnRequest: WdfIoTargetFormatRequestForInternalIoctlOthers failed, %!STATUS!\n",
974 srb->
SrbFlags = DeviceExtension->SrbFlags;
1002 irp->MdlAddress =
info->Gesn.Mdl;
1045 DeviceSetParameter(deviceExtension,
1057RequestPostWorkMcnRequest(
1087 irp = WdfRequestWdmGetIrp(
info->MediaChangeRequest);
1095 TracePrint((
TRACE_LEVEL_WARNING, TRACE_FLAG_MCN,
"MCN request - failed - srb status=%x, sense=%x/%x/%x.\n",
1096 info->MediaChangeSrb.SrbStatus,
1098 ((
PSENSE_DATA)(
info->MediaChangeSrb.SenseInfoBuffer))->AdditionalSenseCode,
1099 ((
PSENSE_DATA)(
info->MediaChangeSrb.SenseInfoBuffer))->AdditionalSenseCodeQualifier));
1110 info->MediaChangeRequest,
1111 &
info->MediaChangeSrb,
1119 DeviceExtension->PrivateFdoData->LoggedTURFailureSinceLastIO =
FALSE;
1121 if (!
info->Gesn.Supported)
1124 "MCN request - succeeded (GESN NOT supported, setting MediaPresent).\n"));
1134 "MCN request - succeeded (GESN supported).\n"));
1138 if (
info->Gesn.Supported)
1154 if (
irp->IoStatus.Information == 8 )
1156 GesnDataInterpret(DeviceExtension,
1176 if (retryImmediately)
1178 info->MediaChangeRetryCount++;
1186 WDFWORKITEM workItem;
1194 status = WdfWorkItemCreate(&workitemConfig,
1198 TracePrint((
TRACE_LEVEL_INFORMATION, TRACE_FLAG_MCN,
"MCN Request: Disabling GESN for WDFDEVICE %p\n", DeviceExtension->Device));
1202 WdfWorkItemEnqueue(workItem);
1206 info->Gesn.EventMask = 0;
1207 info->Gesn.BufferSize = 0;
1208 info->MediaChangeRetryCount = 0;
1209 retryImmediately =
FALSE;
1215 info->MediaChangeRetryCount = 0;
1218 return retryImmediately;
1224RequestSendMcnRequest(
1248 info->MediaChangeRequest,
1249 DeviceExtension->IoTarget,
1289 if (DeviceExtension->MediaChangeDetectionInfo !=
NULL)
1295 DeviceExtension->KernelModeMcnContext.FileObject = (
PVOID)-1;
1296 DeviceExtension->KernelModeMcnContext.DeviceObject = (
PVOID)-1;
1297 DeviceExtension->KernelModeMcnContext.LockCount = 0;
1298 DeviceExtension->KernelModeMcnContext.McnDisableCount = 0;
1304 if (mediaChangeInfo ==
NULL)
1315 if ((DeviceExtension->PowerDescriptor !=
NULL) &&
1316 (DeviceExtension->PowerDescriptor->AsynchronousNotificationSupported !=
FALSE) &&
1339 status = WdfRequestCreate(&attributes,
1340 DeviceExtension->IoTarget,
1348 status = WdfIoTargetFormatRequestForInternalIoctlOthers(DeviceExtension->IoTarget,
1361 if (senseBuffer ==
NULL)
1396 DeviceExtension->MediaChangeDetectionInfo = mediaChangeInfo;
1404 "DeviceInitializeMcn: Testing for GESN\n"));
1405 tempStatus = DeviceInitializeGesn(DeviceExtension);
1410 "DeviceInitializeMcn: GESN available for %p\n",
1411 DeviceExtension->DeviceObject));
1420 "DeviceInitializeMcn: GESN *NOT* available for %p\n",
1421 DeviceExtension->DeviceObject));
1426 mediaChangeInfo->
Gesn.Supported =
FALSE;
1443 sizeof(PlatformInfo));
1448 &GUID_CONSOLE_DISPLAY_STATE,
1476DeviceInitializeGesn(
1500 ULONG atapiResets = 0;
1508 DeviceGetParameter(DeviceExtension,
1511 (
PULONG)&detectionState);
1522 DeviceSetParameter(DeviceExtension,
1568 info->Gesn.EventMask = 0;
1578 for (
i = 0; (
i < 16) && retryImmediately;
i++)
1580 status = RequestSetupMcnRequest(DeviceExtension,
TRUE);
1585 "Setup Mcn request failed %x for WDFDEVICE %p\n",
1586 status, DeviceExtension->Device));
1592 status = DeviceSendRequestSynchronously(DeviceExtension->Device,
info->MediaChangeRequest,
TRUE);
1603 info->MediaChangeRequest,
1604 &(
info->MediaChangeSrb),
1623 if (atapiResets >= 4)
1642 DeviceSetParameter( DeviceExtension,
1647 "GESN test failed %x for WDFDEVICE %p\n",
1648 status, DeviceExtension->Device));
1657 "GESN test failed %x for WDFDEVICE %p\n",
1658 status, DeviceExtension->Device));
1668 "WDFDEVICE %p supports event mask %x\n",
1669 DeviceExtension->Device,
header->SupportedEventClasses));
1675 "GESN supports MCN\n"));
1681 "GESN supports DeviceBusy\n"));
1686 if (
TEST_FLAG(DeviceExtension->PrivateFdoData->HackFlags,
1690 "GESN supports OpChange, but must ignore these events for compatibility\n"));
1697 "GESN supports OpChange\n"));
1700 info->Gesn.EventMask =
header->SupportedEventClasses;
1729 if (
info->Gesn.EventMask == 0)
1732 "GESN supported, but not mask we care about (%x) for FDO %p\n",
1733 header->SupportedEventClasses,
1734 DeviceExtension->DeviceObject));
1741 "GESN hack not required for FDO %p\n",
1742 DeviceExtension->DeviceObject));
1747 "GESN hack enabled for FDO %p\n",
1748 DeviceExtension->DeviceObject));
1749 info->Gesn.HackEventMask = 1;
1755 status = GesnDataInterpret(DeviceExtension,
1762 DeviceSetParameter( DeviceExtension,
1790 "Enabling GESN support for WDFDEVICE %p\n",
1791 DeviceExtension->Device));
1794 DeviceSetParameter( DeviceExtension,
1802 "GESN available but not enabled for WDFDEVICE %p\n",
1803 DeviceExtension->Device));
1811 "GESN support detection failed for WDFDEVICE %p with status %08x\n",
1812 DeviceExtension->Device,
status));
1816 PIRP irp = WdfRequestWdmGetIrp(
info->MediaChangeRequest);
1825 info->Gesn.EventMask = 0;
1826 info->Gesn.BufferSize = 0;
1835DeviceInitializeMediaChangeDetection(
1874 disabled = DeviceIsMediaChangeDisabledDueToHardwareLimitation(DeviceExtension);
1879 "DeviceInitializeMediaChangeDetection: Disabled due to hardware"
1880 "limitations for this device\n"));
1885 disabled = DeviceIsMediaChangeDisabledForClass(DeviceExtension);
1888 "DeviceInitializeMediaChangeDetection: MCN is %s\n",
1889 (disabled ?
"disabled" :
"enabled")));
1891 status = DeviceMediaChangeDeviceInstanceOverride(DeviceExtension,
1897 "DeviceInitializeMediaChangeDetection: Instance using default\n"));
1902 "DeviceInitializeMediaChangeDetection: Instance override: %s MCN\n",
1903 (instanceOverride ?
"Enabling" :
"Disabling")));
1904 disabled = !instanceOverride;
1908 "DeviceInitializeMediaChangeDetection: Instance MCN is %s\n",
1909 (disabled ?
"disabled" :
"enabled")));
1915 status = DeviceInitializeMcn(DeviceExtension,
FALSE);
1924DeviceMediaChangeDeviceInstanceOverride(
1948 WDFKEY deviceKey =
NULL;
1949 WDFKEY subKey =
NULL;
1954 ULONG alwaysEnable = 0;
1955 ULONG alwaysDisable = 0;
1959 status = WdfDeviceOpenRegistryKey(DeviceExtension->Device,
1969 "DeviceMediaChangeDeviceInstanceOverride: "
1970 "Could not open device registry key [%lx]\n",
status));
1976 status = WdfRegistryOpenKey(deviceKey,
1986 "DeviceMediaChangeDeviceInstanceOverride: "
1987 "subkey could not be created. %lx\n",
status));
1997 (
VOID) WdfRegistryQueryULong(subKey,
1998 &enableMcnValueName,
2000 (
VOID) WdfRegistryQueryULong(subKey,
2001 &disableMcnValueName,
2009 WdfRegistryClose(subKey);
2012 if (deviceKey !=
NULL)
2014 WdfRegistryClose(deviceKey);
2017 if (alwaysEnable && alwaysDisable)
2020 "DeviceMediaChangeDeviceInstanceOverride: %s selected\n",
2021 "Both Enable and Disable set -- DISABLE"));
2026 else if (alwaysDisable)
2029 "DeviceMediaChangeDeviceInstanceOverride: %s selected\n",
2035 else if (alwaysEnable)
2038 "DeviceMediaChangeDeviceInstanceOverride: %s selected\n",
2047 "DeviceMediaChangeDeviceInstanceOverride: %s selected\n",
2102 "DeviceMediaChangeRegistryCallBack: NULL context should never be passed to registry call-back!\n"));
2109 if ((*valueFound) != 0)
2112 "DeviceMediaChangeRegistryCallBack: already set to true\n"));
2119 "DeviceMediaChangeRegistryCallBack: NULL string should never be passed to registry call-back!\n"));
2139 if (keyValue ==
NULL)
2147 TracePrint((
TRACE_LEVEL_VERBOSE, TRACE_FLAG_MCN,
"DeviceMediaChangeRegistryCallBack: Match found\n"));
2148 TracePrint((
TRACE_LEVEL_VERBOSE, TRACE_FLAG_MCN,
"DeviceMediaChangeRegistryCallBack: DeviceString at %p\n",
2151 "DeviceMediaChangeRegistryCallBack: KeyValue at %p\n",
2153 (*valueFound) =
TRUE;
2162DeviceIsMediaChangeDisabledDueToHardwareLimitation(
2201 ULONG mediaChangeNotificationDisabled = 0;
2237 serviceKey = WdfRegistryWdmGetHandle(wdfKey);
2240 if ((deviceDescriptor->VendorIdOffset == 0) &&
2241 (deviceDescriptor->ProductIdOffset == 0))
2253 if (deviceDescriptor->VendorIdOffset == 0)
2259 vendorId = (
PUCHAR) deviceDescriptor + deviceDescriptor->VendorIdOffset;
2263 if ( deviceDescriptor->ProductIdOffset == 0 )
2269 productId = (
PUCHAR) deviceDescriptor + deviceDescriptor->ProductIdOffset;
2273 if ( deviceDescriptor->ProductRevisionOffset == 0 )
2279 revisionId = (
PUCHAR) deviceDescriptor + deviceDescriptor->ProductRevisionOffset;
2293 "DeviceIsMediaChangeDisabledDueToHardwareLimitation: Unable to alloc string buffer\n" ));
2303 if (vendorId !=
NULL)
2311 if ( productId !=
NULL )
2318 if ( revisionId !=
NULL )
2328 #pragma warning(suppress:6386)
2339 "DeviceIsMediaChangeDisabledDueToHardwareLimitation: cannot convert "
2340 "to unicode %lx\n",
status));
2347 nullMultiSz =
L"\0";
2350 parameters[0].
Name =
L"AutoRunAlwaysDisable";
2351 parameters[0].
EntryContext = &mediaChangeNotificationDisabled;
2359 &deviceUnicodeString,
2375 WdfRegistryClose(wdfKey);
2378 if (mediaChangeNotificationDisabled > 0)
2381 "DeviceIsMediaChangeDisabledDueToHardwareLimitation: Device is on MCN disable list\n"));
2384 return (mediaChangeNotificationDisabled > 0);
2391DeviceIsMediaChangeDisabledForClass(
2417 WDFKEY serviceKey =
NULL;
2418 WDFKEY parametersKey =
NULL;
2424 ULONG mcnRegistryValue = 1;
2438 "DeviceIsMediaChangeDisabledForClass: Defaulting to %s\n",
2439 (mcnRegistryValue ?
"Enabled" :
"Disabled")));
2440 return (
BOOLEAN)(mcnRegistryValue == 0);
2447 status = WdfRegistryOpenKey(serviceKey,
2456 parametersKey =
NULL;
2461 status = WdfRegistryQueryULong(serviceKey,
2468 "DeviceIsMediaChangeDisabledForClass: <Service>/Autorun flag = %d\n",
2472 if (parametersKey !=
NULL)
2474 status = WdfRegistryQueryULong(parametersKey,
2481 "DeviceIsMediaChangeDisabledForClass: <Service>/Parameters/Autorun flag = %d\n",
2485 WdfRegistryClose(parametersKey);
2488 WdfRegistryClose(serviceKey);
2491 "DeviceIsMediaChangeDisabledForClass: Autoplay for device %p is %s\n",
2492 DeviceExtension->DeviceObject,
2493 (mcnRegistryValue ?
"on" :
"off")
2499 return (
BOOLEAN)(!mcnRegistryValue);
2505DeviceEnableMediaChangeDetection(
2542 "DeviceEnableMediaChangeDetection: not initialized\n"));
2552 oldCount = --
info->MediaChangeDetectionDisableCount;
2557 "DeviceEnableMediaChangeDetection: Disable count reduced to %d - \n",
2558 info->MediaChangeDetectionDisableCount));
2564 info->LastReportedMediaDetectionState =
info->LastKnownMediaDetectionState;
2583DeviceDisableMediaChangeDetection(
2624 info->MediaChangeDetectionDisableCount++;
2627 "DisableMediaChangeDetection: disable count is %d\n",
2628 info->MediaChangeDetectionDisableCount));
2638DeviceReleaseMcnResources(
2669 PIRP irp = WdfRequestWdmGetIrp(
info->MediaChangeRequest);
2677 if (
info->DisplayStateCallbackHandle)
2679 PoUnregisterPowerSettingCallback(
info->DisplayStateCallbackHandle);
2680 info->DisplayStateCallbackHandle =
NULL;
2685 DeviceExtension->MediaChangeDetectionInfo =
NULL;
2771 irp = DeviceExtension->MediaChangeDetectionInfo->MediaChangeSyncIrp;
2786 irpStack->
DeviceObject = DeviceExtension->DeviceObject;
2852DeviceEnableMainTimer(
2873 if ((DeviceExtension->MediaChangeDetectionInfo ==
NULL) ||
2874 (DeviceExtension->MediaChangeDetectionInfo->AsynchronousNotificationSupported !=
FALSE))
2880 if (DeviceExtension->MainTimer ==
NULL)
2893 timerConfig.
Period = 2000;
2897 timerConfig.
Period = 1000;
2907 timerAttributes.
ParentObject = DeviceExtension->Device;
2910 status = WdfTimerCreate(&timerConfig,
2912 &DeviceExtension->MainTimer);
2920 "DeviceEnableMainTimer: Once a second timer enabled for WDFDEVICE %p\n",
2921 DeviceExtension->Device));
2926 "DeviceEnableMainTimer: WDFDEVICE %p, Status %lx initializing timer\n",
2927 DeviceExtension->Device,
status));
2936DeviceDisableMainTimer(
2956 if ((DeviceExtension->MediaChangeDetectionInfo ==
NULL) ||
2957 (DeviceExtension->MediaChangeDetectionInfo->AsynchronousNotificationSupported !=
FALSE))
2963 if (DeviceExtension->MainTimer !=
NULL)
2972 WdfTimerStop(DeviceExtension->MainTimer,
TRUE);
2975 "DeviceDisableMainTimer: Once a second timer disabled for device %p\n",
2976 DeviceExtension->Device));
2981 "DeviceDisableMainTimer: Timer never enabled\n"));
2990RequestHandleMcnControl(
3017 WDFFILEOBJECT fileObject =
NULL;
3032 fileObject = WdfRequestGetFileObject(
Request);
3036 if (fileObject !=
NULL)
3038 fileObjectContext = FileObjectGetContext(fileObject);
3041 if ((fileObjectContext ==
NULL) &&
3044 fileObjectContext = &DeviceExtension->KernelModeMcnContext;
3047 if (fileObjectContext ==
NULL)
3061 DeviceDisableMediaChangeDetection(DeviceExtension, fileObjectContext);
3071 DeviceEnableMediaChangeDetection(DeviceExtension, fileObjectContext,
TRUE);
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
ACPI_SIZE strlen(const char *String)
#define InterlockedIncrement
#define InterlockedDecrement
IO_COMPLETION_ROUTINE RequestMcnSyncIrpCompletion
#define MCN_REG_SUBKEY_NAME
#define GESN_TIMEOUT_VALUE
#define MCN_REG_AUTORUN_ENABLE_INSTANCE_NAME
VOID RequestSetupMcnSyncIrp(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension)
VOID NTAPI DeviceDisableGesn(_In_ WDFWORKITEM WorkItem)
VOID DeviceSetMediaChangeStateEx(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ MEDIA_CHANGE_DETECTION_STATE NewState, _Inout_opt_ PMEDIA_CHANGE_DETECTION_STATE OldState)
VOID DeviceInternalSetMediaChangeState(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ MEDIA_CHANGE_DETECTION_STATE NewState, _Inout_opt_ PMEDIA_CHANGE_DETECTION_STATE OldState)
#define MAXIMUM_IMMEDIATE_MCN_RETRIES
#define GESN_DEVICE_BUSY_LOWER_THRESHOLD_100_MS
NTSTATUS NTAPI DeviceMediaChangeRegistryCallBack(_In_z_ PWSTR ValueName, _In_ ULONG ValueType, _In_reads_bytes_opt_(ValueLength) PVOID ValueData, _In_ ULONG ValueLength, _In_opt_ PVOID Context, _In_opt_ PVOID EntryContext)
#define MCN_REG_AUTORUN_DISABLE_INSTANCE_NAME
EVT_WDF_TIMER DeviceMainTimerTickHandler
struct _CDROM_DEVICE_EXTENSION * PCDROM_DEVICE_EXTENSION
FORCEINLINE BOOLEAN PORT_ALLOCATED_SENSE(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ PSCSI_REQUEST_BLOCK Srb)
_In_ WDFFILEOBJECT _In_ BOOLEAN IgnorePreviousMediaChanges
#define IOCTL_MCN_SYNC_FAKE_IOCTL
#define CDROM_TAG_MEDIA_CHANGE_DETECTION
VOID DeviceReleaseQueue(_In_ WDFDEVICE Device)
#define FREE_POOL(_PoolPtr)
FORCEINLINE VOID FREE_PORT_ALLOCATED_SENSE_BUFFER(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ PSCSI_REQUEST_BLOCK Srb)
#define CDROM_HACK_MSFT_VIRTUAL_ODD
POWER_SETTING_CALLBACK DevicePowerSettingCallback
FORCEINLINE BOOLEAN IsVolumeMounted(_In_ PDEVICE_OBJECT DeviceObject)
_In_ PFILE_OBJECT_CONTEXT FileObjectContext
#define SRB_CLASS_FLAGS_LOW_PRIORITY
#define CDROM_TEST_UNIT_READY_TIMEOUT
NTSTATUS RequestSend(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDFIOTARGET IoTarget, _In_ ULONG Flags, _Out_opt_ PBOOLEAN RequestSent)
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
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)
#define TEST_FLAG(Flags, Bit)
#define CLEAR_FLAG(Flags, Bit)
FORCEINLINE ULONG CountOfSetBitsUChar(UCHAR _X)
VOID DeviceSendNotification(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ const GUID *Guid, _In_ ULONG ExtraDataSize, _In_opt_ PVOID ExtraData)
#define SET_FLAG(Flags, Bit)
VOID RequestClearSendTime(_In_ WDFREQUEST Request)
#define CDROM_TAG_AUTORUN_DISABLE
@ CdromDetectionSupported
@ CdromDetectionUnsupported
#define FDO_HACK_NO_ASYNCHRONOUS_NOTIFICATION
#define CLASSP_REG_MMC_DETECTION_VALUE_NAME
enum _MEDIA_CHANGE_DETECTION_STATE * PMEDIA_CHANGE_DETECTION_STATE
#define FDO_HACK_GESN_IGNORE_OPCHANGE
enum _MEDIA_CHANGE_DETECTION_STATE MEDIA_CHANGE_DETECTION_STATE
#define FDO_HACK_GESN_IS_BAD
enum _CDROM_DETECTION_STATE CDROM_DETECTION_STATE
#define CLASSP_REG_SUBKEY_NAME
#define IOCTL_SCSI_EXECUTE_IN
#define SCSIOP_GET_EVENT_STATUS
#define SCSIOP_TEST_UNIT_READY
struct _SENSE_DATA SENSE_DATA
#define IOCTL_SCSI_EXECUTE_NONE
#define SENSE_BUFFER_SIZE
#define SCSI_SENSE_UNIT_ATTENTION
#define SCSI_ADSENSE_MEDIUM_CHANGED
_In_ BOOLEAN AllowDriveToSleep
#define STATUS_NOT_SUPPORTED
#define NT_SUCCESS(StatCode)
struct _SCSI_REQUEST_BLOCK SCSI_REQUEST_BLOCK
#define SRB_STATUS_BUS_RESET
#define SRB_STATUS_NOT_POWERED
#define SRB_FUNCTION_EXECUTE_SCSI
#define SRB_FLAGS_NO_DATA_TRANSFER
#define SRB_SIMPLE_TAG_REQUEST
#define SRB_STATUS_AUTOSENSE_VALID
#define SRB_FLAGS_DATA_IN
#define SRB_FLAGS_NO_KEEP_AWAKE
#define SRB_FLAGS_DISABLE_SYNCH_TRANSFER
#define SRB_STATUS(Status)
#define SRB_STATUS_QUEUE_FROZEN
#define SRB_FLAGS_NO_QUEUE_FREEZE
#define SRB_STATUS_SUCCESS
#define _IRQL_requires_max_(irql)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define RtlCompareMemory(s1, s2, l)
#define KeQuerySystemTime(t)
GLenum const GLfloat * params
GLuint GLsizei GLsizei * length
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
_In_ GUID _In_ PVOID ValueData
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
#define InterlockedCompareExchange
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
VOID NTAPI MmBuildMdlForNonPagedPool(IN PMDL Mdl)
_In_ PCWSTR _Inout_ _At_ QueryTable EntryContext
#define _In_reads_opt_(s)
#define _In_reads_bytes_opt_(s)
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RTL_QUERY_REGISTRY_REQUIRED
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define RTL_REGISTRY_HANDLE
#define RTL_SIZEOF_THROUGH_FIELD(type, field)
#define UNREFERENCED_PARAMETER(P)
* PSTORAGE_DEVICE_DESCRIPTOR
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
VOID NTAPI IoReuseIrp(IN OUT PIRP Irp, IN NTSTATUS Status)
VOID NTAPI IoFreeIrp(IN PIRP Irp)
ULONG NTAPI KeQueryTimeIncrement(VOID)
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
LONG NTAPI KeReleaseMutex(IN PKMUTEX Mutex, IN BOOLEAN Wait)
#define STATUS_INTERNAL_ERROR
#define STATUS_DEVICE_PROTOCOL_ERROR
#define STATUS_MEDIA_CHANGED
NTKRNLVISTAAPI NTSTATUS NTAPI PoRegisterPowerSettingCallback(_In_opt_ PDEVICE_OBJECT DeviceObject, _In_ LPCGUID SettingGuid, _In_ PPOWER_SETTING_CALLBACK Callback, _In_opt_ PVOID Context, _Outptr_opt_ PVOID *Handle)
#define IRP_MJ_DEVICE_CONTROL
#define NOTIFICATION_DEVICE_BUSY_CLASS_EVENTS
#define NOTIFICATION_MEDIA_EVENT_MEDIA_CHANGE
struct _NOTIFICATION_OPERATIONAL_STATUS * PNOTIFICATION_OPERATIONAL_STATUS
#define NOTIFICATION_MEDIA_STATUS_CLASS_MASK
struct _NOTIFICATION_EXTERNAL_STATUS * PNOTIFICATION_EXTERNAL_STATUS
#define NOTIFICATION_MEDIA_EVENT_NEW_MEDIA
#define NOTIFICATION_OPERATIONAL_OPCODE_FEATURE_CHANGE
#define NOTIFICATION_BUSY_EVENT_LO_CHANGE
#define NOTIFICATION_EXTERNAL_REQUEST_CLASS_MASK
#define NOTIFICATION_NO_CLASS_EVENTS
#define NOTIFICATION_EXTERNAL_EVENT_BUTTON_DOWN
#define LOADING_MECHANISM_CADDY
#define NOTIFICATION_OPERATIONAL_CHANGE_CLASS_MASK
struct _NOTIFICATION_EVENT_STATUS_HEADER * PNOTIFICATION_EVENT_STATUS_HEADER
#define NOTIFICATION_BUSY_STATUS_NO_EVENT
struct _NOTIFICATION_MEDIA_STATUS * PNOTIFICATION_MEDIA_STATUS
#define NOTIFICATION_MEDIA_EVENT_EJECT_REQUEST
#define NOTIFICATION_MEDIA_STATUS_CLASS_EVENTS
#define NOTIFICATION_DEVICE_BUSY_CLASS_MASK
struct _NOTIFICATION_BUSY_STATUS * PNOTIFICATION_BUSY_STATUS
#define NOTIFICATION_EXTERNAL_REQUEST_CLASS_EVENTS
#define NOTIFICATION_MEDIA_EVENT_MEDIA_REMOVAL
#define LOADING_MECHANISM_TRAY
#define NOTIFICATION_OPERATIONAL_OPCODE_FEATURE_ADDED
#define NOTIFICATION_OPERATIONAL_CHANGE_CLASS_EVENTS
#define NOTIFICATION_OPERATIONAL_EVENT_CHANGE_REQUESTED
#define STATUS_MORE_PROCESSING_REQUIRED
#define TRACE_LEVEL_WARNING
#define TRACE_LEVEL_VERBOSE
#define TRACE_LEVEL_ERROR
#define TRACE_LEVEL_INFORMATION
PMEDIA_CHANGE_DETECTION_INFO MediaChangeDetectionInfo
ULONG Estimated100msToReady
PDEVICE_OBJECT DeviceObject
struct _IO_STACK_LOCATION::@1579::@1580 DeviceIoControl
struct _IO_STACK_LOCATION::@3978::@4017 Others
union _IO_STACK_LOCATION::@1579 Parameters
struct _IO_STACK_LOCATION::@3978::@4000 Scsi
PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine
UCHAR SenseInfoBufferLength
UCHAR AdditionalSenseLength
UCHAR AdditionalSenseCode
WDF_EXECUTION_LEVEL ExecutionLevel
BOOLEAN AutomaticSerialization
BOOLEAN AutomaticSerialization
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_IO_DEVICE_ERROR
#define STATUS_INVALID_DEVICE_REQUEST
#define STATUS_DATA_OVERRUN
#define STATUS_INVALID_PARAMETER
#define STATUS_IO_TIMEOUT
#define STATUS_UNSUCCESSFUL
#define STATUS_INVALID_DEVICE_STATE
#define STATUS_INSUFFICIENT_RESOURCES
struct _CDB::_CDB6GENERIC CDB6GENERIC
struct _CDB::_GET_EVENT_STATUS_NOTIFICATION GET_EVENT_STATUS_NOTIFICATION
FORCEINLINE LONGLONG WDF_REL_TIMEOUT_IN_MS(_In_ ULONGLONG Time)
_In_ PDEVICE_OBJECT DeviceObject
FORCEINLINE WDFDRIVER WdfGetDriver(VOID)
FORCEINLINE VOID WDF_OBJECT_ATTRIBUTES_INIT(_Out_ PWDF_OBJECT_ATTRIBUTES Attributes)
#define WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(_attributes, _contexttype)
@ WdfExecutionLevelInheritFromParent
#define WdfObjectGetTypedContext(handle, type)
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG _Out_opt_ PULONG ValueType
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
@ WDF_REQUEST_SEND_OPTION_SYNCHRONOUS
@ WDF_REQUEST_REUSE_NO_FLAGS
FORCEINLINE VOID WDF_REQUEST_REUSE_PARAMS_INIT(_Out_ PWDF_REQUEST_REUSE_PARAMS Params, _In_ ULONG Flags, _In_ NTSTATUS Status)
FORCEINLINE VOID WDF_TIMER_CONFIG_INIT(_Out_ PWDF_TIMER_CONFIG Config, _In_ PFN_WDF_TIMER EvtTimerFunc)
#define WDF_NO_OBJECT_ATTRIBUTES
FORCEINLINE VOID WDF_WORKITEM_CONFIG_INIT(_Out_ PWDF_WORKITEM_CONFIG Config, _In_ PFN_WDF_WORKITEM EvtWorkItemFunc)
_Must_inspect_result_ _In_ PWDF_WORKITEM_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWORKITEM * WorkItem
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
FORCEINLINE VOID IoSetNextIrpStackLocation(_Inout_ PIRP Irp)
#define PLUGPLAY_REGKEY_DEVICE
#define SL_OVERRIDE_VERIFY_VOLUME
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
#define KeWaitForMutexObject