Skip to content

Commit e02e4ae

Browse files
committed
Fixes #313 (unable to start when sws is enabled and Windows 10 taskbar is disabled)
1 parent 04616ce commit e02e4ae

File tree

3 files changed

+77
-28
lines changed

3 files changed

+77
-28
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ Tested on build 22000.318.
88

99
#### Fixes
1010

11-
* Lots of bug and issue fixes for shell extension failing to work under certain circumstances; fixed #259
11+
* Fixes an issue that prevented Explorer from starting up when Windows 10 taskbar was disabled and Windows 10 window switcher was enabled (#313) (.1)
12+
* Lots of bug and issue fixes for shell extension failing to work under certain circumstances (#259)
1213

1314
## 22000.318.35
1415

ExplorerPatcher/ExplorerPatcher.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ END
5151
//
5252

5353
VS_VERSION_INFO VERSIONINFO
54-
FILEVERSION 22000,318,36,0
55-
PRODUCTVERSION 22000,318,36,0
54+
FILEVERSION 22000,318,36,1
55+
PRODUCTVERSION 22000,318,36,1
5656
FILEFLAGSMASK 0x3fL
5757
#ifdef _DEBUG
5858
FILEFLAGS 0x1L
@@ -69,12 +69,12 @@ BEGIN
6969
BEGIN
7070
VALUE "CompanyName", "VALINET Solutions SRL"
7171
VALUE "FileDescription", "ExplorerPatcher"
72-
VALUE "FileVersion", "22000.318.36.0"
72+
VALUE "FileVersion", "22000.318.36.1"
7373
VALUE "InternalName", "ExplorerPatcher.dll"
7474
VALUE "LegalCopyright", "Copyright (C) 2006-2021 VALINET Solutions SRL. All rights reserved."
7575
VALUE "OriginalFilename", "ExplorerPatcher.dll"
7676
VALUE "ProductName", "ExplorerPatcher"
77-
VALUE "ProductVersion", "22000.318.36.0"
77+
VALUE "ProductVersion", "22000.318.36.1"
7878
END
7979
END
8080
BLOCK "VarFileInfo"

ExplorerPatcher/dllmain.c

Lines changed: 71 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ HANDLE hIsWinXShown = NULL;
7575
HANDLE hWinXThread = NULL;
7676
HANDLE hSwsSettingsChanged = NULL;
7777
HANDLE hSwsOpacityMaybeChanged = NULL;
78+
HANDLE hWin11AltTabInitialized = NULL;
7879
BYTE* lpShouldDisplayCCButton = NULL;
7980
HMONITOR hMonitorList[30];
8081
DWORD dwMonitorCount = 0;
@@ -863,6 +864,11 @@ void UpdateStartMenuPositioning(LPARAM loIsShouldInitializeArray_hiIsShouldRoIni
863864
BOOL bShouldInitialize = LOWORD(loIsShouldInitializeArray_hiIsShouldRoInitialize);
864865
BOOL bShouldRoInitialize = HIWORD(loIsShouldInitializeArray_hiIsShouldRoInitialize);
865866

867+
if (!bOldTaskbar)
868+
{
869+
return;
870+
}
871+
866872
DWORD dwPosCurrent = GetStartMenuPosition(SHRegGetValueFromHKCUHKLMFunc);
867873
if (bShouldInitialize || InterlockedAdd(&dwTaskbarAl, 0) != dwPosCurrent)
868874
{
@@ -2475,6 +2481,9 @@ void sws_ReadSettings(sws_WindowSwitcher* sws)
24752481

24762482
DWORD WindowSwitcher(DWORD unused)
24772483
{
2484+
WaitForSingleObject(hWin11AltTabInitialized, INFINITE);
2485+
Sleep(500);
2486+
24782487
while (TRUE)
24792488
{
24802489
sws_ReadSettings(NULL);
@@ -3122,7 +3131,7 @@ HWND CreateWindowExWHook(
31223131
{
31233132
SetWindowSubclass(hWnd, ShowDesktopSubclassProc, ShowDesktopSubclassProc, 0);
31243133
}
3125-
else if (bIsExplorerProcess && (*((WORD*)&(lpClassName)+1)) && !wcscmp(lpClassName, L"Shell_TrayWnd"))
3134+
else if (bOldTaskbar && bIsExplorerProcess && (*((WORD*)&(lpClassName)+1)) && !wcscmp(lpClassName, L"Shell_TrayWnd"))
31263135
{
31273136
SetWindowSubclass(hWnd, Shell_TrayWndSubclassProc, Shell_TrayWndSubclassProc, 0);
31283137
}
@@ -3769,6 +3778,38 @@ LSTATUS explorer_RegGetValueW(
37693778
return lRes;
37703779
}
37713780

3781+
LSTATUS twinuipcshell_RegGetValueW(
3782+
HKEY hkey,
3783+
LPCWSTR lpSubKey,
3784+
LPCWSTR lpValue,
3785+
DWORD dwFlags,
3786+
LPDWORD pdwType,
3787+
PVOID pvData,
3788+
LPDWORD pcbData
3789+
)
3790+
{
3791+
LSTATUS lRes = RegGetValueW(hkey, lpSubKey, lpValue, dwFlags, pdwType, pvData, pcbData);
3792+
3793+
if (!lstrcmpW(lpValue, L"AltTabSettings"))
3794+
{
3795+
if (*(DWORD*)pvData)
3796+
{
3797+
*(DWORD*)pvData = 1;
3798+
}
3799+
3800+
if (hWin11AltTabInitialized)
3801+
{
3802+
SetEvent(hWin11AltTabInitialized);
3803+
CloseHandle(hWin11AltTabInitialized);
3804+
hWin11AltTabInitialized = NULL;
3805+
}
3806+
3807+
lRes = ERROR_SUCCESS;
3808+
}
3809+
3810+
return lRes;
3811+
}
3812+
37723813
BOOL CALLBACK GetMonitorByIndex(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, RECT* rc)
37733814
{
37743815
//printf(">> %d %d %d %d\n", lprcMonitor->left, lprcMonitor->top, lprcMonitor->right, lprcMonitor->bottom);
@@ -4115,6 +4156,7 @@ __declspec(dllexport) DWORD WINAPI main(
41154156
#ifdef _WIN64
41164157
if (bIsExplorer)
41174158
{
4159+
hWin11AltTabInitialized = CreateEventW(NULL, FALSE, FALSE, NULL);
41184160
CreateThread(
41194161
0,
41204162
0,
@@ -4165,10 +4207,10 @@ __declspec(dllexport) DWORD WINAPI main(
41654207

41664208
HANDLE hExplorer = GetModuleHandleW(NULL);
41674209
SetChildWindowNoActivateFunc = GetProcAddress(GetModuleHandleW(L"user32.dll"), (LPCSTR)2005);
4168-
VnPatchIAT(hExplorer, "user32.dll", (LPCSTR)2005, explorer_SetChildWindowNoActivateHook);
4169-
VnPatchDelayIAT(hExplorer, "ext-ms-win-rtcore-ntuser-window-ext-l1-1-0.dll", "SendMessageW", explorer_SendMessageW);
41704210
if (bOldTaskbar)
41714211
{
4212+
VnPatchIAT(hExplorer, "user32.dll", (LPCSTR)2005, explorer_SetChildWindowNoActivateHook);
4213+
VnPatchDelayIAT(hExplorer, "ext-ms-win-rtcore-ntuser-window-ext-l1-1-0.dll", "SendMessageW", explorer_SendMessageW);
41724214
VnPatchIAT(hExplorer, "api-ms-win-core-libraryloader-l1-2-0.dll", "GetProcAddress", explorer_GetProcAddressHook);
41734215
VnPatchIAT(hExplorer, "shell32.dll", "ShellExecuteW", explorer_ShellExecuteW);
41744216
VnPatchIAT(hExplorer, "API-MS-WIN-CORE-REGISTRY-L1-1-0.DLL", "RegGetValueW", explorer_RegGetValueW);
@@ -4197,7 +4239,7 @@ __declspec(dllexport) DWORD WINAPI main(
41974239
VnPatchIAT(hExplorer, "user32.dll", "SetWindowCompositionAttribute", explorer_SetWindowCompositionAttribute);
41984240
}
41994241
//VnPatchDelayIAT(hExplorer, "ext-ms-win-rtcore-ntuser-window-ext-l1-1-0.dll", "CreateWindowExW", explorer_CreateWindowExW);
4200-
if (dwIMEStyle)
4242+
if (bOldTaskbar && dwIMEStyle)
42014243
{
42024244
VnPatchIAT(hExplorer, "api-ms-win-core-com-l1-1-0.dll", "CoCreateInstance", explorer_CoCreateInstanceHook);
42034245
}
@@ -4309,6 +4351,7 @@ __declspec(dllexport) DWORD WINAPI main(
43094351
}
43104352
}
43114353
}
4354+
VnPatchIAT(hTwinuiPcshell, "API-MS-WIN-CORE-REGISTRY-L1-1-0.DLL", "RegGetValueW", twinuipcshell_RegGetValueW);
43124355
printf("Setup twinui.pcshell functions done\n");
43134356

43144357

@@ -4386,27 +4429,32 @@ __declspec(dllexport) DWORD WINAPI main(
43864429
ResetEvent(hEvent);
43874430
}*/
43884431

4389-
4390-
CreateThread(
4391-
0,
4392-
0,
4393-
PlayStartupSound,
4394-
0,
4395-
0,
4396-
0
4397-
);
4398-
printf("Play startup sound thread...\n");
4432+
if (bOldTaskbar)
4433+
{
4434+
CreateThread(
4435+
0,
4436+
0,
4437+
PlayStartupSound,
4438+
0,
4439+
0,
4440+
0
4441+
);
4442+
printf("Play startup sound thread...\n");
4443+
}
43994444

44004445

4401-
CreateThread(
4402-
0,
4403-
0,
4404-
SignalShellReady,
4405-
dwExplorerReadyDelay,
4406-
0,
4407-
0
4408-
);
4409-
printf("Signal shell ready...\n");
4446+
if (bOldTaskbar)
4447+
{
4448+
CreateThread(
4449+
0,
4450+
0,
4451+
SignalShellReady,
4452+
dwExplorerReadyDelay,
4453+
0,
4454+
0
4455+
);
4456+
printf("Signal shell ready...\n");
4457+
}
44104458

44114459

44124460
CreateThread(

0 commit comments

Comments
 (0)