Problem copying file from dokan file system to a folder on Windows

494 views
Skip to first unread message

Roberto Carlos Fernandez Gerhardt

unread,
Apr 15, 2016, 6:21:13 AM4/15/16
to Dokan
Hi!

I'm making a Dokan(y) file system for reading old floppy disk images.

I got it mostly working and I can even do a file preview with Total Commander, but when I try to extract the file to a regular windows folder, I get a "Remove the write protection" error.

Sometimes I get a "Your internet security settings don't allow you to download this file" type of error.

Maybe I need to implement the GetFileSecurity function, but I don't really know what the system is expecting.

Has anyone run into the same issue?

Here you have a screen capture of a mounted 180KB floppy image:


Thanks in advance!

Rob

Roberto Carlos Fernandez Gerhardt

unread,
Apr 16, 2016, 6:03:01 AM4/16/16
to Dokan
Hi,

I noticed that if I try to open a file on my filesystem with HxD hex editor, it tries to read way beyond the end of file.

For example, opening a 6144 byte file, trying to get to the will try to read a number of bytes at offset 7538464...

Could the program be assuming it's reading the file on a ntfs filesystem and assuming ntfs values?

Thanks,
Rob

Roberto Carlos Fernandez Gerhardt

unread,
Apr 16, 2016, 11:43:34 AM4/16/16
to Dokan
Hello everyone!

I've managed to retrieve the files on my filesystem by zipping them instead of copying them directly XD

Now, it seems that when files are accesed via CreateFile with the following access mask:

READ_CONTROL
SYNCHRONIZE
STANDARD_RIGHTS_REQUIRED
STANDARD_RIGHTS_ALL
SPECIFIC_RIGHTS_ALL 

everything goes well.

But, if the file is opened only with SPECIFIC_RIGHTS_ALL, ReadFile is not called at all.

Do I have to fill the PDOKAN_IO_SECURITY_CONTEXT structure? Which values would be needed?

I still don't know why HxD Hex Editor doesn't get the right file size and tries to get all to 0xFFFFFFFF if you tell him t go to the end of file...

Cheers,
Rob

On Friday, April 15, 2016 at 12:21:13 PM UTC+2, Roberto Carlos Fernandez Gerhardt wrote:

Roberto Carlos Fernandez Gerhardt

unread,
Apr 17, 2016, 2:00:11 PM4/17/16
to Dokan
Hi,

I asked Maël Hörz, author of the HxD Hex Editor, on the subject, and he kindly debugged his program with my filesystem and found that IOCTL_DISK_GET_DRIVE_GEOMETRY was returning values that don't reflect the actual disk geometry of the file system.

I found that on device.c the answer to that query is done via the DokanPopulateDiskGeometry function, which return predefined values.

Is this meant to work this way? Or is it any way I could provide the right values? Disk images for my file system can range from 180 to 720 KB and I would need to pass the right values.

Thanks,
Rob

Liryna

unread,
Apr 19, 2016, 4:01:38 PM4/19/16
to Dokan
Hi Roberto,

About  IOCTL_DISK_GET_DRIVE_GEOMETRY, you are right the values are predefined.
But with last changes (after 1.0.0-RC2 release), there is AllocationUnitSize & SectorSize as DokanOptions.
https://github.com/dokan-dev/dokany/blob/master/samples/dokan_mirror/mirror.c#L1343
https://github.com/dokan-dev/dokany/blob/master/samples/dokan_mirror/mirror.c#L1347

This will help you to pesonnalize your sector size as you want.
(careful with windows restriction -> https://github.com/dokan-dev/dokany/blob/90ee4996d9eee2f78a774b9bc509172adfaf29f6/dokan/dokan.c#L162 )

About windows requesting to read much more far than the size of the file...does notepad also request wrong offset ?
Normally such issue happen from an incorrect information returned (wrong file size or such).

I hope I answered your questions,
Liryna

Roberto Carlos Fernandez Gerhardt

unread,
Apr 20, 2016, 8:09:31 AM4/20/16
to Dokan
Hi,

Thanks for your answer!

I'll be compiling the latest master and test the new DokanOptions.

Regarding the restrictions, I think that it's good to enforce them if the filesystem is FAT or NTFS, but if you're mounting a different filesystem, you could have values out of that range. Mine has 256 byte sector size so Windows would still retrive incorrect information about my filesystem size.

I tried opening a file from my filesystem with notepad on Windows 7, and the offset and size requested are ok, but it still gives an "Incorrect parameter" error.

As I told earlier, I can zip or 7-zip the files and extract them in a standard folder, but notepad, hxd and explorer itself have issues due to incorrect drive geometry params.

Cheers,
Rob

Liryna

unread,
Apr 20, 2016, 3:34:06 PM4/20/16
to Dokan
Hi,

I never tried sector size < 256, it would be nice if you can give feedback! If everything worked I would allow until 128 sector size.


>notepad, hxd and explorer itself have issues due to incorrect drive geometry params.
The sample mirror does not have such issue, what is the difference with your FS ?

Best regards,
Reply all
Reply to author
Forward
0 new messages