ReadFile reacts strangely to cached informations #335
Replies: 1 comment
-
My understanding of this method is that the buffer array size in the ReadFile input parameters is not configurable by your code. It depends on the application that is making the call to use your dokan drive on what read size they have specified and that's how it comes through into ReadFile. So before your code inside ReadFile decides if it's cached vs not cached the input parameter for I would suggest using process monitor from sysinternals as it can show you each individual ReadFile call including their buffer sizes so you can compare the scenarios easier. This should tell you exactly how the application is trying to read the file without needing to put lots of logging in. |
Beta Was this translation helpful? Give feedback.
-
Hey there, I have been trying to develop a caching mechanism for my dokan-dotnet project, but dokan, especially the ReadFile function doesn't seem to behave like it usually does when opening files this way. To put some context, my project is a mounted dokan drive that acts as a virtual reader for files on a distant server. Now, to explain quickly how this cache works, everytime a file is opened through dokan for the first time, i encrypt it's content with a key that's unique to any user of my application and store it in a real file on the user's computer, now everytime that i boot up my dokan application, i go and read these file in my application's memory, so i don't have to ask my distant server again. I am also using a .csv file to keep tracks of the file that are available in the cache. I already verified and i have no problem getting the exact same data as the one i would get from the server, so the problem is not about the encryption means. I think that the real problem is related to the fact that when trying to read through the file, we read very little data from the file at a time, compared to when i'm not using the data from the cache, as you can see on the two screenshots below :
This is when i'm not using the data from my cache :
And this is when i'm using data from the cache :
We can see on there that the buffer size drastically drops when using the cached data, even though it is the same data, in the same amount.
Here is a gist where most of the code i considered relevant to this issue is, let me know if you'd need any more informations or parts of my code.
https://gist.github.com/Thomas-Giaroli/0ab6e1203203610d97d1c6ea3ebf354d
Thanks already.
Beta Was this translation helpful? Give feedback.
All reactions