Skip to content

Commit

Permalink
Taskbar10: Say goodbye to the stock 10 taskbar implementation in expl…
Browse files Browse the repository at this point in the history
…orer.exe of 26002+
  • Loading branch information
Amrsatrio committed Apr 25, 2024
1 parent 24e019d commit e57a6b0
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 20 deletions.
14 changes: 10 additions & 4 deletions ExplorerPatcher/dllmain.c
Expand Up @@ -4189,7 +4189,7 @@ HRESULT stobject_CoCreateInstanceHook(
LPVOID* ppv
)
{
if (global_rovi.dwBuildNumber >= 25000 && IsEqualGUID(rclsid, &CLSID_NetworkTraySSO) && bOldTaskbar)
if (global_rovi.dwBuildNumber >= 25236 && IsEqualGUID(rclsid, &CLSID_NetworkTraySSO) && bOldTaskbar)
{
wchar_t szPath[MAX_PATH];
ZeroMemory(szPath, sizeof(szPath));
Expand Down Expand Up @@ -6555,6 +6555,7 @@ void WINAPI LoadSettings(LPARAM lParam)
if (!bWasOldTaskbarSet)
{
bOldTaskbar = dwTemp;
AdjustTaskbarStyleValue(&bOldTaskbar);
bWasOldTaskbarSet = TRUE;
}
dwSize = sizeof(DWORD);
Expand Down Expand Up @@ -9896,6 +9897,7 @@ int RtlQueryFeatureConfigurationHook(UINT32 featureId, int sectionType, INT64* c
}
break;
}
#if 0
case 42537950: // DisableWin10Taskbar
{
if (bOldTaskbar)
Expand All @@ -9905,6 +9907,7 @@ int RtlQueryFeatureConfigurationHook(UINT32 featureId, int sectionType, INT64* c
}
break;
}
#endif
case 44656322: // ID44656322
{
if (bOldTaskbar)
Expand Down Expand Up @@ -11872,7 +11875,7 @@ LSTATUS pnidui_RegGetValueW(HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpValue, DWORD
void PatchPnidui(HMODULE hPnidui)
{
VnPatchIAT(hPnidui, "api-ms-win-core-com-l1-1-0.dll", "CoCreateInstance", pnidui_CoCreateInstanceHook);
if (global_rovi.dwBuildNumber >= 25000)
if (global_rovi.dwBuildNumber >= 25236)
{
VnPatchIAT(hPnidui, "api-ms-win-core-registry-l1-1-0.dll", "RegGetValueW", pnidui_RegGetValueW);
}
Expand Down Expand Up @@ -12211,6 +12214,7 @@ DWORD Inject(BOOL bIsExplorer)
if (bOldTaskbar >= 2 && !pszTaskbarDll)
{
bOldTaskbar = 1;
AdjustTaskbarStyleValue(&bOldTaskbar);
}


Expand Down Expand Up @@ -12238,6 +12242,7 @@ DWORD Inject(BOOL bIsExplorer)
CImmersiveColor_GetColorFunc = (DWORD(*)(int))((uintptr_t)hExplorer + symbols_PTRS.explorer_PTRS[0]);
}

#if 0
if (global_rovi.dwBuildNumber >= 26002)
{
// Please Microsoft 🙏
Expand Down Expand Up @@ -12267,6 +12272,7 @@ DWORD Inject(BOOL bIsExplorer)
);
}
}
#endif
}

SetChildWindowNoActivateFunc = GetProcAddress(GetModuleHandleW(L"user32.dll"), (LPCSTR)2005);
Expand Down Expand Up @@ -12664,7 +12670,7 @@ DWORD Inject(BOOL bIsExplorer)
VnPatchIAT(hStobject, "user32.dll", "TrackPopupMenu", stobject_TrackPopupMenuHook);
VnPatchIAT(hStobject, "user32.dll", "TrackPopupMenuEx", stobject_TrackPopupMenuExHook);
}
if (global_rovi.dwBuildNumber >= 25000 && bOldTaskbar)
if (global_rovi.dwBuildNumber >= 25236 && bOldTaskbar)
{
PatchStobject(hStobject);
}
Expand All @@ -12690,7 +12696,7 @@ DWORD Inject(BOOL bIsExplorer)



if (global_rovi.dwBuildNumber < 25000)
if (global_rovi.dwBuildNumber < 25236)
{
HANDLE hPnidui = LoadLibraryW(L"pnidui.dll");
if (hPnidui)
Expand Down
53 changes: 51 additions & 2 deletions ExplorerPatcher/hooking.h
@@ -1,37 +1,64 @@
#ifndef _H_HOOKING_H_
#define _H_HOOKING_H_

#define STRAT_REPLACE_ANY_TYPE_OF_JUMP_WITH_NOP 0
#define STRAT_REPLACE_ANY_TYPE_OF_JUMP_WITH_ALWAYS_JUMP 1
#define HOOK_WITH_FUNCHOOK 0
#define HOOK_WITH_DETOURS 1
#define HOW_TO_HOOK HOOK_WITH_FUNCHOOK

#if HOW_TO_HOOK == HOOK_WITH_FUNCHOOK

#ifdef _M_ARM64
#error Cannot compile for ARM64 using funchook. Change the source to hook with Detours and try again. Compilation aborted.
#endif

#include <funchook.h>
#include <distorm.h>
#pragma comment(lib, "funchook.lib")
#pragma comment(lib, "Psapi.lib") // required by funchook
#pragma comment(lib, "distorm.lib")

#elif HOW_TO_HOOK == HOOK_WITH_DETOURS

#ifdef __cplusplus
extern "C"
{
#endif

#include <detours.h>
#pragma comment(lib, "detours.lib")

#ifdef __cplusplus
inline
#endif
void* funchook_create(void)
{
return 1;
}

#ifdef __cplusplus
inline
#endif
int funchook_uninstall(
void* _this,
int flags
)
{
return 0;
}

#ifdef __cplusplus
inline
#endif
int funchook_destroy(void* _this)
{
return 0;
}

#ifdef __cplusplus
inline
#endif
int funchook_prepare(
void* funchook,
void** target_func,
Expand All @@ -43,17 +70,39 @@ int funchook_prepare(
DetourAttach(target_func, hook_func);
return DetourTransactionCommit();
}

#ifdef __cplusplus
inline
#endif
int funchook_install(
void* funchook,
int flags
)
{
return 0;
}

#ifdef __cplusplus
} // extern "C"
#endif

#endif

#define HOOKING_SUCCESS 0

#ifdef __cplusplus
extern "C"
{
#endif

#if HOW_TO_HOOK == HOOK_WITH_FUNCHOOK
funchook_t* funchook = 0;
funchook_t* funchook;
#elif HOW_TO_HOOK == HOOK_WITH_DETOURS
void* funchook = 0;
void* funchook;
#endif

#ifdef __cplusplus
} // extern "C"
#endif

#endif
35 changes: 35 additions & 0 deletions ExplorerPatcher/utility.h
Expand Up @@ -102,6 +102,9 @@ DEFINE_GUID(IID_ITrayUIComponent,
0x64, 0xb4, 0xc0, 0x9b, 0x21, 0x1b
);

#ifdef __cplusplus
inline
#endif
HRESULT(*explorer_TrayUI_CreateInstanceFunc)(ITrayUIHost* host, REFIID riid, void** ppv);
#pragma endregion

Expand Down Expand Up @@ -145,6 +148,9 @@ typedef LSTATUS(*t_SHRegGetValueFromHKCUHKLM)(
void* pvData,
DWORD* pcbData
);
#ifdef __cplusplus
inline
#endif
t_SHRegGetValueFromHKCUHKLM SHRegGetValueFromHKCUHKLMFunc;

inline LSTATUS SHRegGetValueFromHKCUHKLMWithOpt(
Expand Down Expand Up @@ -215,6 +221,9 @@ inline LSTATUS SHRegGetValueFromHKCUHKLMWithOpt(
return lRes;
}

#ifdef __cplusplus
inline
#endif
HWND(WINAPI* CreateWindowInBand)(
_In_ DWORD dwExStyle,
_In_opt_ LPCWSTR lpClassName,
Expand All @@ -231,10 +240,19 @@ HWND(WINAPI* CreateWindowInBand)(
DWORD band
);

#ifdef __cplusplus
inline
#endif
BOOL(WINAPI* GetWindowBand)(HWND hWnd, PDWORD pdwBand);

#ifdef __cplusplus
inline
#endif
BOOL(WINAPI* SetWindowBand)(HWND hWnd, HWND hwndInsertAfter, DWORD dwBand);

#ifdef __cplusplus
inline
#endif
INT64(*SetWindowCompositionAttribute)(HWND, void*);

static void(*SetPreferredAppMode)(BOOL bAllowDark);
Expand Down Expand Up @@ -672,6 +690,11 @@ inline BOOL DoesWindows10StartMenuExist()
return FileExistsW(szPath);
}

inline BOOL IsStockWindows10TaskbarAvailable()
{
return global_rovi.dwBuildNumber < 26002;
}

#if WITH_ALT_TASKBAR_IMPL
inline const WCHAR* PickTaskbarDll()
{
Expand Down Expand Up @@ -721,6 +744,18 @@ inline BOOL DoesTaskbarDllExist()
}
#endif

inline void AdjustTaskbarStyleValue(DWORD* pdwValue)
{
if (*pdwValue >= 2 && !DoesTaskbarDllExist())
{
*pdwValue = 1;
}
if (*pdwValue == 1 && !IsStockWindows10TaskbarAvailable())
{
*pdwValue = 0;
}
}

#ifdef __cplusplus
}
#endif
Expand Down
33 changes: 19 additions & 14 deletions ep_gui/GUI.c
Expand Up @@ -12,7 +12,7 @@ DWORD GUI_FileSize = 0;
BOOL g_darkModeEnabled = FALSE;
static void(*RefreshImmersiveColorPolicyState)() = NULL;
DWORD dwTaskbarPosition = 3;
BOOL gui_bOldTaskbar = TRUE;
DWORD GUI_TaskbarStyle = 1;

LSTATUS SetPolicy(HKEY hKey, LPCWSTR wszPolicyPath, LPCWSTR wszPolicyName, DWORD dwVal)
{
Expand Down Expand Up @@ -632,7 +632,7 @@ LSTATUS GUI_Internal_RegQueryValueExW(
if (pcbData == sizeof(StuckRectsData) && srd.pvData[0] == sizeof(StuckRectsData) && srd.pvData[1] == -2)
{
dwTaskbarPosition = srd.pvData[3];
if (!gui_bOldTaskbar)
if (GUI_TaskbarStyle == 0)
{
if (srd.pvData[3] != 1 && srd.pvData[3] != 3) // Disallow left/right settings for Windows 11 taskbar, as this breaks it
{
Expand Down Expand Up @@ -672,7 +672,7 @@ LSTATUS GUI_Internal_RegQueryValueExW(
);
if (pcbData == sizeof(StuckRectsData) && srd.pvData[0] == sizeof(StuckRectsData) && srd.pvData[1] == -2)
{
if (!gui_bOldTaskbar)
if (GUI_TaskbarStyle == 0)
{
if (srd.pvData[3] != 1 && srd.pvData[3] != 3) // Disallow left/right settings for Windows 11 taskbar, as this breaks it
{
Expand Down Expand Up @@ -1000,14 +1000,14 @@ static void GUI_UpdateLanguages()
EP_L10N_GetCurrentThreadLanguage(wszThreadLanguage, ARRAYSIZE(wszThreadLanguage));
}

DWORD GUI_GetTaskbarStyle()
DWORD GUI_GetTaskbarStyle(BOOL bAdjust)
{
DWORD dwRes = 1;
DWORD dwSize = sizeof(DWORD);
RegGetValueW(HKEY_CURRENT_USER, _T(REGPATH), L"OldTaskbar", RRF_RT_DWORD, NULL, &dwRes, &dwSize);
if (dwRes >= 2 && !DoesTaskbarDllExist())
if (bAdjust)
{
dwRes = 1;
AdjustTaskbarStyleValue(&dwRes);
}
return dwRes;
}
Expand Down Expand Up @@ -1161,19 +1161,23 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
if (!_stricmp(funcName, "DoesOSBuildSupportSpotlight") && !DoesOSBuildSupportSpotlight()) bSkipLines = TRUE;
else if (!_stricmp(funcName, "IsSpotlightEnabled") && !IsSpotlightEnabled()) bSkipLines = TRUE;
else if (!_stricmp(funcName, "IsSWSEnabled") && (dwRes = 0, RegGetValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer", L"AltTabSettings", RRF_RT_DWORD, NULL, &dwRes, &dwSize), (dwRes != 2))) bSkipLines = TRUE;
else if (!_stricmp(funcName, "IsOldTaskbar") && GUI_GetTaskbarStyle() == 0) bSkipLines = TRUE;
else if (!_stricmp(funcName, "!IsOldTaskbar") && GUI_GetTaskbarStyle() != 0) bSkipLines = TRUE;
else if (!_stricmp(funcName, "IsStockWin10Taskbar") && GUI_GetTaskbarStyle() != 1) bSkipLines = TRUE;
else if (!_stricmp(funcName, "IsAltImplTaskbar") && GUI_GetTaskbarStyle() <= 1) bSkipLines = TRUE;
else if (!_stricmp(funcName, "IsOldTaskbar") && GUI_GetTaskbarStyle(TRUE) == 0) bSkipLines = TRUE;
else if (!_stricmp(funcName, "!IsOldTaskbar") && GUI_GetTaskbarStyle(TRUE) != 0) bSkipLines = TRUE;
else if (!_stricmp(funcName, "IsStockWin10Taskbar") && GUI_GetTaskbarStyle(TRUE) != 1) bSkipLines = TRUE;
else if (!_stricmp(funcName, "IsAltImplTaskbar") && GUI_GetTaskbarStyle(TRUE) <= 1) bSkipLines = TRUE;
else if (!_stricmp(funcName, "DoesTaskbarDllExist") && !DoesTaskbarDllExist()) bSkipLines = TRUE;
else if (!_stricmp(funcName, "!DoesTaskbarDllExist") && DoesTaskbarDllExist()) bSkipLines = TRUE;
else if (!_stricmp(funcName, "!IsStockWindows10TaskbarAvailable") && !(!IsStockWindows10TaskbarAvailable() && GUI_GetTaskbarStyle(FALSE) == 1)) bSkipLines = TRUE;
else if (!_stricmp(funcName, "IsWindows10StartMenu") && (!DoesWindows10StartMenuExist() || (dwRes = 0, RegGetValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", L"Start_ShowClassicMode", RRF_RT_DWORD, NULL, &dwRes, &dwSize), (dwRes != 1)))) bSkipLines = TRUE;
else if (!_stricmp(funcName, "!IsWindows10StartMenu") && (DoesWindows10StartMenuExist() && (dwRes = 0, RegGetValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", L"Start_ShowClassicMode", RRF_RT_DWORD, NULL, &dwRes, &dwSize), (dwRes == 1)))) bSkipLines = TRUE;
else if (!_stricmp(funcName, "DoesWindows10StartMenuExist") && !DoesWindows10StartMenuExist()) bSkipLines = TRUE;
else if (!_stricmp(funcName, "IsWeatherEnabled") && (dwRes = 0, RegGetValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced\\People", L"PeopleBand", RRF_RT_DWORD, NULL, &dwRes, &dwSize), (dwRes != 1))) bSkipLines = TRUE;
else if (!_stricmp(funcName, "IsWindows11Version22H2OrHigher") && !IsWindows11Version22H2OrHigher()) bSkipLines = TRUE;
else if (!_stricmp(funcName, "!IsWindows11Version22H2OrHigher") && IsWindows11Version22H2OrHigher()) bSkipLines = TRUE;
else if (!_stricmp(funcName, "!(IsWindows11Version22H2OrHigher&&!IsOldTaskbar)") && (IsWindows11Version22H2OrHigher() && GUI_GetTaskbarStyle() == 0)) bSkipLines = TRUE;
else if (!_stricmp(funcName, "!(IsWindows11Version22H2OrHigher&&!IsOldTaskbar)") && (IsWindows11Version22H2OrHigher() && GUI_GetTaskbarStyle(TRUE) == 0)) bSkipLines = TRUE;
#if 1
else if (!_stricmp(funcName, "LogonLogoffShutdownSoundsAvailable")) bSkipLines = TRUE;
#endif
if (bSkipLines)
{
do
Expand Down Expand Up @@ -2485,7 +2489,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
BOOL bShouldAlterTaskbarDa = FALSE;
if (!wcscmp(name, L"TaskbarDa"))
{
if (!gui_bOldTaskbar)
if (GUI_TaskbarStyle == 0)
{
MENUITEMINFOA menuInfo;
ZeroMemory(&menuInfo, sizeof(MENUITEMINFOA));
Expand All @@ -2502,7 +2506,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
}
if (!wcscmp(name, L"Virtualized_" _T(EP_CLSID) L"_TaskbarPosition") || !wcscmp(name, L"Virtualized_" _T(EP_CLSID) L"_MMTaskbarPosition"))
{
if (!gui_bOldTaskbar)
if (GUI_TaskbarStyle == 0)
{
MENUITEMINFOA menuInfo;
ZeroMemory(&menuInfo, sizeof(MENUITEMINFOA));
Expand Down Expand Up @@ -2600,7 +2604,8 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
);
if (!wcscmp(name, L"OldTaskbar"))
{
gui_bOldTaskbar = value;
GUI_TaskbarStyle = value;
AdjustTaskbarStyleValue(&GUI_TaskbarStyle);
}
if (hDC && bInvert)
{
Expand Down
1 change: 1 addition & 0 deletions ep_gui/resources/EPSettingsResources.h
Expand Up @@ -50,6 +50,7 @@
#define IDS_TB_ICONSIZE_0 1046
#define IDS_TB_STYLE_2 1047
#define IDS_TB_ALTIMPL_NOTICE 1048
#define IDS_TB_WIN10_UNAVAILABLE 1049

#define IDS_TRAY 1101
#define IDS_TRAY_SKINMENUS 1102
Expand Down
1 change: 1 addition & 0 deletions ep_gui/resources/lang/ep_gui.en-US.rc
Expand Up @@ -41,6 +41,7 @@ BEGIN
IDS_TB_STYLE_0 "Windows 11 (default)"
IDS_TB_STYLE_1 "Windows 10"
IDS_TB_STYLE_2 "Windows 10 (ExplorerPatcher)"
IDS_TB_WIN10_UNAVAILABLE "Windows 10 taskbar is not available in this version of Windows."
IDS_TB_MORE "More taskbar options in the Settings app"
IDS_TB_CUSTOMIZETRAYICONS "Customize notification area icons"
IDS_TB_CUSTOMIZESYSTEMICONS "Customize system icons in the notification area"
Expand Down

1 comment on commit e57a6b0

@Trd24
Copy link

@Trd24 Trd24 commented on e57a6b0 May 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the Win 10 taskbar be re-enabled as this article states is possible or will it be gone forever?
https://www.xda-developers.com/latest-windows-11-update-breaks-windows-10-taskbar-apps/

"Fans of the Windows 10 taskbar need not panic just yet. First, this update only affects the Canary build of Windows 11, so anyone on the release build still has at least a few weeks until this affects them. Second, the DisableWin10Taskbar variable is itself disabled by default, but Microsoft may change that in a future update. Finally, as demonstrated in the above video, you can toggle this variable using ViVeTool, meaning you can dodge this restriction if Microsoft does enable it by default."

Please sign in to comment.