diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 3b0f81d..b4a9962 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -65,7 +65,6 @@ DWORD bClassicThemeMitigations = FALSE; DWORD bHookStartMenu = TRUE; DWORD bPropertiesInWinX = FALSE; DWORD bNoMenuAccelerator = FALSE; -DWORD bTaskbarMonitorOverride = 0; DWORD dwIMEStyle = 0; DWORD dwTaskbarAl = 1; DWORD bShowUpdateToast = FALSE; @@ -3753,15 +3752,6 @@ void WINAPI LoadSettings(BOOL bIsExplorer) &dwSize ); dwSize = sizeof(DWORD); - RegQueryValueExW( - hKey, - TEXT("TaskbarMonitorOverride"), - 0, - NULL, - &bTaskbarMonitorOverride, - &dwSize - ); - dwSize = sizeof(DWORD); RegQueryValueExW( hKey, TEXT("IMEStyle"), @@ -4938,42 +4928,6 @@ LSTATUS twinuipcshell_RegGetValueW( return lRes; } -BOOL CALLBACK GetMonitorByIndex(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, RECT* rc) -{ - //printf(">> %d %d %d %d\n", lprcMonitor->left, lprcMonitor->top, lprcMonitor->right, lprcMonitor->bottom); - if (--rc->left < 0) - { - *rc = *lprcMonitor; - return FALSE; - } - return TRUE; -} - -HMONITOR explorer_MonitorFromRect(LPCRECT lprc, DWORD dwFlags) -{ - /*printf("%d %d %d %d\n", lprc->left, lprc->top, lprc->right, lprc->bottom); - - return MonitorFromRect(lprc, dwFlags); - //}*/ - if (bTaskbarMonitorOverride) - { - RECT rc; - ZeroMemory(&rc, sizeof(RECT)); - rc.left = bTaskbarMonitorOverride - 1; - EnumDisplayMonitors( - NULL, - NULL, - GetMonitorByIndex, - &rc - ); - if (rc.top != rc.bottom) - { - return MonitorFromRect(&rc, dwFlags); - } - } - return MonitorFromRect(lprc, dwFlags); -} - HRESULT (*explorer_SHCreateStreamOnModuleResourceWFunc)( HMODULE hModule, LPCWSTR pwszName, @@ -5084,6 +5038,92 @@ HRESULT WINAPI explorer_SHCreateStreamOnModuleResourceWHook( #pragma endregion +#pragma region "Remember primary taskbar positioning" +BOOL bTaskbarFirstTimePositioning = FALSE; +BOOL bTaskbarSet = FALSE; + +BOOL explorer_SetRect(LPRECT lprc, int xLeft, int yTop, int xRight, int yBottom) +{ + BOOL bIgnore = FALSE; + if (bTaskbarFirstTimePositioning) + { + bIgnore = bTaskbarSet; + } + else + { + bTaskbarFirstTimePositioning = TRUE; + bIgnore = (GetSystemMetrics(SM_CMONITORS) == 1); + bTaskbarSet = bIgnore; + } + + if (bIgnore) + { + return SetRect(lprc, xLeft, yTop, xRight, yBottom); + } + if (xLeft) + { + return SetRect(lprc, xLeft, yTop, xRight, yBottom); + } + if (yTop) + { + return SetRect(lprc, xLeft, yTop, xRight, yBottom); + } + if (xRight != GetSystemMetrics(SM_CXSCREEN)) + { + return SetRect(lprc, xLeft, yTop, xRight, yBottom); + } + if (yBottom != GetSystemMetrics(SM_CYSCREEN)) + { + return SetRect(lprc, xLeft, yTop, xRight, yBottom); + } + + bTaskbarSet = TRUE; + + StuckRectsData srd; + DWORD pcbData = sizeof(StuckRectsData); + RegGetValueW( + HKEY_CURRENT_USER, + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StuckRectsLegacy", + L"Settings", + REG_BINARY, + NULL, + &srd, + &pcbData); + + if (pcbData != sizeof(StuckRectsData)) + { + return SetRect(lprc, xLeft, yTop, xRight, yBottom); + } + + if (srd.pvData[0] != sizeof(StuckRectsData)) + { + return SetRect(lprc, xLeft, yTop, xRight, yBottom); + } + + if (srd.pvData[1] != -2) + { + return SetRect(lprc, xLeft, yTop, xRight, yBottom); + } + + HMONITOR hMonitor = MonitorFromRect(&(srd.rc), MONITOR_DEFAULTTOPRIMARY); + MONITORINFO mi; + ZeroMemory(&mi, sizeof(MONITORINFO)); + mi.cbSize = sizeof(MONITORINFO); + if (!GetMonitorInfoW(hMonitor, &mi)) + { + return SetRect(lprc, xLeft, yTop, xRight, yBottom); + } + + if (lprc) + { + *lprc = mi.rcMonitor; + return TRUE; + } + + return FALSE; +} +#pragma endregion + DWORD InjectBasicFunctions(BOOL bIsExplorer, BOOL bInstall) { //Sleep(150); @@ -5452,7 +5492,6 @@ DWORD Inject(BOOL bIsExplorer) VnPatchIAT(hExplorer, "API-MS-WIN-CORE-REGISTRY-L1-1-0.DLL", "RegSetValueExW", explorer_RegSetValueExW); VnPatchIAT(hExplorer, "API-MS-WIN-CORE-REGISTRY-L1-1-0.DLL", "RegCreateKeyExW", explorer_RegCreateKeyExW); VnPatchIAT(hExplorer, "API-MS-WIN-SHCORE-REGISTRY-L1-1-0.DLL", "SHGetValueW", explorer_SHGetValueW); - VnPatchIAT(hExplorer, "user32.dll", "MonitorFromRect", explorer_MonitorFromRect); VnPatchIAT(hExplorer, "user32.dll", "LoadMenuW", explorer_LoadMenuW); } VnPatchIAT(hExplorer, "API-MS-WIN-CORE-REGISTRY-L1-1-0.DLL", "RegOpenKeyExW", explorer_RegOpenKeyExW); @@ -5485,6 +5524,10 @@ DWORD Inject(BOOL bIsExplorer) { VnPatchIAT(hExplorer, "api-ms-win-core-com-l1-1-0.dll", "CoCreateInstance", explorer_CoCreateInstanceHook); } + if (bOldTaskbar) + { + VnPatchIAT(hExplorer, "API-MS-WIN-NTUSER-RECTANGLE-L1-1-0.DLL", "SetRect", explorer_SetRect); + } #ifdef USE_PRIVATE_INTERFACES diff --git a/ExplorerPatcher/settings.reg b/ExplorerPatcher/settings.reg index 68e63cc..c49c9c2 100644 --- a/ExplorerPatcher/settings.reg +++ b/ExplorerPatcher/settings.reg @@ -384,31 +384,6 @@ ;x 8000 8 seconds ;x 10000 10 seconds "ExplorerReadyDelay"=dword:00000000 -[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher] -;a Only change the following option if you have a single taskbar !!! -;c 21 Always show main taskbar on this monitor * (not working) -;x 0 Primary (default) -;x 1 1 -;x 2 2 -;x 3 3 -;x 4 4 -;x 5 5 -;x 6 6 -;x 7 7 -;x 8 8 -;x 9 9 -;x 10 10 -;x 11 11 -;x 12 12 -;x 13 13 -;x 14 14 -;x 15 15 -;x 16 16 -;x 17 17 -;x 18 18 -;x 19 19 -;x 20 20 -"TaskbarMonitorOverride"=dword:00000000 ;t ________________________ ;e Only change these settings after reading the documentation about them. ;y Learn more 🡕