Skip to content

Commit

Permalink
Taskbar10: Fixed start menu/search flyout positioning code crashing E…
Browse files Browse the repository at this point in the history
…xplorer when the display resolution changes
  • Loading branch information
Amrsatrio committed Nov 18, 2023
1 parent d6cdb5d commit 7d0cdde
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 11 deletions.
45 changes: 40 additions & 5 deletions ExplorerPatcher/dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,13 @@ HRESULT WINAPI windowsudkshellcommon_SLGetWindowsInformationDWORDHook(PCWSTR pws
return hr;
}

static BOOL(*windowsudkshellcommon_TaskbarMultiMonIsEnabledFunc)(void* _this) = NULL;

bool windowsudkshellcommon_TaskbarMultiMonIsEnabledHook(void* _this)
{
return bOldTaskbar ? false : windowsudkshellcommon_TaskbarMultiMonIsEnabledFunc(_this);
}

#pragma endregion


Expand Down Expand Up @@ -12264,14 +12271,42 @@ DWORD Inject(BOOL bIsExplorer)
}

HANDLE hWindowsudkShellcommon = LoadLibraryW(L"windowsudk.shellcommon.dll");
HANDLE hSLC = LoadLibraryW(L"slc.dll");
if (hWindowsudkShellcommon && hSLC)
if (hWindowsudkShellcommon)
{
SLGetWindowsInformationDWORDFunc = GetProcAddress(hSLC, "SLGetWindowsInformationDWORD");
HANDLE hSLC = LoadLibraryW(L"slc.dll");
if (hSLC)
{
SLGetWindowsInformationDWORDFunc = GetProcAddress(hSLC, "SLGetWindowsInformationDWORD");

if (SLGetWindowsInformationDWORDFunc)
if (SLGetWindowsInformationDWORDFunc)
{
VnPatchDelayIAT(hWindowsudkShellcommon, "ext-ms-win-security-slc-l1-1-0.dll", "SLGetWindowsInformationDWORD", windowsudkshellcommon_SLGetWindowsInformationDWORDHook);
}
}

MODULEINFO mi;
GetModuleInformation(GetCurrentProcess(), hWindowsudkShellcommon, &mi, sizeof(MODULEINFO));

// Fix ReportMonitorRemoved in UpdateStartMenuPositioning crashing, *for now*
// We can't use our RtlQueryFeatureConfiguration() hook because our function didn't get called with the feature ID
// TODO Need to check again later after this feature flag has been removed
// E8 ?? ?? ?? ?? 48 8B 7D FF 84 C0 74 1F 48 8D 4F 08
PBYTE match = FindPattern(
hWindowsudkShellcommon,
mi.SizeOfImage,
"\xE8\x00\x00\x00\x00\x48\x8B\x7D\xFF\x84\xC0\x74\x1F\x48\x8D\x4F\x08",
"x????xxxxxxxxxxxx"
);
if (match)
{
VnPatchDelayIAT(hWindowsudkShellcommon, "ext-ms-win-security-slc-l1-1-0.dll", "SLGetWindowsInformationDWORD", windowsudkshellcommon_SLGetWindowsInformationDWORDHook);
match += 5 + *(int*)(match + 1);
windowsudkshellcommon_TaskbarMultiMonIsEnabledFunc = match;
printf("wil::details::FeatureImpl<__WilFeatureTraits_Feature_Servicing_TaskbarMultiMon_38545217>::__private_IsEnabled() = %llX\n", match - (PBYTE)hWindowsudkShellcommon);
rv = funchook_prepare(
funchook,
(void**)&windowsudkshellcommon_TaskbarMultiMonIsEnabledFunc,
windowsudkshellcommon_TaskbarMultiMonIsEnabledHook
);
}

printf("Setup windowsudk.shellcommon functions done\n");
Expand Down
4 changes: 2 additions & 2 deletions ExplorerPatcher/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,9 @@ BOOL(WINAPI* SetWindowBand)(HWND hWnd, HWND hwndInsertAfter, DWORD dwBand);

INT64(*SetWindowCompositionAttribute)(HWND, void*);

static void(*SetPreferredAppMode)(bool bAllowDark);
static void(*SetPreferredAppMode)(BOOL bAllowDark);

static void(*AllowDarkModeForWindow)(HWND hWnd, bool bAllowDark);
static void(*AllowDarkModeForWindow)(HWND hWnd, BOOL bAllowDark);

static bool(*ShouldAppsUseDarkMode)();

Expand Down
8 changes: 5 additions & 3 deletions ep_gui/GUI.c
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,9 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
DttOpts.crText = g_darkModeEnabled ? GUI_TEXTCOLOR_DARK : GUI_TEXTCOLOR;
DWORD dwTextFlags = DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS;
RECT rcText;
DWORD dwMaxHeight = 0, dwMaxWidth = (DWORD)(480 * (_this->dpi.x / 96.0));
DWORD dwMinWidthDp = 480;
if (!wcscmp(wszLanguage, L"nl-NL")) dwMinWidthDp = 600;
DWORD dwMaxHeight = 0, dwMaxWidth = (DWORD)(dwMinWidthDp * (_this->dpi.x / 96.0));
BOOL bTabOrderHit = FALSE;
DWORD dwLeftPad = _this->padding.left + _this->sidebarWidth + _this->padding.right;
DWORD dwInitialLeftPad = dwLeftPad;
Expand Down Expand Up @@ -3841,11 +3843,11 @@ __declspec(dllexport) int ZZGUI(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLin
ULONG ulNumLanguages = 0;
LPCWSTR wszLanguagesBuffer = NULL;
ULONG cchLanguagesBuffer = 0;
if (GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &ulNumLanguages, NULL, &cchLanguagesBuffer))
if (GetThreadPreferredUILanguages(MUI_LANGUAGE_NAME, &ulNumLanguages, NULL, &cchLanguagesBuffer))
{
if (wszLanguagesBuffer = malloc(cchLanguagesBuffer * sizeof(WCHAR)))
{
if (GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &ulNumLanguages, wszLanguagesBuffer, &cchLanguagesBuffer))
if (GetThreadPreferredUILanguages(MUI_LANGUAGE_NAME, &ulNumLanguages, wszLanguagesBuffer, &cchLanguagesBuffer))
{
wcscpy_s(wszLanguage, MAX_PATH, wszLanguagesBuffer);
bOk = TRUE;
Expand Down

0 comments on commit 7d0cdde

Please sign in to comment.