SpartanJ / efsw

efsw is a C++ cross-platform file system watcher and notifier.
Other
662 stars 101 forks source link

Fix issue with ReadDirectoryChangesW API on Win32 when buffer overflows #164

Closed r00tcxx closed 1 year ago

r00tcxx commented 1 year ago

On Win32, when using the ReadDirectoryChangesW API to monitor file system changes, if the buffer used to receive system change messages overflows, ReadDirectoryChangesW will still return true but will discard all the content of the buffer. In this case, the lpBytesReturned parameter will be zero. If ReadDirectoryChangesW is not called again after this, we can no longer get new change information.

r00tcxx commented 1 year ago

This issue becomes particularly evident when recursively monitoring an NTFS volume. Once the buffer overflows, the entire monitoring system ceases to function.

SpartanJ commented 1 year ago

Thanks for your contribution! Also: you can enlarge the buffer size for that buffer with the new WatcherOption's (WinBufferSize).