From a9b089a86abb58f6d598366b31f5ec11ee873660 Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Sun, 21 Jul 2024 14:57:31 +0700 Subject: [PATCH 1/4] Taskbar10: Reworked `ImmersiveColor.h`'s referencing to `uxtheme.dll` private functions --- ExplorerPatcher/ImmersiveColor.h | 71 +-------------------------- ExplorerPatcher/dllmain.c | 18 ++++--- ExplorerPatcher/utility.h | 84 +++++++++++++++++++++----------- ep_gui/GUI.c | 1 - 4 files changed, 67 insertions(+), 107 deletions(-) diff --git a/ExplorerPatcher/ImmersiveColor.h b/ExplorerPatcher/ImmersiveColor.h index 5c002fe..fe9840f 100644 --- a/ExplorerPatcher/ImmersiveColor.h +++ b/ExplorerPatcher/ImmersiveColor.h @@ -2,76 +2,7 @@ #include -enum IMMERSIVE_COLOR_TYPE -{ - // Defining only used ones - IMCLR_SystemAccentLight2 = 2, - IMCLR_SystemAccentDark2 = 6 -}; - -struct IMMERSIVE_COLOR_PREFERENCE -{ - DWORD crStartColor; - DWORD crAccentColor; -}; - -enum IMMERSIVE_HC_CACHE_MODE -{ - IHCM_USE_CACHED_VALUE = 0, - IHCM_REFRESH = 1 -}; - -typedef bool (*RefreshImmersiveColorPolicyState_t)(); // 104 -inline bool RefreshImmersiveColorPolicyState() -{ - static RefreshImmersiveColorPolicyState_t fn; - if (!fn) - { - HMODULE h = GetModuleHandleW(L"uxtheme.dll"); - if (h) - fn = (RefreshImmersiveColorPolicyState_t)GetProcAddress(h, MAKEINTRESOURCEA(104)); - } - return fn ? fn() : false; -} - -typedef bool (*GetIsImmersiveColorUsingHighContrast_t)(IMMERSIVE_HC_CACHE_MODE); // 106 -inline bool GetIsImmersiveColorUsingHighContrast(IMMERSIVE_HC_CACHE_MODE mode) -{ - static GetIsImmersiveColorUsingHighContrast_t fn; - if (!fn) - { - HMODULE h = GetModuleHandleW(L"uxtheme.dll"); - if (h) - fn = (GetIsImmersiveColorUsingHighContrast_t)GetProcAddress(h, MAKEINTRESOURCEA(106)); - } - return fn ? fn(mode) : false; -} - -typedef HRESULT (*GetUserColorPreference_t)(IMMERSIVE_COLOR_PREFERENCE*, bool); // 120 -inline HRESULT GetUserColorPreference(IMMERSIVE_COLOR_PREFERENCE* pcpColorPreference, bool fForceReload) -{ - static GetUserColorPreference_t fn; - if (!fn) - { - HMODULE h = GetModuleHandleW(L"uxtheme.dll"); - if (h) - fn = (GetUserColorPreference_t)GetProcAddress(h, MAKEINTRESOURCEA(120)); - } - return fn ? fn(pcpColorPreference, fForceReload) : E_FAIL; -} - -typedef DWORD (*GetColorFromPreference_t)(const IMMERSIVE_COLOR_PREFERENCE*, IMMERSIVE_COLOR_TYPE, bool, IMMERSIVE_HC_CACHE_MODE); // 121 -inline DWORD GetColorFromPreference(const IMMERSIVE_COLOR_PREFERENCE* cpcpPreference, IMMERSIVE_COLOR_TYPE colorType, bool fNoHighContrast, IMMERSIVE_HC_CACHE_MODE mode) -{ - static GetColorFromPreference_t fn; - if (!fn) - { - HMODULE h = GetModuleHandleW(L"uxtheme.dll"); - if (h) - fn = (GetColorFromPreference_t)GetProcAddress(h, MAKEINTRESOURCEA(121)); - } - return fn ? fn(cpcpPreference, colorType, fNoHighContrast, mode) : 0; -} +#include "utility.h" class CImmersiveColor { diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 15dcd0e..2387769 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -12597,15 +12597,19 @@ DWORD Inject(BOOL bIsExplorer) HANDLE hUxtheme = LoadLibraryW(L"uxtheme.dll"); - SetPreferredAppMode = GetProcAddress(hUxtheme, (LPCSTR)0x87); - AllowDarkModeForWindow = GetProcAddress(hUxtheme, (LPCSTR)0x85); - ShouldAppsUseDarkMode = GetProcAddress(hUxtheme, (LPCSTR)0x84); - ShouldSystemUseDarkMode = GetProcAddress(hUxtheme, (LPCSTR)0x8A); - GetThemeName = GetProcAddress(hUxtheme, (LPCSTR)0x4A); - PeopleBand_DrawTextWithGlowFunc = GetProcAddress(hUxtheme, (LPCSTR)0x7E); + GetThemeName = (GetThemeName_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(74)); + RefreshImmersiveColorPolicyState = (RefreshImmersiveColorPolicyState_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(104)); + GetIsImmersiveColorUsingHighContrast = (GetIsImmersiveColorUsingHighContrast_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(106)); + GetUserColorPreference = (GetUserColorPreference_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(120)); + GetColorFromPreference = (GetColorFromPreference_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(121)); + PeopleBand_DrawTextWithGlowFunc = GetProcAddress(hUxtheme, MAKEINTRESOURCEA(126)); + ShouldAppsUseDarkMode = (ShouldAppsUseDarkMode_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(132)); + AllowDarkModeForWindow = (AllowDarkModeForWindow_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(133)); + SetPreferredAppMode = (SetPreferredAppMode_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(135)); + ShouldSystemUseDarkMode = (ShouldSystemUseDarkMode_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(138)); if (bOldTaskbar) { - VnPatchIAT(hExplorer, "uxtheme.dll", (LPCSTR)0x7E, PeopleBand_DrawTextWithGlowHook); + VnPatchIAT(hExplorer, "uxtheme.dll", MAKEINTRESOURCEA(138), PeopleBand_DrawTextWithGlowHook); } // DwmExtendFrameIntoClientArea hooked in LoadSettings printf("Setup uxtheme functions done\n"); diff --git a/ExplorerPatcher/utility.h b/ExplorerPatcher/utility.h index 671e127..5bb840a 100644 --- a/ExplorerPatcher/utility.h +++ b/ExplorerPatcher/utility.h @@ -32,6 +32,12 @@ #define WM_MSG_GUI_SECTION WM_USER + 1 #define WM_MSG_GUI_SECTION_GET 1 +#ifdef __cplusplus +#define EP_INLINE inline +#else +#define EP_INLINE +#endif + #ifdef __cplusplus extern "C" { #endif @@ -98,10 +104,7 @@ DEFINE_GUID(IID_ITrayUIComponent, 0x64, 0xb4, 0xc0, 0x9b, 0x21, 0x1b ); -#ifdef __cplusplus -inline -#endif -HRESULT(*explorer_TrayUI_CreateInstanceFunc)(ITrayUIHost* host, REFIID riid, void** ppv); +EP_INLINE HRESULT(*explorer_TrayUI_CreateInstanceFunc)(ITrayUIHost* host, REFIID riid, void** ppv); #pragma endregion inline int FileExistsW(wchar_t* file) @@ -144,10 +147,7 @@ typedef LSTATUS(*t_SHRegGetValueFromHKCUHKLM)( void* pvData, DWORD* pcbData ); -#ifdef __cplusplus -inline -#endif -t_SHRegGetValueFromHKCUHKLM SHRegGetValueFromHKCUHKLMFunc; +EP_INLINE t_SHRegGetValueFromHKCUHKLM SHRegGetValueFromHKCUHKLMFunc; inline LSTATUS SHRegGetValueFromHKCUHKLMWithOpt( PCWSTR pwszKey, @@ -217,10 +217,7 @@ inline LSTATUS SHRegGetValueFromHKCUHKLMWithOpt( return lRes; } -#ifdef __cplusplus -inline -#endif -HWND(WINAPI* CreateWindowInBand)( +EP_INLINE HWND(WINAPI* CreateWindowInBand)( _In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, @@ -236,30 +233,59 @@ HWND(WINAPI* CreateWindowInBand)( DWORD band ); -#ifdef __cplusplus -inline -#endif -BOOL(WINAPI* GetWindowBand)(HWND hWnd, PDWORD pdwBand); +EP_INLINE BOOL(WINAPI* GetWindowBand)(HWND hWnd, PDWORD pdwBand); -#ifdef __cplusplus -inline -#endif -BOOL(WINAPI* SetWindowBand)(HWND hWnd, HWND hwndInsertAfter, DWORD dwBand); +EP_INLINE BOOL(WINAPI* SetWindowBand)(HWND hWnd, HWND hwndInsertAfter, DWORD dwBand); -#ifdef __cplusplus -inline -#endif -INT64(*SetWindowCompositionAttribute)(HWND, void*); +EP_INLINE INT64(*SetWindowCompositionAttribute)(HWND, void*); + +// uxtheme.dll private functions + +typedef enum IMMERSIVE_COLOR_TYPE +{ + // Defining only used ones + IMCLR_SystemAccentLight2 = 2, + IMCLR_SystemAccentDark2 = 6 +} IMMERSIVE_COLOR_TYPE; + +typedef struct IMMERSIVE_COLOR_PREFERENCE +{ + DWORD crStartColor; + DWORD crAccentColor; +} IMMERSIVE_COLOR_PREFERENCE; + +typedef enum IMMERSIVE_HC_CACHE_MODE +{ + IHCM_USE_CACHED_VALUE = 0, + IHCM_REFRESH = 1 +} IMMERSIVE_HC_CACHE_MODE; + +typedef void(*GetThemeName_t)(void*, void*, void*); // 74 +EP_INLINE GetThemeName_t GetThemeName; + +typedef bool(*RefreshImmersiveColorPolicyState_t)(); // 104 +EP_INLINE RefreshImmersiveColorPolicyState_t RefreshImmersiveColorPolicyState; + +typedef bool(*GetIsImmersiveColorUsingHighContrast_t)(IMMERSIVE_HC_CACHE_MODE); // 106 +EP_INLINE GetIsImmersiveColorUsingHighContrast_t GetIsImmersiveColorUsingHighContrast; + +typedef HRESULT(*GetUserColorPreference_t)(IMMERSIVE_COLOR_PREFERENCE*, bool); // 120 +EP_INLINE GetUserColorPreference_t GetUserColorPreference; -static void(*SetPreferredAppMode)(BOOL bAllowDark); +typedef DWORD(*GetColorFromPreference_t)(const IMMERSIVE_COLOR_PREFERENCE*, IMMERSIVE_COLOR_TYPE, bool, IMMERSIVE_HC_CACHE_MODE); // 121 +EP_INLINE GetColorFromPreference_t GetColorFromPreference; -static void(*AllowDarkModeForWindow)(HWND hWnd, BOOL bAllowDark); +typedef bool(*ShouldAppsUseDarkMode_t)(); // 132 +EP_INLINE ShouldAppsUseDarkMode_t ShouldAppsUseDarkMode; -static bool(*ShouldAppsUseDarkMode)(); +typedef void(*AllowDarkModeForWindow_t)(HWND hWnd, BOOL bAllowDark); // 133 +EP_INLINE AllowDarkModeForWindow_t AllowDarkModeForWindow; -static bool(*ShouldSystemUseDarkMode)(); +typedef void(*SetPreferredAppMode_t)(BOOL bAllowDark); // 135 +EP_INLINE SetPreferredAppMode_t SetPreferredAppMode; -static void(*GetThemeName)(void*, void*, void*); +typedef bool(*ShouldSystemUseDarkMode_t)(); // 138 +EP_INLINE ShouldSystemUseDarkMode_t ShouldSystemUseDarkMode; void* ReadFromFile(wchar_t* wszFileName, DWORD* dwSize); diff --git a/ep_gui/GUI.c b/ep_gui/GUI.c index 9220cba..a494f84 100644 --- a/ep_gui/GUI.c +++ b/ep_gui/GUI.c @@ -10,7 +10,6 @@ WCHAR wszThreadLanguage[LOCALE_NAME_MAX_LENGTH]; void* GUI_FileMapping = NULL; DWORD GUI_FileSize = 0; BOOL g_darkModeEnabled = FALSE; -static void(*RefreshImmersiveColorPolicyState)() = NULL; DWORD dwTaskbarPosition = 3; DWORD GUI_TaskbarStyle = 1; From 48c2a7551efc5d6f2d2bc842c6c2f9f8b590b349 Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Sun, 21 Jul 2024 15:03:41 +0700 Subject: [PATCH 2/4] Build: Disable bundling of ep_taskbar for now --- .github/workflows/build.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ce2554f..9d3b318 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -86,13 +86,13 @@ jobs: run: | nuget restore ExplorerPatcher.sln - - name: Download ep_taskbar - uses: robinraju/release-downloader@v1 - with: - repository: ExplorerPatcher/ep_taskbar_releases - fileName: ep_taskbar.*.dll - latest: true - out-file-path: build/Release + # - name: Download ep_taskbar + # uses: robinraju/release-downloader@v1 + # with: + # repository: ExplorerPatcher/ep_taskbar_releases + # fileName: ep_taskbar.*.dll + # latest: true + # out-file-path: build/Release - name: Build funchook shell: powershell From 214ad2bd18bf82da673ff0c37f0f103eec37b143 Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Sun, 21 Jul 2024 15:09:53 +0700 Subject: [PATCH 3/4] Version: 22621.3880.66.2 (pre-release) --- CHANGELOG.md | 12 +++++++++--- version.h | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e1feed..9193a6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,17 +2,23 @@ This document includes the same release notes as in the [Releases](https://github.com/valinet/ExplorerPatcher/releases) section on GitHub. -## 22621.3810.66 - -##### 1 +## 22621.3880.66 Tested on OS builds 19045.4598, 22621.3296, 22621.3810, 26120.961, and 26244.5000. (Note: 22621 and 22631 share the same OS files) +##### 1 + * Taskbar10: Introduced a new taskbar implementation: Windows 10 (ExplorerPatcher). (146070d, 0b86e55) * You can try this implementation out by changing the "Taskbar style" to "Windows 10 (ExplorerPatcher)". * For now, this is **only available for builds 22621, 22631, and 22635.** Other builds will not have the option. * Refer to [this wiki article](https://github.com/valinet/ExplorerPatcher/wiki/ExplorerPatcher's-taskbar-implementation) for more information including important ones. +##### 2 + +* Taskbar10: Due to false positive antivirus detections, the new taskbar implementation is no longer bundled in the setup program. (48c2a75) + * If you want to use the new taskbar implementation, you can download the appropriate DLL for your system from the [Releases](https://github.com/ExplorerPatcher/ep_taskbar_releases/releases/latest) page of its releases repository, and then manually putting it in `C:\Program Files\ExplorerPatcher` without the architecture specifier. + * For example, for 226xx builds on x64-based systems, download `ep_taskbar.2.amd64.dll`, rename to `ep_taskbar.2.dll`, and lastly put it in `C:\Program Files\ExplorerPatcher`. + ## 22621.3527.65 Tested on OS builds 22621.3296, 22621.3447, 22621.3527, 22635.3566, 26058.1000, 26120.461, and 26200.5001. (Note: 22621 and 22631 share the same OS files) diff --git a/version.h b/version.h index 101bc10..f63f8ff 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ #define VER_MAJOR 22621 -#define VER_MINOR 3810 +#define VER_MINOR 3880 #define VER_BUILD_HI 66 -#define VER_BUILD_LO 1 +#define VER_BUILD_LO 2 #define VER_FLAGS VS_FF_PRERELEASE From 19177e4f72f4668d60155264fc551c7e5420bc99 Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Sun, 21 Jul 2024 23:27:48 +0700 Subject: [PATCH 4/4] ep_taskbar: Hook context menu functions --- ExplorerPatcher/dllmain.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 2387769..c6830ac 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -2284,10 +2284,12 @@ INT64 ReBarWindow32SubclassProc(_In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM wPar return DefSubclassProc(hWnd, uMsg, wParam, lParam); } +HMODULE g_hMyTaskbar; + HMENU explorer_LoadMenuW(HINSTANCE hInstance, LPCWSTR lpMenuName) { HMENU hMenu = LoadMenuW(hInstance, lpMenuName); - if (hInstance == GetModuleHandle(NULL) && lpMenuName == MAKEINTRESOURCEW(205)) + if ((hInstance == GetModuleHandle(NULL) || (g_hMyTaskbar && hInstance == g_hMyTaskbar)) && lpMenuName == MAKEINTRESOURCEW(205)) { HMENU hSubMenu = GetSubMenu(hMenu, 0); if (hSubMenu) @@ -11919,6 +11921,7 @@ HMODULE PrepareAlternateTaskbarImplementation(symbols_addr* symbols_PTRS, const wprintf(L"[TB] '%s' not found\n", pszTaskbarDll); return NULL; } + g_hMyTaskbar = hMyTaskbar; typedef DWORD (*GetVersion_t)(); GetVersion_t GetVersion = (GetVersion_t)GetProcAddress(hMyTaskbar, "GetVersion"); @@ -12609,7 +12612,7 @@ DWORD Inject(BOOL bIsExplorer) ShouldSystemUseDarkMode = (ShouldSystemUseDarkMode_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(138)); if (bOldTaskbar) { - VnPatchIAT(hExplorer, "uxtheme.dll", MAKEINTRESOURCEA(138), PeopleBand_DrawTextWithGlowHook); + VnPatchIAT(hExplorer, "uxtheme.dll", MAKEINTRESOURCEA(126), PeopleBand_DrawTextWithGlowHook); } // DwmExtendFrameIntoClientArea hooked in LoadSettings printf("Setup uxtheme functions done\n"); @@ -12807,6 +12810,11 @@ DWORD Inject(BOOL bIsExplorer) VnPatchIAT(hTwinuiPcshell, "API-MS-WIN-CORE-REGISTRY-L1-1-0.DLL", "RegGetValueW", twinuipcshell_RegGetValueW); HMODULE hMyTaskbar = PrepareAlternateTaskbarImplementation(&symbols_PTRS, pszTaskbarDll); + if (hMyTaskbar) + { + VnPatchIAT(hMyTaskbar, "user32.dll", "LoadMenuW", explorer_LoadMenuW); + VnPatchIAT(hMyTaskbar, "user32.dll", "TrackPopupMenuEx", explorer_TrackPopupMenuExHook); + } printf("Setup twinui.pcshell functions done\n");