Skip to content

Commit 9e91030

Browse files
committed
File Explorer: Correct shrunk address bar toolbar button size when Servicing_CFDNavButtonsTheming (NI: 56845961, GE: 52061322) is enabled (#4552)
1 parent f4e9faf commit 9e91030

File tree

1 file changed

+82
-4
lines changed

1 file changed

+82
-4
lines changed

ExplorerPatcher/dllmain.c

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8774,14 +8774,14 @@ int explorerframe_GetSystemMetricsForDpi(int nIndex, UINT dpi)
87748774
return GetSystemMetricsForDpi(nIndex, dpi);
87758775
}
87768776

8777-
#if defined(_M_X64)
87788777
static void PatchAddressBarSizing(const MODULEINFO* mi)
87798778
{
87808779
// <- means inlined
87818780

87828781
PBYTE match;
87838782
DWORD dwOldProtect;
87848783

8784+
#if defined(_M_X64)
87858785
// Patch address bar positioning
87868786
if (IsWindows11())
87878787
{
@@ -8999,6 +8999,7 @@ static void PatchAddressBarSizing(const MODULEINFO* mi)
89998999
VirtualProtect(match, 8, dwOldProtect, &dwOldProtect);
90009000
}
90019001
}*/
9002+
#endif
90029003

90039004
if (IsWindows11())
90049005
{
@@ -9007,6 +9008,7 @@ static void PatchAddressBarSizing(const MODULEINFO* mi)
90079008
// Inlined SHLogicalToPhysicalDPI()
90089009
// 41 B8 60 00 00 00 41 8D 58 B1
90099010
// xx To A8
9011+
#if defined(_M_X64)
90109012
match = FindPattern(
90119013
mi->lpBaseOfDll,
90129014
mi->SizeOfImage,
@@ -9038,11 +9040,87 @@ static void PatchAddressBarSizing(const MODULEINFO* mi)
90389040
VirtualProtect(match, 16, dwOldProtect, &dwOldProtect);
90399041
}
90409042
}
9043+
#endif
9044+
9045+
// Windows 11 - Revert feature flag Servicing_CFDNavButtonsTheming's effect on toolbar button size
9046+
// Nickel: 56845961, Germanium: 52061322
9047+
#if defined(_M_X64)
9048+
// Feature flag present, Nickel
9049+
// CAddressBand::_PositionChildWindows() <- CAddressBand::ResizeToolbarButtons()
9050+
// BA 04 00 00 00 0F 95 C0 84 C0 75 02 8B D6
9051+
// xxxxxxxxxxx To 01 00 00 00
9052+
match = FindPattern(
9053+
mi->lpBaseOfDll,
9054+
mi->SizeOfImage,
9055+
"\xBA\x04\x00\x00\x00\x0F\x95\xC0\x84\xC0\x75\x02\x8B\xD6",
9056+
"xxxxxxxxxxxxxx"
9057+
);
9058+
if (match && VirtualProtect(match, 5, PAGE_EXECUTE_READWRITE, &dwOldProtect))
9059+
{
9060+
*(int*)(match + 1) = 1;
9061+
VirtualProtect(match, 5, dwOldProtect, &dwOldProtect);
9062+
}
9063+
else
9064+
{
9065+
// Feature flag present, Germanium+
9066+
// CAddressBand::ResizeToolbarButtons()
9067+
// C7 44 24 ?? 04 00 00 00 84 C0 75 08 C7 44 24 ?? 01 00 00 00
9068+
// xxxxxxxxxxx To 01 00 00 00
9069+
match = FindPattern(
9070+
mi->lpBaseOfDll,
9071+
mi->SizeOfImage,
9072+
"\xC7\x44\x24\x00\x04\x00\x00\x00\x84\xC0\x75\x08\xC7\x44\x24\x00\x01\x00\x00\x00",
9073+
"xxx?xxxxxxxxxxx?xxxx"
9074+
);
9075+
if (match && VirtualProtect(match, 8, PAGE_EXECUTE_READWRITE, &dwOldProtect))
9076+
{
9077+
*(int*)(match + 4) = 1;
9078+
VirtualProtect(match, 8, dwOldProtect, &dwOldProtect);
9079+
}
9080+
}
9081+
// TODO Revisit once forced-on
9082+
#elif defined(_M_ARM64)
9083+
// Feature flag present, target register W1 (Nickel)
9084+
// CAddressBand::ResizeToolbarButtons()
9085+
// CAddressBand::_PositionChildWindows() <- CAddressBand::ResizeToolbarButtons()
9086+
// 81 00 80 52 02 00 00 14 21 00 80 52
9087+
// xxxxxxxxxxx To 21 00 80 52
9088+
match = FindPattern(
9089+
mi->lpBaseOfDll,
9090+
mi->SizeOfImage,
9091+
"\x81\x00\x80\x52\x02\x00\x00\x14\x21\x00\x80\x52",
9092+
"xxxxxxxxxxxx"
9093+
);
9094+
if (match)
9095+
{
9096+
if (VirtualProtect(match, 4, PAGE_EXECUTE_READWRITE, &dwOldProtect))
9097+
{
9098+
*(DWORD*)(match + 0) = 0x52800021; // MOV W1, #1
9099+
VirtualProtect(match, 4, dwOldProtect, &dwOldProtect);
9100+
}
9101+
}
9102+
else
9103+
{
9104+
// Feature flag present, target register W8 (Germanium+)
9105+
// CAddressBand::ResizeToolbarButtons()
9106+
// 88 00 80 52 02 00 00 14 28 00 80 52
9107+
// xxxxxxxxxxx To 28 00 80 52
9108+
match = FindPattern(
9109+
mi->lpBaseOfDll,
9110+
mi->SizeOfImage,
9111+
"\x88\x00\x80\x52\x02\x00\x00\x14\x28\x00\x80\x52",
9112+
"xxxxxxxxxxxx"
9113+
);
9114+
if (match && VirtualProtect(match, 4, PAGE_EXECUTE_READWRITE, &dwOldProtect))
9115+
{
9116+
*(DWORD*)(match + 0) = 0x52800028; // MOV W8, #1
9117+
VirtualProtect(match, 4, dwOldProtect, &dwOldProtect);
9118+
}
9119+
}
9120+
// TODO Revisit once forced-on
9121+
#endif
90419122
}
90429123
}
9043-
#else
9044-
static void PatchAddressBarSizing(MODULEINFO* mi) {}
9045-
#endif
90469124
#pragma endregion
90479125

90489126

0 commit comments

Comments
 (0)