diff --git a/Source/IO/FS/Watcher.NT.cpp b/Source/IO/FS/Watcher.NT.cpp index 71422e87..76ae48d2 100644 --- a/Source/IO/FS/Watcher.NT.cpp +++ b/Source/IO/FS/Watcher.NT.cpp @@ -370,37 +370,47 @@ namespace Aurora::IO::FS return ScheduleOnce(); } - // Request OP lock bool NTWatchObject::ScheduleOnce() { - bool firstTime = !this->ntOverlapped.hEvent; - this->ntOverlapped.hEvent = (HANDLE)this->parent->ntEvent_->GetHandle(); + bool bFirstTime = !this->ntOverlapped.hEvent; + + if (bFirstTime) + { + this->ntOverlapped.hEvent = (HANDLE)this->parent->ntEvent_->GetHandle(); + } - if (AuSwInfo::IsWindows8OrGreater()) + if (!this->bWin7Mode && + AuSwInfo::IsWindows8OrGreater()) { REQUEST_OPLOCK_INPUT_BUFFER input { REQUEST_OPLOCK_CURRENT_VERSION, sizeof(REQUEST_OPLOCK_INPUT_BUFFER), OPLOCK_LEVEL_CACHE_READ | OPLOCK_LEVEL_CACHE_HANDLE, - firstTime ? REQUEST_OPLOCK_INPUT_FLAG_REQUEST : REQUEST_OPLOCK_INPUT_FLAG_ACK, + bFirstTime ? REQUEST_OPLOCK_INPUT_FLAG_REQUEST : REQUEST_OPLOCK_INPUT_FLAG_ACK, }; - DWORD bytesReturned; - if (DeviceIoControl(this->hFileHandle, FSCTL_REQUEST_OPLOCK, &input, sizeof(input), &whoAsked_, sizeof(whoAsked_), &bytesReturned, &this->ntOverlapped)) + DWORD dwBytesReturned; + if (::DeviceIoControl(this->hFileHandle, + FSCTL_REQUEST_OPLOCK, + &input, sizeof(input), + &whoAsked_, sizeof(whoAsked_), + &dwBytesReturned, + &this->ntOverlapped)) { this->CheckBroken(); + return true; } else { - if (GetLastError() != ERROR_IO_PENDING) + if (::GetLastError() == ERROR_IO_PENDING) { - SysPushErrorIO(); - return false; + return true; } } } - else if (pNtNotifyChangeDirectoryFile) + + if (pNtNotifyChangeDirectoryFile) { auto dwRet = pNtNotifyChangeDirectoryFile(this->hFileHandle, this->ntOverlapped.hEvent, @@ -430,7 +440,7 @@ namespace Aurora::IO::FS } else { - CheckBroken(); + this->CheckBroken(); } }