From 0dcf2330b77fe4701a1581d3faa5950e48ddc37e Mon Sep 17 00:00:00 2001 From: mingkuang Date: Tue, 3 Sep 2024 19:42:13 +0800 Subject: [PATCH] =?UTF-8?q?Fea=20#71,=20=E6=B7=BB=E5=8A=A0=E4=B8=80?= =?UTF-8?q?=E4=BA=9BQT=E7=BC=BA=E5=A4=B1=E7=9A=84=E6=8E=A5=E5=8F=A3=20=20?= =?UTF-8?q?=20-=20=E6=B7=BB=E5=8A=A0=20GetPointerFrameTouchInfo=20=20=20-?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=20GetPointerFrameTouchInfoHistory=20=20?= =?UTF-8?q?=20-=20=E6=B7=BB=E5=8A=A0=20GetPointerInfo=20=20=20-=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20GetPointerPenInfoHistory=20=20=20-=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20SkipPointerFrameMessages=20=20=20-=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20GetThreadDpiAwarenessContext=20=20=20-=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20GetWindowDpiAwarenessContext=20=20=20-=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20GetDisplayAutoRotationPreferences=20=20=20?= =?UTF-8?q?-=20=E6=B7=BB=E5=8A=A0=20SetDisplayAutoRotationPreferences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThunksList.md | 9 ++ .../ext-ms-win-rtcore-ntuser-wmpointer.hpp | 127 +++++++++++++++ src/Thunks/user32.hpp | 144 ++++++++++++++++++ 3 files changed, 280 insertions(+) diff --git a/ThunksList.md b/ThunksList.md index bce4fb1..34f7f82 100644 --- a/ThunksList.md +++ b/ThunksList.md @@ -733,6 +733,15 @@ | GetAwarenessFromDpiAwarenessContext | 内部实现。 | AreDpiAwarenessContextsEqual | 内部实现。 | EnableNonClientDpiScaling | 假装成功。 +| GetPointerFrameTouchInfo | 报告错误 ERROR_INVALID_PARAMETER。 +| GetPointerFrameTouchInfoHistory | 报告错误 ERROR_INVALID_PARAMETER。 +| GetPointerInfo | 报告错误 ERROR_INVALID_PARAMETER。 +| GetPointerPenInfoHistory | 报告错误 ERROR_INVALID_PARAMETER。 +| SkipPointerFrameMessages | 假装成功。 +| GetThreadDpiAwarenessContext | 调用 GetProcessDpiAwareness。 +| GetWindowDpiAwarenessContext | 调用 GetProcessDpiAwareness。 +| GetDisplayAutoRotationPreferences | 返回 ORIENTATION_PREFERENCE_NONE。 +| SetDisplayAutoRotationPreferences | 假装成功。 ## userenv.dll | 函数 | Fallback diff --git a/src/Thunks/ext-ms-win-rtcore-ntuser-wmpointer.hpp b/src/Thunks/ext-ms-win-rtcore-ntuser-wmpointer.hpp index 33d8775..454d9f1 100644 --- a/src/Thunks/ext-ms-win-rtcore-ntuser-wmpointer.hpp +++ b/src/Thunks/ext-ms-win-rtcore-ntuser-wmpointer.hpp @@ -172,4 +172,131 @@ return FALSE; } #endif + + +#if (YY_Thunks_Target < __WindowsNT6_2) + + // 最低受支持的客户端 Windows 8 [仅限桌面应用] + // 最低受支持的服务器 Windows Server 2012 [仅限桌面应用] + __DEFINE_THUNK( + user32, + 12, + BOOL, + WINAPI, + GetPointerFrameTouchInfo, + _In_ UINT32 _uPointerId, + _Inout_ UINT32* _pcPointerCount, + _Out_writes_opt_(*_pcPointerCount) POINTER_TOUCH_INFO* _pTouchInfo + ) + { + if (const auto _pfnGetPointerFrameTouchInfo = try_get_GetPointerFrameTouchInfo()) + { + return _pfnGetPointerFrameTouchInfo(_uPointerId, _pcPointerCount, _pTouchInfo); + } + + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } +#endif + + +#if (YY_Thunks_Target < __WindowsNT6_2) + + // 最低受支持的客户端 Windows 8 [仅限桌面应用] + // 最低受支持的服务器 Windows Server 2012 [仅限桌面应用] + __DEFINE_THUNK( + user32, + 16, + BOOL, + WINAPI, + GetPointerFrameTouchInfoHistory, + _In_ UINT32 _uPointerId, + _Inout_ UINT32* _pcEntriesCount, + _Inout_ UINT32* _pcPointerCount, + _Out_writes_opt_(*_pcEntriesCount * *_pcPointerCount) POINTER_TOUCH_INFO* _pTouchInfo + ) + { + if (const auto _pfnGetPointerFrameTouchInfoHistory = try_get_GetPointerFrameTouchInfoHistory()) + { + return _pfnGetPointerFrameTouchInfoHistory(_uPointerId, _pcEntriesCount, _pcPointerCount, _pTouchInfo); + } + + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } +#endif + + +#if (YY_Thunks_Target < __WindowsNT6_2) + + // 最低受支持的客户端 Windows 8 [仅限桌面应用] + // 最低受支持的服务器 Windows Server 2012 [仅限桌面应用] + __DEFINE_THUNK( + user32, + 8, + BOOL, + WINAPI, + GetPointerInfo, + _In_ UINT32 _uPointerId, + _Out_writes_(1) POINTER_INFO* _pPointerInfo + ) + { + if (const auto _pfnGetPointerInfo = try_get_GetPointerInfo()) + { + return _pfnGetPointerInfo(_uPointerId, _pPointerInfo); + } + + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } +#endif + + +#if (YY_Thunks_Target < __WindowsNT6_2) + + // 最低受支持的客户端 Windows 8 [仅限桌面应用] + // 最低受支持的服务器 Windows Server 2012 [仅限桌面应用] + __DEFINE_THUNK( + user32, + 12, + BOOL, + WINAPI, + GetPointerPenInfoHistory, + _In_ UINT32 _uPointerId, + _Inout_ UINT32* _pcEntriesCount, + _Out_writes_opt_(*_pcEntriesCount) POINTER_PEN_INFO* _pPenInfo + ) + { + if (const auto _pfnGetPointerPenInfoHistory = try_get_GetPointerPenInfoHistory()) + { + return _pfnGetPointerPenInfoHistory(_uPointerId, _pcEntriesCount, _pPenInfo); + } + + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } +#endif + + +#if (YY_Thunks_Target < __WindowsNT6_2) + + // 最低受支持的客户端 Windows 8 [仅限桌面应用] + // 最低受支持的服务器 Windows Server 2012 [仅限桌面应用] + __DEFINE_THUNK( + user32, + 4, + BOOL, + WINAPI, + SkipPointerFrameMessages, + _In_ UINT32 _uPointerId + ) + { + if (const auto _pfnSkipPointerFrameMessages = try_get_SkipPointerFrameMessages()) + { + return _pfnSkipPointerFrameMessages(_uPointerId); + } + + return TRUE; + } +#endif } diff --git a/src/Thunks/user32.hpp b/src/Thunks/user32.hpp index eaef9f3..7aa3820 100644 --- a/src/Thunks/user32.hpp +++ b/src/Thunks/user32.hpp @@ -964,4 +964,148 @@ namespace YY::Thunks return TRUE; } #endif + + +#if (YY_Thunks_Target < __WindowsNT10_14393) + + // 最低受支持的客户端 Windows 10版本 1607 [仅限桌面应用] + // 最低受支持的服务器 Windows Server 2016[仅限桌面应用] + __DEFINE_THUNK( + user32, + 0, + DPI_AWARENESS_CONTEXT, + WINAPI, + GetThreadDpiAwarenessContext + ) + { + if (auto const _pfnGetThreadDpiAwarenessContext = try_get_GetThreadDpiAwarenessContext()) + { + return _pfnGetThreadDpiAwarenessContext(); + } + + PROCESS_DPI_AWARENESS _eValue = PROCESS_DPI_AWARENESS::PROCESS_DPI_UNAWARE; + auto _hr = GetProcessDpiAwareness(NULL, &_eValue); + if (SUCCEEDED(_hr)) + { + switch (_eValue) + { + case PROCESS_DPI_UNAWARE: + return DPI_AWARENESS_CONTEXT_UNAWARE; + case PROCESS_SYSTEM_DPI_AWARE: + return DPI_AWARENESS_CONTEXT_SYSTEM_AWARE; + case PROCESS_PER_MONITOR_DPI_AWARE: + return DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE; + default: + break; + } + } + + return DPI_AWARENESS_CONTEXT_UNAWARE; + } +#endif + + +#if (YY_Thunks_Target < __WindowsNT10_14393) + + // 最低受支持的客户端 Windows 10版本 1607 [仅限桌面应用] + // 最低受支持的服务器 Windows Server 2016[仅限桌面应用] + __DEFINE_THUNK( + user32, + 4, + DPI_AWARENESS_CONTEXT, + WINAPI, + GetWindowDpiAwarenessContext, + _In_ HWND _hWnd + ) + { + if (auto const _pfnGetWindowDpiAwarenessContext = try_get_GetWindowDpiAwarenessContext()) + { + return _pfnGetWindowDpiAwarenessContext(_hWnd); + } + + DWORD _uProcessId = 0; + GetWindowThreadProcessId(_hWnd, &_uProcessId); + if (_uProcessId == 0) + { + return NULL; + } + + HANDLE _hProcess = NULL; + if (_uProcessId != GetCurrentProcessId() && internal::GetSystemVersion() >= internal::MakeVersion(6, 3)) + { + _hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, _uProcessId); + } + + PROCESS_DPI_AWARENESS _eValue = PROCESS_DPI_AWARENESS::PROCESS_DPI_UNAWARE; + auto _hr = GetProcessDpiAwareness(_hProcess, &_eValue); + if (_hProcess) + { + CloseHandle(_hProcess); + } + + if (SUCCEEDED(_hr)) + { + switch (_eValue) + { + case PROCESS_DPI_UNAWARE: + return DPI_AWARENESS_CONTEXT_UNAWARE; + case PROCESS_SYSTEM_DPI_AWARE: + return DPI_AWARENESS_CONTEXT_SYSTEM_AWARE; + case PROCESS_PER_MONITOR_DPI_AWARE: + return DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE; + default: + break; + } + } + + return DPI_AWARENESS_CONTEXT_UNAWARE; + } +#endif + + +#if (YY_Thunks_Target < __WindowsNT6_2) + + // 最低受支持的客户端 Windows 8 [桌面应用 |UWP 应用] + // 最低受支持的服务器 Windows Server 2012[桌面应用 | UWP 应用] + __DEFINE_THUNK( + user32, + 4, + BOOL, + WINAPI, + SetDisplayAutoRotationPreferences, + _In_ ORIENTATION_PREFERENCE _eOrientation + ) + { + if (auto const _pfnSetDisplayAutoRotationPreferences = try_get_SetDisplayAutoRotationPreferences()) + { + return _pfnSetDisplayAutoRotationPreferences(_eOrientation); + } + + return TRUE; + } +#endif + + +#if (YY_Thunks_Target < __WindowsNT6_2) + + // 最低受支持的客户端 Windows 8 [桌面应用 |UWP 应用] + // 最低受支持的服务器 Windows Server 2012[桌面应用 | UWP 应用] + __DEFINE_THUNK( + user32, + 4, + BOOL, + WINAPI, + GetDisplayAutoRotationPreferences, + _Out_ ORIENTATION_PREFERENCE* _peOrientation + ) + { + if (auto const _pfnGetDisplayAutoRotationPreferences = try_get_GetDisplayAutoRotationPreferences()) + { + return _pfnGetDisplayAutoRotationPreferences(_peOrientation); + } + + *_peOrientation = ORIENTATION_PREFERENCE::ORIENTATION_PREFERENCE_NONE; + return TRUE; + } +#endif } //namespace YY::Thunks