dokan-dev / dokan-dotnet

Dokan DotNet Wrapper
http://dokan-dev.github.io
MIT License
462 stars 116 forks source link

NUL in ReadFile #263

Closed TekuSP closed 3 years ago

TekuSP commented 3 years ago

Greetings,

I have problems with NULs appearing in files, corrupting them this way. image

I tried everything in my code, to remove trailing zeros, to check WriteFile... Nothing worked. How does the buffer system work with WinApi?

Can ReadFile create trailing zeros? Anyone had ever before such issue?

Liryna commented 3 years ago

@TekuSP Hi,

Are you able to reproduce the issue with the sample ? Does the filled buffer size param is correctly set ? Like the read ask for 200bytes, you only set 190 bytes but you set the read field done to 200 still

TekuSP commented 3 years ago

Well, I am trusting Stream to read correctly. I can double check bytesRead value. bytesRead = cryptoStream.Read(buffer, 0, buffer.Length);

TekuSP commented 3 years ago

Nope. bytesRead is correctly set. I tried testing with Debug.WriteLine($"Bytes read for file {fileName} were: {bytesRead}"); And it returned Bytes read for file \test.txt were: 3 Which is correct, but result file is: image

Liryna commented 3 years ago

@TekuSP Could it be that the file size returned to the file informations is the size of the encrypted data while the plain data is smaller in reality? And then the diff would be filled with nul.

TekuSP commented 3 years ago

That is possible, and I will double check that.

TekuSP commented 3 years ago

Yes that was the case! Thank you!