From ac268b1acbfb3833a5ace7ff5f8e7787c28ff255 Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Fri, 27 Oct 2023 02:08:05 +0700 Subject: [PATCH] Taskbar10: Partially fixed Windows 11 Start menu and Search positioning on builds 23545+ (Dev) --- CHANGELOG.md | 1 + ExplorerPatcher/StartMenu.c | 38 ++++++++++++++++++++++++++++++------- ExplorerPatcher/StartMenu.h | 31 +++++++++++++++++++++++------- 3 files changed, 56 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3836c2687..ea043aff7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ Note: After updating to this version, the symbols will be re-downloaded even if * 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. (11160c8) * Symbols: Reworked how symbols are managed so that symbols don't need to be successfully downloaded in succession. (8412bd6) +* Setup: Fixed uninstallation of EP installations that have went through upgrades before the proper Pin to Start fix. (845d2b5, a7c87ce) ## 22621.2361.58 diff --git a/ExplorerPatcher/StartMenu.c b/ExplorerPatcher/StartMenu.c index a0f16912a..2e4597f5e 100644 --- a/ExplorerPatcher/StartMenu.c +++ b/ExplorerPatcher/StartMenu.c @@ -677,6 +677,7 @@ BOOL NeedsRo_PositionStartMenuForMonitor( //hr = (*(HRESULT(**)(INT64, INT64*))(*(INT64*)pTaskbarLayoutFactory + 48))(pTaskbarLayoutFactory, &v12); hr = pTaskbarLayoutFactory->lpVtbl->get_Current(pTaskbarLayoutFactory, &pTaskbarLayout); } + int interfaceVersion = 1; if (SUCCEEDED(hr)) { /*hr = (**(HRESULT(***)(INT64, GUID*, INT64*))v12)( @@ -689,6 +690,15 @@ BOOL NeedsRo_PositionStartMenuForMonitor( &IID_WindowsUdk_UI_Shell_ITaskbarLayoutManager, &pTaskbarLayoutManager ); + if (hr == E_NOINTERFACE) + { + interfaceVersion = 2; + hr = pTaskbarLayout->lpVtbl->QueryInterface( + pTaskbarLayout, + &IID_WindowsUdk_UI_Shell_ITaskbarLayoutManager2, + &pTaskbarLayoutManager + ); + } } if (SUCCEEDED(hr)) { @@ -714,12 +724,26 @@ BOOL NeedsRo_PositionStartMenuForMonitor( if (data->operation == STARTMENU_POSITIONING_OPERATION_ADD) { - hr = pTaskbarLayoutManager->lpVtbl->ReportMonitorAdded( - pTaskbarLayoutManager, - hMonitor, - &instanceof_WindowsUdk_UI_Shell_ITaskbarSettings, - NULL - ); + if (interfaceVersion == 1) + { + hr = pTaskbarLayoutManager->lpVtbl->ReportMonitorAdded( + pTaskbarLayoutManager, + hMonitor, + &instanceof_WindowsUdk_UI_Shell_ITaskbarSettings, + NULL + ); + } + else + { + unsigned __int64 result = 0; + hr = pTaskbarLayoutManager->lpVtbl->ReportMonitorAdded2( + pTaskbarLayoutManager, + hMonitor, + &instanceof_WindowsUdk_UI_Shell_ITaskbarSettings, + NULL, + &result + ); + } data->pMonitorList[InterlockedIncrement(data->pMonitorCount) - 1] = hMonitor; printf("[Positioning] Added settings for monitor %p : %d\n", hMonitor, data->location); } @@ -729,7 +753,7 @@ BOOL NeedsRo_PositionStartMenuForMonitor( pTaskbarLayoutManager, hMonitor, &instanceof_WindowsUdk_UI_Shell_ITaskbarSettings - ); + ); // TODO Doesn't work when the 2nd interface is used. Needs further investigation printf("[Positioning] Changed settings for monitor: %p : %d\n", hMonitor, data->location); } else if (data->operation == STARTMENU_POSITIONING_OPERATION_REMOVE) diff --git a/ExplorerPatcher/StartMenu.h b/ExplorerPatcher/StartMenu.h index 87869f36c..8ecbe807f 100644 --- a/ExplorerPatcher/StartMenu.h +++ b/ExplorerPatcher/StartMenu.h @@ -291,9 +291,16 @@ interface WindowsUdk_UI_Shell_TaskbarLayoutStatics // : IInspectable }; DEFINE_GUID(IID_WindowsUdk_UI_Shell_ITaskbarLayoutManager, - 0x4FB10D7C4, + 0xFB10D7C4, 0x4F7F, 0x5DE5, 0xA5, 0x28, - 0x7e, 0xfe, 0xf4, 0x18, 0xaa, 0x48 + 0x7E, 0xFE, 0xF4, 0x18, 0xAA, 0x48 +); + +// Used in 23545+ (or maybe couple lower builds too). Still named ITaskbarLayoutManager but has different ReportMonitorAdded signature. +DEFINE_GUID(IID_WindowsUdk_UI_Shell_ITaskbarLayoutManager2, + 0x98F82ED2, + 0x4791, 0x58A0, 0x8D, 0x2F, + 0xDA, 0xBD, 0x7A, 0x2F, 0x18, 0x9F ); typedef struct WindowsUdk_UI_Shell_TaskbarLayoutManagerVtbl // : IInspectableVtbl @@ -325,11 +332,21 @@ typedef struct WindowsUdk_UI_Shell_TaskbarLayoutManagerVtbl // : IInspectableVtb __RPC__in WindowsUdk_UI_Shell_TaskbarLayoutManager* This, /* [out] */ __RPC__out TrustLevel* trustLevel); - HRESULT(STDMETHODCALLTYPE* ReportMonitorAdded)( - __RPC__in WindowsUdk_UI_Shell_TaskbarLayoutManager* This, - __RPC__in HMONITOR hMonitor, - __RPC__in void* _instance_of_winrt_WindowsUdk_UI_Shell_ITaskbarSettings, - __RPC__in LPRECT _unknown_lpGeometry); + union + { + HRESULT(STDMETHODCALLTYPE* ReportMonitorAdded)( + __RPC__in WindowsUdk_UI_Shell_TaskbarLayoutManager* This, + __RPC__in HMONITOR hMonitor, + __RPC__in void* _instance_of_winrt_WindowsUdk_UI_Shell_ITaskbarSettings, + __RPC__in void* _unknown_shellViewToRectMap); + + HRESULT(STDMETHODCALLTYPE* ReportMonitorAdded2)( + __RPC__in WindowsUdk_UI_Shell_TaskbarLayoutManager* This, + __RPC__in HMONITOR hMonitor, + __RPC__in void* _instance_of_winrt_WindowsUdk_UI_Shell_ITaskbarSettings, + __RPC__in void* _unknown_shellViewToRectMap, + /* [out] */ __RPC__out unsigned __int64* result); + }; HRESULT(STDMETHODCALLTYPE* ReportMonitorRemoved)( __RPC__in WindowsUdk_UI_Shell_TaskbarLayoutManager* This,