Skip to content

Commit

Permalink
Taskbar10: Various *important* fixes:
Browse files Browse the repository at this point in the history
- Revised the method for enabling the old taskbar by intercepting the code path for initializing the new taskbar, due to a very rare issue where our hook does not get called on certain recent builds. (valinet#2499)
- Fixed crash on 25921+ due to the removal of pnidui.dll. (valinet#2558)
- Fixed potential stability issues when using the new taskbar on 22621.2787+.
  • Loading branch information
Amrsatrio committed Dec 11, 2023
1 parent a7a3d27 commit ec68783
Show file tree
Hide file tree
Showing 7 changed files with 18,999 additions and 19,214 deletions.
712 changes: 358 additions & 354 deletions ExplorerPatcher/ExplorerPatcher.vcxproj

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions ExplorerPatcher/Taskbar10.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "utility.h"

#pragma region "Enable old taskbar"
/***
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 can to make the last
argument of that function be set to false, so that we'll get the Windows 10 taskbar instead of the Windows 11 one that
gets constructed through `CTray::InitializeTrayUIComponent()`.
Alternatively, we can modify the behavior of `CTray::InitializeTrayUIComponent`. It contains the code to call
`TrayUI_CreateInstance()` that resides in `Taskbar.dll` (checked through HKLM\SOFTWARE\Classes\CLSID\<the CLSID>) which
is a copy of the Windows 10 taskbar code but modified over the time to support the Windows 11 taskbar. We see that it
calls `CoCreateInstance` to get an `ITrayUIComponent` interface to an instance of `TrayUIComponent`. We hook that
function to make it return our own custom `ITrayUIComponent` instance. Our `ITrayUIComponent::InitializeWithTray()`
function calls `TrayUI_CreateInstance()` of `explorer.exe` that is also called when the last argument of
`IsExtensionAvailable()` after the call is false.
This way, we can get the Windows 10 taskbar which resides in explorer.exe without hooking LoadLibraryExW() in order to
perform our initial method which has been known to be inconsistent on some systems. (Thanks feature flags!)
***/

static ULONG STDMETHODCALLTYPE nimplAddRefRelease(IUnknown* This)
{
return 1;
}

static HRESULT STDMETHODCALLTYPE ITrayUIComponent_QueryInterface(ITrayUIComponent* This, REFIID riid, void** ppvObject)
{
// Should never be called
return E_NOTIMPL;
}

static HRESULT STDMETHODCALLTYPE ITrayUIComponent_InitializeWithTray(ITrayUIComponent* This, ITrayUIHost* host, ITrayUI** result)
{
return explorer_TrayUI_CreateInstanceFunc(host, &IID_ITrayUI, (void**)result);
}

static const ITrayUIComponentVtbl instanceof_ITrayUIComponentVtbl = {
.QueryInterface = ITrayUIComponent_QueryInterface,
.AddRef = nimplAddRefRelease,
.Release = nimplAddRefRelease,
.InitializeWithTray = ITrayUIComponent_InitializeWithTray
};
const ITrayUIComponent instanceof_ITrayUIComponent = { &instanceof_ITrayUIComponentVtbl };
#pragma endregion
Loading

0 comments on commit ec68783

Please sign in to comment.