Repository: dokan-dev/dokany

Issue #843: Cannot Mount Removable Drive with mirror.exe
Created: 2019-10-31T15:13:37Z
Environment

Windows version: 10.0.14393
Processor architecture: x64
Dokany version: 1.1.0
Library type (Dokany/FUSE): n/a

Check List

 I checked my issue doesn't exist yet
 My issue is valid with mirror default sample and not specific to my user-mode driver implementation
 I can always reproduce the issue with the provided description below.
 I have updated Dokany to the latest version and have reboot my computer after.
 I tested one of the last snapshot from appveyor CI

Description
Running mirror with options Mount Manager & removable drive fails to mount.
Steps to reproduce:
Run mirror.exe with following parameters (including Mount Manager & removable drive)
mirror.exe /o /m /d /s /r C:\tmp /l h
CMD logs (tested with Dokany/mirror 1.1.0 & 1.3.0):
With option "use removable drive"

mirror.exe /o /m /d /s /r C:\Users /l h
RootDirectory: C:\Users
Attempting to add SE_SECURITY_NAME privilege to process token ##
failed: Unable to adjust token privileges: 1300
Failed to add security privilege to process
=> GetFileSecurity/SetFileSecurity may not work properly
=> Please restart mirror sample with administrator rights to fix it
Dokan: debug mode on
Dokan: use stderr
AllocationUnitSize: 512 SectorSize: 512
device opened
Dokan Error: CreateFile failed \.\Volume{d6cc17c5-1724-4085-bce7-964f1e9f5de9}: 5
Dokan Error: CreateFile failed \.\Volume{d6cc17c5-1724-4085-bce7-964f1e9f5de9}: 5
Dokan Error: DokanKeepAlive CreateFile failed \.\Volume{d6cc17c5-1724-4085-bce7-964f1e9f5de9}: 5
Dokan Error: CreateFile failed \.\Volume{d6cc17c5-1724-4085-bce7-964f1e9f5de9}: 5
Dokan Error: CreateFile failed \.\Volume{d6cc17c5-1724-4085-bce7-964f1e9f5de9}: 5
Dokan Error: CreateFile failed \.\Volume{d6cc17c5-1724-4085-bce7-964f1e9f5de9}: 5
mounted: h -> \Volume{d6cc17c5-1724-4085-bce7-964f1e9f5de9}
Mounted
Unmounted
unload Success

=================
Without option "use removable drive"

mirror.exe /o /d /s /r C:\Users /l h
RootDirectory: C:\Users
Attempting to add SE_SECURITY_NAME privilege to process token ##
failed: Unable to adjust token privileges: 1300
Failed to add security privilege to process
=> GetFileSecurity/SetFileSecurity may not work properly
=> Please restart mirror sample with administrator rights to fix it
Dokan: debug mode on
Dokan: use stderr
AllocationUnitSize: 512 SectorSize: 512
device opened
###QueryVolumeInfo -001
GetVolumeInfmounted: h -> \Volume{d6cc17c5-173f-4085-bce7-964f1e9f5de9}
ormation: max component length 255
Mounted
GetVolumeInformation: file system name NTFS
GetVolumeInformation: got file system flags 0x03e700ff, returning 0x0004000f
###Create 0000
.....

Strange is that despite the message "Failed to add security privilege to process ...", visible on both options for mount, the one without "use removable drive" manages to mount, whereas the other is failing
Logs
logs_mountmanager&removabledrive.txt

Duplicate issue #920: Access denied, when using remote desktop
Created: 2020-07-28T06:35:09Z
Environment

Windows version: Windows 10, V1903
Processor architecture: x64
Dokany version: 1.3.1.1000
Library type (Dokany/FUSE): FUSE

Check List

 I checked my issue doesn't exist yet
 My issue is valid with mirror default sample and not specific to my user-mode driver implementation
 I can always reproduce the issue with the provided description below.
 I have updated Dokany to the latest version and have reboot my computer after.
 I tested one of the last snapshot from appveyor CI

Description
I have implemented a fuse-based filesystem, which works well on many machines, when logged in locally. However, if I run the same program via remote desktop or as a Jenkins job, Windows denies the access to the volume to each of the worker threads. I have passed the debug flag to the fuse implementation and got the following output, when running on a remote machine:
stderr:
Dokan: debug mode on
Dokan: use stderr
AllocationUnitSize: 512 SectorSize: 512
device opened
Dokan Error: CreateFile failed \\.\Volume{d6cc17c5-1734-4085-bce7-964f1e9f5de9}: 5
Dokan Error: CreateFile failed \\.\Volume{d6cc17c5-1734-4085-bce7-964f1e9f5de9}: 5
Dokan Error: CreateFile failed \\.\Volume{d6cc17c5-1734-4085-bce7-964f1e9f5de9}: 5
Dokan Error: CreateFile failed \\.\Volume{d6cc17c5-1734-4085-bce7-964f1e9f5de9}: 5
Dokan Error: CreateFile failed \\.\Volume{d6cc17c5-1734-4085-bce7-964f1e9f5de9}: 5
Dokan Error: CreateFile failed \\.\Volume{d6cc17c5-1734-4085-bce7-964f1e9f5de9}: 5
Dokan Error: CreateFile failed \\.\Volume{d6cc17c5-1734-4085-bce7-964f1e9f5de9}: 5
CreateMountPoint C:/temp/VD.281536/mnt -> \??\Volume{d6cc17c5-1734-4085-bce7-964f1e9f5de9}\ success
Dokan Error: CreateFile failed \\.\Volume{d6cc17c5-1734-4085-bce7-964f1e9f5de9}: 5
Dokan Error: CreateFile failed \\.\Volume{d6cc17c5-1734-4085-bce7-964f1e9f5de9}: 5
mounted: C:/temp/VD.281536/mnt -> \Volume{d6cc17c5-1734-4085-bce7-964f1e9f5de9}
Mounted
Dokan Error: CreateFile failed \\.\Volume{d6cc17c5-1734-4085-bce7-964f1e9f5de9}: 5
Unmount

When doing the same logged in locally, the following output occurs and everything works as expected:
Dokan: debug mode on
Dokan: use stderr
AllocationUnitSize: 512 SectorSize: 512
device opened
CreateMountPoint C:/Users/<username deleted>/AppData/Local/Temp/VD.704801/mnt -> \??\Volume{d6cc17c5-1734-4085-bce7-964f1e9f5de9}\ success
###QueryVolumeInfo -001
GetVolumeInformation
mounted: C:/Users/<username deleted>/AppData/Local/Temp/VD.704801/mnt -> \Volume{d6cc17c5-1734-4085-bce7-964f1e9f5de9}
Mounted
###Create 0000
CreateFile: \
	DesiredAccess: SYNCHRONIZE|FILE_READ_DATA
	ShareAccess: FILE_SHARE_DELETE|FILE_SHARE_WRITE|FILE_SHARE_READ
...


I have tried this on different machines with different OS levels varying from Windows Server 2012R2 up to Windows 10 V1903, but the result is always the same. From looking at the source code, I think the error occurs in DokanLoop, where each thread tries to access the volume via CreateFile in order to call DeviceIOControl afterwards, but for some reason Windows denies the access to the volume, if logged in remotely. I have tried to replicate this with the mirror example, but the mirror example does not build with Visual Studio, I cannot use cygwin for this.
Any idea what's going on here or how to circumvent this?

Closing comment (2020-08-04T07:42:32Z): Duplicate of #843 @martin5233 we can continue there if you would like.