1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2024-11-23 23:21:08 +01:00

All: Fixes for Windows 10

This commit is contained in:
Valentin Radu 2022-02-21 02:42:35 +02:00
parent 52cee9ebbb
commit 2cc9b0ed7f
9 changed files with 356 additions and 165 deletions

View File

@ -914,6 +914,12 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
SetTextColor(hdcPaint, GetSysColor(COLOR_WINDOWTEXT));
SetBkMode(hdcPaint, TRANSPARENT);
}
else if (!IsWindows11() && hDC)
{
COLORREF oldcr = SetBkColor(hdcPaint, g_darkModeEnabled ? RGB(0, 0, 0) : RGB(255, 255, 255));
ExtTextOutW(hdcPaint, 0, 0, ETO_OPAQUE, &rc, L"", 0, 0);
SetBkColor(hdcPaint, oldcr);
}
BOOL bResetLastHeading = TRUE;
BOOL bWasSpecifiedSectionValid = FALSE;
@ -939,7 +945,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
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) || AuditFile) &&
!((!IsThemeActive() || IsHighContrast()) && !strncmp(line, ";M ", 3))
!((!IsThemeActive() || IsHighContrast() || !IsWindows11()) && !strncmp(line, ";M ", 3))
)
{
#ifndef USE_PRIVATE_INTERFACES
@ -2960,7 +2966,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
printf("%d %d - %d %d\n", rcWin.right - rcWin.left, rcWin.bottom - rcWin.top, dwMaxWidth, dwMaxHeight);
dwMaxWidth += dwInitialLeftPad + _this->padding.left + _this->padding.right;
if (!IsThemeActive() || IsHighContrast())
if (!IsThemeActive() || IsHighContrast() || !IsWindows11())
{
dwMaxHeight += GUI_LINE_HEIGHT * dy + 20 * dy;
}
@ -2983,68 +2989,75 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
SWP_NOZORDER | SWP_NOACTIVATE | (_this->bCalcExtent == 2 ? SWP_NOMOVE : 0)
);
DWORD dwReadSection = 0;
if (_this->bCalcExtent != 2)
{
DWORD dwReadSection = 0;
HKEY hKey = NULL;
DWORD dwSize = sizeof(DWORD);
RegCreateKeyExW(
HKEY_CURRENT_USER,
TEXT(REGPATH),
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_READ | KEY_WOW64_64KEY | KEY_WRITE,
NULL,
&hKey,
NULL
);
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
{
hKey = NULL;
}
if (hKey)
{
dwReadSection = 0;
dwSize = sizeof(DWORD);
RegQueryValueExW(
hKey,
TEXT("LastSectionInProperties"),
HKEY hKey = NULL;
DWORD dwSize = sizeof(DWORD);
RegCreateKeyExW(
HKEY_CURRENT_USER,
TEXT(REGPATH),
0,
NULL,
&dwReadSection,
&dwSize
REG_OPTION_NON_VOLATILE,
KEY_READ | KEY_WOW64_64KEY | KEY_WRITE,
NULL,
&hKey,
NULL
);
if (dwReadSection)
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
{
_this->section = dwReadSection - 1;
hKey = NULL;
}
dwReadSection = 0;
dwSize = sizeof(DWORD);
RegQueryValueExW(
hKey,
TEXT("OpenPropertiesAtNextStart"),
0,
NULL,
&dwReadSection,
&dwSize
);
if (dwReadSection)
if (hKey)
{
_this->section = dwReadSection - 1;
dwReadSection = 0;
RegSetValueExW(
dwSize = sizeof(DWORD);
RegQueryValueExW(
hKey,
TEXT("LastSectionInProperties"),
0,
NULL,
&dwReadSection,
&dwSize
);
if (dwReadSection)
{
_this->section = dwReadSection - 1;
}
dwReadSection = 0;
dwSize = sizeof(DWORD);
RegQueryValueExW(
hKey,
TEXT("OpenPropertiesAtNextStart"),
0,
REG_DWORD,
NULL,
&dwReadSection,
sizeof(DWORD)
&dwSize
);
if (dwReadSection)
{
_this->section = dwReadSection - 1;
dwReadSection = 0;
RegSetValueExW(
hKey,
TEXT("OpenPropertiesAtNextStart"),
0,
REG_DWORD,
&dwReadSection,
sizeof(DWORD)
);
}
RegCloseKey(hKey);
}
RegCloseKey(hKey);
}
_this->bCalcExtent = FALSE;
if (_this->bCalcExtent == 2)
{
_this->section = _this->last_section;
}
_this->bCalcExtent = 0;
InvalidateRect(hwnd, NULL, FALSE);
}
@ -3085,7 +3098,7 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
_this->dpi.x = dpiX;
_this->dpi.y = dpiY;
SetRect(&_this->border_thickness, 2, 2, 2, 2);
if (IsThemeActive())
if (IsThemeActive() && IsWindows11())
{
BOOL bIsCompositionEnabled = TRUE;
DwmIsCompositionEnabled(&bIsCompositionEnabled);
@ -3119,7 +3132,7 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED
);
SetTimer(hWnd, GUI_TIMER_READ_HELP, GUI_TIMER_READ_HELP_TIMEOUT, NULL);
if (IsThemeActive() && !IsHighContrast())
if (IsThemeActive() && !IsHighContrast() && IsWindows11())
{
RECT rcTitle;
DwmGetWindowAttribute(hWnd, DWMWA_CAPTION_BUTTON_BOUNDS, &rcTitle, sizeof(RECT));
@ -3133,9 +3146,16 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
{
AllowDarkModeForWindow(hWnd, g_darkModeEnabled);
BOOL value = g_darkModeEnabled;
DwmSetWindowAttribute(hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &value, sizeof(BOOL));
RTL_OSVERSIONINFOW rovi;
DWORD32 ubr = VnGetOSVersionAndUBR(&rovi);
int s = 0;
if (rovi.dwBuildNumber < 18985)
{
s = -1;
}
DwmSetWindowAttribute(hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE + s, &value, sizeof(BOOL));
}
if (!IsThemeActive() || IsHighContrast())
if (!IsThemeActive() || IsHighContrast() || !IsWindows11())
{
int extendedStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
SetWindowLong(hWnd, GWL_EXSTYLE, extendedStyle | WS_EX_DLGMODALFRAME);
@ -3159,7 +3179,7 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
{
if (IsColorSchemeChangeMessage(lParam))
{
if (IsThemeActive())
if (IsThemeActive() && IsWindows11())
{
BOOL bIsCompositionEnabled = TRUE;
DwmIsCompositionEnabled(&bIsCompositionEnabled);
@ -3183,12 +3203,11 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
DwmExtendFrameIntoClientArea(hWnd, &marGlassInset);
}
}
_this->bCalcExtent = 2;
BOOL bIsCompositionEnabled = TRUE;
DwmIsCompositionEnabled(&bIsCompositionEnabled);
if (bIsCompositionEnabled)
{
BOOL value = (IsThemeActive() && !IsHighContrast()) ? 1 : 0;
BOOL value = (IsThemeActive() && !IsHighContrast() && IsWindows11()) ? 1 : 0;
DwmSetWindowAttribute(hWnd, DWMWA_MICA_EFFFECT, &value, sizeof(BOOL));
}
if (IsThemeActive() && ShouldAppsUseDarkMode && !IsHighContrast())
@ -3200,12 +3219,25 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
g_darkModeEnabled = bDarkModeEnabled;
AllowDarkModeForWindow(hWnd, g_darkModeEnabled);
BOOL value = g_darkModeEnabled;
DwmSetWindowAttribute(hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &value, sizeof(BOOL));
RTL_OSVERSIONINFOW rovi;
DWORD32 ubr = VnGetOSVersionAndUBR(&rovi);
int s = 0;
if (rovi.dwBuildNumber < 18985)
{
s = -1;
}
DwmSetWindowAttribute(hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE + s, &value, sizeof(BOOL));
_this->bCalcExtent = 2;
_this->last_section = _this->section;
_this->section = 0;
InvalidateRect(hWnd, NULL, FALSE);
}
}
else
{
_this->bCalcExtent = 2;
_this->last_section = _this->section;
_this->section = 0;
InvalidateRect(hWnd, NULL, FALSE);
}
}
@ -3316,7 +3348,7 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
return 0;
}
}
else if (uMsg == WM_NCMOUSELEAVE && IsThemeActive() && !IsHighContrast())
else if (uMsg == WM_NCMOUSELEAVE && IsThemeActive() && !IsHighContrast() && IsWindows11())
{
LRESULT lRes = 0;
if (DwmDefWindowProc(hWnd, uMsg, wParam, lParam, &lRes))
@ -3324,7 +3356,7 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
return lRes;
}
}
else if (uMsg == WM_NCRBUTTONUP && IsThemeActive() && !IsHighContrast())
else if (uMsg == WM_NCRBUTTONUP && IsThemeActive() && !IsHighContrast() && IsWindows11())
{
HMENU pSysMenu = GetSystemMenu(hWnd, FALSE);
if (pSysMenu != NULL)
@ -3342,7 +3374,7 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
}
return 0;
}
else if ((uMsg == WM_LBUTTONUP || uMsg == WM_RBUTTONUP) && IsThemeActive() && !IsHighContrast())
else if ((uMsg == WM_LBUTTONUP || uMsg == WM_RBUTTONUP) && IsThemeActive() && !IsHighContrast() && IsWindows11())
{
POINT pt;
pt.x = GET_X_LPARAM(lParam);
@ -3398,7 +3430,7 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
return 0;
}
}
else if (uMsg == WM_NCHITTEST && IsThemeActive() && !IsHighContrast())
else if (uMsg == WM_NCHITTEST && IsThemeActive() && !IsHighContrast() && IsWindows11())
{
LRESULT lRes = 0;
if (DwmDefWindowProc(hWnd, uMsg, wParam, lParam, &lRes))
@ -3425,7 +3457,7 @@ static LRESULT CALLBACK GUI_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
return HTCAPTION;
}
}
else if (uMsg == WM_NCCALCSIZE && wParam == TRUE && IsThemeActive() && !IsHighContrast())
else if (uMsg == WM_NCCALCSIZE && wParam == TRUE && IsThemeActive() && !IsHighContrast() && IsWindows11())
{
NCCALCSIZE_PARAMS* sz = (NCCALCSIZE_PARAMS*)(lParam);
sz->rgrc[0].left += _this->border_thickness.left;
@ -3769,7 +3801,7 @@ __declspec(dllexport) int ZZGUI(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLin
);
}
if (IsThemeActive() && !IsHighContrast())
if (IsThemeActive() && !IsHighContrast() && IsWindows11())
{
if (bIsCompositionEnabled)
{

View File

@ -85,6 +85,7 @@ typedef struct _GUI
WCHAR sectionNames[20][20];
BOOL bRebuildIfTabOrderIsEmpty;
int dwPageLocation;
DWORD last_section;
} GUI;
static HRESULT GUI_AboutProc(

View File

@ -4234,7 +4234,8 @@ __int64 __fastcall PeopleBand_DrawTextWithGlowHook(
COLORREF rgbColor = RGB(0, 0, 0);
if (bIsThemeActive)
{
if (ShouldSystemUseDarkMode && ShouldSystemUseDarkMode())
RTL_OSVERSIONINFOW rovi;
if ((VnGetOSVersion(&rovi) && rovi.dwBuildNumber < 18985) || (ShouldSystemUseDarkMode && ShouldSystemUseDarkMode()))
{
rgbColor = RGB(255, 255, 255);
}
@ -4660,20 +4661,31 @@ BOOL explorer_SetChildWindowNoActivateHook(HWND hWnd)
uintptr_t Instance = *(uintptr_t*)GetWindowLongPtrW(hWnd, 0);
if (Instance)
{
uintptr_t off_TrayButton_GetComponentName = 0;
if (IsWindows11())
uintptr_t TrayButton_GetComponentName = *(INT_PTR(WINAPI**)())(Instance + 304); // 280 in versions of Windows 10 where this method exists
wchar_t* wszComponentName = NULL;
if (IsWindows11() && !IsBadCodePtr(TrayButton_GetComponentName))
{
off_TrayButton_GetComponentName = 304;
wszComponentName = (const WCHAR*)(*(uintptr_t(**)(void))(Instance + 304))();
}
else
{
off_TrayButton_GetComponentName = 280;
WCHAR title[MAX_PATH];
GetWindowTextW(hWnd, title, MAX_PATH);
WCHAR pbtitle[MAX_PATH];
HMODULE hPeopleBand = LoadLibraryExW(L"PeopleBand.dll", NULL, LOAD_LIBRARY_AS_DATAFILE);
if (hPeopleBand)
{
LoadStringW(hPeopleBand, 256, pbtitle, 260);
FreeLibrary(hPeopleBand);
}
if (!wcscmp(pbtitle, title))
{
wszComponentName = L"PeopleButton";
}
}
uintptr_t TrayButton_GetComponentName = *(INT_PTR(WINAPI**)())(Instance + off_TrayButton_GetComponentName);
if (!IsBadCodePtr(TrayButton_GetComponentName))
if (wszComponentName)
{
wchar_t* wszComponentName = (const WCHAR*)(*(uintptr_t(**)(void))(Instance + off_TrayButton_GetComponentName))();
if (!wcscmp(wszComponentName, L"CortanaButton") && IsWindows11())
if (!wcscmp(wszComponentName, L"CortanaButton"))
{
DWORD dwOldProtect;
VirtualProtect(Instance + 160, sizeof(uintptr_t), PAGE_READWRITE, &dwOldProtect);
@ -4685,7 +4697,7 @@ BOOL explorer_SetChildWindowNoActivateHook(HWND hWnd)
*(uintptr_t*)(Instance + 216) = Widgets_GetTooltipTextHook; // OnTooltipShow
VirtualProtect(Instance + 216, sizeof(uintptr_t), dwOldProtect, &dwOldProtect);
}
else if (!wcscmp(wszComponentName, L"MultitaskingButton") && IsWindows11())
else if (!wcscmp(wszComponentName, L"MultitaskingButton"))
{
DWORD dwOldProtect;
VirtualProtect(Instance + 160, sizeof(uintptr_t), PAGE_READWRITE, &dwOldProtect);
@ -7831,107 +7843,122 @@ DWORD InjectBasicFunctions(BOOL bIsExplorer, BOOL bInstall)
//Sleep(150);
HMODULE hShlwapi = LoadLibraryW(L"Shlwapi.dll");
if (bInstall)
if (hShlwapi)
{
SHRegGetValueFromHKCUHKLMFunc = GetProcAddress(hShlwapi, "SHRegGetValueFromHKCUHKLM");
}
else
{
FreeLibrary(hShlwapi);
FreeLibrary(hShlwapi);
if (bInstall)
{
SHRegGetValueFromHKCUHKLMFunc = GetProcAddress(hShlwapi, "SHRegGetValueFromHKCUHKLM");
}
else
{
FreeLibrary(hShlwapi);
FreeLibrary(hShlwapi);
}
}
HANDLE hShell32 = LoadLibraryW(L"shell32.dll");
if (bInstall)
if (hShell32)
{
VnPatchIAT(hShell32, "user32.dll", "TrackPopupMenu", TrackPopupMenuHook);
VnPatchIAT(hShell32, "user32.dll", "SystemParametersInfoW", DisableImmersiveMenus_SystemParametersInfoW);
if (!bIsExplorer)
if (bInstall)
{
CreateWindowExWFunc = CreateWindowExW;
VnPatchIAT(hShell32, "user32.dll", "CreateWindowExW", CreateWindowExWHook);
SetWindowLongPtrWFunc = SetWindowLongPtrW;
VnPatchIAT(hShell32, "user32.dll", "SetWindowLongPtrW", SetWindowLongPtrWHook);
VnPatchIAT(hShell32, "user32.dll", "TrackPopupMenu", TrackPopupMenuHook);
VnPatchIAT(hShell32, "user32.dll", "SystemParametersInfoW", DisableImmersiveMenus_SystemParametersInfoW);
if (!bIsExplorer)
{
CreateWindowExWFunc = CreateWindowExW;
VnPatchIAT(hShell32, "user32.dll", "CreateWindowExW", CreateWindowExWHook);
SetWindowLongPtrWFunc = SetWindowLongPtrW;
VnPatchIAT(hShell32, "user32.dll", "SetWindowLongPtrW", SetWindowLongPtrWHook);
}
}
}
else
{
VnPatchIAT(hShell32, "user32.dll", "TrackPopupMenu", TrackPopupMenu);
VnPatchIAT(hShell32, "user32.dll", "SystemParametersInfoW", SystemParametersInfoW);
if (!bIsExplorer)
else
{
VnPatchIAT(hShell32, "user32.dll", "CreateWindowExW", CreateWindowExW);
VnPatchIAT(hShell32, "user32.dll", "SetWindowLongPtrW", SetWindowLongPtrW);
VnPatchIAT(hShell32, "user32.dll", "TrackPopupMenu", TrackPopupMenu);
VnPatchIAT(hShell32, "user32.dll", "SystemParametersInfoW", SystemParametersInfoW);
if (!bIsExplorer)
{
VnPatchIAT(hShell32, "user32.dll", "CreateWindowExW", CreateWindowExW);
VnPatchIAT(hShell32, "user32.dll", "SetWindowLongPtrW", SetWindowLongPtrW);
}
FreeLibrary(hShell32);
FreeLibrary(hShell32);
}
FreeLibrary(hShell32);
FreeLibrary(hShell32);
}
HANDLE hShcore = LoadLibraryW(L"shcore.dll");
if (bInstall)
if (hShcore)
{
explorerframe_SHCreateWorkerWindowFunc = GetProcAddress(hShcore, (LPCSTR)188);
}
else
{
FreeLibrary(hShcore);
FreeLibrary(hShcore);
if (bInstall)
{
explorerframe_SHCreateWorkerWindowFunc = GetProcAddress(hShcore, (LPCSTR)188);
}
else
{
FreeLibrary(hShcore);
FreeLibrary(hShcore);
}
}
HANDLE hExplorerFrame = LoadLibraryW(L"ExplorerFrame.dll");
if (bInstall)
if (hExplorerFrame)
{
VnPatchIAT(hExplorerFrame, "user32.dll", "TrackPopupMenu", TrackPopupMenuHook);
VnPatchIAT(hExplorerFrame, "user32.dll", "SystemParametersInfoW", DisableImmersiveMenus_SystemParametersInfoW);
VnPatchIAT(hExplorerFrame, "shcore.dll", (LPCSTR)188, explorerframe_SHCreateWorkerWindowHook); // <<<SAB>>>
if (!bIsExplorer)
if (bInstall)
{
CreateWindowExWFunc = CreateWindowExW;
VnPatchIAT(hExplorerFrame, "user32.dll", "CreateWindowExW", CreateWindowExWHook);
SetWindowLongPtrWFunc = SetWindowLongPtrW;
VnPatchIAT(hExplorerFrame, "user32.dll", "SetWindowLongPtrW", SetWindowLongPtrWHook);
VnPatchIAT(hExplorerFrame, "user32.dll", "TrackPopupMenu", TrackPopupMenuHook);
VnPatchIAT(hExplorerFrame, "user32.dll", "SystemParametersInfoW", DisableImmersiveMenus_SystemParametersInfoW);
VnPatchIAT(hExplorerFrame, "shcore.dll", (LPCSTR)188, explorerframe_SHCreateWorkerWindowHook); // <<<SAB>>>
if (!bIsExplorer)
{
CreateWindowExWFunc = CreateWindowExW;
VnPatchIAT(hExplorerFrame, "user32.dll", "CreateWindowExW", CreateWindowExWHook);
SetWindowLongPtrWFunc = SetWindowLongPtrW;
VnPatchIAT(hExplorerFrame, "user32.dll", "SetWindowLongPtrW", SetWindowLongPtrWHook);
}
VnPatchIAT(hExplorerFrame, "API-MS-WIN-CORE-STRING-L1-1-0.DLL", "CompareStringOrdinal", ExplorerFrame_CompareStringOrdinal);
}
VnPatchIAT(hExplorerFrame, "API-MS-WIN-CORE-STRING-L1-1-0.DLL", "CompareStringOrdinal", ExplorerFrame_CompareStringOrdinal);
}
else
{
VnPatchIAT(hExplorerFrame, "user32.dll", "TrackPopupMenu", TrackPopupMenu);
VnPatchIAT(hExplorerFrame, "user32.dll", "SystemParametersInfoW", SystemParametersInfoW);
VnPatchIAT(hExplorerFrame, "shcore.dll", (LPCSTR)188, explorerframe_SHCreateWorkerWindowFunc);
if (!bIsExplorer)
else
{
VnPatchIAT(hExplorerFrame, "user32.dll", "CreateWindowExW", CreateWindowExW);
VnPatchIAT(hExplorerFrame, "user32.dll", "SetWindowLongPtrW", SetWindowLongPtrW);
VnPatchIAT(hExplorerFrame, "user32.dll", "TrackPopupMenu", TrackPopupMenu);
VnPatchIAT(hExplorerFrame, "user32.dll", "SystemParametersInfoW", SystemParametersInfoW);
VnPatchIAT(hExplorerFrame, "shcore.dll", (LPCSTR)188, explorerframe_SHCreateWorkerWindowFunc);
if (!bIsExplorer)
{
VnPatchIAT(hExplorerFrame, "user32.dll", "CreateWindowExW", CreateWindowExW);
VnPatchIAT(hExplorerFrame, "user32.dll", "SetWindowLongPtrW", SetWindowLongPtrW);
}
VnPatchIAT(hExplorerFrame, "API-MS-WIN-CORE-STRING-L1-1-0.DLL", "CompareStringOrdinal", CompareStringOrdinal);
FreeLibrary(hExplorerFrame);
FreeLibrary(hExplorerFrame);
}
VnPatchIAT(hExplorerFrame, "API-MS-WIN-CORE-STRING-L1-1-0.DLL", "CompareStringOrdinal", CompareStringOrdinal);
FreeLibrary(hExplorerFrame);
FreeLibrary(hExplorerFrame);
}
HANDLE hWindowsUIFileExplorer = LoadLibraryW(L"Windows.UI.FileExplorer.dll");
if (hWindowsUIFileExplorer)
{
VnPatchDelayIAT(hWindowsUIFileExplorer, "user32.dll", "TrackPopupMenu", TrackPopupMenuHook);
VnPatchDelayIAT(hWindowsUIFileExplorer, "user32.dll", "SystemParametersInfoW", DisableImmersiveMenus_SystemParametersInfoW);
if (!bIsExplorer)
if (bInstall)
{
CreateWindowExWFunc = CreateWindowExW;
VnPatchIAT(hWindowsUIFileExplorer, "user32.dll", "CreateWindowExW", CreateWindowExWHook);
SetWindowLongPtrWFunc = SetWindowLongPtrW;
VnPatchIAT(hWindowsUIFileExplorer, "user32.dll", "SetWindowLongPtrW", SetWindowLongPtrWHook);
VnPatchDelayIAT(hWindowsUIFileExplorer, "user32.dll", "TrackPopupMenu", TrackPopupMenuHook);
VnPatchDelayIAT(hWindowsUIFileExplorer, "user32.dll", "SystemParametersInfoW", DisableImmersiveMenus_SystemParametersInfoW);
if (!bIsExplorer)
{
CreateWindowExWFunc = CreateWindowExW;
VnPatchIAT(hWindowsUIFileExplorer, "user32.dll", "CreateWindowExW", CreateWindowExWHook);
SetWindowLongPtrWFunc = SetWindowLongPtrW;
VnPatchIAT(hWindowsUIFileExplorer, "user32.dll", "SetWindowLongPtrW", SetWindowLongPtrWHook);
}
}
}
else
{
VnPatchDelayIAT(hWindowsUIFileExplorer, "user32.dll", "TrackPopupMenu", TrackPopupMenu);
VnPatchDelayIAT(hWindowsUIFileExplorer, "user32.dll", "SystemParametersInfoW", SystemParametersInfoW);
if (!bIsExplorer)
else
{
VnPatchIAT(hWindowsUIFileExplorer, "user32.dll", "CreateWindowExW", CreateWindowExW);
VnPatchIAT(hWindowsUIFileExplorer, "user32.dll", "SetWindowLongPtrW", SetWindowLongPtrW);
VnPatchDelayIAT(hWindowsUIFileExplorer, "user32.dll", "TrackPopupMenu", TrackPopupMenu);
VnPatchDelayIAT(hWindowsUIFileExplorer, "user32.dll", "SystemParametersInfoW", SystemParametersInfoW);
if (!bIsExplorer)
{
VnPatchIAT(hWindowsUIFileExplorer, "user32.dll", "CreateWindowExW", CreateWindowExW);
VnPatchIAT(hWindowsUIFileExplorer, "user32.dll", "SetWindowLongPtrW", SetWindowLongPtrW);
}
FreeLibrary(hWindowsUIFileExplorer);
FreeLibrary(hWindowsUIFileExplorer);
}
FreeLibrary(hWindowsUIFileExplorer);
FreeLibrary(hWindowsUIFileExplorer);
}
}

View File

@ -185,10 +185,9 @@
"SwitcherIsPerApplication"=dword:00000000
;b %PLACEHOLDER_0001%
"NoPerApplicationList"=dword:00000000
;c 3 Theme
;c 2 Theme
;x 0 Default
;x 1 Acrylic
;x 2 Mica (always opaque)
"Theme"=dword:00000000
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MultitaskingView\AltTabViewHost]
;c 19 Opacity

View File

@ -567,8 +567,7 @@ LRESULT CALLBACK PleaseWait_HookProc(int code, WPARAM wParam, LPARAM lParam);
inline BOOL IsWindows11()
{
RTL_OSVERSIONINFOW rovi;
DWORD32 ubr = VnGetOSVersionAndUBR(&rovi);
if (rovi.dwBuildNumber >= 21996)
if (VnGetOSVersion(&rovi) && rovi.dwBuildNumber >= 21996)
{
return TRUE;
}

View File

@ -805,7 +805,7 @@ int WINAPI wWinMain(
{
bOk = GetWindowsDirectoryW(wszPath, MAX_PATH);
}
if (bOk)
if (bOk && IsWindows11())
{
wcscat_s(wszPath, MAX_PATH, L"\\SystemApps\\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\\dxgi.dll");
bOk = InstallResource(bInstall, hInstance, IDR_EP_AMD64, wszPath);
@ -814,7 +814,7 @@ int WINAPI wWinMain(
{
bOk = GetWindowsDirectoryW(wszPath, MAX_PATH);
}
if (bOk)
if (bOk && IsWindows11())
{
wcscat_s(wszPath, MAX_PATH, L"\\SystemApps\\ShellExperienceHost_cw5n1h2txyewy\\dxgi.dll");
bOk = InstallResource(bInstall, hInstance, IDR_EP_AMD64, wszPath);

View File

@ -846,10 +846,24 @@ LRESULT CALLBACK epw_Weather_WindowProc(_In_ HWND hWnd, _In_ UINT uMsg, _In_ WPA
marGlassInset.cyBottomHeight = 0;
marGlassInset.cyTopHeight = 0;
}
DwmExtendFrameIntoClientArea(_this->hWnd, &marGlassInset);
BOOL value = (IsThemeActive() && !IsHighContrast()) ? 1 : 0;
DwmSetWindowAttribute(hWnd, 1029, &value, sizeof(BOOL));
LONG64 dwDarkMode = InterlockedAdd64(&_this->g_darkModeEnabled, 0);
if (IsWindows11())
{
DwmExtendFrameIntoClientArea(_this->hWnd, &marGlassInset);
BOOL value = (IsThemeActive() && !IsHighContrast()) ? 1 : 0;
DwmSetWindowAttribute(_this->hWnd, 1029, &value, sizeof(BOOL));
}
else
{
RTL_OSVERSIONINFOW rovi;
DWORD32 ubr = GetOSVersionAndUBR(&rovi);
int s = 0;
if (rovi.dwBuildNumber < 18985)
{
s = -1;
}
DwmSetWindowAttribute(_this->hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE + s, &dwDarkMode, sizeof(LONG64));
}
if (!dwDarkMode)
{
epw_Weather_SetDarkMode(_this, dwDarkMode, TRUE);
@ -865,7 +879,22 @@ LRESULT CALLBACK epw_Weather_WindowProc(_In_ HWND hWnd, _In_ UINT uMsg, _In_ WPA
SetWindowPos(_this->hWnd, NULL, rc->left, rc->top, w, rc->bottom - rc->top, 0);
return 0;
}
else if (uMsg == WM_PAINT && !IsWindows11())
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
if (ps.fErase)
{
LONG64 bEnabled, dwDarkMode;
dwDarkMode = InterlockedAdd64(&_this->g_darkModeEnabled, 0);
epw_Weather_IsDarkMode(_this, dwDarkMode, &bEnabled);
COLORREF oldcr = SetBkColor(hdc, bEnabled ? RGB(0, 0, 0) : RGB(255, 255, 255));
ExtTextOutW(hdc, 0, 0, ETO_OPAQUE, &ps.rcPaint, L"", 0, 0);
SetBkColor(hdc, oldcr);
}
EndPaint(hWnd, &ps);
return 0;
}
/*BOOL bIsRunningWithoutVisualStyle = !IsThemeActive() || IsHighContrast();
if (uMsg == WM_CREATE)
{
@ -939,7 +968,8 @@ HRESULT STDMETHODCALLTYPE epw_Weather_IsDarkMode(EPWeather* _this, LONG64 dwDark
DwmIsCompositionEnabled(&bIsCompositionEnabled);
if (!dwDarkMode)
{
*bEnabled = bIsCompositionEnabled && (ShouldSystemUseDarkMode ? ShouldSystemUseDarkMode() : FALSE) && !IsHighContrast();
RTL_OSVERSIONINFOW rovi;
*bEnabled = bIsCompositionEnabled && ((GetOSVersion(&rovi) && rovi.dwBuildNumber < 18985) ? TRUE : (ShouldSystemUseDarkMode ? ShouldSystemUseDarkMode() : FALSE)) && !IsHighContrast();
}
else
{
@ -959,7 +989,14 @@ HRESULT STDMETHODCALLTYPE epw_Weather_SetDarkMode(EPWeather* _this, LONG64 dwDar
if (_this->hWnd)
{
AllowDarkModeForWindow(_this->hWnd, bEnabled);
DwmSetWindowAttribute(_this->hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &bEnabled, sizeof(BOOL));
RTL_OSVERSIONINFOW rovi;
DWORD32 ubr = GetOSVersionAndUBR(&rovi);
int s = 0;
if (rovi.dwBuildNumber < 18985)
{
s = -1;
}
DwmSetWindowAttribute(_this->hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE + s, &bEnabled, sizeof(BOOL));
//InvalidateRect(_this->hWnd, NULL, FALSE);
PostMessageW(_this->hWnd, EP_WEATHER_WM_SET_BROWSER_THEME, bEnabled, bRefresh);
}
@ -1016,7 +1053,7 @@ DWORD WINAPI epw_Weather_MainThread(EPWeather* _this)
wc.style = CS_DBLCLKS;
wc.lpfnWndProc = epw_Weather_WindowProc;
wc.hInstance = epw_hModule;
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.hbrBackground = IsWindows11() ? (HBRUSH)GetStockObject(BLACK_BRUSH) : NULL;
wc.lpszClassName = _T(EPW_WEATHER_CLASSNAME);
wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
if (!RegisterClassW(&wc))
@ -1051,14 +1088,28 @@ DWORD WINAPI epw_Weather_MainThread(EPWeather* _this)
goto cleanup;
}
if (!IsHighContrast())
{
MARGINS marGlassInset = { -1, -1, -1, -1 }; // -1 means the whole window
DwmExtendFrameIntoClientArea(_this->hWnd, &marGlassInset);
BOOL value = 1;
DwmSetWindowAttribute(_this->hWnd, 1029, &value, sizeof(BOOL));
}
LONG64 dwDarkMode = InterlockedAdd64(&_this->g_darkModeEnabled, 0);
if (IsWindows11())
{
if (!IsHighContrast())
{
MARGINS marGlassInset = { -1, -1, -1, -1 }; // -1 means the whole window
DwmExtendFrameIntoClientArea(_this->hWnd, &marGlassInset);
BOOL value = 1;
DwmSetWindowAttribute(_this->hWnd, 1029, &value, sizeof(BOOL));
}
}
else
{
RTL_OSVERSIONINFOW rovi;
DWORD32 ubr = GetOSVersionAndUBR(&rovi);
int s = 0;
if (rovi.dwBuildNumber < 18985)
{
s = -1;
}
DwmSetWindowAttribute(_this->hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE + s, &dwDarkMode, sizeof(LONG64));
}
epw_Weather_SetDarkMode(_this, dwDarkMode, FALSE);
InterlockedExchange64(&_this->bBrowserBusy, TRUE);

View File

@ -60,4 +60,86 @@ inline void QueryVersionInfo(HMODULE hModule, WORD Resource, DWORD* dwLeftMost,
LocalFree(pResCopy);
}
#define OSVERSION_INVALID 0xffffffff
typedef LONG NTSTATUS, * PNTSTATUS;
#define STATUS_SUCCESS (0x00000000)
typedef NTSTATUS(WINAPI* VnRtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
// https://stackoverflow.com/questions/36543301/detecting-windows-10-version/36543774#36543774
inline BOOL GetOSVersion(PRTL_OSVERSIONINFOW lpRovi)
{
HMODULE hMod = GetModuleHandleW(L"ntdll.dll");
if (hMod != NULL)
{
VnRtlGetVersionPtr fxPtr = (VnRtlGetVersionPtr)GetProcAddress(
hMod,
"RtlGetVersion"
);
if (fxPtr != NULL)
{
lpRovi->dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOW);
if (STATUS_SUCCESS == fxPtr(lpRovi))
{
return TRUE;
}
}
}
return FALSE;
}
// https://stackoverflow.com/questions/47926094/detecting-windows-10-os-build-minor-version
inline DWORD32 GetUBR()
{
DWORD32 ubr = 0, ubr_size = sizeof(DWORD32);
HKEY hKey;
LONG lRes = RegOpenKeyExW(
HKEY_LOCAL_MACHINE,
wcschr(
wcschr(
wcschr(
UNIFIEDBUILDREVISION_KEY,
'\\'
) + 1,
'\\'
) + 1,
'\\'
) + 1,
0,
KEY_READ,
&hKey
);
if (lRes == ERROR_SUCCESS)
{
RegQueryValueExW(
hKey,
UNIFIEDBUILDREVISION_VALUE,
0,
NULL,
&ubr,
&ubr_size
);
}
}
inline DWORD32 GetOSVersionAndUBR(PRTL_OSVERSIONINFOW lpRovi)
{
if (!GetOSVersion(lpRovi))
{
return OSVERSION_INVALID;
}
return GetUBR();
}
inline BOOL IsWindows11()
{
RTL_OSVERSIONINFOW rovi;
if (GetOSVersion(&rovi) && rovi.dwBuildNumber >= 21996)
{
return TRUE;
}
return FALSE;
}
#endif

@ -1 +1 @@
Subproject commit 6fdceae19a8f4339cd59618b3bbd35dac574ac34
Subproject commit 1778125faba51fa23b500efd2f0404c87b701e23