Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taskbar height and icon size v1.2.11 #875

Merged
merged 1 commit into from
Aug 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 60 additions & 19 deletions mods/taskbar-icon-size.wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @id taskbar-icon-size
// @name Taskbar height and icon size
// @description Control the taskbar height and icon size, improve icon quality (Windows 11 only)
// @version 1.2.10
// @version 1.2.11
// @author m417z
// @github https://github.com/m417z
// @twitter https://twitter.com/m417z
Expand Down Expand Up @@ -395,27 +395,29 @@ SystemTrayController_UpdateFrameSize_t
void WINAPI SystemTrayController_UpdateFrameSize_Hook(void* pThis) {
Wh_Log(L">");

// Find the last height offset and reset the height value.
//
// 66 0f 2e b3 b0 00 00 00 UCOMISD uVar4,qword ptr [RBX + 0xb0]
// 7a 4c JP LAB_180075641
// 75 4a JNZ LAB_180075641

DWORD lastHeightOffset = 0;
const BYTE* start =
(const BYTE*)SystemTrayController_UpdateFrameSize_SymbolAddress;
const BYTE* end = start + 0x200;
for (const BYTE* p = start; p != end; p++) {
if (p[0] == 0x66 && p[1] == 0x0F && p[2] == 0x2E && p[3] == 0xB3 &&
p[8] == 0x7A && p[10] == 0x75) {
lastHeightOffset = *(DWORD*)(p + 4);
break;
static LONG lastHeightOffset = []() -> LONG {
// Find the last height offset and reset the height value.
//
// 66 0f 2e b3 b0 00 00 00 UCOMISD uVar4,qword ptr [RBX + 0xb0]
// 7a 4c JP LAB_180075641
// 75 4a JNZ LAB_180075641
const BYTE* start =
(const BYTE*)SystemTrayController_UpdateFrameSize_SymbolAddress;
const BYTE* end = start + 0x200;
for (const BYTE* p = start; p != end; p++) {
if (p[0] == 0x66 && p[1] == 0x0F && p[2] == 0x2E && p[3] == 0xB3 &&
p[8] == 0x7A && p[10] == 0x75) {
LONG offset = *(LONG*)(p + 4);
Wh_Log(L"lastHeightOffset=0x%X", offset);
return offset;
}
}
}

Wh_Log(L"lastHeightOffset=0x%X", lastHeightOffset);
Wh_Log(L"lastHeightOffset not found");
return 0;
}();

if (lastHeightOffset) {
if (lastHeightOffset > 0) {
*(double*)((BYTE*)pThis + lastHeightOffset) = 0;
}

Expand All @@ -426,6 +428,23 @@ void WINAPI SystemTrayController_UpdateFrameSize_Hook(void* pThis) {
g_inSystemTrayController_UpdateFrameSize = false;
}

using TaskbarFrame_MaxHeight_double_t = void(WINAPI*)(void* pThis,
double value);
TaskbarFrame_MaxHeight_double_t TaskbarFrame_MaxHeight_double_Original;

using TaskbarFrame_Height_double_t = void(WINAPI*)(void* pThis, double value);
TaskbarFrame_Height_double_t TaskbarFrame_Height_double_Original;
void WINAPI TaskbarFrame_Height_double_Hook(void* pThis, double value) {
Wh_Log(L">");

if (TaskbarFrame_MaxHeight_double_Original) {
TaskbarFrame_MaxHeight_double_Original(
pThis, std::numeric_limits<double>::infinity());
}

return TaskbarFrame_Height_double_Original(pThis, value);
}

using SystemTraySecondaryController_UpdateFrameSize_t =
void(WINAPI*)(void* pThis);
SystemTraySecondaryController_UpdateFrameSize_t
Expand Down Expand Up @@ -1303,6 +1322,28 @@ bool HookTaskbarViewDllSymbols(HMODULE module) {
nullptr, // Hooked manually, we need the symbol address.
true, // Missing in older Windows 11 versions.
},
{
{
LR"(public: __cdecl winrt::impl::consume_Windows_UI_Xaml_IFrameworkElement<struct winrt::Taskbar::implementation::TaskbarFrame>::MaxHeight(double)const )",
LR"(public: __cdecl winrt::impl::consume_Windows_UI_Xaml_IFrameworkElement<struct winrt::Taskbar::implementation::TaskbarFrame>::MaxHeight(double)const __ptr64)",
},
(void**)&TaskbarFrame_MaxHeight_double_Original,
nullptr,
true, // From Windows 11 version 22H2.
},
{
{
LR"(public: __cdecl winrt::impl::consume_Windows_UI_Xaml_IFrameworkElement<struct winrt::Taskbar::implementation::TaskbarFrame>::Height(double)const )",
LR"(public: __cdecl winrt::impl::consume_Windows_UI_Xaml_IFrameworkElement<struct winrt::Taskbar::implementation::TaskbarFrame>::Height(double)const __ptr64)",

// Windows 11 version 21H2.
LR"(public: void __cdecl winrt::impl::consume_Windows_UI_Xaml_IFrameworkElement<struct winrt::Taskbar::implementation::TaskbarFrame>::Height(double)const )",
LR"(public: void __cdecl winrt::impl::consume_Windows_UI_Xaml_IFrameworkElement<struct winrt::Taskbar::implementation::TaskbarFrame>::Height(double)const __ptr64)",
},
(void**)&TaskbarFrame_Height_double_Original,
(void*)TaskbarFrame_Height_double_Hook,
true, // Gone in Windows 11 version 24H2.
},
{
{
LR"(private: void __cdecl winrt::SystemTray::implementation::SystemTraySecondaryController::UpdateFrameSize(void))",
Expand Down