Repository navigation
Conversation
The partition refresh opened every drive letter from A: to Z: to read IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, including CD/DVD/BD drives. This runs every partition refresh interval and on every device change, so it also runs right after a disc is inserted. While the optical volume is open (or the open is blocked while the drive spins up), Windows vetoes ejects and device removal (Kernel-PnP event 225), and a newly inserted disc can be ejected again with "Please insert a disk into drive X:". Optical drives are not GUID_DEVINTERFACE_DISK devices, so their volumes never contain extents of a monitored disk. Detect them through QueryDosDevice (\Device\CdRom*), which only reads the object manager symbolic link and does not touch the device, and skip them in both the drive-letter scan and the Storage Spaces volume enumeration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When LibreHardwareMonitor (DiskInfoToolkit 2.2.2) is running, swapping discs in an internal Blu-ray drive fails: the first disc reads fine, but the second disc is ejected again and Windows shows "Please insert a disk into drive F:". Disabling the drive in Device Manager is also refused. The System log shows Kernel-PnP event 225 (an application stopped the removal or ejection of the device) for the LibreHardwareMonitor process. Closing LibreHardwareMonitor fixes it immediately.
Cause
StoragePartitionReader.AssignDriveLettersAndFreeSpacechecks every drive letter fromA:toZ:throughWindowsVolumeExtentMap.TryGet, which opens\\.\X:and sendsIOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS. This includes optical drives.This scan runs on the partition refresh interval and after every
DBT_DEVICEARRIVAL/DBT_DEVNODES_CHANGED, so it also runs right after a disc is inserted. While the optical volume handle is open, or whileCreateFileis blocked because the drive is spinning up, Windows vetoes the eject or removal.Optical drives are not
GUID_DEVINTERFACE_DISKdevices, so their volumes can never contain extents of a disk that DiskInfoToolkit monitors. Opening them gains nothing.WindowsStorageSpaceVolumeReader.ReadVolumeDiskNumbershas the same pattern: it opens every volume returned byFindFirstVolume/FindNextVolume.Changes
Utilities/OpticalDeviceHelper: detects optical volumes withQueryDosDevice(target starts with\Device\CdRom). This only reads the object manager symbolic link and never opens the device.WindowsVolumeExtentMap.TryGet: optical drive letters return an unsuccessful lookup without opening the volume. The result is not reported as severe or failed, so a partition refresh is never aborted because of an optical drive.WindowsStorageSpaceVolumeReader.ReadVolumeDiskNumbers: skips volumes whose NT device name (already resolved viaQueryDosDevice) is an optical device.OpticalDeviceHelperTestcovers device name matching and unknown DOS device names.Testing
dotnet build DiskInfoToolkit.sln -c Release: all targets (net472, net481, netstandard2.0, net8.0, net9.0, net10.0) build with 0 warnings and 0 errors.dotnet test: 59 passed, 0 failed (12 new).F:→\Device\CdRom0),F:is detected as optical and every disk still gets its drive letters (C:, D:/E:, I:, M:, N:, S:).Note
This change was written with the help of an AI coding assistant (Claude Opus in Claude Code). I reviewed it and verified it myself on the machine where the problem occurred: with LibreHardwareMonitor built against this branch running, the Blu-ray disc swap issue no longer occurs, and the existing disks still show their drive letters and sensor data.
🤖 Generated with Claude Code