Browse Source

Taskbar10: Fixed start menu/search flyout positioning code crashing Explorer when the display resolution changes

pull/2488/head
Amrsatrio 2 years ago
parent
commit
7d0cdde356
  1. 2
      ExplorerPatcher-L10N
  2. 45
      ExplorerPatcher/dllmain.c
  3. 4
      ExplorerPatcher/utility.h
  4. 8
      ep_gui/GUI.c

2
ExplorerPatcher-L10N

@ -1 +1 @@
Subproject commit 6012fe38c9220ebfc685e3a2f65ea6d8262717a5 Subproject commit d09fb3722cda34c082a1bb2645224a85af1d27e8

45
ExplorerPatcher/dllmain.c

@ -1079,6 +1079,13 @@ HRESULT WINAPI windowsudkshellcommon_SLGetWindowsInformationDWORDHook(PCWSTR pws
return hr; return hr;
} }
static BOOL(*windowsudkshellcommon_TaskbarMultiMonIsEnabledFunc)(void* _this) = NULL;
bool windowsudkshellcommon_TaskbarMultiMonIsEnabledHook(void* _this)
{
return bOldTaskbar ? false : windowsudkshellcommon_TaskbarMultiMonIsEnabledFunc(_this);
}
#pragma endregion #pragma endregion
@ -12264,14 +12271,42 @@ DWORD Inject(BOOL bIsExplorer)
} }
HANDLE hWindowsudkShellcommon = LoadLibraryW(L"windowsudk.shellcommon.dll"); HANDLE hWindowsudkShellcommon = LoadLibraryW(L"windowsudk.shellcommon.dll");
HANDLE hSLC = LoadLibraryW(L"slc.dll"); if (hWindowsudkShellcommon)
if (hWindowsudkShellcommon && hSLC)
{ {
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"); printf("Setup windowsudk.shellcommon functions done\n");

4
ExplorerPatcher/utility.h

@ -368,9 +368,9 @@ BOOL(WINAPI* SetWindowBand)(HWND hWnd, HWND hwndInsertAfter, DWORD dwBand);
INT64(*SetWindowCompositionAttribute)(HWND, void*); 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)(); static bool(*ShouldAppsUseDarkMode)();

8
ep_gui/GUI.c

@ -1002,7 +1002,9 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
DttOpts.crText = g_darkModeEnabled ? GUI_TEXTCOLOR_DARK : GUI_TEXTCOLOR; DttOpts.crText = g_darkModeEnabled ? GUI_TEXTCOLOR_DARK : GUI_TEXTCOLOR;
DWORD dwTextFlags = DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS; DWORD dwTextFlags = DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS;
RECT rcText; 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; BOOL bTabOrderHit = FALSE;
DWORD dwLeftPad = _this->padding.left + _this->sidebarWidth + _this->padding.right; DWORD dwLeftPad = _this->padding.left + _this->sidebarWidth + _this->padding.right;
DWORD dwInitialLeftPad = dwLeftPad; DWORD dwInitialLeftPad = dwLeftPad;
@ -3841,11 +3843,11 @@ __declspec(dllexport) int ZZGUI(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLin
ULONG ulNumLanguages = 0; ULONG ulNumLanguages = 0;
LPCWSTR wszLanguagesBuffer = NULL; LPCWSTR wszLanguagesBuffer = NULL;
ULONG cchLanguagesBuffer = 0; 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 (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); wcscpy_s(wszLanguage, MAX_PATH, wszLanguagesBuffer);
bOk = TRUE; bOk = TRUE;

Loading…
Cancel
Save