From b2ac6991c22c438f48ee88ee9bd3a7596908050f Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Fri, 15 Oct 2021 13:50:52 +0300 Subject: [PATCH] Update to .30 --- .gitmodules | 3 + CHANGELOG.md | 16 + ExplorerPatcher/ExplorerPatcher.rc | 8 +- ExplorerPatcher/ExplorerPatcher.vcxproj | 15 + .../ExplorerPatcher.vcxproj.filters | 75 +- ExplorerPatcher/GUI.c | 298 +++- ExplorerPatcher/GUI.h | 13 +- ExplorerPatcher/SettingsMonitor.c | 392 +---- ExplorerPatcher/SettingsMonitor.h | 18 +- ExplorerPatcher/StartMenu.c | 18 +- ExplorerPatcher/StartMenu.h | 3 + ExplorerPatcher/TaskbarCenter.c | 21 +- ExplorerPatcher/TaskbarCenter.h | 2 + ExplorerPatcher/dllmain.c | 1335 +++++++++++++---- ExplorerPatcher/settings.reg | 178 ++- ExplorerPatcher/utility.c | 6 +- README.md | 191 +-- libs/sws | 1 + 18 files changed, 1726 insertions(+), 867 deletions(-) create mode 160000 libs/sws diff --git a/.gitmodules b/.gitmodules index 367508e..997fac9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "libs/Detours"] path = libs/Detours url = https://github.com/microsoft/Detours +[submodule "libs/sws"] + path = libs/sws + url = https://github.com/valinet/sws diff --git a/CHANGELOG.md b/CHANGELOG.md index b7f0aff..db03420 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,22 @@ This document includes the same release notes as in the [Releases](https://github.com/valinet/ExplorerPatcher/releases) section on GitHub. +## 22000.258.30.0 + +Tested on build: 22000.258. + +* Reworked settings framework + * More settings are available to customize + * Most setting changes take effect immediatly +* Implemented Windows 10 window switcher (Alt+Tab) +* GUI + * Revamped GUI, now the interface is split by categories and is displayed on two columns + * Regular items do not display a "+" sign anymore at the beginning of their label + * The current choice is ticked in the drop down menu + * Regions are now calculated correctly + * Solved memory leaks +* General bug fixes + ## 22000.258.26.3 Tested on build: 22000.258. diff --git a/ExplorerPatcher/ExplorerPatcher.rc b/ExplorerPatcher/ExplorerPatcher.rc index 337daf2..e41767c 100644 --- a/ExplorerPatcher/ExplorerPatcher.rc +++ b/ExplorerPatcher/ExplorerPatcher.rc @@ -51,8 +51,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 22000,258,26,3 - PRODUCTVERSION 22000,258,26,3 + FILEVERSION 22000,258,30,0 + PRODUCTVERSION 22000,258,30,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -69,12 +69,12 @@ BEGIN BEGIN VALUE "CompanyName", "VALINET Solutions SRL" VALUE "FileDescription", "ExplorerPatcher" - VALUE "FileVersion", "22000.258.26.3" + VALUE "FileVersion", "22000.258.30.0" 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.258.26.3" + VALUE "ProductVersion", "22000.258.30.0" END END BLOCK "VarFileInfo" diff --git a/ExplorerPatcher/ExplorerPatcher.vcxproj b/ExplorerPatcher/ExplorerPatcher.vcxproj index bed789c..d27be88 100644 --- a/ExplorerPatcher/ExplorerPatcher.vcxproj +++ b/ExplorerPatcher/ExplorerPatcher.vcxproj @@ -193,6 +193,13 @@ + + + + + + + @@ -207,6 +214,14 @@ + + + + + + + + diff --git a/ExplorerPatcher/ExplorerPatcher.vcxproj.filters b/ExplorerPatcher/ExplorerPatcher.vcxproj.filters index 2238013..eca0abb 100644 --- a/ExplorerPatcher/ExplorerPatcher.vcxproj.filters +++ b/ExplorerPatcher/ExplorerPatcher.vcxproj.filters @@ -13,6 +13,18 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + {bd0d631a-7170-49ec-94ef-70c77ec3a4ab} + + + {4caf96b4-d282-4cad-a9c6-4d8d1374e5a6} + + + {2b202c30-7683-42d3-afc3-ddd3c38e1c8d} + + + {08cd1a6f-9a8f-45ef-a50b-142a1725c106} + @@ -48,17 +60,41 @@ Header Files - + Header Files - Header Files + Header Files\internal - - Header Files + + Header Files\internal - Header Files + Header Files\internal + + + Header Files\sws + + + Header Files\sws + + + Header Files\sws + + + Header Files\sws + + + Header Files\sws + + + Header Files\sws + + + Header Files\sws + + + Header Files\sws @@ -94,14 +130,35 @@ Source Files - + Source Files - Source Files + Source Files\internal - - Source Files + + Source Files\internal + + + Source Files\sws + + + Source Files\sws + + + Source Files\sws + + + Source Files\sws + + + Source Files\sws + + + Source Files\sws + + + Source Files\sws diff --git a/ExplorerPatcher/GUI.c b/ExplorerPatcher/GUI.c index d60745a..dca3b86 100644 --- a/ExplorerPatcher/GUI.c +++ b/ExplorerPatcher/GUI.c @@ -89,6 +89,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) _this->padding.right = GUI_PADDING_RIGHT * dx; _this->padding.top = GUI_PADDING_TOP * dy; _this->padding.bottom = GUI_PADDING_BOTTOM * dy; + _this->sidebarWidth = GUI_SIDEBAR_WIDTH * dx; RECT rc; GetClientRect(hwnd, &rc); @@ -137,6 +138,11 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) logFont.lfWeight = FW_REGULAR; logFont.lfUnderline = 0; HFONT hFontRegular = CreateFontIndirect(&logFont); + logFont.lfWeight = FW_DEMIBOLD; + logFont.lfHeight = GUI_SECTION_FONT_SIZE * dy; + HFONT hFontSection = CreateFontIndirect(&logFont); + logFont.lfUnderline = 1; + HFONT hFontSectionSel = CreateFontIndirect(&logFont); HFONT hOldFont = NULL; DTTOPTS DttOpts; @@ -148,6 +154,8 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) RECT rcText; DWORD dwMaxHeight = 0, dwMaxWidth = 0; BOOL bTabOrderHit = FALSE; + DWORD dwLeftPad = _this->padding.left + _this->sidebarWidth + _this->padding.right; + DWORD dwInitialLeftPad = dwLeftPad; HDC hdcPaint = NULL; BP_PAINTPARAMS params = { sizeof(BP_PAINTPARAMS) }; @@ -156,7 +164,12 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) if (!hDC || (hDC && hdcPaint)) { - if (!IsThemeActive()) + if (!hDC) + { + hdcPaint = GetDC(hwnd); + } + + if (!IsThemeActive() && hDC) { COLORREF oldcr = SetBkColor(hdcPaint, GetSysColor(COLOR_WINDOW)); ExtTextOutW(hdcPaint, 0, 0, ETO_OPAQUE, &rc, L"", 0, 0); @@ -166,13 +179,13 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) FILE* f = fmemopen(pRscr, cbRscr, "r"); char* line = malloc(MAX_LINE_LENGTH * sizeof(char)); - wchar_t* text = malloc(MAX_LINE_LENGTH * sizeof(wchar_t)); + wchar_t* text = malloc((MAX_LINE_LENGTH + 3) * sizeof(wchar_t)); wchar_t* name = malloc(MAX_LINE_LENGTH * sizeof(wchar_t)); wchar_t* section = malloc(MAX_LINE_LENGTH * sizeof(wchar_t)); - size_t bufsiz = 0, numChRd = 0, tabOrder = 1; + size_t bufsiz = MAX_LINE_LENGTH, numChRd = 0, tabOrder = 1, currentSection = -1, topAdj = 0; while ((numChRd = getline(&line, &bufsiz, f)) != -1) { - if (strcmp(line, "Windows Registry Editor Version 5.00\r\n") && strcmp(line, "\r\n")) + if (strcmp(line, "Windows Registry Editor Version 5.00\r\n") && strcmp(line, "\r\n") && (currentSection == -1 || currentSection == _this->section || !strncmp(line, ";T ", 3) || !strncmp(line, ";f", 2))) { #ifndef USE_PRIVATE_INTERFACES if (!strncmp(line, ";p ", 3)) @@ -184,6 +197,25 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) } } #endif + if (!strncmp(line, ";f", 2)) + { + //if (topAdj + ((currentSection + 2) * GUI_SECTION_HEIGHT * dy) > dwMaxHeight) + //{ + // dwMaxHeight = topAdj + ((currentSection + 2) * GUI_SECTION_HEIGHT * dy); + //} + if (_this->dwStatusbarY == 0) + { + dwMaxHeight += GUI_STATUS_PADDING * dy; + _this->dwStatusbarY = dwMaxHeight / dy; + } + else + { + dwMaxHeight = _this->dwStatusbarY * dy; + } + currentSection = -1; + dwLeftPad = 0; + continue; + } if (!strncmp(line, "[", 1)) { @@ -201,31 +233,115 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) DWORD dwLineHeight = GUI_LINE_HEIGHT; - rcText.left = _this->padding.left; + rcText.left = dwLeftPad + _this->padding.left; rcText.top = _this->padding.top + dwMaxHeight; rcText.right = (rc.right - rc.left) - _this->padding.right; rcText.bottom = dwMaxHeight + dwLineHeight * dy - _this->padding.bottom; if (!strncmp(line, ";T ", 3)) { - hOldFont = SelectObject(hDC ? hdcPaint : GetDC(hwnd), hFontTitle); + if (currentSection + 1 == _this->section) + { + hOldFont = SelectObject(hdcPaint, hFontSectionSel); + } + else + { + hOldFont = SelectObject(hdcPaint, hFontSection); + } + rcText.left = _this->padding.left; + rcText.right = _this->padding.left + _this->sidebarWidth; + rcText.top = topAdj + ((currentSection + 1) * GUI_SECTION_HEIGHT * dy); + rcText.bottom = topAdj + ((currentSection + 2) * GUI_SECTION_HEIGHT * dy); + ZeroMemory(text, (MAX_LINE_LENGTH + 3) * sizeof(wchar_t)); + MultiByteToWideChar( + CP_UTF8, + MB_PRECOMPOSED, + line + 3, + numChRd - 3, + text, + MAX_LINE_LENGTH + ); + if (hDC) + { + if (IsThemeActive()) + { + DrawThemeTextEx( + _this->hTheme, + hdcPaint, + 0, + 0, + text, + -1, + dwTextFlags, + &rcText, + &DttOpts + ); + } + else + { + DrawTextW( + hdcPaint, + text, + -1, + &rcText, + dwTextFlags + ); + } + } + else + { + RECT rcTemp; + rcTemp = rcText; + DrawTextW( + hdcPaint, + text, + -1, + &rcTemp, + DT_CALCRECT + ); + rcTemp.bottom = rcText.bottom; + if (PtInRect(&rcTemp, pt)) + { + _this->section = currentSection + 1; + InvalidateRect(hwnd, NULL, FALSE); + } + } + currentSection++; + continue; } else if (!strncmp(line, ";M ", 3)) { - hOldFont = SelectObject(hDC ? hdcPaint : GetDC(hwnd), hFontCaption); + rcText.left = _this->padding.left; + topAdj = dwMaxHeight + GUI_CAPTION_LINE_HEIGHT * dy; + hOldFont = SelectObject(hdcPaint, hFontCaption); } else if (!strncmp(line, ";u ", 3)) { - hOldFont = SelectObject(hDC ? hdcPaint : GetDC(hwnd), hFontUnderline); + hOldFont = SelectObject(hdcPaint, hFontUnderline); } else { - hOldFont = SelectObject(hDC ? hdcPaint : GetDC(hwnd), hFontRegular); + hOldFont = SelectObject(hdcPaint, hFontRegular); } if (!strncmp(line, ";T ", 3) || !strncmp(line, ";t ", 3) || !strncmp(line, ";u ", 3) || !strncmp(line, ";M ", 3)) { - ZeroMemory(text, MAX_LINE_LENGTH * sizeof(wchar_t)); + if (!strncmp(line, ";t ", 3)) + { + char* p = strstr(line, "%VERSIONINFO%"); + if (p) + { + DWORD dwLeftMost = 0; + DWORD dwSecondLeft = 0; + DWORD dwSecondRight = 0; + DWORD dwRightMost = 0; + + QueryVersionInfo(hModule, VS_VERSION_INFO, &dwLeftMost, &dwSecondLeft, &dwSecondRight, &dwRightMost); + + sprintf_s(p, MAX_PATH, "%d.%d.%d.%d", dwLeftMost, dwSecondLeft, dwSecondRight, dwRightMost); + } + } + ZeroMemory(text, (MAX_LINE_LENGTH + 3) * sizeof(wchar_t)); MultiByteToWideChar( CP_UTF8, MB_PRECOMPOSED, @@ -247,13 +363,15 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) MAX_PATH ); PathStripPath(exeName); - if (wcscmp(exeName, L"explorer.exe")) - { - LoadStringW(hModule, IDS_PRODUCTNAME, text, MAX_LINE_LENGTH); - } - else - { - LoadStringW(GetModuleHandleW(L"ExplorerFrame.dll"), 50222, text, 260); + //if (wcscmp(exeName, L"explorer.exe")) + //{ + // LoadStringW(hModule, IDS_PRODUCTNAME, text, MAX_LINE_LENGTH); + //} + //else + //{ + HMODULE hExplorerFrame = LoadLibraryExW(L"ExplorerFrame.dll", NULL, LOAD_LIBRARY_AS_DATAFILE); + LoadStringW(hExplorerFrame, 50222, text, 260); + FreeLibrary(hExplorerFrame); wchar_t* p = wcschr(text, L'('); if (p) { @@ -268,7 +386,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) *p = 0; } } - } + //} rcText.bottom += GUI_CAPTION_LINE_HEIGHT - dwLineHeight; dwLineHeight = GUI_CAPTION_LINE_HEIGHT; _this->extent.cyTopHeight = rcText.bottom; @@ -343,7 +461,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) RECT rcTemp; rcTemp = rcText; DrawTextW( - GetDC(hwnd), + hdcPaint, text, -1, &rcTemp, @@ -535,7 +653,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) } else if (!strncmp(line, ";l ", 3) || !strncmp(line, ";c ", 3) || !strncmp(line, ";b ", 3) || !strncmp(line, ";i ", 3) || !strncmp(line, ";d ", 3) || !strncmp(line, ";v ", 3)) { - ZeroMemory(text, MAX_LINE_LENGTH * sizeof(wchar_t)); + ZeroMemory(text, (MAX_LINE_LENGTH + 3) * sizeof(wchar_t)); text[0] = L'\u2795'; text[1] = L' '; text[2] = L' '; @@ -624,7 +742,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) { wchar_t* x = wcschr(d + 1, L':'); x++; - value = _wtoi(x); + value = wcstol(x, NULL, 16); } if (!bJustCheck) @@ -707,28 +825,41 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) MAX_LINE_LENGTH, L" : " ); - MENUITEMINFOA menuInfo; - ZeroMemory(&menuInfo, sizeof(MENUITEMINFOA)); - menuInfo.cbSize = sizeof(MENUITEMINFOA); + MENUITEMINFOW menuInfo; + ZeroMemory(&menuInfo, sizeof(MENUITEMINFOW)); + menuInfo.cbSize = sizeof(MENUITEMINFOW); menuInfo.fMask = MIIM_STRING; - GetMenuItemInfoA(hMenu, value + 1, FALSE, &menuInfo); - char* buf = malloc(sizeof(char) * (menuInfo.cch + 1)); - menuInfo.dwTypeData = buf; + GetMenuItemInfoW(hMenu, value + 1, FALSE, &menuInfo); menuInfo.cch += 1; - GetMenuItemInfoA(hMenu, value + 1, FALSE, &menuInfo); - MultiByteToWideChar( - CP_UTF8, - MB_PRECOMPOSED, - buf, - menuInfo.cch, - text + wcslen(text), - MAX_LINE_LENGTH + menuInfo.dwTypeData = text + wcslen(text); + GetMenuItemInfoW(hMenu, value + 1, FALSE, &menuInfo); + ZeroMemory(&menuInfo, sizeof(MENUITEMINFOW)); + menuInfo.cbSize = sizeof(MENUITEMINFOW); + menuInfo.fMask = MIIM_STATE; + menuInfo.fState = MFS_CHECKED; + SetMenuItemInfo(hMenu, value + 1, FALSE, &menuInfo); + } + if (hDC && !bInvert && !bBool && !bJustCheck) + { + RECT rcTemp; + rcTemp = rcText; + DrawTextW( + hdcPaint, + text, + 3, + &rcTemp, + DT_CALCRECT ); + rcText.left += rcTemp.right - rcTemp.left; + for (unsigned int i = 0; i < wcslen(text); ++i) + { + text[i] = text[i + 3]; + } } RECT rcTemp; rcTemp = rcText; DrawTextW( - GetDC(hwnd), + hdcPaint, text, -1, &rcTemp, @@ -786,8 +917,17 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) { if (bChoice) { + RECT rcTemp; + rcTemp = rcText; + DrawTextW( + hdcPaint, + text, + 3, + &rcTemp, + DT_CALCRECT + ); POINT p; - p.x = rcText.left; + p.x = rcText.left + rcTemp.right - rcTemp.left; p.y = rcText.bottom; ClientToScreen( hwnd, @@ -849,7 +989,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) RECT rcTemp; rcTemp = rcText; DrawTextW( - GetDC(hwnd), + hdcPaint, text, -1, &rcTemp, @@ -945,14 +1085,24 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) } } fclose(f); + free(section); + free(name); + free(text); + free(line); + SelectObject(hdcPaint, hOldFont); + if (!hDC) + { + ReleaseDC(hwnd, hdcPaint); + } + DeleteObject(hFontSectionSel); + DeleteObject(hFontSection); + DeleteObject(hFontRegular); + DeleteObject(hFontTitle); + DeleteObject(hFontUnderline); + DeleteObject(hFontCaption); if (hDC) { - SelectObject(hdcPaint, hOldFont); - DeleteObject(hFontRegular); - DeleteObject(hFontTitle); - DeleteObject(hFontUnderline); - DeleteObject(hFontCaption); if (_this->tabOrder == GUI_MAX_TABORDER) { _this->tabOrder = tabOrder; @@ -969,7 +1119,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt) GetWindowRect(hwnd, &rcWin); printf("%d %d - %d %d\n", rcWin.right - rcWin.left, rcWin.bottom - rcWin.top, dwMaxWidth, dwMaxHeight); - dwMaxWidth += _this->padding.left + _this->padding.right; + dwMaxWidth += dwInitialLeftPad + _this->padding.left + _this->padding.right; dwMaxHeight += GUI_LINE_HEIGHT * dy + 20 * dy; HMONITOR hMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY); @@ -1057,6 +1207,10 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR PostQuitMessage(0); return 0; } + else if (uMsg == WM_GETICON) + { + return _this->hIcon; + } else if (uMsg == WM_SETTINGCHANGE) { if (IsColorSchemeChangeMessage(lParam)) @@ -1113,6 +1267,14 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR GUI_Build(0, hWnd, pt); return 0; } + // this should be determined from the file, but for now it works + else if (wParam >= 0x30 + 1 && wParam <= 0x30 + 7) + { + _this->tabOrder = 0; + _this->section = wParam - 0x30 - 1; + InvalidateRect(hWnd, NULL, FALSE); + return 0; + } } else if (uMsg == WM_NCHITTEST && IsThemeActive()) { @@ -1239,9 +1401,28 @@ __declspec(dllexport) int ZZGUI(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLin _this.padding.right = GUI_PADDING_RIGHT; _this.padding.top = GUI_PADDING_TOP; _this.padding.bottom = GUI_PADDING_BOTTOM; + _this.sidebarWidth = GUI_SIDEBAR_WIDTH; _this.hTheme = OpenThemeData(NULL, TEXT(GUI_WINDOWSWITCHER_THEME_CLASS)); _this.tabOrder = 0; _this.bCalcExtent = TRUE; + _this.section = 0; + _this.dwStatusbarY = 0; + _this.hIcon = NULL; + + wchar_t wszPath[MAX_PATH]; + ZeroMemory( + wszPath, + (MAX_PATH) * sizeof(wchar_t) + ); + GetWindowsDirectoryW( + wszPath, + MAX_PATH + ); + wcscat_s( + wszPath, + MAX_PATH, + L"\\explorer.exe" + ); WNDCLASS wc = { 0 }; ZeroMemory(&wc, sizeof(WNDCLASSW)); @@ -1251,10 +1432,18 @@ __declspec(dllexport) int ZZGUI(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLin wc.hInstance = hModule; wc.lpszClassName = L"ExplorerPatcherGUI"; wc.hCursor = LoadCursorW(NULL, IDC_ARROW); + HMODULE hExplorer = LoadLibraryExW(wszPath, NULL, LOAD_LIBRARY_AS_DATAFILE); + if (hExplorer) + { + _this.hIcon = LoadIconW(hExplorer, L"ICO_MYCOMPUTER"); + wc.hIcon = _this.hIcon; + } RegisterClassW(&wc); TCHAR title[260]; - LoadStringW(GetModuleHandleW(L"ExplorerFrame.dll"), 726, title, 260); + HMODULE hExplorerFrame = LoadLibraryExW(L"ExplorerFrame.dll", NULL, LOAD_LIBRARY_AS_DATAFILE); + LoadStringW(hExplorerFrame, 726, title, 260); + FreeLibrary(hExplorerFrame); if (title[0] == 0) { LoadStringW(hModule, IDS_PRODUCTNAME, title, 260); @@ -1326,10 +1515,27 @@ __declspec(dllexport) int ZZGUI(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLin DispatchMessage(&msg); } - if (bHasLoadedUxtheme) + if (hExplorer) + { + CloseHandle(_this.hIcon); + FreeLibrary(hExplorer); + } + + if (bHasLoadedUxtheme && hUxtheme) { FreeLibrary(hUxtheme); } + _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT); + _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDOUT); + _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT); + _CrtDumpMemoryLeaks(); +#ifdef _DEBUG + _getch(); +#endif + printf("Ended \"GUI\" thread.\n"); } diff --git a/ExplorerPatcher/GUI.h b/ExplorerPatcher/GUI.h index b21dec7..e07704f 100644 --- a/ExplorerPatcher/GUI.h +++ b/ExplorerPatcher/GUI.h @@ -1,5 +1,8 @@ #ifndef _H_GUI_H_ #define _H_GUI_H_ +#define _CRTDBG_MAP_ALLOC +#include +#include #pragma comment(linker,"\"/manifestdependency:type='win32' \ name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") @@ -28,9 +31,11 @@ extern HMODULE hModule; #define GUI_POSITION_X CW_USEDEFAULT #define GUI_POSITION_Y CW_USEDEFAULT #define GUI_POSITION_WIDTH 367 -#define GUI_POSITION_HEIGHT 616 +#define GUI_POSITION_HEIGHT 316 #define GUI_WINDOWSWITCHER_THEME_CLASS "ControlPanelStyle" #define GUI_CAPTION_FONT_SIZE -22 +#define GUI_SECTION_FONT_SIZE -12 +#define GUI_SECTION_HEIGHT 32 #define GUI_TITLE_FONT_SIZE -12 #define GUI_LINE_HEIGHT 26 #define GUI_CAPTION_LINE_HEIGHT 42 @@ -41,20 +46,26 @@ extern HMODULE hModule; #define GUI_MAX_TABORDER 9999 #define GUI_PADDING 5 #define GUI_PADDING_LEFT GUI_PADDING * 3 +#define GUI_SIDEBAR_WIDTH 110 #define GUI_PADDING_RIGHT GUI_PADDING * 3 #define GUI_PADDING_TOP GUI_PADDING #define GUI_PADDING_BOTTOM GUI_PADDING +#define GUI_STATUS_PADDING 10 typedef struct _GUI { POINT location; SIZE size; RECT padding; + UINT sidebarWidth; HBRUSH hBackgroundBrush; HTHEME hTheme; POINT dpi; MARGINS extent; UINT tabOrder; BOOL bCalcExtent; + SIZE_T section; + DWORD dwStatusbarY; + HICON hIcon; } GUI; static HRESULT GUI_AboutProc( diff --git a/ExplorerPatcher/SettingsMonitor.c b/ExplorerPatcher/SettingsMonitor.c index 7ab42e9..dd53147 100644 --- a/ExplorerPatcher/SettingsMonitor.c +++ b/ExplorerPatcher/SettingsMonitor.c @@ -1,336 +1,64 @@ #include "SettingsMonitor.h" -DWORD MonitorSettingsChanges(SettingsChangeParameters* params) +DWORD MonitorSettings(SettingsChangeParameters* params) { - HMODULE hModule = LoadLibraryW(L"Shlwapi.dll"); - if (hModule) - { - FARPROC SHRegGetValueFromHKCUHKLMFunc = GetProcAddress(hModule, "SHRegGetValueFromHKCUHKLM"); - DWORD dwSize = sizeof(DWORD); - LONG lRes = ERROR_SUCCESS; - HKEY hKeyCU, hKeyLM; + while (TRUE) + { + HANDLE* handles = malloc(sizeof(HANDLE) * params->size); + if (!handles) + { + return 0; + } + for (unsigned int i = 0; i < params->size; ++i) + { + params->settings[i].hEvent = CreateEventW(NULL, FALSE, FALSE, NULL); + if (!params->settings[i].hEvent) + { + return 0; + } + handles[i] = params->settings[i].hEvent; + if (RegCreateKeyExW( + params->settings[i].origin, + params->settings[i].name, + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_READ, + NULL, + &(params->settings[i].hKey), + NULL + ) != ERROR_SUCCESS) + { + return 0; + } + if (RegNotifyChangeKeyValue( + params->settings[i].hKey, + FALSE, + REG_NOTIFY_CHANGE_LAST_SET, + params->settings[i].hEvent, + TRUE + ) != ERROR_SUCCESS) + { + return 0; + } + } + DWORD dwRes = WaitForMultipleObjects( + params->size, + handles, + FALSE, + INFINITE + ); + if (dwRes != WAIT_FAILED) + { + unsigned int i = dwRes - WAIT_OBJECT_0; + params->settings[i].callback(params->settings[i].data); + } + free(handles); + for (unsigned int i = 0; i < params->size; ++i) + { + CloseHandle(params->settings[i].hEvent); + RegCloseKey(params->settings[i].hKey); + } + } +} - dwSize = sizeof(DWORD); - DWORD dwInitialTaskbarAl = 0, dwTaskbarAl = 0, dwInitialTaskbarAlWas = 0; - if (!SHRegGetValueFromHKCUHKLMFunc || SHRegGetValueFromHKCUHKLMFunc( - TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"), - TEXT("TaskbarAl"), - SRRF_RT_REG_DWORD, - NULL, - &dwInitialTaskbarAl, - (LPDWORD)(&dwSize) - ) != ERROR_SUCCESS) - { - dwInitialTaskbarAl = 0; - } - else - { - dwInitialTaskbarAlWas = 1; - } - - dwSize = sizeof(DWORD); - DWORD dwInitialMaximumFrequentApps = 6, dwMaximumFrequentApps = 6, dwInitialMaximumFrequentAppsWas = 0; - if (!SHRegGetValueFromHKCUHKLMFunc || SHRegGetValueFromHKCUHKLMFunc( - TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"), - TEXT("Start_MaximumFrequentApps"), - SRRF_RT_REG_DWORD, - NULL, - &dwInitialMaximumFrequentApps, - (LPDWORD)(&dwSize) - ) != ERROR_SUCCESS) - { - dwInitialMaximumFrequentApps = 6; - } - else - { - dwInitialMaximumFrequentAppsWas = 1; - } - - while (TRUE) - { - lRes = RegOpenKeyExW( - HKEY_CURRENT_USER, - TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"), - 0, - KEY_READ, - &hKeyCU - ); - if (hKeyCU == NULL || hKeyCU == INVALID_HANDLE_VALUE) - { - hKeyCU = NULL; - } - if (lRes != ERROR_SUCCESS) - { - return 0; - } - HANDLE hEvHKCU = CreateEvent(NULL, FALSE, FALSE, NULL); - if (hEvHKCU == NULL || hEvHKCU == INVALID_HANDLE_VALUE) - { - hEvHKCU = NULL; - return 0; - } - RegNotifyChangeKeyValue( - hKeyCU, - FALSE, - REG_NOTIFY_CHANGE_LAST_SET, - hEvHKCU, - TRUE - ); - - lRes = RegOpenKeyExW( - HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"), - 0, - KEY_READ, - &hKeyLM - ); - if (hKeyLM == NULL || hKeyLM == INVALID_HANDLE_VALUE) - { - hKeyLM = NULL; - } - if (lRes != ERROR_SUCCESS) - { - return 0; - } - HANDLE hEvHKLM = CreateEvent(NULL, FALSE, FALSE, NULL); - if (hEvHKLM == NULL || hEvHKLM == INVALID_HANDLE_VALUE) - { - hEvHKLM = NULL; - return 0; - } - RegNotifyChangeKeyValue( - hKeyLM, - FALSE, - REG_NOTIFY_CHANGE_LAST_SET, - hEvHKLM, - TRUE - ); - printf("!!! Setup monitor %d %d\n", hEvHKCU, hEvHKLM); - - HANDLE hEvents[2]; - hEvents[0] = hEvHKCU; - hEvents[1] = hEvHKLM; - DWORD rv = WaitForMultipleObjects( - 2, - hEvents, - FALSE, - INFINITE - ); - if (rv == WAIT_OBJECT_0) - { - dwSize = sizeof(DWORD); - lRes = RegQueryValueExW( - hKeyCU, - TEXT("TaskbarAl"), - 0, - NULL, - &dwTaskbarAl, - &dwSize - ); - if (lRes != ERROR_SUCCESS && dwInitialTaskbarAlWas) - { - if (params->TaskbarAlChangedCallback) - { - void* p = 0; - if (params->TaskbarAlChangedCallbackData) - { - p = params->TaskbarAlChangedCallbackData; - } - params->TaskbarAlChangedCallback(p, dwTaskbarAl); - } - else - { - exit(0); - } - dwInitialTaskbarAl = dwTaskbarAl; - } - if (lRes == ERROR_SUCCESS && dwTaskbarAl != dwInitialTaskbarAl) - { - if (params->TaskbarAlChangedCallback) - { - void* p = 0; - if (params->TaskbarAlChangedCallbackData) - { - p = params->TaskbarAlChangedCallbackData; - } - params->TaskbarAlChangedCallback(p, dwTaskbarAl); - } - else - { - exit(0); - } - dwInitialTaskbarAl = dwTaskbarAl; - } - - if (params->isStartMenuExperienceHost) - { - dwSize = sizeof(DWORD); - lRes = RegQueryValueExW( - hKeyCU, - TEXT("Start_MaximumFrequentApps"), - 0, - NULL, - &dwMaximumFrequentApps, - &dwSize - ); - if (lRes != ERROR_SUCCESS && dwInitialMaximumFrequentAppsWas) - { - if (params->Start_MaximumRecentAppsChangedCallback) - { - void* p = 0; - if (params->Start_MaximumRecentAppsChangedCallbackData) - { - p = params->Start_MaximumRecentAppsChangedCallbackData; - } - params->Start_MaximumRecentAppsChangedCallback(p, dwMaximumFrequentApps); - } - else - { - exit(0); - } - dwInitialMaximumFrequentApps = dwMaximumFrequentApps; - } - if (lRes == ERROR_SUCCESS && dwMaximumFrequentApps != dwInitialMaximumFrequentApps) - { - if (params->Start_MaximumRecentAppsChangedCallback) - { - void* p = 0; - if (params->Start_MaximumRecentAppsChangedCallbackData) - { - p = params->Start_MaximumRecentAppsChangedCallbackData; - } - params->Start_MaximumRecentAppsChangedCallback(p, dwMaximumFrequentApps); - } - else - { - exit(0); - } - dwInitialMaximumFrequentApps = dwMaximumFrequentApps; - } - } - } - else if (rv == WAIT_OBJECT_0 + 1) - { - dwSize = sizeof(DWORD); - lRes = RegQueryValueExW( - hKeyCU, - TEXT("TaskbarAl"), - 0, - NULL, - &dwTaskbarAl, - &dwSize - ); - if (lRes != ERROR_SUCCESS) - { - dwSize = sizeof(DWORD); - lRes = RegQueryValueExW( - hKeyLM, - TEXT("TaskbarAl"), - 0, - NULL, - &dwTaskbarAl, - &dwSize - ); - if (lRes != ERROR_SUCCESS && dwInitialTaskbarAlWas) - { - if (params->TaskbarAlChangedCallback) - { - void* p = 0; - if (params->TaskbarAlChangedCallbackData) - { - p = params->TaskbarAlChangedCallbackData; - } - params->TaskbarAlChangedCallback(p, dwTaskbarAl); - } - else - { - exit(0); - } - dwInitialTaskbarAl = dwTaskbarAl; - } - if (lRes == ERROR_SUCCESS && dwTaskbarAl != dwInitialTaskbarAl) - { - if (params->TaskbarAlChangedCallback) - { - void* p = 0; - if (params->TaskbarAlChangedCallbackData) - { - p = params->TaskbarAlChangedCallbackData; - } - params->TaskbarAlChangedCallback(p, dwTaskbarAl); - } - else - { - exit(0); - } - dwInitialTaskbarAl = dwTaskbarAl; - } - } - - if (params->isStartMenuExperienceHost) - { - dwSize = sizeof(DWORD); - lRes = RegQueryValueExW( - hKeyCU, - TEXT("Start_MaximumFrequentApps"), - 0, - NULL, - &dwMaximumFrequentApps, - &dwSize - ); - if (lRes != ERROR_SUCCESS) - { - dwSize = sizeof(DWORD); - lRes = RegQueryValueExW( - hKeyLM, - TEXT("Start_MaximumFrequentApps"), - 0, - NULL, - &dwMaximumFrequentApps, - &dwSize - ); - if (lRes != ERROR_SUCCESS && dwInitialMaximumFrequentAppsWas) - { - if (params->Start_MaximumRecentAppsChangedCallback) - { - void* p = 0; - if (params->Start_MaximumRecentAppsChangedCallbackData) - { - p = params->Start_MaximumRecentAppsChangedCallbackData; - } - params->Start_MaximumRecentAppsChangedCallback(p, dwMaximumFrequentApps); - } - else - { - exit(0); - } - dwInitialMaximumFrequentApps = dwMaximumFrequentApps; - } - if (lRes == ERROR_SUCCESS && dwMaximumFrequentApps != dwInitialMaximumFrequentApps) - { - if (params->Start_MaximumRecentAppsChangedCallback) - { - void* p = 0; - if (params->Start_MaximumRecentAppsChangedCallbackData) - { - p = params->Start_MaximumRecentAppsChangedCallbackData; - } - params->Start_MaximumRecentAppsChangedCallback(p, dwMaximumFrequentApps); - } - else - { - exit(0); - } - dwInitialMaximumFrequentApps = dwMaximumFrequentApps; - } - } - } - } - - if (hEvHKCU) CloseHandle(hEvHKCU); - if (hEvHKLM) CloseHandle(hEvHKLM); - if (hKeyCU) RegCloseKey(hKeyCU); - if (hKeyLM) RegCloseKey(hKeyLM); - } - } -} \ No newline at end of file diff --git a/ExplorerPatcher/SettingsMonitor.h b/ExplorerPatcher/SettingsMonitor.h index ea60f58..b726f89 100644 --- a/ExplorerPatcher/SettingsMonitor.h +++ b/ExplorerPatcher/SettingsMonitor.h @@ -4,13 +4,19 @@ #include #pragma comment(lib, "Shlwapi.lib") +typedef struct _Setting +{ + HKEY origin; + wchar_t name[MAX_PATH]; + HKEY hKey; + HANDLE hEvent; + void(*callback)(void*); + void* data; +} Setting; typedef struct _SettingsChangeParameters { - BOOL isStartMenuExperienceHost; - void (*TaskbarAlChangedCallback)(INT64, DWORD); - void* TaskbarAlChangedCallbackData; - void (*Start_MaximumRecentAppsChangedCallback)(INT64, DWORD); - void* Start_MaximumRecentAppsChangedCallbackData; + Setting* settings; + DWORD size; } SettingsChangeParameters; -DWORD MonitorSettingsChanges(SettingsChangeParameters* params); +DWORD MonitorSettings(SettingsChangeParameters*); #endif diff --git a/ExplorerPatcher/StartMenu.c b/ExplorerPatcher/StartMenu.c index a8cad77..9bbe537 100644 --- a/ExplorerPatcher/StartMenu.c +++ b/ExplorerPatcher/StartMenu.c @@ -77,7 +77,12 @@ LRESULT CALLBACK OpenStartOnCurentMonitorThreadHook( MSG* msg = (MSG*)lParam; if (GetSystemMetrics(SM_CMONITORS) >= 2 && msg->message == WM_SYSCOMMAND && (msg->wParam & 0xFFF0) == SC_TASKLIST) { - DWORD dwStatus = 0; + if (bMonitorOverride) + { + goto finish; + } + + /*DWORD dwStatus = 0; DWORD dwSize = sizeof(DWORD); HMODULE hModule = GetModuleHandle(TEXT("Shlwapi.dll")); FARPROC SHRegGetValueFromHKCUHKLMFunc = GetProcAddress(hModule, "SHRegGetValueFromHKCUHKLM"); @@ -91,7 +96,7 @@ LRESULT CALLBACK OpenStartOnCurentMonitorThreadHook( ) != ERROR_SUCCESS || dwStatus == 1) { goto finish; - } + }*/ DWORD pts = GetMessagePos(); POINT pt; @@ -163,7 +168,12 @@ DWORD OpenStartAtLogonThread(OpenStartAtLogonThreadParams* unused) ); printf("Started \"Open Start at Logon\" thread.\n"); - DWORD dwStatus = 0; + if (!bOpenAtLogon) + { + return 0; + } + + /*DWORD dwStatus = 0; DWORD dwSize = sizeof(DWORD); HMODULE hModule = GetModuleHandle(TEXT("Shlwapi")); FARPROC SHRegGetValueFromHKCUHKLMFunc = GetProcAddress(hModule, "SHRegGetValueFromHKCUHKLM"); @@ -177,7 +187,7 @@ DWORD OpenStartAtLogonThread(OpenStartAtLogonThreadParams* unused) ) != ERROR_SUCCESS || dwStatus == 0) { return 0; - } + }*/ POINT pt; pt.x = 0; diff --git a/ExplorerPatcher/StartMenu.h b/ExplorerPatcher/StartMenu.h index 7506796..552926e 100644 --- a/ExplorerPatcher/StartMenu.h +++ b/ExplorerPatcher/StartMenu.h @@ -7,6 +7,9 @@ #pragma comment(lib, "Shlwapi.lib") #include +extern DWORD bMonitorOverride; +extern DWORD bOpenAtLogon; + DEFINE_GUID(CLSID_ImmersiveShell, 0xc2f03a33, 0x21f5, 0x47fa, 0xb4, 0xbb, diff --git a/ExplorerPatcher/TaskbarCenter.c b/ExplorerPatcher/TaskbarCenter.c index cfbcff3..c8b369a 100644 --- a/ExplorerPatcher/TaskbarCenter.c +++ b/ExplorerPatcher/TaskbarCenter.c @@ -2,6 +2,25 @@ HANDLE hEvent; +HRESULT TaskbarCenter_Center() +{ + HRESULT hr = S_OK; + HWND hWnd = FindWindowExW(NULL, NULL, L"Shell_TrayWnd", NULL); + + while (hWnd) + { + if (SUCCEEDED(hr)) + { + /*hr = AccessibleObjectFromWindow( + + );*/ + } + + hWnd = NULL; + } + +} + BOOL TaskbarCenter_Notify() { if (hEvent) @@ -19,7 +38,7 @@ BOOL GetClientRectHook(HWND hWnd, LPRECT lpRect) GetClassNameW(hWnd, wszClassName, 100); if (!wcscmp(wszClassName, L"MSTaskListWClass")) { - TaskbarCenter_Notify(); + TaskbarCenter_Center(); } return GetClientRect(hWnd, lpRect); } diff --git a/ExplorerPatcher/TaskbarCenter.h b/ExplorerPatcher/TaskbarCenter.h index 717d761..36060f8 100644 --- a/ExplorerPatcher/TaskbarCenter.h +++ b/ExplorerPatcher/TaskbarCenter.h @@ -2,6 +2,8 @@ #define _H_TASKBARCENTER_H_ #include #include +#include +#pragma comment(lib, "Oleacc.lib") #include #define TASKBAR_CHANGED_NOTIFICATION L"Global\\ExplorerPatcher_TaskbarChangedNotification_{B37553B7-425C-44F6-A04A-126849EE59CB}" diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 7006bfd..36ca56f 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -28,18 +28,31 @@ #define POPUPMENU_BLUETOOTH_TIMEOUT 700 #define POPUPMENU_PNIDUI_TIMEOUT 300 #define POPUPMENU_SNDVOLSSO_TIMEOUT 300 +#define POPUPMENU_EX_ELAPSED 300 HWND archivehWnd; HMODULE hStartIsBack64 = 0; -BOOL bHideExplorerSearchBar = FALSE; -BOOL bMicaEffectOnTitlebar = FALSE; -BOOL bHideControlCenterButton = FALSE; -BOOL bSkinMenus = TRUE; -BOOL bSkinIcons = TRUE; -BOOL bReplaceNetwork = FALSE; +DWORD bOldTaskbar = TRUE; +DWORD bAllocConsole = FALSE; +DWORD bHideExplorerSearchBar = FALSE; +DWORD bMicaEffectOnTitlebar = FALSE; +DWORD bHideControlCenterButton = FALSE; +DWORD bFlyoutMenus = TRUE; +DWORD bCenterMenus = TRUE; +DWORD bSkinMenus = TRUE; +DWORD bSkinIcons = TRUE; +DWORD bReplaceNetwork = FALSE; +DWORD dwExplorerReadyDelay = 0; +DWORD bEnableArchivePlugin = FALSE; +DWORD bMonitorOverride = TRUE; +DWORD bOpenAtLogon = FALSE; +DWORD bClockFlyoutOnWinC = FALSE; +DWORD bDisableImmersiveContextMenu = FALSE; HMODULE hModule = NULL; HANDLE hIsWinXShown = NULL; HANDLE hWinXThread = NULL; +HANDLE hSwsSettingsChanged = NULL; +HANDLE hSwsOpacityMaybeChanged = NULL; #include "utility.h" #ifdef USE_PRIVATE_INTERFACES @@ -54,7 +67,7 @@ HANDLE hWinXThread = NULL; #include "StartMenu.h" #include "GUI.h" #include "TaskbarCenter.h" - +#include "../libs/sws/SimpleWindowSwitcher/sws_WindowSwitcher.h" #pragma region "Generics" #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) @@ -410,14 +423,18 @@ DWORD ShowLauncherTipContextMenu( &menuInfo ); - INT64* unknown_array = calloc(4, sizeof(INT64)); - ImmersiveContextMenuHelper_ApplyOwnerDrawToMenuFunc( - *((HMENU*)((char*)params->_this + 0xe8)), - hWinXWnd, - &(params->point), - 0xc, - unknown_array - ); + INT64* unknown_array = NULL; + if (bSkinMenus) + { + unknown_array = calloc(4, sizeof(INT64)); + ImmersiveContextMenuHelper_ApplyOwnerDrawToMenuFunc( + *((HMENU*)((char*)params->_this + 0xe8)), + hWinXWnd, + &(params->point), + 0xc, + unknown_array + ); + } BOOL res = TrackPopupMenu( *((HMENU*)((char*)params->_this + 0xe8)), @@ -429,12 +446,15 @@ DWORD ShowLauncherTipContextMenu( 0 ); - ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( - *((HMENU*)((char*)params->_this + 0xe8)), - hWinXWnd, - &(params->point) - ); - free(unknown_array); + if (bSkinMenus) + { + ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( + *((HMENU*)((char*)params->_this + 0xe8)), + hWinXWnd, + &(params->point) + ); + free(unknown_array); + } RemoveMenu( *((HMENU*)((char*)params->_this + 0xe8)), @@ -446,7 +466,53 @@ DWORD ShowLauncherTipContextMenu( { if (res == 3999) { - CreateThread(0, 0, ZZGUI, 0, 0, 0); + //CreateThread(0, 0, ZZGUI, 0, 0, 0); + wchar_t wszPath[MAX_PATH * 2]; + ZeroMemory( + wszPath, + (MAX_PATH * 2) * sizeof(wchar_t) + ); + wszPath[0] = '\"'; + GetSystemDirectoryW( + wszPath + 1, + MAX_PATH + ); + wcscat_s( + wszPath, + MAX_PATH * 2, + L"\\rundll32.exe\" \"" + ); + GetWindowsDirectoryW( + wszPath + wcslen(wszPath), + MAX_PATH + ); + wcscat_s( + wszPath, + MAX_PATH * 2, + L"\\dxgi.dll\",ZZGUI" + ); + wprintf(L"Launching : %s\n", wszPath); + STARTUPINFO si; + ZeroMemory(&si, sizeof(STARTUPINFO)); + si.cb = sizeof(si); + PROCESS_INFORMATION pi; + ZeroMemory(&pi, sizeof(PROCESS_INFORMATION)); + if (CreateProcessW( + NULL, + wszPath, + NULL, + NULL, + TRUE, + CREATE_UNICODE_ENVIRONMENT, + NULL, + NULL, + &si, + &pi + )) + { + CloseHandle(pi.hThread); + CloseHandle(pi.hProcess); + } } else if (res < 4000) { @@ -503,7 +569,7 @@ INT64 CLauncherTipContextMenu_ShowLauncherTipContextMenuHook( point = *pt; BOOL bBottom, bRight; POINT dPt = GetDefaultWinXPosition(FALSE, &bBottom, &bRight, FALSE); - if (bBottom) + if (bBottom && IsThemeActive()) { HMONITOR hMonitor = MonitorFromPoint(point, MONITOR_DEFAULTTOPRIMARY); MONITORINFO mi; @@ -624,19 +690,24 @@ UINT GetTaskbarLocationAndSize(POINT ptCursor, RECT* rc) if (hWnd) { GetWindowRect(hWnd, rc); - if (rc->left < 5 && rc->top > 5) + RECT rcC = *rc; + rcC.left -= mi.rcMonitor.left; + rcC.right -= mi.rcMonitor.left; + rcC.top -= mi.rcMonitor.top; + rcC.bottom -= mi.rcMonitor.top; + if (rcC.left < 5 && rcC.top > 5) { return TB_POS_BOTTOM; } - else if (rc->left < 5 && rc->top < 5 && rc->right > rc->bottom) + else if (rcC.left < 5 && rcC.top < 5 && rcC.right > rcC.bottom) { return TB_POS_TOP; } - else if (rc->left < 5 && rc->top < 5 && rc->right < rc->bottom) + else if (rcC.left < 5 && rcC.top < 5 && rcC.right < rcC.bottom) { return TB_POS_LEFT; } - else if (rc->left > 5 && rc->top < 5) + else if (rcC.left > 5 && rcC.top < 5) { return TB_POS_RIGHT; } @@ -699,6 +770,152 @@ void PopupMenuAdjustCoordinatesAndFlags(int* x, int* y, UINT* uFlags) *uFlags |= TPM_VCENTERALIGN | TPM_RIGHTALIGN; } } +BOOL IsImmersiveMenu = FALSE; +BOOL CheckIfImmersiveContextMenu( + HWND unnamedParam1, + LPCSTR unnamedParam2, + HANDLE unnamedParam3 +) +{ + if ((*((WORD*)&(unnamedParam2)+1))) + { + if (!strncmp(unnamedParam2, "ImmersiveContextMenuArray", 25)) + { + IsImmersiveMenu = TRUE; + return FALSE; + } + } + return TRUE; +} +BOOL shell32_TrackPopupMenuHook( + HMENU hMenu, + UINT uFlags, + int x, + int y, + int nReserved, + HWND hWnd, + const RECT* prcRect +) +{ + IsImmersiveMenu = FALSE; + if (bDisableImmersiveContextMenu) + { + EnumPropsA(hWnd, CheckIfImmersiveContextMenu); + if (IsImmersiveMenu) + { + POINT pt; + pt.x = x; + pt.y = y; + ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( + hMenu, + hWnd, + &(pt) + ); + } + IsImmersiveMenu = FALSE; + } + if (bSkinMenus) + { + //PopupMenuAdjustCoordinatesAndFlags(&x, &y, &uFlags); + } + return TrackPopupMenu( + hMenu, + uFlags, + x, + y, + 0, + hWnd, + prcRect + ); +} +BOOL TrackPopupMenuHook( + HMENU hMenu, + UINT uFlags, + int x, + int y, + int nReserved, + HWND hWnd, + const RECT* prcRect +) +{ + IsImmersiveMenu = FALSE; + if (!bSkinMenus) + { + EnumPropsA(hWnd, CheckIfImmersiveContextMenu); + if (IsImmersiveMenu) + { + POINT pt; + pt.x = x; + pt.y = y; + ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( + hMenu, + hWnd, + &(pt) + ); + } + IsImmersiveMenu = FALSE; + } + if (bCenterMenus) + { + //PopupMenuAdjustCoordinatesAndFlags(&x, &y, &uFlags); + } + return TrackPopupMenu( + hMenu, + uFlags, + x, + y, + 0, + hWnd, + prcRect + ); +} +long long TrackPopupMenuExElapsed = 0; +BOOL TrackPopupMenuExHook( + HMENU hMenu, + UINT uFlags, + int x, + int y, + HWND hWnd, + LPTPMPARAMS lptpm +) +{ + long long elapsed = milliseconds_now() - TrackPopupMenuExElapsed; + BOOL b = FALSE; + if (elapsed > POPUPMENU_EX_ELAPSED || !bFlyoutMenus) + { + if (bCenterMenus) + { + PopupMenuAdjustCoordinatesAndFlags(&x, &y, &uFlags); + } + IsImmersiveMenu = FALSE; + if (!bSkinMenus) + { + EnumPropsA(hWnd, CheckIfImmersiveContextMenu); + if (IsImmersiveMenu) + { + POINT pt; + pt.x = x; + pt.y = y; + ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( + hMenu, + hWnd, + &(pt) + ); + } + IsImmersiveMenu = FALSE; + } + b = TrackPopupMenuEx( + hMenu, + uFlags, + x, + y, + hWnd, + lptpm + ); + TrackPopupMenuExElapsed = milliseconds_now(); + } + return b; +} long long pnidui_TrackPopupMenuElapsed = 0; BOOL pnidui_TrackPopupMenuHook( HMENU hMenu, @@ -712,12 +929,29 @@ BOOL pnidui_TrackPopupMenuHook( { long long elapsed = milliseconds_now() - pnidui_TrackPopupMenuElapsed; BOOL b = FALSE; - if (elapsed > POPUPMENU_PNIDUI_TIMEOUT || !bSkinMenus) + if (elapsed > POPUPMENU_PNIDUI_TIMEOUT || !bFlyoutMenus) { - if (bSkinMenus) + if (bCenterMenus) { PopupMenuAdjustCoordinatesAndFlags(&x, &y, &uFlags); } + IsImmersiveMenu = FALSE; + if (!bSkinMenus) + { + EnumPropsA(hWnd, CheckIfImmersiveContextMenu); + if (IsImmersiveMenu) + { + POINT pt; + pt.x = x; + pt.y = y; + ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( + hMenu, + hWnd, + &(pt) + ); + } + IsImmersiveMenu = FALSE; + } b = TrackPopupMenu( hMenu, uFlags | TPM_RIGHTBUTTON, @@ -755,9 +989,29 @@ BOOL sndvolsso_TrackPopupMenuExHook( { long long elapsed = milliseconds_now() - sndvolsso_TrackPopupMenuExElapsed; BOOL b = FALSE; - if (elapsed > POPUPMENU_SNDVOLSSO_TIMEOUT) + if (elapsed > POPUPMENU_SNDVOLSSO_TIMEOUT || !bFlyoutMenus) { - PopupMenuAdjustCoordinatesAndFlags(&x, &y, &uFlags); + if (bCenterMenus) + { + PopupMenuAdjustCoordinatesAndFlags(&x, &y, &uFlags); + } + IsImmersiveMenu = FALSE; + if (!bSkinMenus) + { + EnumPropsA(hWnd, CheckIfImmersiveContextMenu); + if (IsImmersiveMenu) + { + POINT pt; + pt.x = x; + pt.y = y; + ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( + hMenu, + hWnd, + &(pt) + ); + } + IsImmersiveMenu = FALSE; + } b = TrackPopupMenuEx( hMenu, uFlags | TPM_RIGHTBUTTON, @@ -770,8 +1024,8 @@ BOOL sndvolsso_TrackPopupMenuExHook( } return b; } -long long TrackPopupMenuElapsed = 0; -BOOL TrackPopupMenuHook( +long long stobject_TrackPopupMenuElapsed = 0; +BOOL stobject_TrackPopupMenuHook( HMENU hMenu, UINT uFlags, int x, @@ -781,23 +1035,30 @@ BOOL TrackPopupMenuHook( const RECT* prcRect ) { - long long elapsed = milliseconds_now() - TrackPopupMenuElapsed; + long long elapsed = milliseconds_now() - stobject_TrackPopupMenuElapsed; BOOL b = FALSE; - if (elapsed > POPUPMENU_SAFETOREMOVE_TIMEOUT) + if (elapsed > POPUPMENU_SAFETOREMOVE_TIMEOUT || !bFlyoutMenus) { - PopupMenuAdjustCoordinatesAndFlags(&x, &y, &uFlags); - INT64* unknown_array = calloc(4, sizeof(INT64)); + if (bCenterMenus) + { + PopupMenuAdjustCoordinatesAndFlags(&x, &y, &uFlags); + } + INT64* unknown_array = NULL; POINT pt; - pt.x = x; - pt.y = y; - ImmersiveContextMenuHelper_ApplyOwnerDrawToMenuFunc( - hMenu, - hWnd, - &(pt), - 0xc, - unknown_array - ); - SetWindowSubclass(hWnd, OwnerDrawSubclassProc, OwnerDrawSubclassProc, 0); + if (bSkinMenus) + { + unknown_array = calloc(4, sizeof(INT64)); + pt.x = x; + pt.y = y; + ImmersiveContextMenuHelper_ApplyOwnerDrawToMenuFunc( + hMenu, + hWnd, + &(pt), + 0xc, + unknown_array + ); + SetWindowSubclass(hWnd, OwnerDrawSubclassProc, OwnerDrawSubclassProc, 0); + } b = TrackPopupMenu( hMenu, uFlags | TPM_RIGHTBUTTON, @@ -807,19 +1068,22 @@ BOOL TrackPopupMenuHook( hWnd, prcRect ); - TrackPopupMenuElapsed = milliseconds_now(); - RemoveWindowSubclass(hWnd, OwnerDrawSubclassProc, OwnerDrawSubclassProc); - ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( - hMenu, - hWnd, - &(pt) - ); - free(unknown_array); + stobject_TrackPopupMenuElapsed = milliseconds_now(); + if (bSkinMenus) + { + RemoveWindowSubclass(hWnd, OwnerDrawSubclassProc, OwnerDrawSubclassProc); + ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( + hMenu, + hWnd, + &(pt) + ); + free(unknown_array); + } } return b; } -long long TrackPopupMenuExElapsed = 0; -BOOL TrackPopupMenuExHook( +long long bthprops_TrackPopupMenuExElapsed = 0; +BOOL bthprops_TrackPopupMenuExHook( HMENU hMenu, UINT uFlags, int x, @@ -828,23 +1092,30 @@ BOOL TrackPopupMenuExHook( LPTPMPARAMS lptpm ) { - long long elapsed = milliseconds_now() - TrackPopupMenuExElapsed; + long long elapsed = milliseconds_now() - bthprops_TrackPopupMenuExElapsed; BOOL b = FALSE; - if (elapsed > POPUPMENU_BLUETOOTH_TIMEOUT) + if (elapsed > POPUPMENU_BLUETOOTH_TIMEOUT || !bFlyoutMenus) { - PopupMenuAdjustCoordinatesAndFlags(&x, &y, &uFlags); - INT64* unknown_array = calloc(4, sizeof(INT64)); + if (bCenterMenus) + { + PopupMenuAdjustCoordinatesAndFlags(&x, &y, &uFlags); + } + INT64* unknown_array = NULL; POINT pt; - pt.x = x; - pt.y = y; - ImmersiveContextMenuHelper_ApplyOwnerDrawToMenuFunc( - hMenu, - hWnd, - &(pt), - 0xc, - unknown_array - ); - SetWindowSubclass(hWnd, OwnerDrawSubclassProc, OwnerDrawSubclassProc, 0); + if (bSkinMenus) + { + unknown_array = calloc(4, sizeof(INT64)); + pt.x = x; + pt.y = y; + ImmersiveContextMenuHelper_ApplyOwnerDrawToMenuFunc( + hMenu, + hWnd, + &(pt), + 0xc, + unknown_array + ); + SetWindowSubclass(hWnd, OwnerDrawSubclassProc, OwnerDrawSubclassProc, 0); + } b = TrackPopupMenuEx( hMenu, uFlags | TPM_RIGHTBUTTON, @@ -853,14 +1124,17 @@ BOOL TrackPopupMenuExHook( hWnd, lptpm ); - TrackPopupMenuExElapsed = milliseconds_now(); - RemoveWindowSubclass(hWnd, OwnerDrawSubclassProc, OwnerDrawSubclassProc); - ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( - hMenu, - hWnd, - &(pt) - ); - free(unknown_array); + bthprops_TrackPopupMenuExElapsed = milliseconds_now(); + if (bSkinMenus) + { + RemoveWindowSubclass(hWnd, OwnerDrawSubclassProc, OwnerDrawSubclassProc); + ImmersiveContextMenuHelper_RemoveOwnerDrawFromMenuFunc( + hMenu, + hWnd, + &(pt) + ); + free(unknown_array); + } } return b; } @@ -1009,6 +1283,10 @@ INT64 winrt_Windows_Internal_Shell_implementation_MeetAndChatManager_OnMessageHo INT a3 ) { + if (!bClockFlyoutOnWinC) + { + return winrt_Windows_Internal_Shell_implementation_MeetAndChatManager_OnMessageFunc(_this, a2, a3); + } if (a2 == 786 && a3 == 107) { POINT ptCursor; @@ -1400,7 +1678,7 @@ BOOL explorer_SetChildWindowNoActivateHook(HWND hWnd) BYTE* lpShouldDisplayCCButton = (BYTE*)(GetWindowLongPtrW(hWnd, 0) + 120); if (*lpShouldDisplayCCButton) { - *lpShouldDisplayCCButton = FALSE; + *lpShouldDisplayCCButton = !bHideControlCenterButton; } } return SetChildWindowNoActivateFunc(hWnd); @@ -1532,95 +1810,211 @@ DWORD SignalShellReady(DWORD wait) #pragma endregion -__declspec(dllexport) DWORD WINAPI main( - _In_ LPVOID lpParameter -) +#pragma region "Window Switcher" +DWORD sws_IsEnabled = TRUE; + +void sws_ReadSettings(sws_WindowSwitcher* sws) { -#ifdef DEBUG - FILE* conout; - AllocConsole(); - freopen_s( - &conout, - "CONOUT$", - "w", - stdout - ); -#endif + HKEY hKey = NULL; + DWORD dwSize = 0; - int rv; - if (!funchook) + RegCreateKeyExW( + HKEY_CURRENT_USER, + TEXT(REGPATH) L"\\sws", + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_READ, + NULL, + &hKey, + NULL + ); + if (hKey == NULL || hKey == INVALID_HANDLE_VALUE) { - funchook = funchook_create(); - printf("funchook create %d\n", funchook != 0); - - HKEY hKey = NULL; - DWORD dwDisposition; - DWORD dwSize = sizeof(DWORD); - - - - RegCreateKeyExW( - HKEY_CURRENT_USER, - TEXT(REGPATH), - 0, - NULL, - REG_OPTION_NON_VOLATILE, - KEY_READ, - NULL, - &hKey, - &dwDisposition - ); - if (hKey == NULL || hKey == INVALID_HANDLE_VALUE) - { - hKey = NULL; - } - DWORD bAllocConsole = FALSE; + hKey = NULL; + } + if (hKey) + { + dwSize = sizeof(DWORD); RegQueryValueExW( hKey, - TEXT("AllocConsole"), + TEXT("Enabled"), 0, NULL, - &bAllocConsole, + &sws_IsEnabled, &dwSize ); - printf("AllocConsole %d %d\n", bAllocConsole, hKey); - if (bAllocConsole) + if (sws) { - FILE* conout; - AllocConsole(); - freopen_s( - &conout, - "CONOUT$", - "w", - stdout + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("IncludeWallpaper"), + 0, + NULL, + &(sws->bIncludeWallpaper), + &dwSize ); + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("RowHeight"), + 0, + NULL, + &(sws->dwRowHeight), + &dwSize + ); + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("MaxWidth"), + 0, + NULL, + &(sws->dwMaxWP), + &dwSize + ); + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("MaxHeight"), + 0, + NULL, + &(sws->dwMaxHP), + &dwSize + ); + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("ColorScheme"), + 0, + NULL, + &(sws->dwColorScheme), + &dwSize + ); + sws_WindowSwitcher_RefreshTheme(sws); } - HMODULE hSws = LoadLibraryW(L"SimpleWindowSwitcher.dll"); - if (hSws) - { - printf("Loaded Simple Window Switcher.\n"); - } + RegCloseKey(hKey); + } +} - symbols_addr symbols_PTRS; - ZeroMemory( - &symbols_PTRS, - sizeof(symbols_addr) - ); - - if (LoadSymbols(&symbols_PTRS, hModule)) +DWORD WindowSwitcher(DWORD unused) +{ + while (TRUE) + { + sws_ReadSettings(NULL); + if (sws_IsEnabled) { - printf("Symbols have to be (re)downloaded...\n"); - DownloadSymbolsParams* params = malloc(sizeof(DownloadSymbolsParams)); - params->hModule = hModule; - CreateThread(0, 0, DownloadSymbols, params, 0, 0); - return 0; + sws_error_t err; + sws_WindowSwitcher* sws = NULL; + err = sws_error_Report(sws_error_GetFromInternalError(sws_WindowSwitcher_Initialize(&sws, FALSE)), NULL); + sws_ReadSettings(sws); + if (err == SWS_ERROR_SUCCESS) + { + sws_WindowSwitcher_RefreshTheme(sws); + // set settings + HANDLE hEvents[3]; + hEvents[0] = sws->hEvExit; + hEvents[1] = hSwsSettingsChanged; + hEvents[2] = hSwsOpacityMaybeChanged; + while (TRUE) + { + DWORD dwRes = MsgWaitForMultipleObjectsEx( + 3, + hEvents, + INFINITE, + QS_ALLINPUT, + MWMO_INPUTAVAILABLE + ); + if (dwRes == WAIT_OBJECT_0 + 0) + { + break; + } + if (dwRes == WAIT_OBJECT_0 + 1) + { + sws_ReadSettings(sws); + // set settings + if (!sws_IsEnabled) + { + break; + } + } + else if (dwRes == WAIT_OBJECT_0 + 2) + { + sws_WindowSwitcher_RefreshTheme(sws); + } + else if (dwRes == WAIT_OBJECT_0 + 3) + { + MSG msg; + if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + else + { + break; + } + } + sws_WindowSwitcher_Clear(sws); + } + else + { + return 0; + } } else { - printf("Loaded symbols\n"); + WaitForSingleObject( + hSwsSettingsChanged, + INFINITE + ); } + } +} +#pragma endregion +#pragma region "Load Settings in Explorer" +void Explorer_LoadSettings(int unused) +{ + HKEY hKey = NULL; + DWORD dwSize = 0; + + RegCreateKeyExW( + HKEY_CURRENT_USER, + TEXT(REGPATH), + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_READ, + NULL, + &hKey, + NULL + ); + if (hKey == NULL || hKey == INVALID_HANDLE_VALUE) + { + hKey = NULL; + } + if (hKey) + { + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("AllocConsole"), + 0, + NULL, + &bAllocConsole, + &dwSize + ); + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("OldTaskbar"), + 0, + NULL, + &bOldTaskbar, + &dwSize + ); dwSize = sizeof(DWORD); RegQueryValueExW( hKey, @@ -1649,6 +2043,24 @@ __declspec(dllexport) DWORD WINAPI main( &dwSize ); dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("FlyoutMenus"), + 0, + NULL, + &bFlyoutMenus, + &dwSize + ); + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("CenterMenus"), + 0, + NULL, + &bCenterMenus, + &dwSize + ); + dwSize = sizeof(DWORD); RegQueryValueExW( hKey, TEXT("SkinMenus"), @@ -1675,45 +2087,384 @@ __declspec(dllexport) DWORD WINAPI main( &bReplaceNetwork, &dwSize ); + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("ExplorerReadyDelay"), + 0, + NULL, + &dwExplorerReadyDelay, + &dwSize + ); + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("ArchiveMenu"), + 0, + NULL, + &bEnableArchivePlugin, + &dwSize + ); + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("ClockFlyoutOnWinC"), + 0, + NULL, + &bClockFlyoutOnWinC, + &dwSize + ); + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("DisableImmersiveContextMenu"), + 0, + NULL, + &bDisableImmersiveContextMenu, + &dwSize + ); + RegCloseKey(hKey); + } + + RegCreateKeyExW( + HKEY_CURRENT_USER, + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartPage", + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_READ, + NULL, + &hKey, + NULL + ); + if (hKey == NULL || hKey == INVALID_HANDLE_VALUE) + { + hKey = NULL; + } + if (hKey) + { + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("MonitorOverride"), + 0, + NULL, + &bMonitorOverride, + &dwSize + ); + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("OpenAtLogon"), + 0, + NULL, + &bOpenAtLogon, + &dwSize + ); + RegCloseKey(hKey); + } + + RegCreateKeyExW( + HKEY_CURRENT_USER, + TEXT(REGPATH) L"\\sws", + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_READ, + NULL, + &hKey, + NULL + ); + if (hKey == NULL || hKey == INVALID_HANDLE_VALUE) + { + hKey = NULL; + } + if (hKey) + { + RegCloseKey(hKey); + } + + RegCreateKeyExW( + HKEY_CURRENT_USER, + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MultitaskingView\\AltTabViewHost", + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_READ, + NULL, + &hKey, + NULL + ); + if (hKey == NULL || hKey == INVALID_HANDLE_VALUE) + { + hKey = NULL; + } + if (hKey) + { + RegCloseKey(hKey); + } + + RegCreateKeyExW( + HKEY_CURRENT_USER, + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_READ, + NULL, + &hKey, + NULL + ); + if (hKey == NULL || hKey == INVALID_HANDLE_VALUE) + { + hKey = NULL; + } + if (hKey) + { + RegCloseKey(hKey); + } + + RegCreateKeyExW( + HKEY_CURRENT_USER, + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Search", + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_READ, + NULL, + &hKey, + NULL + ); + if (hKey == NULL || hKey == INVALID_HANDLE_VALUE) + { + hKey = NULL; + } + if (hKey) + { + RegCloseKey(hKey); + } + + RegCreateKeyExW( + HKEY_CURRENT_USER, + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced\\People", + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_READ, + NULL, + &hKey, + NULL + ); + if (hKey == NULL || hKey == INVALID_HANDLE_VALUE) + { + hKey = NULL; + } + if (hKey) + { + RegCloseKey(hKey); + } + + RegCreateKeyExW( + HKEY_CURRENT_USER, + L"SOFTWARE\\Microsoft\\TabletTip\\1.7", + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_READ, + NULL, + &hKey, + NULL + ); + if (hKey == NULL || hKey == INVALID_HANDLE_VALUE) + { + hKey = NULL; + } + if (hKey) + { + RegCloseKey(hKey); + } +} + +void Explorer_RefreshUI(int unused) +{ + SendNotifyMessageW(HWND_BROADCAST, WM_WININICHANGE, 0, (LPARAM)L"TraySettings"); +} + +void Explorer_TogglePeopleButton(int unused) +{ + HWND hShellTray_Wnd = FindWindowExW(NULL, NULL, L"Shell_TrayWnd", NULL); + if (hShellTray_Wnd) + { + INT64* CTrayInstance = (BYTE*)(GetWindowLongPtrW(hShellTray_Wnd, 0)); // -> CTray + const unsigned int TRAYUI_OFFSET_IN_CTRAY = 110; + INT64* TrayUIInstance = *((INT64*)CTrayInstance + TRAYUI_OFFSET_IN_CTRAY); + + ((void(*)(void*))(*(INT64*)((*(INT64*)TrayUIInstance) + 57 * sizeof(uintptr_t))))(TrayUIInstance); + } +} + +void Explorer_ToggleTouchpad(int unused) +{ + HWND hShellTray_Wnd = FindWindowExW(NULL, NULL, L"Shell_TrayWnd", NULL); + if (hShellTray_Wnd) + { + INT64* CTrayInstance = (BYTE*)(GetWindowLongPtrW(hShellTray_Wnd, 0)); // -> CTray + const unsigned int TRAYUI_OFFSET_IN_CTRAY = 110; + INT64* TrayUIInstance = *((INT64*)CTrayInstance + TRAYUI_OFFSET_IN_CTRAY); + + ((void(*)(void*))(*(INT64*)((*(INT64*)TrayUIInstance) + 60 * sizeof(uintptr_t))))(TrayUIInstance); + } +} +#pragma endregion + + +__declspec(dllexport) DWORD WINAPI main( + _In_ LPVOID lpParameter +) +{ +#ifdef DEBUG + FILE* conout; + AllocConsole(); + freopen_s( + &conout, + "CONOUT$", + "w", + stdout + ); +#endif + + int rv; + if (!funchook) + { + funchook = funchook_create(); + printf("funchook create %d\n", funchook != 0); + Explorer_LoadSettings(0); + + hSwsSettingsChanged = CreateEventW(NULL, FALSE, FALSE, NULL); + hSwsOpacityMaybeChanged = CreateEventW(NULL, FALSE, FALSE, NULL); + + Setting* settings = calloc(8, sizeof(Setting)); + settings[0].callback = Explorer_LoadSettings; + settings[0].data = NULL; + settings[0].hEvent = NULL; + settings[0].hKey = NULL; + wcscpy_s(settings[0].name, MAX_PATH, TEXT(REGPATH)); + settings[0].origin = HKEY_CURRENT_USER; + + settings[1].callback = Explorer_LoadSettings; + settings[1].data = NULL; + settings[1].hEvent = NULL; + settings[1].hKey = NULL; + wcscpy_s(settings[1].name, MAX_PATH, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartPage"); + settings[1].origin = HKEY_CURRENT_USER; + + settings[2].callback = SetEvent; + settings[2].data = hSwsSettingsChanged; + settings[2].hEvent = NULL; + settings[2].hKey = NULL; + wcscpy_s(settings[2].name, MAX_PATH, TEXT(REGPATH) L"\\sws"); + settings[2].origin = HKEY_CURRENT_USER; + + settings[3].callback = SetEvent; + settings[3].data = hSwsOpacityMaybeChanged; + settings[3].hEvent = NULL; + settings[3].hKey = NULL; + wcscpy_s(settings[3].name, MAX_PATH, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MultitaskingView\\AltTabViewHost"); + settings[3].origin = HKEY_CURRENT_USER; + + settings[4].callback = Explorer_RefreshUI; + settings[4].data = NULL; + settings[4].hEvent = NULL; + settings[4].hKey = NULL; + wcscpy_s(settings[4].name, MAX_PATH, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"); + settings[4].origin = HKEY_CURRENT_USER; + + settings[5].callback = Explorer_RefreshUI; + settings[5].data = NULL; + settings[5].hEvent = NULL; + settings[5].hKey = NULL; + wcscpy_s(settings[5].name, MAX_PATH, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Search"); + settings[5].origin = HKEY_CURRENT_USER; + + settings[6].callback = Explorer_RefreshUI; + settings[6].data = NULL; + settings[6].hEvent = NULL; + settings[6].hKey = NULL; + wcscpy_s(settings[6].name, MAX_PATH, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced\\People"); + settings[6].origin = HKEY_CURRENT_USER; + + settings[7].callback = Explorer_RefreshUI; + settings[7].data = NULL; + settings[7].hEvent = NULL; + settings[7].hKey = NULL; + wcscpy_s(settings[7].name, MAX_PATH, L"SOFTWARE\\Microsoft\\TabletTip\\1.7"); + settings[7].origin = HKEY_CURRENT_USER; + + SettingsChangeParameters* params = calloc(1, sizeof(SettingsChangeParameters)); + params->settings = settings; + params->size = 8; + CreateThread( + 0, + 0, + MonitorSettings, + params, + 0, + 0 + ); - /* - TCHAR* wszSBPath = malloc((MAX_PATH + 1) * sizeof(TCHAR)); - if (!wszSBPath) + if (bAllocConsole) { - return 0; + FILE* conout; + AllocConsole(); + freopen_s( + &conout, + "CONOUT$", + "w", + stdout + ); } - ZeroMemory( - wszSBPath, - (MAX_PATH + 1) * sizeof(TCHAR) - ); - SHGetFolderPathW( - NULL, - CSIDL_APPDATA, - NULL, - SHGFP_TYPE_CURRENT, - wszSBPath - ); - wcscat_s( - wszSBPath, - MAX_PATH, - TEXT(APP_RELATIVE_PATH) L"\\StartAllBackX64.dll" + + + CreateThread( + 0, + 0, + WindowSwitcher, + 0, + 0, + 0 ); - hStartIsBack64 = LoadLibraryW(wszSBPath); - free(wszSBPath); - */ + symbols_addr symbols_PTRS; + ZeroMemory( + &symbols_PTRS, + sizeof(symbols_addr) + ); + if (LoadSymbols(&symbols_PTRS, hModule)) + { + printf("Symbols have to be (re)downloaded...\n"); + DownloadSymbolsParams* params = malloc(sizeof(DownloadSymbolsParams)); + params->hModule = hModule; + CreateThread(0, 0, DownloadSymbols, params, 0, 0); + return 0; + } + else + { + printf("Loaded symbols\n"); + } + - HANDLE hExplorer = GetModuleHandle(NULL); + HANDLE hExplorer = GetModuleHandleW(NULL); SetChildWindowNoActivateFunc = GetProcAddress(GetModuleHandleW(L"user32.dll"), (LPCSTR)2005); - if (bHideControlCenterButton) + 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); + VnPatchIAT(hExplorer, "api-ms-win-core-libraryloader-l1-2-0.dll", "GetProcAddress", explorer_GetProcAddressHook); } - 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, "user32.dll", "TrackPopupMenuEx", TrackPopupMenuExHook); printf("Setup explorer functions done\n"); @@ -1784,10 +2535,7 @@ __declspec(dllexport) DWORD WINAPI main( HANDLE hStobject = LoadLibraryW(L"stobject.dll"); - if (bSkinMenus) - { - VnPatchDelayIAT(hStobject, "user32.dll", "TrackPopupMenu", TrackPopupMenuHook); - } + VnPatchDelayIAT(hStobject, "user32.dll", "TrackPopupMenu", stobject_TrackPopupMenuHook); #ifdef USE_PRIVATE_INTERFACES if (bSkinIcons) { @@ -1799,10 +2547,7 @@ __declspec(dllexport) DWORD WINAPI main( HANDLE hBthprops = LoadLibraryW(L"bthprops.cpl"); - if (bSkinMenus) - { - VnPatchIAT(hBthprops, "user32.dll", "TrackPopupMenuEx", TrackPopupMenuExHook); - } + VnPatchIAT(hBthprops, "user32.dll", "TrackPopupMenuEx", bthprops_TrackPopupMenuExHook); #ifdef USE_PRIVATE_INTERFACES if (bSkinIcons) { @@ -1815,10 +2560,7 @@ __declspec(dllexport) DWORD WINAPI main( HANDLE hPnidui = LoadLibraryW(L"pnidui.dll"); VnPatchIAT(hPnidui, "api-ms-win-core-com-l1-1-0.dll", "CoCreateInstance", pnidui_CoCreateInstanceHook); - if (bSkinMenus || bReplaceNetwork) - { - VnPatchIAT(hPnidui, "user32.dll", "TrackPopupMenu", pnidui_TrackPopupMenuHook); - } + VnPatchIAT(hPnidui, "user32.dll", "TrackPopupMenu", pnidui_TrackPopupMenuHook); #ifdef USE_PRIVATE_INTERFACES if (bSkinIcons) { @@ -1831,10 +2573,7 @@ __declspec(dllexport) DWORD WINAPI main( HANDLE hSndvolsso = LoadLibraryW(L"sndvolsso.dll"); - if (bSkinMenus) - { - VnPatchIAT(hSndvolsso, "user32.dll", "TrackPopupMenuEx", sndvolsso_TrackPopupMenuExHook); - } + VnPatchIAT(hSndvolsso, "user32.dll", "TrackPopupMenuEx", sndvolsso_TrackPopupMenuExHook); #ifdef USE_PRIVATE_INTERFACES if (bSkinIcons) { @@ -1848,10 +2587,17 @@ __declspec(dllexport) DWORD WINAPI main( HANDLE hExplorerFrame = LoadLibraryW(L"ExplorerFrame.dll"); explorerframe_SHCreateWorkerWindowFunc = GetProcAddress(LoadLibraryW(L"shcore.dll"), (LPCSTR)188); VnPatchIAT(hExplorerFrame, "shcore.dll", (LPCSTR)188, explorerframe_SHCreateWorkerWindowHook); + VnPatchIAT(hExplorerFrame, "user32.dll", "TrackPopupMenu", TrackPopupMenuHook); printf("Setup ExplorerFrame functions done\n"); + HANDLE hShell32 = LoadLibraryW(L"shell32.dll"); + VnPatchIAT(hShell32, "user32.dll", "TrackPopupMenu", shell32_TrackPopupMenuHook); + printf("Setup shell32 functions done\n"); + + + rv = funchook_install(funchook, 0); if (rv != 0) { @@ -1861,18 +2607,6 @@ __declspec(dllexport) DWORD WINAPI main( printf("Installed hooks.\n"); - /* - if (hStartIsBack64) - { - ((void(*)())((uintptr_t)hStartIsBack64 + SB_INIT1))(); - - ((void(*)())((uintptr_t)hStartIsBack64 + SB_INIT2))(); - - printf("Loaded and initialized StartIsBack64 DLL\n"); - } - */ - - HANDLE hEvent = CreateEventEx( 0, L"ShellDesktopSwitchEvent", @@ -1883,8 +2617,6 @@ __declspec(dllexport) DWORD WINAPI main( printf("Created ShellDesktopSwitchEvent event.\n"); - - CreateThread( 0, 0, @@ -1896,29 +2628,17 @@ __declspec(dllexport) DWORD WINAPI main( printf("Play startup sound thread...\n"); - - DWORD delay = 0; - RegQueryValueExW( - hKey, - TEXT("ExplorerReadyDelay"), - 0, - NULL, - &delay, - &dwSize - ); CreateThread( 0, 0, SignalShellReady, - delay, + dwExplorerReadyDelay, 0, 0 ); printf("Signal shell ready...\n"); - - CreateThread( 0, 0, @@ -1930,18 +2650,6 @@ __declspec(dllexport) DWORD WINAPI main( printf("Open Start on monitor thread\n"); - - - - DWORD bEnableArchivePlugin = 0; - RegQueryValueExW( - hKey, - TEXT("ArchiveMenu"), - 0, - NULL, - &bEnableArchivePlugin, - &dwSize - ); if (bEnableArchivePlugin) { ArchiveMenuThreadParams* params = calloc(1, sizeof(ArchiveMenuThreadParams)); @@ -1960,13 +2668,11 @@ __declspec(dllexport) DWORD WINAPI main( } - - HookStartMenuParams* params = calloc(1, sizeof(HookStartMenuParams)); - params->dwTimeout = 1000; - params->hModule = hModule; - GetModuleFileNameW(hModule, params->wszModulePath, MAX_PATH); - CreateThread(0, 0, HookStartMenu, params, 0, 0); - + HookStartMenuParams* params2 = calloc(1, sizeof(HookStartMenuParams)); + params2->dwTimeout = 1000; + params2->hModule = hModule; + GetModuleFileNameW(hModule, params2->wszModulePath, MAX_PATH); + CreateThread(0, 0, HookStartMenu, params2, 0, 0); // This notifies applications when the taskbar has recomputed its layout @@ -1980,10 +2686,6 @@ __declspec(dllexport) DWORD WINAPI main( } - if (hKey) - { - RegCloseKey(hKey); - } //CreateThread(0, 0, PositionStartMenuTimeout, 0, 0, 0); @@ -2023,6 +2725,72 @@ char VisibilityChangedEventArguments_GetVisible(__int64 a1) return v3[0]; } +DWORD StartMenu_maximumFreqApps = 6; +DWORD StartMenu_ShowAllApps = 0; + +void StartMenu_LoadSettings(int unused) +{ + HKEY hKey = NULL; + DWORD dwSize; + + RegCreateKeyExW( + HKEY_CURRENT_USER, + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartPage", + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_READ, + NULL, + &hKey, + NULL + ); + if (hKey == NULL || hKey == INVALID_HANDLE_VALUE) + { + hKey = NULL; + } + if (hKey) + { + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("MakeAllAppsDefault"), + 0, + NULL, + &StartMenu_ShowAllApps, + &dwSize + ); + RegCloseKey(hKey); + } + RegCreateKeyExW( + HKEY_CURRENT_USER, + TEXT(REGPATH), + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_READ, + NULL, + &hKey, + NULL + ); + if (hKey == NULL || hKey == INVALID_HANDLE_VALUE) + { + hKey = NULL; + } + if (hKey) + { + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("Start_MaximumFrequentApps"), + 0, + NULL, + &StartMenu_maximumFreqApps, + &dwSize + ); + RegCloseKey(hKey); + } +} + static INT64(*StartDocked_LauncherFrame_OnVisibilityChangedFunc)(void*, INT64, void*); static INT64(*StartDocked_LauncherFrame_ShowAllAppsFunc)(void* _this); @@ -2030,41 +2798,21 @@ static INT64(*StartDocked_LauncherFrame_ShowAllAppsFunc)(void* _this); INT64 StartDocked_LauncherFrame_OnVisibilityChangedHook(void* _this, INT64 a2, void* VisibilityChangedEventArguments) { INT64 r = StartDocked_LauncherFrame_OnVisibilityChangedFunc(_this, a2, VisibilityChangedEventArguments); - HMODULE hModule = LoadLibraryW(L"Shlwapi.dll"); - if (hModule) + if (StartMenu_ShowAllApps) { - DWORD dwStatus = 0, dwSize = sizeof(DWORD); - FARPROC SHRegGetValueFromHKCUHKLMFunc = GetProcAddress(hModule, "SHRegGetValueFromHKCUHKLM"); - if (!SHRegGetValueFromHKCUHKLMFunc || SHRegGetValueFromHKCUHKLMFunc( - TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartPage"), - TEXT("MakeAllAppsDefault"), - SRRF_RT_REG_DWORD, - NULL, - &dwStatus, - (LPDWORD)(&dwSize) - ) != ERROR_SUCCESS) - { - dwStatus = 0; - } - FreeLibrary(hModule); - if (dwStatus) + //if (VisibilityChangedEventArguments_GetVisible(VisibilityChangedEventArguments)) { - //if (VisibilityChangedEventArguments_GetVisible(VisibilityChangedEventArguments)) - { - StartDocked_LauncherFrame_ShowAllAppsFunc(_this); - } + StartDocked_LauncherFrame_ShowAllAppsFunc(_this); } } return r; } -INT64 maximumFreqApps; - INT64(*StartDocked_SystemListPolicyProvider_GetMaximumFrequentAppsFunc)(void*); INT64 StartDocked_SystemListPolicyProvider_GetMaximumFrequentAppsHook(void* _this) { - return maximumFreqApps; + return StartMenu_maximumFreqApps; } INT64(*StartDocked_StartSizingFrame_StartSizingFrameFunc)(void* _this); @@ -2130,6 +2878,34 @@ BOOL WINAPI DllMain( { funchook = funchook_create(); + StartMenu_LoadSettings(0); + + Setting* settings = calloc(2, sizeof(Setting)); + settings[0].callback = StartMenu_LoadSettings; + settings[0].data = 0; + settings[0].hEvent = NULL; + settings[0].hKey = NULL; + wcscpy_s(settings[0].name, MAX_PATH, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartPage"); + settings[0].origin = HKEY_CURRENT_USER; + settings[1].callback = exit; + settings[1].data = 0; + settings[1].hEvent = NULL; + settings[1].hKey = NULL; + wcscpy_s(settings[1].name, MAX_PATH, TEXT(REGPATH)); + settings[1].origin = HKEY_CURRENT_USER; + + SettingsChangeParameters* params = calloc(1, sizeof(SettingsChangeParameters)); + params->settings = settings; + params->size = 2; + CreateThread( + 0, + 0, + MonitorSettings, + params, + 0, + 0 + ); + int rv; DWORD dwVal0 = 0x62254, dwVal1 = 0x188EBC, dwVal2 = 0x187120, dwVal3 = 0x3C10, dwVal4 = 0x160AEC; @@ -2139,18 +2915,6 @@ BOOL WINAPI DllMain( { DWORD dwStatus = 0, dwSize = sizeof(DWORD); FARPROC SHRegGetValueFromHKCUHKLMFunc = GetProcAddress(hModule, "SHRegGetValueFromHKCUHKLM"); - if (!SHRegGetValueFromHKCUHKLMFunc || SHRegGetValueFromHKCUHKLMFunc( - TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"), - TEXT("Start_MaximumFrequentApps"), - SRRF_RT_REG_DWORD, - NULL, - &dwStatus, - (LPDWORD)(&dwSize) - ) != ERROR_SUCCESS) - { - dwStatus = 6; - } - maximumFreqApps = dwStatus; if (SHRegGetValueFromHKCUHKLMFunc) { @@ -2201,17 +2965,6 @@ BOOL WINAPI DllMain( FreeLibrary(hModule); } - SettingsChangeParameters* params = calloc(1, sizeof(SettingsChangeParameters)); - params->isStartMenuExperienceHost = TRUE; - CreateThread( - 0, - 0, - MonitorSettingsChanges, - params, - 0, - 0 - ); - LoadLibraryW(L"StartDocked.dll"); HANDLE hStartDocked = GetModuleHandle(L"StartDocked.dll"); StartDocked_LauncherFrame_ShowAllAppsFunc = (INT64(*)(void*)) @@ -2240,7 +2993,7 @@ BOOL WINAPI DllMain( FreeLibraryAndExitThread(hModule, rv); return rv; } - StartDocked_StartSizingFrame_StartSizingFrameFunc = (INT64(*)(void*, INT64, void*)) + /*StartDocked_StartSizingFrame_StartSizingFrameFunc = (INT64(*)(void*, INT64, void*)) ((uintptr_t)hStartDocked + dwVal4); rv = funchook_prepare( funchook, @@ -2251,7 +3004,7 @@ BOOL WINAPI DllMain( { FreeLibraryAndExitThread(hModule, rv); return rv; - } + }*/ rv = funchook_install(funchook, 0); if (rv != 0) diff --git a/ExplorerPatcher/settings.reg b/ExplorerPatcher/settings.reg index eab24b3..7ad7241 100644 --- a/ExplorerPatcher/settings.reg +++ b/ExplorerPatcher/settings.reg @@ -3,62 +3,88 @@ ;M Settings ;T Taskbar +[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher] +;b Enable Windows 10 taskbar * +"OldTaskbar"=dword:00000001 +;t The following settings only apply to the Windows 10 taskbar: ;l Enable missing system tray icons ;shell:::{05d7b0f4-2121-4eff-bf6b-ed3f69b894d9}\SystemIcons [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced] -;c 3 Combine taskbar icons on main taskbar * +;c 3 Combine taskbar icons on main taskbar ;x 0 Always combine ;x 1 Combine when taskbar is full ;x 2 Never combine "TaskbarGlomLevel"=dword:00000002 -;c 3 Combine taskbar icons on other taskbars * +;c 3 Combine taskbar icons on other taskbars ;x 0 Always combine ;x 1 Combine when taskbar is full ;x 2 Never combine "MMTaskbarGlomLevel"=dword:00000002 -;c 2 Taskbar icon size * +;c 2 Taskbar icon size ;x 1 Small ;x 0 Large (default) "TaskbarSmallIcons"=dword:00000000 +;b Show Task view button +"ShowTaskViewButton"=dword:00000000 +[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Search] +;b Show Search button +"SearchboxTaskbarMode"=dword:00000000 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher] -;b Disable Control Center button * -"HideControlCenterButton"=dword:00000000 -;b Center and skin system tray icon menus * +;b Skin taskbar and tray pop-up menus "SkinMenus"=dword:00000001 +;b Center tray icon pop-up menus +"CenterMenus"=dword:00000001 +;b Flyout behavior for tray icon pop-up menus +"FlyoutMenus"=dword:00000001 +;b Open Network and Sharing Center from pop-up menu of network tray icon +"ReplaceNetwork"=dword:00000000 +;b Hide Control Center button * +"HideControlCenterButton"=dword:00000000 ;p 2 ;b Apply Windows 11 style to system tray icons * "SkinIcons"=dword:00000001 -;b Open network settings in Control Panel for system tray icon * -"ReplaceNetwork"=dword:00000000 +[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People] +;b Show People on the taskbar * +"PeopleBand"=dword:00000000 +[HKEY_CURRENT_USER\Software\Microsoft\TabletTip\1.7] +;b Show touch keyboard button * +"TipbandDesiredVisibility"=dword:00000000 ;T File Explorer -[-HKEY_CURRENT_USER\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32] -;d Disable immersive context menu * -@="" [-HKEY_CURRENT_USER\Software\Classes\CLSID\{d93ed569-3b3e-4bff-8355-3c44f6a52bb5}\InprocServer32] -;d Disable command bar * +;d Disable the Windows 11 command bar * +@="" +[-HKEY_CURRENT_USER\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32] +;d Disable the Windows 11 context menu * @="" +[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher] +;b Disable the Windows 10 (immersive) context menu +"DisableImmersiveContextMenu"=dword:00000000 [-HKEY_CURRENT_USER\Software\Classes\CLSID\{1d64637d-31e9-4b06-9124-e83fb178ac6e}\TreatAs] ;d Disable modern search bar @="{64bc32b5-4eec-4de7-972d-bd8bd0324537}" [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher] -;b Hide search bar completely * +;b Hide search bar completely "HideExplorerSearchBar"=dword:00000000 ;p 2 -;b Mica effect on title bar * +;b Mica effect on title bar "MicaEffectOnTitlebar"=dword:00000000 ;T Start menu +[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StartPage] +;i Open Start on monitor containing the cursor +"MonitorOverride"=dword:00000001 +;b Open Start at logon +"OpenAtLogon"=dword:00000000 +;b Open Start in All apps by default +"MakeAllAppsDefault"=dword:00000000 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced] ;c 2 Location on screen * ;x 0 Left ;x 1 Center (default) "TaskbarAl"=dword:00000001 -[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StartPage] -;b Open Start to All apps by default -"MakeAllAppsDefault"=dword:00000000 -[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced] -;c 22 Maximum number of frequent apps to show in Start +[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher] +;c 22 Maximum number of frequent apps to show ;x 0 None ;x 1 1 ;x 2 2 @@ -83,7 +109,98 @@ ;x 99999 Unlimited "Start_MaximumFrequentApps"=dword:00000006 +;T Window switcher +[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher\sws] +;b Use Windows 10 window switcher (Alt+Tab) +"Enabled"=dword:00000000 +;t The following settings only apply to the Windows 10 window switcher: +;b Include desktop +"IncludeWallpaper"=dword:00000001 +;c 3 Color scheme +;x 0 Follow system setting (default) +;x 1 Light +;x 2 Dark +"ColorScheme"=dword:00000000 +[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MultitaskingView\AltTabViewHost] +;c 15 Opacity +;x 100 Opaque +;x 95 95 % +;x 90 90 % +;x 85 85 % +;x 80 80 % +;x 75 75 % +;x 70 70 % +;x 65 65 % +;x 60 60 % (default) +;x 55 55 % +;x 50 50 % +;x 45 45 % +;x 40 40 % +;x 35 35 % +;x 30 30 % +"Grid_backgroundPercent"=dword:0000003c +[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher\sws] +;c 15 Row height +;x 330 330 pt +;x 320 320 pt +;x 310 310 pt +;x 300 300 pt +;x 290 290 pt +;x 280 280 pt +;x 270 270 pt +;x 260 260 pt +;x 250 250 pt (default) +;x 240 240 pt +;x 230 230 pt +;x 220 220 pt +;x 210 210 pt +;x 200 200 pt +;x 190 190 pt +"RowHeight"=dword:000000fa +;c 10 Maximum width (percentage of screen width) +;x 100 100 % (not recommended) +;x 95 95 % +;x 90 90 % +;x 85 85 % +;x 80 80 % (default) +;x 75 75 % +;x 70 70 % +;x 65 65 % +;x 60 60 % +;x 55 55 % +"MaxWidth"=dword:00000050 +;c 10 Maximum height (percentage of screen height) +;x 100 100 % (not recommended) +;x 95 95 % +;x 90 90 % +;x 85 85 % +;x 80 80 % (default) +;x 75 75 % +;x 70 70 % +;x 65 65 % +;x 60 60 % +;x 55 55 % +"MaxHeight"=dword:00000050 + + +;T Other +[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher] +;b Open clock flyout when pressing Win+C instead of Microsoft Teams +"ClockFlyoutOnWinC"=dword:00000000 +[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced] +;c 6 Default action in shutdown dialog (Alt+F4 on desktop) +;x 256 Switch user +;x 1 Sign out +;x 16 Sleep +;x 64 Hibernate +;x 2 Shut down (default) +;x 4 Restart +"Start_PowerButtonAction"=dword:00000002 +;b Show Command Prompt instead of PowerShell in Win+X menu * +"DontUsePowerShellOnWinX"=dword:00000000 + ;T Advanced +;t Only change these settings if you know what you are doing. You've been warned! [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher] ;b Enable console * "AllocConsole"=dword:00000000 @@ -96,11 +213,30 @@ ;x 2000 2 seconds ;x 3000 3 seconds "ExplorerReadyDelay"=dword:00000000 +[HKEY_CURRENT_USER\Control Panel\Desktop] +;b Show Windows build info on the desktop * +"PaintDesktopversion"=dword:00000000 + +;T About +;t Version %VERSIONINFO% +;t Copyright (C) 2006-2021 VALINET Solutions SRL. All rights reserved. +;t +;t This project aims to bring back a productive working environment on Windows 11. +;t Proudly programmed by Valentin-Gabriel Radu. +;l Visit project GitHub (https://github.com/valinet) +;https://github.com/valinet +;l Visit web site (https://www.valinet.ro) +;https://www.valinet.ro +;l E-mail author (valentingabrielradu@gmail.com) +;mailto:valentingabrielradu@gmail.com +;l Donate (using PayPal) +;https://www.paypal.com/donate?business=valentingabrielradu%40gmail.com&no_recurring=0&item_name=ExplorerPatcher¤cy_code=EUR +;f ;t Settings marked with an (*) require restarting the File Explorer process. ;u Restart File Explorer ;restart ;u Restore default settings ;reset -;u About ExplorerPatcher -;about \ No newline at end of file +;;u About ExplorerPatcher +;;about \ No newline at end of file diff --git a/ExplorerPatcher/utility.c b/ExplorerPatcher/utility.c index 8923019..6f5de29 100644 --- a/ExplorerPatcher/utility.c +++ b/ExplorerPatcher/utility.c @@ -284,7 +284,7 @@ POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight, BOO { RECT rc; GetWindowRect(hWnd, &rc); - if (rc.left - mi.rcMonitor.left == 0) + if (rc.left - mi.rcMonitor.left <= 0) { if (bUseRcWork) { @@ -298,7 +298,7 @@ POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight, BOO { point.x++; } - if (rc.top - mi.rcMonitor.top == 0) + if (rc.top - mi.rcMonitor.top <= 0) { if (bUseRcWork) { @@ -345,7 +345,7 @@ POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight, BOO { point.x--; } - if (rc.top - mi.rcMonitor.top == 0) + if (rc.top - mi.rcMonitor.top <= 0) { if (bUseRcWork) { diff --git a/README.md b/README.md index bf925e5..acbf7e1 100644 --- a/README.md +++ b/README.md @@ -12,41 +12,63 @@ PayPal donations: [here](https://www.paypal.com/donate?business=valentingabrielr +The functionality of this software includes: + +* Taskbar from Windows 10: + * "always combine" / "combine when full" / "never combine" options for main and secondary taskbars + * Search button + * Task View button + * optional skinned, centered and toggled pop-up menus, or non-skinned (useful for classic theme users) + * open "Network and Sharing Center" when clicking "Open Network & Internet settings" in the pop-ip menu of the system tray network icon + * hide Control Center button + * Show People on the taskbar + * Show touch keyboard button + +* File Explorer + * disable the Windows 11 command bar + * disable the Windows 11 context menu + * disable even the Windows 10 (immersive) context menu (useful for classic theme users) + * disable modern search bar (reverts to the search bar in early Windows 10 builds or Windows 7/8) + * disable search bar completely +* Start menu from Windows 11 + * open Start on monitor containing the cursor + * open Start at logon + * open Start in "All apps" by default + * positioning on screen + * maximum number of frequent apps to show +* Window switcher (Alt-Tab) from Windows 10: + * choose whether to include desktop in the window list + * ability to set opacity of the window list + * set row size, maximum extents etc +* Others + * Open the time and date flyout when pressing `Win`+`C` (instead of Microsoft Teams) + * Set default shutdown action for `Alt`+`F4` on the desktop + * Show Command Prompt instead of PowerShell in the `Win`+`X` menu + Screenshots: [<1>](https://gist.githubusercontent.com/valinet/d0f72ff09773702584e77c46065b95e0/raw/94036ed3e38218b87744a29ae5c40b06be637daf/ep_img0.png) [<2>](https://user-images.githubusercontent.com/6503598/131937638-d513ca72-ead7-459b-a8ce-619fb302b7da.png) ## dxgi.dll - the patcher -In the [Releases](https://github.com/valinet/ExplorerPatcher/releases) section, you will find a download for a DLL called `dxgi.dll`. It has been tested on the latest stable build of Windows 11 (22000.258), but it may work just fine on newer builds too. This is the runtime part of the application. You need to place this DLL in the following location: `C:\Windows`. This will enable the following functionality: - -* use the classic taskbar from Windows 10 (without the nasty effects of `UndockingDisabled`) -* restores the classic power user menu (`Win+X`) when using the classic taskbar -* Start menu follows the taskbar alignment setting (`Left`/`Center`) specified in `Settings\Personalization\Taskbar\Taskbar behaviors\Taskbar alignment` -* ability to show the Start menu on the monitor containing the cursor when pressing the Windows key -* skin "Safe to Remove Hardware" and "Bluetooth" popup menus -* play log on sound, if enabled -* option to hide the search bar in File Explorer -* option to disable the control center button in the taskbar -* show the "All apps" list by default when opening the Start menu -* customize the maximum number of "Most used" apps displayed in the "All apps" list in Start -* disable the immersive contex menu system-wide -* disable the Windows 11 File Explorer command bar +In the [Releases](https://github.com/valinet/ExplorerPatcher/releases) section, you will find a download for a DLL called `dxgi.dll`. It has been tested on the latest stable build of Windows 11 (22000.258), but it may work just fine on newer builds too. This is the runtime part of the application. You need to place this DLL in the following location: `C:\Windows`. After you have completed the above setup, make sure you have an active Internet connection and restart the Explorer process using Task Manager or by issuing the following command: `taskkill /f /im explorer.exe`. Once File Explorer restarts, some necessary files (symbol files) will be downloaded from Microsoft (around 50MB). This should be relatively quick, depending on your Internet connection speed. When this is done, File Explorer will restart again and will be ready for use. Notifications should show up informing you about the progress, and you can also use Task Manager to watch for network activity. This process only happens when a new Windows 11 build is installed on the machine. Now, the classic taskbar should be enabled. Still, there is some more setup to do, depending on your preferences. +Important! As you may notice, the usual system tray icons are not enabled by default. To enable them, open the GUI (`Win`+`X` and choose "Enable missing system tray icons"). + ## Configuration interface -To configure the most common options, the application now comes with a configuration user interface. To open it, right click the Start button (or press `Win`+`X`) and choose "Properties". Alternatively, to open the GUI standalone, run the following command: `rundll32.exe C:\Windows\dxgi.dll,ZZGUI`. +To configure the most common options, the application now comes with a configuration user interface. To open it, right click the Start button (or press `Win`+`X`) and choose "Properties". + +All of the options described above, and more, can be configured using the GUI. Below is a screenshot of the main page ("Taskbar") of the configuration interface. - + The icon near an option signifies its current state: * ✔️ enabled * ❌ disabled -* ➕ performs an action that allows you to change that option (usually, the current value is located after the colon in its description) - -The links at the bottom allow you to perform the most frequent actions. +* ➕ link to another resource ## Recommended tools @@ -70,137 +92,8 @@ You can try one of my other utilities available [here](https://github.com/valine ## Manual configuration -To learn how to configure all the options manually, read on: - -### Enable system tray icons -As you have noticed, some system tray icons are missing (for example, the clock, notification center button, network, battery, sound etc). To enable these icons, open the following using Run: - -``` -%windir%\explorer.exe shell:::{05d7b0f4-2121-4eff-bf6b-ed3f69b894d9}\SystemIcons -``` - -In the window that appears, toggle to `On` whatever icons you would like to have enabled in the taskbar. - -### Show labels for taskbar buttons -One of the great features the old taskbar had was the ability to ungroup the taskbar buttons, showing a button with a label for each window that the user currently has open. To enable this functionality, run either of the following commands, depending on your preference. - -#### Ungroup icons on all taskbars - -Run this command as administrator: -``` -reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /f /v "NoTaskGrouping" /t REG_DWORD /d 1 -``` - -#### Ungroup icons on main taskbar only - -``` -reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /f /v "TaskbarGlomLevel" /t REG_DWORD /d 2 -``` - -#### Ungroup icons on secondary taskbars - -``` -reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /f /v "MMTaskbarGlomLevel" /t REG_DWORD /d 2 -``` - -In the commands above, change `2` to `0` for "Always combine" and `2` to `1` for "Combine when taskbar is full`. - -### Disable the immersive context menu - -As you probably have noticed, Windows 11 introduced a simplified context menu in File Explorer. To get to the old menu which contains all entries from shell extensions, one has to click on "Show more options" or type Shift+F10. To disable this new menu, run the following command: - -``` -reg.exe add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve -``` - -To restore back the immersive menu, run: - -``` -reg.exe delete "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}" /f -``` - -### Disable the command bar in File Explorer -In Windows 11, File Explorer comes with a command bar instead of the traditional ribbon. To disable this and get back the ribbon, run the following command: - -``` -reg.exe add "HKCU\Software\Classes\CLSID\{d93ed569-3b3e-4bff-8355-3c44f6a52bb5}\InprocServer32" /f /ve -``` - -To restore back the command bar, run: - -``` -reg.exe delete "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}" /f -``` - -If you want to get back the command bar from Windows 7, after enabling back the ribbon, [OldNewExplorer](https://msfn.org/board/topic/170375-oldnewexplorer-119/) will allow you to do so, and many more options, like drive ungrouping in This PC, as it used to be prior to Windows 8.1. - -### Disable the modern search box in File Explorer -In Windows 10 1903, Microsoft introduced a new search box in File Explorer. This new search control is clunky, does not search automatically and usually is kind of broken. The old search box remains available, but only in Control Panel windows. To enable it on all File Explorer windows, run the following command: - -``` -reg.exe add "HKCU\Software\Classes\CLSID\{1d64637d-31e9-4b06-9124-e83fb178ac6e}\TreatAs" /f /ve /t REG_SZ /d "{64bc32b5-4eec-4de7-972d-bd8bd0324537}" -``` - -To restore the modern search box, run: - -``` -reg.exe delete "HKCU\Software\Classes\CLSID\{1d64637d-31e9-4b06-9124-e83fb178ac6e}" /f -``` - -Also, in the next section, which desribes the configuration options for the software, you will learn about how to disable the search box altogether, should you want to. - -### Patcher settings -Now that you have set up the basic stuff, you can choose to enable additional settings to enhance the experience even more. For this, customize the following commands by changing the number acording to your needs: - -* `HideExplorerSearchBar` completely removes the search box in File Explorer (default = 0) - - ``` - reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher" /f /v "HideExplorerSearchBar" /t REG_DWORD /d 1 - ``` - -* `HideControlCenterButton` disables the Control Center button and its associated shortcut key (`Win`+`A`) (default = 0) - - ``` - reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher" /f /v "HideControlCenterButton" /t REG_DWORD /d 1 - ``` - -* `SkinMenus` applies the immersive skin to "Safe to Remove Hardware" and "Bluetooth" pop-up menus (default = 1) - - ``` - reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher" /f /v "SkinMenus" /t REG_DWORD /d 1 - ``` - -* `ReplaceNetwork` makes right clicking the system tray network icon and choosing "Open Network & Internet settings" open the "Network and Sharing Center" page in Control Panel instead of the network section of the Settings app (default = 0) - - ``` - reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher" /f /v "ReplaceNetwork" /t REG_DWORD /d 1 - ``` - -* `AllocConsole` will display a console window (for debugging purposes) (default = 0, for advanced users only) - - ``` - reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher" /f /v "AllocConsole" /t REG_DWORD /d 1 - ``` - -* `ExplorerReadyDelay` adds even more delay before the shell is announced that Explorer is ready loading (helps if you experience a delay at logon) - the unit is ms (milliseconds), 1000ms = 1 second (default = 0, for advanced users only) - - ``` - reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ExplorerPatcher" /f /v "ExplorerReadyDelay" /t REG_DWORD /d 1000 - ``` - -Also, if you chose to place the patcher in `C:\Windows\SystemApps\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy` as well, use the following commands to configure Start menu options: - -* Open Start menu to "All apps" directly (replace with 0 to disable) - - ``` - reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\StartPage" /f /v "MakeAllAppsDefault" /t REG_DWORD /d 1 - ``` - -* Show only 4 most recent apps (change the number to customize) +You can manually configure the application by setting registry values. The registry entries supported by this application are described in [this file](https://github.com/valinet/ExplorerPatcher/blob/master/ExplorerPatcher/settings.reg). - ``` - reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /f /v "Start_MaximumFrequentApps" /t REG_DWORD /d 4 - ``` ## More configuration Even more registry configuration settings are described in the following document, make sure to take a look on it [here](https://github.com/valinet/ExplorerPatcher/issues/9). diff --git a/libs/sws b/libs/sws new file mode 160000 index 0000000..52572a5 --- /dev/null +++ b/libs/sws @@ -0,0 +1 @@ +Subproject commit 52572a5d458bef414812a3c32836530d0a857514