Menu ▾ ▴

System encryption pretest fails with "The parameter is incorrect" (File::Write) on NVMe drives requiring 16-byte buffer alignment (AlignmentMask = 0xF)

Tod Dot
2026-10-02
2026-10-05
  • Tod Dot

    Tod Dot - 2026-10-02

    Summary

    System encryption pretest fails on a Lenovo ThinkPad X1 Carbon Gen 14 with
    "The parameter is incorrect. Source: VeraCrypt::File::Write:959" (1.26.24)
    and "VeraCrypt::File::Write:1024" (1.26.29).

    The root cause appears to be buffer alignment: the NVMe drive / stornvme
    reports AlignmentMask = 0xF (16-byte), and Windows rejects raw disk I/O
    whose buffer address is not 16-byte aligned with ERROR_INVALID_PARAMETER (87).
    Most drives report AlignmentMask = 0x3 (4-byte), which is why the issue
    does not appear on other hardware.

    Environment

    • Machine: Lenovo ThinkPad X1 Carbon Gen 14, Type 21V7
    • BIOS: N4OET51W (1.14), UEFI, GPT
    • OS: Windows 11 Pro 25H2, build 26200
    • Drive: SAMSUNG MZVL81T0HFLB-00BLL (Lenovo OEM), firmware 4L2QKXF7
    • Sector size: logical 512, physical 4096
    • Controller: Standard NVM Express Controller (stornvme 10.0.26100.7920)
    • VeraCrypt: 1.26.24 and 1.26.29, both fail the same way
    • BitLocker fully decrypted, Secure Boot off

    Reproduction

    1. System > Encrypt system partition/drive (single boot, encrypt Windows partition)
    2. Complete the wizard up to System Encryption Pretest
    3. Click Test -> error "The parameter is incorrect. Source: VeraCrypt::File::Write:959"
    4. VeraCrypt rolls back the EFI loader files

    Diagnostics

    Process Monitor: VeraCrypt Format.exe opens \Device\Harddisk0\DR0 for
    Read/Write, then closes it ~240 ms later with no WriteFile logged, and rollback
    starts immediately. The write is rejected by the I/O manager before an IRP
    reaches the storage stack, which is consistent with an alignment check.

    A read-only test (attached script) querying IOCTL_STORAGE_QUERY_PROPERTY
    (StorageAdapterProperty) and reading 4096 bytes from \.\PhysicalDrive0
    with different buffer offsets from a page-aligned base:

    AlignmentMask=0xF MaxTransfer=262144 MaxPhysPages=513 BusType=17 (NVMe)

    buffer offset 0 -> OK
    buffer offset 4 -> ERROR 87
    buffer offset 8 -> ERROR 87
    buffer offset 12 -> ERROR 87
    buffer offset 16 -> OK
    buffer offset 32 -> OK
    buffer offset 64 -> OK
    buffer offset 76 -> ERROR 87
    buffer offset 80 -> OK
    buffer offset 512 -> OK

    Same result with and without FILE_FLAG_NO_BUFFERING.

    Our analysis suggests the buffer passed to WriteFile in File::Write is a
    member inside a larger object, landing at offset 76 (4-byte aligned but
    not 16-byte aligned).

    Disabling VBS/HVCI/System Guard and Secure Boot made no difference.

    Suggested fix

    Allocate buffers used for raw device I/O with explicit alignment
    (e.g. _aligned_malloc / VirtualAlloc, or align to at least the device
    AlignmentMask + 1 / sector size), or copy into an aligned bounce buffer
    in File::Write / File::Read before calling WriteFile / ReadFile.

    Older reports with the same error at different line numbers, never resolved:

    Newer NVMe drives/platforms reporting 16-byte alignment may make this
    more common going forward.

     
  • Tod Dot

    Tod Dot - 2026-10-05

    Update: second affected machine (UFS storage, 4K sectors)

    Tested a second machine with a different vendor, storage type and controller.
    The same buffer alignment issue is present, plus a 4K sector size.

    Environment

    • Machine: ASUS Vivobook Go 15 E1504TA
    • BIOS: E1504TA.311 (2025-11-13), UEFI, GPT
    • OS: Windows 11 Pro 25H2, build 26200.8037
    • Drive: MICRON MT256GBEAZ4U31, firmware 0102, soldered UFS (not NVMe, not replaceable)
    • Controller: Intel Universal Flash Storage (UFS) Host Controller (storufs 10.0.26100.7920)
    • Sector size: logical 4096, physical 4096 (4Kn)
    • VeraCrypt 1.26.24, BitLocker fully decrypted, Secure Boot off

    VeraCrypt error on this machine: [PASTE ERROR TEXT HERE]

    Alignment test (same read-only script as above)

    AlignmentMask=0x7 MaxTransfer=524288 MaxPhysPages=64 BusType=19 (UFS)

    buffer offset 0 -> OK
    buffer offset 4 -> ERROR 87
    buffer offset 8 -> OK
    buffer offset 12 -> ERROR 87
    buffer offset 16 -> OK
    buffer offset 76 -> ERROR 87
    buffer offset 80 -> OK

    Same result with and without FILE_FLAG_NO_BUFFERING.

    This controller requires 8-byte alignment rather than 16-byte, but offset 76
    still fails (76 mod 8 = 4). Any buffer that is only 4-byte aligned fails on
    both machines.

    Second blocker: 4Kn logical sectors

    The drive reports 4096-byte logical sectors. As far as I understand,
    VeraCrypt system encryption requires 512-byte logical sectors. UFS devices
    cannot be reformatted to 512-byte LBA, so this machine cannot be
    system-encrypted even if the alignment issue is fixed. Can you confirm 4Kn
    support status for system encryption, and whether it is planned?

    DiskCryptor fails too

    DiskCryptor 2.0.1 pre-release fails on the same machine when starting
    encryption of C: with "Error start encrypt volume [C:] Error: read/write error".
    I have not traced the cause there, but it suggests the problem is not unique
    to VeraCrypt: either 4Kn sectors or the stricter alignment breaks raw disk I/O
    in other disk encryption tools as well.

    Summary

    Machine Storage Logical sector AlignmentMask Offset 76
    Lenovo X1 Carbon G14 Samsung NVMe 512 0xF (16) FAIL
    ASUS Vivobook Go 15 Micron UFS 4096 0x7 (8) FAIL

    Controllers that require more than 4-byte alignment are becoming common on
    new platforms (NVMe and UFS). Aligning raw I/O buffers to at least the sector
    size (e.g. _aligned_malloc / VirtualAlloc) would cover both cases.

     

Log in to post a comment.