39#pragma alloc_text(PAGE, DeviceGetParameter)
40#pragma alloc_text(PAGE, DeviceSetParameter)
41#pragma alloc_text(PAGE, DeviceSendSrbSynchronously)
42#pragma alloc_text(PAGE, DevicePickDvdRegion)
43#pragma alloc_text(PAGE, StringsAreMatched)
44#pragma alloc_text(PAGE, PerformEjectionControl)
45#pragma alloc_text(PAGE, DeviceFindFeaturePage)
46#pragma alloc_text(PAGE, DevicePrintAllFeaturePages)
47#pragma alloc_text(PAGE, DeviceRegisterInterface)
48#pragma alloc_text(PAGE, DeviceRestoreDefaultSpeed)
49#pragma alloc_text(PAGE, DeviceSendRequestSynchronously)
50#pragma alloc_text(PAGE, MediaReadCapacity)
51#pragma alloc_text(PAGE, MediaReadCapacityDataInterpret)
52#pragma alloc_text(PAGE, DeviceRetrieveModeSenseUsingScratch)
53#pragma alloc_text(PAGE, ModeSenseFindSpecificPage)
54#pragma alloc_text(PAGE, DeviceUnlockExclusive)
163 WDFKEY rootKey =
NULL;
164 WDFKEY subKey =
NULL;
167 ULONG defaultParameterValue;
179 status = WdfDeviceOpenRegistryKey(DeviceExtension->Device,
188 status = WdfRegistryOpenKey(rootKey,
196 WdfRegistryClose(rootKey);
205 status = WdfRegistryQueryULong((subKey !=
NULL) ? subKey : rootKey,
218 WdfRegistryClose(subKey);
224 WdfRegistryClose(rootKey);
232 status = WdfDeviceOpenRegistryKey(DeviceExtension->Device,
241 status = WdfRegistryOpenKey(rootKey,
249 WdfRegistryClose(rootKey);
258 status = WdfRegistryQueryULong((subKey !=
NULL) ? subKey : rootKey,
276 WdfRegistryClose(subKey);
282 WdfRegistryClose(rootKey);
321 WDFKEY rootKey =
NULL;
322 WDFKEY subKey =
NULL;
336 status = WdfDeviceOpenRegistryKey(DeviceExtension->Device,
345 status = WdfRegistryOpenKey(rootKey,
353 WdfRegistryClose(rootKey);
360 status = WdfRegistryAssignULong((subKey !=
NULL) ? subKey : rootKey,
368 WdfRegistryClose(subKey);
374 WdfRegistryClose(rootKey);
385DeviceSendRequestSynchronously(
418 WdfRequestFormatRequestUsingCurrentType(
Request);
424 requestCancelled = WdfRequestIsCanceled(requestContext->
OriginalRequest);
427 if (!requestCancelled)
446DeviceSendSrbSynchronously(
495 ULONG retryCount = 0;
535 "DeviceSendSrbSynchronously: Can't allocate MDL\n"));
555 status = WdfRequestCreate(&attributes,
562 "DeviceSendSrbSynchronously: Can't create request: %lx\n",
579 if (mdlAddress ==
NULL)
584 "DeviceSendSrbSynchronously: Can't allocate MDL\n"));
600 "DeviceSendSrbSynchronously: Exception %lx locking buffer\n",
status));
636 "DeviceSendSrbSynchronously: WdfRequestReuse failed, %!STATUS!\n",
643 status = WdfIoTargetFormatRequestForInternalIoctlOthers(deviceExtension->
IoTarget,
653 "DeviceSendSrbSynchronously: WdfIoTargetFormatRequestForInternalIoctlOthers failed, %!STATUS!\n",
659 requestContext = RequestGetContext(
request);
699 irp->MdlAddress = mdlAddress;
728 &retryIntervalIn100ns);
733 t.QuadPart = -retryIntervalIn100ns;
748 if ((zpoddInfo !=
NULL) &&
753 "DeviceSendSrbSynchronously: soft eject detected, device marked as active\n"));
755 DeviceMarkActive(deviceExtension,
TRUE,
FALSE);
782 memoryLocked =
FALSE;
837 "Error sending event: size too large! (%x)\n",
860 if (ExtraData !=
NULL)
911 WDFREQUEST startUnitRequest =
NULL;
912 WDFMEMORY inputMemory =
NULL;
918 deviceExtension = DeviceGetExtension(
Device);
930 "DeviceSendStartUnit: Failed to allocate completion context\n"));
968 status = WdfRequestCreate(&attributes,
982 status = WdfMemoryCreatePreallocated(&attributes,
990 status = WdfIoTargetFormatRequestForInternalIoctlOthers(deviceExtension->
IoTarget,
1004 WdfRequestSetCompletionRoutine(startUnitRequest,
1019 if (startUnitRequest !=
NULL)
1021 WdfObjectDelete(startUnitRequest);
1318 status = WdfIoTargetFormatRequestForInternalIoctlOthers(deviceExtension->
IoTarget,
1332 "DeviceReleaseQueueCompletion: WdfIoTargetFormatRequestForInternalIoctlOthers failed, %!STATUS!\n",
1343 if (releaseQueueNeeded)
1388 fdoData->
Perf.SuccessfulIO = 0;
1405 "PerfIncrementErrorCount: Too many errors; disabling tagged queuing and "
1406 "synchronous data tranfers.\n"));
1414 "PerfIncrementErrorCount: Too many errors; disabling disconnects.\n"));
1424DeviceFindFeaturePage(
1470 buffer = FeatureBuffer->Data;
1480 thisFeature = (
header->FeatureCode[0] << 8) |
1481 (
header->FeatureCode[1]);
1501 "Feature %x exists, but not safe to access all its data. returning NULL\n",
1511 if ((
header->AdditionalLength % 4) &&
1527DevicePrintAllFeaturePages(
1560 "CdromGetConfiguration: CurrentProfile %x "
1561 "with %x bytes of data at %p\n",
1562 Buffer->CurrentProfile[0] << 8 |
1563 Buffer->CurrentProfile[1],
1570 "CdromGetConfiguration: %s %s\n",
1572 "Currently supports" :
"Is able to support"),
1580 "CdromGetConfiguration: %s %s\n",
1582 "Currently supports" :
"Is able to support"),
1590 "CdromGetConfiguration: %s %s\n",
1592 "Currently supports" :
"Is able to support"),
1600 "CdromGetConfiguration: %s %s\n",
1602 "Currently supports" :
"Is able to support"),
1610 "CdromGetConfiguration: %s %s\n",
1612 "Currently supports" :
"Is able to support"),
1620 "CdromGetConfiguration: %s %s\n",
1622 "Currently supports" :
"Is able to support"),
1630 "CdromGetConfiguration: %s %s\n",
1632 "Currently supports" :
"Is able to support"),
1640 "CdromGetConfiguration: %s %s\n",
1642 "Currently supports" :
"Is able to support"),
1654 "CdromGetConfiguration: %s %s\n",
1656 "Currently supports" :
"Is able to support"),
1664 UCHAR dateString[18] = { 0 };
1665 dateString[ 0] =
date->Year[0];
1666 dateString[ 1] =
date->Year[1];
1667 dateString[ 2] =
date->Year[2];
1668 dateString[ 3] =
date->Year[3];
1669 dateString[ 4] =
'/';
1670 dateString[ 5] =
date->Month[0];
1671 dateString[ 6] =
date->Month[1];
1672 dateString[ 7] =
'/';
1673 dateString[ 8] =
date->Day[0];
1674 dateString[ 9] =
date->Day[1];
1675 dateString[10] =
' ';
1676 dateString[11] =
' ';
1677 dateString[12] =
date->Hour[0];
1678 dateString[13] =
date->Hour[1];
1679 dateString[14] =
':';
1680 dateString[15] =
date->Minute[0];
1681 dateString[16] =
date->Minute[1];
1689 "CdromGetConfiguration: Firmware Date/Time %s (UTC)\n",
1703 "CdromGetConfiguration: %s %s\n",
1705 "Currently supports" :
"Is able to support"),
1706 "Software Write Protect"
1713 "CdromGetConfiguration: %s %s\n",
1715 "Currently supports" :
"Is able to support"),
1723 "CdromGetConfiguration: %s %s\n",
1725 "Currently supports" :
"Is able to support"),
1733 "CdromGetConfiguration: %s %s\n",
1735 "Currently supports" :
"Is able to support"),
1736 "reading from CD-ROM/R/RW"
1743 "CdromGetConfiguration: %s %s\n",
1745 "Currently supports" :
"Is able to support"),
1746 "DVD Structure Reads"
1753 "CdromGetConfiguration: %s %s\n",
1755 "Currently supports" :
"Is able to support"),
1763 "CdromGetConfiguration: %s %s\n",
1765 "Currently supports" :
"Is able to support"),
1766 "Incremental Streaming Writing"
1773 "CdromGetConfiguration: %s %s\n",
1775 "Currently supports" :
"Is able to support"),
1776 "Sector Erasable Media"
1783 "CdromGetConfiguration: %s %s\n",
1785 "Currently supports" :
"Is able to support"),
1793 "CdromGetConfiguration: %s %s\n",
1795 "Currently supports" :
"Is able to support"),
1803 "CdromGetConfiguration: %s %s\n",
1805 "Currently supports" :
"Is able to support"),
1813 "CdromGetConfiguration: %s %s\n",
1815 "Currently supports" :
"Is able to support"),
1816 "Restricted Overwrites"
1823 "CdromGetConfiguration: %s %s\n",
1825 "Currently supports" :
"Is able to support"),
1826 "CD-RW CAV recording"
1833 "CdromGetConfiguration: %s %s\n",
1835 "Currently supports" :
"Is able to support"),
1836 "Mount Rainier media"
1843 "CdromGetConfiguration: %s %s\n",
1845 "Currently supports" :
"Is able to support"),
1846 "Enhanced Defect Reporting"
1853 "CdromGetConfiguration: %s %s\n",
1855 "Currently supports" :
"Is able to support"),
1863 "CdromGetConfiguration: %s %s\n",
1865 "Currently supports" :
"Is able to support"),
1866 "Rigid Restricted Overwrite"
1873 "CdromGetConfiguration: %s %s\n",
1875 "Currently supports" :
"Is able to support"),
1876 "CD Recording (Track At Once)"
1883 "CdromGetConfiguration: %s %s\n",
1885 "Currently supports" :
"Is able to support"),
1886 "CD Recording (Mastering)"
1893 "CdromGetConfiguration: %s %s\n",
1895 "Currently supports" :
"Is able to support"),
1896 "DVD Recording (Mastering)"
1903 "CdromGetConfiguration: %s %s\n",
1905 "Currently supports" :
"Is able to support"),
1913 "CdromGetConfiguration: %s %s\n",
1915 "Currently supports" :
"Is able to support"),
1923 "CdromGetConfiguration: %s %s\n",
1925 "Currently supports" :
"Is able to support"),
1933 "CdromGetConfiguration: %s %s\n",
1935 "Currently supports" :
"Is able to support"),
1936 "Layer Jump Recording"
1943 "CdromGetConfiguration: %s %s\n",
1945 "Currently supports" :
"Is able to support"),
1953 "CdromGetConfiguration: %s %s\n",
1955 "Currently supports" :
"Is able to support"),
1964 "CdromGetConfiguration: %s %s\n",
1966 "Currently supports" :
"Is able to support"),
1974 "CdromGetConfiguration: %s %s\n",
1976 "Currently supports" :
"Is able to support"),
1977 "Analogue CD Audio Operations"
1984 "CdromGetConfiguration: %s %s\n",
1986 "Currently supports" :
"Is able to support"),
1994 "CdromGetConfiguration: %s %s\n",
1996 "Currently supports" :
"Is able to support"),
1997 "Real-time Streaming Reads"
2004 "CdromGetConfiguration: %s %s\n",
2006 "Currently supports" :
"Is able to support"),
2007 "DVD Disc Control Blocks"
2014 "CdromGetConfiguration: %s %s\n",
2016 "Currently supports" :
"Is able to support"),
2024 "CdromGetConfiguration: %s %s\n",
2026 "Currently supports" :
"Is able to support"),
2094 MediaReadCapacityDataInterpret(
Device, &capacityData);
2102MediaReadCapacityDataInterpret(
2124 ULONG lastSector = 0;
2127 ULONG bytesPerBlock = 0;
2135 "MediaReadCapacityDataInterpret: Entering\n"));
2153 errorHappened =
TRUE;
2157 lastBit = (
ULONG)(-1);
2163 bps = (1 << lastBit);
2169 "MediaReadCapacityDataInterpret: Calculated bps %#x\n",
2184 "MediaReadCapacityDataInterpret: Sector size is %d\n",
2188 "MediaReadCapacityDataInterpret: Number of Sectors is %d\n",
2249 size_t bytesReturned = 0;
2250 ULONG bufferLen = 0;
2251 UCHAR mediaRegion = 0;
2252 ULONG pickDvdRegion = 0;
2253 ULONG defaultDvdRegion = 0;
2254 ULONG dvdRegion = 0;
2255 WDFKEY registryKey =
NULL;
2281 if (dvdReadStructure ==
NULL)
2298 "DevicePickDvdRegion (%p): Getting Copyright Descriptor\n",
2301 status = ReadDvdStructure(deviceExtension,
2310 "DevicePickDvdRegion (%p): Got Copyright Descriptor %x\n",
2321 "DevicePickDvdRegion (%p): RegionManagementInformation "
2322 "is set to dis-allow playback for all regions. This is "
2323 "most likely a poorly authored disc. defaulting to all "
2324 "region disc for purpose of choosing initial region\n",
2329 mediaRegion = ~dvdCopyRight->RegionManagementInformation;
2335 "DevicePickDvdRegion (%p): failed to auto-choose a region due to status %x getting copyright descriptor\n",
2347 "DevicePickDvdRegion (%p): Getting RpcKey\n",
2349 status = DvdStartSessionReadKey(deviceExtension,
2359 "DevicePickDvdRegion (%p): Got RpcKey %x\n",
2365 "DevicePickDvdRegion (%p): failed to get RpcKey from "
2366 "a DVD Device\n",
Device));
2379 "DevicePickDvdRegion (%p): not picking a region since "
2380 "it is already chosen\n",
Device));
2387 "DevicePickDvdRegion (%p): not picking a region since "
2388 "only one change remains\n",
Device));
2400 status = WdfRegistryQueryULong(registryKey,
2404 WdfRegistryClose(registryKey);
2410 "DevicePickDvdRegion (%p): failed to read registry value due to status %x\n",
2414 defaultDvdRegion = 0;
2422 "DevicePickDvdRegion (%p): registry has a bogus default "
2423 "region value of %x\n",
Device, defaultDvdRegion));
2425 defaultDvdRegion = 0;
2432 if ((defaultDvdRegion != 0) &&
2433 (mediaRegion & (1 << (defaultDvdRegion - 1))))
2438 dvdRegion = (1 << (defaultDvdRegion - 1));
2441 "DevicePickDvdRegion (%p): Choice #1: media matches "
2442 "drive's default, chose region %x\n",
Device, dvdRegion));
2444 else if (mediaRegion)
2451 while (mediaRegion && !dvdRegion)
2454 dvdRegion = mediaRegion &
mask;
2459 "DevicePickDvdRegion (%p): Choice #2: choosing lowest "
2460 "media region %x\n",
Device, dvdRegion));
2462 else if (defaultDvdRegion)
2466 dvdRegion = (1 << (defaultDvdRegion - 1));
2468 "DevicePickDvdRegion (%p): Choice #3: using default "
2469 "region for this install %x\n",
Device, dvdRegion));
2477 "DevicePickDvdRegion (%p): Choice #4: failed to choose "
2478 "a media region\n",
Device));
2492 "DevicePickDvdRegion (%p): Sending new Rpc Key to region %x\n",
2495 status = DvdSendKey(deviceExtension,
2502 "DevicePickDvdRegion (%p): Sent new Rpc Key %x\n",
2507 TracePrint((
TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL,
"DevicePickDvdRegion (%p): unable to set dvd initial "
2512 TracePrint((
TRACE_LEVEL_VERBOSE, TRACE_FLAG_IOCTL,
"DevicePickDvdRegion (%p): Successfully set dvd "
2513 "initial region\n",
Device));
2519 if (dvdReadStructure)
2532DeviceRegisterInterface(
2554 WDFSTRING
string =
NULL;
2566 interfaceGuid = (
LPGUID)&GUID_DEVINTERFACE_CDROM;
2567 setRestricted =
TRUE;
2568 savingString = &localString;
2571 interfaceGuid = (
LPGUID)&MOUNTDEV_MOUNTED_DEVICE_GUID;
2572 savingString = &(DeviceExtension->MountedDeviceInterfaceName);
2578 status = WdfDeviceCreateDeviceInterface(DeviceExtension->Device,
2585 "DeviceRegisterInterface: Unable to register cdrom "
2586 "DCA for fdo %p type: %s [%lx]\n",
2587 DeviceExtension->Device,
2608 status = WdfDeviceRetrieveDeviceInterfaceString(DeviceExtension->Device,
2616 WdfStringGetUnicodeString(
string, savingString);
2618 if (setRestricted) {
2621 WdfObjectDelete(
string);
2667 if (perfDescriptor ==
NULL)
2689 "DeviceRestoreDefaultSpeed: Set Streaming command completed with status: 0x%X\n",
status));
2728 if (StringToMatch ==
NULL)
2777 if (syncEvent ==
NULL)
2830 status = DeviceRetrieveDescriptor(DeviceExtension->Device,
2852 size_t outputBufferSize;
2857 status = RtlULongAdd(descHeader->Size, deviceIdDescriptor->Size, &descHeader->Size);
2860 (outputBufferSize < descHeader->
Size))
2875 deviceIdDescriptor->Size);
2919 if (deviceDescriptor ==
NULL)
2933 (deviceDescriptor->SerialNumberOffset == 0))
2947 status = RtlULongAdd(descHeader->Size, deviceDescriptor->Size, &descHeader->Size);
2950 (outputBufferSize < descHeader->
Size))
2965 deviceDescriptor->Size);
2977DeviceRetrieveModeSenseUsingScratch(
3005 ULONG transferSize =
min(
Length, DeviceExtension->ScratchContext.ScratchBufferSize);
3019 status = ScratchBuffer_ExecuteCdb(DeviceExtension,
NULL, transferSize,
TRUE, &cdb, 6);
3023 transferSize =
min(
Length, DeviceExtension->ScratchContext.ScratchSrb->DataTransferLength);
3025 DeviceExtension->ScratchContext.ScratchBuffer,
3031 return transferSize;
3036ModeSenseFindSpecificPage(
3066 ULONG parameterHeaderLength;
3072 parameterHeaderLength = (Use6BytesCdb)
3076 if (
Length >= parameterHeaderLength)
3079 ULONG blockDescriptorLength;
3092 ModeSenseBuffer += parameterHeaderLength + blockDescriptorLength;
3096 while (ModeSenseBuffer +
3110 result = ModeSenseBuffer;
3127PerformEjectionControl(
3157 LONG newLockCount = 0;
3158 LONG newProtectedLockCount = 0;
3159 LONG newInternalLockCount = 0;
3160 LONG newFileLockCount = 0;
3175 "PerformEjectionControl: "
3176 "Received request for %s lock type\n",
3184 WDFFILEOBJECT fileObject =
NULL;
3186 fileObject = WdfRequestGetFileObject(
Request);
3188 if (fileObject ==
NULL)
3193 "FileObject does not match to the one in IRP_MJ_CREATE, KMDF returns NULL\n"));
3197 fileObjectContext = FileObjectGetContext(fileObject);
3202 NT_ASSERT(DeviceExtension->LockCount >= 0);
3203 NT_ASSERT(DeviceExtension->ProtectedLockCount >= 0);
3204 NT_ASSERT(DeviceExtension->InternalLockCount >= 0);
3207 newLockCount = DeviceExtension->LockCount;
3208 newProtectedLockCount = DeviceExtension->ProtectedLockCount;
3209 newInternalLockCount = DeviceExtension->InternalLockCount;
3210 if (fileObjectContext)
3213 newFileLockCount = fileObjectContext->
LockCount;
3220 countChanged =
TRUE;
3225 newProtectedLockCount++;
3226 countChanged =
TRUE;
3230 newInternalLockCount++;
3231 countChanged =
TRUE;
3235 if (newLockCount != 0)
3238 countChanged =
TRUE;
3243 if ( (newFileLockCount == 0) || (newProtectedLockCount == 0) )
3249 newProtectedLockCount--;
3250 countChanged =
TRUE;
3255 newInternalLockCount--;
3256 countChanged =
TRUE;
3259 if ( (DeviceExtension->LockCount != 0) ||
3260 (DeviceExtension->ProtectedLockCount != 0) ||
3261 (DeviceExtension->InternalLockCount != 0) )
3263 previouslyLocked =
TRUE;
3265 if ( (newLockCount != 0) ||
3266 (newProtectedLockCount != 0) ||
3267 (newInternalLockCount != 0) )
3273 if (previouslyLocked != nowLocked)
3285 status = DeviceSendSrbSynchronously(DeviceExtension->Device,
3298 DeviceExtension->LockCount = newLockCount;
3299 DeviceExtension->ProtectedLockCount = newProtectedLockCount;
3300 DeviceExtension->InternalLockCount = newInternalLockCount;
3301 if (fileObjectContext)
3303 fileObjectContext->
LockCount = newFileLockCount;
3307 WdfWaitLockRelease(DeviceExtension->EjectSynchronizationLock);
3310 "PerformEjectionControl: %!STATUS!, "
3311 "Count Changed: %d, Command Sent: %d, "
3312 "Current Counts: Internal: %x Secure: %x Simple: %x\n",
3315 previouslyLocked != nowLocked,
3316 DeviceExtension->InternalLockCount,
3317 DeviceExtension->ProtectedLockCount,
3318 DeviceExtension->LockCount
3327DeviceUnlockExclusive(
3351 PCDROM_DATA cdData = &DeviceExtension->DeviceAdditionalData;
3354 LONG requestInUse = 0;
3363 "RequestHandleExclusiveAccessUnlockDevice: Device not locked for exclusive access, can't unlock device.\n"));
3370 "RequestHandleExclusiveAccessUnlockDevice: Unable to unlock device, invalid file object\n"));
3387 "DeviceUnlockExclusive: Changing the media state to MediaUnavailable\n"));
3406 &GUID_IO_CDROM_EXCLUSIVE_UNLOCK,
3414 ANPending =
info->ANSignalPendingDueToExclusiveLock;
3415 info->ANSignalPendingDueToExclusiveLock =
FALSE;
3417 if ((ANPending !=
FALSE) && (
info->MediaChangeDetectionDisableCount == 0))
3422 if (requestInUse == 0)
3447 ULONG ioctlCode = 0;
3452 WdfRequestGetParameters(
Request, &requestParameters);
3461 "Request complete - IOCTL - code: %X; Status: %X; Information: %X\n",
3469 "Request complete - IOCTL - code: %X; Status: %X; Information: %X\n",
3478 "Request complete - READ - Starting Offset: %X; Length: %X; Transferred Length: %X; Status: %X\n",
3487 "Request complete - WRITE - Starting Offset: %X; Length: %X; Transferred Length: %X; Status: %X\n",
3498 if (
irp->Tail.Overlay.Thread)
3551 WdfRequestCompleteWithInformation(
Request,
3553 WdfRequestGetInformation(
Request));
3559DeviceSendPowerDownProcessRequest(
3592 PCDB cdb = (
PCDB)DeviceExtension->PowerContext.Srb.Cdb;
3593 ULONG timeoutValue = DeviceExtension->TimeOutValue;
3594 ULONG retryCount = 1;
3597 DeviceExtension->PowerContext.RetryIntervalIn100ns = 0;
3598 status = PowerContextReuseRequest(DeviceExtension);
3607 switch(DeviceExtension->PowerContext.PowerChangeState.PowerDown)
3618 timeoutValue = DeviceExtension->TimeOutValue;
3626 ULONG secondsRemaining = 0;
3628#if (WINVER >= 0x0601)
3630 PoQueryWatchdogTime(DeviceExtension->LowerPdo, &secondsRemaining);
3633 if (secondsRemaining == 0)
3642 if (secondsRemaining >= 32)
3652 if (retryCount == 1)
3654 timeoutValue = secondsRemaining - 30;
3672 DeviceExtension->PowerContext.RetryCount = retryCount;
3686 DeviceExtension->PowerContext.Srb.TimeOutValue = timeoutValue;
3699 DeviceExtension->PowerContext.Srb.CdbLength = 10;
3705 DeviceExtension->PowerContext.Srb.CdbLength = 6;
3718 WdfRequestSetCompletionRoutine(DeviceExtension->PowerContext.PowerRequest,
3724 DeviceExtension->PowerContext.PowerRequest,
3725 DeviceExtension->IoTarget,
3736 "%p\tError occured when issuing %s command to device. Srb %p, Status %x\n",
3737 DeviceExtension->PowerContext.PowerRequest,
3738 (DeviceExtension->PowerContext.PowerChangeState.PowerDown ==
PowerDownDeviceQuiesced) ?
"SYNC CACHE" :
"STOP UNIT",
3739 &DeviceExtension->PowerContext.Srb,
3740 DeviceExtension->PowerContext.Srb.SrbStatus));
3745 DeviceExtension->PowerContext.PowerRequest,
3746 &(DeviceExtension->PowerContext.Srb),
3747 retryCount - DeviceExtension->PowerContext.RetryCount,
3749 &(DeviceExtension->PowerContext.RetryIntervalIn100ns));
3751 if (shouldRetry && (DeviceExtension->PowerContext.RetryCount-- == 0))
3753 shouldRetry =
FALSE;
3759 shouldRetry =
FALSE;
3766 shouldRetry =
FALSE;
3772 t.QuadPart = -DeviceExtension->PowerContext.RetryIntervalIn100ns;
3775 status = PowerContextReuseRequest(DeviceExtension);
3778 shouldRetry =
FALSE;
3826 if ((DeviceExtension->ZeroPowerODDInfo !=
NULL) &&
3827 (DeviceExtension->ZeroPowerODDInfo->InZeroPowerState !=
FALSE))
3852 if ((requestSent ==
FALSE) ||
3857 if (requestSent ==
FALSE)
3860 "WdfRequestSend failed: %lx\n",
3870 if (RequestSent !=
NULL)
3872 *RequestSent = requestSent;
ACPI_SIZE strlen(const char *String)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER Handler
#define InterlockedIncrement
#define InterlockedExchange
VOID RequestSetupMcnSyncIrp(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension)
VOID DeviceSetMediaChangeStateEx(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ MEDIA_CHANGE_DETECTION_STATE NewState, _Inout_opt_ PMEDIA_CHANGE_DETECTION_STATE OldState)
_In_ PSCSI_REQUEST_BLOCK Srb
_In_opt_ PWSTR _In_ PWSTR ParameterName
FORCEINLINE BOOLEAN PORT_ALLOCATED_SENSE(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ PSCSI_REQUEST_BLOCK Srb)
_In_ WDFFILEOBJECT _In_ BOOLEAN IgnorePreviousMediaChanges
#define DVD_DEFAULT_REGION
#define IOCTL_MCN_SYNC_FAKE_IOCTL
_In_ size_t _In_ UCHAR PageMode
#define FREE_POOL(_PoolPtr)
#define START_UNIT_TIMEOUT
FORCEINLINE VOID FREE_PORT_ALLOCATED_SENSE_BUFFER(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ PSCSI_REQUEST_BLOCK Srb)
#define CdromMmcUpdateRequired
SYNC_HANDLER * PSYNC_HANDLER
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID BufferAddress
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID _In_ ULONG _In_ BOOLEAN _In_opt_ WDFREQUEST OriginalRequest
FORCEINLINE BOOLEAN IsVolumeMounted(_In_ PDEVICE_OBJECT DeviceObject)
_In_opt_ PWSTR _In_ PWSTR _Inout_ PULONG ParameterValue
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID _In_ ULONG _In_ BOOLEAN WriteToDevice
struct _COMPLETION_CONTEXT * PCOMPLETION_CONTEXT
_In_ PREAD_CAPACITY_DATA ReadCapacityBuffer
#define CDROM_TAG_SYNC_EVENT
#define EXCLUSIVE_OWNER(_CdData, _FileObject)
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
EVT_WDF_REQUEST_COMPLETION_ROUTINE DeviceAsynchronousCompletion
EVT_WDF_REQUEST_COMPLETION_ROUTINE RequestDummyCompletionRoutine
_In_ ULONG _In_ UCHAR PageCode
_In_opt_ PWSTR SubkeyName
#define SCSI_CDROM_TIMEOUT
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)
_In_ ULONG const _In_ FEATURE_NUMBER const Feature
EVT_WDF_REQUEST_COMPLETION_ROUTINE DeviceReleaseQueueCompletion
_In_z_ PCHAR TargetString
IO_COMPLETION_ROUTINE RequestAsynchronousIrpCompletion
#define CDROM_READ_CAPACITY_TIMEOUT
#define TEST_FLAG(Flags, Bit)
#define CLEAR_FLAG(Flags, Bit)
_In_ WDFREQUEST _In_ BOOLEAN RequestFormated
#define EXCLUSIVE_MODE(_CdData)
_In_ WDFREQUEST _In_ MEDIA_LOCK_TYPE LockType
#define CDROM_TAG_NOTIFICATION
@ PowerDownDeviceQuiesced
#define SET_FLAG(Flags, Bit)
_In_ ULONG _In_ UCHAR _In_ UCHAR PageControl
#define DVD_TAG_DVD_REGION
#define CDROM_TAG_COMPLETION_CONTEXT
#define CDROM_TAG_SENSE_INFO
EVT_WDF_WORKITEM DeviceRestoreDefaultSpeed
#define CLASS_ERROR_LEVEL_2
#define CLASS_ERROR_LEVEL_1
enum _MEDIA_CHANGE_DETECTION_STATE MEDIA_CHANGE_DETECTION_STATE
#define IOCTL_SCSI_EXECUTE_IN
#define SCSIOP_MEDIUM_REMOVAL
struct _MODE_PARAMETER_HEADER10 MODE_PARAMETER_HEADER10
struct _MODE_PARAMETER_HEADER10 * PMODE_PARAMETER_HEADER10
#define SCSIOP_READ_CAPACITY
#define IOCTL_SCSI_EXECUTE_OUT
#define IOCTL_SCSI_EXECUTE_NONE
#define SENSE_BUFFER_SIZE
#define SCSIOP_MODE_SENSE
#define SCSIOP_START_STOP_UNIT
struct _MODE_PARAMETER_HEADER * PMODE_PARAMETER_HEADER
#define SCSIOP_SET_STREAMING
#define SCSIOP_SYNCHRONIZE_CACHE
#define DVD_SET_RPC_KEY_LENGTH
#define IOCTL_DVD_READ_KEY
#define DVD_RPC_KEY_LENGTH
_In_ const GUID _In_ ULONG ExtraDataSize
#define STATUS_INVALID_HANDLE
#define STATUS_NOT_IMPLEMENTED
#define NT_SUCCESS(StatCode)
VOID DeviceReleaseQueue(_In_ WDFDEVICE Device)
NTSTATUS RequestSetContextFields(_In_ WDFREQUEST Request, _In_ PSYNC_HANDLER Handler)
NTSTATUS RequestSend(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDFIOTARGET IoTarget, _In_ ULONG Flags, _Out_opt_ PBOOLEAN RequestSent)
NTSTATUS RequestDuidGetDeviceIdProperty(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
VOID RequestCompletion(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ NTSTATUS Status, _In_ ULONG_PTR Information)
VOID DevicePerfIncrementErrorCount(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension)
VOID RequestSetSentTime(_In_ WDFREQUEST Request)
NTSTATUS RequestDuidGetDeviceProperty(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDF_REQUEST_PARAMETERS RequestParameters, _Out_ size_t *DataLength)
VOID RequestSetReceivedTime(_In_ WDFREQUEST Request)
VOID DeviceSendNotification(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ const GUID *Guid, _In_ ULONG ExtraDataSize, _In_opt_ PVOID ExtraData)
VOID DeviceSendIoctlAsynchronously(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ ULONG IoControlCode, _In_ PDEVICE_OBJECT TargetDeviceObject)
VOID RequestClearSendTime(_In_ WDFREQUEST Request)
VOID DeviceSendStartUnit(_In_ WDFDEVICE Device)
_In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_PARAMETERS RequestParameters
struct _DVD_RPC_KEY * PDVD_RPC_KEY
struct _DVD_COPYRIGHT_DESCRIPTOR * PDVD_COPYRIGHT_DESCRIPTOR
struct _SCSI_REQUEST_BLOCK SCSI_REQUEST_BLOCK
#define SRB_FUNCTION_EXECUTE_SCSI
#define SRB_FLAGS_DATA_OUT
#define SRB_FLAGS_NO_DATA_TRANSFER
#define SRB_FLAGS_DISABLE_DISCONNECT
#define SRB_STATUS_PENDING
#define SRB_SIMPLE_TAG_REQUEST
#define SRB_FLAGS_QUEUE_ACTION_ENABLE
#define SRB_FUNCTION_LOCK_QUEUE
#define SRB_FUNCTION_FLUSH_QUEUE
#define SRB_FUNCTION_UNLOCK_QUEUE
#define SRB_FLAGS_BYPASS_LOCKED_QUEUE
#define SRB_FLAGS_DATA_IN
#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 InterlockedExchangePointer(Target, Value)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define KeRaiseIrql(irql, oldIrql)
#define KeReleaseSpinLock(sl, irql)
#define KeLowerIrql(oldIrql)
#define KeAcquireSpinLock(sl, irql)
#define KeGetCurrentIrql()
#define KeDelayExecutionThread(mode, foo, t)
IN OUT PVCB IN PDEVICE_OBJECT TargetDeviceObject
GLenum const GLfloat * params
GLuint GLsizei GLsizei * length
#define EXCEPTION_EXECUTE_HANDLER
#define InterlockedCompareExchange
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
#define _In_reads_bytes_(s)
#define _In_reads_opt_(s)
#define _Analysis_assume_
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RTL_SIZEOF_THROUGH_FIELD(type, field)
#define UNREFERENCED_PARAMETER(P)
struct _FEATURE_HEADER * PFEATURE_HEADER
enum _FEATURE_NUMBER FEATURE_NUMBER
struct _FEATURE_DATA_FIRMWARE_DATE * PFEATURE_DATA_FIRMWARE_DATE
@ FeatureRestrictedOverwrite
@ FeatureIncrementalStreamingWritable
@ FeatureDefectManagement
@ FeatureRealTimeStreaming
@ FeatureCDAudioAnalogPlay
@ FeatureLogicalUnitSerialNumber
@ FeatureDiscControlBlocks
@ FeatureLayerJumpRecording
@ FeatureMicrocodeUpgrade
@ FeatureRigidRestrictedOverwrite
@ FeatureDvdRecordableWrite
@ FeatureEnhancedDefectReporting
struct _FEATURE_HEADER FEATURE_HEADER
_In_ ULONG _In_ ULONG _In_ ULONG Length
* PSTORAGE_DESCRIPTOR_HEADER
enum _STORAGE_PROPERTY_ID STORAGE_PROPERTY_ID
* PSTORAGE_DEVICE_DESCRIPTOR
@ StorageDeviceIdProperty
* PSTORAGE_DEVICE_ID_DESCRIPTOR
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
VOID NTAPI IoFreeIrp(IN PIRP Irp)
VOID NTAPI IoSetHardErrorOrVerifyDevice(IN PIRP Irp, IN PDEVICE_OBJECT DeviceObject)
#define STATUS_INTERNAL_ERROR
#define STATUS_DEVICE_DOES_NOT_EXIST
NTSTATUS NTAPI IoReportTargetDeviceChangeAsynchronous(IN PDEVICE_OBJECT PhysicalDeviceObject, IN PVOID NotificationStructure, IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL, IN PVOID Context OPTIONAL)
struct DVD_READ_STRUCTURE * PDVD_READ_STRUCTURE
struct _DVD_SET_RPC_KEY * PDVD_SET_RPC_KEY
struct _DVD_COPY_PROTECT_KEY * PDVD_COPY_PROTECT_KEY
#define _SEH2_GetExceptionCode()
#define _SEH2_EXCEPT(...)
#define _SEH2_YIELD(__stmt)
#define IRP_MJ_DEVICE_CONTROL
FORCEINLINE VOID ScratchBuffer_EndUse(_Inout_ PCDROM_DEVICE_EXTENSION DeviceExtension)
#define ScratchBuffer_BeginUse(context)
struct _PERFORMANCE_DESCRIPTOR PERFORMANCE_DESCRIPTOR
struct _MODE_DISCONNECT_PAGE * PMODE_DISCONNECT_PAGE
#define REVERSE_BYTES_SHORT(Destination, Source)
PFIXED_SENSE_DATA senseInfoBuffer
#define REVERSE_BYTES(Destination, Source)
#define SRB_FLAGS_D3_PROCESSING
#define SRB_FUNCTION_QUIESCE_DEVICE
#define KeQueryTickCount(CurrentCount)
#define STATUS_MORE_PROCESSING_REQUIRED
#define STATUS_BUFFER_OVERFLOW
struct _STORAGE_DEVICE_UNIQUE_IDENTIFIER * PSTORAGE_DEVICE_UNIQUE_IDENTIFIER
#define TRACE_LEVEL_WARNING
#define TRACE_LEVEL_VERBOSE
#define TRACE_LEVEL_ERROR
#define TRACE_LEVEL_INFORMATION
DVD_STRUCTURE_FORMAT Format
WDFFILEOBJECT ExclusiveOwner
BOOLEAN ReleaseQueueInProgress
PZERO_POWER_ODD_INFO ZeroPowerODDInfo
WDFMEMORY ReleaseQueueInputMemory
BOOLEAN ReleaseQueueNeeded
PCDROM_PRIVATE_FDO_DATA PrivateFdoData
WDFSPINLOCK ReleaseQueueSpinLock
WDFREQUEST ReleaseQueueRequest
LARGE_INTEGER PartitionLength
DISK_GEOMETRY DiskGeometry
SCSI_REQUEST_BLOCK ReleaseQueueSrb
CDROM_DATA DeviceAdditionalData
BOOLEAN LoggedTURFailureSinceLastIO
struct _CDROM_PRIVATE_FDO_DATA::@1062 Perf
WDFREQUEST OriginalRequest
LARGE_INTEGER TimeReceived
LARGE_INTEGER TimeSentDownLasttTime
PSYNC_HANDLER SyncCallback
LARGE_INTEGER TimeSentDownFirstTime
UCHAR CopyrightProtectionType
UCHAR RegionManagementInformation
UCHAR UserResetsAvailable
UCHAR PreferredDriveRegionCode
union _IO_STACK_LOCATION::@1581 Parameters
struct _IO_STACK_LOCATION::@3980::@4002 Scsi
struct _IO_STACK_LOCATION::@1581::@1582 DeviceIoControl
ULONG LogicalBlockAddress
UCHAR SenseInfoBufferLength
struct _SCSI_REQUEST_BLOCK * NextSrb
ULONG StorageDeviceIdOffset
ULONG StorageDeviceOffset
union _WDF_REQUEST_PARAMETERS::@3883 Parameters
struct _WDF_REQUEST_PARAMETERS::@3883::@3885 Read
struct _WDF_REQUEST_PARAMETERS::@3883::@3887 DeviceIoControl
struct _WDF_REQUEST_PARAMETERS::@3883::@3886 Write
BOOLEAN MonitorStartStopUnit
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_INVALID_DEVICE_REQUEST
#define STATUS_INVALID_PARAMETER
#define STATUS_INVALID_DEVICE_STATE
#define STATUS_INSUFFICIENT_RESOURCES
struct _CDB::_CDB10 CDB10
struct _CDB::_MEDIA_REMOVAL MEDIA_REMOVAL
struct _CDB::_START_STOP START_STOP
struct _CDB::_MODE_SENSE MODE_SENSE
struct _CDB::_SYNCHRONIZE_CACHE10 SYNCHRONIZE_CACHE10
struct _CDB::_SET_STREAMING SET_STREAMING
#define PLUGPLAY_REGKEY_DRIVER
_Must_inspect_result_ _In_ WDFDEVICE Device
#define DECLARE_CONST_UNICODE_STRING(_variablename, _string)
_In_ PDEVICE_OBJECT DeviceObject
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
@ WdfRequestTypeDeviceControl
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
FORCEINLINE WDFDRIVER WdfGetDriver(VOID)
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIOTARGET * IoTarget
FORCEINLINE VOID WDF_OBJECT_ATTRIBUTES_INIT(_Out_ PWDF_OBJECT_ATTRIBUTES Attributes)
#define WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(_attributes, _contexttype)
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
_Must_inspect_result_ FORCEINLINE BOOLEAN WdfRequestSend(_In_ WDFREQUEST Request, _In_ WDFIOTARGET Target, _In_opt_ PWDF_REQUEST_SEND_OPTIONS Options)
FORCEINLINE VOID WDF_REQUEST_SEND_OPTIONS_INIT(_Out_ PWDF_REQUEST_SEND_OPTIONS Options, _In_ ULONG Flags)
@ WDF_REQUEST_SEND_OPTION_IGNORE_TARGET_STATE
@ WDF_REQUEST_SEND_OPTION_SYNCHRONOUS
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
@ WDF_REQUEST_REUSE_NO_FLAGS
FORCEINLINE VOID WDF_REQUEST_PARAMETERS_INIT(_Out_ PWDF_REQUEST_PARAMETERS Parameters)
EVT_WDF_REQUEST_COMPLETION_ROUTINE * PFN_WDF_REQUEST_COMPLETION_ROUTINE
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine
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)
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
#define WDF_NO_OBJECT_ATTRIBUTES
_Must_inspect_result_ _In_ PWDF_WORKITEM_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWORKITEM * WorkItem
_Must_inspect_result_ _In_ ULONG Flags
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
#define IoIsErrorUserInduced(Status)
#define PLUGPLAY_REGKEY_DEVICE