SetFileValidData
SetFileValidData is a privileged Windows function that advances a file's valid-data boundary without initializing the newly exposed bytes.
The caller must enable SE_MANAGE_VOLUME_NAME before opening the handle with GENERIC_WRITE. Skipping initialization can expose previous disk contents to readers. This is not a general-purpose preallocation recommendation. [1]
Allocation size, file size and valid data length are separate stream properties. SetEndOfFile changes file size, whereas SetFileValidData changes the validity boundary. A larger boundary is therefore not evidence that the application wrote the intervening bytes. [2] [3]
MS-FSCC's FileValidDataLengthInformation describes a positive signed 64-bit value above the current VDL and at most the file size. Its documented errors include insufficient privilege and an invalid parameter for sparse or compressed files. This protocol information class must not be treated as a universal Win32 support matrix. [4]
Relations
Limitations
- Access restrictions must protect still-unwritten ranges after interruptions and in later copies, not only against concurrent readers. [1]
Citations
- Microsoft Learn: SetFileValidData, privilege requirements and stale-content disclosure
- Microsoft Learn: SetEndOfFile, file size versus valid data length
- Microsoft Learn: FSRTL_COMMON_FCB_HEADER, separate stream length fields
- Microsoft MS-FSCC 2.4.50: FileValidDataLengthInformation, bounds and errors
Sources & caveats
- Source review of Microsoft API, driver and MS-FSCC documentation, 2026-11-29. No Windows execution, performance measurement or raw-device access was performed.
- The Win32 page disagrees internally about equality with file size and network-file support. No general guarantee is inferred for either; the MS-FSCC bounds describe a separately scoped information class.