Skip to content

Commit

Permalink
Cycle through taskbar windows on click v1.1.1 (#1122)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
m417z authored Oct 22, 2024
1 parent 8453e01 commit c04dfbc
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions mods/taskbar-left-click-cycle.wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -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();
}
}
Expand Down

0 comments on commit c04dfbc

Please sign in to comment.