Weird behaviour with notepad writes in Dokan

Hi,

I am having some issues understanding how notepad deals with saving a file. I am using Dokan (0.6.0) on Windows 7 64-bit, so my perspective is from that.

What I get when I save is:

  • CreateFile, with OPEN_ALWAYS and FILE_APPEND_DATA
  • A write, neither paging io or nocache flag set (but synchronous io is). But the offset is 0, and it writes the entire file content.

This means that while I interpret FILE_APPEND_DATA to mean it wants to append any writes to the end of file, what it actually does is write as if it wanted to do CREATE_ALWAYS. So the entire original file is appended to itself + changes.

I understand that notepad uses memory mapping, but I can’t really see how that would result in this behaviour. Is it a bug in Dokan perhaps? Is there some new flag I should check deeper down? There is also a bit in the code that checks the ByteOffset with FILE_WRITE_TO_END_OF_FILE, but that doesn’t seem to work ever.

I appreciate any help you may give!