From 9e7b6032bf03e34eccb153e3ad7c636db3688b42 Mon Sep 17 00:00:00 2001 From: lordmilko Date: Wed, 23 Mar 2022 20:04:00 +1100 Subject: [PATCH] Other: Add support for disabling Aero Snap Quadrants on Windows 11 --- ExplorerPatcher/dllmain.c | 42 ++++++++++++++++++++++++++++++++++++ ExplorerPatcher/settings.reg | 3 +++ 2 files changed, 45 insertions(+) diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index b2808bd..ba709b0 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -92,6 +92,7 @@ DWORD bTaskbarAutohideOnDoubleClick = FALSE; DWORD dwOrbStyle = 0; DWORD bEnableSymbolDownload = TRUE; DWORD dwAltTabSettings = 0; +DWORD bDisableAeroSnapQuadrants = FALSE; DWORD dwSnapAssistSettings = 0; DWORD dwStartShowClassicMode = 0; BOOL bDoNotRedirectSystemToSettingsApp = FALSE; @@ -1023,6 +1024,23 @@ void ToggleLauncherTipContextMenu() #pragma endregion +#pragma region "windowsudk.shellcommon Hooks" + +static HRESULT(WINAPI *SLGetWindowsInformationDWORDFunc)(PCWSTR pwszValueName, DWORD* pdwValue) = NULL; + +HRESULT WINAPI windowsudkshellcommon_SLGetWindowsInformationDWORDHook(PCWSTR pwszValueName, DWORD* pdwValue) +{ + HRESULT hr = SLGetWindowsInformationDWORDFunc(pwszValueName, pdwValue); + + if (bDisableAeroSnapQuadrants && !wcsncmp(pwszValueName, L"Shell-Windowing-LimitSnappedWindows", 35)) + *pdwValue = 1; + + return hr; +} + +#pragma endregion + + #pragma region "twinui.pcshell.dll hooks" #ifdef _WIN64 #define LAUNCHERTIP_CLASS_NAME L"LauncherTipWnd" @@ -6166,6 +6184,16 @@ void WINAPI LoadSettings(LPARAM lParam) LaunchPropertiesGUI(hModule); #endif } + + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("DisableAeroSnapQuadrants"), + 0, + NULL, + &bDisableAeroSnapQuadrants, + &dwSize + ); dwSize = sizeof(DWORD); RegQueryValueExW( hKey, @@ -9475,6 +9503,20 @@ DWORD Inject(BOOL bIsExplorer) VnPatchIAT(hInputSwitch, "user32.dll", "TrackPopupMenuEx", inputswitch_TrackPopupMenuExHook); printf("Setup inputswitch functions done\n"); } + + HANDLE hWindowsudkShellcommon = LoadLibraryW(L"windowsudk.shellcommon.dll"); + HANDLE hSLC = LoadLibraryW(L"slc.dll"); + if (hWindowsudkShellcommon && hSLC) + { + SLGetWindowsInformationDWORDFunc = GetProcAddress(hSLC, "SLGetWindowsInformationDWORD"); + + if (SLGetWindowsInformationDWORDFunc) + { + VnPatchDelayIAT(hWindowsudkShellcommon, "ext-ms-win-security-slc-l1-1-0.dll", "SLGetWindowsInformationDWORD", windowsudkshellcommon_SLGetWindowsInformationDWORDHook); + } + + printf("Setup windowsudk.shellcommon functions done\n"); + } } diff --git a/ExplorerPatcher/settings.reg b/ExplorerPatcher/settings.reg index 889bd6e..d85413c 100644 --- a/ExplorerPatcher/settings.reg +++ b/ExplorerPatcher/settings.reg @@ -537,6 +537,9 @@ ;x 4 Restart "Start_PowerButtonAction"=dword:00000002 [HKEY_CURRENT_USER\Software\ExplorerPatcher] +;b Disable Window Snap Quadrants +"DisableAeroSnapQuadrants"=dword:00000000 +[HKEY_CURRENT_USER\Software\ExplorerPatcher] ;c 2 Snap Assist style ;x 0 Windows 11 (default) ;x 3 Windows 10