Skip to content

Commit

Permalink
Fea #70, 特意为Vista系统做rust调用SetFileCompletionNotificationModes兼容
Browse files Browse the repository at this point in the history
  • Loading branch information
mingkuang-Chuyu committed May 1, 2024
1 parent c787d87 commit 7f33eef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ YY-Thunks(鸭船),存在的目的就是抹平不同系统的差异,编

## 更新日志

请参阅 [Changelog.md](https://github.com/Chuyu-Team/YY-Thunks/wiki)
请参阅 [releases 更新日志](https://github.com/Chuyu-Team/YY-Thunks/releases)
22 changes: 19 additions & 3 deletions src/Thunks/api-ms-win-core-kernel32-legacy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ namespace YY
}
#endif

#if (YY_Thunks_Support_Version < NTDDI_WIN6)
#if (YY_Thunks_Support_Version < NTDDI_WIN7)

// 支持的最低客户端 Windows Vista [桌面应用程序 |UWP 应用]
// 支持的最低服务器 Windows Server 2008 [桌面应用程序 |UWP 应用]
Expand All @@ -410,7 +410,23 @@ namespace YY
{
if (const auto _pfnSetFileCompletionNotificationModes = try_get_SetFileCompletionNotificationModes())
{
return _pfnSetFileCompletionNotificationModes(FileHandle, Flags);
#if (YY_Thunks_Support_Version >= NTDDI_WIN7)
return _pfnSetFileCompletionNotificationModes(FileHandle, Flags);
#else // (YY_Thunks_Support_Version < NTDDI_WIN7)
if (_pfnSetFileCompletionNotificationModes(FileHandle, Flags))
{
return TRUE;
}

if (GetLastError() == ERROR_ACCESS_DENIED && internal::GetSystemVersion() <= internal::MakeVersion(6, 0))
{
// https://github.com/Chuyu-Team/YY-Thunks/issues/70
// 特殊行为定制:Vista系统可能返回拒绝访问,为了不影响一些库的逻辑,直接返回TRUE。
// 毕竟这个函数本身没有太重要的功能。
return TRUE;
}
return FALSE;
#endif // (YY_Thunks_Support_Version < NTDDI_WIN7)
}

// 初步看起来没有什么的,只是会降低完成端口的效率。
Expand All @@ -421,4 +437,4 @@ namespace YY
#endif
}//namespace Thunks

} //namespace YY
} //namespace YY

0 comments on commit 7f33eef

Please sign in to comment.