kpaseetpin - 2016-09-22

I guess i have to beat the devs over the head with steps to reproduce.

Steps to reproduce

  1. Create a test file

    • Create a file called HelloWorld.txt on an NTFS formatted volume
    • Open the file in Notepad, and enter the contents "Hello, world!"
    • Save the file, and close notepad
  2. Encrypt the file using NTFS encryption

    • Right click the file HelloWorld.txt in Windows Explorer, and select Properties
    • On the General tab, click the Advanced button
    • Check the Encrypt contents to secure data checkbox
    • Click OK to close and Advanced attributes dialog box
    • Click OK to close the HelloWorld.txt Properties dialog box
  3. Copy the NTFS EFS encrypted file to a Veracrypt mounted partition

    • Right click the file HelloWorld.txt in Windows Explorer, and select Copy
    • In Windows Explorer, navigate to a mounted, NTFS formatted, Veracrypt volume
    • Right-click in the Windows Explorer file list, and select Paste
    • Notice the error Invalid MS-DOS function

To eliminate any blame of Explorer, i created a sample program that simply does:

CopyFile("c:\temp\HelloWorld.txt", "f:\HelloWorld.txt", false);

The function fails, and GetLastError returns ERROR_INVALID_FUNCTION (1): "Incorrect function"

Using Process Monitor reveals a call to DeviceIOControl with the IOCTL IOCTL_MOUNTDEV_QUERY_DEVICE_NAME. The function call fails with Invalid Parameter.

From MSDN:

Support for this IOCTL by the mount manager clients is mandatory. Upon receiving this IOCTL a client driver must provide the (nonpersistent) device (or target) name for the volume. The mount manager uses the device name returned by the client as the target of a symbolic link. An example of a device name would be "\Device\HarddiskVolume1".

(Emphasis mine)

You can see the stack trace chain leading up to the DeviceIOControl:

Module Function
KERNELBASE.dll DeviceIOControl
KERNELBASE.dll GetVolumeNameForRoot
KERNELBASE.dll GetVolumePathNameInternalW
KERNELBASE.dll GetVolumePathNameW
feclient.dll EfspGetFullName
feclient.dll CEfsClientBase::LocateAndConnectToService
feclient.dll CEfsClientBase::EfsFileKeyInfoClient
feclient.dll EfsClientGetKeyInfo
feclient.dll EfsClientGetEncryptedFileVersion
KERNELBASE.dll Tbsi_Physical_Presence_Command
KERNELBASE.dll BasepCopyFileW
KERNELBASE.dll CopyFileExW
KERNELBASE.dll CopyFileW
TestVeraCryptBug.exe TestVeraCryptBug.exe + 0x4e224

Now that i've done the hard work, can you please respond correctly to the IOCTL_MOUNTDEV_QUERY_DEVICE_NAME i/o control code when asked for it?

(GitHub issue can be found here)

 

Last edit: kpaseetpin 2018-04-19