When the application writes data to the file, this data goes to the system cache. After the application closes the file the cache is flushed to the disk by the system cache manager and only after than the file is closed on the filesystem. The application has no way to know that the error has happened because the error (in your case) happens long after CloseHandle has been completed.

The OnCleanupFile callback is optional. If you implement it then it will be always called synchronously when a file handle is being closed by the use of CloseHandle or ZwClose API. Unfortunately although these API have returned error parameter Windows doesn't expect that the handle closing operation can fail. We have experimented with this and tried to return error from the driver during the cleanup request handling, but Windows ignored any error.

Quote

tweety wrote:
One thing is strange: all throws from close and cleanup are displayed to the user on renaming file. Why is that?

During file renaming CBFS first calls the OnCleanup and OnClose callbacks for all openings of the the file, then calls the OnRename callback, and then the OnOpen callback for the renamed file (again for all openings). It isn't correct there that an error thrown from the OnCleanup and OnClose callbacks is taken into account there. We will correct it.

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.