From c04dfbc63407803920ca0699c8b2a160e23d757b Mon Sep 17 00:00:00 2001 From: Michael Maltsev <4129781+m417z@users.noreply.github.com> Date: Tue, 22 Oct 2024 12:20:26 +0300 Subject: [PATCH] Cycle through taskbar windows on click v1.1.1 (#1122) * Fixed initialization with the ExplorerPatcher taskbar. ExplorerPatcher 66.7 or newer is supported. * The "Customize the old taskbar on Windows 11" option no longer needs to be enabled for the mod to work with the ExplorerPatcher taskbar. --- mods/taskbar-left-click-cycle.wh.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/mods/taskbar-left-click-cycle.wh.cpp b/mods/taskbar-left-click-cycle.wh.cpp index 07b53317d..5a0522837 100644 --- a/mods/taskbar-left-click-cycle.wh.cpp +++ b/mods/taskbar-left-click-cycle.wh.cpp @@ -2,7 +2,7 @@ // @id taskbar-left-click-cycle // @name Cycle through taskbar windows on click // @description Makes clicking on combined taskbar items cycle through windows instead of opening thumbnail previews -// @version 1.1 +// @version 1.1.1 // @author m417z // @github https://github.com/m417z // @twitter https://twitter.com/m417z @@ -214,6 +214,10 @@ bool HookExplorerPatcherSymbols(HMODULE explorerPatcherModule) { return true; } + if (g_winVersion >= WinVersion::Win11) { + g_winVersion = WinVersion::Win10; + } + struct EXPLORER_PATCHER_HOOK { PCSTR symbol; void** pOriginalFunction; @@ -366,19 +370,21 @@ BOOL Wh_ModInit() { if (hasWin10Taskbar && !HookTaskbarSymbols()) { return FALSE; } - - HandleLoadedExplorerPatcher(); - - HMODULE kernelBaseModule = GetModuleHandle(L"kernelbase.dll"); - FARPROC pKernelBaseLoadLibraryExW = - GetProcAddress(kernelBaseModule, "LoadLibraryExW"); - Wh_SetFunctionHook((void*)pKernelBaseLoadLibraryExW, - (void*)LoadLibraryExW_Hook, - (void**)&LoadLibraryExW_Original); } else if (!HookTaskbarSymbols()) { return FALSE; } + HandleLoadedExplorerPatcher(); + + HMODULE kernelBaseModule = GetModuleHandle(L"kernelbase.dll"); + FARPROC pKernelBaseLoadLibraryExW = + GetProcAddress(kernelBaseModule, "LoadLibraryExW"); + Wh_SetFunctionHook((void*)pKernelBaseLoadLibraryExW, + (void*)LoadLibraryExW_Hook, + (void**)&LoadLibraryExW_Original); + + g_initialized = true; + return TRUE; } @@ -387,7 +393,7 @@ void Wh_ModAfterInit() { // Try again in case there's a race between the previous attempt and the // LoadLibraryExW hook. - if (g_settings.oldTaskbarOnWin11 && !g_explorerPatcherInitialized) { + if (!g_explorerPatcherInitialized) { HandleLoadedExplorerPatcher(); } }