diff --git a/ThunksList.md b/ThunksList.md index c9dc11e..e88f694 100644 --- a/ThunksList.md +++ b/ThunksList.md @@ -194,6 +194,10 @@ | DwmSetWindowAttribute | 不存在时,返回 `DWM_E_COMPOSITIONDISABLED`(表示DWM已禁用)。 | DwmFlush | 不存在时,返回 `S_OK_`。 | DwmGetCompositionTimingInfo | 不存在时,返回 `DWM_E_COMPOSITIONDISABLED`(表示DWM已禁用)。 +| DwmInvalidateIconicBitmaps | 不存在时,返回 `DWM_E_COMPOSITIONDISABLED`(表示DWM已禁用)。 +| DwmSetIconicLivePreviewBitmap | 不存在时,返回 `DWM_E_COMPOSITIONDISABLED`(表示DWM已禁用)。 +| DwmSetIconicThumbnail | 不存在时,返回 `DWM_E_COMPOSITIONDISABLED`(表示DWM已禁用)。 + ## dwrite.dll | 函数 | Fallback diff --git a/src/Thunks/dwmapi.hpp b/src/Thunks/dwmapi.hpp index 1c70ae1..8914438 100644 --- a/src/Thunks/dwmapi.hpp +++ b/src/Thunks/dwmapi.hpp @@ -3,286 +3,354 @@ // 忽略deprecated,因为是Thunks项目肯定是需要调用老接口的。 #pragma warning(disable:4995) -namespace YY +namespace YY::Thunks { - namespace Thunks - { #if (YY_Thunks_Support_Version < NTDDI_WIN6) - // 最低受支持的客户端 Windows Vista [仅限桌面应用] - // 最低受支持的服务器 Windows Server 2008[仅限桌面应用] - __DEFINE_THUNK( - dwmapi, - 8, - HRESULT, - STDAPICALLTYPE, - DwmEnableBlurBehindWindow, - HWND _hWnd, - _In_ const DWM_BLURBEHIND* _pBlurBehind - ) - { - if (const auto _pfnDwmEnableBlurBehindWindow = try_get_DwmEnableBlurBehindWindow()) - { - return _pfnDwmEnableBlurBehindWindow(_hWnd, _pBlurBehind); - } - - // 老版本系统不支持Dwm,因此假装此功能被禁用 - return DWM_E_COMPOSITIONDISABLED; - } + // 最低受支持的客户端 Windows Vista [仅限桌面应用] + // 最低受支持的服务器 Windows Server 2008[仅限桌面应用] + __DEFINE_THUNK( + dwmapi, + 8, + HRESULT, + STDAPICALLTYPE, + DwmEnableBlurBehindWindow, + HWND _hWnd, + _In_ const DWM_BLURBEHIND* _pBlurBehind + ) + { + if (const auto _pfnDwmEnableBlurBehindWindow = try_get_DwmEnableBlurBehindWindow()) + { + return _pfnDwmEnableBlurBehindWindow(_hWnd, _pBlurBehind); + } + + // 老版本系统不支持Dwm,因此假装此功能被禁用 + return DWM_E_COMPOSITIONDISABLED; + } #endif #if (YY_Thunks_Support_Version < NTDDI_WIN6) - // 最低受支持的客户端 Windows Vista [仅限桌面应用] - // 最低受支持的服务器 Windows Server 2008[仅限桌面应用] - __DEFINE_THUNK( - dwmapi, - 4, - HRESULT, - STDAPICALLTYPE, - DwmIsCompositionEnabled, - _Out_ BOOL* _pbEnabled - ) + // 最低受支持的客户端 Windows Vista [仅限桌面应用] + // 最低受支持的服务器 Windows Server 2008[仅限桌面应用] + __DEFINE_THUNK( + dwmapi, + 4, + HRESULT, + STDAPICALLTYPE, + DwmIsCompositionEnabled, + _Out_ BOOL* _pbEnabled + ) + { + if (const auto _pfnDwmIsCompositionEnabled = try_get_DwmIsCompositionEnabled()) + { + return _pfnDwmIsCompositionEnabled(_pbEnabled); + } + + if (!_pbEnabled) { - if (const auto _pfnDwmIsCompositionEnabled = try_get_DwmIsCompositionEnabled()) - { - return _pfnDwmIsCompositionEnabled(_pbEnabled); - } + return E_INVALIDARG; + } - if (!_pbEnabled) - { - return E_INVALIDARG; - } + *_pbEnabled = FALSE; + return S_OK; + } +#endif - *_pbEnabled = FALSE; + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + + // 最低受支持的客户端 Windows Vista [仅限桌面应用] + // 最低受支持的服务器 Windows Server 2008[仅限桌面应用] + __DEFINE_THUNK( + dwmapi, + 4, + HRESULT, + STDAPICALLTYPE, + DwmEnableComposition, + UINT _uCompositionAction + ) + { + if (const auto _pfnDwmEnableComposition = try_get_DwmEnableComposition()) + { + return _pfnDwmEnableComposition(_uCompositionAction); + } + + if (DWM_EC_DISABLECOMPOSITION == _uCompositionAction) + { return S_OK; } + else if (DWM_EC_ENABLECOMPOSITION == _uCompositionAction) + { + return DWM_E_COMPOSITIONDISABLED; + } + else + { + return E_INVALIDARG; + } + } #endif #if (YY_Thunks_Support_Version < NTDDI_WIN6) - // 最低受支持的客户端 Windows Vista [仅限桌面应用] - // 最低受支持的服务器 Windows Server 2008[仅限桌面应用] - __DEFINE_THUNK( - dwmapi, - 4, - HRESULT, - STDAPICALLTYPE, - DwmEnableComposition, - UINT _uCompositionAction - ) + // 最低受支持的客户端 Windows Vista [仅限桌面应用] + // 最低受支持的服务器 Windows Server 2008[仅限桌面应用] + __DEFINE_THUNK( + dwmapi, + 8, + HRESULT, + STDAPICALLTYPE, + DwmExtendFrameIntoClientArea, + HWND _hWnd, + _In_ const MARGINS* _pMarInset + ) + { + if (const auto _pfnDwmExtendFrameIntoClientArea = try_get_DwmExtendFrameIntoClientArea()) + { + return _pfnDwmExtendFrameIntoClientArea(_hWnd, _pMarInset); + } + + if (!_pMarInset) { - if (const auto _pfnDwmEnableComposition = try_get_DwmEnableComposition()) - { - return _pfnDwmEnableComposition(_uCompositionAction); - } - - if (DWM_EC_DISABLECOMPOSITION == _uCompositionAction) - { - return S_OK; - } - else if (DWM_EC_ENABLECOMPOSITION == _uCompositionAction) - { - return DWM_E_COMPOSITIONDISABLED; - } - else - { - return E_INVALIDARG; - } + return E_INVALIDARG; } + return DWM_E_COMPOSITIONDISABLED; + } #endif #if (YY_Thunks_Support_Version < NTDDI_WIN6) - // 最低受支持的客户端 Windows Vista [仅限桌面应用] - // 最低受支持的服务器 Windows Server 2008[仅限桌面应用] - __DEFINE_THUNK( - dwmapi, - 8, - HRESULT, - STDAPICALLTYPE, - DwmExtendFrameIntoClientArea, - HWND _hWnd, - _In_ const MARGINS* _pMarInset - ) + // 最低受支持的客户端 Windows Vista [仅限桌面应用] + // 最低受支持的服务器 Windows Server 2008[仅限桌面应用] + __DEFINE_THUNK( + dwmapi, + 20, + BOOL, + STDAPICALLTYPE, + DwmDefWindowProc, + _In_ HWND _hWnd, + UINT _uMsg, + WPARAM _wParam, + LPARAM _lParam, + _Out_ LRESULT* _plResult + ) + { + if (const auto _pfnDwmDefWindowProc = try_get_DwmDefWindowProc()) { - if (const auto _pfnDwmExtendFrameIntoClientArea = try_get_DwmExtendFrameIntoClientArea()) - { - return _pfnDwmExtendFrameIntoClientArea(_hWnd, _pMarInset); - } - - if (!_pMarInset) - { - return E_INVALIDARG; - } - return DWM_E_COMPOSITIONDISABLED; + return _pfnDwmDefWindowProc(_hWnd, _uMsg, _wParam, _lParam, _plResult); } + + return FALSE; + } #endif #if (YY_Thunks_Support_Version < NTDDI_WIN6) - // 最低受支持的客户端 Windows Vista [仅限桌面应用] - // 最低受支持的服务器 Windows Server 2008[仅限桌面应用] - __DEFINE_THUNK( - dwmapi, - 20, - BOOL, - STDAPICALLTYPE, - DwmDefWindowProc, - _In_ HWND _hWnd, - UINT _uMsg, - WPARAM _wParam, - LPARAM _lParam, - _Out_ LRESULT* _plResult - ) + // 最低受支持的客户端 Windows Vista [仅限桌面应用] + // 最低受支持的服务器 Windows Server 2008[仅限桌面应用] + __DEFINE_THUNK( + dwmapi, + 8, + HRESULT, + STDAPICALLTYPE, + DwmGetColorizationColor, + _Out_ DWORD* _pcrColorization, + _Out_ BOOL* _pbOpaqueBlend + ) + { + if (const auto _pfnDwmGetColorizationColor = try_get_DwmGetColorizationColor()) { - if (const auto _pfnDwmDefWindowProc = try_get_DwmDefWindowProc()) - { - return _pfnDwmDefWindowProc(_hWnd, _uMsg, _wParam, _lParam, _plResult); - } + return _pfnDwmGetColorizationColor(_pcrColorization, _pbOpaqueBlend); + } - return FALSE; + if (_pcrColorization == nullptr || _pbOpaqueBlend == nullptr) + { + return E_INVALIDARG; } + + return DWM_E_COMPOSITIONDISABLED; + } #endif #if (YY_Thunks_Support_Version < NTDDI_WIN6) - // 最低受支持的客户端 Windows Vista [仅限桌面应用] - // 最低受支持的服务器 Windows Server 2008[仅限桌面应用] - __DEFINE_THUNK( - dwmapi, - 8, - HRESULT, - STDAPICALLTYPE, - DwmGetColorizationColor, - _Out_ DWORD* _pcrColorization, - _Out_ BOOL* _pbOpaqueBlend - ) + // 最低受支持的客户端 Windows Vista [仅限桌面应用] + // 最低受支持的服务器 Windows Server 2008[仅限桌面应用] + __DEFINE_THUNK( + dwmapi, + 16, + HRESULT, + STDAPICALLTYPE, + DwmGetWindowAttribute, + HWND _hWnd, + DWORD _uAttribute, + _Out_writes_bytes_(_cbAttribute) PVOID _pvAttribute, + DWORD _cbAttribute + ) + { + if (const auto _pfnDwmGetWindowAttribute = try_get_DwmGetWindowAttribute()) { - if (const auto _pfnDwmGetColorizationColor = try_get_DwmGetColorizationColor()) - { - return _pfnDwmGetColorizationColor(_pcrColorization, _pbOpaqueBlend); - } - - if (_pcrColorization == nullptr || _pbOpaqueBlend == nullptr) - { - return E_INVALIDARG; - } + return _pfnDwmGetWindowAttribute(_hWnd, _uAttribute, _pvAttribute, _cbAttribute); + } - return DWM_E_COMPOSITIONDISABLED; + if (!_pvAttribute) + { + return E_INVALIDARG; } + return DWM_E_COMPOSITIONDISABLED; + } #endif #if (YY_Thunks_Support_Version < NTDDI_WIN6) - // 最低受支持的客户端 Windows Vista [仅限桌面应用] - // 最低受支持的服务器 Windows Server 2008[仅限桌面应用] - __DEFINE_THUNK( - dwmapi, - 16, - HRESULT, - STDAPICALLTYPE, - DwmGetWindowAttribute, - HWND _hWnd, - DWORD _uAttribute, - _Out_writes_bytes_(_cbAttribute) PVOID _pvAttribute, - DWORD _cbAttribute - ) + // 最低受支持的客户端 Windows Vista [仅限桌面应用] + // 最低受支持的服务器 Windows Server 2008[仅限桌面应用] + __DEFINE_THUNK( + dwmapi, + 16, + HRESULT, + STDAPICALLTYPE, + DwmSetWindowAttribute, + HWND _hWnd, + DWORD _uAttribute, + _In_reads_bytes_(_cbAttribute) LPCVOID _pvAttribute, + DWORD _cbAttribute + ) + { + if (const auto _pfnDwmSetWindowAttribute = try_get_DwmSetWindowAttribute()) { - if (const auto _pfnDwmGetWindowAttribute = try_get_DwmGetWindowAttribute()) - { - return _pfnDwmGetWindowAttribute(_hWnd, _uAttribute, _pvAttribute, _cbAttribute); - } - - if (!_pvAttribute) - { - return E_INVALIDARG; - } - return DWM_E_COMPOSITIONDISABLED; + return _pfnDwmSetWindowAttribute(_hWnd, _uAttribute, _pvAttribute, _cbAttribute); + } + + if (!_pvAttribute) + { + return E_INVALIDARG; } + + return DWM_E_COMPOSITIONDISABLED; + } #endif #if (YY_Thunks_Support_Version < NTDDI_WIN6) - // 最低受支持的客户端 Windows Vista [仅限桌面应用] - // 最低受支持的服务器 Windows Server 2008[仅限桌面应用] - __DEFINE_THUNK( - dwmapi, - 16, - HRESULT, - STDAPICALLTYPE, - DwmSetWindowAttribute, - HWND _hWnd, - DWORD _uAttribute, - _In_reads_bytes_(_cbAttribute) LPCVOID _pvAttribute, - DWORD _cbAttribute - ) + // 最低受支持的客户端 Windows Vista [仅限桌面应用] + // 最低受支持的服务器 Windows Server 2008[仅限桌面应用] + __DEFINE_THUNK( + dwmapi, + 0, + HRESULT, + STDAPICALLTYPE, + DwmFlush, + ) + { + if (const auto _pfnDwmFlush = try_get_DwmFlush()) { - if (const auto _pfnDwmSetWindowAttribute = try_get_DwmSetWindowAttribute()) - { - return _pfnDwmSetWindowAttribute(_hWnd, _uAttribute, _pvAttribute, _cbAttribute); - } - - if (!_pvAttribute) - { - return E_INVALIDARG; - } - - return DWM_E_COMPOSITIONDISABLED; + return _pfnDwmFlush(); } + + return S_OK; + } #endif #if (YY_Thunks_Support_Version < NTDDI_WIN6) - // 最低受支持的客户端 Windows Vista [仅限桌面应用] - // 最低受支持的服务器 Windows Server 2008[仅限桌面应用] - __DEFINE_THUNK( - dwmapi, - 0, - HRESULT, - STDAPICALLTYPE, - DwmFlush, - ) + // Minimum supported client Windows Vista + // Minimum supported server Windows Server 2008 + __DEFINE_THUNK( + dwmapi, + 8, + HRESULT, + STDAPICALLTYPE, + DwmGetCompositionTimingInfo, + _In_ HWND _hWnd, + _Out_ DWM_TIMING_INFO* _pTimingInfo + ) + { + if (auto const _pfnDwmGetCompositionTimingInfo = try_get_DwmGetCompositionTimingInfo()) { - if (const auto _pfnDwmFlush = try_get_DwmFlush()) - { - return _pfnDwmFlush(); - } - - return S_OK; + return _pfnDwmGetCompositionTimingInfo(_hWnd, _pTimingInfo); } + + return DWM_E_COMPOSITIONDISABLED; + } #endif #if (YY_Thunks_Support_Version < NTDDI_WIN6) - // Minimum supported client Windows Vista - // Minimum supported server Windows Server 2008 - __DEFINE_THUNK( - dwmapi, - 8, - HRESULT, - STDAPICALLTYPE, - DwmGetCompositionTimingInfo, - _In_ HWND _hWnd, - _Out_ DWM_TIMING_INFO* _pTimingInfo - ) + // Windows Vista [desktop apps only] + // Windows Server 2008 [desktop apps only] + __DEFINE_THUNK( + dwmapi, + 4, + HRESULT, + STDAPICALLTYPE, + DwmInvalidateIconicBitmaps, + HWND hwnd + ) + { + if (auto const pDwmInvalidateIconicBitmaps = try_get_DwmInvalidateIconicBitmaps()) { - if (auto const _pfnDwmGetCompositionTimingInfo = try_get_DwmGetCompositionTimingInfo()) - { - return _pfnDwmGetCompositionTimingInfo(_hWnd, _pTimingInfo); - } + return pDwmInvalidateIconicBitmaps(hwnd); + } - return DWM_E_COMPOSITIONDISABLED; + return DWM_E_COMPOSITIONDISABLED; + } +#endif + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + + // Windows Vista [desktop apps only] + // Windows Server 2008 [desktop apps only] + __DEFINE_THUNK( + dwmapi, + 16, + HRESULT, + STDAPICALLTYPE, + DwmSetIconicLivePreviewBitmap, + HWND hwnd, + HBITMAP hbmp, + _In_opt_ POINT *pptClient, + DWORD dwSITFlags) + { + if (auto const pDwmSetIconicLivePreviewBitmap = try_get_DwmSetIconicLivePreviewBitmap()) + { + return pDwmSetIconicLivePreviewBitmap(hwnd, hbmp, pptClient, dwSITFlags); + } + + return DWM_E_COMPOSITIONDISABLED; + } +#endif + +#if (YY_Thunks_Support_Version < NTDDI_WIN6) + + // Windows Vista [desktop apps only] + // Windows Server 2008 [desktop apps only] + __DEFINE_THUNK( + dwmapi, + 12, + HRESULT, + STDAPICALLTYPE, + DwmSetIconicThumbnail, + HWND hwnd, + HBITMAP hbmp, + DWORD dwSITFlags) + { + if (auto const pDwmSetIconicThumbnail = try_get_DwmSetIconicThumbnail()) + { + return pDwmSetIconicThumbnail(hwnd, hbmp, dwSITFlags); } + + return DWM_E_COMPOSITIONDISABLED; + } + #endif - } // namespace Thunks -} // namespace YY +} // namespace YY::Thunks