From 0e55f304c44c2c6d8d1a9f6ce4a1acb18b69f1ba Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Fri, 21 Mar 2025 02:34:11 +0700 Subject: [PATCH] Taskbar10: Fix stack corruption in dynamically linked NtDCompositionGetFrameStatistics call on 11 21H2+ --- ExplorerPatcher/Taskbar10.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/ExplorerPatcher/Taskbar10.cpp b/ExplorerPatcher/Taskbar10.cpp index 62648a5..fc62b6e 100644 --- a/ExplorerPatcher/Taskbar10.cpp +++ b/ExplorerPatcher/Taskbar10.cpp @@ -163,17 +163,20 @@ struct TaskbarTheme } }; -struct struct_b +enum D3D_FEATURE_LEVEL : int; + +struct COMPOSITION_CAPABILITY_INFO { - int a; - int b; - int c; - int d; + D3D_FEATURE_LEVEL minSafeFeatureLevel; + D3D_FEATURE_LEVEL maxHardwareFeatureLevel; + int usingSoftwareDevice; + int areEffectsSupported; + int boostCompositorClockSupported; // Valid on 11 21H2+ }; -typedef HRESULT (*NtDCompositionGetFrameStatistics_t)(DCOMPOSITION_FRAME_STATISTICS*, struct_b*); +typedef NTSTATUS (*NtDCompositionGetFrameStatistics_t)(DCOMPOSITION_FRAME_STATISTICS*, COMPOSITION_CAPABILITY_INFO*); -inline HRESULT NtDCompositionGetFrameStatistics(DCOMPOSITION_FRAME_STATISTICS* a, struct_b* b) +inline NTSTATUS NtDCompositionGetFrameStatistics(DCOMPOSITION_FRAME_STATISTICS* pStatistics, COMPOSITION_CAPABILITY_INFO* pCapabilities) { static NtDCompositionGetFrameStatistics_t f = nullptr; if (!f) @@ -182,14 +185,14 @@ inline HRESULT NtDCompositionGetFrameStatistics(DCOMPOSITION_FRAME_STATISTICS* a if (h) f = (NtDCompositionGetFrameStatistics_t)GetProcAddress(h, MAKEINTRESOURCEA(1046)); } - return f ? f(a, b) : E_NOTIMPL; + return f ? f(pStatistics, pCapabilities) : (NTSTATUS)0xC0000002L; // STATUS_NOT_IMPLEMENTED } bool ShouldApplyBlur() { - DCOMPOSITION_FRAME_STATISTICS v7; - struct_b v6; - return SUCCEEDED(NtDCompositionGetFrameStatistics(&v7, &v6)) && v6.d && !v6.c; + DCOMPOSITION_FRAME_STATISTICS statistics; + COMPOSITION_CAPABILITY_INFO capabilities; + return NtDCompositionGetFrameStatistics(&statistics, &capabilities) >= 0 && capabilities.areEffectsSupported && !capabilities.usingSoftwareDevice; } TaskbarTheme GetTaskbarTheme()