From 8fc53a12856896a12dcba61631f847ef4e0ecd60 Mon Sep 17 00:00:00 2001 From: aubymori Date: Sat, 21 Oct 2023 01:21:17 -0500 Subject: [PATCH 1/7] Accurate taskbar fonts for classic theme mitigations --- ExplorerPatcher/dllmain.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 049f03b68..bca8447c6 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -8062,27 +8062,15 @@ HRESULT explorer_DrawThemeTextEx( SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), &ncm, 0); HFONT hFont = NULL; - if (bIsActiveUnhovered) + if (bIsActiveUnhovered || bIsActiveHovered) { - hFont = CreateFontIndirectW(&(ncm.lfCaptionFont)); - } - else if (bIsInactiveUnhovered) - { - hFont = CreateFontIndirectW(&(ncm.lfMenuFont)); - } - else if (bIsActiveHovered) - { - hFont = CreateFontIndirectW(&(ncm.lfCaptionFont)); - } - else if (bIsInactiveHovered) - { - hFont = CreateFontIndirectW(&(ncm.lfMenuFont)); + ncm.lfCaptionFont.lfWeight = FW_BOLD; } else { - hFont = CreateFontIndirectW(&(ncm.lfMenuFont)); - //wprintf(L"DrawThemeTextEx %d %d %s\n", iPartId, iStateId, pszText); + ncm.lfCaptionFont.lfWeight = FW_NORMAL; } + hFont = CreateFontIndirectW(&(ncm.lfCaptionFont)); if (iPartId == 5 && iStateId == 0) // clock { From 655e62c364e3b16c8a4b53e42e0b56a18a644d85 Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Sun, 22 Oct 2023 00:03:31 +0700 Subject: [PATCH 2/7] Start10: Fixed a bug where certain localizable texts stayed in English I've employed a different method to fix the context menus. Even so, I'm keeping the old method as a fallback. --- ExplorerPatcher/ExplorerPatcher.rc | Bin 35990 -> 36132 bytes ExplorerPatcher/dllmain.c | 108 +++++++++++++++++++++++++++-- ExplorerPatcher/resource.h | 1 + 3 files changed, 102 insertions(+), 7 deletions(-) diff --git a/ExplorerPatcher/ExplorerPatcher.rc b/ExplorerPatcher/ExplorerPatcher.rc index 1e1f3a87867f6e916a5cd38530b9c59e6967742b..3e006d955d5f02d833343a84d4169c9c6cc2a245 100644 GIT binary patch delta 100 zcmbO>lWEB;rVS2)llKVlD7rBOF}N}WGk5?=7a$$N5Xs;J7KvwwU~pn^o17_Nsvg9U r%8m_buffer = LockResource(hgRscr); + pBuffer->m_count = SizeofResource(hModule, hRscr); + pBuffer->m_bufferType = XBT_Binary; + return TRUE; +} + +Parser_XamlBuffer g_EmptyRefreshedStylesXbfBuffer; + +HRESULT(*CCoreServices_TryLoadXamlResourceHelperFunc)(void* _this, void* pUri, bool* pfHasBinaryFile, void** ppMemory, Parser_XamlBuffer* pBuffer, void** ppPhysicalUri); +HRESULT CCoreServices_TryLoadXamlResourceHelperHook(void* _this, void* pUri, bool* pfHasBinaryFile, void** ppMemory, Parser_XamlBuffer* pBuffer, void** ppPhysicalUri) +{ + HRESULT(*Clone)(void* _this, void** ppUri); // index 3 + HRESULT(*GetPath)(void* _this, unsigned int* pBufferLength, wchar_t* pszBuffer); // index 12 + void** vtable = *(void***)pUri; + Clone = vtable[3]; + GetPath = vtable[12]; + wchar_t thePath[MAX_PATH]; + unsigned int len = MAX_PATH; + GetPath(pUri, &len, thePath); + // OutputDebugStringW(thePath); OutputDebugStringW(L"<<<<<\n"); + + if (!wcscmp(thePath, L"/JumpViewUI/RefreshedStyles.xaml")) + { + *pfHasBinaryFile = true; + *pBuffer = g_EmptyRefreshedStylesXbfBuffer; + if (ppPhysicalUri) + Clone(pUri, ppPhysicalUri); + return pBuffer->m_buffer ? S_OK : E_FAIL; + } + + return CCoreServices_TryLoadXamlResourceHelperFunc(_this, pUri, pfHasBinaryFile, ppMemory, pBuffer, ppPhysicalUri); +} + +static BOOL StartMenu_FixContextMenuXbfHijackMethod() +{ + LoadLibraryW(L"Windows.UI.Xaml.dll"); + HANDLE hWindowsUIXaml = GetModuleHandleW(L"Windows.UI.Xaml.dll"); + MODULEINFO mi; + GetModuleInformation(GetCurrentProcess(), hWindowsUIXaml, &mi, sizeof(mi)); + + if (!StartMenu_FillParserBuffer(&g_EmptyRefreshedStylesXbfBuffer, IDR_REFRESHEDSTYLES_XBF)) + return FALSE; + + // 49 89 43 C8 E8 ?? ?? ?? ?? 85 C0 + // ^^^^^^^^^^^ + // Ref: CCoreServices::LoadXamlResource() + PBYTE match = FindPattern( + mi.lpBaseOfDll, + mi.SizeOfImage, + "\x49\x89\x43\xC8\xE8\x00\x00\x00\x00\x85\xC0", + "xxxxx????xx" + ); + if (!match) + return FALSE; + + match += 4; + match += 5 + *(int*)(match + 1); + CCoreServices_TryLoadXamlResourceHelperFunc = match; + funchook_prepare( + funchook, + (void**)&CCoreServices_TryLoadXamlResourceHelperFunc, + CCoreServices_TryLoadXamlResourceHelperHook + ); + return TRUE; +} + LSTATUS StartUI_RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult) { if (wcsstr(lpSubKey, L"$start.tilegrid$windows.data.curatedtilecollection.tilecollection\\Current")) @@ -13189,13 +13279,17 @@ DWORD InjectStartMenu() PatchAppResolver(); PatchStartTileData(); - // Redirects to pri files from 22000.51 which work with the legacy menu - LoadLibraryW(L"MrmCoreR.dll"); - HANDLE hMrmCoreR = GetModuleHandleW(L"MrmCoreR.dll"); - VnPatchIAT(hMrmCoreR, "api-ms-win-core-file-l1-1-0.dll", "CreateFileW", StartUI_CreateFileW); - VnPatchIAT(hMrmCoreR, "api-ms-win-core-file-l1-1-0.dll", "GetFileAttributesExW", StartUI_GetFileAttributesExW); - VnPatchIAT(hMrmCoreR, "api-ms-win-core-file-l1-1-0.dll", "FindFirstFileW", StartUI_FindFirstFileW); - VnPatchIAT(hMrmCoreR, "api-ms-win-core-registry-l1-1-0.dll", "RegGetValueW", StartUI_RegGetValueW); + // Fixes context menu crashes + if (!StartMenu_FixContextMenuXbfHijackMethod()) { + // Fallback to the old method, but we'll have broken localization + // Redirects to pri files from 22000.51 which work with the legacy menu + LoadLibraryW(L"MrmCoreR.dll"); + HANDLE hMrmCoreR = GetModuleHandleW(L"MrmCoreR.dll"); + VnPatchIAT(hMrmCoreR, "api-ms-win-core-file-l1-1-0.dll", "CreateFileW", StartUI_CreateFileW); + VnPatchIAT(hMrmCoreR, "api-ms-win-core-file-l1-1-0.dll", "GetFileAttributesExW", StartUI_GetFileAttributesExW); + VnPatchIAT(hMrmCoreR, "api-ms-win-core-file-l1-1-0.dll", "FindFirstFileW", StartUI_FindFirstFileW); + VnPatchIAT(hMrmCoreR, "api-ms-win-core-registry-l1-1-0.dll", "RegGetValueW", StartUI_RegGetValueW); + } // Enables "Show more tiles" setting LoadLibraryW(L"Windows.CloudStore.dll"); diff --git a/ExplorerPatcher/resource.h b/ExplorerPatcher/resource.h index 57986c4dc..2e86782dd 100644 --- a/ExplorerPatcher/resource.h +++ b/ExplorerPatcher/resource.h @@ -16,6 +16,7 @@ #define IDS_UNINSTALL_ERROR_TEXT 112 #define IDS_OPERATION_NONE 113 #define IDR_REGISTRY2 114 +#define IDR_REFRESHEDSTYLES_XBF 115 #define IDS_DRIVECATEGORY_HARDDISKDRIVES 40000 #define IDS_DRIVECATEGORY_REMOVABLESTORAGE 40001 #define IDS_DRIVECATEGORY_OTHER 40002 From 11160c804d1212923dee468b9838e2d5f4eeb136 Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Sun, 22 Oct 2023 00:08:35 +0700 Subject: [PATCH 3/7] GUI: Fixed a bug where "Remember last used section" doesn't remember the current page after being enabled --- ExplorerPatcher/ExplorerPatcher.vcxproj | 4 ++-- ExplorerPatcher/def.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ExplorerPatcher/ExplorerPatcher.vcxproj b/ExplorerPatcher/ExplorerPatcher.vcxproj index 1f0721717..10dadad18 100644 --- a/ExplorerPatcher/ExplorerPatcher.vcxproj +++ b/ExplorerPatcher/ExplorerPatcher.vcxproj @@ -96,7 +96,7 @@ true true true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + NDEBUG;_CONSOLE;WINRT_NO_SOURCE_LOCATION;%(PreprocessorDefinitions) true $(SolutionDir)libs\funchook\include;$(SolutionDir)libs\libvalinet;$(SolutionDir)libs\funchook\distorm\include;$(SolutionDir)libs\Detours\include;%(AdditionalIncludeDirectories) MultiThreaded @@ -126,7 +126,7 @@ true true true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + NDEBUG;_CONSOLE;WINRT_NO_SOURCE_LOCATION;%(PreprocessorDefinitions) true $(SolutionDir)libs\funchook\include;$(SolutionDir)libs\libvalinet;$(SolutionDir)libs\funchook\distorm\include;$(SolutionDir)libs\Detours\include;%(AdditionalIncludeDirectories) MultiThreaded diff --git a/ExplorerPatcher/def.h b/ExplorerPatcher/def.h index 3b1d683ea..ba61dc290 100644 --- a/ExplorerPatcher/def.h +++ b/ExplorerPatcher/def.h @@ -1,8 +1,8 @@ #ifndef _H_DEF_H_ #define _H_DEF_H_ #define APPID L"Microsoft.Windows.Explorer" -#define REGPATH "SOFTWARE\\ExplorerPatcher" -#define REGPATH_OLD "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ExplorerPatcher" +#define REGPATH "Software\\ExplorerPatcher" +#define REGPATH_OLD "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ExplorerPatcher" #define REGPATH_STARTMENU REGPATH_OLD #define SPECIAL_FOLDER CSIDL_PROGRAM_FILES #define SPECIAL_FOLDER_LEGACY CSIDL_APPDATA From 2cc87aba39d4150741a0ec54c163d793f5ec69f9 Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Sun, 22 Oct 2023 01:56:31 +0700 Subject: [PATCH 4/7] Taskbar10: Fixed a bug where the Windows 10 taskbar no longer shows after a certain configuration update in 23560.1000 --- ExplorerPatcher/dllmain.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index f5b6522cf..d9e963c6f 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -4296,6 +4296,7 @@ INT64 winrt_Windows_Internal_Shell_implementation_MeetAndChatManager_OnMessageHo #pragma region "Enable old taskbar" #ifdef _WIN64 +HRESULT(*explorer_RoGetActivationFactoryFunc)(HSTRING activatableClassId, GUID* iid, void** factory); HRESULT explorer_RoGetActivationFactoryHook(HSTRING activatableClassId, GUID* iid, void** factory) { PCWSTR StringRawBuffer = WindowsGetStringRawBuffer(activatableClassId, 0); @@ -4312,7 +4313,7 @@ HRESULT explorer_RoGetActivationFactoryHook(HSTRING activatableClassId, GUID* ii return S_OK; } } - return RoGetActivationFactory(activatableClassId, iid, factory); + return explorer_RoGetActivationFactoryFunc(activatableClassId, iid, factory); } FARPROC explorer_GetProcAddressHook(HMODULE hModule, const CHAR* lpProcName) @@ -11384,7 +11385,9 @@ DWORD Inject(BOOL bIsExplorer) { VnPatchIAT(hExplorer, "user32.dll", (LPCSTR)2005, explorer_SetChildWindowNoActivateHook); VnPatchDelayIAT(hExplorer, "ext-ms-win-rtcore-ntuser-window-ext-l1-1-0.dll", "SendMessageW", explorer_SendMessageW); - VnPatchIAT(hExplorer, "api-ms-win-core-libraryloader-l1-2-0.dll", "GetProcAddress", explorer_GetProcAddressHook); + // A certain configuration update in 23560.1000 broke this method, this didn't get called with + // "RoGetActivationFactory" anymore. We're now hooking RoGetActivationFactory directly. + // VnPatchIAT(hExplorer, "api-ms-win-core-libraryloader-l1-2-0.dll", "GetProcAddress", explorer_GetProcAddressHook); VnPatchIAT(hExplorer, "shell32.dll", "ShellExecuteW", explorer_ShellExecuteW); VnPatchIAT(hExplorer, "shell32.dll", "ShellExecuteExW", explorer_ShellExecuteExW); VnPatchIAT(hExplorer, "API-MS-WIN-CORE-REGISTRY-L1-1-0.DLL", "RegGetValueW", explorer_RegGetValueW); @@ -11712,11 +11715,31 @@ DWORD Inject(BOOL bIsExplorer) printf("Setup twinui.pcshell functions done\n"); - if (IsWindows11Version22H2OrHigher()) + if (IsWindows11()) { HANDLE hCombase = LoadLibraryW(L"combase.dll"); - // Fixed a bug that crashed Explorer when a folder window was opened after a first one was closed on OS builds 22621+ - VnPatchIAT(hCombase, "api-ms-win-core-libraryloader-l1-2-0.dll", "LoadLibraryExW", Windows11v22H2_combase_LoadLibraryExW); + if (bOldTaskbar) + { + // Hook RoGetActivationFactory() for old taskbar + explorer_RoGetActivationFactoryFunc = GetProcAddress(hCombase, "RoGetActivationFactory"); + if (explorer_RoGetActivationFactoryFunc) + { + rv = funchook_prepare( + funchook, + (void**)&explorer_RoGetActivationFactoryFunc, + explorer_RoGetActivationFactoryHook + ); + } + if (rv != 0) + { + printf("Failed to hook RoGetActivationFactory(). rv = %d\n", rv); + } + } + if (IsWindows11Version22H2OrHigher()) + { + // Fixed a bug that crashed Explorer when a folder window was opened after a first one was closed on OS builds 22621+ + VnPatchIAT(hCombase, "api-ms-win-core-libraryloader-l1-2-0.dll", "LoadLibraryExW", Windows11v22H2_combase_LoadLibraryExW); + } printf("Setup combase functions done\n"); } From 5321766d4e610f4f50c61fda8a925763e873c7a3 Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Sun, 22 Oct 2023 01:58:16 +0700 Subject: [PATCH 5/7] Start10: Add RefreshedStyles.xbf --- ExplorerPatcher/RefreshedStyles.xbf | Bin 0 -> 536 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 ExplorerPatcher/RefreshedStyles.xbf diff --git a/ExplorerPatcher/RefreshedStyles.xbf b/ExplorerPatcher/RefreshedStyles.xbf new file mode 100644 index 0000000000000000000000000000000000000000..68f84fcf4482adc4cb1c0728603ae341b346bf74 GIT binary patch literal 536 zcmcJMy-veG5QHZ&^au%2)1$=p`3F;BJGKNZ0?|gn{75#Ah$GVSHWU;T6g&hEmG971 zP_w7i%+BrI?%m!LwZ2EvnWQle)dsirW&`Zq;fKRdhhGj0V}g@eT!bd`^RmwCpfdg} zEKQM_C@5#9h@-el1N10Q%Qy{8nv^Cf>nhDmlI>6i<$YGF&xHJoe68c+xFd$@G`k9DOzZeLT^c6ZOa zE{Hn1xkhQ|`by_y9Q?|< Date: Sun, 22 Oct 2023 02:11:20 +0700 Subject: [PATCH 6/7] Version: 22621.2428.59.1 (Pre-release) --- CHANGELOG.md | 17 +++++++++++++++++ version.h | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72400451c..79070fbb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,23 @@ This document includes the same release notes as in the [Releases](https://github.com/valinet/ExplorerPatcher/releases) section on GitHub. +## 22621.2428.59 + +Tested on OS builds 22000.2416, 22621.2428, 23555.1000, and 23560.1000. + +#### Details + +##### 1 + +* Taskbar10: Fixed Control Center and Toast Center positioning on build 25951 (Canary). (dca0b3a) +* Taskbar10: Fixed start menu position when the taskbar is at the left or right side on Moment 4 builds. (a57471f) +* Taskbar10: Fixed the Windows 10 taskbar background patch to not crash anymore on build 25951 (Canary). (b52bd79) +* Taskbar10: Made taskbar fonts (when using classic theme mitigations) more accurate (thanks @aubymori). (8fc53a1) +* Start10: Fixed a bug where certain texts in the Windows 10 Start menu stayed in English. (c6a7d3f, ed251e9) +* Start10: Properly fixed start menu showing/hiding along with its original animations on builds 22000.65+. (7e2f768) +* GUI: Fixed a bug where "Remember last used section" doesn't remember the current page after being enabled. (dcf72bb) +* Symbols: Reworked how symbols are managed so that symbols don't need to be successfully downloaded in succession. (8412bd6) + ## 22621.2361.58 Tested on OS builds 22000.2416, 22621.1, 22621.2134, 22621.2361, 22631.2338, and 23545.1000. diff --git a/version.h b/version.h index aa2215c90..9d708d784 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ #define VER_MAJOR 22621 -#define VER_MINOR 2361 -#define VER_BUILD_HI 58 -#define VER_BUILD_LO 4 +#define VER_MINOR 2428 +#define VER_BUILD_HI 59 +#define VER_BUILD_LO 1 #define VER_FLAGS VS_FF_PRERELEASE From a77aff4b296a21417ea252debc95e0156e1e6245 Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Sun, 22 Oct 2023 02:37:04 +0700 Subject: [PATCH 7/7] Taskbar10: Pulled back 2cc87ab Crashes on 22621.2428 (by a call from Windows.UI.Immersive.dll), needs further investigation for a proper fix --- CHANGELOG.md | 2 ++ ExplorerPatcher/dllmain.c | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79070fbb3..1cdc27eeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ Tested on OS builds 22000.2416, 22621.2428, 23555.1000, and 23560.1000. ##### 1 +Note: After updating to this version, the symbols will be re-downloaded even if they have been downloaded before. + * Taskbar10: Fixed Control Center and Toast Center positioning on build 25951 (Canary). (dca0b3a) * Taskbar10: Fixed start menu position when the taskbar is at the left or right side on Moment 4 builds. (a57471f) * Taskbar10: Fixed the Windows 10 taskbar background patch to not crash anymore on build 25951 (Canary). (b52bd79) diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index d9e963c6f..41af42f2f 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -11386,8 +11386,9 @@ DWORD Inject(BOOL bIsExplorer) VnPatchIAT(hExplorer, "user32.dll", (LPCSTR)2005, explorer_SetChildWindowNoActivateHook); VnPatchDelayIAT(hExplorer, "ext-ms-win-rtcore-ntuser-window-ext-l1-1-0.dll", "SendMessageW", explorer_SendMessageW); // A certain configuration update in 23560.1000 broke this method, this didn't get called with - // "RoGetActivationFactory" anymore. We're now hooking RoGetActivationFactory directly. - // VnPatchIAT(hExplorer, "api-ms-win-core-libraryloader-l1-2-0.dll", "GetProcAddress", explorer_GetProcAddressHook); + // "RoGetActivationFactory" anymore. ~~We're now hooking RoGetActivationFactory directly.~~ Pulled back for now. + explorer_RoGetActivationFactoryFunc = RoGetActivationFactory; + VnPatchIAT(hExplorer, "api-ms-win-core-libraryloader-l1-2-0.dll", "GetProcAddress", explorer_GetProcAddressHook); VnPatchIAT(hExplorer, "shell32.dll", "ShellExecuteW", explorer_ShellExecuteW); VnPatchIAT(hExplorer, "shell32.dll", "ShellExecuteExW", explorer_ShellExecuteExW); VnPatchIAT(hExplorer, "API-MS-WIN-CORE-REGISTRY-L1-1-0.DLL", "RegGetValueW", explorer_RegGetValueW); @@ -11718,7 +11719,7 @@ DWORD Inject(BOOL bIsExplorer) if (IsWindows11()) { HANDLE hCombase = LoadLibraryW(L"combase.dll"); - if (bOldTaskbar) + /*if (bOldTaskbar) // TODO Pulled back for now, crashes on 22621.2428 { // Hook RoGetActivationFactory() for old taskbar explorer_RoGetActivationFactoryFunc = GetProcAddress(hCombase, "RoGetActivationFactory"); @@ -11734,7 +11735,7 @@ DWORD Inject(BOOL bIsExplorer) { printf("Failed to hook RoGetActivationFactory(). rv = %d\n", rv); } - } + }*/ if (IsWindows11Version22H2OrHigher()) { // Fixed a bug that crashed Explorer when a folder window was opened after a first one was closed on OS builds 22621+