[*] Fix FS Watcher under Windows XP -> Windows 7
This commit is contained in:
parent
4a5cb3c168
commit
7fa0a52e2c
@ -86,6 +86,7 @@ namespace Aurora
|
|||||||
ADD_GET_PROC(Nt, RtlWaitOnAddress)
|
ADD_GET_PROC(Nt, RtlWaitOnAddress)
|
||||||
ADD_GET_PROC(Nt, ZwSetTimerResolution)
|
ADD_GET_PROC(Nt, ZwSetTimerResolution)
|
||||||
ADD_GET_PROC(Nt, NtQueryInformationProcess)
|
ADD_GET_PROC(Nt, NtQueryInformationProcess)
|
||||||
|
ADD_GET_PROC(Nt, NtNotifyChangeDirectoryFile)
|
||||||
|
|
||||||
ADD_GET_PROC_BI(Kernel32, KernelBase, VirtualAlloc2)
|
ADD_GET_PROC_BI(Kernel32, KernelBase, VirtualAlloc2)
|
||||||
ADD_GET_PROC_BI(Kernel32, KernelBase, MapViewOfFile3)
|
ADD_GET_PROC_BI(Kernel32, KernelBase, MapViewOfFile3)
|
||||||
|
@ -127,6 +127,18 @@ namespace Aurora
|
|||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
inline NTSTATUS(__stdcall *pNtNotifyChangeDirectoryFile)(
|
||||||
|
HANDLE FileHandle,
|
||||||
|
HANDLE Event,
|
||||||
|
PIO_APC_ROUTINE ApcRoutine,
|
||||||
|
PVOID ApcContext,
|
||||||
|
PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
PVOID Buffer,
|
||||||
|
ULONG BufferSize,
|
||||||
|
ULONG CompletionFilter,
|
||||||
|
BOOLEAN WatchTree
|
||||||
|
);
|
||||||
|
|
||||||
inline BOOL(__stdcall *pGetSystemCpuSetInformation)(
|
inline BOOL(__stdcall *pGetSystemCpuSetInformation)(
|
||||||
PSYSTEM_CPU_SET_INFORMATION Information,
|
PSYSTEM_CPU_SET_INFORMATION Information,
|
||||||
ULONG BufferLength,
|
ULONG BufferLength,
|
||||||
|
@ -45,7 +45,11 @@ namespace Aurora::IO::FS
|
|||||||
NTWatcher *parent;
|
NTWatcher *parent;
|
||||||
AuString strBaseDir;
|
AuString strBaseDir;
|
||||||
HANDLE hFileHandle {INVALID_HANDLE_VALUE};
|
HANDLE hFileHandle {INVALID_HANDLE_VALUE};
|
||||||
|
bool bWin7Mode {};
|
||||||
|
AuSPtr<Loop::LSEvent> pWin7Event {};
|
||||||
AuUInt32 dwReferences {};
|
AuUInt32 dwReferences {};
|
||||||
|
UCHAR buffer[8000];
|
||||||
|
IO_STATUS_BLOCK ioStatusBlock;
|
||||||
|
|
||||||
~NTWatchObject()
|
~NTWatchObject()
|
||||||
{
|
{
|
||||||
@ -372,6 +376,8 @@ namespace Aurora::IO::FS
|
|||||||
bool firstTime = !this->ntOverlapped.hEvent;
|
bool firstTime = !this->ntOverlapped.hEvent;
|
||||||
this->ntOverlapped.hEvent = (HANDLE)this->parent->ntEvent_->GetHandle();
|
this->ntOverlapped.hEvent = (HANDLE)this->parent->ntEvent_->GetHandle();
|
||||||
|
|
||||||
|
if (AuSwInfo::IsWindows8OrGreater())
|
||||||
|
{
|
||||||
REQUEST_OPLOCK_INPUT_BUFFER input
|
REQUEST_OPLOCK_INPUT_BUFFER input
|
||||||
{
|
{
|
||||||
REQUEST_OPLOCK_CURRENT_VERSION,
|
REQUEST_OPLOCK_CURRENT_VERSION,
|
||||||
@ -393,6 +399,40 @@ namespace Aurora::IO::FS
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (pNtNotifyChangeDirectoryFile)
|
||||||
|
{
|
||||||
|
auto dwRet = pNtNotifyChangeDirectoryFile(this->hFileHandle,
|
||||||
|
this->ntOverlapped.hEvent,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&ioStatusBlock,
|
||||||
|
buffer,
|
||||||
|
sizeof(buffer),
|
||||||
|
//FILE_NOTIFY_CHANGE_NAME |
|
||||||
|
FILE_NOTIFY_CHANGE_ATTRIBUTES |
|
||||||
|
FILE_NOTIFY_CHANGE_SIZE |
|
||||||
|
FILE_NOTIFY_CHANGE_LAST_WRITE |
|
||||||
|
FILE_NOTIFY_CHANGE_LAST_ACCESS |
|
||||||
|
FILE_NOTIFY_CHANGE_CREATION,
|
||||||
|
FALSE);
|
||||||
|
this->bWin7Mode = true;
|
||||||
|
|
||||||
|
if (dwRet == STATUS_PENDING)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(dwRet))
|
||||||
|
{
|
||||||
|
SysPushErrorIO();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CheckBroken();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -401,7 +441,9 @@ namespace Aurora::IO::FS
|
|||||||
{
|
{
|
||||||
DWORD bytesTransferred;
|
DWORD bytesTransferred;
|
||||||
|
|
||||||
if (this->bBroken || GetOverlappedResult(this->hFileHandle, &this->ntOverlapped, &bytesTransferred, false))
|
if (this->bBroken ||
|
||||||
|
((this->bWin7Mode) ||
|
||||||
|
(!this->bWin7Mode && GetOverlappedResult(this->hFileHandle, &this->ntOverlapped, &bytesTransferred, false))))
|
||||||
{
|
{
|
||||||
bool bSuccess {true};
|
bool bSuccess {true};
|
||||||
this->bBroken = true;
|
this->bBroken = true;
|
||||||
@ -423,11 +465,18 @@ namespace Aurora::IO::FS
|
|||||||
bAnyTriggered = true;
|
bAnyTriggered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->bWin7Mode)
|
||||||
|
{
|
||||||
|
bSuccess = ScheduleOnce();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (this->whoAsked_.Flags & REQUEST_OPLOCK_OUTPUT_FLAG_ACK_REQUIRED)
|
if (this->whoAsked_.Flags & REQUEST_OPLOCK_OUTPUT_FLAG_ACK_REQUIRED)
|
||||||
{
|
{
|
||||||
this->whoAsked_.Flags = 0;
|
this->whoAsked_.Flags = 0;
|
||||||
bSuccess = ScheduleOnce();
|
bSuccess = ScheduleOnce();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->bBroken = false;
|
this->bBroken = false;
|
||||||
return bSuccess;
|
return bSuccess;
|
||||||
|
Loading…
Reference in New Issue
Block a user