dokan-rust icon indicating copy to clipboard operation
dokan-rust copied to clipboard

File is getting deleted even when create_file and delete_file returns STATUS_ACCESS_DENIED

Open ajaykumargdr opened this issue 1 year ago • 1 comments

Environment

  • Windows version: Windows 11 Pro (23H2)
  • Processor architecture: x86
  • Dokany version: 2.2.0.1000

Description

We are trying to restrict deletion of file in some predefined cases. We tried returning STATUSS_ACCESS_DENIED from delete_file if the predefined condition are met. But later we got to know that delete_file is not getting called all the time when a file is getting deleted. So we also tried returning STATUSS_ACCESS_DENIED in create_file if delete_on_close is to true and predefined conditions met, but this also not preventing the file from getting deleted.

We also went thought the Question about preventing dokan delete a file discussion. We tried this fix but it didn't work for us.

ajaykumargdr avatar Oct 25 '24 11:10 ajaykumargdr

Based on this suggestion we tried checking the desired_access and returning STATUS_ACCESS_DENIED if it contains DELETE from the create_file. However this approach is making dokan throwing a error error: process didn't exit successfully: 'target\release\webdrive-app.exe' (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION).

It seems like even after we return the Err(STATUS_ACCESS_DENIED) from the create_file it is somehow continuing the cycle and trying to access the context from other functions like get_file_information. We doubt that since the context is assigned at the end of create_file function, returning error before that causes this issue.

We tried commenting all other code where we use context and this time it didn't give any errors, but it also didn't showed any popup in the explorer such as access denied.

ajaykumargdr avatar Oct 28 '24 06:10 ajaykumargdr