From bc3bbc7e5e9c9965b9376bca5c810f373047ec1b Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Sun, 24 Sep 2023 05:10:10 +0700 Subject: [PATCH 1/6] Taskbar10: Fixed Windows 10 taskbar not showing up on Windows 11 builds with "Never combine" on the new taskbar --- ExplorerPatcher/dllmain.c | 58 +++++++++---- ExplorerPatcher/utility.c | 172 +++++++++++++++++++++----------------- ExplorerPatcher/utility.h | 167 ++++++++++++++++++++++++++++++++---- 3 files changed, 289 insertions(+), 108 deletions(-) diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 38afca5..e819131 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -4277,18 +4277,21 @@ INT64 winrt_Windows_Internal_Shell_implementation_MeetAndChatManager_OnMessageHo #pragma region "Enable old taskbar" #ifdef _WIN64 -DEFINE_GUID(GUID_18C02F2E_2754_5A20_8BD5_0B34CE79DA2B, - 0x18C02F2E, - 0x2754, 0x5A20, 0x8b, 0xd5, - 0x0b, 0x34, 0xce, 0x79, 0xda, 0x2b -); HRESULT explorer_RoGetActivationFactoryHook(HSTRING activatableClassId, GUID* iid, void** factory) { PCWSTR StringRawBuffer = WindowsGetStringRawBuffer(activatableClassId, 0); - if (!wcscmp(StringRawBuffer, L"WindowsUdk.ApplicationModel.AppExtensions.XamlExtensions") && IsEqualGUID(iid, &GUID_18C02F2E_2754_5A20_8BD5_0B34CE79DA2B)) + if (!wcscmp(StringRawBuffer, L"WindowsUdk.ApplicationModel.AppExtensions.XamlExtensions")) { - *factory = &XamlExtensionsFactory; - return S_OK; + if (IsEqualGUID(iid, &IID_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics)) + { + *factory = &instanceof_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics; + return S_OK; + } + if (IsEqualGUID(iid, &IID_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2)) + { + *factory = &instanceof_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2; + return S_OK; + } } return RoGetActivationFactory(activatableClassId, iid, factory); } @@ -9629,17 +9632,36 @@ struct RTL_FEATURE_CONFIGURATION { int (*RtlQueryFeatureConfigurationFunc)(UINT32 featureId, int sectionType, INT64* changeStamp, struct RTL_FEATURE_CONFIGURATION* buffer); int RtlQueryFeatureConfigurationHook(UINT32 featureId, int sectionType, INT64* changeStamp, struct RTL_FEATURE_CONFIGURATION* buffer) { int rv = RtlQueryFeatureConfigurationFunc(featureId, sectionType, changeStamp, buffer); + switch (featureId) + { #if !USE_MOMENT_3_FIXES_ON_MOMENT_2 - if (IsWindows11Version22H2Build1413OrHigher() && bOldTaskbar && featureId == 26008830) { - // Disable tablet optimized taskbar feature when using the Windows 10 taskbar - // - // For now, this fixes Task View and Win-Tab, Alt-Tab breaking after pressing Win-Tab, - // flyouts alignment, notification center alignment, Windows key shortcuts on - // OS builds 22621.1413+ - // - buffer->enabledState = FEATURE_ENABLED_STATE_DISABLED; - } + case 26008830: // STTest + { + if (bOldTaskbar) + { + // Disable tablet optimized taskbar feature when using the Windows 10 taskbar + // + // For now, this fixes Task View and Win-Tab, Alt-Tab breaking after pressing Win-Tab, + // flyouts alignment, notification center alignment, Windows key shortcuts on + // OS builds 22621.1413+ + // + buffer->enabledState = FEATURE_ENABLED_STATE_DISABLED; + } + break; + } +#endif +#if 0 + case 42952021: // CategorySpecificXamlExtensions + { + if (bOldTaskbar) + { + // Make CTray::Init() use IXamlExtensionsStatics (first version, that we can modify) + buffer->enabledState = FEATURE_ENABLED_STATE_DISABLED; + } + break; + } #endif + } return rv; } #pragma endregion @@ -10962,7 +10984,7 @@ DWORD Inject(BOOL bIsExplorer) } if (!symbols_PTRS.twinui_pcshell_PTRS[8] || symbols_PTRS.twinui_pcshell_PTRS[8] == 0xFFFFFFFF) { - // Ref: CMultitaskingViewManager::_CreateMTVHost + // Ref: CMultitaskingViewManager::_CreateMTVHost() // 4C 89 74 24 ? ? 8B ? ? 8B ? 8B D7 48 8B CE E8 ? ? ? ? 90 // ^^^^^^^ PBYTE match = FindPattern( diff --git a/ExplorerPatcher/utility.c b/ExplorerPatcher/utility.c index 4ab453a..c39cfb1 100644 --- a/ExplorerPatcher/utility.c +++ b/ExplorerPatcher/utility.c @@ -6,102 +6,124 @@ RTL_OSVERSIONINFOW global_rovi; DWORD32 global_ubr; #pragma region "Weird stuff" -INT64 STDMETHODCALLTYPE nimpl4_1(INT64 a1, DWORD* a2) +/*** +Let me explain the weird stuff. This was not documented here before so updating this was a hell of a task. + +Our target is in `CTray::Init()`. It constructs either the Windows 11 or the Windows 10 taskbar based on the result of +`winrt::WindowsUdk::ApplicationModel::AppExtensions::XamlExtensions::IsExtensionAvailable()`. We have to make the last +argument of that function be set to false, so that we'll get the Windows 10 taskbar. In order to make a patch that does +not use patterns, we hook `RoGetActivationFactory` and return a dummy object with our own specially crafted vtable. + +So the calls are as follows: + +`CTray::Init()` calls `factory_cache_entry::call()` to get an interface to +`XamlExtensions` (located in windowsudk.shellcommon.dll) through `IXamlExtensionsStatics`. First, the factory cache +system tries to retrieve its activation factory. It calls `RoGetActivationFactory` with the `IID` of +`IXamlExtensionsStatics`. Our hook makes that function return a dummy `IXamlExtensionsStatics` with our own vtable. +Despite the name, it is an activation factory. (Ref: `explorer_RoGetActivationFactoryHook()` in dllmain.c) + +Then, the cache system checks if the factory implements `IAgileObject` by calling `QueryInterface(IID_IAgileObject)` of +the factory. This will be used to determine if the factory should be cached or not. We intercept this call and do +nothing to make the process easy, so the factory will never be cached. In reality, `XamlExtensions` does not implement +`IAgileObject`. + +Then, the cache system calls the lambda that's passed into `factory_cache_entry<~>::call()` in order to retrieve an +interface that can be used. The lambda that `CTray::Init()` passes into the system, retrieves an instance of +`XamlExtensions` by calling `IXamlExtensionsStatics::Current()` of the factory using COM. Here, we intercept the call +through our custom `IXamlExtensionsStatics` vtable and return a dummy `XamlExtensions` instance with our own vtable +whose `QueryInterface()` with the IID of `IXamlExtensions2` returns a dummy `IXamlExtensions2` with our own vtable. + +On builds with the "Never combine" feature on the new taskbar, it uses `IXamlExtensionsStatics2::GetForCategory()` +instead of `IXamlExtensionsStatics::Current()`. + +Now that `CTray::Init()` has an instance of `XamlExtensions`, it calls `IXamlExtensions2::IsExtensionAvailable()`. +As the name says, if the extension (or Windows 11 taskbar) is available, `CTray::Init()` will continue to make the +Windows 11 taskbar through `CTray::InitializeTrayUIComponent()`. Otherwise, it will make the Windows 10 taskbar through +`TrayUI_CreateInstance()` that has been since ages. + +`CTray::Init()` gets that value through the `IXamlExtensions2` interface of the `XamlExtensions` instance. COM calls are +made, which are `QueryInterface(IID_IXamlExtensions2)` and `IXamlExtensions2::IsExtensionAvailable()` itself. We +intercept the former call through our custom vtable for our dummy `XamlExtensions` instance to return a dummy +`IXamlExtensions2` with our own vtable too. Then, we intercept the latter call through our custom `IXamlExtensions2` +vtable to have the last argument set to false, and now we have the good old taskbar. +***/ + +static ULONG STDMETHODCALLTYPE nimplAddRefRelease(IUnknown* This) { - *a2 = 1; - return 0; -} -INT64 STDMETHODCALLTYPE nimpl4_0(INT64 a1, DWORD* a2) -{ - *a2 = 0; - return 0; + return 1; } -__int64 STDMETHODCALLTYPE nimpl2(__int64 a1, uintptr_t* a2) -{ - __int64 v2; // rax - v2 = a1 + 8; - if (!a1) - v2 = 0i64; - - *a2 = v2; - return 0i64; -} -ULONG STDMETHODCALLTYPE nimpl3() +static HRESULT STDMETHODCALLTYPE nimplReturnHResultNotImpl(IUnknown* This) { - return 1; + return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE nimpl() + +static HRESULT STDMETHODCALLTYPE WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics_QueryInterface(WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics* This, REFIID riid, void** ppvObject) { + // Should only be called with IID_IAgileObject return E_NOTIMPL; } -HRESULT STDMETHODCALLTYPE nimpl1(__int64 a1, uintptr_t* a2, uintptr_t* a3) -{ - __int64 v4 = a1; // rcx - if (*a2 != 0x5FADCA5C34A95314i64 || a2[1] != 0xC1661118901A7CAEui64) - return E_NOTIMPL; - - *a3 = v4; +static HRESULT STDMETHODCALLTYPE WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics_Current(WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics* This, void** _instance_of_winrt_WindowsUdk_ApplicationModel_AppExtensions_XamlExtensions) +{ + *_instance_of_winrt_WindowsUdk_ApplicationModel_AppExtensions_XamlExtensions = &instanceof_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2; return S_OK; } -HRESULT STDMETHODCALLTYPE nimpl1_2(__int64 a1, uintptr_t* a2, uintptr_t* a3) -{ - __int64 v4 = a1 - sizeof(__int64); // rcx - if (*a2 != 0x5FADCA5C34A95314i64 || a2[1] != 0xC1661118901A7CAEui64) - return E_NOTIMPL; - - *a3 = v4; +static HRESULT STDMETHODCALLTYPE WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2_GetForCategory(WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2* This, HSTRING a2, void** _instance_of_winrt_WindowsUdk_ApplicationModel_AppExtensions_XamlExtensions) +{ + *_instance_of_winrt_WindowsUdk_ApplicationModel_AppExtensions_XamlExtensions = &instanceof_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2; return S_OK; } -HRESULT STDMETHODCALLTYPE nimpl1_3(__int64 a1, uintptr_t* a2, uintptr_t* a3) -{ - __int64 v4 = a1 - 2 * sizeof(__int64); // rcx - - if (*a2 != 0x5FADCA5C34A95314i64 || a2[1] != 0xC1661118901A7CAEui64) - return E_NOTIMPL; - *a3 = v4; - return S_OK; +static HRESULT STDMETHODCALLTYPE WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2_QueryInterface(WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2* This, REFIID riid, void** ppvObject) +{ + if (IsEqualIID(riid, &IID_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2)) + { + *ppvObject = &instanceof_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2; + return S_OK; + } + return E_NOTIMPL; } -__int64 STDMETHODCALLTYPE nimpl4(__int64 a1, __int64 a2, __int64 a3, BYTE* a4) + +static HRESULT STDMETHODCALLTYPE WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2_IsExtensionAvailable(WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2* This, HSTRING a2, HSTRING a3, BYTE* a4) { *a4 = 0; - return 0i64; + return S_OK; } -const IActivationFactoryVtbl _IActivationFactoryVtbl = { - .QueryInterface = nimpl1, - .AddRef = nimpl3, - .Release = nimpl3, - .GetIids = nimpl, - .GetRuntimeClassName = nimpl, - .GetTrustLevel = nimpl, - .ActivateInstance = nimpl2 -}; -const IActivationFactoryVtbl _IActivationFactoryVtbl2 = { - .QueryInterface = nimpl1_2, - .AddRef = nimpl3, - .Release = nimpl3, - .GetIids = nimpl, - .GetRuntimeClassName = nimpl, - .GetTrustLevel = nimpl, - .ActivateInstance = nimpl + +static const WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStaticsVtbl instanceof_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStaticsVtbl = { + .QueryInterface = WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics_QueryInterface, + .AddRef = nimplAddRefRelease, + .Release = nimplAddRefRelease, + .GetIids = nimplReturnHResultNotImpl, + .GetRuntimeClassName = nimplReturnHResultNotImpl, + .GetTrustLevel = nimplReturnHResultNotImpl, + .Current = WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics_Current }; -const IActivationFactoryVtbl _IActivationFactoryVtbl3 = { - .QueryInterface = nimpl1_3, - .AddRef = nimpl3, - .Release = nimpl3, - .GetIids = nimpl, - .GetRuntimeClassName = nimpl, - .GetTrustLevel = nimpl, - .ActivateInstance = nimpl4 +const WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics instanceof_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics = { &instanceof_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStaticsVtbl }; + +static const WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2Vtbl instanceof_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2Vtbl = { + .QueryInterface = WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics_QueryInterface, + .AddRef = nimplAddRefRelease, + .Release = nimplAddRefRelease, + .GetIids = nimplReturnHResultNotImpl, + .GetRuntimeClassName = nimplReturnHResultNotImpl, + .GetTrustLevel = nimplReturnHResultNotImpl, + .GetForCategory = WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2_GetForCategory }; -const IActivationFactoryAA XamlExtensionsFactory = { - .lpVtbl = &_IActivationFactoryVtbl, - .lpVtbl2 = &_IActivationFactoryVtbl2, - .lpVtbl3 = &_IActivationFactoryVtbl3 +const WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2 instanceof_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2 = { &instanceof_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2Vtbl }; + +static const WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2Vtbl instanceof_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2Vtbl = { + .QueryInterface = WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2_QueryInterface, + .AddRef = nimplAddRefRelease, + .Release = nimplAddRefRelease, + .GetIids = nimplReturnHResultNotImpl, + .GetRuntimeClassName = nimplReturnHResultNotImpl, + .GetTrustLevel = nimplReturnHResultNotImpl, + .IsExtensionAvailable = WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2_IsExtensionAvailable }; +const WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2 instanceof_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2 = { &instanceof_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2Vtbl }; #pragma endregion void printf_guid(GUID guid) @@ -1640,4 +1662,4 @@ BOOL ExtractMonitorByIndex(HMONITOR hMonitor, HDC hDC, LPRECT lpRect, MonitorOve } mod->cbIndex++; return TRUE; -} \ No newline at end of file +} diff --git a/ExplorerPatcher/utility.h b/ExplorerPatcher/utility.h index 51abe1d..6f96817 100644 --- a/ExplorerPatcher/utility.h +++ b/ExplorerPatcher/utility.h @@ -73,22 +73,159 @@ HRESULT ShellExecuteFromExplorer( void ToggleTaskbarAutohide(); #pragma region "Weird stuff" -INT64 STDMETHODCALLTYPE nimpl4_1(INT64 a1, DWORD* a2); -INT64 STDMETHODCALLTYPE nimpl4_0(INT64 a1, DWORD* a2); -__int64 STDMETHODCALLTYPE nimpl2(__int64 a1, uintptr_t* a2); -ULONG STDMETHODCALLTYPE nimpl3(); -HRESULT STDMETHODCALLTYPE nimpl(); -HRESULT STDMETHODCALLTYPE nimpl1(__int64 a1, uintptr_t* a2, uintptr_t* a3); -HRESULT STDMETHODCALLTYPE nimpl1_2(__int64 a1, uintptr_t* a2, uintptr_t* a3); -HRESULT STDMETHODCALLTYPE nimpl1_3(__int64 a1, uintptr_t* a2, uintptr_t* a3); -__int64 STDMETHODCALLTYPE nimpl4(__int64 a1, __int64 a2, __int64 a3, BYTE* a4); -typedef struct _IActivationFactoryAA +typedef interface WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics; + +DEFINE_GUID(IID_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics, + 0x18c02f2e, + 0x2754, 0x5a20, 0x8b, 0xd5, + 0x0b, 0x34, 0xce, 0x79, 0xda, 0x2b +); + +typedef struct WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStaticsVtbl // : IInspectableVtbl +{ + BEGIN_INTERFACE + + HRESULT(STDMETHODCALLTYPE* QueryInterface)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics* This, + /* [in] */ __RPC__in REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void** ppvObject); + + ULONG(STDMETHODCALLTYPE* AddRef)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics* This); + + ULONG(STDMETHODCALLTYPE* Release)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics* This); + + HRESULT(STDMETHODCALLTYPE* GetIids)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics* This, + /* [out] */ __RPC__out ULONG* iidCount, + /* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID** iids); + + HRESULT(STDMETHODCALLTYPE* GetRuntimeClassName)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics* This, + /* [out] */ __RPC__deref_out_opt HSTRING* className); + + HRESULT(STDMETHODCALLTYPE* GetTrustLevel)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics* This, + /* [out] */ __RPC__out TrustLevel* trustLevel); + + HRESULT(STDMETHODCALLTYPE* Current)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics* This, + /* [out] */ __RPC__out void** _instance_of_winrt_WindowsUdk_ApplicationModel_AppExtensions_XamlExtensions); + + END_INTERFACE +} WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStaticsVtbl; + +interface WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics // : IInspectable +{ + const struct WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStaticsVtbl* lpVtbl; +}; + +typedef interface WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2 WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2; + +DEFINE_GUID(IID_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2, + 0x0fe87da5, + 0xa7a6, 0x5de3, 0x83, 0x5f, + 0xd9, 0x8c, 0x87, 0x56, 0x01, 0x44 +); + +typedef struct WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2Vtbl // : IInspectableVtbl +{ + BEGIN_INTERFACE + + HRESULT(STDMETHODCALLTYPE* QueryInterface)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2* This, + /* [in] */ __RPC__in REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void** ppvObject); + + ULONG(STDMETHODCALLTYPE* AddRef)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2* This); + + ULONG(STDMETHODCALLTYPE* Release)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2* This); + + HRESULT(STDMETHODCALLTYPE* GetIids)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2* This, + /* [out] */ __RPC__out ULONG* iidCount, + /* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID** iids); + + HRESULT(STDMETHODCALLTYPE* GetRuntimeClassName)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2* This, + /* [out] */ __RPC__deref_out_opt HSTRING* className); + + HRESULT(STDMETHODCALLTYPE* GetTrustLevel)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2* This, + /* [out] */ __RPC__out TrustLevel* trustLevel); + + HRESULT(STDMETHODCALLTYPE* GetForCategory)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2* This, + __RPC__in HSTRING a2, + /* [out] */ __RPC__out void** _instance_of_winrt_WindowsUdk_ApplicationModel_AppExtensions_XamlExtensions); + + END_INTERFACE +} WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2Vtbl; + +interface WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2 // : IInspectable +{ + const struct WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2Vtbl* lpVtbl; +}; + +typedef interface WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2 WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2; + +DEFINE_GUID(IID_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2, + 0x34a95314, + 0xca5c, 0x5fad, 0xae, 0x7c, + 0x1a, 0x90, 0x18, 0x11, 0x66, 0xc1 +); + +typedef struct WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2Vtbl // : IInspectableVtbl { - CONST_VTBL struct IActivationFactoryVtbl* lpVtbl; - struct IActivationFactoryVtbl* lpVtbl2; - struct IActivationFactoryVtbl* lpVtbl3; -} IActivationFactoryAA; -extern const IActivationFactoryAA XamlExtensionsFactory; + BEGIN_INTERFACE + + HRESULT(STDMETHODCALLTYPE* QueryInterface)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2* This, + /* [in] */ __RPC__in REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void** ppvObject); + + ULONG(STDMETHODCALLTYPE* AddRef)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2* This); + + ULONG(STDMETHODCALLTYPE* Release)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2* This); + + HRESULT(STDMETHODCALLTYPE* GetIids)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2* This, + /* [out] */ __RPC__out ULONG* iidCount, + /* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*iidCount) IID** iids); + + HRESULT(STDMETHODCALLTYPE* GetRuntimeClassName)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2* This, + /* [out] */ __RPC__deref_out_opt HSTRING* className); + + HRESULT(STDMETHODCALLTYPE* GetTrustLevel)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2* This, + /* [out] */ __RPC__out TrustLevel* trustLevel); + + HRESULT(STDMETHODCALLTYPE* IsExtensionAvailable)( + __RPC__in WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2* This, + __RPC__in HSTRING a2, + __RPC__in HSTRING a3, + /* [out] */ __RPC__out BYTE* a4); + + END_INTERFACE +} WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2Vtbl; + +interface WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2 // : IInspectable +{ + const struct WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2Vtbl* lpVtbl; +}; + +extern const WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics instanceof_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics; +extern const WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2 instanceof_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensionsStatics2; +extern const WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2 instanceof_WindowsUdk_ApplicationModel_AppExtensions_IXamlExtensions2; #pragma endregion inline int FileExistsW(wchar_t* file) From 6023718b959941eccc586aa81c9eeab4e5998385 Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Sun, 24 Sep 2023 19:52:48 +0700 Subject: [PATCH 2/6] Taskbar11: Fixed a bug that crashed `explorer.exe` when right clicking the new taskbar on Windows 11 builds with "Never combine" on the new taskbar --- ExplorerPatcher/dllmain.c | 78 +++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 28 deletions(-) diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index e819131..a1a0165 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -2411,6 +2411,8 @@ LRESULT CALLBACK Shell_TrayWndMouseProc( return CallNextHookEx(Shell_TrayWndMouseHook, nCode, wParam, lParam); } +PBYTE g_pTrayUIHost; + INT64 Shell_TrayWndSubclassProc( _In_ HWND hWnd, _In_ UINT uMsg, @@ -2492,29 +2494,25 @@ INT64 Shell_TrayWndSubclassProc( } DeleteMenu(hSubMenu, 424, MF_BYCOMMAND); // Lock the taskbar DeleteMenu(hSubMenu, 425, MF_BYCOMMAND); // Lock all taskbars - HWND hShellTray_Wnd = FindWindowExW(NULL, NULL, L"Shell_TrayWnd", NULL); - INT64* CTrayInstance = (BYTE*)(GetWindowLongPtrW(hShellTray_Wnd, 0)); // -> CTray - const unsigned int TRAYUI_OFFSET_IN_CTRAY = 110; - uintptr_t TrayUIInstance = *((INT64*)CTrayInstance + TRAYUI_OFFSET_IN_CTRAY) + 8; - if (TrayUIInstance) + if (g_pTrayUIHost) { - int offset = 656; - if (IsWindows11Version22H2OrHigher()) offset = 640; - if (IsWindows11Version22H2Build2134OrHigher()) offset = 648; - if ((*(unsigned __int8(__fastcall**)(INT64))(**(INT64**)(TrayUIInstance + offset) + 104i64))(*(INT64*)(TrayUIInstance + offset))) + void** pTrayUIHostVtbl = *(void***)g_pTrayUIHost; + BOOL (*ShouldDeleteContextMenuUndo)(PBYTE) = pTrayUIHostVtbl[13]; + UINT (*GetContextMenuUndoResourceId)(PBYTE) = pTrayUIHostVtbl[14]; + + if (ShouldDeleteContextMenuUndo(g_pTrayUIHost)) { - DeleteMenu(hSubMenu, 0x1A0u, 0); + DeleteMenu(hSubMenu, 416, MF_BYCOMMAND); } else { - WCHAR Buffer[MAX_PATH]; - WCHAR v40[MAX_PATH]; - WCHAR NewItem[MAX_PATH]; - LoadStringW(GetModuleHandleW(NULL), 0x216u, Buffer, 64); - UINT v22 = (*(__int64(__fastcall**)(INT64))(**(INT64**)(TrayUIInstance + offset) + 112i64))(*(INT64*)(TrayUIInstance + offset)); - LoadStringW(GetModuleHandleW(NULL), v22, v40, 96); - swprintf_s(NewItem, 0xA0ui64, Buffer, v40); - ModifyMenuW(hSubMenu, 0x1A0u, 0, 0x1A0ui64, NewItem); + WCHAR wszTemplate[64]; + WCHAR wszCommand[96]; + WCHAR wszMenu[160]; + LoadStringW(GetModuleHandleW(NULL), 534, wszTemplate, 64); + LoadStringW(GetModuleHandleW(NULL), GetContextMenuUndoResourceId(g_pTrayUIHost), wszCommand, 96); + swprintf_s(wszMenu, 160, wszTemplate, wszCommand); + ModifyMenuW(hSubMenu, 416, MF_BYCOMMAND, 416, wszMenu); } } else @@ -10715,6 +10713,8 @@ DWORD Inject(BOOL bIsExplorer) HANDLE hExplorer = GetModuleHandleW(NULL); + MODULEINFO miExplorer; + GetModuleInformation(GetCurrentProcess(), hExplorer, &miExplorer, sizeof(MODULEINFO)); SetChildWindowNoActivateFunc = GetProcAddress(GetModuleHandleW(L"user32.dll"), (LPCSTR)2005); if (bOldTaskbar) { @@ -10784,7 +10784,29 @@ DWORD Inject(BOOL bIsExplorer) VnPatchIAT(hExplorer, "dwmapi.dll", "DwmUpdateThumbnailProperties", explorer_DwmUpdateThumbnailPropertiesHook); PatchExplorer_UpdateWindowAccentProperties(); } - + if (IsWindows11()) + { + // Find a pointer to ITrayUIHost needed to have a working Windows 10 taskbar context menu on Windows 11 taskbar + // Ref: CTray::Init() + // 4C 8D 05 ? ? ? ? 48 8D 0D ? ? ? ? E8 ? ? ? ? 48 8B 8D + // ^^^^^^^ + PBYTE match = FindPattern( + hExplorer, + miExplorer.SizeOfImage, + "\x4C\x8D\x05\x00\x00\x00\x00\x48\x8D\x0D\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x48\x8B\x8D", + "xxx????xxx????x????xxx" + ); + if (match) + { + match += 7; + g_pTrayUIHost = match + 7 + *(int*)(match + 3); + printf("ITrayUIHost = %llX\n", g_pTrayUIHost - (PBYTE)hExplorer); + } + else + { + printf("Failed to find ITrayUIHost, the custom Windows 11 taskbar context menu will not have the undo function\n"); + } + } HANDLE hShcore = LoadLibraryW(L"shcore.dll"); SHWindowsPolicy = GetProcAddress(hShcore, (LPCSTR)190); @@ -10857,7 +10879,7 @@ DWORD Inject(BOOL bIsExplorer) // ^^^^^^^ PBYTE match = FindPattern( hTwinuiPcshell, - miTwinuiPcshell.lpBaseOfDll, + miTwinuiPcshell.SizeOfImage, "\x4D\x8B\xCF\x4D\x8B\xC4\x8B\xD6\x48\x8B\x49\x08\xE8\x00\x00\x00\x00\xE9", "xxxxxxxxxxxxx????x" ); @@ -10873,7 +10895,7 @@ DWORD Inject(BOOL bIsExplorer) // 48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 30 49 8B D8 48 8B FA 48 8B F1 49 83 20 00 41 B0 03 B2 01 PBYTE match = FindPattern( hTwinuiPcshell, - miTwinuiPcshell.lpBaseOfDll, + miTwinuiPcshell.SizeOfImage, "\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x30\x49\x8B\xD8\x48\x8B\xFA\x48\x8B\xF1\x49\x83\x20\x00\x41\xB0\x03\xB2\x01", "xxxx?xxxx?xxxxxxxxxxxxxxxxxxxxxxx" ); @@ -10890,7 +10912,7 @@ DWORD Inject(BOOL bIsExplorer) // ^^^^^^^ PBYTE match = FindPattern( hTwinuiPcshell, - miTwinuiPcshell.lpBaseOfDll, + miTwinuiPcshell.SizeOfImage, "\xE8\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x0F\xB7\xC8\xE8\x00\x00\x00\x00\xF7\xD8", "x????x????xxxx????xx" ); @@ -10907,7 +10929,7 @@ DWORD Inject(BOOL bIsExplorer) // ^^^^^^^ PBYTE match = FindPattern( hTwinuiPcshell, - miTwinuiPcshell.lpBaseOfDll, + miTwinuiPcshell.SizeOfImage, "\xE8\x00\x00\x00\x00\x85\xDB\x74\x29", "x????xxxx" ); @@ -10923,7 +10945,7 @@ DWORD Inject(BOOL bIsExplorer) // ^^^^^^^ PBYTE match = FindPattern( hTwinuiPcshell, - miTwinuiPcshell.lpBaseOfDll, + miTwinuiPcshell.SizeOfImage, "\xE8\x00\x00\x00\x00\x90\x49\x8D\x56\x38\x49\x8B\xCE", "x????xxxxxxxx" ); @@ -10939,7 +10961,7 @@ DWORD Inject(BOOL bIsExplorer) // ^^^^^^^ PBYTE match = FindPattern( hTwinuiPcshell, - miTwinuiPcshell.lpBaseOfDll, + miTwinuiPcshell.SizeOfImage, "\xE8\x00\x00\x00\x00\x90\x48\x8D\x56\x38\x48\x8B\xCE", "x????xxxxxxxx" ); @@ -10954,7 +10976,7 @@ DWORD Inject(BOOL bIsExplorer) // 48 83 EC 28 41 B0 03 B2 01 PBYTE match = FindPattern( hTwinuiPcshell, - miTwinuiPcshell.lpBaseOfDll, + miTwinuiPcshell.SizeOfImage, "\x48\x83\xEC\x28\x41\xB0\x03\xB2\x01", "xxxxxxxxx" ); @@ -10971,7 +10993,7 @@ DWORD Inject(BOOL bIsExplorer) // ^^^^^^^ PBYTE match = FindPattern( hTwinuiPcshell, - miTwinuiPcshell.lpBaseOfDll, + miTwinuiPcshell.SizeOfImage, "\x4C\x89\x74\x24\x00\x00\x8B\x00\x00\x8B\x00\x8B\xD7\x48\x8B\xCE\xE8\x00\x00\x00\x00\x8B", "xxxx??x??x?xxxxxx????x" ); @@ -10989,7 +11011,7 @@ DWORD Inject(BOOL bIsExplorer) // ^^^^^^^ PBYTE match = FindPattern( hTwinuiPcshell, - miTwinuiPcshell.lpBaseOfDll, + miTwinuiPcshell.SizeOfImage, "\x4C\x89\x74\x24\x00\x00\x8B\x00\x00\x8B\x00\x8B\xD7\x48\x8B\xCE\xE8\x00\x00\x00\x00\x90", "xxxx??x??x?xxxxxx????x" ); From b426d2c46a764816f28f2343a6024128fdcc3da2 Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Mon, 25 Sep 2023 04:34:02 +0700 Subject: [PATCH 3/6] File Explorer: Try to avoid crashes related to the new Windows App SDK views --- ExplorerPatcher/dllmain.c | 186 +++++++++++++++++++++++++------------- 1 file changed, 121 insertions(+), 65 deletions(-) diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index a1a0165..70ffefc 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -1915,86 +1915,106 @@ DWORD FixTaskbarAutohide(DWORD unused) #pragma region "EnsureXAML on OS builds 22621+" #ifdef _WIN64 DEFINE_GUID(uuidof_Windows_Internal_Shell_XamlExplorerHost_IXamlApplicationStatics, - 0xECC13292, 0x27EF, 0x547A, 0xAC, 0x8B, 0x76, 0xCD, 0x17, 0x32, 0x21, 0x86); + 0xECC13292, + 0x27EF, 0x547A, 0xAC, 0x8B, + 0x76, 0xCD, 0x17, 0x32, 0x21, 0x86 +); + +// 22621.2134+. Still named IXamlApplicationStatics. +DEFINE_GUID(uuidof_Windows_Internal_Shell_XamlExplorerHost_IXamlApplicationStatics2, + 0x5148D7B1, + 0x800E, 0x5C86, 0x8F, 0x69, + 0x55, 0x81, 0x97, 0x48, 0x31, 0x23 +); DEFINE_GUID(uuidof_Windows_UI_Core_ICoreWindow5, - 0x28258A12, 0x7D82, 0x505B, 0xB2, 0x10, 0x71, 0x2B, 0x04, 0xA5, 0x88, 0x82); + 0x28258A12, + 0x7D82, 0x505B, 0xB2, 0x10, + 0x71, 0x2B, 0x04, 0xA5, 0x88, 0x82 +); BOOL bIsXAMLEnsured = FALSE; void EnsureXAML() { - signed int v0; // eax - signed int v2; // eax + if (bIsXAMLEnsured) + return; + bIsXAMLEnsured = TRUE; + ULONGLONG initTime = GetTickCount64(); + HRESULT hr; - if (!bIsXAMLEnsured) + HSTRING_HEADER hstringheaderXamlApplication; + HSTRING hstringXamlApplication = NULL; + hr = WindowsCreateStringReference(L"Windows.Internal.Shell.XamlExplorerHost.XamlApplication", 55, &hstringheaderXamlApplication, &hstringXamlApplication); + if (FAILED(hr)) { - bIsXAMLEnsured = TRUE; - ULONGLONG initTime = GetTickCount64(); - - IInspectable* pUIXamlApplicationFactory = NULL; - HSTRING_HEADER hstringheaderXamlApplication; - HSTRING hstringXamlApplication = NULL; - IInspectable* pCoreWindow5 = NULL; - HSTRING_HEADER hstringheaderWindowsXamlManager; - HSTRING hstringWindowsXamlManager = NULL; + printf("[EnsureXAML] WindowsCreateStringReference(XamlApplication) failed. 0x%lX\n", hr); + goto cleanup; + } - if (FAILED(WindowsCreateStringReference(L"Windows.Internal.Shell.XamlExplorerHost.XamlApplication", 0x37u, &hstringheaderXamlApplication, &hstringXamlApplication)) || !hstringXamlApplication) - { - printf("Error in sub_1800135EC on WindowsCreateStringReference.\n"); - goto cleanup; - } - if (FAILED(RoGetActivationFactory(hstringXamlApplication, &uuidof_Windows_Internal_Shell_XamlExplorerHost_IXamlApplicationStatics, &pUIXamlApplicationFactory)) || !pUIXamlApplicationFactory) + IInspectable* pXamlApplicationStatics = NULL; + hr = RoGetActivationFactory(hstringXamlApplication, &uuidof_Windows_Internal_Shell_XamlExplorerHost_IXamlApplicationStatics, &pXamlApplicationStatics); + if (FAILED(hr)) + { + hr = RoGetActivationFactory(hstringXamlApplication, &uuidof_Windows_Internal_Shell_XamlExplorerHost_IXamlApplicationStatics2, &pXamlApplicationStatics); + if (FAILED(hr)) { - printf("Error in sub_1800135EC on RoGetActivationFactory.\n"); + printf("[EnsureXAML] RoGetActivationFactory(IXamlApplicationStatics) failed. 0x%lX\n", hr); goto cleanup0; } + } - IUnknown* pXamlApplication = NULL; - (*(void(__fastcall**)(__int64, __int64*))(*(INT64*)pUIXamlApplicationFactory + 48))(pUIXamlApplicationFactory, &pXamlApplication); // get_Current - if (!pXamlApplication) - { - printf("Error in sub_1800135EC on pUIXamlApplicationFactory + 48.\n"); - goto cleanup1; - } - else pXamlApplication->lpVtbl->Release(pXamlApplication); + IUnknown* pXamlApplication = NULL; + HRESULT (*IXamlApplicationStatics_get_Current)(IInspectable*, void**) = ((void**)pXamlApplicationStatics->lpVtbl)[6]; + hr = IXamlApplicationStatics_get_Current(pXamlApplicationStatics, &pXamlApplication); + if (FAILED(hr)) + { + printf("[EnsureXAML] IXamlApplicationStatics::get_Current() failed.\n"); + goto cleanup1; + } + pXamlApplication->lpVtbl->Release(pXamlApplication); - if (FAILED(WindowsCreateStringReference(L"Windows.UI.Xaml.Hosting.WindowsXamlManager", 0x2Au, &hstringheaderWindowsXamlManager, &hstringWindowsXamlManager))) - { - printf("Error in sub_1800135EC on WindowsCreateStringReference 2.\n"); - goto cleanup1; - } - if (FAILED(RoGetActivationFactory(hstringWindowsXamlManager, &uuidof_Windows_UI_Core_ICoreWindow5, &pCoreWindow5))) - { - printf("Error in sub_1800135EC on RoGetActivationFactory 2.\n"); - goto cleanup2; - } + HSTRING_HEADER hstringheaderWindowsXamlManager; + HSTRING hstringWindowsXamlManager = NULL; + hr = WindowsCreateStringReference(L"Windows.UI.Xaml.Hosting.WindowsXamlManager", 42, &hstringheaderWindowsXamlManager, &hstringWindowsXamlManager); + if (FAILED(hr)) + { + printf("[EnsureXAML] WindowsCreateStringReference(WindowsXamlManager) failed. 0x%lX\n", hr); + goto cleanup1; + } + + __x_ABI_CWindows_CUI_CCore_CICoreWindow5* pCoreWindow5 = NULL; + hr = RoGetActivationFactory(hstringWindowsXamlManager, &uuidof_Windows_UI_Core_ICoreWindow5, &pCoreWindow5); + if (FAILED(hr)) + { + printf("[EnsureXAML] RoGetActivationFactory(ICoreWindow5) failed. 0x%lX\n", hr); + goto cleanup2; + } - if (pCoreWindow5) + if (pCoreWindow5) + { + __x_ABI_CWindows_CSystem_CIDispatcherQueue* pDispatcherQueue = NULL; + hr = pCoreWindow5->lpVtbl->get_DispatcherQueue(pCoreWindow5, &pDispatcherQueue); + if (FAILED(hr)) { - IUnknown* pDispatcherQueue = NULL; - (*(void(__fastcall**)(__int64, __int64*))(*(INT64*)pCoreWindow5 + 48))(pCoreWindow5, &pDispatcherQueue); // get_DispatcherQueue - if (!pDispatcherQueue) - { - printf("Error in sub_1800135EC on pCoreWindow5 + 48.\n"); - goto cleanup3; - } - // Keep pDispatcherQueue referenced in memory + printf("[EnsureXAML] ICoreWindow5::get_DispatcherQueue() failed.\n"); + goto cleanup3; } + // Keep pDispatcherQueue referenced in memory + } - ULONGLONG finalTime = GetTickCount64(); - printf("EnsureXAML %lld ms.\n", finalTime - initTime); + ULONGLONG finalTime = GetTickCount64(); + printf("[EnsureXAML] %lld ms.\n", finalTime - initTime); - cleanup3: - if (pCoreWindow5) pCoreWindow5->lpVtbl->Release(pCoreWindow5); - cleanup2: - if (hstringWindowsXamlManager) WindowsDeleteString(hstringWindowsXamlManager); - cleanup1: - if (pUIXamlApplicationFactory) pUIXamlApplicationFactory->lpVtbl->Release(pUIXamlApplicationFactory); - cleanup0: - if (hstringXamlApplication) WindowsDeleteString(hstringXamlApplication); - cleanup: - ; - } +cleanup3: + if (pCoreWindow5) pCoreWindow5->lpVtbl->Release(pCoreWindow5); +cleanup2: + if (hstringWindowsXamlManager) WindowsDeleteString(hstringWindowsXamlManager); +cleanup1: + if (pXamlApplicationStatics) pXamlApplicationStatics->lpVtbl->Release(pXamlApplicationStatics); +cleanup0: + if (hstringXamlApplication) WindowsDeleteString(hstringXamlApplication); +cleanup: + ; } HRESULT(*ICoreWindow5_get_DispatcherQueueFunc)(INT64, INT64); @@ -8573,13 +8593,27 @@ HRESULT shell32_DriveTypeCategorizer_CreateInstanceHook(IUnknown* pUnkOuter, REF #pragma region "File Explorer command bar and ribbon support" +DEFINE_GUID(CLSID_XamlIslandViewAdapter, + 0x6480100B, + 0x5A83, 0x4D1E, 0x9F, 0x69, + 0x8A, 0xE5, 0xA8, 0x8E, 0x9A, 0x33 +); + DEFINE_GUID(CLSID_UIRibbonFramework, - 0x926749FA, 0x2615, 0x4987, 0x88, 0x45, 0xC3, 0x3E, 0x65, 0xF2, 0xB9, 0x57); + 0x926749FA, + 0x2615, 0x4987, 0x88, 0x45, + 0xC3, 0x3E, 0x65, 0xF2, 0xB9, 0x57 +); + DEFINE_GUID(IID_UIRibbonFramework, - 0xF4F0385D, 0x6872, 0x43A8, 0xAD, 0x09, 0x4C, 0x33, 0x9C, 0xB3, 0xF5, 0xC5); + 0xF4F0385D, + 0x6872, 0x43A8, 0xAD, 0x09, + 0x4C, 0x33, 0x9C, 0xB3, 0xF5, 0xC5 +); + HRESULT ExplorerFrame_CoCreateInstanceHook(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID* ppv) { - if ((dwFileExplorerCommandUI != 0) && *(INT64*)&rclsid->Data1 == 0x4D1E5A836480100B && *(INT64*)rclsid->Data4 == 0x339A8EA8E58A699F) + if (dwFileExplorerCommandUI != 0 && IsEqualCLSID(rclsid, &CLSID_XamlIslandViewAdapter)) { return REGDB_E_CLASSNOTREG; } @@ -9643,6 +9677,29 @@ int RtlQueryFeatureConfigurationHook(UINT32 featureId, int sectionType, INT64* c // flyouts alignment, notification center alignment, Windows key shortcuts on // OS builds 22621.1413+ // + // Removed in 22621.2134+ + // + buffer->enabledState = FEATURE_ENABLED_STATE_DISABLED; + } + break; + } +#endif +#if 1 + case 40729001: // WASDKInFileExplorer + { + if (dwFileExplorerCommandUI != 0) + { + // Disable the new Windows App SDK views (in Home and Gallery) when not using the Windows 11 command bar + // + // There is an issue where Explorer crashes when one goes to a page with WASDK, goes to another page + // without WASDK, and returning to a page with WASDK. + // + // However this also disables the new Gallery page altogether. + // TODO- We have to find a way to either fix the crashing or make Gallery use the non WASDK view in the + // TODO same way as when Explorer is opened into Control Panel then going to Gallery. + // + // TODO- We cannot rely on feature flag patches because they will eventually be removed. + // buffer->enabledState = FEATURE_ENABLED_STATE_DISABLED; } break; @@ -11521,7 +11578,6 @@ DWORD Inject(BOOL bIsExplorer) ArchiveMenuThread, params, 0, - 0, 0 ); } From cdead1b18a64151ef3d3f3523fde2828982540fe Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Mon, 25 Sep 2023 02:29:54 +0300 Subject: [PATCH 4/6] libvalinet: Upgraded to latest version which fixes VnGetUBR Thanks @roflcopter4 --- libs/libvalinet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/libvalinet b/libs/libvalinet index f0b704f..eaf0e7a 160000 --- a/libs/libvalinet +++ b/libs/libvalinet @@ -1 +1 @@ -Subproject commit f0b704fb585aff54692fda6a7d1edcef3fa3e27b +Subproject commit eaf0e7a2b1a0fefca334746157f7bab65eaf3737 From 1977d78ba06f83708d033781a4bab4573bd20697 Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Mon, 25 Sep 2023 11:02:41 +0700 Subject: [PATCH 5/6] Taskbar10: Fix pen menu crashing `explorer.exe` on 22621.2134+ --- ExplorerPatcher/dllmain.c | 48 +++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 70ffefc..52fa2b3 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -9928,12 +9928,27 @@ INT64 twinui_pcshell_IsUndockedAssetAvailableHook(INT a1, INT64 a2, INT64 a3, co } } -INT64(*twinui_pcshell_CMultitaskingViewManager__CreateDCompMTVHostFunc)(INT64 a1, unsigned int a2, INT64 a3, INT64 a4, INT64* a5); -INT64(*twinui_pcshell_CMultitaskingViewManager__CreateXamlMTVHostFunc)(INT64 a1, unsigned int a2, INT64 a3, INT64 a4, INT64* a5); -INT64 twinui_pcshell_CMultitaskingViewManager__CreateXamlMTVHostHook(INT64 a1, unsigned int a2, INT64 a3, INT64 a4, INT64* a5) +INT64(*twinui_pcshell_CMultitaskingViewManager__CreateDCompMTVHostFunc)(INT64 this, unsigned int a2, INT64 a3, INT64 a4, INT64* a5); +INT64(*twinui_pcshell_CMultitaskingViewManager__CreateXamlMTVHostFunc)(INT64 this, unsigned int a2, INT64 a3, INT64 a4, INT64* a5); +INT64 twinui_pcshell_CMultitaskingViewManager__CreateXamlMTVHostHook(INT64 this, unsigned int a2, INT64 a3, INT64 a4, INT64* a5) { - if (!twinui_pcshell_IsUndockedAssetAvailableHook(a2, 0, 0, 0, NULL)) return twinui_pcshell_CMultitaskingViewManager__CreateDCompMTVHostFunc(a1, a2, a3, a4, a5); - return twinui_pcshell_CMultitaskingViewManager__CreateXamlMTVHostFunc(a1, a2, a3, a4, a5); + if (!twinui_pcshell_IsUndockedAssetAvailableHook(a2, 0, 0, NULL)) + return twinui_pcshell_CMultitaskingViewManager__CreateDCompMTVHostFunc(this, a2, a3, a4, a5); + return twinui_pcshell_CMultitaskingViewManager__CreateXamlMTVHostFunc(this, a2, a3, a4, a5); +} + +HRESULT(*twinui_pcshell_PenMenuSystemTrayManager__GetDynamicSystemTrayHeightForMonitorFunc)(IInspectable* this, HMONITOR hMonitor, float* outHeight); +HRESULT twinui_pcshell_PenMenuSystemTrayManager__GetDynamicSystemTrayHeightForMonitorHook(IInspectable* this, HMONITOR hMonitor, float* outHeight) +{ + if (bOldTaskbar) + { + MONITORINFO mi; + mi.cbSize = sizeof(MONITORINFO); + GetMonitorInfoW(hMonitor, &mi); + *outHeight = (float)(mi.rcMonitor.bottom - mi.rcWork.bottom); + return S_OK; + } + return twinui_pcshell_PenMenuSystemTrayManager__GetDynamicSystemTrayHeightForMonitorFunc(this, hMonitor, outHeight); } #ifdef _WIN64 @@ -11211,6 +11226,29 @@ DWORD Inject(BOOL bIsExplorer) MODULEINFO miHardwareConfirmator; GetModuleInformation(GetCurrentProcess(), hHardwareConfirmator, &miHardwareConfirmator, sizeof(MODULEINFO)); Moment2PatchHardwareConfirmator(&miHardwareConfirmator); + + // Fix pen menu + // 48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 50 49 8B F0 48 81 C1 + twinui_pcshell_PenMenuSystemTrayManager__GetDynamicSystemTrayHeightForMonitorFunc = FindPattern( + hTwinuiPcshell, + miTwinuiPcshell.SizeOfImage, + "\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x50\x49\x8B\xF0\x48\x81\xC1", + "xxxx?xxxx?xxxxxxxxxxx" + ); + rv = -1; + if (twinui_pcshell_PenMenuSystemTrayManager__GetDynamicSystemTrayHeightForMonitorFunc) + { + printf("PenMenuSystemTrayManager::GetDynamicSystemTrayHeightForMonitor() = %llX\n", (PBYTE)twinui_pcshell_PenMenuSystemTrayManager__GetDynamicSystemTrayHeightForMonitorFunc - (PBYTE)hTwinuiPcshell); + rv = funchook_prepare( + funchook, + (void**)&twinui_pcshell_PenMenuSystemTrayManager__GetDynamicSystemTrayHeightForMonitorFunc, + twinui_pcshell_PenMenuSystemTrayManager__GetDynamicSystemTrayHeightForMonitorHook + ); + } + if (rv != 0) + { + printf("Failed to hook PenMenuSystemTrayManager::GetDynamicSystemTrayHeightForMonitor(). rv = %d\n", rv); + } } #endif From 05611dd29c0856d5323f92864cec05a12c94bef9 Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Mon, 25 Sep 2023 12:00:10 +0700 Subject: [PATCH 6/6] Version: 22621.2361.58.1 --- CHANGELOG.md | 14 ++++++++++++++ version.h | 10 +++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d198c9b..3c03c7b 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.2361.58 + +Tested on OS builds 22000.2416, 22621.1, 22621.2134, 22621.2361, 22631.2338, and 23545.1000. + +#### Details + +##### 1 + +* Taskbar10: Fixed Windows 10 taskbar not showing up on Windows 11 builds with "Never combine" on the new taskbar. (bc3bbc7) +* Taskbar10: Fixed pen menu crashing `explorer.exe` on 22621.2134+. (1977d78) +* Taskbar11: Fixed a bug that crashed `explorer.exe` when right clicking the new taskbar on Windows 11 builds with "Never combine" on the new taskbar. (6023718) +* File Explorer: EP now tries to avoid crashes related to the new Windows App SDK views. (b426d2c) +* On OS builds 22621+, fixed a bug that crashed `explorer.exe` when required functions in `twinui.pcshell.dll` (for Win+X and Windows 10 Alt+Tab) could not be found using the fallback method. (6023718) + ## 22621.2283.57 Tested on OS build 22621.2283. Installer requires Internet connectivity. diff --git a/version.h b/version.h index b773c2d..3144e74 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ #define VER_MAJOR 22621 -#define VER_MINOR 2283 -#define VER_BUILD_HI 57 -#define VER_BUILD_LO 2 +#define VER_MINOR 2361 +#define VER_BUILD_HI 58 +#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.2283.57.2" -#define VER_PRODUCT_STRING VALUE "ProductVersion", "22621.2283.57.2" +#define VER_FILE_STRING VALUE "FileVersion", "22621.2361.58.1" +#define VER_PRODUCT_STRING VALUE "ProductVersion", "22621.2361.58.1"