Skip to content

Commit

Permalink
Fixes #313 (unable to start when sws is enabled and Windows 10 taskba…
Browse files Browse the repository at this point in the history
…r is disabled)
  • Loading branch information
valinet committed Nov 11, 2021
1 parent 04616ce commit e02e4ae
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 28 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Tested on build 22000.318.

#### Fixes

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

## 22000.318.35

Expand Down
8 changes: 4 additions & 4 deletions ExplorerPatcher/ExplorerPatcher.rc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 22000,318,36,0
PRODUCTVERSION 22000,318,36,0
FILEVERSION 22000,318,36,1
PRODUCTVERSION 22000,318,36,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -69,12 +69,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "VALINET Solutions SRL"
VALUE "FileDescription", "ExplorerPatcher"
VALUE "FileVersion", "22000.318.36.0"
VALUE "FileVersion", "22000.318.36.1"
VALUE "InternalName", "ExplorerPatcher.dll"
VALUE "LegalCopyright", "Copyright (C) 2006-2021 VALINET Solutions SRL. All rights reserved."
VALUE "OriginalFilename", "ExplorerPatcher.dll"
VALUE "ProductName", "ExplorerPatcher"
VALUE "ProductVersion", "22000.318.36.0"
VALUE "ProductVersion", "22000.318.36.1"
END
END
BLOCK "VarFileInfo"
Expand Down
94 changes: 71 additions & 23 deletions ExplorerPatcher/dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ HANDLE hIsWinXShown = NULL;
HANDLE hWinXThread = NULL;
HANDLE hSwsSettingsChanged = NULL;
HANDLE hSwsOpacityMaybeChanged = NULL;
HANDLE hWin11AltTabInitialized = NULL;
BYTE* lpShouldDisplayCCButton = NULL;
HMONITOR hMonitorList[30];
DWORD dwMonitorCount = 0;
Expand Down Expand Up @@ -863,6 +864,11 @@ void UpdateStartMenuPositioning(LPARAM loIsShouldInitializeArray_hiIsShouldRoIni
BOOL bShouldInitialize = LOWORD(loIsShouldInitializeArray_hiIsShouldRoInitialize);
BOOL bShouldRoInitialize = HIWORD(loIsShouldInitializeArray_hiIsShouldRoInitialize);

if (!bOldTaskbar)
{
return;
}

DWORD dwPosCurrent = GetStartMenuPosition(SHRegGetValueFromHKCUHKLMFunc);
if (bShouldInitialize || InterlockedAdd(&dwTaskbarAl, 0) != dwPosCurrent)
{
Expand Down Expand Up @@ -2475,6 +2481,9 @@ void sws_ReadSettings(sws_WindowSwitcher* sws)

DWORD WindowSwitcher(DWORD unused)
{
WaitForSingleObject(hWin11AltTabInitialized, INFINITE);
Sleep(500);

while (TRUE)
{
sws_ReadSettings(NULL);
Expand Down Expand Up @@ -3122,7 +3131,7 @@ HWND CreateWindowExWHook(
{
SetWindowSubclass(hWnd, ShowDesktopSubclassProc, ShowDesktopSubclassProc, 0);
}
else if (bIsExplorerProcess && (*((WORD*)&(lpClassName)+1)) && !wcscmp(lpClassName, L"Shell_TrayWnd"))
else if (bOldTaskbar && bIsExplorerProcess && (*((WORD*)&(lpClassName)+1)) && !wcscmp(lpClassName, L"Shell_TrayWnd"))
{
SetWindowSubclass(hWnd, Shell_TrayWndSubclassProc, Shell_TrayWndSubclassProc, 0);
}
Expand Down Expand Up @@ -3769,6 +3778,38 @@ LSTATUS explorer_RegGetValueW(
return lRes;
}

LSTATUS twinuipcshell_RegGetValueW(
HKEY hkey,
LPCWSTR lpSubKey,
LPCWSTR lpValue,
DWORD dwFlags,
LPDWORD pdwType,
PVOID pvData,
LPDWORD pcbData
)
{
LSTATUS lRes = RegGetValueW(hkey, lpSubKey, lpValue, dwFlags, pdwType, pvData, pcbData);

if (!lstrcmpW(lpValue, L"AltTabSettings"))
{
if (*(DWORD*)pvData)
{
*(DWORD*)pvData = 1;
}

if (hWin11AltTabInitialized)
{
SetEvent(hWin11AltTabInitialized);
CloseHandle(hWin11AltTabInitialized);
hWin11AltTabInitialized = NULL;
}

lRes = ERROR_SUCCESS;
}

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);
Expand Down Expand Up @@ -4115,6 +4156,7 @@ __declspec(dllexport) DWORD WINAPI main(
#ifdef _WIN64
if (bIsExplorer)
{
hWin11AltTabInitialized = CreateEventW(NULL, FALSE, FALSE, NULL);
CreateThread(
0,
0,
Expand Down Expand Up @@ -4165,10 +4207,10 @@ __declspec(dllexport) DWORD WINAPI main(

HANDLE hExplorer = GetModuleHandleW(NULL);
SetChildWindowNoActivateFunc = GetProcAddress(GetModuleHandleW(L"user32.dll"), (LPCSTR)2005);
VnPatchIAT(hExplorer, "user32.dll", (LPCSTR)2005, explorer_SetChildWindowNoActivateHook);
VnPatchDelayIAT(hExplorer, "ext-ms-win-rtcore-ntuser-window-ext-l1-1-0.dll", "SendMessageW", explorer_SendMessageW);
if (bOldTaskbar)
{
VnPatchIAT(hExplorer, "user32.dll", (LPCSTR)2005, explorer_SetChildWindowNoActivateHook);
VnPatchDelayIAT(hExplorer, "ext-ms-win-rtcore-ntuser-window-ext-l1-1-0.dll", "SendMessageW", explorer_SendMessageW);
VnPatchIAT(hExplorer, "api-ms-win-core-libraryloader-l1-2-0.dll", "GetProcAddress", explorer_GetProcAddressHook);
VnPatchIAT(hExplorer, "shell32.dll", "ShellExecuteW", explorer_ShellExecuteW);
VnPatchIAT(hExplorer, "API-MS-WIN-CORE-REGISTRY-L1-1-0.DLL", "RegGetValueW", explorer_RegGetValueW);
Expand Down Expand Up @@ -4197,7 +4239,7 @@ __declspec(dllexport) DWORD WINAPI main(
VnPatchIAT(hExplorer, "user32.dll", "SetWindowCompositionAttribute", explorer_SetWindowCompositionAttribute);
}
//VnPatchDelayIAT(hExplorer, "ext-ms-win-rtcore-ntuser-window-ext-l1-1-0.dll", "CreateWindowExW", explorer_CreateWindowExW);
if (dwIMEStyle)
if (bOldTaskbar && dwIMEStyle)
{
VnPatchIAT(hExplorer, "api-ms-win-core-com-l1-1-0.dll", "CoCreateInstance", explorer_CoCreateInstanceHook);
}
Expand Down Expand Up @@ -4309,6 +4351,7 @@ __declspec(dllexport) DWORD WINAPI main(
}
}
}
VnPatchIAT(hTwinuiPcshell, "API-MS-WIN-CORE-REGISTRY-L1-1-0.DLL", "RegGetValueW", twinuipcshell_RegGetValueW);
printf("Setup twinui.pcshell functions done\n");


Expand Down Expand Up @@ -4386,27 +4429,32 @@ __declspec(dllexport) DWORD WINAPI main(
ResetEvent(hEvent);
}*/


CreateThread(
0,
0,
PlayStartupSound,
0,
0,
0
);
printf("Play startup sound thread...\n");
if (bOldTaskbar)
{
CreateThread(
0,
0,
PlayStartupSound,
0,
0,
0
);
printf("Play startup sound thread...\n");
}


CreateThread(
0,
0,
SignalShellReady,
dwExplorerReadyDelay,
0,
0
);
printf("Signal shell ready...\n");
if (bOldTaskbar)
{
CreateThread(
0,
0,
SignalShellReady,
dwExplorerReadyDelay,
0,
0
);
printf("Signal shell ready...\n");
}


CreateThread(
Expand Down

0 comments on commit e02e4ae

Please sign in to comment.