Skip to content

Commit dca0b3a

Browse files
committed
Taskbar10: Made the Control Center and Toast Center positioning patch work with build 25951 (Canary)
1 parent b157aba commit dca0b3a

File tree

3 files changed

+47
-29
lines changed

3 files changed

+47
-29
lines changed

ExplorerPatcher/ImmersiveFlyouts.c

+11-12
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void InvokeActionCenter()
5656
}
5757
}
5858

59-
void InvokeFlyout(BOOL bAction, DWORD dwWhich)
59+
HRESULT InvokeFlyoutRect(BOOL bAction, DWORD dwWhich, __x_ABI_CWindows_CFoundation_CRect* pRc)
6060
{
6161
HRESULT hr = S_OK;
6262
IUnknown* pImmersiveShell = NULL;
@@ -70,13 +70,13 @@ void InvokeFlyout(BOOL bAction, DWORD dwWhich)
7070
if (SUCCEEDED(hr))
7171
{
7272
IShellExperienceManagerFactory* pShellExperienceManagerFactory = NULL;
73-
IUnknown_QueryService(
73+
hr = IUnknown_QueryService(
7474
pImmersiveShell,
7575
&CLSID_ShellExperienceManagerFactory,
7676
&CLSID_ShellExperienceManagerFactory,
7777
&pShellExperienceManagerFactory
7878
);
79-
if (pShellExperienceManagerFactory)
79+
if (SUCCEEDED(hr))
8080
{
8181
HSTRING_HEADER hstringHeader;
8282
HSTRING hstring = NULL;
@@ -102,36 +102,34 @@ void InvokeFlyout(BOOL bAction, DWORD dwWhich)
102102
&hstringHeader,
103103
&hstring
104104
);
105-
if (hstring)
105+
if (SUCCEEDED(hr))
106106
{
107107
IUnknown* pIntf = NULL;
108-
pShellExperienceManagerFactory->lpVtbl->GetExperienceManager(
108+
hr = pShellExperienceManagerFactory->lpVtbl->GetExperienceManager(
109109
pShellExperienceManagerFactory,
110110
hstring,
111111
&pIntf
112112
);
113-
if (pIntf)
113+
if (SUCCEEDED(hr))
114114
{
115115
IExperienceManager* pExperienceManager = NULL;
116-
pIntf->lpVtbl->QueryInterface(
116+
hr = pIntf->lpVtbl->QueryInterface(
117117
pIntf,
118118
dwWhich == INVOKE_FLYOUT_NETWORK ? &IID_NetworkFlyoutExperienceManager :
119119
(dwWhich == INVOKE_FLYOUT_CLOCK ? &IID_TrayClockFlyoutExperienceManager :
120120
(dwWhich == INVOKE_FLYOUT_BATTERY ? &IID_TrayBatteryFlyoutExperienceManager :
121121
(dwWhich == INVOKE_FLYOUT_SOUND ? &IID_TrayMtcUvcFlyoutExperienceManager : &IID_IUnknown))),
122122
&pExperienceManager
123123
);
124-
if (pExperienceManager)
124+
if (SUCCEEDED(hr))
125125
{
126-
RECT rc;
127-
SetRect(&rc, 0, 0, 0, 0);
128126
if (bAction == INVOKE_FLYOUT_SHOW)
129127
{
130-
pExperienceManager->lpVtbl->ShowFlyout(pExperienceManager, &rc, NULL);
128+
hr = pExperienceManager->lpVtbl->ShowFlyout(pExperienceManager, pRc);
131129
}
132130
else if (bAction == INVOKE_FLYOUT_HIDE)
133131
{
134-
pExperienceManager->lpVtbl->HideFlyout(pExperienceManager);
132+
hr = pExperienceManager->lpVtbl->HideFlyout(pExperienceManager);
135133
}
136134
pExperienceManager->lpVtbl->Release(pExperienceManager);
137135
}
@@ -143,4 +141,5 @@ void InvokeFlyout(BOOL bAction, DWORD dwWhich)
143141
}
144142
pImmersiveShell->lpVtbl->Release(pImmersiveShell);
145143
}
144+
return hr;
146145
}

ExplorerPatcher/ImmersiveFlyouts.h

+11-3
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ typedef struct IExperienceManagerVtbl // : IInspectable
5757

5858
HRESULT(STDMETHODCALLTYPE* ShowFlyout)(
5959
IExperienceManager* This,
60-
/* [in] */ RECT* rect,
61-
/* [in] */ HWND hWnd);
60+
/* [in] */ __x_ABI_CWindows_CFoundation_CRect* rect);
6261

6362
HRESULT(STDMETHODCALLTYPE* HideFlyout)(
6463
IExperienceManager* This);
@@ -192,5 +191,14 @@ void InvokeActionCenter();
192191
#define INVOKE_FLYOUT_CLOCK 2
193192
#define INVOKE_FLYOUT_BATTERY 3
194193
#define INVOKE_FLYOUT_SOUND 4
195-
void InvokeFlyout(BOOL bAction, DWORD dwWhich);
194+
195+
HRESULT InvokeFlyoutRect(BOOL bAction, DWORD dwWhich, __x_ABI_CWindows_CFoundation_CRect* pRc);
196+
197+
inline HRESULT InvokeFlyout(BOOL bAction, DWORD dwWhich)
198+
{
199+
__x_ABI_CWindows_CFoundation_CRect rc;
200+
ZeroMemory(&rc, sizeof(rc));
201+
return InvokeFlyoutRect(bAction, dwWhich, &rc);
202+
}
203+
196204
#endif

ExplorerPatcher/dllmain.c

+25-14
Original file line numberDiff line numberDiff line change
@@ -10009,10 +10009,10 @@ BOOL Moment2PatchControlCenter(LPMODULEINFO mi)
1000910009
{
1001010010
// Step 1:
1001110011
// Scan within the DLL for `rcMonitor = mi.rcMonitor`.
10012-
// ```0F 10 44 24 ?? F3 0F 7F 44 24 ?? 80 BF // movups - movdqu - cmp```
10012+
// ```0F 10 44 24 ?? F3 0F 7F 44 24 ?? 80 // movups - movdqu - cmp```
1001310013
// 22621.1992: 4B35B
1001410014
// 22621.2283: 65C5C
10015-
PBYTE rcMonitorAssignment = FindPattern(mi->lpBaseOfDll, mi->SizeOfImage, "\x0F\x10\x44\x24\x00\xF3\x0F\x7F\x44\x24\x00\x80\xBF", "xxxx?xxxxx?xx");
10015+
PBYTE rcMonitorAssignment = FindPattern(mi->lpBaseOfDll, mi->SizeOfImage, "\x0F\x10\x44\x24\x00\xF3\x0F\x7F\x44\x24\x00\x80", "xxxx?xxxxx?x");
1001610016
if (!rcMonitorAssignment) return FALSE;
1001710017
printf("[CC] rcMonitorAssignment = %llX\n", rcMonitorAssignment - (PBYTE)mi->lpBaseOfDll);
1001810018

@@ -10066,11 +10066,23 @@ BOOL Moment2PatchToastCenter(LPMODULEINFO mi)
1006610066
{
1006710067
// Step 1:
1006810068
// Scan within the DLL for `rcMonitor = mi.rcMonitor`.
10069-
// ```0F 10 45 84 ?? 0F 7F 44 24 ?? 48 8B CF // movups - movdqu - mov```
10069+
//
10070+
// Pattern 1:
10071+
// Will have a match if CToastCenterExperienceManager::ShouldShowWithinWorkArea() is present.
10072+
// ```0F 10 45 ?? ?? 0F 7F 44 24 ?? 48 8B CF // movups - movdqu - mov```
1007010073
// 22621.1992: 40CE8
1007110074
// 22621.2283: 501DB
10072-
PBYTE rcMonitorAssignment = FindPattern(mi->lpBaseOfDll, mi->SizeOfImage, "\x0F\x10\x45\x84\x00\x0F\x7F\x44\x24\x00\x48\x8B\xCF", "xxxx?xxxx?xxx");
10073-
if (!rcMonitorAssignment) return FALSE;
10075+
//
10076+
// Pattern 2:
10077+
// Will have a match if CToastCenterExperienceManager::ShouldShowWithinWorkArea() is inlined.
10078+
// ```0F 10 45 ?? ?? 0F 7F 44 24 ?? 44 // movups - movdqu - cmp```
10079+
// 25951.1000: 36B2C4
10080+
PBYTE rcMonitorAssignment = FindPattern(mi->lpBaseOfDll, mi->SizeOfImage, "\x0F\x10\x45\x00\x00\x0F\x7F\x44\x24\x00\x48\x8B\xCF", "xxx??xxxx?xxx");
10081+
if (!rcMonitorAssignment)
10082+
{
10083+
rcMonitorAssignment = FindPattern(mi->lpBaseOfDll, mi->SizeOfImage, "\x0F\x10\x45\x00\x00\x0F\x7F\x44\x24\x00\x44", "xxx??xxxx?x");
10084+
if (!rcMonitorAssignment) return FALSE;
10085+
}
1007410086
printf("[TC] rcMonitorAssignment = %llX\n", rcMonitorAssignment - (PBYTE)mi->lpBaseOfDll);
1007510087

1007610088
// Step 2:
@@ -10266,12 +10278,11 @@ void WINAPI HardwareConfirmatorShellcode(PBYTE pCoroInstance)
1026610278
hr = pTheFunc(pEdgeUiManager, &rc);
1026710279
}
1026810280

10269-
typedef struct { float x, y, width, height; } Windows_Foundation_Rect;
10270-
Windows_Foundation_Rect* out = pCoroInstance + g_Moment2PatchOffsets.coroInstance_rcOut;
10271-
out->x = (float)rc.left;
10272-
out->y = (float)rc.top;
10273-
out->width = (float)(rc.right - rc.left);
10274-
out->height = (float)(rc.bottom - rc.top);
10281+
__x_ABI_CWindows_CFoundation_CRect* out = pCoroInstance + g_Moment2PatchOffsets.coroInstance_rcOut;
10282+
out->X = (float)rc.left;
10283+
out->Y = (float)rc.top;
10284+
out->Width = (float)(rc.right - rc.left);
10285+
out->Height = (float)(rc.bottom - rc.top);
1027510286

1027610287
pEdgeUiManager->lpVtbl->Release(pEdgeUiManager);
1027710288
}
@@ -11057,13 +11068,13 @@ DWORD Inject(BOOL bIsExplorer)
1105711068
{
1105811069
// Find a pointer to ITrayUIHost needed to have a working Windows 10 taskbar context menu on Windows 11 taskbar
1105911070
// Ref: CTray::Init()
11060-
// 4C 8D 05 ? ? ? ? 48 8D 0D ? ? ? ? E8 ? ? ? ? 48 8B 8D
11071+
// 4C 8D 05 ? ? ? ? 48 8D 0D ? ? ? ? E8 ? ? ? ? 48 8B
1106111072
// ^^^^^^^
1106211073
PBYTE match = FindPattern(
1106311074
hExplorer,
1106411075
miExplorer.SizeOfImage,
11065-
"\x4C\x8D\x05\x00\x00\x00\x00\x48\x8D\x0D\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x48\x8B\x8D",
11066-
"xxx????xxx????x????xxx"
11076+
"\x4C\x8D\x05\x00\x00\x00\x00\x48\x8D\x0D\x00\x00\x00\x00\xE8\x00\x00\x00\x00\x48\x8B",
11077+
"xxx????xxx????x????xx"
1106711078
);
1106811079
if (match)
1106911080
{

0 commit comments

Comments
 (0)