Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open file with zero access mode read permissions in file-id crate #625

Closed
mhnap opened this issue Jul 25, 2024 · 1 comment · Fixed by #639
Closed

Open file with zero access mode read permissions in file-id crate #625

mhnap opened this issue Jul 25, 2024 · 1 comment · Fixed by #639

Comments

@mhnap
Copy link

mhnap commented Jul 25, 2024

As an improvement to the file-id crate, I would propose change:

.read(true)

to:

.access_mode(0)

From https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea#files:

The dwDesiredAccess parameter can be zero, allowing the application to query file attributes without accessing the file if the application is running with adequate security settings. This is useful to test for the existence of a file without opening it for read and/or write access, or to obtain other statistics about the file or directory.

For example, currently, I get an error trying to get info for C:\Users\Administrator\AppData\Local\Microsoft\Windows\UsrClass.dat file:

Os {
    code: 32,
    kind: Uncategorized,
    message: "The process cannot access the file because it is being used by another process.",
},
dfaust added a commit to dfaust/notify that referenced this issue Sep 15, 2024
dfaust added a commit to dfaust/notify that referenced this issue Sep 15, 2024
@dfaust
Copy link
Member

dfaust commented Sep 15, 2024

Good suggestion. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants