Skip to content

Commit

Permalink
Fea #71, 添加一些QT缺失的接口
Browse files Browse the repository at this point in the history
  - 添加 GetPointerFrameTouchInfo
  - 添加 GetPointerFrameTouchInfoHistory
  - 添加 GetPointerInfo
  - 添加 GetPointerPenInfoHistory
  - 添加 SkipPointerFrameMessages
  - 添加 GetThreadDpiAwarenessContext
  - 添加 GetWindowDpiAwarenessContext
  - 添加 GetDisplayAutoRotationPreferences
  - 添加 SetDisplayAutoRotationPreferences
  • Loading branch information
mingkuang-Chuyu committed Sep 3, 2024
1 parent 563b0b4 commit 0dcf233
Show file tree
Hide file tree
Showing 3 changed files with 280 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ThunksList.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
127 changes: 127 additions & 0 deletions src/Thunks/ext-ms-win-rtcore-ntuser-wmpointer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
144 changes: 144 additions & 0 deletions src/Thunks/user32.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0dcf233

Please sign in to comment.