Windows: improve mounted volume storage identity - #1840
Open
0x1337F00D wants to merge 1 commit into
Open
Conversation
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
This improves the Windows storage identity reported by mounted VeraCrypt volumes without introducing a new driver ABI or registry option.
It fixes two separate contract problems:
STORAGE_DEVICE_DESCRIPTOR.DeviceTypewas populated withFILE_DEVICE_DISK(0x07). In a storage device descriptor this field uses SCSI peripheral device types, where0x07means optical memory. Mounted volumes now reportDIRECT_ACCESS_DEVICE(0x00).No debug fields, performance counters, direct-I/O changes, DCS changes, or new registry gates are included.
Raw-volume identity
For a normal volume mounted from a raw partition or whole disk, the driver records the complete lower-stack
STORAGE_DEVICE_NUMBERtuple and the host partition starting offset.When the identity is complete and representable, responses are derived from:
The same values are then used for:
IOCTL_STORAGE_GET_DEVICE_NUMBERIOCTL_VOLUME_GET_VOLUME_DISK_EXTENTSIOCTL_DISK_GET_PARTITION_INFO[_EX]IOCTL_DISK_GET_DRIVE_LAYOUT[_EX]IOCTL_STORAGE_READ_CAPACITYThis preserves valid whole-disk
PartitionNumber == 0values and avoids mixing fields from unrelated lower-stack queries.The existing opt-in controls remain authoritative:
TC_DRIVER_CONFIG_ENABLE_EXTENDED_IOCTLgates the extended storage IOCTLs.VC_DRIVER_CONFIG_ALLOW_WINDOWS_DEFRAGgates volume disk extents.Fail-closed cases
Physical identity is not published when the backing tuple is incomplete, arithmetic or host bounds fail, sector alignment is invalid, or the result cannot be represented by the MBR-compatible view currently returned by this driver.
The physical view is also excluded for:
File containers therefore receive the corrected direct-access device type but keep the existing synthetic partition geometry. They intentionally do not receive an invented physical disk number or extent: no matching
PhysicalDriveN/PnP disk exists for such a number.Validation
Development and runtime validation were performed only on Windows 11 ARM64 in a Parallels VM with a locally test-signed driver.
The final one-commit tree built successfully as an ARM64 Release driver:
33c7eb2dbc68e851ef3a9c5ab8901b5cef2a5a5cveracrypt.sysSHA-256:8FD4B559E884E3E9D3E6873161BD48083012363BB673F0693D81364FEA62C4E1Runtime validation combined this commit with the ARM64 system-encryption branch and verified the installed driver hash before loading it as a demand-start test driver.
File-container checks:
STORAGE_DEVICE_DESCRIPTOR.DeviceType = 0BusType = BusTypeVirtualchkdskcompleted without errorsRaw VHD-backed partition checks:
196608, length262144458752STORAGE_DEVICE_DESCRIPTOR.DeviceType = 0chkdskcompleted without errorsNo VM snapshot was created. Testsigning, the test service, driver file, and VHD were removed afterward, and Secure Boot was restored.
Scope boundary
This is an IOCTL compatibility change, not a new Windows PnP storage architecture. It does not create a disk PDO or partition PDO for
\Device\VeraCryptVolumeX.Consequently, consumers that query the mounted handle directly can correlate a raw VeraCrypt volume with its real backing disk and extent, but the modern Storage module (
Get-Volume/Get-Partition) still does not enumerate the decrypted view as a separate PnP disk or partition. Solving that requires a real storage-stack participant and should be reviewed independently.x64 Windows, bare-metal hardware, Windows Backup and Restore, and third-party imaging products have not yet been tested.
Related background: #1664, #1036.