I'm running into an issue that I don't quite understand and I'm hoping someone out there can explain it to me.

I open a file on my virtual disk and read it into a program like notepad and then close it. After that happens someone else externally to my Windows system writes some data into the file and changes its size. After that I go back and read the file with notepad and I only see the original file, not the new changes that were made.

I logged a lot of debugging messages to try to understand this and it seems like notepad does a call to the CbFsGetFileInfo callback to determine how many bytes it should read. When I get that call, my system passes back to CbFs in the EndOfFile parameter the correct length. This is followed immediately by a call to the CbFsReadFile callback where the BytesToRead parameter is somehow set to the old length of the file rather than the new length that I passed back in the GetFileInfo callback. So, my system only reads that amount of bytes and that is why I see only the old file data rather than the new data. I am quite puzzled as to why the CbFsReadFile callback is being passed the incorrect information in the BytesToRead parameter. Anybody have any ideas as to why this is happening?

I looked over my debugging logs a little closer and I think I may have an explanation for this.

When the CbFsGetFileInfo callback is called, I log the originating process and it is notepad, but when the CbFsReadFile callback is called, the originating process is the null string. I am also logging the process that opened the file and that is always Windows Explorer.

So, what I believe is happening is that because I mistakenly set CallAllOpenCloseCallbacks to FALSE!

I just reset it back to TRUE and I will let you know if that fixes the problem.

"null" process is Memory Manager of Windows. Notepad works via memory-mapped files, which means that the file is mapped into a memory block and then Notepad works with it. When the file is closed, memory manager flushes the block of memory to the disk, but this can be not immediate.

I've checked it and haven't been able to reproduce it. What type of the CallbackFS library (C++, Delphy, .NET2.0, .NET1.1) and what version of Windows do you use? And please specify in more details your actions that cause the problem.

Well with a little more experimentation I am now convinced that the problem lies somewhere in my system's code rather than yours, so you do not need to work on this anymore until I can find some more evidence that shows that CbFs may be doing something wrong. As of now, I believe you are doing everything right and my code is just not setting things correctly.

We use cookies to help provide you with the best possible online experience. By using this site, you agree that we may store and access cookies on your device. You can find out more about and set your own preferences here.