dokan-dev / dokany

User mode file system library for windows with FUSE Wrapper
http://dokan-dev.github.io
5.15k stars 657 forks source link

When is ReadFile() called? #1221

Closed lailtonwbc closed 1 month ago

lailtonwbc commented 1 month ago

I want to download a file when I open it(when I double click to run it or when I open a document, etc). So I am implementing something in DOKAN_OPERATIONS ReadFile() api callback. I am going to download a file when ReadFile() is called. But it seems that ReadFile() is also called in many other cases. When I move mouse over some files(ex: test.exe file), ReadFile() of test.exe is called. When I open a folder which test.exe is in, ReadFile() of test.exe is called. When I double click test.exe, ReadFile() of test.exe is called. When I click mouse right button on test.exe, ReadFile() of test.exe is called. Is there a way to know that I really open a file to run exe file or read a document file in ReadFile()? If I am trying in wrong way, then how to download a file when we need(open) it?

Environment: Dokan Version: 2.1.0 Operating System: Win10 & Win11

Liryna commented 1 month ago

It is expected that the system or apps do random read to try to find what it contains or just to generate a thumbnail / preview. If you want to know whether you should download the file, you will need to analyze the pattern see if sequential reads are happening and therefore has a good chance to end up reading the whole.