From 2572a802db0355fc50674f23a7a99baccab707a0 Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Tue, 15 Nov 2022 15:35:33 +0200 Subject: [PATCH 01/10] Start11: Respect "Layout" settings on 22621-based builds Impact: The actual layout setting from Windows Settings - Personalization - Start is ignored and the "Default" layout setting is always used when displaying the Windows 11 Start menu on 22621-based builds when the setting to disable the "Recommended" section is NOT used in ExplorerPatcher Properties. Description: The issue has been addressed by remembering the current/ previous setting and using that when setting the height of the pinned area when the setting to disable the "Recommended" section is NOT used in ExplorerPatcher Properties, as opposed to the previous behavior where a hardcoded value was being used. --- ExplorerPatcher/lvt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ExplorerPatcher/lvt.c b/ExplorerPatcher/lvt.c index 3d29d47..36b8d37 100644 --- a/ExplorerPatcher/lvt.c +++ b/ExplorerPatcher/lvt.c @@ -622,13 +622,17 @@ void LVT_StartDocked_DisableRecommendedSection(HWND hWnd, BOOL bApply) pStartMenuPinnedList->lpVtbl->QueryInterface(pStartMenuPinnedList, &IID_Windows_UI_Xaml_IFrameworkElement, &pFrameworkElement); if (pFrameworkElement) { + static double StartMenuPinnedList_Height = 252.0; + double tempStartMenuPinnedList_Height = 0.0; + if (SUCCEEDED(pFrameworkElement->lpVtbl->get_Height(pFrameworkElement, &tempStartMenuPinnedList_Height)) && tempStartMenuPinnedList_Height != 510.0) StartMenuPinnedList_Height = tempStartMenuPinnedList_Height; + if (bApply) { pFrameworkElement->lpVtbl->put_Height(pFrameworkElement, 510.0); } else { - pFrameworkElement->lpVtbl->put_Height(pFrameworkElement, 252.0); + pFrameworkElement->lpVtbl->put_Height(pFrameworkElement, StartMenuPinnedList_Height); } pFrameworkElement->lpVtbl->Release(pFrameworkElement); } From 6190fd227879e48ba5bee8b484ca8fcee9395a9b Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Tue, 15 Nov 2022 15:37:46 +0200 Subject: [PATCH 02/10] Version: 22621.608.51.5 --- CHANGELOG.md | 4 ++++ version.h | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b213c0..99f0e98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,10 @@ Please make sure you are connected to the Internet while installing, the applica * Windows 11 taskbar: Fixed a bug that could crash `explorer.exe` when right clicking certain system tray icons on 22621-based builds. Thanks for the reports about this issue. (a6a88b1) +##### 5 + +* Windows 11 Start menu: Fixed a bug that prevented the menu from taking into account the "Layout" setting from Windows Settings - Personalization - Taskbar on 22621-based builds. (2572a80) + ## 22622.450.50 Tested on OS build 22622.450. diff --git a/version.h b/version.h index ccbbd13..83014ec 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ #define VER_MAJOR 22621 #define VER_MINOR 608 #define VER_BUILD_HI 51 -#define VER_BUILD_LO 4 +#define VER_BUILD_LO 5 #define VER_FLAGS VS_FF_PRERELEASE @@ -12,5 +12,5 @@ #define VER_STR(arg) #arg // The String form of the version numbers -#define VER_FILE_STRING VALUE "FileVersion", "22621.608.51.4" -#define VER_PRODUCT_STRING VALUE "ProductVersion", "22621.608.51.4" +#define VER_FILE_STRING VALUE "FileVersion", "22621.608.51.5" +#define VER_PRODUCT_STRING VALUE "ProductVersion", "22621.608.51.5" From d7a038564b81730072549ba3fe3346408565998b Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Thu, 17 Nov 2022 01:28:31 +0200 Subject: [PATCH 03/10] All: Protect against crashes caused by failure to patch the IAT Impact: A recent bug report on the Mozilla Firefox issue tracker (https://bugzilla.mozilla.org/show_bug.cgi?id=1798707) identifies a crash in the Firefox browser caused by an invalid memory access performed by ExplorerPatcher (https://crash-stats.mozilla.org/signature/?signature=explorerpatcher.amd64.dll%20|%20%3Cunknown%20in%20Windows.UI.FileExplorer.dll%3E%20|%20explorerpatcher.amd64.dll%20|%20RtlpFindEntry%20|%20RtlpAllocateHeap%20|%20RtlpAllocateHeapInternal%20|%20explorerpatcher.amd64.dll%20|%20RtlDosApplyFileIsolationRedirection_Ustr%20|%20LdrpApplyFileNameRed...&date=%3E%3D2022-11-02T20%3A44%3A00.000Z&date=%3C2022-11-16T20%3A44%3A00.000Z). This might happen only when the "Register as shell extension: option is used, and ExplorerPatcher is injected in other processes. Testing was unable to reproduce the issue, but looking on the crash logs it was determined that it likely happens in "VnPatchDelayIAT", where the memory is patched regardless of whether the protection level actually succeeded changing or not. The call is suspected to fail when certain antivirus solutions are used, although a clear test case with this scenario could not be determined. Also, code review determined that a race condition might happen in both "VnPatchIAT" and "VnPatchDelayIAT", where some other thread might unload the module while the code works with it, attempting to patch the requested function. Description: The issue has been addressed by improved checks and ensuring the module is not unloaded while the functions work with it. The program only attempts to patch the memory if the previous protection change call actually succeeded. Additionally, the module reference count is increased prior to working with it when attempting the patch, in order to prevent other threads from successfully unloading it. The proposed changes should harden the code against unexpected behavior and should address the crashes experienced when the code runs in other processes, including Firefox. --- libs/libvalinet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/libvalinet b/libs/libvalinet index 15ad6ce..f0b704f 160000 --- a/libs/libvalinet +++ b/libs/libvalinet @@ -1 +1 @@ -Subproject commit 15ad6ceb685c54de7ebb77f115eabbf88caebf33 +Subproject commit f0b704fb585aff54692fda6a7d1edcef3fa3e27b From d262c41850d535551af8442483f7f84fd08da3d6 Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Thu, 17 Nov 2022 01:32:06 +0200 Subject: [PATCH 04/10] Version: 22621.608.51.6 --- CHANGELOG.md | 4 ++++ version.h | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99f0e98..6f085d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,10 @@ Please make sure you are connected to the Internet while installing, the applica * Windows 11 Start menu: Fixed a bug that prevented the menu from taking into account the "Layout" setting from Windows Settings - Personalization - Taskbar on 22621-based builds. (2572a80) +##### 6 + +* Fixed a bug that could cause the host process of ExplorerPatcher to crash under certain circumstances. (d7a0385) + ## 22622.450.50 Tested on OS build 22622.450. diff --git a/version.h b/version.h index 83014ec..2be8264 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ #define VER_MAJOR 22621 #define VER_MINOR 608 #define VER_BUILD_HI 51 -#define VER_BUILD_LO 5 +#define VER_BUILD_LO 6 #define VER_FLAGS VS_FF_PRERELEASE @@ -12,5 +12,5 @@ #define VER_STR(arg) #arg // The String form of the version numbers -#define VER_FILE_STRING VALUE "FileVersion", "22621.608.51.5" -#define VER_PRODUCT_STRING VALUE "ProductVersion", "22621.608.51.5" +#define VER_FILE_STRING VALUE "FileVersion", "22621.608.51.6" +#define VER_PRODUCT_STRING VALUE "ProductVersion", "22621.608.51.6" From 4212e357b7298a6cb21cd108abaf0fb9364dfb44 Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Thu, 17 Nov 2022 02:51:32 +0200 Subject: [PATCH 05/10] Start11: Center menu on screen also works when taskbar is not at the bottom --- ExplorerPatcher/dllmain.c | 48 ++++++++++++++++++++------------------ ExplorerPatcher/lvt.c | 49 ++++++++++++++++++++++++++++++++++++++- ExplorerPatcher/lvt.h | 2 +- 3 files changed, 74 insertions(+), 25 deletions(-) diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 7580d88..6b87447 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -10994,6 +10994,7 @@ void StartMenu_LoadSettings(BOOL bRestartIfChanged) if (InterlockedExchange64(&dwTaskbarAl, dwVal) != dwVal) { StartUI_EnableRoundedCornersApply = TRUE; + StartDocked_DisableRecommendedSectionApply = TRUE; } RegCloseKey(hKey); @@ -11259,7 +11260,7 @@ LSTATUS StartUI_RegCloseKey(HKEY hKey) return RegCloseKey(hKey); } -int StartUI_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw) +int Start_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw) { WCHAR wszDebug[MAX_PATH]; BOOL bIsWindowVisible = FALSE; @@ -11268,7 +11269,7 @@ int StartUI_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw) { if (IsWindows11()) ShowWindow(hWnd, bIsWindowVisible ? SW_SHOW : SW_HIDE); DWORD TaskbarAl = InterlockedAdd(&dwTaskbarAl, 0); - if (bIsWindowVisible && (!TaskbarAl ? StartUI_EnableRoundedCornersApply : 1)) + if (bIsWindowVisible && (!TaskbarAl ? (dwStartShowClassicMode ? StartUI_EnableRoundedCornersApply : StartDocked_DisableRecommendedSectionApply) : 1)) { HWND hWndTaskbar = NULL; if (TaskbarAl) @@ -11335,16 +11336,32 @@ int StartUI_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw) } } RECT rc; - LVT_StartUI_EnableRoundedCorners(hWnd, StartUI_EnableRoundedCorners, dwPos, hWndTaskbar, &rc); - if (!StartUI_EnableRoundedCorners) + if (dwStartShowClassicMode) { - StartUI_EnableRoundedCornersApply = FALSE; + LVT_StartUI_EnableRoundedCorners(hWnd, StartUI_EnableRoundedCorners, dwPos, hWndTaskbar, &rc); + if (!StartUI_EnableRoundedCorners) + { + StartUI_EnableRoundedCornersApply = FALSE; + } + } + else + { + LVT_StartDocked_DisableRecommendedSection(hWnd, StartDocked_DisableRecommendedSection, &rc); + StartDocked_DisableRecommendedSectionApply = FALSE; } if (hWndTaskbar) { if (rcC.left < 5 && rcC.top > 5) { - SetWindowPos(hWnd, NULL, mi.rcMonitor.left + (((mi.rcMonitor.right - mi.rcMonitor.left) - (rc.right - rc.left)) / 2), mi.rcMonitor.top, 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS); + if (dwStartShowClassicMode) + { + SetWindowPos(hWnd, NULL, mi.rcMonitor.left + (((mi.rcMonitor.right - mi.rcMonitor.left) - (rc.right - rc.left)) / 2), mi.rcMonitor.top, 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS); + } + else + { + // Windows 11 Start menu knows how to center itself when the taskbar is at the bottom of the screen + SetWindowPos(hWnd, NULL, mi.rcMonitor.left, mi.rcMonitor.top, 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS); + } } else if (rcC.left < 5 && rcC.top < 5 && rcC.right > rcC.bottom) { @@ -11368,21 +11385,6 @@ int StartUI_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw) return SetWindowRgn(hWnd, hRgn, bRedraw); } -int StartDocked_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw) -{ - BOOL bIsWindowVisible = FALSE; - HRESULT hr = IsThreadCoreWindowVisible(&bIsWindowVisible); - if (SUCCEEDED(hr)) - { - if (bIsWindowVisible && StartUI_EnableRoundedCornersApply) - { - LVT_StartDocked_DisableRecommendedSection(hWnd, StartDocked_DisableRecommendedSection); - StartDocked_DisableRecommendedSectionApply = FALSE; - } - } - return SetWindowRgn(hWnd, hRgn, bRedraw); -} - int WINAPI SetupMessage(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType) { return 0; @@ -11810,7 +11812,7 @@ void InjectStartMenu() hStartUI = GetModuleHandleW(L"StartUI.dll"); // Fixes hang when Start menu closes - VnPatchDelayIAT(hStartUI, "ext-ms-win-ntuser-draw-l1-1-0.dll", "SetWindowRgn", StartUI_SetWindowRgn); + VnPatchDelayIAT(hStartUI, "ext-ms-win-ntuser-draw-l1-1-0.dll", "SetWindowRgn", Start_SetWindowRgn); if (IsWindows11()) { @@ -11840,7 +11842,7 @@ void InjectStartMenu() LoadLibraryW(L"StartDocked.dll"); hStartDocked = GetModuleHandleW(L"StartDocked.dll"); - VnPatchDelayIAT(hStartDocked, "ext-ms-win-ntuser-draw-l1-1-0.dll", "SetWindowRgn", StartDocked_SetWindowRgn); + VnPatchDelayIAT(hStartDocked, "ext-ms-win-ntuser-draw-l1-1-0.dll", "SetWindowRgn", Start_SetWindowRgn); } Setting* settings = calloc(6, sizeof(Setting)); diff --git a/ExplorerPatcher/lvt.c b/ExplorerPatcher/lvt.c index 36b8d37..ecf2072 100644 --- a/ExplorerPatcher/lvt.c +++ b/ExplorerPatcher/lvt.c @@ -518,12 +518,25 @@ void LVT_StartUI_EnableRoundedCorners(HWND hWnd, DWORD dwReceipe, DWORD dwPos, H } // Reference: https://www.reddit.com/r/Windows11/comments/p1ksou/this_is_not_a_concept_microsoft_in_windows_11/ -void LVT_StartDocked_DisableRecommendedSection(HWND hWnd, BOOL bApply) +void LVT_StartDocked_DisableRecommendedSection(HWND hWnd, BOOL bApply, RECT* rect) { WCHAR wszDebug[MAX_PATH]; HRESULT hr = S_OK; Windows_UI_Xaml_IDependencyObject* pRootDependencyObject = NULL; + Windows_UI_Xaml_Controls_ICanvasStatics* pCanvasStatics = NULL; + + if (SUCCEEDED(hr)) + { + HSTRING_HEADER hshControlsCanvasStatics; + HSTRING hsControlsCanvasStatics = NULL; + hr = WindowsCreateStringReference(L"Windows.UI.Xaml.Controls.Canvas", 31, &hshControlsCanvasStatics, &hsControlsCanvasStatics); + if (SUCCEEDED(hr) && hsControlsCanvasStatics) + { + hr = RoGetActivationFactory(hsControlsCanvasStatics, &IID_Windows_UI_Xaml_Controls_ICanvasStatics, &pCanvasStatics); + WindowsDeleteString(hsControlsCanvasStatics); + } + } if (SUCCEEDED(hr)) { @@ -570,6 +583,35 @@ void LVT_StartDocked_DisableRecommendedSection(HWND hWnd, BOOL bApply) Windows_UI_Xaml_IDependencyObject* pStartSizingFrame = LVT_FindChildByClassName(pRootDependencyObject, pVisualTreeHelperStatics, L"StartDocked.StartSizingFrame", NULL); if (pStartSizingFrame) { + Windows_UI_Xaml_Thickness drc; + drc.Left = 0.0; drc.Right = 0.0; drc.Top = 0.0; drc.Bottom = 0.0; + Windows_UI_Xaml_IUIElement* pIUIElement = NULL; + Windows_UI_Xaml_IFrameworkElement* pFrameworkElement = NULL; + pStartSizingFrame->lpVtbl->QueryInterface(pStartSizingFrame, &IID_Windows_UI_Xaml_IUIElement, &pIUIElement); + if (pIUIElement) + { + pCanvasStatics->lpVtbl->GetLeft(pCanvasStatics, pIUIElement, &(drc.Left)); + pCanvasStatics->lpVtbl->GetTop(pCanvasStatics, pIUIElement, &(drc.Top)); + } + pStartSizingFrame->lpVtbl->QueryInterface(pStartSizingFrame, &IID_Windows_UI_Xaml_IFrameworkElement, &pFrameworkElement); + if (pFrameworkElement) + { + pFrameworkElement->lpVtbl->get_ActualWidth(pFrameworkElement, &(drc.Right)); + pFrameworkElement->lpVtbl->get_ActualHeight(pFrameworkElement, &(drc.Bottom)); + } + UINT dpi = GetDpiForWindow(hWnd); + RECT rc; + SetRect(&rc, drc.Left, drc.Top, drc.Right, drc.Bottom); + SetRect(&rc, MulDiv(rc.left, dpi, 96), MulDiv(rc.top, dpi, 96), MulDiv(rc.right, dpi, 96), MulDiv(rc.bottom, dpi, 96)); + *rect = rc; + if (pFrameworkElement) + { + pFrameworkElement->lpVtbl->Release(pFrameworkElement); + } + if (pIUIElement) + { + pIUIElement->lpVtbl->Release(pIUIElement); + } Windows_UI_Xaml_IDependencyObject* pStartSizingFramePanel = LVT_FindChildByClassName(pStartSizingFrame, pVisualTreeHelperStatics, L"StartDocked.StartSizingFramePanel", NULL); if (pStartSizingFramePanel) { @@ -698,6 +740,11 @@ void LVT_StartDocked_DisableRecommendedSection(HWND hWnd, BOOL bApply) } pRootDependencyObject->lpVtbl->Release(pRootDependencyObject); } + + if (pCanvasStatics) + { + pCanvasStatics->lpVtbl->Release(pCanvasStatics); + } } HRESULT IsThreadCoreWindowVisible(BOOL* bIsVisible) diff --git a/ExplorerPatcher/lvt.h b/ExplorerPatcher/lvt.h index 8815d63..fc1a2f0 100644 --- a/ExplorerPatcher/lvt.h +++ b/ExplorerPatcher/lvt.h @@ -1024,7 +1024,7 @@ Windows_UI_Xaml_IDependencyObject* LVT_FindChildByName(Windows_UI_Xaml_IDependen void LVT_StartUI_EnableRoundedCorners(HWND, DWORD, DWORD, HWND, RECT*); -void LVT_StartDocked_DisableRecommendedSection(HWND, BOOL); +void LVT_StartDocked_DisableRecommendedSection(HWND, BOOL, RECT*); HRESULT IsThreadCoreWindowVisible(BOOL*); #endif From 53fad19901958a7781db62d3e4d24f482966d263 Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Thu, 17 Nov 2022 02:52:31 +0200 Subject: [PATCH 06/10] Start: Better way to determine the monitor on which the Start menu will open --- ExplorerPatcher/StartMenu.c | 23 ---------------------- ExplorerPatcher/dllmain.c | 39 +++++++++++++++++++++++++++++++++++-- ExplorerPatcher/utility.c | 16 +++++++++++++++ ExplorerPatcher/utility.h | 9 +++++++++ 4 files changed, 62 insertions(+), 25 deletions(-) diff --git a/ExplorerPatcher/StartMenu.c b/ExplorerPatcher/StartMenu.c index dbd391a..9063d64 100644 --- a/ExplorerPatcher/StartMenu.c +++ b/ExplorerPatcher/StartMenu.c @@ -66,29 +66,6 @@ void OpenStartOnMonitor(HMONITOR monitor) } } -typedef struct _MonitorOverrideData -{ - DWORD cbIndex; - DWORD dwIndex; - HMONITOR hMonitor; -} MonitorOverrideData; - -BOOL ExtractMonitorByIndex(HMONITOR hMonitor, HDC hDC, LPRECT lpRect, MonitorOverrideData* mod) -{ - POINT pt; pt.x = 0; pt.y = 0; - if (MonitorFromPoint(pt, MONITOR_DEFAULTTONULL) == hMonitor) - { - return TRUE; - } - if (mod->cbIndex == mod->dwIndex) - { - mod->hMonitor = hMonitor; - return FALSE; - } - mod->cbIndex++; - return TRUE; -} - LRESULT CALLBACK OpenStartOnCurentMonitorThreadHook( int code, WPARAM wParam, diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 6b87447..a2e89a7 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -10861,6 +10861,15 @@ void StartMenu_LoadSettings(BOOL bRestartIfChanged) &StartMenu_ShowAllApps, &dwSize ); + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("MonitorOverride"), + 0, + NULL, + &bMonitorOverride, + &dwSize + ); RegCloseKey(hKey); } RegCreateKeyExW( @@ -11274,10 +11283,36 @@ int Start_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw) HWND hWndTaskbar = NULL; if (TaskbarAl) { + HMONITOR hMonitorOfStartMenu = NULL; + if (bMonitorOverride == 1 || !bMonitorOverride) { + POINT pt; + if (!bMonitorOverride) GetCursorPos(&pt); + else { + pt.x = 0; pt.y = 0; + } + hMonitorOfStartMenu = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY); + } + else { + MonitorOverrideData mod; + mod.cbIndex = 2; + mod.dwIndex = bMonitorOverride; + mod.hMonitor = NULL; + EnumDisplayMonitors(NULL, NULL, ExtractMonitorByIndex, &mod); + if (mod.hMonitor == NULL) + { + POINT pt; pt.x = 0; pt.y = 0; + hMonitorOfStartMenu = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY); + } + else + { + hMonitorOfStartMenu = mod.hMonitor; + } + } + HWND hWndTemp = NULL; HWND hShellTray_Wnd = FindWindowExW(NULL, NULL, L"Shell_TrayWnd", NULL); - if (hShellTray_Wnd && !hWndTaskbar && MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY) == MonitorFromWindow(hShellTray_Wnd, MONITOR_DEFAULTTOPRIMARY) && dwOldTaskbarAl) + if (hShellTray_Wnd && !hWndTaskbar && hMonitorOfStartMenu == MonitorFromWindow(hShellTray_Wnd, MONITOR_DEFAULTTOPRIMARY) && dwOldTaskbarAl) { hWndTaskbar = hShellTray_Wnd; } @@ -11292,7 +11327,7 @@ int Start_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw) L"Shell_SecondaryTrayWnd", NULL ); - if (hWndTemp && !hWndTaskbar && MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY) == MonitorFromWindow(hWndTemp, MONITOR_DEFAULTTOPRIMARY) && dwMMOldTaskbarAl) + if (hWndTemp && !hWndTaskbar && hMonitorOfStartMenu == MonitorFromWindow(hWndTemp, MONITOR_DEFAULTTOPRIMARY) && dwMMOldTaskbarAl) { hWndTaskbar = hWndTemp; break; diff --git a/ExplorerPatcher/utility.c b/ExplorerPatcher/utility.c index d0eaae5..4ab453a 100644 --- a/ExplorerPatcher/utility.c +++ b/ExplorerPatcher/utility.c @@ -1625,3 +1625,19 @@ void SpotlightHelper(DWORD dwOp, HWND hWnd, HMENU hMenu, LPPOINT pPt) CoTaskMemFree(pidl); } } + +BOOL ExtractMonitorByIndex(HMONITOR hMonitor, HDC hDC, LPRECT lpRect, MonitorOverrideData* mod) +{ + POINT pt; pt.x = 0; pt.y = 0; + if (MonitorFromPoint(pt, MONITOR_DEFAULTTONULL) == hMonitor) + { + return TRUE; + } + if (mod->cbIndex == mod->dwIndex) + { + mod->hMonitor = hMonitor; + return FALSE; + } + mod->cbIndex++; + return TRUE; +} \ No newline at end of file diff --git a/ExplorerPatcher/utility.h b/ExplorerPatcher/utility.h index 61db46a..1b6c7e9 100644 --- a/ExplorerPatcher/utility.h +++ b/ExplorerPatcher/utility.h @@ -584,4 +584,13 @@ BOOL DoesOSBuildSupportSpotlight(); BOOL IsSpotlightEnabled(); void SpotlightHelper(DWORD dwOp, HWND hWnd, HMENU hMenu, LPPOINT pPt); + +typedef struct _MonitorOverrideData +{ + DWORD cbIndex; + DWORD dwIndex; + HMONITOR hMonitor; +} MonitorOverrideData; + +BOOL ExtractMonitorByIndex(HMONITOR hMonitor, HDC hDC, LPRECT lpRect, MonitorOverrideData* mod); #endif From 451db3c5b65bec09a288084bb8056fbb0ae2a446 Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Thu, 17 Nov 2022 03:13:27 +0200 Subject: [PATCH 07/10] Taskbar11: Option to use the stock taskbar context menu --- ExplorerPatcher/dllmain.c | 3 ++- ExplorerPatcher/settings.reg | 2 +- ExplorerPatcher/settings10.reg | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index a2e89a7..f1647f5 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -2349,7 +2349,8 @@ LRESULT CALLBACK Shell_TrayWndMouseProc( _In_ LPARAM lParam ) { - if (!bOldTaskbar && + if (!bOldTaskbar && + !bNoPropertiesInContextMenu && nCode == HC_ACTION && wParam == WM_RBUTTONUP && IsPointOnEmptyAreaOfNewTaskbar(((MOUSEHOOKSTRUCT*)lParam)->pt) diff --git a/ExplorerPatcher/settings.reg b/ExplorerPatcher/settings.reg index 1425538..eba4489 100644 --- a/ExplorerPatcher/settings.reg +++ b/ExplorerPatcher/settings.reg @@ -725,7 +725,7 @@ ;d Enable SysListView32 for Explorer views * @="" [HKEY_CURRENT_USER\Software\ExplorerPatcher] -;b Hide the program settings item ("Properties") from the taskbar context menu +;b Do not change the taskbar context menu (e.g. do not display the "Properties" item) "NoPropertiesInContextMenu"=dword:00000000 ;b Enable symbols download * "EnableSymbolDownload"=dword:00000001 diff --git a/ExplorerPatcher/settings10.reg b/ExplorerPatcher/settings10.reg index a7788a7..323ca81 100644 --- a/ExplorerPatcher/settings10.reg +++ b/ExplorerPatcher/settings10.reg @@ -560,7 +560,7 @@ ;d Enable SysListView32 for Explorer views * @="" [HKEY_CURRENT_USER\Software\ExplorerPatcher] -;b Hide the program settings item ("Properties") from the taskbar context menu +;b Do not change the taskbar context menu (e.g. do not display the "Properties" item) "NoPropertiesInContextMenu"=dword:00000000 ;b Enable symbols download * "EnableSymbolDownload"=dword:00000001 From 02cb6e900cd75cdc4d702d23f882944804f41f11 Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Thu, 17 Nov 2022 03:18:41 +0200 Subject: [PATCH 08/10] Version: 22621.819.52.1 --- CHANGELOG.md | 14 ++++++++++++++ version.h | 10 +++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f085d9..1eb55f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,20 @@ This document includes the same release notes as in the [Releases](https://github.com/valinet/ExplorerPatcher/releases) section on GitHub. +## 22621.819.52 + +Tested on OS builds 22621.819 and 22000.1098. + +Please make sure you are connected to the Internet while installing, the application might need to perform one-time downloads for several resources in order to enable full functionality. + +#### Details + +##### 1 + +* Windows 11 Start menu: Implemented centering on screen when taskbar is not at the bottom. (4212e35) +* Windows 11 taskbar: Option to use the stock taskbar context menu. (451db3c) +* Fixed a bug that could display the Start menu on a wrong monitor or outside the screen when the taskbar was moved to the top of the screen and the previous setting was at the right edge of the screen. (53fad19) + ## 22621.608.51 Tested on OS builds 22621.608 and 22000.1042. diff --git a/version.h b/version.h index 2be8264..024c8e2 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ #define VER_MAJOR 22621 -#define VER_MINOR 608 -#define VER_BUILD_HI 51 -#define VER_BUILD_LO 6 +#define VER_MINOR 819 +#define VER_BUILD_HI 52 +#define VER_BUILD_LO 1 #define VER_FLAGS VS_FF_PRERELEASE @@ -12,5 +12,5 @@ #define VER_STR(arg) #arg // The String form of the version numbers -#define VER_FILE_STRING VALUE "FileVersion", "22621.608.51.6" -#define VER_PRODUCT_STRING VALUE "ProductVersion", "22621.608.51.6" +#define VER_FILE_STRING VALUE "FileVersion", "22621.819.52.1" +#define VER_PRODUCT_STRING VALUE "ProductVersion", "22621.819.52.1" From 9f9d43e103216da8fad3d086c218978eee5f8429 Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Thu, 17 Nov 2022 16:05:23 +0200 Subject: [PATCH 09/10] Start11: Fix "Disable recommended section" to work at 125% display scaling --- ExplorerPatcher/lvt.c | 87 +++++++++++++++++++++++++++++++++++++++++++ ExplorerPatcher/lvt.h | 7 +++- 2 files changed, 92 insertions(+), 2 deletions(-) diff --git a/ExplorerPatcher/lvt.c b/ExplorerPatcher/lvt.c index ecf2072..4b4aae5 100644 --- a/ExplorerPatcher/lvt.c +++ b/ExplorerPatcher/lvt.c @@ -517,6 +517,79 @@ void LVT_StartUI_EnableRoundedCorners(HWND hWnd, DWORD dwReceipe, DWORD dwPos, H } } +void LVT_StartDocked_120DPIHack(int maxHeight) +{ + HRESULT hr = S_OK; + Windows_UI_Xaml_IDependencyObject* pRootDependencyObject = NULL; + if (SUCCEEDED(hr)) + { + HSTRING_HEADER hshWindowStatics; + HSTRING hsWindowStatics = NULL; + hr = WindowsCreateStringReference(L"Windows.UI.Xaml.Window", 22, &hshWindowStatics, &hsWindowStatics); + if (SUCCEEDED(hr) && hsWindowStatics) + { + Windows_UI_Xaml_IWindowStatics* pWindowStatics = NULL; + hr = RoGetActivationFactory(hsWindowStatics, &IID_Windows_UI_Xaml_IWindowStatics, &pWindowStatics); + if (SUCCEEDED(hr)) + { + Windows_UI_Xaml_IWindow* pWindow = NULL; + hr = pWindowStatics->lpVtbl->get_Current(pWindowStatics, &pWindow); + if (SUCCEEDED(hr)) + { + IInspectable* pUIElement = NULL; + hr = pWindow->lpVtbl->get_Content(pWindow, &pUIElement); + if (SUCCEEDED(hr)) + { + hr = pUIElement->lpVtbl->QueryInterface(pUIElement, &IID_Windows_UI_Xaml_IDependencyObject, &pRootDependencyObject); + + pUIElement->lpVtbl->Release(pUIElement); + } + pWindow->lpVtbl->Release(pWindow); + } + pWindowStatics->lpVtbl->Release(pWindowStatics); + } + WindowsDeleteString(hsWindowStatics); + } + } + if (pRootDependencyObject) + { + HSTRING_HEADER hshVisualTreeHelperStatics; + HSTRING hsVisualTreeHelperStatics = NULL; + hr = WindowsCreateStringReference(L"Windows.UI.Xaml.Media.VisualTreeHelper", 38, &hshVisualTreeHelperStatics, &hsVisualTreeHelperStatics); + if (SUCCEEDED(hr) && hsVisualTreeHelperStatics) + { + Windows_UI_Xaml_IVisualTreeHelperStatics* pVisualTreeHelperStatics = NULL; + hr = RoGetActivationFactory(hsVisualTreeHelperStatics, &IID_Windows_UI_Xaml_IVisualTreeHelperStatics, &pVisualTreeHelperStatics); + if (SUCCEEDED(hr)) + { + Windows_UI_Xaml_IDependencyObject* pStartSizingFrame = LVT_FindChildByClassName(pRootDependencyObject, pVisualTreeHelperStatics, L"StartDocked.StartSizingFrame", NULL); + if (pStartSizingFrame) + { + Windows_UI_Xaml_IUIElement* pIUIElement = NULL; + pStartSizingFrame->lpVtbl->QueryInterface(pStartSizingFrame, &IID_Windows_UI_Xaml_IUIElement, &pIUIElement); + if (pIUIElement) + { + Windows_UI_Xaml_IFrameworkElement* pFrameworkElement = NULL; + pStartSizingFrame->lpVtbl->QueryInterface(pStartSizingFrame, &IID_Windows_UI_Xaml_IFrameworkElement, &pFrameworkElement); + if (pFrameworkElement) + { + pIUIElement->lpVtbl->put_Visibility(pIUIElement, Windows_UI_Xaml_Visibility_Collapsed); + pFrameworkElement->lpVtbl->put_MaxHeight(pFrameworkElement, maxHeight); + pIUIElement->lpVtbl->put_Visibility(pIUIElement, Windows_UI_Xaml_Visibility_Visible); + pFrameworkElement->lpVtbl->Release(pFrameworkElement); + } + pIUIElement->lpVtbl->Release(pIUIElement); + } + pStartSizingFrame->lpVtbl->Release(pStartSizingFrame); + } + pVisualTreeHelperStatics->lpVtbl->Release(pVisualTreeHelperStatics); + } + WindowsDeleteString(hsVisualTreeHelperStatics); + } + pRootDependencyObject->lpVtbl->Release(pRootDependencyObject); + } +} + // Reference: https://www.reddit.com/r/Windows11/comments/p1ksou/this_is_not_a_concept_microsoft_in_windows_11/ void LVT_StartDocked_DisableRecommendedSection(HWND hWnd, BOOL bApply, RECT* rect) { @@ -604,6 +677,20 @@ void LVT_StartDocked_DisableRecommendedSection(HWND hWnd, BOOL bApply, RECT* rec SetRect(&rc, drc.Left, drc.Top, drc.Right, drc.Bottom); SetRect(&rc, MulDiv(rc.left, dpi, 96), MulDiv(rc.top, dpi, 96), MulDiv(rc.right, dpi, 96), MulDiv(rc.bottom, dpi, 96)); *rect = rc; + if (bApply && dpi == 120) + { + HANDLE hRealThreadHandle = NULL; + DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hRealThreadHandle, THREAD_SET_CONTEXT, FALSE, 0); + if (hRealThreadHandle) + { + QueueUserAPC(LVT_StartDocked_120DPIHack, hRealThreadHandle, 826); + CloseHandle(hRealThreadHandle); + } + } + else if (pFrameworkElement) + { + pFrameworkElement->lpVtbl->put_MaxHeight(pFrameworkElement, 726.0); + } if (pFrameworkElement) { pFrameworkElement->lpVtbl->Release(pFrameworkElement); diff --git a/ExplorerPatcher/lvt.h b/ExplorerPatcher/lvt.h index fc1a2f0..49691b6 100644 --- a/ExplorerPatcher/lvt.h +++ b/ExplorerPatcher/lvt.h @@ -6,6 +6,7 @@ #include #include #include +#include #define LVT_LOC_NONE 0 #define LVT_LOC_BOTTOMLEFT 1 @@ -460,10 +461,12 @@ typedef struct Windows_UI_Xaml_IFrameworkElement_Vtbl __RPC__in Windows_UI_Xaml_IFrameworkElement* This); HRESULT(STDMETHODCALLTYPE* get_MaxHeight)( - __RPC__in Windows_UI_Xaml_IFrameworkElement* This); + __RPC__in Windows_UI_Xaml_IFrameworkElement* This, + /* [out] */ __RPC__out DOUBLE* value); HRESULT(STDMETHODCALLTYPE* put_MaxHeight)( - __RPC__in Windows_UI_Xaml_IFrameworkElement* This); + __RPC__in Windows_UI_Xaml_IFrameworkElement* This, + /* [in] */ __RPC__in DOUBLE value); HRESULT(STDMETHODCALLTYPE* get_HorizontalAlignment)( __RPC__in Windows_UI_Xaml_IFrameworkElement* This); From 7c4567ac799ceaed8fbb582d1e232dfacfa3c354 Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Thu, 17 Nov 2022 16:09:16 +0200 Subject: [PATCH 10/10] Version: 22621.819.52.2 --- CHANGELOG.md | 4 ++++ version.h | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1eb55f6..9c99452 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ Please make sure you are connected to the Internet while installing, the applica * Windows 11 taskbar: Option to use the stock taskbar context menu. (451db3c) * Fixed a bug that could display the Start menu on a wrong monitor or outside the screen when the taskbar was moved to the top of the screen and the previous setting was at the right edge of the screen. (53fad19) +##### 2 + +* Windows 11 Start menu: Fixed a bug that prevented the disable "Recommended" section feature from working when the scaling level of the screen the Start menu is displayed on is set to 125% (120 DPI). (9f9d43e) + ## 22621.608.51 Tested on OS builds 22621.608 and 22000.1042. diff --git a/version.h b/version.h index 024c8e2..2b5d1f6 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ #define VER_MAJOR 22621 #define VER_MINOR 819 #define VER_BUILD_HI 52 -#define VER_BUILD_LO 1 +#define VER_BUILD_LO 2 #define VER_FLAGS VS_FF_PRERELEASE @@ -12,5 +12,5 @@ #define VER_STR(arg) #arg // The String form of the version numbers -#define VER_FILE_STRING VALUE "FileVersion", "22621.819.52.1" -#define VER_PRODUCT_STRING VALUE "ProductVersion", "22621.819.52.1" +#define VER_FILE_STRING VALUE "FileVersion", "22621.819.52.2" +#define VER_PRODUCT_STRING VALUE "ProductVersion", "22621.819.52.2"